From c4f4eb9b848cd9960c1829fb67569a80be90562e Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Thu, 1 Nov 2012 16:02:34 +0200 Subject: [PATCH] Add initial EaselJS definitions and tests --- Definitions/easeljs-0.5.d.ts | 95 ++++++++++++++++++++++++++++++++++++ Tests/easeljs-tests.ts | 37 ++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 Definitions/easeljs-0.5.d.ts create mode 100644 Tests/easeljs-tests.ts diff --git a/Definitions/easeljs-0.5.d.ts b/Definitions/easeljs-0.5.d.ts new file mode 100644 index 000000000..65a6b8098 --- /dev/null +++ b/Definitions/easeljs-0.5.d.ts @@ -0,0 +1,95 @@ +// Type definitions for EaselJS 0.5 +// Project: http://www.createjs.com/#!/EaselJS +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +interface AlphaMapFilter { + alphaMap; + constructor (alphaMap); + applyFilter(ctx: any, x: any, y: any, width, height, targetCtx, targetX, targetY): void; + clone(); + toString(): string; +} + +interface AlphaMaskFilter { +} + +interface Bitmap extends DisplayObject { +} + +interface BitmapAnimation extends DisplayObject { +} + +interface BoxBlurFilter { +} + +interface ColorFilter { +} + +interface ColorMatrix { +} + +interface ColorMatrixFilter { +} + +interface Command { +} + +interface Container extends DisplayObject { +} + +interface DisplayObject { +} + +interface DOMElement extends DisplayObject { +} + +interface Graphics { +} + +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; +} \ No newline at end of file diff --git a/Tests/easeljs-tests.ts b/Tests/easeljs-tests.ts new file mode 100644 index 000000000..94accea97 --- /dev/null +++ b/Tests/easeljs-tests.ts @@ -0,0 +1,37 @@ +/// + +function test_simple() { + var canvas = document.getElementById('canvas'); + var stage = new Stage(canvas); + var shape = new Shape(); + shape.graphics.beginFill('rgba(255,0,0,1)').drawRoundRect(0, 0, 120, 120, 10); + stage.addChild(shape); + stage.update(); +} + +function test_animation() { + var ss = new SpriteSheet({ + "frames": { + "width": 200, + "numFrames": 64, + "regX": 2, + "regY": 2, + "height": 361 + }, + "animations": { "jump": [26, 63], "run": [0, 25] }, + "images": ["./assets/runningGrant.png"] + }); + + ss.getAnimation("run").frequency = 2; + ss.getAnimation("run").next = "jump"; + ss.getAnimation("jump").next = "run"; + + var bitmapAnimation = new BitmapAnimation(ss); + bitmapAnimation.scaleY = bitmapAnimation.scaleX = .4; + + bitmapAnimation.gotoAndPlay("run"); + + Ticker.setFPS(60); + Ticker.addListener(stage); + stage.addChild(bitmapAnimation); +} \ No newline at end of file