phaser/typescript/pixi.comments.d.ts

3496 lines
98 KiB
TypeScript
Raw Normal View History

2016-07-01 15:57:13 +00:00
// Type definitions for PIXI with Phaser Deviations.
declare module PIXI {
export var game: Phaser.Game;
export var WEBGL_RENDERER: number;
export var CANVAS_RENDERER: number;
export var VERSION: string;
export enum blendModes {
NORMAL,
ADD,
MULTIPLY,
SCREEN,
OVERLAY,
DARKEN,
LIGHTEN,
COLOR_DODGE,
COLOR_BURN,
HARD_LIGHT,
SOFT_LIGHT,
DIFFERENCE,
EXCLUSION,
HUE,
SATURATION,
COLOR,
LUMINOSITY
}
export enum scaleModes {
DEFAULT,
LINEAR,
NEAREST
}
export var defaultRenderOptions: PixiRendererOptions;
export var INTERACTION_REQUENCY: number;
export var AUTO_PREVENT_DEFAULT: boolean;
export var PI_2: number;
export var RAD_TO_DEG: number;
export var DEG_TO_RAD: number;
export var RETINA_PREFIX: string;
export var identityMatrix: Matrix;
export var glContexts: WebGLRenderingContext[];
export var instances: any[];
export var TextureSilentFail: boolean;
export var BitmapText: { fonts: {} };
export function isPowerOfTwo(width: number, height: number): boolean;
export function rgb2hex(rgb: number[]): string;
export function hex2rgb(hex: string): number[];
export function autoDetectRenderer(width?: number, height?: number, options?: PixiRendererOptions): PixiRenderer;
export function autoDetectRecommendedRenderer(width?: number, height?: number, options?: PixiRendererOptions): PixiRenderer;
export function canUseNewCanvasBlendModes(): boolean;
export function getNextPowerOfTwo(value: number): number;
export function AjaxRequest(): XMLHttpRequest;
export function CompileFragmentShader(gl: WebGLRenderingContext, shaderSrc: string[]): any;
export function CompileProgram(gl: WebGLRenderingContext, vertexSrc: string[], fragmentSrc: string[]): any;
export interface IEventCallback {
(e?: IEvent): void;
}
export interface IEvent {
type: string;
content: any;
}
export interface HitArea {
contains(x: number, y: number): boolean;
}
export interface IInteractionDataCallback {
(interactionData: InteractionData): void;
}
export interface PixiRenderer {
autoResize: boolean;
clearBeforeRender: boolean;
height: number;
resolution: number;
transparent: boolean;
type: number;
view: HTMLCanvasElement;
width: number;
destroy(): void;
render(stage: DisplayObjectContainer): void;
resize(width: number, height: number): void;
}
export interface PixiRendererOptions {
autoResize?: boolean;
antialias?: boolean;
clearBeforeRender?: boolean;
preserveDrawingBuffer?: boolean;
resolution?: number;
transparent?: boolean;
view?: HTMLCanvasElement;
}
export interface BitmapTextStyle {
font?: string;
align?: string;
tint?: string;
}
export interface TextStyle {
align?: string;
dropShadow?: boolean;
dropShadowColor?: string;
dropShadowAngle?: number;
dropShadowDistance?: number;
fill?: string;
font?: string;
lineJoin?: string;
stroke?: string;
strokeThickness?: number;
wordWrap?: boolean;
wordWrapWidth?: number;
}
export interface Loader {
load(): void;
}
export interface MaskData {
alpha: number;
worldTransform: number[];
}
export interface RenderSession {
context: CanvasRenderingContext2D;
maskManager: CanvasMaskManager;
scaleMode: scaleModes;
smoothProperty: string;
roundPixels: boolean;
}
export interface ShaderAttribute {
// TODO: Find signature of shader attributes
}
export interface FilterBlock {
visible: boolean;
renderable: boolean;
}
2016-06-17 11:46:47 +00:00
/**
* This is the base class for creating a PIXI filter. Currently only webGL supports filters.
* If you want to make a custom filter this should be your base class.
*/
2016-07-01 15:57:13 +00:00
export class AbstractFilter {
2016-06-17 11:46:47 +00:00
/**
* This is the base class for creating a PIXI filter. Currently only webGL supports filters.
* If you want to make a custom filter this should be your base class.
*
* @param fragmentSrc The fragment source in an array of strings.
* @param uniforms An object containing the uniforms for this filter.
*/
2016-07-01 15:57:13 +00:00
constructor(fragmentSrc: string | string[], uniforms: any);
dirty: boolean;
padding: number;
uniforms: any;
fragmentSrc: string | string[];
apply(frameBuffer: WebGLFramebuffer): void;
2016-06-17 11:46:47 +00:00
/**
* Syncs the uniforms between the class object and the shaders.
*/
2016-07-01 15:57:13 +00:00
syncUniforms(): void;
}
export class AlphaMaskFilter extends AbstractFilter {
constructor(texture: Texture);
map: Texture;
onTextureLoaded(): void;
}
export class AsciiFilter extends AbstractFilter {
size: number;
}
export class AssetLoader implements Mixin {
assetURLs: string[];
crossorigin: boolean;
loadersByType: { [key: string]: Loader };
constructor(assetURLs: string[], crossorigin: boolean);
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
export class AtlasLoader implements Mixin {
url: string;
baseUrl: string;
crossorigin: boolean;
loaded: boolean;
constructor(url: string, crossorigin: boolean);
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
2016-06-17 11:46:47 +00:00
/**
* A texture stores the information that represents an image. All textures have a base texture.
*/
2016-07-01 15:57:13 +00:00
export class BaseTexture implements Mixin {
2016-06-17 11:46:47 +00:00
/**
* Helper function that creates a base texture from the given canvas element.
*
* @param canvas The canvas element source of the texture
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
*/
2016-07-01 15:57:13 +00:00
static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): BaseTexture;
2016-06-17 11:46:47 +00:00
/**
* A texture stores the information that represents an image. All textures have a base texture.
*
* @param source the source object (image or canvas)
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
*/
2016-07-01 15:57:13 +00:00
constructor(source: HTMLImageElement, scaleMode: scaleModes);
2016-06-17 11:46:47 +00:00
/**
* A texture stores the information that represents an image. All textures have a base texture.
*
* @param source the source object (image or canvas)
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
*/
2016-07-01 15:57:13 +00:00
constructor(source: HTMLCanvasElement, scaleMode: scaleModes);
2016-06-17 11:46:47 +00:00
/**
* [read-only] The height of the base texture set when the image has loaded
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* [read-only] Set to true once the base texture has loaded
*/
2016-07-01 15:57:13 +00:00
hasLoaded: boolean;
2016-06-17 11:46:47 +00:00
/**
* Set this to true if a mipmap of this texture needs to be generated. This value needs to be set before the texture is used
* Also the texture must be a power of two size to work
*/
2016-07-01 15:57:13 +00:00
mipmap: boolean;
2016-06-17 11:46:47 +00:00
/**
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
* Default: true
*/
2016-07-01 15:57:13 +00:00
premultipliedAlpha: boolean;
2016-06-17 11:46:47 +00:00
/**
* The Resolution of the texture.
*/
2016-07-01 15:57:13 +00:00
resolution: number;
2016-06-17 11:46:47 +00:00
/**
* The scale mode to apply when scaling this texture
* Default: PIXI.scaleModes.LINEAR
*/
2016-07-01 15:57:13 +00:00
scaleMode: scaleModes;
2016-06-17 11:46:47 +00:00
/**
* A BaseTexture can be set to skip the rendering phase in the WebGL Sprite Batch.
*
* You may want to do this if you have a parent Sprite with no visible texture (i.e. uses the internal `__default` texture)
* that has children that you do want to render, without causing a batch flush in the process.
*/
2016-07-01 15:57:13 +00:00
skipRender: boolean;
2016-06-17 11:46:47 +00:00
/**
* The image source that is used to create the texture.
*/
2016-07-01 15:57:13 +00:00
source: HTMLImageElement;
2016-06-17 11:46:47 +00:00
/**
* [read-only] The width of the base texture set when the image has loaded
*/
2016-07-01 15:57:13 +00:00
width: number;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
2016-06-17 11:46:47 +00:00
/**
* Forces this BaseTexture to be set as loaded, with the given width and height.
* Then calls BaseTexture.dirty.
* Important for when you don't want to modify the source object by forcing in `complete` or dimension properties it may not have.
*
* @param width - The new width to force the BaseTexture to be.
* @param height - The new height to force the BaseTexture to be.
*/
2016-07-01 15:57:13 +00:00
forceLoaded(width: number, height: number): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys this base texture
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Sets all glTextures to be dirty.
*/
2016-07-01 15:57:13 +00:00
dirty(): void;
2016-06-17 11:46:47 +00:00
/**
* Removes the base texture from the GPU, useful for managing resources on the GPU.
* Atexture is still 100% usable and will simply be reuploaded if there is a sprite on screen that is using it.
*/
2016-07-01 15:57:13 +00:00
unloadFromGPU(): void;
}
export class BitmapFontLoader implements Mixin {
constructor(url: string, crossorigin: boolean);
baseUrl: string;
crossorigin: boolean;
texture: Texture;
url: string;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
export class BlurFilter extends AbstractFilter {
blur: number;
blurX: number;
blurY: number;
}
export class BlurXFilter extends AbstractFilter {
blur: number;
}
export class BlurYFilter extends AbstractFilter {
blur: number;
}
2016-06-17 11:46:47 +00:00
/**
* Creates a Canvas element of the given size.
*/
2016-07-01 15:57:13 +00:00
export class CanvasBuffer {
2016-06-17 11:46:47 +00:00
/**
* Creates a Canvas element of the given size.
*
* @param width the width for the newly created canvas
* @param height the height for the newly created canvas
*/
2016-07-01 15:57:13 +00:00
constructor(width: number, height: number);
2016-06-17 11:46:47 +00:00
/**
* The Canvas object that belongs to this CanvasBuffer.
*/
2016-07-01 15:57:13 +00:00
canvas: HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* A CanvasRenderingContext2D object representing a two-dimensional rendering context.
*/
2016-07-01 15:57:13 +00:00
context: CanvasRenderingContext2D;
2016-06-17 11:46:47 +00:00
/**
* The height of the Canvas in pixels.
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* The width of the Canvas in pixels.
*/
2016-07-01 15:57:13 +00:00
width: number;
2016-06-17 11:46:47 +00:00
/**
* Frees the canvas up for use again.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Clears the canvas that was created by the CanvasBuffer class.
*/
2016-07-01 15:57:13 +00:00
clear(): void;
2016-06-17 11:46:47 +00:00
/**
* Resizes the canvas to the specified width and height.
*
* @param width the new width of the canvas
* @param height the new height of the canvas
*/
2016-07-01 15:57:13 +00:00
resize(width: number, height: number): void;
}
2016-06-17 11:46:47 +00:00
/**
* The CanvasPool is a global static object that allows Pixi and Phaser to pool canvas DOM elements.
*/
2016-07-01 15:57:13 +00:00
export class CanvasPool {
2016-06-17 11:46:47 +00:00
/**
* Creates a new Canvas DOM element, or pulls one from the pool if free.
*
* @param parent The parent of the canvas element.
* @param width The width of the canvas element.
* @param height The height of the canvas element.
* @return The canvas element.
*/
2016-07-01 15:57:13 +00:00
static create(parent: HTMLElement, width?: number, height?: number): HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* Gets the first free canvas index from the pool.
*/
2016-07-01 15:57:13 +00:00
static getFirst(): HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* Removes the parent from a canvas element from the pool, freeing it up for re-use.
*
* @param parent The parent of the canvas element.
*/
2016-07-01 15:57:13 +00:00
static remove(parent: HTMLElement): void;
2016-06-17 11:46:47 +00:00
/**
* Removes the parent from a canvas element from the pool, freeing it up for re-use.
*
* @param canvas The canvas element to remove
*/
2016-07-01 15:57:13 +00:00
static removeByCanvas(canvas: HTMLCanvasElement): HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* Gets the total number of used canvas elements in the pool.
* @return The number of in-use (parented) canvas elements in the pool.
*/
2016-07-01 15:57:13 +00:00
static getTotal(): number;
2016-06-17 11:46:47 +00:00
/**
* Gets the total number of free canvas elements in the pool.
* @return The number of free (un-parented) canvas elements in the pool.
*/
2016-07-01 15:57:13 +00:00
static getFree(): number;
}
2016-06-17 11:46:47 +00:00
/**
* A set of functions used to handle masking.
*/
2016-07-01 15:57:13 +00:00
export class CanvasMaskManager {
2016-06-17 11:46:47 +00:00
/**
* This method adds it to the current stack of masks.
*
* @param maskData the maskData that will be pushed
* @param renderSession The renderSession whose context will be used for this mask manager.
*/
2016-07-01 15:57:13 +00:00
pushMask(maskData: MaskData, renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Restores the current drawing context to the state it was before the mask was applied.
*
* @param renderSession The renderSession whose context will be used for this mask manager.
*/
2016-07-01 15:57:13 +00:00
popMask(renderSession: RenderSession): void;
}
2016-06-17 11:46:47 +00:00
/**
* The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL.
* Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :)
*/
2016-07-01 15:57:13 +00:00
export class CanvasRenderer implements PixiRenderer {
2016-06-17 11:46:47 +00:00
/**
* The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL.
* Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :)
*
* @param game A reference to the Phaser Game instance
*/
2016-07-01 15:57:13 +00:00
constructor(game: Phaser.Game);
game: Phaser.Game;
2016-06-17 11:46:47 +00:00
/**
* The renderer type.
*/
2016-07-01 15:57:13 +00:00
type: number;
2016-06-17 11:46:47 +00:00
/**
* The resolution of the canvas.
*/
2016-07-01 15:57:13 +00:00
resolution: number;
2016-06-17 11:46:47 +00:00
/**
* This sets if the CanvasRenderer will clear the canvas or not before the new render pass.
* If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color.
* If the Stage is transparent Pixi will use clearRect to clear the canvas every frame.
* Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set.
*/
2016-07-01 15:57:13 +00:00
clearBeforeRender: boolean;
2016-06-17 11:46:47 +00:00
/**
* Whether the render view is transparent
*/
2016-07-01 15:57:13 +00:00
transparent: boolean;
2016-06-17 11:46:47 +00:00
/**
* Whether the render view should be resized automatically
*/
2016-07-01 15:57:13 +00:00
autoResize: boolean;
2016-06-17 11:46:47 +00:00
/**
* The width of the canvas view
* Default: 800
*/
2016-07-01 15:57:13 +00:00
width: number;
2016-06-17 11:46:47 +00:00
/**
* The height of the canvas view
* Default: 600
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* The canvas element that everything is drawn to.
*/
2016-07-01 15:57:13 +00:00
view: HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* The canvas 2d context that everything is drawn with
*/
2016-07-01 15:57:13 +00:00
context: CanvasRenderingContext2D;
2016-06-17 11:46:47 +00:00
/**
* Boolean flag controlling canvas refresh.
*/
2016-07-01 15:57:13 +00:00
refresh: boolean;
2016-06-17 11:46:47 +00:00
/**
* Internal var.
*/
2016-07-01 15:57:13 +00:00
count: number;
maskManager: CanvasMaskManager;
2016-06-17 11:46:47 +00:00
/**
* The render session is just a bunch of parameter used for rendering
*/
2016-07-01 15:57:13 +00:00
renderSession: RenderSession;
2016-06-17 11:46:47 +00:00
/**
* Renders the Stage to this canvas view
*
* @param stage the Stage element to be rendered
*/
2016-07-01 15:57:13 +00:00
render(stage: DisplayObjectContainer): void;
2016-06-17 11:46:47 +00:00
/**
* Resizes the canvas view to the specified width and height
*
* @param width the new width of the canvas view
* @param height the new height of the canvas view
*/
2016-07-01 15:57:13 +00:00
resize(width: number, height: number): void;
2016-06-17 11:46:47 +00:00
/**
* Removes everything from the renderer and optionally removes the Canvas DOM element.
*
* @param removeView Removes the Canvas element from the DOM. - Default: true
*/
2016-07-01 15:57:13 +00:00
destroy(removeView?: boolean): void;
}
2016-06-17 11:46:47 +00:00
/**
* Utility methods for Sprite/Texture tinting.
*/
2016-07-01 15:57:13 +00:00
export class CanvasTinter {
2016-06-17 11:46:47 +00:00
/**
* Basically this method just needs a sprite and a color and tints the sprite with the given color.
*
* @param sprite the sprite to tint
* @param color the color to use to tint the sprite with
* @return The tinted canvas
*/
2016-07-01 15:57:13 +00:00
static getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* Tint a texture using the "multiply" operation.
*
* @param texture the texture to tint
* @param color the color to use to tint the sprite with
* @param canvas the current canvas
*/
2016-07-01 15:57:13 +00:00
static tintWithMultiply(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
static tintWithOverlay(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
static tintWithPerPixel(texture: Texture, color: number, canvas: HTMLCanvasElement): void;
2016-06-17 11:46:47 +00:00
/**
* Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method.
*/
2016-07-01 15:57:13 +00:00
static canUseMultiply: boolean;
static tintMethod: any;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class Circle implements HitArea {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
constructor(x: number, y: number, radius: number);
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
x: number;
y: number;
radius: number;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
clone(): Circle;
contains(x: number, y: number): boolean;
getBounds(): Rectangle;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class ColorMatrixFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
constructor();
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
matrix: number[];
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class ColorStepFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
step: number;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class ConvolutionFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
constructor(matrix: number[], width: number, height: number);
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
matrix: Matrix;
width: number;
height: number;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class CrossHatchFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
blur: number;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class DisplacementFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
constructor(texture: Texture);
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
map: Texture;
offset: Point;
scale: Point;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class DotScreenFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
angle: number;
scale: Point;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class DisplayObject {
alpha: number;
buttonMode: boolean;
cacheAsBitmap: boolean;
defaultCursor: string;
filterArea: Rectangle;
filters: AbstractFilter[];
hitArea: HitArea;
interactive: boolean;
mask: Graphics;
parent: DisplayObjectContainer;
pivot: Point;
position: Point;
renderable: boolean;
rotation: number;
scale: Point;
stage: DisplayObjectContainer;
visible: boolean;
worldAlpha: number;
worldPosition: Point;
worldScale: Point;
worldTransform: Matrix;
worldRotation: number;
worldVisible: boolean;
x: number;
y: number;
click(e: InteractionData): void;
Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it.
2016-07-20 23:14:10 +00:00
displayObjectUpdateTransform(parent?: DisplayObjectContainer): void;
2016-07-01 15:57:13 +00:00
generateTexture(resolution?: number, scaleMode?: number, renderer?: PixiRenderer | number): RenderTexture;
mousedown(e: InteractionData): void;
mouseout(e: InteractionData): void;
mouseover(e: InteractionData): void;
mouseup(e: InteractionData): void;
mousemove(e: InteractionData): void;
mouseupoutside(e: InteractionData): void;
rightclick(e: InteractionData): void;
rightdown(e: InteractionData): void;
rightup(e: InteractionData): void;
rightupoutside(e: InteractionData): void;
setStageReference(stage: DisplayObjectContainer): void;
tap(e: InteractionData): void;
toGlobal(position: Point): Point;
toLocal(position: Point, from: DisplayObject): Point;
touchend(e: InteractionData): void;
touchendoutside(e: InteractionData): void;
touchstart(e: InteractionData): void;
touchmove(e: InteractionData): void;
Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it.
2016-07-20 23:14:10 +00:00
updateTransform(parent?: DisplayObjectContainer): void;
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
/**
* A DisplayObjectContainer represents a collection of display objects.
* It is the base class of all display objects that act as a container for other objects.
*/
2016-07-01 15:57:13 +00:00
export class DisplayObjectContainer extends DisplayObject {
2016-06-17 11:46:47 +00:00
/**
* A DisplayObjectContainer represents a collection of display objects.
* It is the base class of all display objects that act as a container for other objects.
*/
2016-07-01 15:57:13 +00:00
constructor();
2016-06-17 11:46:47 +00:00
/**
* [read-only] The array of children of this container.
*/
2016-07-01 15:57:13 +00:00
children: DisplayObject[];
2016-06-17 11:46:47 +00:00
/**
* The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
*/
2016-07-01 15:57:13 +00:00
width: number;
2016-06-17 11:46:47 +00:00
/**
* If `ignoreChildInput` is `false` it will allow this objects _children_ to be considered as valid for Input events.
*
* If this property is `true` then the children will _not_ be considered as valid for Input events.
*
* Note that this property isn't recursive: only immediate children are influenced, it doesn't scan further down.
*/
2016-07-01 15:57:13 +00:00
ignoreChildInput: boolean;
2016-06-17 11:46:47 +00:00
/**
* Adds a child to the container.
*
* @param child The DisplayObject to add to the container
* @return The child that was added.
*/
2016-07-01 15:57:13 +00:00
addChild(child: DisplayObject): DisplayObject;
2016-06-17 11:46:47 +00:00
/**
* Adds a child to the container at a specified index. If the index is out of bounds an error will be thrown
*
* @param child The child to add
* @param index The index to place the child in
* @return The child that was added.
*/
2016-07-01 15:57:13 +00:00
addChildAt(child: DisplayObject, index: number): DisplayObject;
2016-06-17 11:46:47 +00:00
/**
Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it.
2016-07-20 23:14:10 +00:00
* Retrieves the global bounds of the displayObjectContainer as a rectangle. The bounds calculation takes all visible children into consideration.
* @param targetCoordinateSpace Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
2016-06-17 11:46:47 +00:00
* @return The rectangular bounding area
*/
Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it.
2016-07-20 23:14:10 +00:00
getBounds(targetCoordinateSpace?: DisplayObject | Matrix): Rectangle;
2016-06-17 11:46:47 +00:00
/**
* Returns the child at the specified index
*
* @param index The index to get the child from
* @return The child at the given index, if any.
*/
2016-07-01 15:57:13 +00:00
getChildAt(index: number): DisplayObject;
2016-06-17 11:46:47 +00:00
/**
* Returns the index position of a child DisplayObject instance
*
* @param child The DisplayObject instance to identify
* @return The index position of the child display object to identify
*/
2016-07-01 15:57:13 +00:00
getChildIndex(child: DisplayObject): number;
2016-06-17 11:46:47 +00:00
/**
* Retrieves the non-global local bounds of the displayObjectContainer as a rectangle. The calculation takes all visible children into consideration.
* @return The rectangular bounding area
*/
2016-07-01 15:57:13 +00:00
getLocalBounds(): Rectangle;
2016-06-17 11:46:47 +00:00
/**
* Removes a child from the container.
*
* @param child The DisplayObject to remove
* @return The child that was removed.
*/
2016-07-01 15:57:13 +00:00
removeChild(child: DisplayObject): DisplayObject;
2016-06-17 11:46:47 +00:00
/**
* Removes a child from the specified index position.
*
* @param index The index to get the child from
* @return The child that was removed.
*/
2016-07-01 15:57:13 +00:00
removeChildAt(index: number): DisplayObject;
2016-06-17 11:46:47 +00:00
/**
* Removes all children from this container that are within the begin and end indexes.
*
* @param beginIndex The beginning position. Default value is 0.
* @param endIndex The ending position. Default value is size of the container.
*/
2016-07-01 15:57:13 +00:00
removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[];
2016-06-17 11:46:47 +00:00
/**
* Removes the current stage reference from the container and all of its children.
*/
2016-07-01 15:57:13 +00:00
removeStageReference(): void;
2016-06-17 11:46:47 +00:00
/**
* Changes the position of an existing child in the display object container
*
* @param child The child DisplayObject instance for which you want to change the index number
* @param index The resulting index number for the child display object
*/
2016-07-01 15:57:13 +00:00
setChildIndex(child: DisplayObject, index: number): void;
2016-06-17 11:46:47 +00:00
/**
* Swaps the position of 2 Display Objects within this container.
*
* @param child -
* @param child2 -
*/
2016-07-01 15:57:13 +00:00
swapChildren(child: DisplayObject, child2: DisplayObject): void;
Fix for PIXI's DisplayObject/DisplayObjectContainer - getting correct dimensions and bounds With the previous fix what the getBounds did was: 1) if targetCoordinateSpace is the same instance as the caller of getBounds(), then it will return the bounds of the caller without any transformations; 2) if targetCoordinateSpace is null/undefined it will return the global bounds of the caller. 3) if targetCoordinateSpace is any valid DisplayObject it will return the local bounds of the caller. What this fix does is fixing 3) along with other obsolete code that wasn't necessary so I reverted it. So now if the targetCoordinateSpace is a valid DisplayObject: - if it's a parent of the caller at some level it will return the bounds relative to it - if it's not parenting the caller at all it will get global bounds of it and the caller and will calculate the x and y bounds of the caller relative to the targetCoordinateSpace DisplayObject Also I have fixed how empty groups are treated when they have no other children except groups, so now calculations are correct. They obviously have 0 width and height but are still being positioned and other things could possibly relate to that bounds and it didn't make sense to me to ignore them. Also added a DisplayObjectContainer.contains(child) method which determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself. This method is used in the new getBounds function. Corrected DisplayObject's default _bounds rect from (0, 0, 1, 1), to (0, 0, 0, 0) - it doesn't seem to break anything and also in the getBounds before the fix, when there were no children it assigned a (0, 0, 0, 0) rectangle to it so I am pretty sure it's safe to correct it.
2016-07-20 23:14:10 +00:00
/**
* Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.
*
* @param child
*/
contains(child: DisplayObject): boolean;
2016-07-01 15:57:13 +00:00
}
export class Ellipse implements HitArea {
constructor(x: number, y: number, width: number, height: number);
x: number;
y: number;
width: number;
height: number;
clone(): Ellipse;
contains(x: number, y: number): boolean;
getBounds(): Rectangle;
}
2016-06-17 11:46:47 +00:00
/**
* Creates an homogenous object for tracking events so users can know what to expect.
*/
2016-07-01 15:57:13 +00:00
export class Event {
2016-06-17 11:46:47 +00:00
/**
* Creates an homogenous object for tracking events so users can know what to expect.
*
* @param target The target object that the event is called on
* @param name The string name of the event that was triggered
* @param data Arbitrary event data to pass along
*/
2016-07-01 15:57:13 +00:00
constructor(target: any, name: string, data: any);
2016-06-17 11:46:47 +00:00
/**
* The original target the event triggered on.
*/
2016-07-01 15:57:13 +00:00
target: any;
2016-06-17 11:46:47 +00:00
/**
* The string name of the event that this represents.
*/
2016-07-01 15:57:13 +00:00
type: string;
2016-06-17 11:46:47 +00:00
/**
* The data that was passed in with this event.
*/
2016-07-01 15:57:13 +00:00
data: any;
2016-06-17 11:46:47 +00:00
/**
* The timestamp when the event occurred.
*/
2016-07-01 15:57:13 +00:00
timeStamp: number;
2016-06-17 11:46:47 +00:00
/**
* Stops the propagation of events up the scene graph (prevents bubbling).
*/
2016-07-01 15:57:13 +00:00
stopPropagation(): void;
preventDefault(): void;
2016-06-17 11:46:47 +00:00
/**
* Stops the propagation of events to sibling listeners (no longer calls any listeners).
*/
2016-07-01 15:57:13 +00:00
stopImmediatePropagation(): void;
}
2016-06-17 11:46:47 +00:00
/**
* Mixins event emitter functionality to a class
*/
2016-07-01 15:57:13 +00:00
export class EventTarget {
2016-06-17 11:46:47 +00:00
/**
* Mixes in the properties of the EventTarget prototype onto another object
*
* @param object The obj to mix into
*/
2016-07-01 15:57:13 +00:00
static mixin(obj: any): void;
}
export class FilterTexture {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
* @param width the horizontal range of the filter
* @param height the vertical range of the filter
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext, width: number, height: number, scaleMode: scaleModes);
fragmentSrc: string[];
frameBuffer: WebGLFramebuffer;
gl: WebGLRenderingContext;
program: WebGLProgram;
scaleMode: number;
texture: WebGLTexture;
2016-06-17 11:46:47 +00:00
/**
* Clears the filter texture.
*/
2016-07-01 15:57:13 +00:00
clear(): void;
2016-06-17 11:46:47 +00:00
/**
* Resizes the texture to the specified width and height
*
* @param width the new width of the texture
* @param height the new height of the texture
*/
2016-07-01 15:57:13 +00:00
resize(width: number, height: number): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys the filter texture.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
}
2016-06-17 11:46:47 +00:00
/**
* A GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
export class GraphicsData {
2016-06-17 11:46:47 +00:00
/**
* A GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
constructor(lineWidth?: number, lineColor?: number, lineAlpha?: number, fillColor?: number, fillAlpha?: number, fill?: boolean, shape?: any);
lineWidth: number;
lineColor: number;
lineAlpha: number;
fillColor: number;
fillAlpha: number;
fill: boolean;
shape: any;
type: number;
}
2016-06-17 11:46:47 +00:00
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and rectangles to the display, and color and fill them.
*/
2016-07-01 15:57:13 +00:00
export class Graphics extends DisplayObjectContainer {
static POLY: number;
static RECT: number;
static CIRC: number;
static ELIP: number;
static RREC: number;
2016-06-17 11:46:47 +00:00
/**
* The blend mode to be applied to the graphic shape. Apply a value of PIXI.blendModes.NORMAL to reset the blend mode.
* Default: PIXI.blendModes.NORMAL;
*/
2016-07-01 15:57:13 +00:00
blendMode: number;
2016-06-17 11:46:47 +00:00
/**
* The bounds' padding used for bounds calculation.
*/
2016-07-01 15:57:13 +00:00
boundsPadding: number;
2016-06-17 11:46:47 +00:00
/**
* The alpha value used when filling the Graphics object.
*/
2016-07-01 15:57:13 +00:00
fillAlpha: number;
2016-06-17 11:46:47 +00:00
/**
* Whether this shape is being used as a mask.
*/
2016-07-01 15:57:13 +00:00
isMask: boolean;
2016-06-17 11:46:47 +00:00
/**
* The width (thickness) of any lines drawn.
*/
2016-07-01 15:57:13 +00:00
lineWidth: number;
2016-06-17 11:46:47 +00:00
/**
* The color of any lines drawn.
* Default: 0
*/
2016-07-01 15:57:13 +00:00
lineColor: number;
2016-06-17 11:46:47 +00:00
/**
* The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF to reset the tint.
* Default: 0xFFFFFF
*/
2016-07-01 15:57:13 +00:00
tint: number;
worldAlpha: number;
2016-06-17 11:46:47 +00:00
/**
* The arc method creates an arc/curve (used to create circles, or parts of circles).
*
* @param cx The x-coordinate of the center of the circle
* @param cy The y-coordinate of the center of the circle
* @param radius The radius of the circle
* @param startAngle The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)
* @param endAngle The ending angle, in radians
* @param anticlockwise Optional. Specifies whether the drawing should be counterclockwise or clockwise. False is default, and indicates clockwise, while true indicates counter-clockwise.
* @param segments Optional. The number of segments to use when calculating the arc. The default is 40. If you need more fidelity use a higher number.
*/
2016-07-01 15:57:13 +00:00
arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): Graphics;
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Specifies a simple one-color fill that subsequent calls to other Graphics methods
* (such as lineTo() or drawCircle()) use when drawing.
*
* @param color the color of the fill
* @param alpha the alpha of the fill
*/
2016-07-01 15:57:13 +00:00
beginFill(color?: number, alpha?: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Calculate the points for a bezier curve and then draws it.
*
* @param cpX Control point x
* @param cpY Control point y
* @param cpX2 Second Control point x
* @param cpY2 Second Control point y
* @param toX Destination point x
* @param toY Destination point y
*/
2016-07-01 15:57:13 +00:00
bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
*/
2016-07-01 15:57:13 +00:00
clear(): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Destroys a previous cached sprite.
*/
2016-07-01 15:57:13 +00:00
destroyCachedSprite(): void;
2016-06-17 11:46:47 +00:00
/**
* Draws a circle.
*
* @param x The X coordinate of the center of the circle
* @param y The Y coordinate of the center of the circle
* @param diameter The diameter of the circle
*/
2016-07-01 15:57:13 +00:00
drawCircle(x: number, y: number, diameter: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Draws an ellipse.
*
* @param x The X coordinate of the center of the ellipse
* @param y The Y coordinate of the center of the ellipse
* @param width The half width of the ellipse
* @param height The half height of the ellipse
*/
2016-07-01 15:57:13 +00:00
drawEllipse(x: number, y: number, width: number, height: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Draws a polygon using the given path.
*
* @param path The path data used to construct the polygon. Can either be an array of points or a Phaser.Polygon object.
*/
2016-07-01 15:57:13 +00:00
drawPolygon(...path: any[]): Graphics;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param x The X coord of the top-left of the rectangle
* @param y The Y coord of the top-left of the rectangle
* @param width The width of the rectangle
* @param height The height of the rectangle
*/
2016-07-01 15:57:13 +00:00
drawRect(x: number, y: number, width: number, height: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param x The X coord of the top-left of the rectangle
* @param y The Y coord of the top-left of the rectangle
* @param width The width of the rectangle
* @param height The height of the rectangle
* @param radius Radius of the rectangle corners. In WebGL this must be a value between 0 and 9.
*/
2016-07-01 15:57:13 +00:00
drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
*
* @param shape The Shape object to draw.
* @return The generated GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
drawShape(shape: Circle): GraphicsData;
2016-06-17 11:46:47 +00:00
/**
* Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
*
* @param shape The Shape object to draw.
* @return The generated GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
drawShape(shape: Rectangle): GraphicsData;
2016-06-17 11:46:47 +00:00
/**
* Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
*
* @param shape The Shape object to draw.
* @return The generated GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
drawShape(shape: Ellipse): GraphicsData;
2016-06-17 11:46:47 +00:00
/**
* Draws the given shape to this Graphics object. Can be any of Circle, Rectangle, Ellipse, Line or Polygon.
*
* @param shape The Shape object to draw.
* @return The generated GraphicsData object.
*/
2016-07-01 15:57:13 +00:00
drawShape(shape: Polygon): GraphicsData;
2016-06-17 11:46:47 +00:00
/**
* Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
*/
2016-07-01 15:57:13 +00:00
endFill(): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Useful function that returns a texture of the graphics object that can then be used to create sprites
* This can be quite useful if your geometry is complicated and needs to be reused multiple times.
*
* @param resolution The resolution of the texture being generated - Default: 1
* @param scaleMode Should be one of the PIXI.scaleMode consts
* @param padding Add optional extra padding to the generated texture (default 0)
* @return a texture of the graphics object
*/
2016-07-01 15:57:13 +00:00
generateTexture(resolution?: number, scaleMode?: number, padding?: number): RenderTexture;
2016-06-17 11:46:47 +00:00
/**
* Specifies the line style used for subsequent calls to Graphics methods such as the lineTo() method or the drawCircle() method.
*
* @param lineWidth width of the line to draw, will update the objects stored style
* @param color color of the line to draw, will update the objects stored style
* @param alpha alpha of the line to draw, will update the objects stored style
*/
2016-07-01 15:57:13 +00:00
lineStyle(lineWidth?: number, color?: number, alpha?: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Draws a line using the current line style from the current drawing position to (x, y);
* The current drawing position is then set to (x, y).
*
* @param x the X coordinate to draw to
* @param y the Y coordinate to draw to
*/
2016-07-01 15:57:13 +00:00
lineTo(x: number, y: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Moves the current drawing position to x, y.
*
* @param x the X coordinate to move to
* @param y the Y coordinate to move to
*/
2016-07-01 15:57:13 +00:00
moveTo(x: number, y: number): Graphics;
2016-06-17 11:46:47 +00:00
/**
* Calculate the points for a quadratic bezier curve and then draws it.
* Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* @param cpX Control point x
* @param cpY Control point y
* @param toX Destination point x
* @param toY Destination point y
*/
2016-07-01 15:57:13 +00:00
quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): Graphics;
}
export class GrayFilter extends AbstractFilter {
gray: number;
}
export class ImageLoader implements Mixin {
constructor(url: string, crossorigin?: boolean);
texture: Texture;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
loadFramedSpriteSheet(frameWidth: number, frameHeight: number, textureName: string): void;
}
export class InteractionData {
global: Point;
target: Sprite;
originalEvent: Event;
getLocalPosition(displayObject: DisplayObject, point?: Point, globalPos?: Point): Point;
}
export class InteractionManager {
currentCursorStyle: string;
last: number;
mouse: InteractionData;
mouseOut: boolean;
mouseoverEnabled: boolean;
onMouseMove: Function;
onMouseDown: Function;
onMouseOut: Function;
onMouseUp: Function;
onTouchStart: Function;
onTouchEnd: Function;
onTouchMove: Function;
pool: InteractionData[];
resolution: number;
stage: DisplayObjectContainer;
touches: { [id: string]: InteractionData };
constructor(stage: DisplayObjectContainer);
}
export class InvertFilter extends AbstractFilter {
invert: number;
}
export class JsonLoader implements Mixin {
constructor(url: string, crossorigin?: boolean);
baseUrl: string;
crossorigin: boolean;
loaded: boolean;
url: string;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
export class Matrix {
a: number;
b: number;
c: number;
d: number;
tx: number;
ty: number;
append(matrix: Matrix): Matrix;
apply(pos: Point, newPos: Point): Point;
applyInverse(pos: Point, newPos: Point): Point;
determineMatrixArrayType(): number[];
identity(): Matrix;
rotate(angle: number): Matrix;
fromArray(array: number[]): void;
translate(x: number, y: number): Matrix;
toArray(transpose: boolean): number[];
scale(x: number, y: number): Matrix;
}
export interface Mixin {
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
}
export class NoiseFilter extends AbstractFilter {
noise: number;
}
export class NormalMapFilter extends AbstractFilter {
map: Texture;
offset: Point;
scale: Point;
}
export class PixelateFilter extends AbstractFilter {
size: number;
}
export interface IPixiShader {
fragmentSrc: string[];
gl: WebGLRenderingContext;
program: WebGLProgram;
vertexSrc: string[];
destroy(): void;
init(): void;
}
export class PixiShader implements IPixiShader {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext);
2016-06-17 11:46:47 +00:00
/**
* Uniform attributes cache.
*/
2016-07-01 15:57:13 +00:00
attributes: ShaderAttribute[];
2016-06-17 11:46:47 +00:00
/**
* The Default Vertex shader source.
*/
2016-07-01 15:57:13 +00:00
defaultVertexSrc: string[];
2016-06-17 11:46:47 +00:00
/**
* A dirty flag
*/
2016-07-01 15:57:13 +00:00
dirty: boolean;
2016-06-17 11:46:47 +00:00
/**
* A local flag
*/
2016-07-01 15:57:13 +00:00
firstRun: boolean;
2016-06-17 11:46:47 +00:00
/**
* A local texture counter for multi-texture shaders.
*/
2016-07-01 15:57:13 +00:00
textureCount: number;
2016-06-17 11:46:47 +00:00
/**
* The fragment shader.
*/
2016-07-01 15:57:13 +00:00
fragmentSrc: string[];
gl: WebGLRenderingContext;
2016-06-17 11:46:47 +00:00
/**
* The WebGL program.
*/
2016-07-01 15:57:13 +00:00
program: WebGLProgram;
vertexSrc: string[];
2016-06-17 11:46:47 +00:00
/**
* Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded)
*/
2016-07-01 15:57:13 +00:00
initSampler2D(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader uniform values.
*
* Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/
* http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
*/
2016-07-01 15:57:13 +00:00
initUniforms(): void;
2016-06-17 11:46:47 +00:00
/**
* Updates the shader uniform values.
*/
2016-07-01 15:57:13 +00:00
syncUniforms(): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys the shader.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader.
*/
2016-07-01 15:57:13 +00:00
init(): void;
}
export class PixiFastShader implements IPixiShader {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext);
2016-06-17 11:46:47 +00:00
/**
* A local texture counter for multi-texture shaders.
*/
2016-07-01 15:57:13 +00:00
textureCount: number;
2016-06-17 11:46:47 +00:00
/**
* The fragment shader.
*/
2016-07-01 15:57:13 +00:00
fragmentSrc: string[];
gl: WebGLRenderingContext;
2016-06-17 11:46:47 +00:00
/**
* The WebGL program.
*/
2016-07-01 15:57:13 +00:00
program: WebGLProgram;
2016-06-17 11:46:47 +00:00
/**
* The vertex shader.
*/
2016-07-01 15:57:13 +00:00
vertexSrc: string[];
2016-06-17 11:46:47 +00:00
/**
* Destroys the shader.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader.
*/
2016-07-01 15:57:13 +00:00
init(): void;
}
export class PrimitiveShader implements IPixiShader {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext);
2016-06-17 11:46:47 +00:00
/**
* The fragment shader.
*/
2016-07-01 15:57:13 +00:00
fragmentSrc: string[];
gl: WebGLRenderingContext;
2016-06-17 11:46:47 +00:00
/**
* The WebGL program.
*/
2016-07-01 15:57:13 +00:00
program: WebGLProgram;
2016-06-17 11:46:47 +00:00
/**
* The vertex shader.
*/
2016-07-01 15:57:13 +00:00
vertexSrc: string[];
2016-06-17 11:46:47 +00:00
/**
* Destroys the shader.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader.
*/
2016-07-01 15:57:13 +00:00
init(): void;
}
export class ComplexPrimitiveShader implements IPixiShader {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext);
2016-06-17 11:46:47 +00:00
/**
* The fragment shader.
*/
2016-07-01 15:57:13 +00:00
fragmentSrc: string[];
gl: WebGLRenderingContext;
2016-06-17 11:46:47 +00:00
/**
* The WebGL program.
*/
2016-07-01 15:57:13 +00:00
program: WebGLProgram;
2016-06-17 11:46:47 +00:00
/**
* The vertex shader.
*/
2016-07-01 15:57:13 +00:00
vertexSrc: string[];
2016-06-17 11:46:47 +00:00
/**
* Destroys the shader.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader.
*/
2016-07-01 15:57:13 +00:00
init(): void;
}
export class StripShader implements IPixiShader {
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
constructor(gl: WebGLRenderingContext);
/**
* The fragment shader.
*/
fragmentSrc: string[];
gl: WebGLRenderingContext;
/**
* The WebGL program.
*/
program: WebGLProgram;
/**
* The vertex shader.
*/
vertexSrc: string[];
/**
* Destroys the shader.
*/
destroy(): void;
/**
* Initialises the shader.
*/
init(): void;
}
export class Point {
constructor(x?: number, y?: number);
x: number;
y: number;
clone(): Point;
set(x: number, y: number): void;
}
export class Polygon implements HitArea {
constructor(points: Point[]);
constructor(points: number[]);
constructor(...points: Point[]);
constructor(...points: number[]);
points: any[];
clone(): Polygon;
contains(x: number, y: number): boolean;
}
export class Rectangle implements HitArea {
constructor(x?: number, y?: number, width?: number, height?: number);
x: number;
y: number;
width: number;
height: number;
clone(): Rectangle;
contains(x: number, y: number): boolean;
}
export class RGBSplitFilter extends AbstractFilter {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
red: Point;
green: Point;
blue: Point;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
}
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
export class Rope extends Strip {
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
points: Point[];
vertices: number[];
2016-06-17 11:46:47 +00:00
/**
*
*
* @param texture - The texture to use on the rope.
* @param points - An array of {PIXI.Point}.
*/
2016-07-01 15:57:13 +00:00
constructor(texture: Texture, points: Point[]);
refresh(): void;
setTexture(texture: Texture): void;
}
export class RoundedRectangle implements HitArea {
constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
x: number;
y: number;
width: number;
height: number;
radius: number;
clone(): RoundedRectangle;
contains(x: number, y: number): boolean;
}
export class SepiaFilter extends AbstractFilter {
sepia: number;
}
export class SmartBlurFilter extends AbstractFilter {
blur: number;
}
export class SpineLoader implements Mixin {
url: string;
crossorigin: boolean;
loaded: boolean;
constructor(url: string, crossOrigin: boolean);
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
export class SpineTextureLoader {
constructor(basePath: string, crossorigin: boolean);
load(page: AtlasPage, file: string): void;
unload(texture: BaseTexture): void;
}
2016-06-17 11:46:47 +00:00
/**
* The Sprite object is the base for all textured objects that are rendered to the screen
*/
2016-07-01 15:57:13 +00:00
export class Sprite extends DisplayObjectContainer {
2016-06-17 11:46:47 +00:00
/**
* The Sprite object is the base for all textured objects that are rendered to the screen
*
* @param texture The texture for this sprite
*
* A sprite can be created directly from an image like this :
* var sprite = new PIXI.Sprite.fromImage('assets/image.png');
* yourStage.addChild(sprite);
* then obviously don't forget to add it to the stage you have already created
*/
2016-07-01 15:57:13 +00:00
constructor(texture: Texture);
2016-06-17 11:46:47 +00:00
/**
* The anchor sets the origin point of the texture.
* The default is 0,0 this means the texture's origin is the top left
* Setting than anchor to 0.5,0.5 means the textures origin is centered
* Setting the anchor to 1,1 would mean the textures origin points will be the bottom right corner
*/
2016-07-01 15:57:13 +00:00
anchor: Point;
2016-06-17 11:46:47 +00:00
/**
* The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.
*
* Warning: You cannot have a blend mode and a filter active on the same Sprite. Doing so will render the sprite invisible.
* Default: PIXI.blendModes.NORMAL;
*/
2016-07-01 15:57:13 +00:00
blendMode: blendModes;
2016-06-17 11:46:47 +00:00
/**
* Controls if this Sprite is processed by the core Phaser game loops and Group loops.
* Default: true
*/
2016-07-01 15:57:13 +00:00
exists: boolean;
2016-06-17 11:46:47 +00:00
/**
* The shader that will be used to render the texture to the stage. Set to null to remove a current shader.
* Default: null
*/
2016-07-01 15:57:13 +00:00
shader: IPixiShader;
2016-06-17 11:46:47 +00:00
/**
* The texture that the sprite is using
*/
2016-07-01 15:57:13 +00:00
texture: Texture;
2016-06-17 11:46:47 +00:00
/**
* The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.
* Default: 0xFFFFFF
*/
2016-07-01 15:57:13 +00:00
tint: number;
2016-06-17 11:46:47 +00:00
/**
* Sets the texture of the sprite. Be warned that this doesn't remove or destroy the previous
* texture this Sprite was using.
*
* @param texture The PIXI texture that is displayed by the sprite
* @param destroy Call Texture.destroy on the current texture before replacing it with the new one?
*/
2016-07-01 15:57:13 +00:00
setTexture(texture: Texture, destroyBase?: boolean): void;
}
2016-06-17 11:46:47 +00:00
/**
* The SpriteBatch class is a really fast version of the DisplayObjectContainer
* built solely for speed, so use when you need a lot of sprites or particles.
* And it's extremely easy to use :
*
* var container = new PIXI.SpriteBatch();
*
* stage.addChild(container);
*
* for(var i = 0; i < 100; i++)
* {
* var sprite = new PIXI.Sprite.fromImage("myImage.png");
* container.addChild(sprite);
* }
* And here you have a hundred sprites that will be renderer at the speed of light
*/
2016-07-01 15:57:13 +00:00
export class SpriteBatch extends DisplayObjectContainer {
2016-06-17 11:46:47 +00:00
/**
* The SpriteBatch class is a really fast version of the DisplayObjectContainer
* built solely for speed, so use when you need a lot of sprites or particles.
* And it's extremely easy to use :
*
* var container = new PIXI.SpriteBatch();
*
* stage.addChild(container);
*
* for(var i = 0; i < 100; i++)
* {
* var sprite = new PIXI.Sprite.fromImage("myImage.png");
* container.addChild(sprite);
* }
* And here you have a hundred sprites that will be renderer at the speed of light
*
* @param texture -
*/
2016-07-01 15:57:13 +00:00
constructor(texture?: Texture);
ready: boolean;
textureThing: Texture;
initWebGL(gl: WebGLRenderingContext): void;
}
export class SpriteSheetLoader implements Mixin {
constructor(url: string, crossorigin?: boolean);
baseUrl: string;
crossorigin: boolean;
frames: any;
texture: Texture;
url: string;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
load(): void;
}
export class Strip extends DisplayObjectContainer {
static DrawModes: {
TRIANGLE_STRIP: number;
TRIANGLES: number;
};
2016-06-17 11:46:47 +00:00
/**
*
*
* @param texture The texture to use
* @param width the width
* @param height the height
*/
2016-07-01 15:57:13 +00:00
constructor(texture: Texture);
2016-06-17 11:46:47 +00:00
/**
* The blend mode to be applied to the sprite. Set to PIXI.blendModes.NORMAL to remove any blend mode.
* Default: PIXI.blendModes.NORMAL;
*/
2016-07-01 15:57:13 +00:00
blendMode: number;
colors: number[];
2016-06-17 11:46:47 +00:00
/**
* Whether the strip is dirty or not
*/
2016-07-01 15:57:13 +00:00
dirty: boolean;
indices: number[];
2016-06-17 11:46:47 +00:00
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles to overlap a bit with each other.
*/
2016-07-01 15:57:13 +00:00
canvasPadding: number;
2016-06-17 11:46:47 +00:00
/**
* The texture of the strip
*/
2016-07-01 15:57:13 +00:00
texture: Texture;
uvs: number[];
vertices: number[];
2016-06-17 11:46:47 +00:00
/**
* Returns the bounds of the mesh as a rectangle. The bounds calculation takes the worldTransform into account.
*
* @param matrix the transformation matrix of the sprite
* @return the framing rectangle
*/
2016-07-01 15:57:13 +00:00
getBounds(matrix?: Matrix): Rectangle;
}
2016-06-17 11:46:47 +00:00
/**
* A texture stores the information that represents an image or part of an image. It cannot be added
* to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used.
*/
2016-07-01 15:57:13 +00:00
export class Texture implements Mixin {
static emptyTexture: Texture;
2016-06-17 11:46:47 +00:00
/**
* Helper function that creates a new a Texture based on the given canvas element.
*
* @param canvas The canvas element source of the texture
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
*/
2016-07-01 15:57:13 +00:00
static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): Texture;
2016-06-17 11:46:47 +00:00
/**
* A texture stores the information that represents an image or part of an image. It cannot be added
* to the display list directly. Instead use it as the texture for a PIXI.Sprite. If no frame is provided then the whole image is used.
*
* @param baseTexture The base texture source to create the texture from
* @param frame The rectangle frame of the texture to show
* @param crop The area of original texture
* @param trim Trimmed texture rectangle
*/
2016-07-01 15:57:13 +00:00
constructor(baseTexture: BaseTexture, frame?: Rectangle, crop?: Rectangle, trim?: Rectangle);
2016-06-17 11:46:47 +00:00
/**
* The base texture that this texture uses.
*/
2016-07-01 15:57:13 +00:00
baseTexture: BaseTexture;
2016-06-17 11:46:47 +00:00
/**
* This is the area of the BaseTexture image to actually copy to the Canvas / WebGL when rendering,
* irrespective of the actual frame size or placement (which can be influenced by trimmed texture atlases)
*/
2016-07-01 15:57:13 +00:00
crop: Rectangle;
2016-06-17 11:46:47 +00:00
/**
* The frame specifies the region of the base texture that this texture uses
*/
2016-07-01 15:57:13 +00:00
frame: Rectangle;
2016-06-17 11:46:47 +00:00
/**
* The height of the Texture in pixels.
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* Does this Texture have any frame data assigned to it?
*/
2016-07-01 15:57:13 +00:00
noFrame: boolean;
2016-06-17 11:46:47 +00:00
/**
* This will let a renderer know that a texture has been updated (used mainly for webGL uv updates)
*/
2016-07-01 15:57:13 +00:00
requiresUpdate: boolean;
2016-06-17 11:46:47 +00:00
/**
* The texture trim data.
*/
2016-07-01 15:57:13 +00:00
trim: Point;
2016-06-17 11:46:47 +00:00
/**
* The width of the Texture in pixels.
*/
2016-07-01 15:57:13 +00:00
width: number;
scope: any;
2016-06-17 11:46:47 +00:00
/**
* This will let the renderer know if the texture is valid. If it's not then it cannot be rendered.
*/
2016-07-01 15:57:13 +00:00
valid: boolean;
listeners(eventName: string): Function[];
emit(eventName: string, data?: any): boolean;
dispatchEvent(eventName: string, data?: any): boolean;
on(eventName: string, fn: Function): Function;
addEventListener(eventName: string, fn: Function): Function;
once(eventName: string, fn: Function): Function;
off(eventName: string, fn: Function): Function;
removeAllEventListeners(eventName: string): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys this texture
*
* @param destroyBase Whether to destroy the base texture as well
*/
2016-07-01 15:57:13 +00:00
destroy(destroyBase: boolean): void;
2016-06-17 11:46:47 +00:00
/**
* Specifies the region of the baseTexture that this texture will use.
*
* @param frame The frame of the texture to set it to
*/
2016-07-01 15:57:13 +00:00
setFrame(frame: Rectangle): void;
}
2016-06-17 11:46:47 +00:00
/**
* A tiling sprite is a fast way of rendering a tiling image
*/
2016-07-01 15:57:13 +00:00
export class TilingSprite extends Sprite {
2016-06-17 11:46:47 +00:00
/**
* A tiling sprite is a fast way of rendering a tiling image
*
* @param texture the texture of the tiling sprite
* @param width the width of the tiling sprite
* @param height the height of the tiling sprite
*/
2016-07-01 15:57:13 +00:00
constructor(texture: Texture, width: number, height: number);
2016-06-17 11:46:47 +00:00
/**
* The CanvasBuffer object that the tiled texture is drawn to.
*/
2016-07-01 15:57:13 +00:00
canvasBuffer: PIXI.CanvasBuffer;
2016-06-17 11:46:47 +00:00
/**
* The blend mode to be applied to the sprite
* Default: PIXI.blendModes.NORMAL;
*/
2016-07-01 15:57:13 +00:00
blendMode: number;
2016-06-17 11:46:47 +00:00
/**
* If true the TilingSprite will run generateTexture on its **next** render pass.
* This is set by the likes of Phaser.LoadTexture.setFrame.
* Default: true
*/
2016-07-01 15:57:13 +00:00
refreshTexture: boolean;
2016-06-17 11:46:47 +00:00
/**
* The texture that the sprite is using
*/
2016-07-01 15:57:13 +00:00
texture: Texture;
2016-06-17 11:46:47 +00:00
/**
* If enabled a green rectangle will be drawn behind the generated tiling texture, allowing you to visually
* debug the texture being used.
*/
2016-07-01 15:57:13 +00:00
textureDebug: boolean;
2016-06-17 11:46:47 +00:00
/**
* The tint applied to the sprite. This is a hex value
* Default: 0xFFFFFF
*/
2016-07-01 15:57:13 +00:00
tint: number;
2016-06-17 11:46:47 +00:00
/**
* The offset position of the image that is being tiled
*/
2016-07-01 15:57:13 +00:00
tilePosition: Point;
2016-06-17 11:46:47 +00:00
/**
* The Context fill pattern that is used to draw the TilingSprite in Canvas mode only (will be null in WebGL).
*/
2016-07-01 15:57:13 +00:00
tilePattern: PIXI.Texture;
2016-06-17 11:46:47 +00:00
/**
* The scaling of the image that is being tiled
*/
2016-07-01 15:57:13 +00:00
tileScale: Point;
2016-06-17 11:46:47 +00:00
/**
* A point that represents the scale of the texture object
*/
2016-07-01 15:57:13 +00:00
tileScaleOffset: Point;
2016-06-17 11:46:47 +00:00
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param forcePowerOfTwo Whether we want to force the texture to be a power of two
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
generateTilingTexture(forcePowerOfTwo?: boolean): void;
2016-06-17 11:46:47 +00:00
/**
* Sets the texture of the sprite. Be warned that this doesn't remove or destroy the previous
* texture this Sprite was using.
*
* @param texture The PIXI texture that is displayed by the sprite
* @param destroy Call Texture.destroy on the current texture before replacing it with the new one?
*/
2016-07-01 15:57:13 +00:00
setTexture(texture: Texture): void;
}
export class TiltShiftFilter extends AbstractFilter {
blur: number;
gradientBlur: number;
start: number;
end: number;
}
export class TiltShiftXFilter extends AbstractFilter {
blur: number;
gradientBlur: number;
start: number;
end: number;
updateDelta(): void;
}
export class TiltShiftYFilter extends AbstractFilter {
blur: number;
gradientBlur: number;
start: number;
end: number;
updateDelta(): void;
}
export class TwistFilter extends AbstractFilter {
angle: number;
offset: Point;
radius: number;
}
export class VideoTexture extends BaseTexture {
static baseTextureFromVideo(video: HTMLVideoElement, scaleMode: number): BaseTexture;
static textureFromVideo(video: HTMLVideoElement, scaleMode: number): Texture;
static fromUrl(videoSrc: string, scaleMode?: number, autoPlay?: boolean, type?: string, loop?: boolean): Texture;
controls: boolean;
autoUpdate: boolean;
type: string;
changeSource(src: string, type: string, loop: boolean): void;
play(): void;
stop(): void;
destroy(): void;
updateBound(): void;
onPlayStart: () => void;
onPlayStop: () => void;
onCanPlay: (event: any) => void;
}
export class WebGLBlendModeManager {
currentBlendMode: number;
2016-06-17 11:46:47 +00:00
/**
* Destroys this object.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Sets-up the given blendMode from WebGL's point of view.
*
* @param blendMode the blendMode, should be a Pixi const, such as PIXI.BlendModes.ADD
*/
2016-07-01 15:57:13 +00:00
setBlendMode(blendMode: number): boolean;
2016-06-17 11:46:47 +00:00
/**
* Sets the WebGL Context.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
}
export class WebGLFastSpriteBatch {
constructor(gl: CanvasRenderingContext2D);
currentBatchSize: number;
currentBaseTexture: BaseTexture;
currentBlendMode: number;
renderSession: RenderSession;
drawing: boolean;
indexBuffer: any;
2016-06-17 11:46:47 +00:00
/**
* Index data
*/
2016-07-01 15:57:13 +00:00
indices: number[];
lastIndexCount: number;
matrix: Matrix;
maxSize: number;
shader: IPixiShader;
size: number;
vertexBuffer: any;
2016-06-17 11:46:47 +00:00
/**
* Vertex data
*/
2016-07-01 15:57:13 +00:00
vertices: number[];
vertSize: number;
end(): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param spriteBatch -
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
begin(spriteBatch: SpriteBatch, renderSession: RenderSession): void;
destroy(removeView?: boolean): void;
flush(): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param spriteBatch -
*/
2016-07-01 15:57:13 +00:00
render(spriteBatch: SpriteBatch): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param sprite -
*/
2016-07-01 15:57:13 +00:00
renderSprite(sprite: Sprite): void;
2016-06-17 11:46:47 +00:00
/**
* Sets the WebGL Context.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
start(): void;
stop(): void;
}
export class WebGLFilterManager {
filterStack: AbstractFilter[];
transparent: boolean;
offsetX: number;
offsetY: number;
2016-06-17 11:46:47 +00:00
/**
* Applies the filter to the specified area.
*
* @param filter the filter that needs to be applied
* @param filterArea TODO - might need an update
* @param width the horizontal range of the filter
* @param height the vertical range of the filter
*/
2016-07-01 15:57:13 +00:00
applyFilterPass(filter: AbstractFilter, filterArea: Texture, width: number, height: number): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param renderSession -
* @param buffer -
*/
2016-07-01 15:57:13 +00:00
begin(renderSession: RenderSession, buffer: ArrayBuffer): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys the filter and removes it from the filter stack.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the shader buffers.
*/
2016-07-01 15:57:13 +00:00
initShaderBuffers(): void;
2016-06-17 11:46:47 +00:00
/**
* Removes the last filter from the filter stack and doesn't return it.
*/
2016-07-01 15:57:13 +00:00
popFilter(): void;
2016-06-17 11:46:47 +00:00
/**
* Applies the filter and adds it to the current filter stack.
*
* @param filterBlock the filter that will be pushed to the current filter stack
*/
2016-07-01 15:57:13 +00:00
pushFilter(filterBlock: FilterBlock): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the context and the properties.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
}
2016-06-17 11:46:47 +00:00
/**
* A set of functions used by the webGL renderer to draw the primitive graphics data
*/
2016-07-01 15:57:13 +00:00
export class WebGLGraphics {
static graphicsDataPool: any[];
2016-06-17 11:46:47 +00:00
/**
* Renders the graphics object
*
* @param graphics -
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
static renderGraphics(graphics: Graphics, renderRession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Updates the graphics object
*
* @param graphicsData The graphics object to update
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
static updateGraphics(graphics: Graphics, gl: WebGLRenderingContext): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param webGL -
* @param type -
*/
2016-07-01 15:57:13 +00:00
static switchMode(webGL: WebGLRenderingContext, type: number): any;
2016-06-17 11:46:47 +00:00
/**
* Builds a rectangle to draw
*
* @param graphicsData The graphics object containing all the necessary properties
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildRectangle(graphicsData: GraphicsData, webGLData: any): void;
2016-06-17 11:46:47 +00:00
/**
* Builds a rounded rectangle to draw
*
* @param graphicsData The graphics object containing all the necessary properties
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildRoundedRectangle(graphicsData: GraphicsData, webGLData: any): void;
2016-06-17 11:46:47 +00:00
/**
* Calculate the points for a quadratic bezier curve. (helper function..)
* Based on: https://stackoverflow.com/questions/785097/how-do-i-implement-a-bezier-curve-in-c
*
* @param fromX Origin point x
* @param fromY Origin point x
* @param cpX Control point x
* @param cpY Control point y
* @param toX Destination point x
* @param toY Destination point y
*/
2016-07-01 15:57:13 +00:00
static quadraticBezierCurve(fromX: number, fromY: number, cpX: number, cpY: number, toX: number, toY: number): number[];
2016-06-17 11:46:47 +00:00
/**
* Builds a circle to draw
*
* @param graphicsData The graphics object to draw
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildCircle(graphicsData: GraphicsData, webGLData: any): void;
2016-06-17 11:46:47 +00:00
/**
* Builds a line to draw
*
* @param graphicsData The graphics object containing all the necessary properties
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildLine(graphicsData: GraphicsData, webGLData: any): void;
2016-06-17 11:46:47 +00:00
/**
* Builds a complex polygon to draw
*
* @param graphicsData The graphics object containing all the necessary properties
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildComplexPoly(graphicsData: GraphicsData, webGLData: any): void;
2016-06-17 11:46:47 +00:00
/**
* Builds a polygon to draw
*
* @param graphicsData The graphics object containing all the necessary properties
* @param webGLData -
*/
2016-07-01 15:57:13 +00:00
static buildPoly(graphicsData: GraphicsData, webGLData: any): boolean;
reset(): void;
upload(): void;
}
export class WebGLGraphicsData {
constructor(gl: WebGLRenderingContext);
gl: WebGLRenderingContext;
glPoints: any[];
color: number[];
points: any[];
indices: any[];
buffer: WebGLBuffer;
indexBuffer: WebGLBuffer;
mode: number;
alpha: number;
dirty: boolean;
reset(): void;
upload(): void;
}
export class WebGLMaskManager {
2016-06-17 11:46:47 +00:00
/**
* Destroys the mask stack.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Removes the last filter from the filter stack and doesn't return it.
*
* @param maskData -
* @param renderSession an object containing all the useful parameters
*/
2016-07-01 15:57:13 +00:00
popMask(renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Applies the Mask and adds it to the current filter stack.
*
* @param maskData -
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
pushMask(maskData: any[], renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Sets the drawing context to the one given in parameter.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
}
2016-06-17 11:46:47 +00:00
/**
* The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer
* should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs.
* So no need for Sprite Batches or Sprite Clouds.
* Don't forget to add the view to your DOM or you will not see anything :)
*/
2016-07-01 15:57:13 +00:00
export class WebGLRenderer implements PixiRenderer {
static createWebGLTexture(texture: Texture, gl: WebGLRenderingContext): void;
2016-06-17 11:46:47 +00:00
/**
* The WebGLRenderer draws the stage and all its content onto a webGL enabled canvas. This renderer
* should be used for browsers that support webGL. This Render works by automatically managing webGLBatchs.
* So no need for Sprite Batches or Sprite Clouds.
* Don't forget to add the view to your DOM or you will not see anything :)
*
* @param game A reference to the Phaser Game instance
*/
2016-07-01 15:57:13 +00:00
constructor(game: Phaser.Game);
game: Phaser.Game;
type: number;
2016-06-17 11:46:47 +00:00
/**
* The resolution of the renderer
* Default: 1
*/
2016-07-01 15:57:13 +00:00
resolution: number;
2016-06-17 11:46:47 +00:00
/**
* Whether the render view is transparent
*/
2016-07-01 15:57:13 +00:00
transparent: boolean;
2016-06-17 11:46:47 +00:00
/**
* Whether the render view should be resized automatically
*/
2016-07-01 15:57:13 +00:00
autoResize: boolean;
2016-06-17 11:46:47 +00:00
/**
* The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.
*/
2016-07-01 15:57:13 +00:00
preserveDrawingBuffer: boolean;
2016-06-17 11:46:47 +00:00
/**
* This sets if the WebGLRenderer will clear the context texture or not before the new render pass. If true:
* If the Stage is NOT transparent, Pixi will clear to alpha (0, 0, 0, 0).
* If the Stage is transparent, Pixi will clear to the target Stage's background color.
* Disable this by setting this to false. For example: if your game has a canvas filling background image, you often don't need this set.
*/
2016-07-01 15:57:13 +00:00
clearBeforeRender: boolean;
2016-06-17 11:46:47 +00:00
/**
* The width of the canvas view
*/
2016-07-01 15:57:13 +00:00
width: number;
2016-06-17 11:46:47 +00:00
/**
* The height of the canvas view
*/
2016-07-01 15:57:13 +00:00
height: number;
2016-06-17 11:46:47 +00:00
/**
* The canvas element that everything is drawn to
*/
2016-07-01 15:57:13 +00:00
view: HTMLCanvasElement;
projection: Point;
offset: Point;
2016-06-17 11:46:47 +00:00
/**
* Deals with managing the shader programs and their attribs
*/
2016-07-01 15:57:13 +00:00
shaderManager: WebGLShaderManager;
2016-06-17 11:46:47 +00:00
/**
* Manages the rendering of sprites
*/
2016-07-01 15:57:13 +00:00
spriteBatch: WebGLSpriteBatch;
2016-06-17 11:46:47 +00:00
/**
* Manages the masks using the stencil buffer
*/
2016-07-01 15:57:13 +00:00
maskManager: WebGLMaskManager;
2016-06-17 11:46:47 +00:00
/**
* Manages the filters
*/
2016-07-01 15:57:13 +00:00
filterManager: WebGLFilterManager;
2016-06-17 11:46:47 +00:00
/**
* Manages the stencil buffer
*/
2016-07-01 15:57:13 +00:00
stencilManager: WebGLStencilManager;
2016-06-17 11:46:47 +00:00
/**
* Manages the blendModes
*/
2016-07-01 15:57:13 +00:00
blendModeManager: WebGLBlendModeManager;
renderSession: RenderSession;
initContext(): void;
2016-06-17 11:46:47 +00:00
/**
* Renders the stage to its webGL view
*
* @param stage the Stage element to be rendered
*/
2016-07-01 15:57:13 +00:00
render(stage: DisplayObjectContainer): void;
2016-06-17 11:46:47 +00:00
/**
* Renders a Display Object.
*
* @param displayObject The DisplayObject to render
* @param projection The projection
* @param buffer a standard WebGL buffer
*/
2016-07-01 15:57:13 +00:00
renderDisplayObject(displayObject: DisplayObject, projection: Point, buffer: WebGLBuffer): void;
2016-06-17 11:46:47 +00:00
/**
* Resizes the webGL view to the specified width and height.
*
* @param width the new width of the webGL view
* @param height the new height of the webGL view
*/
2016-07-01 15:57:13 +00:00
resize(width: number, height: number): void;
2016-06-17 11:46:47 +00:00
/**
* Updates and Creates a WebGL texture for the renderers context.
*
* @param texture the texture to update
* @return True if the texture was successfully bound, otherwise false.
*/
2016-07-01 15:57:13 +00:00
updateTexture(texture: Texture): void;
2016-06-17 11:46:47 +00:00
/**
* Removes everything from the renderer (event listeners, spritebatch, etc...)
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Maps Pixi blend modes to WebGL blend modes.
*/
2016-07-01 15:57:13 +00:00
mapBlendModes(): void;
}
export class WebGLShaderManager {
maxAttibs: number;
attribState: any[];
stack: any[];
tempAttribState: any[];
2016-06-17 11:46:47 +00:00
/**
* Destroys this object.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
* Takes the attributes given in parameters.
*
* @param attribs attribs
*/
2016-07-01 15:57:13 +00:00
setAttribs(attribs: ShaderAttribute[]): void;
2016-06-17 11:46:47 +00:00
/**
* Initialises the context and the properties.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
2016-06-17 11:46:47 +00:00
/**
* Sets the current shader.
*
* @param shader -
*/
2016-07-01 15:57:13 +00:00
setShader(shader: IPixiShader): boolean;
}
export class WebGLStencilManager {
stencilStack: any[];
reverse: boolean;
count: number;
2016-06-17 11:46:47 +00:00
/**
* TODO this does not belong here!
*
* @param graphics -
* @param webGLData -
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
bindGraphics(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys the mask stack.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param graphics -
* @param webGLData -
* @param renderSession -
*/
2016-07-01 15:57:13 +00:00
popStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void;
pushStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Sets the drawing context to the one given in parameter.
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
}
export class WebGLSpriteBatch {
blendModes: number[];
2016-06-17 11:46:47 +00:00
/**
* View on the vertices as a Uint32Array
*/
2016-07-01 15:57:13 +00:00
colors: number[];
currentBatchSize: number;
currentBaseTexture: Texture;
defaultShader: AbstractFilter;
dirty: boolean;
drawing: boolean;
2016-06-17 11:46:47 +00:00
/**
* Holds the indices
*/
2016-07-01 15:57:13 +00:00
indices: number[];
lastIndexCount: number;
2016-06-17 11:46:47 +00:00
/**
* View on the vertices as a Float32Array
*/
2016-07-01 15:57:13 +00:00
positions: number[];
textures: Texture[];
shaders: IPixiShader[];
2016-06-17 11:46:47 +00:00
/**
* The number of images in the SpriteBatch before it flushes
*/
2016-07-01 15:57:13 +00:00
size: number;
sprites: any[];
2016-06-17 11:46:47 +00:00
/**
* Holds the vertices
*/
2016-07-01 15:57:13 +00:00
vertices: number[];
vertSize: number;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param renderSession The RenderSession object
*/
2016-07-01 15:57:13 +00:00
begin(renderSession: RenderSession): void;
2016-06-17 11:46:47 +00:00
/**
* Destroys the SpriteBatch.
*/
2016-07-01 15:57:13 +00:00
destroy(): void;
end(): void;
2016-06-17 11:46:47 +00:00
/**
* Renders the content and empties the current batch.
*/
2016-07-01 15:57:13 +00:00
flush(shader?: IPixiShader): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param sprite the sprite to render when using this spritebatch
* @param matrix - Optional matrix. If provided the Display Object will be rendered using this matrix, otherwise it will use its worldTransform.
*/
2016-07-01 15:57:13 +00:00
render(sprite: Sprite): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param texture -
* @param size -
* @param startIndex -
*/
2016-07-01 15:57:13 +00:00
renderBatch(texture: Texture, size: number, startIndex: number): void;
2016-06-17 11:46:47 +00:00
/**
* Renders a TilingSprite using the spriteBatch.
*
* @param sprite the sprite to render
*/
2016-07-01 15:57:13 +00:00
renderTilingSprite(sprite: TilingSprite): void;
setBlendMode(blendMode: blendModes): void;
2016-06-17 11:46:47 +00:00
/**
*
*
* @param gl the current WebGL drawing context
*/
2016-07-01 15:57:13 +00:00
setContext(gl: WebGLRenderingContext): void;
start(): void;
stop(): void;
}
2016-06-17 11:46:47 +00:00
/**
* A RenderTexture is a special texture that allows any Pixi display object to be rendered to it.
*
* __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded otherwise black rectangles will be drawn instead.
*
* A RenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:
*
* var renderTexture = new PIXI.RenderTexture(800, 600);
* var sprite = PIXI.Sprite.fromImage("spinObj_01.png");
* sprite.position.x = 800/2;
* sprite.position.y = 600/2;
* sprite.anchor.x = 0.5;
* sprite.anchor.y = 0.5;
* renderTexture.render(sprite);
*
* The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual position a DisplayObjectContainer should be used:
*
* var doc = new PIXI.DisplayObjectContainer();
* doc.addChild(sprite);
* renderTexture.render(doc); // Renders to center of renderTexture
*/
2016-07-01 15:57:13 +00:00
export class RenderTexture extends Texture {
2016-06-17 11:46:47 +00:00
/**
* A RenderTexture is a special texture that allows any Pixi display object to be rendered to it.
*
* __Hint__: All DisplayObjects (i.e. Sprites) that render to a RenderTexture should be preloaded otherwise black rectangles will be drawn instead.
*
* A RenderTexture takes a snapshot of any Display Object given to its render method. The position and rotation of the given Display Objects is ignored. For example:
*
* var renderTexture = new PIXI.RenderTexture(800, 600);
* var sprite = PIXI.Sprite.fromImage("spinObj_01.png");
* sprite.position.x = 800/2;
* sprite.position.y = 600/2;
* sprite.anchor.x = 0.5;
* sprite.anchor.y = 0.5;
* renderTexture.render(sprite);
*
* The Sprite in this case will be rendered to a position of 0,0. To render this sprite at its actual position a DisplayObjectContainer should be used:
*
* var doc = new PIXI.DisplayObjectContainer();
* doc.addChild(sprite);
* renderTexture.render(doc); // Renders to center of renderTexture
*
* @param width The width of the render texture
* @param height The height of the render texture
* @param renderer The renderer used for this RenderTexture
* @param scaleMode See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values
* @param resolution The resolution of the texture being generated
*/
2016-07-01 15:57:13 +00:00
constructor(width?: number, height?: number, renderer?: PixiRenderer, scaleMode?: scaleModes, resolution?: number);
2016-06-17 11:46:47 +00:00
/**
* The framing rectangle of the render texture
*/
2016-07-01 15:57:13 +00:00
frame: Rectangle;
2016-06-17 11:46:47 +00:00
/**
* The base texture object that this texture uses
*/
2016-07-01 15:57:13 +00:00
baseTexture: BaseTexture;
2016-06-17 11:46:47 +00:00
/**
* The renderer this RenderTexture uses. A RenderTexture can only belong to one renderer at the moment if its webGL.
*/
2016-07-01 15:57:13 +00:00
renderer: PixiRenderer;
2016-06-17 11:46:47 +00:00
/**
* The Resolution of the texture.
*/
2016-07-01 15:57:13 +00:00
resolution: number;
valid: boolean;
2016-06-17 11:46:47 +00:00
/**
* Clears the RenderTexture.
*/
2016-07-01 15:57:13 +00:00
clear(): void;
2016-06-17 11:46:47 +00:00
/**
* Will return a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.
* @return A base64 encoded string of the texture.
*/
2016-07-01 15:57:13 +00:00
getBase64(): string;
2016-06-17 11:46:47 +00:00
/**
* Creates a Canvas element, renders this RenderTexture to it and then returns it.
* @return A Canvas element with the texture rendered on.
*/
2016-07-01 15:57:13 +00:00
getCanvas(): HTMLCanvasElement;
2016-06-17 11:46:47 +00:00
/**
* Will return a HTML Image of the texture
*/
2016-07-01 15:57:13 +00:00
getImage(): HTMLImageElement;
2016-06-17 11:46:47 +00:00
/**
* Resizes the RenderTexture.
*
* @param width The width to resize to.
* @param height The height to resize to.
* @param updateBase Should the baseTexture.width and height values be resized as well?
*/
2016-07-01 15:57:13 +00:00
resize(width: number, height: number, updateBase: boolean): void;
render(displayObject: DisplayObject, matrix?: Matrix, clear?: boolean): void;
}
// SPINE
export class BoneData {
constructor(name: string, parent?: any);
name: string;
parent: any;
length: number;
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
}
export class SlotData {
constructor(name: string, boneData: BoneData);
name: string;
boneData: BoneData;
r: number;
g: number;
b: number;
a: number;
attachmentName: string;
}
export class Bone {
constructor(boneData: BoneData, parent?: any);
data: BoneData;
parent: any;
yDown: boolean;
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
worldRotation: number;
worldScaleX: number;
worldScaleY: number;
updateWorldTransform(flipX: boolean, flip: boolean): void;
setToSetupPose(): void;
}
export class Slot {
constructor(slotData: SlotData, skeleton: Skeleton, bone: Bone);
data: SlotData;
skeleton: Skeleton;
bone: Bone;
r: number;
g: number;
b: number;
a: number;
attachment: RegionAttachment;
setAttachment(attachment: RegionAttachment): void;
setAttachmentTime(time: number): void;
getAttachmentTime(): number;
setToSetupPose(): void;
}
export class Skin {
constructor(name: string);
name: string;
attachments: any;
addAttachment(slotIndex: number, name: string, attachment: RegionAttachment): void;
getAttachment(slotIndex: number, name: string): void;
}
export class Animation {
constructor(name: string, timelines: ISpineTimeline[], duration: number);
name: string;
timelines: ISpineTimeline[];
duration: number;
apply(skeleton: Skeleton, time: number, loop: boolean): void;
min(skeleton: Skeleton, time: number, loop: boolean, alpha: number): void;
}
export class Curves {
constructor(frameCount: number);
curves: number[];
setLinear(frameIndex: number): void;
setStepped(frameIndex: number): void;
setCurve(frameIndex: number, cx1: number, cy1: number, cx2: number, cy2: number): void;
getCurvePercent(frameIndex: number, percent: number): number;
}
export interface ISpineTimeline {
curves: Curves;
frames: number[];
getFrameCount(): number;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class RotateTimeline implements ISpineTimeline {
constructor(frameCount: number);
curves: Curves;
frames: number[];
boneIndex: number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, angle: number): void;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class TranslateTimeline implements ISpineTimeline {
constructor(frameCount: number);
curves: Curves;
frames: number[];
boneIndex: number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class ScaleTimeline implements ISpineTimeline {
constructor(frameCount: number);
curves: Curves;
frames: number[];
boneIndex: number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, x: number, y: number): void;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class ColorTimeline implements ISpineTimeline {
constructor(frameCount: number);
curves: Curves;
frames: number[];
boneIndex: number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, r: number, g: number, b: number, a: number): void;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class AttachmentTimeline implements ISpineTimeline {
constructor(frameCount: number);
curves: Curves;
frames: number[];
attachmentNames: string[];
slotIndex: number;
getFrameCount(): number;
setFrame(frameIndex: number, time: number, attachmentName: string): void;
apply(skeleton: Skeleton, time: number, alpha: number): void;
}
export class SkeletonData {
bones: Bone[];
slots: Slot[];
skins: Skin[];
animations: Animation[];
defaultSkin: Skin;
findBone(boneName: string): Bone;
findBoneIndex(boneName: string): number;
findSlot(slotName: string): Slot;
findSlotIndex(slotName: string): number;
findSkin(skinName: string): Skin;
findAnimation(animationName: string): Animation;
}
export class Skeleton {
constructor(skeletonData: SkeletonData);
data: SkeletonData;
bones: Bone[];
slots: Slot[];
drawOrder: any[];
x: number;
y: number;
skin: Skin;
r: number;
g: number;
b: number;
a: number;
time: number;
flipX: boolean;
flipY: boolean;
updateWorldTransform(): void;
setToSetupPose(): void;
setBonesToSetupPose(): void;
setSlotsToSetupPose(): void;
getRootBone(): Bone;
findBone(boneName: string): Bone;
fineBoneIndex(boneName: string): number;
findSlot(slotName: string): Slot;
findSlotIndex(slotName: string): number;
setSkinByName(skinName: string): void;
setSkin(newSkin: Skin): void;
getAttachmentBySlotName(slotName: string, attachmentName: string): RegionAttachment;
getAttachmentBySlotIndex(slotIndex: number, attachmentName: string): RegionAttachment;
setAttachment(slotName: string, attachmentName: string): void;
update(data: number): void;
}
export class RegionAttachment {
offset: number[];
uvs: number[];
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
width: number;
height: number;
rendererObject: any;
regionOffsetX: number;
regionOffsetY: number;
regionWidth: number;
regionHeight: number;
regionOriginalWidth: number;
regionOriginalHeight: number;
setUVs(u: number, v: number, u2: number, v2: number, rotate: number): void;
updateOffset(): void;
computeVertices(x: number, y: number, bone: Bone, vertices: number[]): void;
}
export class AnimationStateData {
constructor(skeletonData: SkeletonData);
skeletonData: SkeletonData;
animationToMixTime: any;
defaultMix: number;
setMixByName(fromName: string, toName: string, duration: number): void;
setMix(from: string, to: string): number;
}
export class AnimationState {
constructor(stateData: any);
animationSpeed: number;
current: any;
previous: any;
currentTime: number;
previousTime: number;
currentLoop: boolean;
previousLoop: boolean;
mixTime: number;
mixDuration: number;
queue: Animation[];
update(delta: number): void;
apply(skeleton: any): void;
clearAnimation(): void;
setAnimation(animation: any, loop: boolean): void;
setAnimationByName(animationName: string, loop: boolean): void;
addAnimationByName(animationName: string, loop: boolean, delay: number): void;
addAnimation(animation: any, loop: boolean, delay: number): void;
isComplete(): number;
}
export class SkeletonJson {
constructor(attachmentLoader: AtlasAttachmentLoader);
attachmentLoader: AtlasAttachmentLoader;
scale: number;
readSkeletonData(root: any): SkeletonData;
readAttachment(skin: Skin, name: string, map: any): RegionAttachment;
readAnimation(name: string, map: any, skeletonData: SkeletonData): void;
readCurve(timeline: ISpineTimeline, frameIndex: number, valueMap: any): void;
toColor(hexString: string, colorIndex: number): number;
}
export class Atlas {
static FORMAT: {
alpha: number;
intensity: number;
luminanceAlpha: number;
rgb565: number;
rgba4444: number;
rgb888: number;
rgba8888: number;
};
static TextureFilter: {
nearest: number;
linear: number;
mipMap: number;
mipMapNearestNearest: number;
mipMapLinearNearest: number;
mipMapNearestLinear: number;
mipMapLinearLinear: number;
};
static textureWrap: {
mirroredRepeat: number;
clampToEdge: number;
repeat: number;
};
constructor(atlasText: string, textureLoader: AtlasLoader);
textureLoader: AtlasLoader;
pages: AtlasPage[];
regions: AtlasRegion[];
findRegion(name: string): AtlasRegion;
dispose(): void;
updateUVs(page: AtlasPage): void;
}
export class AtlasPage {
name: string;
format: number;
minFilter: number;
magFilter: number;
uWrap: number;
vWrap: number;
rendererObject: any;
width: number;
height: number;
}
export class AtlasRegion {
page: AtlasPage;
name: string;
x: number;
y: number;
width: number;
height: number;
u: number;
v: number;
u2: number;
v2: number;
offsetX: number;
offsetY: number;
originalWidth: number;
originalHeight: number;
index: number;
rotate: boolean;
splits: any[];
pads: any[];
}
export class AtlasReader {
constructor(text: string);
lines: string[];
index: number;
trim(value: string): string;
readLine(): string;
readValue(): string;
readTuple(tuple: number): number;
}
export class AtlasAttachmentLoader {
constructor(atlas: Atlas);
atlas: Atlas;
newAttachment(skin: Skin, type: number, name: string): RegionAttachment;
}
export class Spine extends DisplayObjectContainer {
constructor(url: string);
autoUpdate: boolean;
spineData: any;
skeleton: Skeleton;
stateData: AnimationStateData;
state: AnimationState;
slotContainers: DisplayObjectContainer[];
createSprite(slot: Slot, descriptor: { name: string }): Sprite[];
update(dt: number): void;
}
}
declare function requestAnimFrame(callback: Function): void;
declare module PIXI.PolyK {
export function Triangulate(p: number[]): number[];
}