@azerion/phaser
Version:
A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.
1,741 lines (1,330 loc) • 98.4 kB
TypeScript
// 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;
}
/**
* 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.
*/
export class AbstractFilter {
/**
* 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.
*/
constructor(fragmentSrc: string | string[], uniforms: any);
dirty: boolean;
padding: number;
uniforms: any;
fragmentSrc: string | string[];
apply(frameBuffer: WebGLFramebuffer): void;
/**
* Syncs the uniforms between the class object and the shaders.
*/
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;
}
/**
* A texture stores the information that represents an image. All textures have a base texture.
*/
export class BaseTexture implements Mixin {
/**
* 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
*/
static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): BaseTexture;
/**
* 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
*/
constructor(source: HTMLImageElement, scaleMode: scaleModes);
/**
* 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
*/
constructor(source: HTMLCanvasElement, scaleMode: scaleModes);
/**
* [read-only] The height of the base texture set when the image has loaded
*/
height: number;
/**
* [read-only] Set to true once the base texture has loaded
*/
hasLoaded: boolean;
/**
* 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
*/
mipmap: boolean;
/**
* Controls if RGB channels should be pre-multiplied by Alpha (WebGL only)
* Default: true
*/
premultipliedAlpha: boolean;
/**
* The Resolution of the texture.
*/
resolution: number;
/**
* The scale mode to apply when scaling this texture
* Default: PIXI.scaleModes.LINEAR
*/
scaleMode: scaleModes;
/**
* 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.
*/
skipRender: boolean;
/**
* The image source that is used to create the texture.
*/
source: HTMLImageElement;
/**
* [read-only] The width of the base texture set when the image has loaded
*/
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;
/**
* 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.
*/
forceLoaded(width: number, height: number): void;
/**
* Destroys this base texture
*/
destroy(): void;
/**
* Sets all glTextures to be dirty.
*/
dirty(): void;
/**
* 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.
*/
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;
}
/**
* Creates a Canvas element of the given size.
*/
export class CanvasBuffer {
/**
* 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
*/
constructor(width: number, height: number);
/**
* The Canvas object that belongs to this CanvasBuffer.
*/
canvas: HTMLCanvasElement;
/**
* A CanvasRenderingContext2D object representing a two-dimensional rendering context.
*/
context: CanvasRenderingContext2D;
/**
* The height of the Canvas in pixels.
*/
height: number;
/**
* The width of the Canvas in pixels.
*/
width: number;
/**
* Frees the canvas up for use again.
*/
destroy(): void;
/**
* Clears the canvas that was created by the CanvasBuffer class.
*/
clear(): void;
/**
* 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
*/
resize(width: number, height: number): void;
}
/**
* The CanvasPool is a global static object that allows Pixi and Phaser to pool canvas DOM elements.
*/
export class CanvasPool {
/**
* 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.
*/
static create(parent: HTMLElement, width?: number, height?: number): HTMLCanvasElement;
/**
* Gets the first free canvas index from the pool.
*/
static getFirst(): HTMLCanvasElement;
/**
* Removes the parent from a canvas element from the pool, freeing it up for re-use.
*
* @param parent The parent of the canvas element.
*/
static remove(parent: HTMLElement): void;
/**
* Removes the parent from a canvas element from the pool, freeing it up for re-use.
*
* @param canvas The canvas element to remove
*/
static removeByCanvas(canvas: HTMLCanvasElement): HTMLCanvasElement;
/**
* Gets the total number of used canvas elements in the pool.
* @return The number of in-use (parented) canvas elements in the pool.
*/
static getTotal(): number;
/**
* Gets the total number of free canvas elements in the pool.
* @return The number of free (un-parented) canvas elements in the pool.
*/
static getFree(): number;
}
/**
* A set of functions used to handle masking.
*/
export class CanvasMaskManager {
/**
* 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.
*/
pushMask(maskData: MaskData, renderSession: RenderSession): void;
/**
* 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.
*/
popMask(renderSession: RenderSession): void;
}
/**
* 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 :)
*/
export class CanvasRenderer implements PixiRenderer {
/**
* 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
*/
constructor(game: Phaser.Game);
game: Phaser.Game;
/**
* The renderer type.
*/
type: number;
/**
* The resolution of the canvas.
*/
resolution: number;
/**
* 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.
*/
clearBeforeRender: boolean;
/**
* Whether the render view is transparent
*/
transparent: boolean;
/**
* Whether the render view should be resized automatically
*/
autoResize: boolean;
/**
* The width of the canvas view
* Default: 800
*/
width: number;
/**
* The height of the canvas view
* Default: 600
*/
height: number;
/**
* The canvas element that everything is drawn to.
*/
view: HTMLCanvasElement;
/**
* The canvas 2d context that everything is drawn with
*/
context: CanvasRenderingContext2D;
/**
* Boolean flag controlling canvas refresh.
*/
refresh: boolean;
/**
* Internal var.
*/
count: number;
maskManager: CanvasMaskManager;
/**
* The render session is just a bunch of parameter used for rendering
*/
renderSession: RenderSession;
/**
* Renders the DisplayObjectContainer, usually the Phaser.Stage, to this canvas view.
*
* @param root The root element to be rendered.
*/
render(stage: DisplayObjectContainer): void;
/**
* 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
*/
resize(width: number, height: number): void;
/**
* Removes everything from the renderer and optionally removes the Canvas DOM element.
*
* @param removeView Removes the Canvas element from the DOM. - Default: true
*/
destroy(removeView?: boolean): void;
}
/**
* Utility methods for Sprite/Texture tinting.
*/
export class CanvasTinter {
/**
* 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
*/
static getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement;
/**
* 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
*/
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;
/**
* Whether or not the Canvas BlendModes are supported, consequently the ability to tint using the multiply method.
*/
static canUseMultiply: boolean;
static tintMethod: any;
}
export class Circle implements HitArea {
constructor(x: number, y: number, radius: number);
x: number;
y: number;
radius: number;
clone(): Circle;
contains(x: number, y: number): boolean;
getBounds(): Rectangle;
}
export class ColorMatrixFilter extends AbstractFilter {
constructor();
matrix: number[];
}
export class ColorStepFilter extends AbstractFilter {
step: number;
}
export class ConvolutionFilter extends AbstractFilter {
constructor(matrix: number[], width: number, height: number);
matrix: Matrix;
width: number;
height: number;
}
export class CrossHatchFilter extends AbstractFilter {
blur: number;
}
export class DisplacementFilter extends AbstractFilter {
constructor(texture: Texture);
map: Texture;
offset: Point;
scale: Point;
}
export class DotScreenFilter extends AbstractFilter {
angle: number;
scale: Point;
}
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;
displayObjectUpdateTransform(parent?: DisplayObjectContainer): void;
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;
updateTransform(parent?: DisplayObjectContainer): void;
}
/**
* 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.
*/
export class DisplayObjectContainer extends DisplayObject {
/**
* 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.
*/
constructor();
/**
* [read-only] The array of children of this container.
*/
children: DisplayObject[];
/**
* The height of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
*/
height: number;
/**
* The width of the displayObjectContainer, setting this will actually modify the scale to achieve the value set
*/
width: number;
/**
* 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.
*/
ignoreChildInput: boolean;
/**
* Adds a child to the container.
*
* @param child The DisplayObject to add to the container
* @return The child that was added.
*/
addChild(child: DisplayObject): DisplayObject;
/**
* 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.
*/
addChildAt(child: DisplayObject, index: number): DisplayObject;
/**
* 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.
* @return The rectangular bounding area
*/
getBounds(targetCoordinateSpace?: DisplayObject | Matrix): Rectangle;
/**
* 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.
*/
getChildAt(index: number): DisplayObject;
/**
* 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
*/
getChildIndex(child: DisplayObject): number;
/**
* Retrieves the non-global local bounds of the displayObjectContainer as a rectangle without any transformations. The calculation takes all visible children into consideration.
* @return The rectangular bounding area
*/
getLocalBounds(): Rectangle;
/**
* Removes a child from the container.
*
* @param child The DisplayObject to remove
* @return The child that was removed.
*/
removeChild(child: DisplayObject): DisplayObject;
/**
* Removes a child from the specified index position.
*
* @param index The index to get the child from
* @return The child that was removed.
*/
removeChildAt(index: number): DisplayObject;
/**
* 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.
*/
removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[];
removeStageReference(): void;
/**
* 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
*/
setChildIndex(child: DisplayObject, index: number): void;
/**
* Swaps the position of 2 Display Objects within this container.
*
* @param child -
* @param child2 -
*/
swapChildren(child: DisplayObject, child2: DisplayObject): void;
/**
* Determines whether the specified display object is a child of the DisplayObjectContainer instance or the instance itself.
*
* @param child -
*/
contains(child: DisplayObject): boolean;
}
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;
}
/**
* Creates an homogenous object for tracking events so users can know what to expect.
*/
export class Event {
/**
* 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
*/
constructor(target: any, name: string, data: any);
/**
* The original target the event triggered on.
*/
target: any;
/**
* The string name of the event that this represents.
*/
type: string;
/**
* The data that was passed in with this event.
*/
data: any;
/**
* The timestamp when the event occurred.
*/
timeStamp: number;
/**
* Stops the propagation of events up the scene graph (prevents bubbling).
*/
stopPropagation(): void;
preventDefault(): void;
/**
* Stops the propagation of events to sibling listeners (no longer calls any listeners).
*/
stopImmediatePropagation(): void;
}
/**
* Mixins event emitter functionality to a class
*/
export class EventTarget {
/**
* Mixes in the properties of the EventTarget prototype onto another object
*
* @param object The obj to mix into
*/
static mixin(obj: any): void;
}
export class FilterTexture {
/**
*
*
* @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
*/
constructor(gl: WebGLRenderingContext, width: number, height: number, scaleMode: scaleModes);
fragmentSrc: string[];
frameBuffer: WebGLFramebuffer;
gl: WebGLRenderingContext;
program: WebGLProgram;
scaleMode: number;
texture: WebGLTexture;
/**
* Clears the filter texture.
*/
clear(): void;
/**
* 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
*/
resize(width: number, height: number): void;
/**
* Destroys the filter texture.
*/
destroy(): void;
}
/**
* A GraphicsData object.
*/
export class GraphicsData {
/**
* A GraphicsData object.
*/
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;
}
/**
* The Graphics class contains methods used to draw primitive shapes such as lines, circles and rectangles to the display, and color and fill them.
*/
export class Graphics extends DisplayObjectContainer {
static POLY: number;
static RECT: number;
static CIRC: number;
static ELIP: number;
static RREC: number;
/**
* 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;
*/
blendMode: number;
/**
* The bounds' padding used for bounds calculation.
*/
boundsPadding: number;
/**
* The alpha value used when filling the Graphics object.
*/
fillAlpha: number;
/**
* Whether this shape is being used as a mask.
*/
isMask: boolean;
/**
* The width (thickness) of any lines drawn.
*/
lineWidth: number;
/**
* The color of any lines drawn.
* Default: 0
*/
lineColor: number;
/**
* The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF to reset the tint.
* Default: 0xFFFFFF
*/
tint: number;
worldAlpha: number;
/**
* 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.
*/
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;
/**
* 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
*/
beginFill(color?: number, alpha?: number): Graphics;
/**
* 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
*/
bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Graphics;
/**
* Clears the graphics that were drawn to this Graphics object, and resets fill and line style settings.
*/
clear(): Graphics;
/**
* Destroys a previous cached sprite.
*/
destroyCachedSprite(): void;
/**
* 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
*/
drawCircle(x: number, y: number, diameter: number): Graphics;
/**
* 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
*/
drawEllipse(x: number, y: number, width: number, height: number): Graphics;
/**
* 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.
*/
drawPolygon(...path: any[]): Graphics;
/**
*
*
* @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
*/
drawRect(x: number, y: number, width: number, height: number): Graphics;
/**
*
*
* @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.
*/
drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Graphics;
/**
* 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.
*/
drawShape(shape: Circle): GraphicsData;
/**
* 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.
*/
drawShape(shape: Rectangle): GraphicsData;
/**
* 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.
*/
drawShape(shape: Ellipse): GraphicsData;
/**
* 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.
*/
drawShape(shape: Polygon): GraphicsData;
/**
* Applies a fill to the lines and shapes that were added since the last call to the beginFill() method.
*/
endFill(): Graphics;
/**
* 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
*/
generateTexture(resolution?: number, scaleMode?: number, padding?: number): RenderTexture;
/**
* 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
*/
lineStyle(lineWidth?: number, color?: number, alpha?: number): Graphics;
/**
* 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
*/
lineTo(x: number, y: number): Graphics;
/**
* Moves the current drawing position to x, y.
*
* @param x the X coordinate to move to
* @param y the Y coordinate to move to
*/
moveTo(x: number, y: number): Graphics;
/**
* 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
*/
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 {
/**
*
*
* @param gl the current WebGL drawing context
*/
constructor(gl: WebGLRenderingContext);
/**
* Uniform attributes cache.
*/
attributes: ShaderAttribute[];
/**
* The Default Vertex shader source.
*/
defaultVertexSrc: string[];
/**
* A dirty flag
*/
dirty: boolean;
/**
* A local flag
*/
firstRun: boolean;
/**
* A local texture counter for multi-texture shaders.
*/
textureCount: number;
/**
* The fragment shader.
*/
fragmentSrc: string[];
gl: WebGLRenderingContext;
/**
* The WebGL program.
*/
program: WebGLProgram;
vertexSrc: string[];
/**
* Initialises a Sampler2D uniform (which may only be available later on after initUniforms once the texture has loaded)
*/
initSampler2D(): void;
/**
* 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
*/
initUniforms(): void;
/**
* Updates the shader uniform values.
*/
syncUniforms(): void;
/**
* Destroys the shader.
*/
destroy(): void;
/**
* Initialises the shader.
*/
init(): void;
}
export class PixiFastShader implements IPixiShader {
/**
*
*
* @param gl the current WebGL drawing context
*/
constructor(gl: WebGLRenderingContext);
/**
* A local texture counter for multi-texture shaders.
*/
textureCount: number;
/**
* 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 PrimitiveShader implements IPixiShader {
/**
*
*
* @param gl the current WebGL drawing context
*/
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 ComplexPrimitiveShader implements IPixiShader {
/**
*
*
* @param gl the current WebGL drawing context
*/
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 StripShader implements IPixiShader {
/**
*
*
* @param gl the current WebGL drawing context
*/
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