diff --git a/typescript/phaser.d.ts b/typescript/phaser.d.ts index 2b3ec73d9..5ae962c6f 100644 --- a/typescript/phaser.d.ts +++ b/typescript/phaser.d.ts @@ -1,1363 +1,6 @@ -// Type definitions for PIXI 2.0.0 dev 2014-10-26 -// Project: https://github.com/GoodBoyDigital/pixi.js/ +/// -declare module PIXI { - - 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 BaseTextureCache: { [key: string]: BaseTexture } - export var TextureCache: { [key: string]: Texture } - - 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(number: 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 { - - height: number; - transparent: boolean; - type: number; - width: number; - view: HTMLCanvasElement; - - render(stage: Stage): void; - resize(width: number, height: number): void; - - } - - export interface PixiRendererOptions { - - 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; - 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; - - } - - export class AbstractFilter { - - constructor(fragmentSrc: string[], uniforms: any); - - dirty: boolean; - padding: number; - uniforms: any; - fragmentSrc: string[]; - - apply(frameBuffer: WebGLFramebuffer): void; - 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; - - } - - export class BaseTexture implements Mixin { - - static fromImage(imageUrl: string, crossorigin?: boolean, scaleMode?: scaleModes): BaseTexture; - static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): BaseTexture; - - constructor(source: HTMLImageElement, scaleMode: scaleModes); - constructor(source: HTMLCanvasElement, scaleMode: scaleModes); - - height: number; - hasLoaded: boolean; - premultipliedAlpha: boolean; - resolution: number; - scaleMode: scaleModes; - source: HTMLImageElement; - 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; - - destroy(): void; - dirty(): void; - updateSourceImage(newSrc: string): void; - 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 BitmapText extends DisplayObjectContainer { - - static fonts: any; - - constructor(text: string, style: BitmapTextStyle); - - dirty: boolean; - fontName: string; - fontSize: number; - textWidth: number; - textHeight: number; - tint: number; - style: BitmapTextStyle; - - setText(text: string): void; - setStyle(style: BitmapTextStyle): 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; - - } - - export class CanvasBuffer { - - constructor(width: number, height: number); - - canvas: HTMLCanvasElement; - context: CanvasRenderingContext2D; - height: number; - width: number; - - clear(): void; - resize(width: number, height: number): void; - - } - - export class CanvasMaskManager { - - pushMask(maskData: MaskData, renderSession: RenderSession): void; - popMask(renderSession: RenderSession): void; - - } - - export class CanvasRenderer implements PixiRenderer { - - constructor(width?: number, height?: number, options?: PixiRendererOptions); - - clearBeforeRender: boolean; - context: CanvasRenderingContext2D; - count: number; - height: number; - maskManager: CanvasMaskManager; - refresh: boolean; - renderSession: RenderSession; - resolution: number; - transparent: boolean; - type: number; - view: HTMLCanvasElement; - width: number; - - destroy(removeView?: boolean): void; - render(stage: Stage): void; - resize(width: number, height: number): void; - - } - - export class CanvasTinter { - - static getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement; - 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; - static roundColor(color: number): void; - - static cacheStepsPerColorChannel: number; - static convertTintToImage: boolean; - 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 { - - matrix: Matrix; - - } - - 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: Stage; - visible: boolean; - worldAlpha: number; - worldVisible: boolean; - x: number; - y: number; - - click(e: InteractionData): void; - getBounds(matrix?: Matrix): Rectangle; - getLocalBounds(): Rectangle; - generateTexture(resolution: number, scaleMode: scaleModes, renderer: PixiRenderer): RenderTexture; - mousedown(e: InteractionData): void; - mouseout(e: InteractionData): void; - mouseover(e: InteractionData): void; - mouseup(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: Stage): 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; - - } - - export class DisplayObjectContainer extends DisplayObject { - - constructor(); - - children: DisplayObject[]; - height: number; - width: number; - - addChild(child: DisplayObject): DisplayObject; - addChildAt(child: DisplayObject, index: number): DisplayObject; - getBounds(): Rectangle; - getChildAt(index: number): DisplayObject; - getChildIndex(child: DisplayObject): number; - getLocalBounds(): Rectangle; - removeChild(child: DisplayObject): DisplayObject; - removeChildAt(index: number): DisplayObject; - removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[]; - removeStageReference(): void; - setChildIndex(child: DisplayObject, index: number): void; - swapChildren(child: DisplayObject, child2: DisplayObject): void; - - } - - 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; - - } - - export class Event { - - constructor(target: any, name: string, data: any); - - target: any; - type: string; - data: any; - timeStamp: number; - - stopPropagation(): void; - preventDefault(): void; - stopImmediatePropagation(): void; - - } - - export class EventTarget { - - static mixin(obj: any): void; - - } - - export class FilterTexture { - - constructor(gl: WebGLRenderingContext, width: number, height: number, scaleMode: scaleModes); - - fragmentSrc: string[]; - frameBuffer: WebGLFramebuffer; - gl: WebGLRenderingContext; - program: WebGLProgram; - scaleMode: number; - texture: WebGLTexture; - - clear(): void; - resize(width: number, height: number): void; - destroy(): void; - - } - - export class GraphicsData { - - 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; - - } - - export class Graphics extends DisplayObjectContainer { - - blendMode: number; - boundsPadding: number; - fillAlpha: number; - isMask: boolean; - lineWidth: number; - lineColor: string; - tint: number; - worldAlpha: 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; - beginFill(color: number, alpha?: number): Graphics; - bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Graphics; - clear(): Graphics; - destroyCachedSprite(): void; - drawCircle(x: number, y: number, radius: number): Graphics; - drawEllipse(x: number, y: number, width: number, height: number): Graphics; - drawPolygon(path: any): Graphics; - drawRect(x: number, y: number, width: number, height: number): Graphics; - drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Graphics; - drawShape(shape: Circle): GraphicsData; - drawShape(shape: Rectangle): GraphicsData; - drawShape(shape: Ellipse): GraphicsData; - drawShape(shape: Polygon): GraphicsData; - endFill(): Graphics; - lineStyle(lineWidth: number, color: number, alpha: number): Graphics; - lineTo(x: number, y: number): Graphics; - moveTo(x: number, y: number): Graphics; - quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): Graphics; - updateBounds(): void; - - } - - 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; - - } - - 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: Stage; - touches: { [id: string]: InteractionData }; - - constructor(stage: Stage); - } - - 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 MovieClip extends Sprite { - - static fromFrames(frames: string[]): MovieClip; - static fromImages(images: HTMLImageElement[]): HTMLImageElement; - - constructor(textures: Texture[]); - - animationSpeed: number; - currentFrame: number; - loop: boolean; - playing: boolean; - textures: Texture[]; - totalFrames: number; - - gotoAndPlay(frameNumber: number): void; - gotoAndStop(frameNumber: number): void; - onComplete(): void; - play(): void; - stop(): 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 class IPixiShader { - - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - destroy(): void; - init(): void; - - } - - export class PixiShader implements IPixiShader { - - constructor(gl: WebGLRenderingContext); - - attributes: ShaderAttribute[]; - defaultVertexSrc: string[]; - dirty: boolean; - firstRun: boolean; - textureCount: number; - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - initSampler2D(): void; - initUniforms(): void; - syncUniforms(): void; - - destroy(): void; - init(): void; - - } - - export class PixiFastShader implements IPixiShader { - - constructor(gl: WebGLRenderingContext); - - textureCount: number; - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - destroy(): void; - init(): void; - - } - - export class PrimitiveShader implements IPixiShader { - - constructor(gl: WebGLRenderingContext); - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - destroy(): void; - init(): void; - - } - - export class ComplexPrimitiveShader implements IPixiShader { - - constructor(gl: WebGLRenderingContext); - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - destroy(): void; - init(): void; - - } - - export class StripShader implements IPixiShader { - - constructor(gl: WebGLRenderingContext); - fragmentSrc: string[]; - gl: WebGLRenderingContext; - program: WebGLProgram; - vertexSrc: string[]; - - destroy(): void; - 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: Point[]; - - 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 { - - red: Point; - green: Point; - blue: Point; - - } - - export class Rope extends Strip { - - points: Point[]; - - constructor(texture: Texture, points: Point[]); - - refresh(): void; - setTexture(texture: Texture): void; - - } - - 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 Spine extends DisplayObjectContainer { - - constructor(url: string); - - createSprite(slot: any, descriptior: any): void; - - } - - export class Sprite extends DisplayObjectContainer { - - static fromFrame(frameId: string): Sprite; - static fromImage(url: string, crossorigin?: boolean, scaleMode?: scaleModes): Sprite; - - constructor(texture: Texture); - - anchor: Point; - blendMode: blendModes; - shader: IPixiShader; - texture: Texture; - tint: number; - - setTexture(texture: Texture): void; - - } - - export class SpriteBatch extends DisplayObjectContainer { - - 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 Stage extends DisplayObjectContainer { - - constructor(backgroundColor: number); - - interactionManager: InteractionManager; - - getMousePosition(): Point; - setBackgroundColor(backgroundColor: number): void; - setInteractionDelegate(domElement: HTMLElement): void; - - } - - export class Strip extends DisplayObjectContainer { - - constructor(texture: Texture); - - colors: number[]; - dirty: boolean; - indices: number[]; - padding: number; - texture: Texture; - uvs: number[]; - vertices: number[]; - - } - - export class Text extends Sprite { - - constructor(text: string, style?: TextStyle); - - context: CanvasRenderingContext2D; - resolution: number; - - destroy(destroyTexture: boolean): void; - setStyle(style: TextStyle): void; - setText(text: string): void; - - } - - export class Texture implements Mixin { - - static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): Texture; - static fromFrame(frameId: string): Texture; - static fromImage(imageUrl: string, crossorigin?: boolean, scaleMode?: scaleModes): Texture; - static addTextureToCache(texture: Texture, id: string): void; - static removeTextureFromCache(id: string): Texture; - - constructor(baseTexture: BaseTexture, frame?: Rectangle, crop?: Rectangle, trim?: Rectangle); - - baseTexture: BaseTexture; - crop: Rectangle; - frame: Rectangle; - height: number; - noFrame: boolean; - requiresUpdate: boolean; - trim: Point; - width: number; - scope: any; - 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; - - destroy(destroyBase: boolean): void; - setFrame(frame: Rectangle): void; - - } - - export class TilingSprite extends Sprite { - - constructor(texture: Texture, width: number, height: number); - - blendMode: number; - texture: Texture; - tint: number; - tilePosition: Point; - tileScale: Point; - tileScaleOffset: Point; - - generateTilingTexture(forcePowerOfTwo: boolean): void; - 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 WebGLBlendModeManager { - - currentBlendMode: number; - - destroy(): void; - setBlendMode(blendMode: number): boolean; - setContext(gl: WebGLRenderingContext): void; - - } - - export class WebGLFastSpriteBatch { - - constructor(gl: CanvasRenderingContext2D); - - currentBatchSize: number; - currentBaseTexture: BaseTexture; - currentBlendMode: number; - renderSession: RenderSession; - drawing: boolean; - indexBuffer: any; - indices: number[]; - lastIndexCount: number; - matrix: Matrix; - maxSize: number; - shader: IPixiShader; - size: number; - vertexBuffer: any; - vertices: number[]; - vertSize: number; - - end(): void; - begin(spriteBatch: SpriteBatch, renderSession: RenderSession): void; - destroy(removeView?: boolean): void; - flush(): void; - render(spriteBatch: SpriteBatch): void; - renderSprite(sprite: Sprite): void; - setContext(gl: WebGLRenderingContext): void; - start(): void; - stop(): void; - - } - - export class WebGLFilterManager { - - filterStack: AbstractFilter[]; - transparent: boolean; - offsetX: number; - offsetY: number; - - applyFilterPass(filter: AbstractFilter, filterArea: Texture, width: number, height: number): void; - begin(renderSession: RenderSession, buffer: ArrayBuffer): void; - destroy(): void; - initShaderBuffers(): void; - popFilter(): void; - pushFilter(filterBlock: FilterBlock): void; - setContext(gl: WebGLRenderingContext): void; - - } - - export class WebGLGraphics { - - reset(): void; - upload(): void; - - } - - export class WebGLMaskManager { - - destroy(): void; - popMask(renderSession: RenderSession): void; - pushMask(maskData: any[], renderSession: RenderSession): void; - setContext(gl: WebGLRenderingContext): void; - - } - - export class WebGLRenderer implements PixiRenderer { - - static createWebGLTexture(texture: Texture, gl: WebGLRenderingContext): void; - - constructor(width?: number, height?: number, options?: PixiRendererOptions); - - clearBeforeRender: boolean; - contextLost: boolean; - contextLostBound: Function; - contextRestoreLost: boolean; - contextRestoredBound: Function; - height: number; - gl: WebGLRenderingContext; - offset: Point; - preserveDrawingBuffer: boolean; - projection: Point; - resolution: number; - renderSession: RenderSession; - shaderManager: WebGLShaderManager; - spriteBatch: WebGLSpriteBatch; - maskManager: WebGLMaskManager; - filterManager: WebGLFilterManager; - stencilManager: WebGLStencilManager; - blendModeManager: WebGLBlendModeManager; - transparent: boolean; - type: number; - view: HTMLCanvasElement; - width: number; - - destroy(): void; - initContext(): void; - mapBlendModes(): void; - render(stage: Stage): void; - renderDisplayObject(displayObject: DisplayObject, projection: Point, buffer: WebGLBuffer): void; - resize(width: number, height: number): void; - updateTexture(texture: Texture): void; - - } - - export class WebGLShaderManager { - - maxAttibs: number; - attribState: any[]; - stack: any[]; - tempAttribState: any[]; - - destroy(): void; - setAttribs(attribs: ShaderAttribute[]): void; - setContext(gl: WebGLRenderingContext): void; - setShader(shader: IPixiShader): boolean; - - } - - export class WebGLStencilManager { - - stencilStack: any[]; - reverse: boolean; - count: number; - - bindGraphics(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; - destroy(): void; - popStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; - pushStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; - setContext(gl: WebGLRenderingContext): void; - - } - - export class WebGLSpriteBatch { - - blendModes: number[]; - currentBatchSize: number; - currentBaseTexture: Texture; - defaultShader: AbstractFilter; - dirty: boolean; - drawing: boolean; - indices: number[]; - lastIndexCount: number; - textures: Texture[]; - shaders: IPixiShader[]; - size: number; - sprites: any[]; //todo Sprite[]? - vertices: number[]; - vertSize: number; - - begin(renderSession: RenderSession): void; - destroy(): void; - end(): void; - flush(shader?: IPixiShader): void; - render(sprite: Sprite): void; - renderBatch(texture: Texture, size: number, startIndex: number): void; - renderTilingSprite(sprite: TilingSprite): void; - setBlendMode(blendMode: blendModes): void; - setContext(gl: WebGLRenderingContext): void; - start(): void; - stop(): void; - - } - - export class RenderTexture extends Texture { - - constructor(width?: number, height?: number, renderer?: PixiRenderer, scaleMode?: scaleModes, resolution?: number); - - frame: Rectangle; - baseTexture: BaseTexture; - renderer: PixiRenderer; - resolution: number; - valid: boolean; - - clear(): void; - getBase64(): string; - getCanvas(): HTMLCanvasElement; - getImage(): HTMLImageElement; - resize(width: number, height: number, updateBase: boolean): void; - render(displayObject: DisplayObject, position?: Point, clear?: boolean): void; - - } - -} - -declare function requestAnimFrame(callback: Function): void; - -declare module PIXI.PolyK { - export function Triangulate(p: number[]): number[]; -} - -// Type definitions for Phaser 2.1.4 dev 2014-10-29 +// Type definitions for Phaser 2.1.4 dev 2014-11-05 // Project: https://github.com/photonstorm/phaser declare class Phaser { @@ -2658,6 +1301,7 @@ declare module Phaser { active: boolean; callbackContext: any; disabled: boolean; + enabled: boolean; game: Phaser.Game; onAxisCallBack: Function; onConnectCallback: Function; @@ -2877,6 +1521,7 @@ declare module Phaser { constructor(game: Phaser.Game); + static MAX_POINTERS: number; static MOUSE_OVERRIDES_TOUCH: number; static MOUSE_TOUCH_COMBINE: number; static TOUCH_OVERRIDES_MOUSE: number; @@ -2885,6 +1530,7 @@ declare module Phaser { circle: Phaser.Circle; currentPointers: number; disabled: boolean; + enabled: boolean; doubleTapRate: number; game: Phaser.Game; gamepad: Phaser.Gamepad; @@ -2920,6 +1566,7 @@ declare module Phaser { pollLocked: boolean; pollRate: number; position: Phaser.Point; + pointer: Phaser.Pointer[]; recordLimit: number; recordPointerHistory: boolean; recordRate: number; @@ -2938,10 +1585,11 @@ declare module Phaser { addPointer(): Phaser.Pointer; addMoveCallback(callback: Function, context: any): number; boot(): void; + countActivePointers(limit?: number): number; deleteMoveCallback(index: number): void; destroy(): void; getLocalPosition(displayObject: any, pointer: Phaser.Pointer): Phaser.Point; - getPointer(state: boolean): Phaser.Pointer; + getPointer(isActive?: boolean): Phaser.Pointer; getPointerFromId(pointerID: number): Phaser.Pointer; getPointerFromIdentifier(identifier: number): Phaser.Pointer; hitTest(displayObject: any, pointer: Phaser.Pointer, localPoint: Phaser.Point): void; @@ -3161,6 +1809,7 @@ declare module Phaser { callbackContext: any; disabled: boolean; + enabled: boolean; event: any; game: Phaser.Game; lastChar: string; @@ -3409,6 +2058,7 @@ declare module Phaser { callbackContext: any; capture: boolean; disabled: boolean; + enabled: boolean; event: MouseEvent; game: Phaser.Game; locked: boolean; @@ -4491,12 +3141,14 @@ declare module Phaser { clampY(min: number, max: number): Phaser.Point; clone(output?: Phaser.Point): Phaser.Point; copyFrom(source: Phaser.Point): Phaser.Point; - copyTo(dest: Phaser.Point): any; + copyTo(dest: T): T; + ceil(): Phaser.Point; cross(a: Phaser.Point): number; divide(x: number, y: number): Phaser.Point; distance(dest: Phaser.Point, round?: boolean): number; dot(a: Phaser.Point): number; equals(a: Phaser.Point): boolean; + floor(): Phaser.Point; getMagnitude(): number; getMagnitudeSq(): number; invert(): Phaser.Point; @@ -4559,6 +3211,7 @@ declare module Phaser { x: number; y: number; + addClickTrampoline(name: string, callback: Function, callbackContext: any, ...callbackArgs: any[]): void; justPressed(duration?: number): boolean; justReleased(duration?: number): boolean; leave(event: any): void; @@ -5100,6 +3753,7 @@ declare module Phaser { aspectRatio: number; bounds: Phaser.Rectangle; + currentScaleMode: number; enterFullScreen: Phaser.Signal; enterIncorrectOrientation: Phaser.Signal; enterLandscape: Phaser.Signal; @@ -5108,6 +3762,7 @@ declare module Phaser { height: number; forcePortrait: boolean; forceLandscape: boolean; + fullScreenFailed: boolean; fullScreenTarget: any; fullScreenScaleMode: number; game: Phaser.Game; @@ -5137,16 +3792,19 @@ declare module Phaser { scaleFactor: Phaser.Point; scaleFactorInversed: Phaser.Point; sourceAspectRatio: number; + supportsFullScreen: boolean; trackParentInterval: number; width: number; boot(width: number, height: number): void; checkOrientation(event: any): void; - checkOrientationState(): void; + checkOrientationState(): boolean; checkResize(event: any): void; destroy(): void; forceOrientation(forceLandscape: boolean, forcePortrait?: boolean): void; fullScreenChange(event: any): void; + fullScreenError(event: any): void; + getParentBounds(fullScreen?: boolean, target?: Phaser.Rectangle): Phaser.Rectangle; parseConfig(config: any): void; preUpdate(): void; refresh(): void; @@ -5159,8 +3817,8 @@ declare module Phaser { setShowAll(): void; setSize(): void; setupScale(width: number, height: number): void; - startFullScreen(antialias?: boolean): void; - stopFullScreen(): void; + startFullScreen(antialias?: boolean, allowTrampoline?: boolean): void; + stopFullScreen(): boolean; updateDimensions(width: number, height: number, resize: boolean): void; } @@ -5642,6 +4300,7 @@ declare module Phaser { callbackContext: any; disabled: boolean; + enabled: boolean; event: any; game: Phaser.Game; preventDefault: boolean; diff --git a/typescript/pixi.d.ts b/typescript/pixi.d.ts new file mode 100644 index 000000000..cd8945418 --- /dev/null +++ b/typescript/pixi.d.ts @@ -0,0 +1,1371 @@ +// Type definitions for PIXI 2.0.0 dev 2014-11-05 +// Project: https://github.com/GoodBoyDigital/pixi.js/ + +declare module PIXI { + + 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 BaseTextureCache: { [key: string]: BaseTexture } + export var TextureCache: { [key: string]: Texture } + + 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(number: 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 { + + height: number; + transparent: boolean; + type: number; + width: number; + view: HTMLCanvasElement; + + render(stage: Stage): void; + resize(width: number, height: number): void; + + } + + export interface PixiRendererOptions { + + 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; + 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; + + } + + export class AbstractFilter { + + constructor(fragmentSrc: string[], uniforms: any); + + dirty: boolean; + padding: number; + uniforms: any; + fragmentSrc: string[]; + + apply(frameBuffer: WebGLFramebuffer): void; + 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; + + } + + export class BaseTexture implements Mixin { + + static fromImage(imageUrl: string, crossorigin?: boolean, scaleMode?: scaleModes): BaseTexture; + static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): BaseTexture; + + constructor(source: HTMLImageElement, scaleMode: scaleModes); + constructor(source: HTMLCanvasElement, scaleMode: scaleModes); + + height: number; + hasLoaded: boolean; + premultipliedAlpha: boolean; + resolution: number; + scaleMode: scaleModes; + source: HTMLImageElement; + 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; + + destroy(): void; + dirty(): void; + updateSourceImage(newSrc: string): void; + 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 BitmapText extends DisplayObjectContainer { + + static fonts: any; + + constructor(text: string, style: BitmapTextStyle); + + dirty: boolean; + fontName: string; + fontSize: number; + textWidth: number; + textHeight: number; + tint: number; + style: BitmapTextStyle; + + setText(text: string): void; + setStyle(style: BitmapTextStyle): 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; + + } + + export class CanvasBuffer { + + constructor(width: number, height: number); + + canvas: HTMLCanvasElement; + context: CanvasRenderingContext2D; + height: number; + width: number; + + clear(): void; + resize(width: number, height: number): void; + + } + + export class CanvasMaskManager { + + pushMask(maskData: MaskData, renderSession: RenderSession): void; + popMask(renderSession: RenderSession): void; + + } + + export class CanvasRenderer implements PixiRenderer { + + constructor(width?: number, height?: number, options?: PixiRendererOptions); + + clearBeforeRender: boolean; + context: CanvasRenderingContext2D; + count: number; + height: number; + maskManager: CanvasMaskManager; + refresh: boolean; + renderSession: RenderSession; + resolution: number; + transparent: boolean; + type: number; + view: HTMLCanvasElement; + width: number; + + destroy(removeView?: boolean): void; + render(stage: Stage): void; + resize(width: number, height: number): void; + + } + + export class CanvasTinter { + + static getTintedTexture(sprite: Sprite, color: number): HTMLCanvasElement; + 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; + static roundColor(color: number): void; + + static cacheStepsPerColorChannel: number; + static convertTintToImage: boolean; + 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 { + + matrix: Matrix; + + } + + 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: Stage; + visible: boolean; + worldAlpha: number; + worldVisible: boolean; + x: number; + y: number; + + click(e: InteractionData): void; + getBounds(matrix?: Matrix): Rectangle; + getLocalBounds(): Rectangle; + generateTexture(resolution: number, scaleMode: scaleModes, renderer: PixiRenderer): RenderTexture; + mousedown(e: InteractionData): void; + mouseout(e: InteractionData): void; + mouseover(e: InteractionData): void; + mouseup(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: Stage): 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; + + } + + export class DisplayObjectContainer extends DisplayObject { + + constructor(); + + children: DisplayObject[]; + height: number; + width: number; + + addChild(child: DisplayObject): DisplayObject; + addChildAt(child: DisplayObject, index: number): DisplayObject; + getBounds(): Rectangle; + getChildAt(index: number): DisplayObject; + getChildIndex(child: DisplayObject): number; + getLocalBounds(): Rectangle; + removeChild(child: DisplayObject): DisplayObject; + removeChildAt(index: number): DisplayObject; + removeChildren(beginIndex?: number, endIndex?: number): DisplayObject[]; + removeStageReference(): void; + setChildIndex(child: DisplayObject, index: number): void; + swapChildren(child: DisplayObject, child2: DisplayObject): void; + + } + + 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; + + } + + export class Event { + + constructor(target: any, name: string, data: any); + + target: any; + type: string; + data: any; + timeStamp: number; + + stopPropagation(): void; + preventDefault(): void; + stopImmediatePropagation(): void; + + } + + export class EventTarget { + + static mixin(obj: any): void; + + } + + export class FilterTexture { + + constructor(gl: WebGLRenderingContext, width: number, height: number, scaleMode: scaleModes); + + fragmentSrc: string[]; + frameBuffer: WebGLFramebuffer; + gl: WebGLRenderingContext; + program: WebGLProgram; + scaleMode: number; + texture: WebGLTexture; + + clear(): void; + resize(width: number, height: number): void; + destroy(): void; + + } + + export class GraphicsData { + + 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; + + } + + export class Graphics extends DisplayObjectContainer { + + blendMode: number; + boundsPadding: number; + fillAlpha: number; + isMask: boolean; + lineWidth: number; + lineColor: string; + tint: number; + worldAlpha: 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; + beginFill(color: number, alpha?: number): Graphics; + bezierCurveTo(cpX: number, cpY: number, cpX2: number, cpY2: number, toX: number, toY: number): Graphics; + clear(): Graphics; + destroyCachedSprite(): void; + drawCircle(x: number, y: number, radius: number): Graphics; + drawEllipse(x: number, y: number, width: number, height: number): Graphics; + drawPolygon(path: any): Graphics; + drawRect(x: number, y: number, width: number, height: number): Graphics; + drawRoundedRect(x: number, y: number, width: number, height: number, radius: number): Graphics; + drawShape(shape: Circle): GraphicsData; + drawShape(shape: Rectangle): GraphicsData; + drawShape(shape: Ellipse): GraphicsData; + drawShape(shape: Polygon): GraphicsData; + endFill(): Graphics; + lineStyle(lineWidth: number, color: number, alpha: number): Graphics; + lineTo(x: number, y: number): Graphics; + moveTo(x: number, y: number): Graphics; + quadraticCurveTo(cpX: number, cpY: number, toX: number, toY: number): Graphics; + updateBounds(): void; + + } + + 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; + + } + + 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: Stage; + touches: { [id: string]: InteractionData }; + + constructor(stage: Stage); + } + + 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 MovieClip extends Sprite { + + static fromFrames(frames: string[]): MovieClip; + static fromImages(images: HTMLImageElement[]): HTMLImageElement; + + constructor(textures: Texture[]); + + animationSpeed: number; + currentFrame: number; + loop: boolean; + playing: boolean; + textures: Texture[]; + totalFrames: number; + + gotoAndPlay(frameNumber: number): void; + gotoAndStop(frameNumber: number): void; + onComplete(): void; + play(): void; + stop(): 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 class IPixiShader { + + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + destroy(): void; + init(): void; + + } + + export class PixiShader implements IPixiShader { + + constructor(gl: WebGLRenderingContext); + + attributes: ShaderAttribute[]; + defaultVertexSrc: string[]; + dirty: boolean; + firstRun: boolean; + textureCount: number; + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + initSampler2D(): void; + initUniforms(): void; + syncUniforms(): void; + + destroy(): void; + init(): void; + + } + + export class PixiFastShader implements IPixiShader { + + constructor(gl: WebGLRenderingContext); + + textureCount: number; + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + destroy(): void; + init(): void; + + } + + export class PrimitiveShader implements IPixiShader { + + constructor(gl: WebGLRenderingContext); + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + destroy(): void; + init(): void; + + } + + export class ComplexPrimitiveShader implements IPixiShader { + + constructor(gl: WebGLRenderingContext); + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + destroy(): void; + init(): void; + + } + + export class StripShader implements IPixiShader { + + constructor(gl: WebGLRenderingContext); + fragmentSrc: string[]; + gl: WebGLRenderingContext; + program: WebGLProgram; + vertexSrc: string[]; + + destroy(): void; + 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: number[]; + + 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 { + + red: Point; + green: Point; + blue: Point; + + } + + export class Rope extends Strip { + + points: Point[]; + + constructor(texture: Texture, points: Point[]); + + refresh(): void; + setTexture(texture: Texture): void; + + } + + 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 Spine extends DisplayObjectContainer { + + constructor(url: string); + + createSprite(slot: any, descriptior: any): void; + + } + + export class Sprite extends DisplayObjectContainer { + + static fromFrame(frameId: string): Sprite; + static fromImage(url: string, crossorigin?: boolean, scaleMode?: scaleModes): Sprite; + + constructor(texture: Texture); + + anchor: Point; + blendMode: blendModes; + shader: IPixiShader; + texture: Texture; + tint: number; + + setTexture(texture: Texture): void; + + } + + export class SpriteBatch extends DisplayObjectContainer { + + 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 Stage extends DisplayObjectContainer { + + constructor(backgroundColor: number); + + interactionManager: InteractionManager; + + getMousePosition(): Point; + setBackgroundColor(backgroundColor: number): void; + setInteractionDelegate(domElement: HTMLElement): void; + + } + + export class Strip extends DisplayObjectContainer { + + constructor(texture: Texture); + + colors: number[]; + dirty: boolean; + indices: number[]; + padding: number; + texture: Texture; + uvs: number[]; + vertices: number[]; + + } + + export class Text extends Sprite { + + constructor(text: string, style?: TextStyle); + + context: CanvasRenderingContext2D; + resolution: number; + + destroy(destroyTexture: boolean): void; + setStyle(style: TextStyle): void; + setText(text: string): void; + + } + + export class Texture implements Mixin { + + static fromCanvas(canvas: HTMLCanvasElement, scaleMode?: scaleModes): Texture; + static fromFrame(frameId: string): Texture; + static fromImage(imageUrl: string, crossorigin?: boolean, scaleMode?: scaleModes): Texture; + static addTextureToCache(texture: Texture, id: string): void; + static removeTextureFromCache(id: string): Texture; + + constructor(baseTexture: BaseTexture, frame?: Rectangle, crop?: Rectangle, trim?: Rectangle); + + baseTexture: BaseTexture; + crop: Rectangle; + frame: Rectangle; + height: number; + noFrame: boolean; + requiresUpdate: boolean; + trim: Point; + width: number; + scope: any; + 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; + + destroy(destroyBase: boolean): void; + setFrame(frame: Rectangle): void; + + } + + export class TilingSprite extends Sprite { + + constructor(texture: Texture, width: number, height: number); + + blendMode: number; + texture: Texture; + tint: number; + tilePosition: Point; + tileScale: Point; + tileScaleOffset: Point; + + generateTilingTexture(forcePowerOfTwo: boolean): void; + 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): Texture; + + autoUpdate: boolean; + + destroy(): void; + updateBound(): void; + + } + + export class WebGLBlendModeManager { + + currentBlendMode: number; + + destroy(): void; + setBlendMode(blendMode: number): boolean; + setContext(gl: WebGLRenderingContext): void; + + } + + export class WebGLFastSpriteBatch { + + constructor(gl: CanvasRenderingContext2D); + + currentBatchSize: number; + currentBaseTexture: BaseTexture; + currentBlendMode: number; + renderSession: RenderSession; + drawing: boolean; + indexBuffer: any; + indices: number[]; + lastIndexCount: number; + matrix: Matrix; + maxSize: number; + shader: IPixiShader; + size: number; + vertexBuffer: any; + vertices: number[]; + vertSize: number; + + end(): void; + begin(spriteBatch: SpriteBatch, renderSession: RenderSession): void; + destroy(removeView?: boolean): void; + flush(): void; + render(spriteBatch: SpriteBatch): void; + renderSprite(sprite: Sprite): void; + setContext(gl: WebGLRenderingContext): void; + start(): void; + stop(): void; + + } + + export class WebGLFilterManager { + + filterStack: AbstractFilter[]; + transparent: boolean; + offsetX: number; + offsetY: number; + + applyFilterPass(filter: AbstractFilter, filterArea: Texture, width: number, height: number): void; + begin(renderSession: RenderSession, buffer: ArrayBuffer): void; + destroy(): void; + initShaderBuffers(): void; + popFilter(): void; + pushFilter(filterBlock: FilterBlock): void; + setContext(gl: WebGLRenderingContext): void; + + } + + export class WebGLGraphics { + + reset(): void; + upload(): void; + + } + + export class WebGLMaskManager { + + destroy(): void; + popMask(renderSession: RenderSession): void; + pushMask(maskData: any[], renderSession: RenderSession): void; + setContext(gl: WebGLRenderingContext): void; + + } + + export class WebGLRenderer implements PixiRenderer { + + static createWebGLTexture(texture: Texture, gl: WebGLRenderingContext): void; + + constructor(width?: number, height?: number, options?: PixiRendererOptions); + + clearBeforeRender: boolean; + contextLost: boolean; + contextLostBound: Function; + contextRestoreLost: boolean; + contextRestoredBound: Function; + height: number; + gl: WebGLRenderingContext; + offset: Point; + preserveDrawingBuffer: boolean; + projection: Point; + resolution: number; + renderSession: RenderSession; + shaderManager: WebGLShaderManager; + spriteBatch: WebGLSpriteBatch; + maskManager: WebGLMaskManager; + filterManager: WebGLFilterManager; + stencilManager: WebGLStencilManager; + blendModeManager: WebGLBlendModeManager; + transparent: boolean; + type: number; + view: HTMLCanvasElement; + width: number; + + destroy(): void; + initContext(): void; + mapBlendModes(): void; + render(stage: Stage): void; + renderDisplayObject(displayObject: DisplayObject, projection: Point, buffer: WebGLBuffer): void; + resize(width: number, height: number): void; + updateTexture(texture: Texture): void; + + } + + export class WebGLShaderManager { + + maxAttibs: number; + attribState: any[]; + stack: any[]; + tempAttribState: any[]; + + destroy(): void; + setAttribs(attribs: ShaderAttribute[]): void; + setContext(gl: WebGLRenderingContext): void; + setShader(shader: IPixiShader): boolean; + + } + + export class WebGLStencilManager { + + stencilStack: any[]; + reverse: boolean; + count: number; + + bindGraphics(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; + destroy(): void; + popStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; + pushStencil(graphics: Graphics, webGLData: any[], renderSession: RenderSession): void; + setContext(gl: WebGLRenderingContext): void; + + } + + export class WebGLSpriteBatch { + + blendModes: number[]; + currentBatchSize: number; + currentBaseTexture: Texture; + defaultShader: AbstractFilter; + dirty: boolean; + drawing: boolean; + indices: number[]; + lastIndexCount: number; + textures: Texture[]; + shaders: IPixiShader[]; + size: number; + sprites: any[]; //todo Sprite[]? + vertices: number[]; + vertSize: number; + + begin(renderSession: RenderSession): void; + destroy(): void; + end(): void; + flush(shader?: IPixiShader): void; + render(sprite: Sprite): void; + renderBatch(texture: Texture, size: number, startIndex: number): void; + renderTilingSprite(sprite: TilingSprite): void; + setBlendMode(blendMode: blendModes): void; + setContext(gl: WebGLRenderingContext): void; + start(): void; + stop(): void; + + } + + export class RenderTexture extends Texture { + + constructor(width?: number, height?: number, renderer?: PixiRenderer, scaleMode?: scaleModes, resolution?: number); + + frame: Rectangle; + baseTexture: BaseTexture; + renderer: PixiRenderer; + resolution: number; + valid: boolean; + + clear(): void; + getBase64(): string; + getCanvas(): HTMLCanvasElement; + getImage(): HTMLImageElement; + resize(width: number, height: number, updateBase: boolean): void; + render(displayObject: DisplayObject, position?: Point, clear?: boolean): void; + + } + +} + +declare function requestAnimFrame(callback:Function): void; + +declare module PIXI.PolyK { + export function Triangulate(p: number[]): number[]; +} diff --git a/typescript/readme.md b/typescript/readme.md new file mode 100644 index 000000000..89370c1a6 --- /dev/null +++ b/typescript/readme.md @@ -0,0 +1,12 @@ +# TypeScript Definitions # + +If you are a phaser dev then reference the `phaser.d.ts` in your project. + +- `phaser.d.ts` contains a reference to `pixi.d.ts` and so both these files must remain siblings in the same directory. +- `pixi.d.ts` has no dependencies and can be used by pixi devs standalone* + +*Versions of TypeScript lower than version 1.0 may experience errors in `pixi.d.ts` due to missing WebGL definitions. If you fall into this category and cannot upgrade your version, then a `webgl.d.ts` has been provided but is disabled by default. Add this line to the top of the `pixi.d.ts` file `/// ` + +## Contributing ## + +If you find any mistakes in these definitions or you feel they can be improved in any way, please make a pull request against the dev branch. \ No newline at end of file diff --git a/typescript/webgl.d.ts b/typescript/webgl.d.ts new file mode 100644 index 000000000..0a2b6599e --- /dev/null +++ b/typescript/webgl.d.ts @@ -0,0 +1,687 @@ +// +// Copr. (c) 2012 Piers Haken +// +// see: http://www.khronos.org/registry/webgl/specs/latest/ +// + +interface WebGLObject +{ +} + +interface WebGLBuffer extends WebGLObject +{ +} + +interface WebGLFramebuffer extends WebGLObject +{ +} + +interface WebGLProgram extends WebGLObject +{ +} + +interface WebGLRenderbuffer extends WebGLObject +{ +} + +interface WebGLShader extends WebGLObject +{ +} + +interface WebGLTexture extends WebGLObject +{ +} + +interface WebGLUniformLocation +{ +} + +interface WebGLActiveInfo +{ + size: number; + type: number; + name: string; +} + +interface WebGLShaderPrecisionFormat +{ + rangeMin: number; + rangeMax: number; + precision: number; +} + + +interface WebGLContextAttributes +{ + alpha: boolean; + depth: boolean; + stencil: boolean; + antialias: boolean; + premultipliedAlpha: boolean; + preserveDrawingBuffer: boolean; +} + +interface WebGLRenderingContext +{ + /* ClearBufferMask */ + DEPTH_BUFFER_BIT: number; + STENCIL_BUFFER_BIT: number; + COLOR_BUFFER_BIT: number; + + /* BeginMode */ + POINTS: number; + LINES: number; + LINE_LOOP: number; + LINE_STRIP: number; + TRIANGLES: number; + TRIANGLE_STRIP: number; + TRIANGLE_FAN: number; + + /* AlphaFunction (not supported in ES20) */ + /* NEVER */ + /* LESS */ + /* EQUAL */ + /* LEQUAL */ + /* GREATER */ + /* NOTEQUAL */ + /* GEQUAL */ + /* ALWAYS */ + + /* BlendingFactorDest */ + ZERO: number; + ONE: number; + SRC_COLOR: number; + ONE_MINUS_SRC_COLOR: number; + SRC_ALPHA: number; + ONE_MINUS_SRC_ALPHA: number; + DST_ALPHA: number; + ONE_MINUS_DST_ALPHA: number; + + /* BlendingFactorSrc */ + /* ZERO */ + /* ONE */ + DST_COLOR: number; + ONE_MINUS_DST_COLOR: number; + SRC_ALPHA_SATURATE: number; + /* SRC_ALPHA */ + /* ONE_MINUS_SRC_ALPHA */ + /* DST_ALPHA */ + /* ONE_MINUS_DST_ALPHA */ + + /* BlendEquationSeparate */ + FUNC_ADD: number; + BLEND_EQUATION: number; + BLEND_EQUATION_RGB: number; + BLEND_EQUATION_ALPHA: number; + + /* BlendSubtract */ + FUNC_SUBTRACT: number; + FUNC_REVERSE_SUBTRACT: number; + + /* Separate Blend Functions */ + BLEND_DST_RGB: number; + BLEND_SRC_RGB: number; + BLEND_DST_ALPHA: number; + BLEND_SRC_ALPHA: number; + CONSTANT_COLOR: number; + ONE_MINUS_CONSTANT_COLOR: number; + CONSTANT_ALPHA: number; + ONE_MINUS_CONSTANT_ALPHA: number; + BLEND_COLOR: number; + + /* Buffer Objects */ + ARRAY_BUFFER: number; + ELEMENT_ARRAY_BUFFER: number; + ARRAY_BUFFER_BINDING: number; + ELEMENT_ARRAY_BUFFER_BINDING: number; + + STREAM_DRAW: number; + STATIC_DRAW: number; + DYNAMIC_DRAW: number; + + BUFFER_SIZE: number; + BUFFER_USAGE: number; + + CURRENT_VERTEX_ATTRIB: number; + + /* CullFaceMode */ + FRONT: number; + BACK: number; + FRONT_AND_BACK: number; + + /* DepthFunction */ + /* NEVER */ + /* LESS */ + /* EQUAL */ + /* LEQUAL */ + /* GREATER */ + /* NOTEQUAL */ + /* GEQUAL */ + /* ALWAYS */ + + /* EnableCap */ + /* TEXTURE_2D */ + CULL_FACE: number; + BLEND: number; + DITHER: number; + STENCIL_TEST: number; + DEPTH_TEST: number; + SCISSOR_TEST: number; + POLYGON_OFFSET_FILL: number; + SAMPLE_ALPHA_TO_COVERAGE: number; + SAMPLE_COVERAGE: number; + + /* ErrorCode */ + NO_ERROR: number; + INVALID_ENUM: number; + INVALID_VALUE: number; + INVALID_OPERATION: number; + OUT_OF_MEMORY: number; + + /* FrontFaceDirection */ + CW: number; + CCW: number; + + /* GetPName */ + LINE_WIDTH: number; + ALIASED_POINT_SIZE_RANGE: number; + ALIASED_LINE_WIDTH_RANGE: number; + CULL_FACE_MODE: number; + FRONT_FACE: number; + DEPTH_RANGE: number; + DEPTH_WRITEMASK: number; + DEPTH_CLEAR_VALUE: number; + DEPTH_FUNC: number; + STENCIL_CLEAR_VALUE: number; + STENCIL_FUNC: number; + STENCIL_FAIL: number; + STENCIL_PASS_DEPTH_FAIL: number; + STENCIL_PASS_DEPTH_PASS: number; + STENCIL_REF: number; + STENCIL_VALUE_MASK: number; + STENCIL_WRITEMASK: number; + STENCIL_BACK_FUNC: number; + STENCIL_BACK_FAIL: number; + STENCIL_BACK_PASS_DEPTH_FAIL: number; + STENCIL_BACK_PASS_DEPTH_PASS: number; + STENCIL_BACK_REF: number; + STENCIL_BACK_VALUE_MASK: number; + STENCIL_BACK_WRITEMASK: number; + VIEWPORT: number; + SCISSOR_BOX: number; + /* SCISSOR_TEST */ + COLOR_CLEAR_VALUE: number; + COLOR_WRITEMASK: number; + UNPACK_ALIGNMENT: number; + PACK_ALIGNMENT: number; + MAX_TEXTURE_SIZE: number; + MAX_VIEWPORT_DIMS: number; + SUBPIXEL_BITS: number; + RED_BITS: number; + GREEN_BITS: number; + BLUE_BITS: number; + ALPHA_BITS: number; + DEPTH_BITS: number; + STENCIL_BITS: number; + POLYGON_OFFSET_UNITS: number; + /* POLYGON_OFFSET_FILL */ + POLYGON_OFFSET_FACTOR: number; + TEXTURE_BINDING_2D: number; + SAMPLE_BUFFERS: number; + SAMPLES: number; + SAMPLE_COVERAGE_VALUE: number; + SAMPLE_COVERAGE_INVERT: number; + + /* GetTextureParameter */ + /* TEXTURE_MAG_FILTER */ + /* TEXTURE_MIN_FILTER */ + /* TEXTURE_WRAP_S */ + /* TEXTURE_WRAP_T */ + + COMPRESSED_TEXTURE_FORMATS: number; + + /* HintMode */ + DONT_CARE: number; + FASTEST: number; + NICEST: number; + + /* HintTarget */ + GENERATE_MIPMAP_HINT: number; + + /* DataType */ + BYTE: number; + UNSIGNED_BYTE: number; + SHORT: number; + UNSIGNED_SHORT: number; + INT: number; + UNSIGNED_INT: number; + FLOAT: number; + + /* PixelFormat */ + DEPTH_COMPONENT: number; + ALPHA: number; + RGB: number; + RGBA: number; + LUMINANCE: number; + LUMINANCE_ALPHA: number; + + /* PixelType */ + /* UNSIGNED_BYTE */ + UNSIGNED_SHORT_4_4_4_4: number; + UNSIGNED_SHORT_5_5_5_1: number; + UNSIGNED_SHORT_5_6_5: number; + + /* Shaders */ + FRAGMENT_SHADER: number; + VERTEX_SHADER: number; + MAX_VERTEX_ATTRIBS: number; + MAX_VERTEX_UNIFORM_VECTORS: number; + MAX_VARYING_VECTORS: number; + MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + MAX_TEXTURE_IMAGE_UNITS: number; + MAX_FRAGMENT_UNIFORM_VECTORS: number; + SHADER_TYPE: number; + DELETE_STATUS: number; + LINK_STATUS: number; + VALIDATE_STATUS: number; + ATTACHED_SHADERS: number; + ACTIVE_UNIFORMS: number; + ACTIVE_ATTRIBUTES: number; + SHADING_LANGUAGE_VERSION: number; + CURRENT_PROGRAM: number; + + /* StencilFunction */ + NEVER: number; + LESS: number; + EQUAL: number; + LEQUAL: number; + GREATER: number; + NOTEQUAL: number; + GEQUAL: number; + ALWAYS: number; + + /* StencilOp */ + /* ZERO */ + KEEP: number; + REPLACE: number; + INCR: number; + DECR: number; + INVERT: number; + INCR_WRAP: number; + DECR_WRAP: number; + + /* StringName */ + VENDOR: number; + RENDERER: number; + VERSION: number; + + /* TextureMagFilter */ + NEAREST: number; + LINEAR: number; + + /* TextureMinFilter */ + /* NEAREST */ + /* LINEAR */ + NEAREST_MIPMAP_NEAREST: number; + LINEAR_MIPMAP_NEAREST: number; + NEAREST_MIPMAP_LINEAR: number; + LINEAR_MIPMAP_LINEAR: number; + + /* TextureParameterName */ + TEXTURE_MAG_FILTER: number; + TEXTURE_MIN_FILTER: number; + TEXTURE_WRAP_S: number; + TEXTURE_WRAP_T: number; + + /* TextureTarget */ + TEXTURE_2D: number; + TEXTURE: number; + + TEXTURE_CUBE_MAP: number; + TEXTURE_BINDING_CUBE_MAP: number; + TEXTURE_CUBE_MAP_POSITIVE_X: number; + TEXTURE_CUBE_MAP_NEGATIVE_X: number; + TEXTURE_CUBE_MAP_POSITIVE_Y: number; + TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + TEXTURE_CUBE_MAP_POSITIVE_Z: number; + TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + MAX_CUBE_MAP_TEXTURE_SIZE: number; + + /* TextureUnit */ + TEXTURE0: number; + TEXTURE1: number; + TEXTURE2: number; + TEXTURE3: number; + TEXTURE4: number; + TEXTURE5: number; + TEXTURE6: number; + TEXTURE7: number; + TEXTURE8: number; + TEXTURE9: number; + TEXTURE10: number; + TEXTURE11: number; + TEXTURE12: number; + TEXTURE13: number; + TEXTURE14: number; + TEXTURE15: number; + TEXTURE16: number; + TEXTURE17: number; + TEXTURE18: number; + TEXTURE19: number; + TEXTURE20: number; + TEXTURE21: number; + TEXTURE22: number; + TEXTURE23: number; + TEXTURE24: number; + TEXTURE25: number; + TEXTURE26: number; + TEXTURE27: number; + TEXTURE28: number; + TEXTURE29: number; + TEXTURE30: number; + TEXTURE31: number; + ACTIVE_TEXTURE: number; + + /* TextureWrapMode */ + REPEAT: number; + CLAMP_TO_EDGE: number; + MIRRORED_REPEAT: number; + + /* Uniform Types */ + FLOAT_VEC2: number; + FLOAT_VEC3: number; + FLOAT_VEC4: number; + INT_VEC2: number; + INT_VEC3: number; + INT_VEC4: number; + BOOL: number; + BOOL_VEC2: number; + BOOL_VEC3: number; + BOOL_VEC4: number; + FLOAT_MAT2: number; + FLOAT_MAT3: number; + FLOAT_MAT4: number; + SAMPLER_2D: number; + SAMPLER_CUBE: number; + + /* Vertex Arrays */ + VERTEX_ATTRIB_ARRAY_ENABLED: number; + VERTEX_ATTRIB_ARRAY_SIZE: number; + VERTEX_ATTRIB_ARRAY_STRIDE: number; + VERTEX_ATTRIB_ARRAY_TYPE: number; + VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + VERTEX_ATTRIB_ARRAY_POINTER: number; + VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + + /* Shader Source */ + COMPILE_STATUS: number; + + /* Shader Precision-Specified Types */ + LOW_FLOAT: number; + MEDIUM_FLOAT: number; + HIGH_FLOAT: number; + LOW_INT: number; + MEDIUM_INT: number; + HIGH_INT: number; + + /* Framebuffer Object. */ + FRAMEBUFFER: number; + RENDERBUFFER: number; + + RGBA4: number; + RGB5_A1: number; + RGB565: number; + DEPTH_COMPONENT16: number; + STENCIL_INDEX: number; + STENCIL_INDEX8: number; + DEPTH_STENCIL: number; + + RENDERBUFFER_WIDTH: number; + RENDERBUFFER_HEIGHT: number; + RENDERBUFFER_INTERNAL_FORMAT: number; + RENDERBUFFER_RED_SIZE: number; + RENDERBUFFER_GREEN_SIZE: number; + RENDERBUFFER_BLUE_SIZE: number; + RENDERBUFFER_ALPHA_SIZE: number; + RENDERBUFFER_DEPTH_SIZE: number; + RENDERBUFFER_STENCIL_SIZE: number; + + FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + + COLOR_ATTACHMENT0: number; + DEPTH_ATTACHMENT: number; + STENCIL_ATTACHMENT: number; + DEPTH_STENCIL_ATTACHMENT: number; + + NONE: number; + + FRAMEBUFFER_COMPLETE: number; + FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + FRAMEBUFFER_UNSUPPORTED: number; + + FRAMEBUFFER_BINDING: number; + RENDERBUFFER_BINDING: number; + MAX_RENDERBUFFER_SIZE: number; + + INVALID_FRAMEBUFFER_OPERATION: number; + + /* WebGL-specific enums */ + UNPACK_FLIP_Y_WEBGL: number; + UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + CONTEXT_LOST_WEBGL: number; + UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + BROWSER_DEFAULT_WEBGL: number; + + + + + canvas: HTMLCanvasElement; + drawingBufferWidth: number; + drawingBufferHeight: number; + + getContextAttributes(): WebGLContextAttributes; + isContextLost(): boolean; + + getSupportedExtensions(): string[]; + getExtension(name: string): any; + + activeTexture(texture: number): void; + attachShader(program: WebGLProgram, shader: WebGLShader): void; + bindAttribLocation(program: WebGLProgram, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer): void; + bindTexture(target: number, texture: WebGLTexture): void; + blendColor(red: number, green: number, blue: number, alpha: number): void; + blendEquation(mode: number): void; + blendEquationSeparate(modeRGB: number, modeAlpha: number): void; + blendFunc(sfactor: number, dfactor: number): void; + blendFuncSeparate(srcRGB: number, dstRGB: number, srcAlpha: number, dstAlpha: number): void; + + bufferData(target: number, size: number, usage: number): void; + bufferData(target: number, data: ArrayBufferView, usage: number): void; + bufferData(target: number, data: ArrayBuffer, usage: number): void; + bufferSubData(target: number, offset: number, data: ArrayBufferView): void; + bufferSubData(target: number, offset: number, data: ArrayBuffer): void; + + checkFramebufferStatus(target: number): number; + clear(mask: number): void; + clearColor(red: number, green: number, blue: number, alpha: number): void; + clearDepth(depth: number): void; + clearStencil(s: number): void; + colorMask(red: boolean, green: boolean, blue: boolean, alpha: boolean): void; + compileShader(shader: WebGLShader): void; + + compressedTexImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, data: ArrayBufferView): void; + compressedTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, data: ArrayBufferView): void; + + copyTexImage2D(target: number, level: number, internalformat: number, x: number, y: number, width: number, height: number, border: number): void; + copyTexSubImage2D(target: number, level: number, xoffset: number, yoffset: number, x: number, y: number, width: number, height: number): void; + + createBuffer(): WebGLBuffer; + createFramebuffer(): WebGLFramebuffer; + createProgram(): WebGLProgram; + createRenderbuffer(): WebGLRenderbuffer; + createShader(type: number): WebGLShader; + createTexture(): WebGLTexture; + + cullFace(mode: number): void; + + deleteBuffer(buffer: WebGLBuffer): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer): void; + deleteProgram(program: WebGLProgram): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer): void; + deleteShader(shader: WebGLShader): void; + deleteTexture(texture: WebGLTexture): void; + + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram, shader: WebGLShader): void; + disable(cap: number): void; + disableVertexAttribArray(index: number): void; + drawArrays(mode: number, first: number, count: number): void; + drawElements(mode: number, count: number, type: number, offset: number): void; + + enable(cap: number): void; + enableVertexAttribArray(index: number): void; + finish(): void; + flush(): void; + framebufferRenderbuffer(target: number, attachment: number, renderbuffertarget: number, renderbuffer: WebGLRenderbuffer): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture, level: number): void; + frontFace(mode: number): void; + + generateMipmap(target: number): void; + + getActiveAttrib(program: WebGLProgram, index: number): WebGLActiveInfo; + getActiveUniform(program: WebGLProgram, index: number): WebGLActiveInfo; + getAttachedShaders(program: WebGLProgram): WebGLShader[]; + + getAttribLocation(program: WebGLProgram, name: string): number; + + getBufferParameter(target: number, pname: number): any; + getParameter(pname: number): any; + + getError(): number; + + getFramebufferAttachmentParameter(target: number, attachment: number, pname: number): any; + getProgramParameter(program: WebGLProgram, pname: number): any; + getProgramInfoLog(program: WebGLProgram): string; + getRenderbufferParameter(target: number, pname: number): any; + getShaderParameter(shader: WebGLShader, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat; + getShaderInfoLog(shader: WebGLShader): string; + + getShaderSource(shader: WebGLShader): string; + + getTexParameter(target: number, pname: number): any; + + getUniform(program: WebGLProgram, location: WebGLUniformLocation): any; + + getUniformLocation(program: WebGLProgram, name: string): WebGLUniformLocation; + + getVertexAttrib(index: number, pname: number): any; + + getVertexAttribOffset(index: number, pname: number): number; + + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer): boolean; + isProgram(program: WebGLProgram): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer): boolean; + isShader(shader: WebGLShader): boolean; + isTexture(texture: WebGLTexture): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram): void; + pixelStorei(pname: number, param: number): void; + polygonOffset(factor: number, units: number): void; + + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + + renderbufferStorage(target: number, internalformat: number, width: number, height: number): void; + sampleCoverage(value: number, invert: boolean): void; + scissor(x: number, y: number, width: number, height: number): void; + + shaderSource(shader: WebGLShader, source: string): void; + + stencilFunc(func: number, ref: number, mask: number): void; + stencilFuncSeparate(face: number, func: number, ref: number, mask: number): void; + stencilMask(mask: number): void; + stencilMaskSeparate(face: number, mask: number): void; + stencilOp(fail: number, zfail: number, zpass: number): void; + stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void; + + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void; // May throw DOMException + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void; // May throw DOMException + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void; // May throw DOMException + + texParameterf(target: number, pname: number, param: number): void; + texParameteri(target: number, pname: number, param: number): void; + + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void; // May throw DOMException + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void; // May throw DOMException + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void; // May throw DOMException + + uniform1f(location: WebGLUniformLocation, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform1fv(location: WebGLUniformLocation, v: number[]): void; + uniform1i(location: WebGLUniformLocation, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform1iv(location: WebGLUniformLocation, v: number[]): void; + uniform2f(location: WebGLUniformLocation, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform2fv(location: WebGLUniformLocation, v: number[]): void; + uniform2i(location: WebGLUniformLocation, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform2iv(location: WebGLUniformLocation, v: number[]): void; + uniform3f(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform3fv(location: WebGLUniformLocation, v: number[]): void; + uniform3i(location: WebGLUniformLocation, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform3iv(location: WebGLUniformLocation, v: number[]): void; + uniform4f(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array): void; + uniform4fv(location: WebGLUniformLocation, v: number[]): void; + uniform4i(location: WebGLUniformLocation, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array): void; + uniform4iv(location: WebGLUniformLocation, v: number[]): void; + + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: number[]): void; + + useProgram(program: WebGLProgram): void; + validateProgram(program: WebGLProgram): void; + + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array): void; + vertexAttrib1fv(indx: number, value: number[]): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array): void; + vertexAttrib2fv(indx: number, value: number[]): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array): void; + vertexAttrib3fv(indx: number, value: number[]): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array): void; + vertexAttrib4fv(indx: number, value: number[]): void; + vertexAttribPointer(indx: number, size: number, type: number, normalized: boolean, stride: number, offset: number): void; + + viewport(x: number, y: number, width: number, height: number): void; +} +