From 2a02b65c06cafd7b653410a271f2c2d12c442393 Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Fri, 2 Nov 2012 05:27:58 +0200 Subject: [PATCH] Add declaration files for EaselJS, PreloadJS, SoundJS and TweenJS --- Definitions/easeljs-0.5.d.ts | 777 +++++++++++++++++++++++++-------- Definitions/preloadjs-0.2.d.ts | 82 ++++ Definitions/soundjs-0.3.d.ts | 112 +++++ Definitions/tweenjs-0.3.d.ts | 137 ++++++ 4 files changed, 927 insertions(+), 181 deletions(-) create mode 100644 Definitions/preloadjs-0.2.d.ts create mode 100644 Definitions/soundjs-0.3.d.ts create mode 100644 Definitions/tweenjs-0.3.d.ts diff --git a/Definitions/easeljs-0.5.d.ts b/Definitions/easeljs-0.5.d.ts index d0b54a741..4d4969039 100644 --- a/Definitions/easeljs-0.5.d.ts +++ b/Definitions/easeljs-0.5.d.ts @@ -1,71 +1,204 @@ -// Type definitions for EaselJS 0.5 -// Project: http://www.createjs.com/#!/EaselJS -// Definitions by: Boris Yankov -// Definitions: https://github.com/borisyankov/DefinitelyTyped +/* + See https://bitbucket.org/drk4/createjs_ts_definitions for updates/examples + + Copyright (c) 2012 Pedro Ferreira + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ -interface AlphaMapFilter extends Filter { - alphaMap: Image; + // rename the native MouseEvent, to avoid conflit with createjs's MouseEvent +interface NativeMouseEvent extends MouseEvent + { - constructor (alphaMap: Image); + } + + +/// + + +module createjs +{ + // :: base classes :: // + +export class DisplayObject + { + // properties + alpha: number; + cacheCanvas: HTMLCanvasElement; + cacheID: number; + compositeOperation: string; + filters: Filter[]; + hitArea: DisplayObject; + id: number; + mask: Shape; + mouseEnabled: bool; + name: string; + parent: DisplayObject; + regX: number; + regY: number; + rotation: number; + scaleX: number; + scaleY: number; + shadow: Shadow; + skewX: number; + skewY: number; + snapToPixel: bool; + static suppressCrossDomainErrors: bool; + visible: bool; + x: number; + y: number; + + // methods + cache( x: number, y: number, width: number, height: number, scale?: number ): void; + clone(): DisplayObject; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + getCacheDataURL(): void; + getConcatenatedMatrix( mtx: Matrix2D ): Matrix2D; + getMatrix( matrix: Matrix2D ): Matrix2D; + getStage(): Stage; + globalToLocal( x: number, y: number ): Point; + hitTest( x: number, y: number ): bool; + isVisible(): bool; + localToGlobal( x: number, y: number ): Point; + localToLocal( x: number, y: number, target: DisplayObject ): Point; + setTransform( x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number ): DisplayObject; + setupContext( ctx: CanvasRenderingContext2D ): void; + toString(): string; + uncache(): void; + updateCache( compositeOperation: string ): void; + + // events + onClick: (event: MouseEvent) => any; + onDoubleClick: (event: MouseEvent) => any; + onMouseOut: (event: MouseEvent) => any; + onMouseOver: (event: MouseEvent) => any; + onPress: (event: MouseEvent) => any; + onTick: () => any; + } + + +export class Filter + { + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; + clone(): Filter; + getBounds(): Rectangle; + toString(): string; + } + + + // :: The rest :: // + +export class AlphaMapFilter extends Filter + { + constructor( alphaMap: Image ); //HERE doesn't recognize Image type + constructor( alphaMap: HTMLCanvasElement ); + + // properties + alphaMap: Image; //HERE can be also an HTMLCanvasElement.. can't overload properties + + // methods + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; clone(): AlphaMapFilter; -} + toString(): string; + } -interface AlphaMaskFilter extends Filter { - mask: Image; - constructor (mask: Image); +export class AlphaMaskFilter extends Filter + { + constructor( mask: Image ); + constructor( mask: HTMLCanvasElement ); + + // properties + mask: Image; //HERE or HTMLCanvasElement + + // methods + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; clone(): AlphaMaskFilter; -} + toString(): string; + } -interface Bitmap extends DisplayObject { - image?: any; - snapToPixel?: bool; - sourceRect?: Rectangle; - constructor (imageOrUri: any); - cache(): void; +export class Bitmap extends DisplayObject + { + constructor( imageOrUrl: Image ); + constructor( imageOrUrl: HTMLCanvasElement ); + constructor( imageOrUrl: HTMLVideoElement ); + constructor( imageOrUrl: string ); + + // properties + image; //HERE how to tell the various type possibilities? + snapToPixel: bool; + sourceRect: Rectangle; + + // methods clone(): Bitmap; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + isVisible(): bool; toString(): string; uncache(): void; updateCache(): void; -} + } -interface BitmapAnimation extends DisplayObject { - currentAnimation?: string; - currentAnimationFrame?: number; - currentFrame?: number; - offset?: number; - onAnimationEnd?: Function; - paused?: bool; - snapToPixel?: bool; - spriteSheet?: SpriteSheet; - constructor (spriteSheet: SpriteSheet); +export class BitmapAnimation extends DisplayObject + { + constructor( spriteSheet: SpriteSheet ); + + // properties + currentAnimation: string; + currentAnimationFrame: number; + currentFrame: number; + offset: number; + paused: bool; + snapToPixel: bool; + spriteSheet: SpriteSheet; + + // methods advance(): void; cache(): void; - clone(): Point; - gotoAndPlay(frame: number): void; - gotoAndPlay(animation: string): void; - gotoAndStop(frame: number): void; - gotoAndStop(animation: string): void; + clone(): BitmapAnimation; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + gotoAndPlay( frameOrAnimation: string ): void; + gotoAndPlay( frameOrAnimation: number ): void; + isVisible(): bool; play(): void; stop(): void; toString(): string; uncache(): void; updateCache(): void; -} -interface BoxBlurFilter extends Filter { + // events + onAnimationEnd: (reference: BitmapAnimation, animationEnded: string) => any; + } + + +export class BoxBlurFilter extends Filter + { + constructor( blurX: number, blurY: number, quality: number ); + + // properties blurX: number; blurY: number; quality: number; - constructor (blurX: number, blurY: number, quality: number); + // methods + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; clone(): BoxBlurFilter; -} + getBounds(): Rectangle; + toString(): string; + } -interface ColorFilter extends Filter { + +export class ColorFilter extends Filter + { + constructor( redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaMultiplier?: number, redOffset?: number, greenOffset?: number, blueOffset?: number, alphaOffset?: number ); + + // properties alphaOffset: number; blueMultiplier: number; blueOffset: number; @@ -74,179 +207,461 @@ interface ColorFilter extends Filter { redMultiplier: number; redOffset: number; - constructor (redMultiplier: number, greenMultiplier: number, blueMultiplier: number, alphaMultiplier: number, redOffset: number, greenOffset: number, blueOffset: number, alphaOffset: number); + // methods + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; clone(): ColorFilter; -} + toString(): string; + } -interface ColorMatrix { + +export class ColorMatrix + { + constructor( brightness: number, contrast: number, saturation: number, hue: number ); + + // properties DELTA_INDEX: number[]; IDENTITY_MATRIX: number[]; LENGTH: number; - constructor (brightness: number, contrast: number, saturation: number, hue: number); - adjustBrightness(value: number): ColorMatrix; - adjustColor(brightness: number, contrast: number, saturation: number, hue: number): ColorMatrix; - adjustContrast(value: number): ColorMatrix; - adjustSaturation(value: number): ColorMatrix; + // methods + adjustBrightness( value: number ): ColorMatrix; + adjustColor( brightness: number, contrast: number, saturation: number, hue: number ): ColorMatrix; + adjustContrast( value: number ): ColorMatrix; + adjustHue( value: number ): ColorMatrix; + adjustSaturation( value: number ): ColorMatrix; clone(): ColorMatrix; - concat(matrix: number[]): ColorMatrix; - copyMatrix(matrix: number[]): ColorMatrix; + concat( matrix: ColorMatrix[] ): ColorMatrix; + copyMatrix( matrix: ColorMatrix[] ): ColorMatrix; reset(): ColorMatrix; toArray(): number[]; -} + } -interface ColorMatrixFilter extends Filter { - constructor (matrix: ColorMatrix); + +export class ColorMatrixFilter extends Filter + { + constructor( matrix: number[] ); + + // methods + applyFilter( ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx?: CanvasRenderingContext2D, targetX?: number, targetY?: number ): bool; clone(): ColorMatrixFilter; -} + toString(): string; + } -interface Command { - exec(scope: any): void; -} -interface Container extends DisplayObject { +export class Command //HERE is this supposed to be used? (or just internal of the lib) + { + constructor( f, params, path ); + + // methods + exec( scope ): void; + } + + +export class Container extends DisplayObject + { + // properties children: DisplayObject[]; - constructor (); - addChild(child: DisplayObject): DisplayObject; - addChildAt(child: DisplayObject, index: number): DisplayObject; - clone(recursive?: bool): Container; - contains(child: DisplayObject): bool; - getChildAt(index: number): DisplayObject; - getChildIndex(child: DisplayObject): number; + // methods + addChild( ...child: DisplayObject[] ): DisplayObject; + addChildAt( ...child: DisplayObject[], index: number ): DisplayObject; //HERE typescript doesnt like having an argument after the variable length argument + clone( recursive?: bool ): Container; + contains( child: DisplayObject ): bool; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + getChildAt( index: number ): DisplayObject; + getChildIndex( child: DisplayObject ): number; getNumChildren(): number; - getObjectsUnderPoint(x: number, y: number): DisplayObject[]; - getObjectUnderPoint(x: number, y: number): DisplayObject; - removeAllChildren(): void; - removeChild(child: DisplayObject): bool; - removeChildAt(index: number): bool; - setChildIndex(child: DisplayObject, index: number): void; - sortChildren(sortFunction: Function): void; - swapChildren(child1: DisplayObject, child2: DisplayObject): void; - swapChildrenAt(index1: number, index2: number): void; -} - -interface DisplayObject { - alpha?: number; - cacheCanvas?: HTMLCanvasElement; - cacheID?: number; - compositeOperation?: string; - filters?: Filter[]; - hitArea?: DisplayObject; - id?: Number; - mask?: Shape; - mouseEnabled?: bool; - name?: string; - parent?: DisplayObject; - regX?: number; - regY?: number; - rotation?: number; - scaleX?: number; - scaleY?: number; - shadow?: Shadow; - skewX?: number; - skewY?: number; - snapToPixel?: bool; - suppressCrossDomainErrors?: bool; - visible?: bool; - x?: number; - y?: number; - - cache(x: number, y: number, width: number, height: number, scale?: number): void; - clone(): DisplayObject; - draw(ctx: CanvasRenderingContext2D, ignoreCache?: bool): void; - getCacheDataURL(): string; - getConcatenatedMatrix(matrix: Matrix2D): Matrix2D; - getMatrix(matrix: Matrix2D): Matrix2D; - getStage(): Stage; - globalToLocal(x: number, y: number): Point; - hitTest(x: number, y: number): bool; + getObjectsUnderPoint( x, number, y: number ): DisplayObject[]; + getObjectUnderPoint( x: number, y: number ): DisplayObject; + hitTest( x: number, y: number ): bool; isVisible(): bool; - localToGlobal(x: number, y: number): Point; - localToLocal(x: number, y: number, target: DisplayObject): Point; - setTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): DisplayObject; - setupContext(ctx: CanvasRenderingContext2D): void; + removeAllChildren(): void; + removeChild( ...child: DisplayObject[] ): bool; + removeChildAt( ...index: number[] ): bool; + setChildIndex( child: DisplayObject, index: number ): void; + sortChildren( sortFunction: (a: DisplayObject, b: DisplayObject) => number ): void; + swapChildren( child1: DisplayObject, child2: DisplayObject ): void; + swapChildrenAt( index1: number, index2: number ): void; toString(): string; - uncache(): void; - updateCache(compositeOperation: string); + } - onClick?: (event: MouseEvent) =>void; - onDoubleClick?: (event: MouseEvent) =>void; - onMouseOut?: (event: MouseEvent) =>void; - onMouseOver?: (event: MouseEvent) =>void; - onPress?: (event: MouseEvent) =>void; - onTick?: () =>void; -} -interface DOMElement extends DisplayObject { +export class DOMElement extends DisplayObject + { + constructor( htmlElement: HTMLElement ); + + // properties htmlElement: HTMLElement; - constructor (htmlElement: HTMLElement); + // methods cache(): void; clone(): DOMElement; -} - -interface Filter { - constructor (); - applyFilter(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, targetCtx: number, targetX: number, targetY: number): bool; - clone(): Filter; - getBounds(): Rectangle; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + globalToLocal(): void; + isVisible(): bool; + localToGlobal(): void; + localToLocal(): void; toString(): string; -} + uncache(): void; + updateCache(): void; + } -interface Graphics { - BASE_64: any; - curveTo: Function; - drawRect: Function; + +export class Graphics + { + // properties + BASE_64: Object; + curveTo( cpx: number, cpy: number, x: number, y: number ): Graphics; // same as quadraticCurveTo() + drawRect( x: number, y: number, width: number, height: number ): Graphics; // same as rect() STROKE_CAPS_MAP: string[]; STROKE_JOINTS_MAP: string[]; - constructor (); + // methods + arc( x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: bool ): Graphics; + arcTo( x1: number, y1: number, x2: number, y2: number, radius: number ): Graphics; + beginBitmapFill( image: Object, repetition?: string ): Graphics; + beginBitmapStroke( image: Object, repetition?: string ): Graphics; + beginFill( color: string ): Graphics; + beginLinearGradientFill( colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number ): Graphics; + beginLinearGradientStroke( colors: string[], ratios: number[], x0: number, y0: number, x1: number, y1: number ): Graphics; + beginRadialGradientFill( colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number ): Graphics; + beginRadialGradientStroke( colors: string[], ratios: number[], x0: number, y0: number, r0: number, x1: number, y1: number, r1: number ): Graphics; + beginStroke( color: string ): Graphics; + bezierCurveTo( cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number ): Graphics; + clear(): Graphics; + clone(): Graphics; + closePath(): Graphics; + decodePath( str: string ): Graphics; + draw( ctx: CanvasRenderingContext2D ): void; + drawAsPath( ctx: CanvasRenderingContext2D ): void; + drawCircle( x: number, y: number, radius: number ): Graphics; + drawEllipse( x: number, y: number, width: number, height: number ): Graphics; + drawPolyStar( x: number, y: number, radius: number, sides: number, pointSize: number, angle: number ): Graphics; + drawRoundRect( x: number, y: number, width: number, height: number, radius: number ): Graphics; + drawRoundRectComplex( x: number, y: number, width: number, height: number, radiusTL: number, radiusTR: number, radiusBR: number, radisBL: number ): Graphics; + endFill(): Graphics; + endStroke(): Graphics; + static getHSL( hue: number, saturation: number, lightness: number, alpha?: number ): string; + static getRGB( red: number, green: number, blue: number, alpha?: number ): string; + lineTo( x: number, y: number ): Graphics; + moveTo( x: number, y: number ): Graphics; + quadraticCurveTo( cpx: number, cpy: number, x: number, y: number ): Graphics; + rect( x: number, y: number, width: number, height: number ): Graphics; + setStrokeStyle( thickness: number, caps?: string, joints?: string, miter?: number ): Graphics; // caps and joints can be a string or number + setStrokeStyle( thickness: number, caps?: number, joints?: string, miter?: number ): Graphics; + setStrokeStyle( thickness: number, caps?: string, joints?: number, miter?: number ): Graphics; + setStrokeStyle( thickness: number, caps?: number, joints?: number, miter?: number ): Graphics; + toString(): string; + } + +export class Matrix2D + { + constructor( a: number, b: number, c: number, d: number, tx: number, ty: number ); + + // properties + a: number; + alpha: number; + atx: number; + b: number; + c: number; + compositeOperation: string; + d: number; + static DEG_TO_RAD: number; + static identity: Matrix2D; + shadow: Shadow; + ty: number; + + // methods + append( a: number, b: number, c: number, d: number, tx: number, ty: number ): Matrix2D; + appendMatrix( matrix: Matrix2D ): Matrix2D; + appendProperties( a: number, b: number, c: number, d: number, tx: number, ty: number, alpha: number, shadow: Shadow, compositeOperation: string ): Matrix2D; + appendTransform( x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number ): Matrix2D; + clone(): Matrix2D; + decompose( target: Object ): Matrix2D; + identity(): Matrix2D; + invert(): Matrix2D; + isIdentity(): bool; + prepend( a: number, b: number, c: number, d: number, tx: number, ty: number ): Matrix2D; + prependMatrix( matrix: Matrix2D ): Matrix2D; + prependProperties( alpha: number, shadow: Shadow, compositeOperation: string ): Matrix2D; + prependTransform( x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX?: number, regY?: number ): Matrix2D; + rotate( angle: number ): Matrix2D; + scale( x: number, y: number ): Matrix2D; + skew( skewX: number, skewY: number ): Matrix2D; + toString(): string; + translate( x: number, y: number ): Matrix2D; + } + + +export class MouseEvent + { + constructor( type: string, stageX: number, stageY: number, target: DisplayObject, nativeEvent: NativeMouseEvent, pointerID: number, primary: bool, rawX: number, rawY: number ); + + // properties + nativeEvent: NativeMouseEvent; + pointerID: number; + primaryPointer: bool; + rawX: number; + rawY: number; + stageX: number; + stageY: number; + target: DisplayObject; + type: string; + + // methods + clone(): MouseEvent; + toString(): string; + + // events + onMouseMove: ( event: MouseEvent ) => any; + onMouseUp: ( event: MouseEvent ) => any; + } + + +export class MovieClip extends Container + { + constructor( mode: string, startPosition: number, loop: bool, labels: Object ); + + // properties + actionsEnabled: bool; + static INDEPENDENT: string; + loop: bool; + mode: string; + paused: bool; + static SINGLE_FRAME: string; + startPosition: number; + static SYNCHED: string; + timeline: Timeline; //HERE requires tweenJS + + // methods + clone(): void; + draw( ctx: CanvasRenderingContext2D, ignoreCache: bool ): void; + gotoAndPlay( positionOrLabel: string ): void; + gotoAndPlay( positionOrLabel: number ): void; + gotoAndStop( positionOrLabel: string ): void; + gotoAndStop( positionOrLabel: number ): void; + isVisible(): bool; + play(): void; + stop(): void; + toString(): string; + } + + +export class Point + { + constructor( x: number, y: number ); + + // properties + x: number; + y: number; + + // methods + clone(): Point; + toString(): string; + } + + +export class Rectangle + { + constructor( x: number, y: number, width: number, height: number ); + + // properties + x: number; + y: number; + width: number; + height: number; + + // methods + clone(): Rectangle; + toString(): string; + } + + +export class Shadow + { + constructor( color: string, offsetX: number, offsetY: number, blur: number ); + + // properties + blur: number; + color: string; + static identity: Shadow; + offsetX: number; + offsetY: number; + + // methods + clone(): Shadow; + toString(): string; + } + + +export class Shape extends DisplayObject + { + constructor( graphics?: Graphics ); + + // properties + graphics: Graphics; + + // methods + clone(recursive: bool): Shape; + draw( ctx, CanvasRenderingContext2D, ignoreCache: bool ): void; + isVisible(): bool; + toString(): string; + } + + + // what is returned from .getAnimation() +interface SpriteSheetAnimation + { + frames: number[]; + frequency: number; + name: string; + next: string; + } + +export class SpriteSheet + { + constructor( data: Object ); + + // properties + complete: bool; + + // methods + clone(): SpriteSheet; + getAnimation( name: string ): SpriteSheetAnimation; + getAnimations(): string[]; + getFrame( frameIndex: number ): Object; + getNumFrames( animation: string ): number; + toString(): string; + + // events + onComplete: () => any; + } + + +export class SpriteSheetBuilder + { + // properties + defaultScale: number; + maxWidth: number; + maxHeight: number; + padding: number; + spriteSheet: SpriteSheet; + + // methods + addFrame( source: DisplayObject, sourceRect?: Rectangle, scale?: number, setupFunction?: () => any, setupParams?: any[], setupScope?: Object ): number; //HERE returns number or null + addMovieClip( source: MovieClip, sourceRect?: Rectangle, scale?: number ): void; + build(): void; + buildAsync( callback?: ( reference: SpriteSheetBuilder ) => any, timeSlice?: number ): void; + clone(): SpriteSheetBuilder; + stopAsync(): void; + toString(): string; + } + + +export class SpriteSheetUtils + { + static addFlippedFrames(spriteSheet: SpriteSheet, horizontal?: bool, vertical?: bool, both?: bool ): void; + static extractFrame( spriteSheet: Image, frame: number ): Image; //HERE + static flip( spriteSheet: Image, flipData: Object ): void; + static mergeAlpha( rgbImage: Image, alphaImage: Image, canvas?: HTMLCanvasElement ): HTMLCanvasElement; + } + + +export class Stage extends Container + { + constructor (canvas: HTMLCanvasElement); + + // properties + autoClear: bool; + canvas: HTMLCanvasElement; + mouseInBounds: bool; + mouseX: number; + mouseY: number; + snapToPixelEnabled: bool; + tickOnUpdate: bool; + + // methods + clear(): void; + clone(): Stage; + enableMouseOver( frequency: number ): void; + toDataURL( backgroundColor: string, mimeType: string ): string; + toString(): string; + update(): void; + + // events + onMouseDown: ( event: MouseEvent ) => any; + onMouseMove: ( event: MouseEvent ) => any; + onMouseUp: ( event: MouseEvent ) => any; + } + + +export class Text extends DisplayObject + { + constructor(text?: string, font?: string, color?: string); + + // properties + color: string; + font: string; + lineHeight: number; + lineWidth: number; + maxWidth: number; + outline: bool; + text: string; + textAlign: string; + textBaseline: string; + + // methods + clone(): Text; + draw(ctx: CanvasRenderingContext2D, ignoreCache: bool): void; + getMeasuredHeight(): number; + getMeasuredLineHeight(): number; + getMeasuredWidth(): number; + isVisible(): bool; + toString(): string; + } + + +export class Ticker + { + // properties + static useRAF: bool; + + // methods + static addListener( o:Object, pauseable?:bool ): void; + static getFPS(): number; + static getInterval(): number; + static getMeasuredFPS( ticks?: number ): number; + static getPaused(): bool; + static getTicks( pauseable?: bool ): number; + static getTime( pauseable: bool ): number; + static init(): void; + static removeAllListeners(): void; + static removeListener( o: Object ): void; + static setFPS( value: number ): void; + static setInterval( interval: number ): void; + static setPaused( value: bool ): void; + + // events + tick: ( timeElapsed: number ) => any; + } + + +export class Touch + { + // methods + static disable( stage: Stage ): void; + static enable( stage: Stage, singleTouch?: bool, allowDefault?: bool ): bool; + static isSupported(): bool; + } + + +export class UID + { + // methods + static get(): number; + } } -interface Matrix2D { -} -interface MouseEvent { -} -interface MovieClip extends Container { -} - -interface Point { -} - -interface Rectangle { -} - -interface Shadow { -} - -interface Shape extends DisplayObject { -} - -interface SpriteSheet { -} - -interface SpriteSheetBuilder { -} - -interface SpriteSheetUtils { -} - -interface Stage extends Container { -} - -interface Text extends DisplayObject { -} - -interface Ticker { -} - -interface Touch { -} - -interface UID { - get(): number; -} diff --git a/Definitions/preloadjs-0.2.d.ts b/Definitions/preloadjs-0.2.d.ts new file mode 100644 index 000000000..419cf394b --- /dev/null +++ b/Definitions/preloadjs-0.2.d.ts @@ -0,0 +1,82 @@ +/* + See https://bitbucket.org/drk4/createjs_ts_definitions for updates/examples + + Copyright (c) 2012 Pedro Ferreira + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +module createjs +{ +export class AbstractLoader + { + // properties + canceled: bool; + loaded: bool; + progress: number; + + // methods + cancel(): void; + getItem(): Object; + load(): void; + + // events + onComplete: () => any; + onError: () => any; + onFileLoad: () => any; + onFileProgress: () => any; + onLoadStart: () => any; + onProgress: () => any; + } + + +export class PreloadJS extends AbstractLoader + { + constructor( useXHR2?: bool ); + + // properties + static CSS: string; + static IMAGE: string; + static JAVASCRIPT: string; + static JSON: string; + maintainScriptOrder: bool; + next: PreloadJS; + static SOUND: string; + stopOnError: bool; + static TEXT: string; + static TIMEOUT_TIME: number; + useXHR: bool; + static XML: string; + + // methods + BrowserDetect(): Object; + close(): void; + getResult( value: string ): Object; + initialize( useXHR: bool ): void; + installPlugin( plugin: () => any ): void; + load(): void; + loadFile( file: Object, loadNow: bool ): void; + loadFile( file: string, loadNow: bool ): void; + loadManifest( manifest: Object[], loadNow: bool ): void; + loadManifest( manifest: string[], loadNow: bool ): void; + setMaxConnections( value: number ): void; + setPaused( value: bool ): void; + } + + +export class TagLoader extends AbstractLoader + { + constructor( item: Object, srcAttr: string, useXHR: bool ); + constructor( item: string, srcAttr: string, useXHR: bool ); + } + + +export class XHRLoader extends AbstractLoader + { + constructor( file: Object ); + } +} \ No newline at end of file diff --git a/Definitions/soundjs-0.3.d.ts b/Definitions/soundjs-0.3.d.ts new file mode 100644 index 000000000..57f4a97b9 --- /dev/null +++ b/Definitions/soundjs-0.3.d.ts @@ -0,0 +1,112 @@ +/* + See https://bitbucket.org/drk4/createjs_ts_definitions for updates/examples + + Copyright (c) 2012 Pedro Ferreira + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +module createjs +{ +export class FlashPlugin + { + // properties + static BASE_PATH: string; + static capabilities: Object; + showOutput: bool; + + // methods + create( src: string ): SoundInstance; + static generateCapabilities(): void; + static isSupported(): bool; + register( src: string, instances: number ): Object; + } + +export class HTMLAudioPlugin + { + // properties + static capabilities: Object; + static MAX_INSTANCES: number; + + // methods + create( src: string ): SoundInstance; + static generateCapabilities(): void; + static isSupported(): bool; + register( src: string, instances: number ): Object; + } + +export class SoundInstance + { + constructor( src: string ); + + // properties + muted: bool; + owner: HTMLAudioPlugin; + paused: bool; + playState: string; + src: string; + uniqueId: string; //HERE string or number + + // methods + getDuration(): number; + getPan(): number; + getPosition(): number; + getVolume(): number; + mute( isMuted: bool ): bool; + pause(): bool; + play( interrupt: string, delay: number, offset: number, loop: number, volume: number, pan: number ): void; + resume(): bool; + setPan( value: number ): number; + setPosition( value: number ): void; + setVolume( value: number ): bool; + stop(): bool; + + // events + onComplete: () => any; + onLoop: () => any; + onPlayFailed: () => any; + onPlayInterrupted: () => any; + onReady: () => any; + } + + +export class SoundJS + { + // properties + static activePlugin: Object; + static AUDIO_TIMEOUT: number; + static DELIMITER: string; + static INTERRUPT_ANY: string; + static INTERRUPT_EARLY: string; + static INTERRUPT_LATE: string; + static INTERRUPT_NONE: string; + static muted: bool; + static PLAY_FAILED: string; + static PLAY_FINISHED: string; + static PLAY_INITED: string; + static PLAY_INTERRUPTED: string; + static PLAY_SUCCEEDED: string; + + // methods + static checkPlugin( initializeDefault: bool ): bool; + static getCapabilities(): Object; + static getCapability( key: string ); //HERE can return string | number | bool + static getInstanceById( uniqueId: string ): SoundInstance; + static getMasterVolume(): number; + static getSrcFromId( value: string ): string; + static isReady(): bool; + static pause( id: string ): void; + static play( value: string, interrupt?: string, delay?: number, offset?: number, loop?: number, volume?: number, pan?: number ): SoundInstance; + static registerPlugin( plugin: Object ): bool; + static registerPlugins( plugins: Object[] ): bool; + static resume( id: string ): void; + static setMasterVolume( value: number ): bool; + static setMute( isMuted: bool, id: string ): bool; + static setVolume( value: number, id?: string ): bool; + static stop( id?: string ): bool; + } +} diff --git a/Definitions/tweenjs-0.3.d.ts b/Definitions/tweenjs-0.3.d.ts new file mode 100644 index 000000000..9c0bf2da4 --- /dev/null +++ b/Definitions/tweenjs-0.3.d.ts @@ -0,0 +1,137 @@ +/* + See https://bitbucket.org/drk4/createjs_ts_definitions for updates/examples + + Copyright (c) 2012 Pedro Ferreira + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +module createjs +{ +export class CSSPlugin + { + // properties + static cssSuffixMap: Object; + + // methods + static install(): void; + } + + +export class Ease + { + // methods + static backIn(): number; + static backInOut(): number; + static backOut(): number; + static bounceIn( amount: number ): number; + static bounceInOut( amount: number ): number; + static bounceOut( amount: number ): number; + static circIn( amount: number ): number; + static circInOut( amount: number ): number; + static circOut( amount: number ): number; + static cubicIn(): number; + static cubicInOut(): number; + static cubicOut(): number; + static elasticIn(): number; + static elasticInOut(): number; + static elasticOut(): number; + static get( amount: number ): ( amount: number ) => number; + static getBackIn( amount: number ): ( amount: number ) => number; + static getBackInOut( amount: number ): ( amount: number ) => number; + static getBackOut( amount: number ): ( amount: number ) => number; + static getElasticIn( amplitude: number, period: number ): ( amount: number ) => number; + static getElasticInOut( amplitude: number, period: number ): ( amount: number ) => number; + static getElasticOut( amplitude: number, period: number ): ( amount: number ) => number; + static getPowIn( pow: number ): ( amount: number ) => number; + static getPowInOut( pow: number ): ( amount: number ) => number; + static getPowOut( pow: number ): ( amount: number ) => number; + static linear( amount: number ): number; + static none( amount: number ): number; // same as linear + static quadIn(): ( amount: number ) => number; + static quadInOut(): ( amount: number ) => number; + static quadOut(): ( amount: number ) => number; + static quartIn(): ( amount: number ) => number; + static quartInOut(): ( amount: number ) => number; + static quartOut(): ( amount: number ) => number; + static quintIn(): ( amount: number ) => number; + static quintInOut(): ( amount: number ) => number; + static quintOut(): ( amount: number ) => number; + static sineIn( amount: number ): number; + static sineInOut( amount: number ): number; + static sineOut( amount: number ): number; + } + + +export class Timeline + { + constructor( tweens: Tween[], labels: Object, props: Object ); + + // properties + duration: number; + ignoreGlobalPause: bool; + loop: bool; + position: number; + + // methods + addLabel( label: string, position: number ): void; + addTween( ...tween: Tween[] ): void; + gotoAndPlay( positionOrLabel: string ): void; + gotoAndPlay( positionOrLabel: number ): void; + gotoAndStop( positionOrLabel: string ): void; + gotoAndStop( positionOrLabel: number ): void; + removeTween( ...tween: Tween[] ): void; + resolve( positionOrLabel: string ): number; + resolve( positionOrLabel: number ): number; + setPaused( value: bool ): void; + setPosition( value: number, actionsMode?: number ): void; + tick( delta: number ): void; + toString(): string; + updateDuration(): void; + + // events + onChange: ( instance: Timeline ) => any; + } + + +export class Tween + { + constructor( target: Object, props: Object ); + + // properties + duration: number; + static IGNORE: Object; + ignoreGlobalPause: bool; + loop: bool; + static LOOP: number; + static NONE: number; + pluginData: Object; + position: number; + static REVERSE: number; + target: Object; + + // methods + call( callback: ( tweenObject: Tween ) => any, params?: any[], scope?: Object ); // when 'params' isn't given, the callback receives a tweenObject + call( callback: ( ...params:any[] ) => any, params?: any[], scope?: Object ); // otherwise, it receives the params only + static get( target, props: Object ): Tween; + static hasActiveTweens( target? ): void; + static installPlugin( plugin: Object, properties: Object ): void; + pause( tween: Tween ): void; + play( tween: Tween ): void; + static removeTweens( target ): void; + set( props: Object, target? ): void; + setPaused( value: bool ): void; + setPosition( value: number, actionsMode: number ): void; + static tick( delta: number, paused: bool ): void; + to( props: Object, duration?: number, ease?: ( amount: number ) => number ): Tween; + toString(): string; + wait( duration: number ): void; + + // events + onChange: ( instance: Tween ) => any; + } +} \ No newline at end of file