diff --git a/.gitignore b/.gitignore index 5785530..76ff3c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .idea .DS_STORE - diff --git a/CAAT/build/caat-box2d-min.js b/CAAT/build/caat-box2d-min.js new file mode 100644 index 0000000..bfa904a --- /dev/null +++ b/CAAT/build/caat-box2d-min.js @@ -0,0 +1,45 @@ + +/* +The MIT License + +Copyright (c) 2010-2011-2012 Ibon Tolosana [@hyperandroid] + +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. + +Version: 0.6 build: 6 + +Created on: +DATE: 2013-07-01 +TIME: 04:58:33 +*/ + + +CAAT.Module({defines:"CAAT.Foundation.Box2D.B2DBodyActor",depends:["CAAT.Foundation.Actor"],aliases:["CAAT.B2DBodyActor"],extendsClass:"CAAT.Foundation.Actor",extendsWith:function(){CAAT.PMR=64;CAAT.enableBox2DDebug=function(b,a,c,d){if(b){b=new Box2D.Dynamics.b2DebugDraw;try{b.m_sprite.graphics.clear=function(){}}catch(g){}c.SetDebugDraw(b);b.SetSprite(a.ctx);b.SetDrawScale(d||CAAT.PMR);b.SetFillAlpha(0.5);b.SetLineThickness(1);b.SetFlags(3)}else c.SetDebugDraw(null)};return{restitution:0.5,friction:0.5, +density:1,bodyType:Box2D.Dynamics.b2Body.b2_dynamicBody,worldBody:null,world:null,worldBodyFixture:null,bodyDef:null,fixtureDef:null,bodyData:null,recycle:false,__init:function(){this.__super();this.setPositionAnchor(0.5,0.5);return this},setPositionAnchor:function(){this.tAnchorY=this.tAnchorX=0.5},setPositionAnchored:function(b,a){this.x=b;this.y=a;this.tAnchorY=this.tAnchorX=0.5},setRecycle:function(){this.recycle=true;return this},destroy:function(){CAAT.Foundation.Box2D.B2DBodyActor.superclass.destroy.call(this); +if(this.recycle)this.setLocation(-Number.MAX_VALUE,-Number.MAX_VALUE),this.setAwake(false);else{var b=this.worldBody;b.DestroyFixture(this.worldBodyFixture);this.world.DestroyBody(b)}return this},setAwake:function(b){this.worldBody.SetAwake(b);return this},setSleepingAllowed:function(b){this.worldBody.SetSleepingAllowed(b);return this},setLocation:function(b,a){this.worldBody.SetPosition(new Box2D.Common.Math.b2Vec2(b/CAAT.PMR,a/CAAT.PMR));return this},setDensity:function(b){this.density=b;return this}, +setFriction:function(b){this.friction=b;return this},setRestitution:function(b){this.restitution=b;return this},setBodyType:function(b){this.bodyType=b;return this},check:function(b,a,c){b[a]||(b[a]=c)},createBody:function(b,a){if(a)this.check(a,"density",1),this.check(a,"friction",0.5),this.check(a,"restitution",0.2),this.check(a,"bodyType",Box2D.Dynamics.b2Body.b2_staticBody),this.check(a,"userData",{}),this.check(a,"image",null),this.density=a.density,this.friction=a.friction,this.restitution= +a.restitution,this.bodyType=a.bodyType,this.image=a.image;this.world=b;return this},getCenter:function(){return this.worldBody.GetPosition()},getDistanceJointLocalAnchor:function(){return new Box2D.Common.Math.b2Vec2(0,0)},animate:function(b,a){var c=this.worldBody.GetPosition();CAAT.Foundation.Actor.prototype.setLocation.call(this,CAAT.PMR*c.x,CAAT.PMR*c.y);this.setRotation(this.worldBody.GetAngle());return CAAT.Foundation.Box2D.B2DBodyActor.superclass.animate.call(this,b,a)}}}}); +CAAT.Module({defines:"CAAT.Foundation.Box2D.B2DCircularBody",depends:["CAAT.Foundation.Box2D.B2DBodyActor"],aliases:["CAAT.B2DCircularBody"],extendsClass:"CAAT.Foundation.Box2D.B2DBodyActor",constants:{createCircularBody:function(b,a){if(a.radius)this.radius=a.radius;var c=new Box2D.Dynamics.b2FixtureDef;c.density=a.density;c.friction=a.friction;c.restitution=a.restitution;c.shape=new Box2D.Collision.Shapes.b2CircleShape(a.radius/CAAT.PMR);var d=new Box2D.Dynamics.b2BodyDef;d.type=a.bodyType;d.position.Set(a.x/ +CAAT.PMR,a.y/CAAT.PMR);c.userData=a.userData;d.userData=a.userData;var g=b.CreateBody(d),h=g.CreateFixture(c);a.isSensor&&h.SetSensor(true);return{worldBody:g,worldBodyFixture:h,fixDef:c,bodyDef:d}}},extendsWith:{radius:1,createBody:function(b,a){var c=a.radius||1;c+=(a.bodyDefScaleTolerance||0)*Math.random();a.radius=c;CAAT.Foundation.Box2D.B2DCircularBody.superclass.createBody.call(this,b,a);c=CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(b,a);a.userData.actor=this;this.worldBody=c.worldBody; +this.worldBodyFixture=c.worldBodyFixture;this.fixtureDef=c.fixDef;this.bodyDef=c.bodyDef;this.bodyData=a;this.setFillStyle(this.worldBodyFixture.IsSensor()?"red":"green").setBackgroundImage(this.image).setSize(2*a.radius,2*a.radius).setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);return this}}}); +CAAT.Module({defines:"CAAT.Foundation.Box2D.B2DPolygonBody",depends:["CAAT.Foundation.Box2D.B2DBodyActor","CAAT.Foundation.SpriteImage"],aliases:["CAAT.B2DPolygonBody"],constants:{TYPE:{EDGE:"edge",BOX:"box",POLYGON:"polygon"},createPolygonBody:function(b,a){var c=new Box2D.Dynamics.b2FixtureDef;c.density=a.density;c.friction=a.friction;c.restitution=a.restitution;c.shape=new Box2D.Collision.Shapes.b2PolygonShape;var d=Number.MAX_VALUE,g=-Number.MAX_VALUE,h=Number.MAX_VALUE,i=-Number.MAX_VALUE,e= +[],j=a.bodyDefScale||1;j+=(a.bodyDefScaleTolerance||0)*Math.random();for(var f=0;fg&&(g=k);li&&(i=l);e.push(new Box2D.Common.Math.b2Vec2(k/CAAT.PMR,l/CAAT.PMR))}j=[{x:d,y:h},{x:g,y:i}];f=new Box2D.Dynamics.b2BodyDef;f.type=a.bodyType;f.position.Set(((g-d)/2+(a.x||0))/CAAT.PMR,((i-h)/2+(a.y||0))/CAAT.PMR);if(a.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE)d=new Box2D.Common.Math.b2Vec2(e[0].x,e[0].y), +e=new Box2D.Common.Math.b2Vec2(e[1].x-e[0].x,e[1].y-e[0].y),f.position.Set(d.x,d.y),c.shape.SetAsEdge(new Box2D.Common.Math.b2Vec2(0,0),e);else if(a.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.BOX)c.shape.SetAsBox((g-d)/2/CAAT.PMR,(i-h)/2/CAAT.PMR);else if(a.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.POLYGON)c.shape.SetAsArray(e,e.length);else throw"Unkown bodyData polygonType: "+a.polygonType;c.userData=a.userData;f.userData=a.userData;e=b.CreateBody(f);d=e.CreateFixture(c); +a.isSensor&&d.SetSensor(true);return{worldBody:e,worldBodyFixture:d,fixDef:c,bodyDef:f,boundingBox:j}}},extendsClass:"CAAT.Foundation.Box2D.B2DBodyActor",extendsWith:{boundingBox:null,getDistanceJointLocalAnchor:function(){return this.worldBody.GetFixtureList().GetShape().GetLocalCenter()},createBody:function(b,a){CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,b,a);var c=CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(b,a);a.userData.actor=this;this.worldBody=c.worldBody; +this.worldBodyFixture=c.worldBodyFixture;this.fixtureDef=c.fixDef;this.bodyDef=c.bodyDef;this.bodyData=a;this.boundingBox=c.boundingBox;this.setBackgroundImage(a.image).setSize(c.boundingBox[1].x-c.boundingBox[0].x+1,c.boundingBox[1].y-c.boundingBox[0].y+1).setFillStyle(c.worldBodyFixture.IsSensor()?"#0f0":"#f00").setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);return this}}});CAAT.ModuleManager.solveAll(); diff --git a/CAAT/build/caat-box2d.js b/CAAT/build/caat-box2d.js new file mode 100644 index 0000000..7c5c272 --- /dev/null +++ b/CAAT/build/caat-box2d.js @@ -0,0 +1,601 @@ +/* +The MIT License + +Copyright (c) 2010-2011-2012 Ibon Tolosana [@hyperandroid] + +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. +\nVersion: 0.6 build: 7\n +Created on: +DATE: 2013-07-01 +TIME: 06:39:52 +*/\n\n +CAAT.Module({ + + /** + * @name Box2D + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name B2DBodyActor + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines:"CAAT.Foundation.Box2D.B2DBodyActor", + depends:[ + "CAAT.Foundation.Actor" + ], + aliases : ["CAAT.B2DBodyActor"], + extendsClass:"CAAT.Foundation.Actor", + extendsWith:function () { + + /** + * @lends CAAT + */ + + /** + * Points to Meter ratio value. + * @type {Number} + */ + CAAT.PMR = 64; + + /** + * (As Eemeli Kelokorpi suggested) + * + * Enable Box2D debug renderer. + * + * @param set {boolean} enable or disable + * @param director {CAAT.Foundation.Director} + * @param world {object} box2d world + * @param scale {numner} a scale value. + */ + CAAT.enableBox2DDebug = function (set, director, world, scale) { + + if (set) { + var debugDraw = new Box2D.Dynamics.b2DebugDraw(); + try { + debugDraw.m_sprite.graphics.clear = function () { + }; + } catch (e) { + } + + world.SetDebugDraw(debugDraw); + + debugDraw.SetSprite(director.ctx); + debugDraw.SetDrawScale(scale || CAAT.PMR); + debugDraw.SetFillAlpha(.5); + debugDraw.SetLineThickness(1.0); + debugDraw.SetFlags(0x0001 | 0x0002); + + } else { + world.SetDebugDraw(null); + } + }; + + return { + + /** + * @lends CAAT.Foundation.Box2D.B2DBodyActor.prototype + */ + + /** + * Body restitution. + */ + restitution:.5, + + /** + * Body friction. + */ + friction:.5, + + /** + * Body dentisy + */ + density:1, + + /** + * Dynamic bodies by default + */ + bodyType:Box2D.Dynamics.b2Body.b2_dynamicBody, + + /** + * Box2D body + */ + worldBody:null, + + /** + * Box2D world reference. + */ + world:null, + + /** + * Box2d fixture + */ + worldBodyFixture:null, + + /** + * Box2D body definition. + */ + bodyDef:null, + + /** + * Box2D fixture definition. + */ + fixtureDef:null, + + /** + * BodyData object linked to the box2D body. + */ + bodyData:null, + + /** + * Recycle this actor when the body is not needed anymore ?? + */ + recycle:false, + + __init : function() { + this.__super(); + this.setPositionAnchor(.5,.5); + + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + setPositionAnchored : function(x,y,ax,ay) { + this.x= x; + this.y= y; + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + /** + * set this actor to recycle its body, that is, do not destroy it. + */ + setRecycle:function () { + this.recycle = true; + return this; + }, + destroy:function () { + + CAAT.Foundation.Box2D.B2DBodyActor.superclass.destroy.call(this); + if (this.recycle) { + this.setLocation(-Number.MAX_VALUE, -Number.MAX_VALUE); + this.setAwake(false); + } else { + var body = this.worldBody; + body.DestroyFixture(this.worldBodyFixture); + this.world.DestroyBody(body); + } + + return this; + }, + setAwake:function (bool) { + this.worldBody.SetAwake(bool); + return this; + }, + setSleepingAllowed:function (bool) { + this.worldBody.SetSleepingAllowed(bool); + return this; + }, + setLocation:function (x, y) { + this.worldBody.SetPosition( + new Box2D.Common.Math.b2Vec2( + x / CAAT.PMR, + y / CAAT.PMR)); + return this; + }, + /** + * Set this body's + * density. + * @param d {number} + */ + setDensity:function (d) { + this.density = d; + return this; + }, + + /** + * Set this body's friction. + * @param f {number} + */ + setFriction:function (f) { + this.friction = f; + return this; + }, + + /** + * Set this body's restitution coeficient. + * @param r {number} + */ + setRestitution:function (r) { + this.restitution = r; + return this; + }, + + /** + * Set this body's type: + * @param bodyType {Box2D.Dynamics.b2Body.b2_*} + */ + setBodyType:function (bodyType) { + this.bodyType = bodyType; + return this; + }, + + /** + * Helper method to check whether this js object contains a given property and if it doesn't exist + * create and set it to def value. + * @param obj {object} + * @param prop {string} + * @param def {object} + */ + check:function (obj, prop, def) { + if (!obj[prop]) { + obj[prop] = def; + } + }, + + /** + * Create an actor as a box2D body binding, create it on the given world and with + * the initialization data set in bodyData object. + * @param world {Box2D.Dynamics.b2World} a Box2D world instance + * @param bodyData {object} An object with body info. + */ + createBody:function (world, bodyData) { + + if (bodyData) { + this.check(bodyData, 'density', 1); + this.check(bodyData, 'friction', .5); + this.check(bodyData, 'restitution', .2); + this.check(bodyData, 'bodyType', Box2D.Dynamics.b2Body.b2_staticBody); + this.check(bodyData, 'userData', {}); + this.check(bodyData, 'image', null); + + this.density = bodyData.density; + this.friction = bodyData.friction; + this.restitution = bodyData.restitution; + this.bodyType = bodyData.bodyType; + this.image = bodyData.image; + + } + + this.world = world; + + return this; + }, + + /** + * Get this body's center on screen regardless of its shape. + * This method will return box2d body's centroid. + */ + getCenter:function () { + return this.worldBody.GetPosition(); + }, + + /** + * Get a distance joint's position on pixels. + */ + getDistanceJointLocalAnchor:function () { + return new Box2D.Common.Math.b2Vec2(0,0); + }, + + /** + * Method override to get position and rotation angle from box2d body. + * @param director {CAAT.Director} + * @param time {number} + */ + animate: function(director, time) { + + var pos= this.worldBody.GetPosition(); + + CAAT.Foundation.Actor.prototype.setLocation.call( + this, + CAAT.PMR*pos.x, + CAAT.PMR*pos.y); + + this.setRotation( this.worldBody.GetAngle() ); + + return CAAT.Foundation.Box2D.B2DBodyActor.superclass.animate.call(this,director,time); + } + } + } +}); +CAAT.Module( { + + /** + * @name B2DCircularBody + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Box2D.B2DBodyActor + * @constructor + */ + + defines : "CAAT.Foundation.Box2D.B2DCircularBody", + depends : [ + "CAAT.Foundation.Box2D.B2DBodyActor" + ], + aliases : ["CAAT.B2DCircularBody"], + extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor", + constants : { + + /** + * @lends CAAT.Foundation.Box2D.B2DCircularBody + */ + + createCircularBody : function(world, bodyData) { + if ( bodyData.radius ) this.radius= bodyData.radius; + + var fixDef= new Box2D.Dynamics.b2FixtureDef(); + fixDef.density= bodyData.density; + fixDef.friction= bodyData.friction; + fixDef.restitution= bodyData.restitution; + fixDef.shape = new Box2D.Collision.Shapes.b2CircleShape(bodyData.radius/CAAT.PMR); + + var bodyDef = new Box2D.Dynamics.b2BodyDef(); + bodyDef.type = bodyData.bodyType; + bodyDef.position.Set( bodyData.x/CAAT.PMR, bodyData.y/CAAT.PMR ); + + // link entre cuerpo fisico box2d y caat. + fixDef.userData= bodyData.userData; + bodyDef.userData= bodyData.userData; + + var worldBody= world.CreateBody(bodyDef); + var worldBodyFixture= worldBody.CreateFixture(fixDef); + + if ( bodyData.isSensor ) { + worldBodyFixture.SetSensor(true); + } + + return { + worldBody: worldBody, + worldBodyFixture: worldBodyFixture, + fixDef: fixDef, + bodyDef: bodyDef + }; + } + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.Box2D.B2DCircularBody.prototype + */ + + + /** + * Default radius. + */ + radius: 1, + + /** + * Create a box2d body and link it to this CAAT.Actor instance. + * @param world {Box2D.Dynamics.b2World} a Box2D world instance + * @param bodyData {object} + */ + createBody : function(world, bodyData) { + + var scale= (bodyData.radius || 1); + scale= scale+ (bodyData.bodyDefScaleTolerance || 0)*Math.random(); + bodyData.radius= scale; + + CAAT.Foundation.Box2D.B2DCircularBody.superclass.createBody.call(this,world,bodyData); + var box2D_data= CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(world,bodyData); + + bodyData.userData.actor= this; + + this.worldBody= box2D_data.worldBody; + this.worldBodyFixture= box2D_data.worldBodyFixture; + this.fixtureDef= box2D_data.fixDef; + this.bodyDef= box2D_data.bodyDef; + this.bodyData= bodyData; + + this.setFillStyle(this.worldBodyFixture.IsSensor() ? 'red' : 'green'). + setBackgroundImage(this.image). + setSize(2*bodyData.radius,2*bodyData.radius). + setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE); + + + return this; + } + } + +}); +CAAT.Module( { + + /** + * @name B2DPolygonBody + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Box2D.B2DBodyActor + * @constructor + */ + + defines : "CAAT.Foundation.Box2D.B2DPolygonBody", + depends : [ + "CAAT.Foundation.Box2D.B2DBodyActor", + "CAAT.Foundation.SpriteImage" + ], + aliases : ["CAAT.B2DPolygonBody"], + constants: { + + /** + * @lends CAAT.Foundation.Box2D.B2DPolygonBody + */ + + TYPE: { + EDGE: 'edge', + BOX: 'box', + POLYGON:'polygon' + }, + + /** + * Helper function to aid in box2d polygon shaped bodies. + * @param world + * @param bodyData + */ + createPolygonBody : function(world, bodyData) { + var fixDef = new Box2D.Dynamics.b2FixtureDef(); + fixDef.density = bodyData.density; + fixDef.friction = bodyData.friction; + fixDef.restitution = bodyData.restitution; + fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape(); + + var minx = Number.MAX_VALUE; + var maxx = -Number.MAX_VALUE; + var miny = Number.MAX_VALUE; + var maxy = -Number.MAX_VALUE; + + var vec = []; + + var scale = (bodyData.bodyDefScale || 1); + scale = scale + (bodyData.bodyDefScaleTolerance || 0) * Math.random(); + + for (var i = 0; i < bodyData.bodyDef.length; i++) { + var x = bodyData.bodyDef[i].x * scale; + var y = bodyData.bodyDef[i].y * scale; + if (x < minx) { + minx = x; + } + if (x > maxx) { + maxx = x; + } + if (y < miny) { + miny = y; + } + if (y > maxy) { + maxy = y; + } +/* + x += bodyData.x || 0; + y += bodyData.y || 0; + */ + vec.push(new Box2D.Common.Math.b2Vec2(x / CAAT.PMR, y / CAAT.PMR)); + } + + var boundingBox = [ + {x:minx, y:miny}, + {x:maxx, y:maxy} + ]; + + var bodyDef = new Box2D.Dynamics.b2BodyDef(); + bodyDef.type = bodyData.bodyType; + bodyDef.position.Set( + ((maxx - minx) / 2 + (bodyData.x || 0)) / CAAT.PMR, + ((maxy - miny) / 2 + (bodyData.y || 0)) / CAAT.PMR ); + + if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) { + + var v0= new Box2D.Common.Math.b2Vec2(vec[0].x, vec[0].y ); + var v1= new Box2D.Common.Math.b2Vec2(vec[1].x-vec[0].x, vec[1].y-vec[0].y ); + + bodyDef.position.Set(v0.x, v0.y); + fixDef.shape.SetAsEdge(new Box2D.Common.Math.b2Vec2(0,0), v1); + + + } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.BOX) { + + fixDef.shape.SetAsBox( + (maxx - minx) / 2 / CAAT.PMR, + (maxy - miny) / 2 / CAAT.PMR); + + } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.POLYGON ) { + + fixDef.shape.SetAsArray(vec, vec.length); + + } else { + throw 'Unkown bodyData polygonType: '+bodyData.polygonType; + } + + // link entre cuerpo fisico box2d y caat. + fixDef.userData = bodyData.userData; + bodyDef.userData = bodyData.userData; + + var worldBody = world.CreateBody(bodyDef); + var worldBodyFixture = worldBody.CreateFixture(fixDef); + + + if (bodyData.isSensor) { + worldBodyFixture.SetSensor(true); + } + + return { + worldBody: worldBody, + worldBodyFixture: worldBodyFixture, + fixDef: fixDef, + bodyDef: bodyDef, + boundingBox: boundingBox + }; + } + }, + extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor", + extendsWith : { + + /** + * @lends CAAT.Foundation.Box2D.B2DPolygonBody.prototype + */ + + /** + * Measured body's bounding box. + */ + boundingBox: null, + + /** + * Get on-screen distance joint coordinate. + */ + getDistanceJointLocalAnchor : function() { + var b= this.worldBody; + var poly= b.GetFixtureList().GetShape().GetLocalCenter(); + return poly; + }, + + /** + * Create a box2d body and link it to this CAAT.Actor. + * @param world {Box2D.Dynamics.b2World} + * @param bodyData {object} + */ + createBody : function(world, bodyData) { + CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,world,bodyData); + + var box2D_data= CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(world,bodyData); + + bodyData.userData.actor = this; + + this.worldBody= box2D_data.worldBody; + this.worldBodyFixture= box2D_data.worldBodyFixture; + this.fixtureDef= box2D_data.fixDef; + this.bodyDef= box2D_data.bodyDef; + this.bodyData= bodyData; + this.boundingBox= box2D_data.boundingBox; + + this.setBackgroundImage( bodyData.image ). + setSize( + box2D_data.boundingBox[1].x-box2D_data.boundingBox[0].x+1, + box2D_data.boundingBox[1].y-box2D_data.boundingBox[0].y+1 ). + setFillStyle( box2D_data.worldBodyFixture.IsSensor() ? '#0f0' : '#f00'). + setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE); + + return this; + } + } + +}); +CAAT.ModuleManager.solveAll(); diff --git a/CAAT/build/caat-css-min.js b/CAAT/build/caat-css-min.js new file mode 100644 index 0000000..44a6dcd --- /dev/null +++ b/CAAT/build/caat-css-min.js @@ -0,0 +1,583 @@ + +/* +The MIT License + +Copyright (c) 2010-2011-2012 Ibon Tolosana [@hyperandroid] + +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. + +Version: 0.6 build: 6 + +Created on: +DATE: 2013-07-01 +TIME: 04:58:33 +*/ + + +(function(a,b){function c(b){for(var b=b.split("."),c=a,d=null,e=0;e NOT solved."))},removeDependency:function(a){for(var b=0;b Can't extend non-existant class: "+this.baseClass);return}}else b=f;b.extend(this.extendWith,this.constants,this.name,this.aliases,{decorated:this.decorated});console.log("Created module: "+this.name);this.callback&&this.callback()}};var h=function(a,b){this.path=a;this.module=b;return this};h.prototype={path:null,processed:false,module:null,setProcessed:function(){this.processed=true},isProcessed:function(){return this.processed}};var i=function(){this.nodes=[];this.loadedFiles=[]; +this.path={};this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};i.baseURL="";i.modulePath={};i.sortedModulePath=[];i.symbol={};i.prototype={nodes:null,loadedFiles:null,solveListener:null,readyListener:null,orderedSolvedModules:null,addSolvedListener:function(a,b){this.solveListener.push({name:a,callback:b})},solved:function(a){var b;for(b=0;b catched "+ +d+" on module "+a.defines+" preCreation.")}if(!a.depends)a.depends=[];if((b=a.depends)&&!isArray(b))b=[b],a.depends=b;for(c=0;c=0&&b>0,b[5]>>0);return this},transformRenderingContext_Clamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2]>>0,b[5]>>0);return this},setModelViewMatrix:function(a,b,c,d,e){var f,g,h,i,j,k;k= +this.matrix;d=1;j=g=0;i=1;c=Math.cos(e);e=Math.sin(e);f=d;h=j;d=f*c+g*e;g=-f*e+g*c;j=h*c+i*e;i=-h*e+i*c;d*=this.scaleX;g*=this.scaleY;j*=this.scaleX;i*=this.scaleY;k[0]=d;k[1]=g;k[2]=a;k[3]=j;k[4]=i;k[5]=b}}}}); +CAAT.Module({defines:"CAAT.Math.Matrix3",aliases:["CAAT.Matrix3"],extendsWith:function(){return{matrix:null,fmatrix:null,__init:function(){this.matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];this.fmatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return this},transformCoord:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.matrix[0][0]+c*this.matrix[0][1]+d*this.matrix[0][2]+this.matrix[0][3];a.y=b*this.matrix[1][0]+c*this.matrix[1][1]+d*this.matrix[1][2]+this.matrix[1][3];a.z=b*this.matrix[2][0]+c*this.matrix[2][1]+ +d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,i){this.identity();this.matrix[0][0]=a;this.matrix[0][1]=b;this.matrix[0][2]=c;this.matrix[1][0]=d;this.matrix[1][1]=e;this.matrix[1][2]=f;this.matrix[2][0]=g;this.matrix[2][1]=h;this.matrix[2][2]=i;return this},initWithMatrix:function(a){this.matrix=a;return this},flatten:function(){var a=this.fmatrix,b=this.matrix;a[0]=b[0][0];a[1]=b[1][0];a[2]=b[2][0];a[3]=b[3][0];a[4]=b[0][1];a[5]=b[1][1];a[6]=b[2][1];a[7]=b[2][1]; +a[8]=b[0][2];a[9]=b[1][2];a[10]=b[2][2];a[11]=b[3][2];a[12]=b[0][3];a[13]=b[1][3];a[14]=b[2][3];a[15]=b[3][3];return this.fmatrix},identity:function(){for(var a=0;a<4;a++)for(var b=0;b<4;b++)this.matrix[a][b]=a===b?1:0;return this},getMatrix:function(){return this.matrix},rotateXY:function(a){return this.rotate(a,0,0)},rotateXZ:function(a){return this.rotate(0,a,0)},rotateYZ:function(a){return this.rotate(0,0,a)},setRotate:function(a,b,c){this.copy(this.rotate(a,b,c));return this},rotate:function(a, +b,c){var d=new CAAT.Math.Matrix3,e,f;a!==0&&(f=new CAAT.Math.Math.Matrix3,e=Math.sin(a),a=Math.cos(a),f.matrix[1][1]=a,f.matrix[1][2]=-e,f.matrix[2][1]=e,f.matrix[2][2]=a,d.multiply(f));b!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(b),a=Math.cos(b),f.matrix[0][0]=a,f.matrix[0][2]=-e,f.matrix[2][0]=e,f.matrix[2][2]=a,d.multiply(f));c!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(c),a=Math.cos(c),f.matrix[0][0]=a,f.matrix[0][1]=-e,f.matrix[1][0]=e,f.matrix[1][1]=a,d.multiply(f));return d},getClone:function(){var a= +new CAAT.Math.Matrix3;a.copy(this);return a},multiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1],q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],z=n[2][3],A=n[3][0],B=n[3][1],C=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*v+f*A;this.matrix[0][1]=c*p+d*t+e*x+f*B;this.matrix[0][2]=c*q+d*s+e*y+f*C;this.matrix[0][3]= +c*r+d*w+e*z+f*n;this.matrix[1][0]=g*a+h*u+i*v+j*A;this.matrix[1][1]=g*p+h*t+i*x+j*B;this.matrix[1][2]=g*q+h*s+i*y+j*C;this.matrix[1][3]=g*r+h*w+i*z+j*n;this.matrix[2][0]=k*a+m*u+o*v+b*A;this.matrix[2][1]=k*p+m*t+o*x+b*B;this.matrix[2][2]=k*q+m*s+o*y+b*C;this.matrix[2][3]=k*r+m*w+o*z+b*n;return this},premultiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1], +q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*v;this.matrix[0][1]=c*p+d*t+e*x;this.matrix[0][2]=c*q+d*s+e*y;this.matrix[0][3]=c*r+d*w+e*n+f;this.matrix[1][0]=g*a+h*u+i*v;this.matrix[1][1]=g*p+h*t+i*x;this.matrix[1][2]=g*q+h*s+i*y;this.matrix[1][3]=g*r+h*w+i*n+j;this.matrix[2][0]=k*a+m*u+o*v;this.matrix[2][1]=k*p+m*t+o*x;this.matrix[2][2]=k*q+m*s+o*y;this.matrix[2][3]=k*r+m*w+o*n+b;return this},setTranslate:function(a, +b,c){this.identity();this.matrix[0][3]=a;this.matrix[1][3]=b;this.matrix[2][3]=c;return this},translate:function(a,b,c){var d=new CAAT.Math.Matrix3;d.setTranslate(a,b,c);return d},setScale:function(a,b,c){this.identity();this.matrix[0][0]=a;this.matrix[1][1]=b;this.matrix[2][2]=c;return this},scale:function(a,b,c){var d=new CAAT.Math.Matrix3;d.setScale(a,b,c);return d},rotateModelView:function(a,b,c){var d=Math.sin(a),e=Math.sin(b),f=Math.sin(c),a=Math.cos(a),b=Math.cos(b),c=Math.cos(c);this.matrix[0][0]= +b*a;this.matrix[0][1]=-b*d;this.matrix[0][2]=e;this.matrix[0][3]=0;this.matrix[1][0]=f*e*a+d*c;this.matrix[1][1]=c*a-f*e*d;this.matrix[1][2]=-f*b;this.matrix[1][3]=0;this.matrix[2][0]=f*d-c*e*a;this.matrix[2][1]=c*e*d+f*a;this.matrix[2][2]=c*b;this.matrix[2][3]=0;this.matrix[3][0]=0;this.matrix[3][1]=0;this.matrix[3][2]=0;this.matrix[3][3]=1;return this},copy:function(a){for(var b=0;b<4;b++)for(var c=0;c<4;c++)this.matrix[b][c]=a.matrix[b][c];return this},calculateDeterminant:function(){var a=this.matrix, +b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],o=a[2][3],n=a[3][0],p=a[3][1],q=a[3][2],a=a[3][3];return e*g*m*n+c*i*m*n+e*h*j*p+d*i*j*p+d*f*o*p+b*h*o*p+e*f*k*q+b*i*k*q+d*g*j*a+c*h*j*a+c*f*m*a+b*g*m*a+e*h*k*n-d*i*k*n-d*g*o*n-c*h*o*n-e*f*m*p-b*i*m*p-e*g*j*q-c*i*j*q-c*f*o*q-b*g*o*q-d*f*k*a-b*h*k*a},getInverse:function(){var a=this.matrix,b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m= +a[2][2],o=a[2][3],n=a[3][0],p=a[3][1],q=a[3][2],a=a[3][3],r=new CAAT.Math.Matrix3;r.matrix[0][0]=h*o*p+i*k*q+g*m*a-i*m*p-g*o*q-h*k*a;r.matrix[0][1]=e*m*p+c*o*q+d*k*a-c*m*a-d*o*p-e*k*q;r.matrix[0][2]=d*i*p+c*h*a+e*g*q-c*i*q-d*g*a-e*h*p;r.matrix[0][3]=e*h*k+c*i*m+d*g*o-d*i*k-e*g*m-c*h*o;r.matrix[1][0]=i*m*n+f*o*q+h*j*a-h*o*n-i*j*q-f*m*a;r.matrix[1][1]=d*o*n+e*j*q+b*m*a-e*m*n-b*o*q-d*j*a;r.matrix[1][2]=e*h*n+b*i*q+d*f*a-d*i*n-e*f*q-b*h*a;r.matrix[1][3]=d*i*j+e*f*m+b*h*o-e*h*j-b*i*m-d*f*o;r.matrix[2][0]= +g*o*n+i*j*p+f*k*a-i*k*n-f*o*p-g*j*a;r.matrix[2][1]=e*k*n+b*o*p+c*j*a-b*k*a-c*o*n-e*j*p;r.matrix[2][2]=d*i*n+e*f*p+b*g*a-e*g*n-b*i*p-c*f*a;r.matrix[2][3]=e*g*j+b*i*k+c*f*o-b*g*o-c*i*j-e*f*k;r.matrix[3][0]=h*k*n+f*m*p+g*j*q-g*m*n-h*j*p-f*k*q;r.matrix[3][1]=c*m*n+d*j*p+b*k*q-d*k*n-b*m*p-c*j*q;r.matrix[3][2]=d*g*n+b*h*p+c*f*q-b*g*q-c*h*n-d*f*p;r.matrix[3][3]=c*h*j+d*f*k+b*g*m-d*g*j-b*h*k-c*f*m;return r.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;b<4;b++)for(c= +0;c<4;c++)this.matrix[b][c]*=a;return this}}}}); +CAAT.Module({defines:"CAAT.Math.Point",aliases:["CAAT.Point"],extendsWith:function(){return{x:0,y:0,z:0,__init:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},set:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},clone:function(){return new CAAT.Math.Point(this.x,this.y,this.z)},translate:function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this},translatePoint:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},subtract:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z; +return this},multiply:function(a){this.x*=a;this.y*=a;this.z*=a;return this},rotate:function(a){var b=this.x,c=this.y;this.x=b*Math.cos(a)-Math.sin(a)*c;this.y=b*Math.sin(a)+Math.cos(a)*c;this.z=0;return this},setAngle:function(a){var b=this.getLength();this.x=Math.cos(a)*b;this.y=Math.sin(a)*b;this.z=0;return this},setLength:function(a){var b=this.getLength();b?this.multiply(a/b):this.x=this.y=this.z=a;return this},normalize:function(){var a=this.getLength();this.x/=a;this.y/=a;this.z/=a;return this}, +getAngle:function(){return Math.atan2(this.y,this.x)},limit:function(a){var b=this.getLengthSquared();if(b+0.01>a*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b* +b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Math.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}}}); +CAAT.Module({defines:"CAAT.Math.Rectangle",aliases:["CAAT.Rectangle"],extendsWith:function(){return{__init:function(a,b,c,d){arguments.length!==4?this.setEmpty():(this.setLocation(a,b),this.setDimension(c,d))},x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b; +this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d);return this},contains:function(a,b){return a>=this.x&&a=this.y&&bthis.y1)this.y1= +b;if(a>this.x1)this.x1=a;this.width=this.x1-this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1,a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1<=this.x?false:a.x>=this.x1?false:a.y1<=this.y?false:a.ythis.x1?false:b+d-1=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!== +e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e=0,f=this.lifecycleListenerList.length;e>=0;for(var d= +"@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}}}}); +CAAT.Module({defines:"CAAT.Behavior.ContainerBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Behavior.GenericBehavior"],aliases:["CAAT.ContainerBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{parse:function(a){if(a.behaviors&&a.behaviors.length)for(var b=0;b=d)){d=(d-c.behaviorStartTime)/c.behaviorDuration; +c=c.getKeyFrameDataValues(d);for(var f in c)e[f]=c[f]}return e},calculateKeyFrameData:function(a,b){function c(a){if(f[a])h+=f[a];else if(prevValues&&(i=prevValues[a]))h+=i,f[a]=i}var d,e,f={},g;for(d=0;d=g&&(g=(g-e.behaviorStartTime)/e.behaviorDuration,g=e.calculateKeyFrameData(g), +e=e.getPropertyName(b),typeof f[e]==="undefined"&&(f[e]=""),f[e]+=g+" "));var h="",i;c("translate");c("rotate");c("scale");d="";h&&(d="-"+b+"-transform: "+h+";");h="";c("opacity");h&&(d+=" opacity: "+h+";");d+=" -webkit-transform-origin: 0% 0%";return{rules:d,ret:f}},calculateKeyFramesData:function(a,b,c,d,e){if(this.duration===Number.MAX_VALUE)return"";typeof d==="undefined"&&(d=0.5);typeof e==="undefined"&&(e=0.5);typeof c==="undefined"&&(c=100);for(var f="@-"+a+"-keyframes "+b+" {",g,h={},b=0;b<= +c;b++){g=this.interpolator.getPosition(b/c).y;g=this.getKeyFrameDataValues(g);var i=""+b/c*100+"%{",j=g,k=void 0;for(k in h)j[k]||(j[k]=h[k]);h="-"+a+"-transform:";if(j.x||j.y)h+="translate("+(j.x||0)+"px,"+(j.y||0)+"px)";j.angle&&(h+=" rotate("+j.angle+"rad)");if(j.scaleX!==1||j.scaleY!==1)h+=" scale("+j.scaleX+","+j.scaleY+")";h+=";";j.alpha&&(h+=" opacity: "+j.alpha+";");if(d!==0.5||e!==0.5)h+=" -"+a+"-transform-origin:"+d*100+"% "+e*100+"%;";f+=i+h+"}\n";h=g}f+="}\n";return f}}}}); +CAAT.Module({defines:"CAAT.Behavior.GenericBehavior",depends:["CAAT.Behavior.BaseBehavior"],aliases:["CAAT.GenericBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{start:0,end:0,target:null,property:null,callback:null,setForTime:function(a,b){var c=this.start+a*(this.end-this.start);this.callback&&this.callback(c,this.target,b);this.property&&(this.target[this.property]=c)},setValues:function(a,b,c,d,e){this.start=a;this.end=b;this.target=c;this.property=d;this.callback= +e;return this}}}}); +CAAT.Module({defines:"CAAT.Behavior.PathBehavior",aliases:["CAAT.PathBehavior"],depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.SpriteImage"],constants:{AUTOROTATE:{LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2},autorotate:{LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{parse:function(a){CAAT.Behavior.PathBehavior.superclass.parse.call(this,a);a.SVG&&this.setValues((new CAAT.PathUtil.SVGPath).parsePath(a.SVG));if(a.autoRotate)this.autoRotate=a.autoRotate}, +path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,isOpenContour:false,relativeX:0,relativeY:0,setOpenContour:function(a){this.isOpenContour=a;return this},getPropertyName:function(){return"translate"},setRelativeValues:function(a,b){this.relativeX=a;this.relativeY=b;this.isRelative=true;return this},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(){return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+a.x+"px) translateY("+a.y+"px)"},getKeyFrameDataValues:function(a){var a=this.interpolator.getPosition(a).y,b=this.path.getPosition(a),c={x:b.x,y:b.y};if(this.autoRotate)a=a===0?b:this.path.getPosition(a-0.0010),b=Math.atan2(b.y-a.y,b.x-a.x),c.angle=b;return c},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d, +e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a,this.isOpenContour,0.0010);this.isRelative&&(c.x+=this.relativeX,c.y+=this.relativeY);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f= +Math.atan2(e,d),g=CAAT.Foundation.SpriteImage,h=CAAT.Behavior.PathBehavior.AUTOROTATE;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x, +c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}}}}); +CAAT.Module({defines:"CAAT.Behavior.RotateBehavior",extendsClass:"CAAT.Behavior.BaseBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.RotateBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},parse:function(a){CAAT.Behavior.RotateBehavior.superclass.parse.call(this,a);this.startAngle=a.start||0;this.endAngle=a.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX): +0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5},startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,rotationRelative:0,setRelativeValues:function(a){this.rotationRelative=a;this.isRelative=true;return this},getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);this.isRelative&&(c+=this.rotationRelative,c>=Math.PI&&(c-=2*Math.PI),c<-2*Math.PI&&(c+=2*Math.PI));this.doValueApplication&&b.setRotationAnchored(c, +this.anchorX,this.anchorY);return c},setValues:function(a,b,c,d){this.startAngle=a;this.endAngle=b;if(typeof c!=="undefined"&&typeof d!=="undefined")this.anchorX=c,this.anchorY=d;return this},setAngles:function(a,b){return this.setValues(a,b)},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"rotate("+(this.startAngle+a*(this.endAngle-this.startAngle))+"rad)"},getKeyFrameDataValues:function(a){a= +this.interpolator.getPosition(a).y;return{angle:this.startAngle+a*(this.endAngle-this.startAngle)}},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX*100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Behavior.Scale1Behavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.Scale1Behavior"],constants:{AXIS:{X:0,Y:1},Axis:{X:0,Y:1}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startScale:1,endScale:1,anchorX:0.5,anchorY:0.5,applyOnX:true,parse:function(a){CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,a);this.startScale= +a.start||0;this.endScale=a.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX):0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5;this.applyOnX=a.axis?a.axis.toLowerCase()==="x":true},applyOnAxis:function(a){this.applyOnX=a===CAAT.Behavior.Scale1Behavior.AXIS.X?false:true},getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScale+a*(this.endScale-this.startScale);0===c&&(c=0.01);this.doValueApplication&&(this.applyOnX?b.setScaleAnchored(c, +b.scaleY,this.anchorX,this.anchorY):b.setScaleAnchored(b.scaleX,c,this.anchorX,this.anchorY));return c},setValues:function(a,b,c,d,e){this.startScale=a;this.endScale=b;this.applyOnX=!!c;if(typeof d!=="undefined"&&typeof e!=="undefined")this.anchorX=d,this.anchorY=e;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.startScale+a*(this.endScale-this.startScale);return this.applyOnX? +"scaleX("+a+")":"scaleY("+a+")"},getKeyFrameDataValues:function(a){var a=this.interpolator.getPosition(a).y,b={};b[this.applyOnX?"scaleX":"scaleY"]=this.startScale+a*(this.endScale-this.startScale);return b},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX*100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Behavior.ScaleBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],extendsClass:"CAAT.Behavior.BaseBehavior",aliases:["CAAT.ScaleBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startScaleX:1,endScaleX:1,startScaleY:1,endScaleY:1,anchorX:0.5,anchorY:0.5,parse:function(a){CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,a);this.startScaleX=a.scaleX&&a.scaleX.start|| +0;this.endScaleX=a.scaleX&&a.scaleX.end||0;this.startScaleY=a.scaleY&&a.scaleY.start||0;this.endScaleY=a.scaleY&&a.scaleY.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX):0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5},getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScaleX+a*(this.endScaleX-this.startScaleX),d=this.startScaleY+a*(this.endScaleY-this.startScaleY);0===c&&(c=0.01);0===d&&(d=0.01);this.doValueApplication&& +b.setScaleAnchored(c,d,this.anchorX,this.anchorY);return{scaleX:c,scaleY:d}},setValues:function(a,b,c,d,e,f){this.startScaleX=a;this.endScaleX=b;this.startScaleY=c;this.endScaleY=d;if(typeof e!=="undefined"&&typeof f!=="undefined")this.anchorX=e,this.anchorY=f;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"scale("+(this.startScaleX+a*(this.endScaleX-this.startScaleX))+ +","+(this.startScaleY+a*(this.endScaleY-this.startScaleY))+")"},getKeyFrameDataValues:function(a){a=this.interpolator.getPosition(a).y;return{scaleX:this.startScaleX+a*(this.endScaleX-this.startScaleX),scaleY:this.startScaleY+a*(this.endScaleY-this.startScaleY)}},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX* +100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Module.Runtime.BrowserInfo",constants:function(){function a(a){for(var b=0;b0?(a=this.channels.shift(),a.src=b.src,a.volume=b.volume,a.play(),this.workingChannels.push(a)):console.log("Can't play audio: "+a);return b},cancelPlay:function(a){for(var b=0;this.workingChannels.length;b++){var c=this.workingChannels[b];c.caat_id===a&&(c.pause(),this.channels.push(c),this.workingChannels.splice(b,1))}return this},cancelPlayByChannel:function(a){for(var b=0;this.workingChannels.length;b++)if(this.workingChannels[b]=== +a){this.channels.push(a);this.workingChannels.splice(b,1);break}return this},loop:function(a){if(!this.musicEnabled)return null;a=this.getAudio(a);if(null!==a){var b=document.createElement("audio");if(null!==b)return b.src=a.src,b.preload="auto",this.isFirefox?b.addEventListener("ended",function(a){a.target.currentTime=0},false):b.loop=true,b.load(),b.play(),this.loopingChannels.push(b),b}return null},endSound:function(){var a;for(a=0;a=g)return{r:d,g:e,b:f};a=a+(d-a)/g*h>>0;b=b+(e-b)/g*h>>0;c=c+(f-c)/g*h>>0;a>255?a=255:a<0&&(a=0);b>255?b=255:b<0&&(b=0);c>255?c=255:c<0&&(c=0);return{r:a,g:b,b:c}},makeRGBColorRamp:function(a,b,c){var d= +[],e=a.length-1;b/=e;var f,g,h,i,j,k,m,o,n,p,q,r,u,t;for(f=0;f>24&255;n=(m&16711680)>>16;p=(m&65280)>>8;m&=255;g=a[f+1];q=g>>24&255;r=(g&16711680)>>16;u=(g&65280)>>8;g&=255;q=(q-o)/b;r=(r-n)/b;u=(u-p)/b;t=(g-m)/b;for(g=0;g>0;i=n+r*g>>0;j=p+u*g>>0;k=m+t*g>>0;var s=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case s.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+k+")");break;case s.RAMP_RGB:d.push("rgb("+i+","+j+","+k+")");break;case s.RAMP_CHANNEL_RGB:d.push(4278190080| +i<<16|j<<8|k);break;case s.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|k);break;case s.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,k,h]);break;case s.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,k])}}}return d},random:function(){for(var a="#",b=0;b<3;b++)a+="0123456789abcdef"[Math.random()*16>>0];return a}},extendsWith:{__init:function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this},r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}}); +CAAT.Module({defines:"CAAT.Module.Debug.Debug",depends:["CAAT.Event.AnimationLoop"],extendsWith:{width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,textDiscardDR:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'
CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0 Discard DR: 0
Sound
Music
AA Bounding Boxes
Bounding Boxes
Dirty Rects
', +setScale:function(a){this.scale=a;return this},initialize:function(a,b){this.width=a=window.innerWidth;this.height=b;this.framerate={refreshInterval:CAAT.FPS_REFRESH||500,frames:0,timeLastRefresh:0,fps:0,prevFps:-1,fpsMin:1E3,fpsMax:0};if(!document.getElementById("caat-debug")){var c=document.createElement("div");c.innerHTML=this.debugTpl;document.body.appendChild(c);eval(' var __x= CAAT; function initCheck( name, bool, callback ) { var elem= document.getElementById(name); if ( elem ) { elem.className= (bool) ? "checkbox_enabled" : "checkbox_disabled"; if ( callback ) { elem.addEventListener( "click", (function(elem, callback) { return function(e) { elem.__value= !elem.__value; elem.className= (elem.__value) ? "checkbox_enabled" : "checkbox_disabled"; callback(e,elem.__value); } })(elem, callback), false ); } elem.__value= bool; } } function setupTabs() { var numTabs=0; var elem; var elemContent; do { elem= document.getElementById("caat-debug-tab"+numTabs); if ( elem ) { elemContent= document.getElementById("caat-debug-tab"+numTabs+"-content"); if ( elemContent ) { elemContent.style.display= numTabs===0 ? \'block\' : \'none\'; elem.className= numTabs===0 ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; elem.addEventListener( "click", (function(tabIndex) { return function(e) { for( var i=0; ithis.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps= +this.framerate.frames*1E3/(a-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this.framerate.fpsMin;this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps);this.textFPS.innerHTML=this.framerate.fps;var b=(this.frameTimeAcc*100/this.framerate.frames|0)/100;this.frameTimeAcc=0;this.textDrawTime.innerHTML=b;b=(this.frameRAFAcc*100/this.framerate.frames|0)/100;this.frameRAFAcc=0;this.textRAFTime.innerHTML= +b;this.framerate.timeLastRefresh=a;this.framerate.frames=0;this.paint(b)}this.textEntitiesTotal.innerHTML=this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws;this.textDiscardDR.innerHTML=this.statistics.size_discarded_by_dirty_rects},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle= +"black";b.beginPath();b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle= +"#0ff";b.beginPath();b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}}); +CAAT.Module({defines:"CAAT.Module.Font.Font",aliases:"CAAT.Font",depends:["CAAT.Foundation.SpriteImage"],constants:{getFontMetrics:function(a){var b;if(CAAT.CSS_TEXT_METRICS)try{return b=CAAT.Module.Font.Font.getFontMetricsCSS(a)}catch(c){}return CAAT.Module.Font.Font.getFontMetricsNoCSS(a)},getFontMetricsNoCSS:function(a){var a=/(\d+)p[x|t]\s*/i.exec(a),b;b=a?a[1]|0:32;a=b-1;b=b+b*0.2|0;return{height:b,ascent:a,descent:b-a}},getFontMetricsCSS:function(a){function b(a){var b,c,d;d=a&&a.ownerDocument; +b=d.documentElement;a=a.getBoundingClientRect();c=document.body;d=d.nodeType===9?d.defaultView||d.parentWindow:false;return{top:a.top+(d.pageYOffset||b.scrollTop)-(b.clientTop||c.clientTop||0),left:a.left+(d.pageXOffset||b.scrollLeft)-(b.clientLeft||c.clientLeft||0)}}try{var c=document.createElement("span");c.style.font=a;c.innerHTML="Hg";var d=document.createElement("div");d.style.display="inline-block";d.style.width="1px";d.style.heigh="0px";var e=document.createElement("div");e.appendChild(c); +e.appendChild(d);var f=document.body;f.appendChild(e);try{return a={},d.style.verticalAlign="baseline",a.ascent=b(d).top-b(c).top,d.style.verticalAlign="bottom",a.height=b(d).top-b(c).top,a.ascent=Math.ceil(a.ascent),a.height=Math.ceil(a.height),a.descent=a.height-a.ascent,a}finally{f.removeChild(e)}}catch(g){return null}}},extendsWith:function(){return{fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,strokeSize:1,padding:0,image:null,charMap:null,height:0, +ascent:0,descent:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setStrokeSize:function(a){this.strokeSize=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle=a;return this},createDefault:function(a){for(var b="",c=32;c<128;c++)b+=String.fromCharCode(c);return this.create(b, +a)},create:function(a,b){b|=0;this.padding=b;var c=document.createElement("canvas"),d=c.getContext("2d");d.textBaseline="bottom";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;var e=0,f=[],g,h;for(g=0;g>0)+1)+2*b;f.push(i);e+=i}g=CAAT.Font.getFontMetrics(d.font);d=g.height;this.ascent=g.ascent;this.descent=g.descent;this.height=g.height;i=g.ascent;c.width=e;c.height=d;d=c.getContext("2d");d.textBaseline= +"alphabetic";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g0&&g.height>0&&b.drawImage(this.image,g.x,0,h,i,c,d,h,i),c+=h):(b.strokeStyle="#f00",b.strokeRect(c,d,10,i),c+=10)},save:function(){var a=this.image.toDataURL("image/png");document.location.href=a.replace("image/png","image/octet-stream")},drawSpriteText:function(a,b){this.spriteImage.drawSpriteText(a,b)}}}}); +CAAT.Module({defines:"CAAT.Module.CircleManager.PackedCircle",depends:["CAAT.Module.CircleManager.PackedCircle","CAAT.Math.Point"],constants:{BOUNDS_RULE_WRAP:1,BOUNDS_RULE_CONSTRAINT:2,BOUNDS_RULE_DESTROY:4,BOUNDS_RULE_IGNORE:8},extendsWith:{__init:function(){this.boundsRule=CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE;this.position=new CAAT.Math.Point(0,0,0);this.offset=new CAAT.Math.Point(0,0,0);this.targetPosition=new CAAT.Math.Point(0,0,0);return this},id:0,delegate:null,position:null, +offset:null,targetPosition:null,targetChaseSpeed:0.02,isFixed:false,boundsRule:0,collisionMask:0,collisionGroup:0,containsPoint:function(a){return this.position.getDistanceSquared(a)this.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-ethis.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-ed?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}}); +CAAT.Module({defines:"CAAT.Module.Preloader.Preloader",extendsWith:function(){var a=function(a,c,d){this.id=a;this.path=c;this.image=new Image;this.loader=d;this.image.onload=this.onload.bind(this);this.image.onerror=this.onerror.bind(this);return this};a.prototype={id:null,path:null,image:null,loader:null,onload:function(){this.loader.__onload(this);this.image.onload=null;this.image.onerror=null},onerror:function(){this.loader.__onerror(this)},load:function(){this.image.src=this.path},clear:function(){this.loader= +null}};return{__init:function(){this.elements=[];this.baseURL="";return this},currentGroup:null,elements:null,imageCounter:0,cfinished:null,cloaded:null,cerrored:null,loadedCount:0,baseURL:null,addElement:function(b,c){this.elements.push(new a(b,this.baseURL+c,this));return this},clear:function(){for(var a=0;a>=0;var d=true,e=true,f=true,g=true;if(typeof c!== +"undefined"){if(typeof c.top!=="undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,o=c.width-1,n=false;if(d){for(d=0;db){n=true;break}if(n)break}a=d}if(e){n=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){n=true;break}if(n)break}k=d}if(f){n=false;for(j=0;jb){n=true;break}if(n)break}m=j}if(g){n=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){n=true;break}if(n)break}o=j}if(0===m&&0===a&&c.width-1===o&&c.height-1===k)return c;b=o-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height= +e;h=c.getContext("2d");h.putImageData(f,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}}); +CAAT.Module({defines:"CAAT.Module.Collision.QuadTree",depends:["CAAT.Math.Rectangle"],extendsClass:"CAAT.Math.Rectangle",extendsWith:function(){return{bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]= +(new CAAT.Module.Collision.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,i,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ +a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; +for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;bb&&(g=b),setTimeout(function(){j(a,e,c)},g)):j(a,e,c)}};return g}function j(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(true);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,false,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, +0.4))}var c=document.getElementById(c),k;if(CAAT.__CSS__)c&&false===c instanceof HTMLDivElement&&(c=null),c===null&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var m=document.createElement("canvas");c.appendChild(m);c=m}else false==c instanceof HTMLCanvasElement&&(m=document.createElement("canvas"),document.body.appendChild(m),c=m);else c=document.createElement("canvas"),document.body.appendChild(c);k=(new CAAT.Foundation.Director).initialize(a|| +800,b||600,c);a=[];g&&a.push({id:"splash",url:g});h&&a.push({id:"spinner",url:h});k.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){k.setImagesCache(b);var c=i(k,d||5E3,f);CAAT.loop(60);e&&e.length>0?(new CAAT.Module.Preloader.ImagePreloader).loadImages(e,c.loadedImage):c.loadedImage(0,null)}})}}}); +CAAT.Module({defines:"CAAT.PathUtil.PathSegment",depends:["CAAT.Math.Rectangle","CAAT.Math.Point","CAAT.Math.Matrix","CAAT.Math.Curve"],extendsWith:function(){return{__init:function(){this.bbox=new CAAT.Math.Rectangle;return this},color:"#000",length:0,bbox:null,parent:null,setParent:function(a){this.parent=a;return this},setColor:function(a){if(a)this.color=a;return this},endCurvePosition:function(){},startCurvePosition:function(){},setPoints:function(){},setPoint:function(){},getPosition:function(){}, +getLength:function(){return this.length},getBoundingBox:function(){return this.bbox},numControlPoints:function(){},getControlPoint:function(){},endPath:function(){},getContour:function(){},updatePath:function(){},applyAsPath:function(){},transform:function(){},drawHandle:function(a,b,c){a.beginPath();a.arc(b,c,CAAT.Math.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false);a.fill()}}}}); +CAAT.Module({defines:"CAAT.PathUtil.ArcPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.ArcPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point;return this},points:null,cw:true,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:false,setRadius:function(a){this.radius= +a;return this},isArcTo:function(){return this.arcTo},setArcTo:function(a){this.arcTo=a;return this},initialize:function(a,b,c,d){this.setInitialPosition(a,b);this.setFinalPosition(a+c,b);this.angle=d||2*Math.PI;return this},applyAsPath:function(a){a=a.ctx;this.arcTo?a.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):a.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.angle+this.startAngle,this.cw);return this},setPoint:function(a,b){b>=0&& +b1||a<0)a%=1;a<0&&(a=1+a);-1===this.length?this.newPosition.set(this.points[0].x,this.points[0].y):(a=this.angle*a*(this.cw?1:-1)+this.startAngle,this.newPosition.set(this.points[0].x+this.radius*Math.cos(a),this.points[0].y+this.radius*Math.sin(a)));return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save(); +c.strokeStyle=this.color;c.beginPath();this.arcTo?c.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):c.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.startAngle+this.angle,this.cw);c.stroke();if(b){c.globalAlpha=0.5;c.fillStyle="#7f7f00";for(var d=0;d1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition, +a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x},finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]}, +endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/a,y:this.getPosition(c/a).y});return b}}}}); +CAAT.Module({defines:"CAAT.PathUtil.LinearPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point"],aliases:["CAAT.LinearPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point(0,0,0);return this},points:null,newPosition:null,applyAsPath:function(a){a.ctx.lineTo(this.points[1].x,this.points[1].y)},setPoint:function(a, +b){b===0?this.points[0]=a:b===1&&(this.points[1]=a)},updatePath:function(){var a=this.points[1].x-this.points[0].x,b=this.points[1].y-this.points[0].y;this.length=Math.sqrt(a*a+b*b);this.bbox.setEmpty();this.bbox.union(this.points[0].x,this.points[0].y);this.bbox.union(this.points[1].x,this.points[1].y);return this},setPoints:function(a){this.points[0]=a[0];this.points[1]=a[1];this.updatePath();return this},setInitialPosition:function(a,b){this.points[0].x=a;this.points[0].y=b;this.newPosition.set(a, +b);return this},setFinalPosition:function(a,b){this.points[1].x=a;this.points[1].y=b;return this},endCurvePosition:function(){return this.points[1]},startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x}, +finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0]; +else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); +CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; +return this},points:null,cw:true,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x, +this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1; +a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c,b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;f=1||a<=0)){var c,d,e;a>=1?(c=this.__getPositionImpl(0.999),d=this.endCurvePosition(),e=Math.atan2(d.y-c.y,d.x-c.x),c=a%1):(c=this.__getPositionImpl(0.0010),d=this.startCurvePosition(),e=Math.atan2(d.y-c.y,d.x-c.x),c=-a);var f=this.newPosition,g=this.getLength(); +f.x=d.x+c*g*Math.cos(e);f.y=d.y+c*g*Math.sin(e);return f}return this.__getPositionImpl(a)},__getPositionImpl:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,i;e!==f;)if(g=(f+e)/2|0,i=c[g],i<=a&&a<=i+d[g])return a=d[g]?(a-i)/d[g]:0,a>1?a=1:a<0&&(a=0),a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;else a0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();b&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Math.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b="0"&&a<="9"},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(c=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)): +this.callback_tick&&this.callback_tick(a,b,this);return this},remainingTime:function(){return this.duration-(this.scene.time-this.startTime)},reset:function(a){this.remove=false;this.startTime=a;this.owner.ensureTimerTask(this);return this},cancel:function(){this.remove=true;null!=this.callback_cancel&&this.callback_cancel(this.scene.time,this.scene.time-this.startTime,this);return this},addTime:function(a){this.duration+=a;return this}}}); +CAAT.Module({defines:"CAAT.Foundation.Timer.TimerManager",aliases:["CAAT.TimerManager"],depends:["CAAT.Foundation.Timer.TimerTask"],extendsWith:{__init:function(){this.timerList=[];return this},timerList:null,timerSequence:0,checkTimers:function(a){for(var b=this.timerList,c=b.length-1;c>=0;)b[c].remove||b[c].checkTask(a),c--},ensureTimerTask:function(a){this.hasTimer(a)||this.timerList.push(a);return this},hasTimer:function(a){for(var b=this.timerList,c=b.length-1;c>=0;){if(b[c]===a)return true; +c--}return false},createTimer:function(a,b,c,d,e,f){a=(new CAAT.Foundation.Timer.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=f.time;a.owner=this;a.scene=f;this.timerList.push(a);return a},removeExpiredTimers:function(){var a,b=this.timerList;for(a=0;a0&&(b+=this.hgap)}switch(this.halign){case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT:b=this.padding.left;break;case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT:b=a.width-b-this.padding.right;break;default:b=(a.width-b)/2}for(e=0,f=a.getNumChildren();e0&&(c+=this.vgap)}switch(this.valign){case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP:b=this.padding.top;break;case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM:b=a.height-c-this.padding.bottom;break;default:b=(a.height-c)/2}for(d=0,e=a.getNumChildren();d0?g=Math.floor((e+f-1)/f):f=Math.floor((e+g-1)/g);for(var c=(g-1)*this.hgap,d=a.width-(this.padding.left+this.padding.right),e=Math.floor((d-c)/g),h=(f-1)*this.vgap,i=a.height-(this.padding.top+this.padding.bottom),j=Math.floor((i-h)/f),h=Math.floor((i-(j*f+h))/2),i=0,k=this.padding.left+Math.floor((d-(e*g+c))/2);i0?c=Math.ceil((d+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g0?c=Math.ceil((d+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g>0)*e;var k=i+(d/h>>0)*f,m=g+e,o=k+f;g=(new CAAT.Foundation.SpriteImageHelper(g,k,m-g,o-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,o/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(f-=d);var g=(this.offsetY-this.ownerActor.y)%e;g>0&&(g-=e);for(var d=((c.width-f)/d>>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx,a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a, +b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a, +b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex]; +a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a,b,c,d,e,f,g){a.drawImage(this.image,d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+ +d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return""+-(a.x+this.parentOffsetX-this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat": +"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]= +g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case b.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint= +this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1){if(this.prevAnimationTime===-1)this.prevAnimationTime= +a,this.spriteIndex=this.animationImageIndex[0],this.prevIndex=0;else{var b=a;b-=this.prevAnimationTime;b/=this.changeFPS;b%=this.animationImageIndex.length;b=Math.floor(b);b>0,f=0;fa&&(a=c)}this.fontHeight=a;return this.fontHeight*this.fontScale},drawText:function(a,b,c,d){var e,f,g;for(e=0;e0&&f.height>0&&b.drawImage(this.image,f.x,f.y,g,f.height,c+f.xoffset*this.fontScale,d+f.yoffset*this.fontScale,g*this.fontScale,f.height*this.fontScale),c+=f.xadvance*this.fontScale}, +getFontData:function(){var a=this.stringHeight()*0.8>>0;return{height:this.stringHeight(),ascent:a,descent:this.stringHeight()-a}}}}}); +CAAT.Module({defines:"CAAT.Foundation.Actor",aliases:["CAAT.Actor"],depends:"CAAT.Event.AnimationLoop,CAAT.Foundation.SpriteImage,CAAT.Core.Constants,CAAT.Behavior.PathBehavior,CAAT.Behavior.RotateBehavior,CAAT.Behavior.ScaleBehavior,CAAT.Behavior.Scale1Behavior,CAAT.PathUtil.LinearPath,CAAT.Event.AnimationLoop".split(","),constants:{ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8,ANCHOR_CUSTOM:9, +NO_CACHE:0,CACHE_SIMPLE:1,CACHE_DEEP:2},extendsWith:function(){return{__init:function(){this.behaviorList=[];this.styleCache={};this.lifecycleListenerList=[];this.scaleAnchor=this.ANCHOR_CENTER;this.behaviorList=[];this.domElement=document.createElement("div");this.domElement.style.position="absolute";this.domElement.style["-webkit-transform"]="translate3d(0,0,0)";this.domElement.style["-webkit-transition"]="all 0s linear";this.style("display","none");this.AABB=new CAAT.Rectangle;this.viewVertices= +[new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0),new CAAT.Point(0,0,0)];this.setVisible(true);this.resetTransform();this.setScale(1,1);this.setRotation(0);this.modelViewMatrix=new CAAT.Matrix;this.worldModelViewMatrix=new CAAT.Matrix;return this},lifecycleListenerList:null,behaviorList:null,x:0,y:0,width:0,height:0,preferredSize:null,minimumSize:null,start_time:0,duration:Number.MAX_VALUE,clip:false,tAnchorX:0,tAnchorY:0,scaleX:0,scaleY:0,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0, +rotationY:0.5,alpha:1,rotationX:0.5,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,domParent:null,domElement:null,visible:true,mouseEnabled:true,time:0,inFrame:false,backgroundImage:null,size_active:1,size_total:1,id:null,__d_ax:-1,__d_ay:-1,gestureEnabled:false,AABB:null,viewVertices:null,isAA:true,preventLayout:false,setPreventLayout:function(a){this.preventLayout=a;return this},invalidate:function(){this.invalid=true;return this},invalidateLayout:function(){this.parent&&!this.parent.layoutInvalidated&& +this.parent.invalidateLayout();return this},__validateLayout:function(){},setPreferredSize:function(a,b){if(!this.preferredSize)this.preferredSize=new CAAT.Dimension;this.preferredSize.width=a;this.preferredSize.height=b;return this},getPreferredSize:function(){return this.preferredSize?this.preferredSize:this.getMinimumSize()},setMinimumSize:function(a,b){if(!this.minimumSize)this.minimumSize=new CAAT.Dimension;this.minimumSize.width=a;this.minimumSize.height=b;return this},getMinimumSize:function(){return this.minimumSize? +this.minimumSize:new CAAT.Dimension(this.width,this.height)},isVisible:function(){return this.visible},create:function(){return this},moveTo:function(a,b,c,d,e){if(!(a===this.x&&b===this.y)){var f=this.getBehavior("__moveTo");f||(f=(new CAAT.PathBehavior).setId("__moveTo").setValues(new CAAT.LinearPath),this.addBehavior(f));f.path.setInitialPosition(this.x,this.y).setFinalPosition(a,b);f.setDelayTime(d?d:0,c);e&&f.setInterpolator(e);return this}},rotateTo:function(a,b,c,d,e,f){if(a!==this.rotationAngle){var g= +this.getBehavior("__rotateTo");g||(g=(new CAAT.RotateBehavior).setId("__rotateTo").setValues(0,0,0.5,0.5),this.addBehavior(g));g.setValues(this.rotationAngle,a,d,e).setDelayTime(c?c:0,b);f&&g.setInterpolator(f);return this}},scaleTo:function(a,b,c,d,e,f,g){if(!(this.scaleX===a&&this.scaleY===b)){var h=this.getBehavior("__scaleTo");h||(h=(new CAAT.ScaleBehavior).setId("__scaleTo").setValues(1,1,1,1,0.5,0.5),this.addBehavior(h));h.setValues(this.scaleX,a,this.scaleY,b,e,f).setDelayTime(d?d:0,c);g&& +h.setInterpolator(g);return this}},scaleXTo:function(a,b,c,d,e,f){return this.__scale1To(CAAT.Scale1Behavior.AXIS_X,a,b,c,d,e,f)},scaleYTo:function(a,b,c,d,e,f){return this.__scale1To(CAAT.Scale1Behavior.AXIS_Y,a,b,c,d,e,f)},__scale1To:function(a,b,c,d,e,f,g){if(!(a===CAAT.Scale1Behavior.AXIS_X&&b===this.scaleX||a===CAAT.Scale1Behavior.AXIS_Y&&b===this.scaleY)){var h=this.getBehavior("__scaleXTo");h||(h=(new CAAT.Scale1Behavior).setId("__scaleXTo").setValues(1,1,a===CAAT.Scale1Behavior.AXIS_X,0.5, +0.5),this.addBehavior(h));h.setValues(a?this.scaleX:this.scaleY,b,e,f).setDelayTime(d?d:0,c);g&&h.setInterpolator(g);return this}},touchStart:function(){},touchMove:function(){},touchEnd:function(){},gestureStart:function(){},gestureChange:function(a,b,c){this.gestureEnabled&&(this.setRotation(a),this.setScale(b,c));return this},gestureEnd:function(){},setScreenBounds:function(){var a=this.AABB,b=this.viewVertices;if(this.isAA)return b=this.worldModelViewMatrix.matrix,a.x=b[2],a.y=b[5],a.x1=b[2]+ +this.width,a.y1=b[5]+this.height,a.width=a.x1-a.x,a.height=a.y1-a.y,this;var c;c=b[0];c.x=0;c.y=0;c=b[1];c.x=this.width;c.y=0;c=b[2];c.x=this.width;c.y=this.height;c=b[3];c.x=0;c.y=this.height;this.modelToView(this.viewVertices);var d=Number.MAX_VALUE,e=-Number.MAX_VALUE,f=Number.MAX_VALUE,g=-Number.MAX_VALUE;c=b[0];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[1];if(c.xe)e=c.x;if(c.yg)g=c.y;c=b[2];if(c.xe)e=c.x;if(c.y +g)g=c.y;c=b[3];if(c.xe)e=c.x;if(c.yg)g=c.y;a.x=d;a.y=f;a.x1=e;a.y1=g;a.width=e-d;a.height=g-f;return this},setGestureEnabled:function(a){this.gestureEnabled=!!a;return this},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){if(this.parent)try{this.domParent.removeChild(this.domElement)}catch(b){}this.parent=a;null!=a?(this.parent.domElement.appendChild(this.domElement), +this.domParent=this.parent.domElement):this.domParent=null;this.dirty=true;return this},setBackgroundImage:function(a,b){if(a){if(a instanceof HTMLImageElement)a=(new CAAT.Foundation.SpriteImage).initialize(a,1,1);else if(a instanceof HTMLCanvasElement)a.src=a.toDataURL(),a=(new CAAT.Foundation.SpriteImage).initialize(a,1,1);else if(a instanceof CAAT.SpriteImage){if(a.image instanceof HTMLCanvasElement&&!a.image.src)a.image.src=a.image.toDataURL()}else if(isString(a))a=(new CAAT.Foundation.SpriteImage).initialize(CAAT.currentDirector.getImage(a), +1,1);else throw"Invalid image object to set actor's background";a.setOwner(this);this.backgroundImage=a;(typeof b==="undefined"||b)&&this.setSize(a.getWidth(),a.getHeight());this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())}else this.backgroundImage=null,this.style("background","none");return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.style("background","url("+this.backgroundImage.image.src+ +") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setBackgroundImageOffset:function(a,b){this.backgroundImage&&(this.backgroundImage.setOffset(a,b),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition()));return this},setAnimationImageIndex:function(a){this.backgroundImage&&(this.backgroundImage.setAnimationImageIndex(a),this.style("background","url("+this.backgroundImage.image.src+") "+this.backgroundImage.getCurrentSpriteImageCSSPosition())); +return this},addAnimation:function(a,b,c,d){this.backgroundImage&&this.backgroundImage.addAnimation(a,b,c,d);return this},playAnimation:function(a){this.backgroundImage&&this.backgroundImage.playAnimation(a);return this},setAnimationEndCallback:function(a){this.backgroundImage&&this.backgroundImage.setAnimationEndCallback(a)},setChangeFPS:function(a){this.backgroundImage&&this.backgroundImage.setChangeFPS(a);return this},setImageTransformation:function(a){this.transformation=a;a===CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE? +this.style("background-size","100%"):a===CAAT.Foundation.SpriteImage.TR_NONE&&this.style("background-size","auto");return this},centerOn:function(a,b){this.setLocation(a-this.width/2,b-this.height/2);return this},centerAt:function(a,b){return this.centerOn(a,b)},setVisible:function(a){this.visible=a;return this},style:function(a,b){b!==this.styleCache[a]&&(this.styleCache[a]=b,this.domElement.style[a]=b)},style3:function(){var a="";this.transformation===CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL&& +(a=" scale(-1,1) ");this.rotationAngle=Math.round(this.rotationAngle*100)/100;a="translate("+this.x+"px,"+this.y+"px) rotate("+this.rotationAngle+"rad) scale("+this.scaleX+","+this.scaleY+")"+a;if(a!==this.styleCache.transform)this.domElement.style["-ms-transform"]=a,this.domElement.style["-webkit-transform"]="translate3d(0,0,0) "+a,this.domElement.style.OTransform=a,this.domElement.style.MozTransform=a,this.domElement.style.transform=a,this.styleCache.transform=a;a=""+this.rotationX*100+"% "+this.rotationY* +100+"% ";if(a!==this.styleCache["transform-origin"])this.domElement.style["transform-origin"]=a,this.domElement.style["-webkit-transform-origin"]=a,this.domElement.style["-ms-transform-origin"]=a,this.domElement.style.OTransformOrigin=a,this.domElement.style.MozTransformOrigin=a,this.styleCache["transform-origin"]=a;return this},styleAlpha:function(){if(this.alpha!==this.styleCache.opacity)this.domElement.style.filter="alpha(opacity="+(this.alpha*100>>0)+")",this.domElement.style.Oopacity=this.alpha, +this.domElement.style.MozOpacity=this.alpha,this.domElement.style["-khtml-opacity"]=this.alpha,this.domElement.style.opacity=this.alpha,this.styleCache.opacity=this.alpha;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);this.style("display","none");return this},addListener:function(a){this.lifecycleListenerList.push(a)},removeListener:function(a){for(var b=this.lifecycleListenerList.length;b--;)if(this.lifecycleListenerList[b]===a){this.lifecycleListenerList.splice(b,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha= +a;return this},fireEvent:function(a,b){for(var c=0;c=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&b>=0&&a=this.childrenList.length)b=this.childrenList.length;a.setParent(this);this.childrenList.splice(b,0,a);this.domElement.insertBefore(a.domElement,this.domElement.childNodes[b]);this.invalidateLayout();a.dirty=true;return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c=0;b--){var c=this.childrenList[b],d=new CAAT.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},destroy:function(){for(var a=this.childrenList.length-1;a>=0;a--)this.childrenList[a].destroy();CAAT.ActorContainer.superclass.destroy.call(this); +return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},getChildAt:function(a){return this.childrenList[a]},setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c){if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}for(var c=0,e=d.length;c=0;)this.timerList[b].remove||this.timerList[b].checkTask(a),b--},ensureTimerTask:function(a){this.hasTimer(a)||this.timerList.push(a); +return this},hasTimer:function(a){for(var b=this.timerList.length-1;b>=0;){if(this.timerList[b]===a)return true;b--}return false},createTimer:function(a,b,c,d,e){a=(new CAAT.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=this.time;a.scene=this;this.timerList.push(a);return a},removeExpiredTimers:function(){var a;for(a=0;a4&&(c=4);switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:d?f.setPath((new CAAT.Path).setLinear(0, +-this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,-this.height));break;case CAAT.Foundation.Actor.ANCHOR_BOTTOM:d?f.setPath((new CAAT.Path).setLinear(0,this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,this.height));break;case CAAT.Foundation.Actor.ANCHOR_LEFT:d?f.setPath((new CAAT.Path).setLinear(-this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,-this.width,0));break;case CAAT.Foundation.Actor.ANCHOR_RIGHT:d?f.setPath((new CAAT.Path).setLinear(this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0, +0,this.width,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);a=f.path.startCurvePosition();this.setLocation(a.x,a.y);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn= +false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:case CAAT.Foundation.Actor.ANCHOR_CENTER:j=i=1;break;case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:j= +h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var k;k=g;g=i;i=k;k=h;h=j;j=k}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time,b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this}, +easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var f=0,g=0;if(c==CAAT.Foundation.Actor.ANCHOR_CENTER)c=CAAT.Foundation.Actor.ANCHOR_TOP;switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:f= +Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false===d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,d);b=this.getAnchorPercent(c);f=(new CAAT.Behavior.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f); +this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a},behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a;this.style("display",a?"none":"block")},paint:function(){},getIn:function(){}, +goOut:function(){}}}}); +CAAT.Module({defines:"CAAT.Foundation.Director",aliases:["CAAT.Director"],extendsClass:"CAAT.Foundation.ActorContainer",depends:"CAAT.Core.Class,CAAT.Core.Constants,CAAT.Foundation.ActorContainer,CAAT.Module.Audio.AudioManager,CAAT.Module.Runtime.BrowserInfo,CAAT.Module.Debug.Debug,CAAT.Math.Point,CAAT.Math.Rectangle,CAAT.Math.Matrix,CAAT.Foundation.Timer.TimerManager,CAAT.Foundation.Actor,CAAT.Foundation.Scene,CAAT.Event.AnimationLoop,CAAT.Event.Input,CAAT.Event.KeyEvent,CAAT.Event.MouseEvent,CAAT.Event.TouchEvent,CAAT.WebGL.Program,CAAT.WebGL.ColorProgram,CAAT.WebGL.TextureProgram,CAAT.WebGL.GLU,CAAT.Module.TexturePacker.TexturePageManager".split(","),constants:{RENDER_MODE_CONTINUOUS:1, +RENDER_MODE_DIRTY:2,CLEAR_DIRTY_RECTS:1,CLEAR_ALL:true,CLEAR_NONE:false,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16},extendsWith:function(){return{__init:function(){this.__super();this.browserInfo=CAAT.Module.Runtime.BrowserInfo;this.audioManager=(new CAAT.Module.Audio.AudioManager).initialize(8);this.scenes=[];this.imagesCache=[];this.mousePoint=new CAAT.Math.Point(0,0,0);this.prevMousePoint=new CAAT.Math.Point(0,0,0);this.screenMousePoint=new CAAT.Math.Point(0, +0,0);this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.sDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Math.Rectangle);this.dirtyRectsIndex=0;this.touches={};this.timerManager=new CAAT.Foundation.Timer.TimerManager;this.__map={};return this},debug:false,renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false, +lastSelectedActor:null,dragging:false,scenes:null,currentScene:null,canvas:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:CAAT.Foundation.Director.CLEAR_ALL,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null,glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,size_dirtyRects:0,draws:0,size_discarded_by_dirty_rects:0},currentTexturePage:0, +currentOpacity:1,intervalId:null,frameCounter:0,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,sDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,nDirtyRects:0,drDiscarded:0,stopped:false,needsRepaint:false,touches:null,timerManager:null,SCREEN_RATIO:1,__map:null,clean:function(){this.audioManager=this.imagesCache=this.currentScene=this.scenes=null;this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.__gestureRotation= +this.__gestureScale=0;this.dirty=true;this.cDirtyRects=this.dirtyRects=null;this.dirtyRectsIndex=0;this.dirtyRectsEnabled=false;this.nDirtyRects=0;this.onResizeCallback=null;this.__map={};return this},cancelPlay:function(a){return this.audioManager.cancelPlay(a)},cancelPlayByChannel:function(a){return this.audioManager.cancelPlayByChannel(a)},setAudioFormatExtensions:function(a){this.audioManager.setAudioFormatExtensions(a);return this},setValueForKey:function(a,b){this.__map[a]=b;return this},getValueForKey:function(a){return this.__map[a]}, +createTimer:function(a,b,c,d,e){return this.timerManager.createTimer(a,b,c,d,e,this)},requestRepaint:function(){this.needsRepaint=true},getCurrentScene:function(){return this.currentScene},checkDebug:function(){if(!navigator.isCocoonJS&&CAAT.DEBUG){var a=(new CAAT.Module.Debug.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){var c=CAAT.Foundation.Director;switch(this.resize){case c.RESIZE_WIDTH:this.setBounds(0, +0,a,this.height);break;case c.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case c.RESIZE_BOTH:this.setBounds(0,0,a,b);break;case c.RESIZE_PROPORTIONAL:this.setScaleProportional(a,b)}this.glEnabled&&this.glReset();if(this.onResizeCallback)this.onResizeCallback(this,a,b)},setScaleProportional:function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.ctx=this.canvas.getContext(this.glEnabled? +"experimental-webgl":"2d");this.__setupRetina();this.setScaleAnchored(c*this.scaleX,c*this.scaleY,0,0);this.glEnabled&&this.glReset()},enableResizeEvents:function(a,b){var c=CAAT.Foundation.Director;a===c.RESIZE_BOTH||a===c.RESIZE_WIDTH||a===c.RESIZE_HEIGHT||a===c.RESIZE_PROPORTIONAL?(this.referenceWidth=this.width,this.referenceHeight=this.height,this.resize=a,CAAT.registerResizeListener(this),this.onResizeCallback=b,this.windowResized(window.innerWidth,window.innerHeight)):(CAAT.unregisterResizeListener(this), +this.onResizeCallback=null);return this},__setupRetina:function(){if(CAAT.RETINA_DISPLAY_ENABLED){var a=CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio,b=this.ctx.webkitBackingStorePixelRatio||this.ctx.mozBackingStorePixelRatio||this.ctx.msBackingStorePixelRatio||this.ctx.oBackingStorePixelRatio||this.ctx.backingStorePixelRatio||1,c=a/b;a!==b?(a=this.canvas.width,b=this.canvas.height,this.canvas.width=a*c,this.canvas.height=b*c,this.canvas.style.width=a+"px",this.canvas.style.height=b+"px",this.setScaleAnchored(c, +c,0,0)):this.setScaleAnchored(1,1,0,0);this.SCREEN_RATIO=c}else this.setScaleAnchored(1,1,0,0);for(c=0;c=0;b--){var c=this.childrenList[b],d=new CAAT.Math.Point(a.x, +a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0;this.statistics.size_discarded_by_dirty_rects=0},render:function(a){if(!this.currentScene||!this.currentScene.isPaused()){this.time+=a;for(e=0,l=this.childrenList.length;e0&&!navigator.isCocoonJS&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;b=this.cDirtyRects;for(e=0;e=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Math.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height; +this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.setTransform(1,0,0,1,0,0);a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);var c=this.ctx;this.ctx=a;a.save();var d=this.modelViewMatrix,e=this.worldModelViewMatrix;this.modelViewMatrix=this.worldModelViewMatrix=new CAAT.Math.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time); +this.worldModelViewMatrix=e;this.modelViewMatrix=d;a.restore();this.ctx=c}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!CAAT.__CSS__&&CAAT.CACHE_SCENE_ON_CHANGE)this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene; +a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform();a.setLocation(0,0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Foundation.Scene.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Foundation.Scene.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Foundation.Scene.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Foundation.Scene.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList= +[];d.goOut(a);a.getIn(d);this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e<0.33?(e=CAAT.Foundation.Scene.EASE_ROTATION,g=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Foundation.Scene.EASE_SCALE,g=(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Foundation.Scene.EASE_TRANSLATE,g=(new CAAT.Behavior.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Foundation.Scene.EASE_ROTATION, +h=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Foundation.Scene.EASE_SCALE,h=(new CAAT.Behavior.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Foundation.Scene.EASE_TRANSLATE,h=(new CAAT.Behavior.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Foundation.Scene.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Foundation.Scene.EASE_SCALE? +a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)},setScene:function(a){a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.getIn();a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)}, +switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a, +b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b);this.needsRepaint=false}},resetTimeline:function(){this.timeline= +(new Date).getTime()},endLoop:function(){},setClear:function(a){this.clear=a;this.dirtyRectsEnabled=this.clear===CAAT.Foundation.Director.CLEAR_DIRTY_RECTS?true:false;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"): +null,/^(fixed)$/.test(g))break;else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset");return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=new CAAT.Math.Point,d=0,e=0;if(!b)b=window.event;if(b.pageX||b.pageY)d=b.pageX,e=b.pageY;else if(b.clientX||b.clientY)d=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft, +e=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var f=this.getOffset(this.canvas);d-=f.x;e-=f.y;d*=this.SCREEN_RATIO;e*=this.SCREEN_RATIO;c.x=d;c.y=e;if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(c);d=c.x;e=c.y;a.set(d,e);this.screenMousePoint.set(d,e)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown= +true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c=b.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.Event.MouseEvent).init(c.x,c.y,a,b,new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.Event.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.Event.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){if(b= +this.lastSelectedActor,c=b.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.dragging||!(Math.abs(this.prevMousePoint.x-c.x)=this.width||b.y>=this.height))this.touching=true,this.__mouseDownHandler(a)}},__touchEndHandler:function(a){if(this.touching)a.preventDefault(),a.returnValue=false,a=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=false,this.__mouseUpHandler(a)},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),a.returnValue=false,!this.gesturing))for(var b=0;b=this.width||f.y>=this.height)){var g=this.findActorAtPosition(f);g!==null&&(f=g.viewToModel(f),this.touches[e]||(this.touches[e]={actor:g,touch:new CAAT.Event.TouchInfo(e,f.x,f.y,g)},c.push(e)))}}e={};for(b=0;b=b.width||d.y>=b.height))b.touching=true,b.__mouseDownHandler(c)}},false);window.addEventListener("mouseover",function(c){if(c.target===a&&!b.dragging){c.preventDefault();c.cancelBubble=true;c.stopPropagation&&c.stopPropagation();var d=b.mousePoint; +b.getCanvasCoord(d,c);d.x<0||d.y<0||d.x>=b.width||d.y>=b.height||b.__mouseOverHandler(c)}},false);window.addEventListener("mouseout",function(c){if(c.target===a&&!b.dragging)c.preventDefault(),c.cancelBubble=true,c.stopPropagation&&c.stopPropagation(),b.getCanvasCoord(b.mousePoint,c),b.__mouseOutHandler(c)},false);window.addEventListener("mousemove",function(a){a.preventDefault();a.cancelBubble=true;a.stopPropagation&&a.stopPropagation();var d=b.mousePoint;b.getCanvasCoord(d,a);(b.dragging||!(d.x< +0||d.y<0||d.x>=b.width||d.y>=b.height))&&b.__mouseMoveHandler(a)},false);window.addEventListener("dblclick",function(c){if(c.target===a){c.preventDefault();c.cancelBubble=true;c.stopPropagation&&c.stopPropagation();var d=b.mousePoint;b.getCanvasCoord(d,c);d.x<0||d.y<0||d.x>=b.width||d.y>=b.height||b.__mouseDBLClickHandler(c)}},false);CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MOUSE?(a.addEventListener("touchstart",this.__touchStartHandler.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandler.bind(this), +false),a.addEventListener("touchend",this.__touchEndHandler.bind(this),false),a.addEventListener("gesturestart",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureStart(c.scale,c.rotation)},false),a.addEventListener("gestureend",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureEnd(c.scale,c.rotation)},false),a.addEventListener("gesturechange",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureChange(c.scale,c.rotation)}, +false)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this),false),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),false),a.addEventListener("touchcancel",this.__touchCancelHandleMT.bind(this),false),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),false),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this), +false),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),false))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=false;this.createEventHandler(a)},createEventHandler:function(a){this.in_=false;this.addHandlers(a)}}},onCreate:function(){if(typeof CAAT.__CSS__!=="undefined")CAAT.Foundation.Director.prototype.clip=true,CAAT.Foundation.Director.prototype.glEnabled=false,CAAT.Foundation.Director.prototype.getRenderType=function(){return"CSS"},CAAT.Foundation.Director.prototype.setScaleProportional= +function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.eventHandler.style.width=""+this.referenceWidth+"px";this.eventHandler.style.height=""+this.referenceHeight+"px"},CAAT.Foundation.Director.prototype.setBounds=function(a,b,c,d){CAAT.Foundation.Director.superclass.setBounds.call(this,a,b,c,d);for(a=0;ad+this.range?this.minSize:a===d?this.maxSize:a>0)+1)*b},setFillStyle:function(a){this.fill=a},setStrokeStyle:function(a){this.stroke= +a},setStrokeSize:function(a){this.strokeSize=a},setAlignment:function(a){this.alignment=a},setFontSize:function(a){if(a!==this.fontSize)this.fontSize=a,this.__setFont()}};var b=function(){this.text="";return this};b.prototype={x:0,y:0,width:0,text:null,crcs:null,rcs:null,styles:null,images:null,lines:null,documentHeight:0,anchorStack:null,__nextLine:function(){this.x=0;this.currentLine=new f(CAAT.Module.Font.Font.getFontMetrics(this.crcs.sfont));this.lines.push(this.currentLine)},__image:function(a, +b,c){var e;e=typeof b!=="undefined"&&typeof c!=="undefined"?a.getWidth():a instanceof CAAT.Foundation.SpriteImage?a.getWidth():a.getWrappedImageWidth();this.width&&e+this.x>this.width&&this.x>0&&this.__nextLine();this.currentLine.addElementImage(new d(this.x,a,b,c,this.crcs.clone(),this.__getCurrentAnchor()));this.x+=e},__text:function(){if(this.text.length!==0){var a=this.ctx.measureText(this.text).width;this.width&&a+this.x>this.width&&this.x>0&&this.__nextLine();this.currentLine.addElement(new e(this.text, +this.x,a,0,this.crcs.clone(),this.__getCurrentAnchor()));this.x+=a;this.text=""}},fchar:function(a){a===" "?(this.__text(),this.x+=this.ctx.measureText(a).width,this.width&&this.x>this.width&&this.__nextLine()):this.text+=a},end:function(){this.text.length>0&&this.__text();for(var a=0,b=0,c=0;c>0);this.lines[c].setY(a)}this.documentHeight=a+b},getDocumentHeight:function(){return this.documentHeight}, +__getCurrentAnchor:function(){return this.anchorStack.length?this.anchorStack[this.anchorStack.length-1]:null},__resetAppliedStyles:function(){this.rcs=[];this.__pushDefaultStyles()},__pushDefaultStyles:function(){this.crcs=(new a(this.ctx)).setDefault(this.styles["default"]);this.rcs.push(this.crcs)},__pushStyle:function(b){var c=this.crcs;this.crcs=new a(this.ctx);this.crcs.chain=c;this.crcs.setStyle(b);this.crcs.applyStyle();this.rcs.push(this.crcs)},__popStyle:function(){if(this.rcs.length>1)this.rcs.pop(), +this.crcs=this.rcs[this.rcs.length-1],this.crcs.applyStyle()},__popAnchor:function(){this.anchorStack.length>0&&this.anchorStack.pop()},__pushAnchor:function(a){this.anchorStack.push(a)},start:function(a,b,c,d){this.y=this.x=0;this.width=typeof d!=="undefined"?d:0;this.ctx=a;this.lines=[];this.styles=b;this.images=c;this.anchorStack=[];this.__resetAppliedStyles();this.__nextLine()},setTag:function(a){this.__text();a=a.toLowerCase();if(a==="b")this.crcs.setBold(true);else if(a==="/b")this.crcs.setBold(false); +else if(a==="i")this.crcs.setItalic(true);else if(a==="/i")this.crcs.setItalic(false);else if(a==="stroked")this.crcs.setStroked(true);else if(a==="/stroked")this.crcs.setStroked(false);else if(a==="filled")this.crcs.setFilled(true);else if(a==="/filled")this.crcs.setFilled(false);else if(a==="tab")this.x=this.crcs.getTabPos(this.x);else if(a==="br")this.__nextLine();else if(a==="/a")this.__popAnchor();else if(a==="/style")this.rcs.length>1&&this.__popStyle();else if(a.indexOf("fillcolor")===0)a= +a.split("="),this.crcs.setFillStyle(a[1]);else if(a.indexOf("strokecolor")===0)a=a.split("="),this.crcs.setStrokeStyle(a[1]);else if(a.indexOf("strokesize")===0)a=a.split("="),this.crcs.setStrokeSize(a[1]|0);else if(a.indexOf("fontsize")===0)a=a.split("="),this.crcs.setFontSize(a[1]|0);else if(a.indexOf("style")===0)a=a.split("="),(a=this.styles[a[1]])&&this.__pushStyle(a);else if(a.indexOf("image")===0){var a=a.split("=")[1].split(","),b=a[0];if(this.images[b]){var c=0,d=0;a.length>=3&&(c=a[1]|0, +d=a[2]|0);this.__image(this.images[b],c,d)}else CAAT.currentDirector.getImage(b)&&this.__image(CAAT.currentDirector.getImage(b))}else a.indexOf("a=")===0&&(a=a.split("="),this.__pushAnchor(a[1]))}};var c=function(a,b){this.link=a;this.style=b;return this};c.prototype={x:null,y:null,width:null,height:null,style:null,link:null,isLink:function(){return this.link},setLink:function(a){this.link=a;return this},getLink:function(){return this.link},contains:function(){return false}};var d=function(a,b,c, +e,f,m){d.superclass.constructor.call(this,m,f);this.x=a;this.image=b;this.row=c;this.column=e;this.width=b.getWidth();this.height=b.getHeight();if(this.image instanceof CAAT.SpriteImage||this.image instanceof CAAT.Foundation.SpriteImage)this.spriteIndex=typeof c==="undefined"||typeof e==="undefined"?0:c*b.columns+e,this.paint=this.paintSI;return this};d.prototype={image:null,row:null,column:null,spriteIndex:null,paint:function(a){this.style.image(a);a.drawImage(this.image,this.x,-this.height+1)}, +paintSI:function(a){this.style.image(a);this.image.setSpriteIndex(this.spriteIndex);this.image.paint({ctx:a},0,this.x,-this.height+1)},getHeight:function(){return this.image instanceof CAAT.Foundation.SpriteImage?this.image.getHeight():this.image.height},getFontMetrics:function(){return null},contains:function(a,b){return a>=this.x&&a<=this.x+this.width&&b>=this.y&&b=this.x&&a<=this.x+this.width&&b>=this.y&&b<=this.y+this.height},setYPosition:function(a){this.bl=a;this.y=a-this.fm.ascent}}; +extend(d,c);extend(e,c);var f=function(a){this.elements=[];this.defaultFontMetrics=a;return this};f.prototype={elements:null,width:0,height:0,defaultHeight:0,y:0,x:0,alignment:null,baselinePos:0,addElement:function(a){this.width=Math.max(this.width,a.x+a.width);this.height=Math.max(this.height,a.height);this.elements.push(a);this.alignment=a.style.__getProperty("alignment")},addElementImage:function(a){this.width=Math.max(this.width,a.x+a.width);this.height=Math.max(this.height,a.height);this.elements.push(a)}, +getHeight:function(){return this.height},setY:function(a){this.y=a},getY:function(){return this.y},paint:function(a){a.save();a.translate(this.x,this.y+this.baselinePos);for(var b=0;b=0.6&&this.elements.length>1){var c=a-this.width,c=c/(this.elements.length- +1)|0;for(b=1;ba.ascent&&(a=e):a=e:b?d.getHeight()>d.getHeight()&&(b=d):b=d}this.baselinePos=Math.max(a?a.ascent:this.defaultFontMetrics.ascent,b?b.getHeight():this.defaultFontMetrics.ascent);this.height= +this.baselinePos+(a!=null?a.descent:this.defaultFontMetrics.descent);for(c=0;c", +d+1),-1!==o&&(n=f.substr(d+1,o-d-1),n.indexOf("<")!==-1?(this.rc.fchar(p),d+=1):(this.rc.setTag(n),d=o+1))):(this.rc.fchar(p),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension(typeof b==="undefined"?0:b);this.setLinesAlignment();q.restore();this.setPreferredSize(this.documentWidth,this.documentHeight);this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);if(this.matchTextSize)this.width=this.preferredSize.width,this.height=this.preferredSize.height; +return this}},setVerticalAlignment:function(a){this.valignment=a;this.setDocumentPosition();return this},setHorizontalAlignment:function(a){this.halignment=a;this.setDocumentPosition();return this},setDocumentPosition:function(a,b){typeof a!=="undefined"&&this.setHorizontalAlignment(a);typeof b!=="undefined"&&this.setVerticalAlignment(b);var c=0,d=0;this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?d=(this.height-this.documentHeight)/2:this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM&& +(d=this.height-this.documentHeight);this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?c=(this.width-this.documentWidth)/2:this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT&&(c=this.width-this.documentWidth);this.documentX=c;this.documentY=d},__calculateDocumentDimension:function(a){var b,c=0;for(b=this.documentHeight=this.documentWidth=0;b=a&&d.y+d.height>=b)return d.__getElementAt(a-d.x,b-d.y)}return null},mouseExit:function(){CAAT.setCursor("default")},mouseMove:function(a){(a=this.__getDocumentElementAt(a.x,a.y))&&a.getLink()?CAAT.setCursor("pointer"):CAAT.setCursor("default")},mouseClick:function(a){this.clickCallback&&(a=this.__getDocumentElementAt(a.x,a.y),a.getLink()&& +this.clickCallback(a.getLink()))},setClickCallback:function(a){this.clickCallback=a;return this}}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.PathActor",aliases:["CAAT.PathActor"],depends:["CAAT.Foundation.Actor"],extendsClass:"CAAT.Foundation.Actor",extendsWith:{path:null,pathBoundingRectangle:null,bOutline:false,outlineColor:"black",onUpdateCallback:null,interactive:false,getPath:function(){return this.path},setPath:function(a){this.path=a;if(a!=null)this.pathBoundingRectangle=a.getBoundingBox(),this.setInteractive(this.interactive);return this},paint:function(a,b){CAAT.Foundation.UI.PathActor.superclass.paint.call(this, +a,b);if(this.path){var c=a.ctx;c.strokeStyle="#000";this.path.paint(a,this.interactive);if(this.bOutline)c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height)}},showBoundingBox:function(a,b){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= +a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= +a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= +a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ +2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, +this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.StarActor",aliases:["CAAT.StarActor"],depends:["CAAT.Foundation.ActorContainer"],extendsClass:"CAAT.Foundation.ActorContainer",extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";return this},nPeaks:0,maxRadius:0,minRadius:0,initialAngle:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap=a;return this},setLineJoin:function(a){this.lineJoin= +a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setFilled:function(){return this},setOutlined:function(){return this},setCompositeOp:function(a){this.compositeOp=a;return this},setInitialAngle:function(a){this.initialAngle=a;return this},initialize:function(a,b,c){this.setSize(2*b,2*b);this.nPeaks= +a;this.maxRadius=b;this.minRadius=c;return this},paint:function(a){var a=a.ctx,b=this.width/2,c=this.height/2,d=this.maxRadius,e=this.minRadius,f=b+d*Math.cos(this.initialAngle),g=c+d*Math.sin(this.initialAngle);a.lineWidth=this.lineWidth;if(this.lineCap)a.lineCap=this.lineCap;if(this.lineJoin)a.lineJoin=this.lineJoin;if(this.miterLimit)a.miterLimit=this.miterLimit;a.globalCompositeOperation=this.compositeOp;a.beginPath();a.moveTo(f,g);for(f=1;f>0,e.y>>0):c.translate(e.x,e.y);c.rotate(f);this.fill&&c.fillText(h,0,0);if(this.outline)c.beginPath(),c.lineWidth=this.lineWidth,c.strokeText(h,0,0);c.restore();d+=i}},drawSpriteText:function(a,b){null===this.path?this.font.drawText(this.text,a.ctx,0,0):this.drawSpriteTextOnPath(a,b)},drawSpriteTextOnPath:function(a,b){for(var c=a.ctx,d=this.sign*this.pathInterpolator.getPosition(b% +this.pathDuration/this.pathDuration).y*this.path.getLength(),e=new CAAT.Math.Point(0,0,0),f=new CAAT.Math.Point(0,0,0),g=0;g NOT solved.") + ); + }, + + removeDependency : function( modulename ) { + for( var i=0; i Can't extend non-existant class: "+this.baseClass ); + return; + } + + } else { + c= Class; + } + + c= c.extend( this.extendWith, this.constants, this.name, this.aliases, { decorated : this.decorated } ); + + console.log("Created module: "+this.name); + + if ( this.callback ) { + this.callback(); + } + + } + }; + + var ScriptFile= function(path, module) { + this.path= path; + this.module= module; + return this; + } + + ScriptFile.prototype= { + path : null, + processed: false, + module: null, + + setProcessed : function() { + this.processed= true; + }, + + isProcessed : function() { + return this.processed; + } + }; + + var ModuleManager= function() { + this.nodes= []; + this.loadedFiles= []; + this.path= {}; + this.solveListener= []; + this.orderedSolvedModules= []; + this.readyListener= []; + + return this; + }; + + ModuleManager.baseURL= ""; + ModuleManager.modulePath= {}; + ModuleManager.sortedModulePath= []; + ModuleManager.symbol= {}; + + ModuleManager.prototype= { + + nodes: null, // built nodes. + loadedFiles:null, // list of loaded files. avoid loading each file more than once + solveListener: null, // listener for a module solved + readyListener: null, // listener for all modules solved + orderedSolvedModules: null, // order in which modules where solved. + + addSolvedListener : function( modulename, callback ) { + this.solveListener.push( { + name : modulename, + callback : callback + }); + }, + + solved : function( module ) { + var i; + + for( i=0; i "+obj.defines+" onPrecreation"); + try { + obj.onPreCreate(); + } catch(e) { + console.log(" -> catched "+e+" on module "+obj.defines+" preCreation."); + } + } + + if (!obj.depends ) { + obj.depends= []; + } + + var dependencies= obj.depends; + + if ( dependencies ) { + if ( !isArray(dependencies) ) { + dependencies= [ dependencies ]; + obj.depends= dependencies; + } + } + + // elimina dependencias ya resueltas en otras cargas. + i=0; + while( i=}, // dependencies class names + * extendsClass{string}, // class to extend from + * extensdWith{object}, // actual prototype to extend + * aliases{Array} // other class names + * } + * + * @name Module + * @memberof CAAT + * @static + * + * @param obj {object} + */ + NS.Module= function loadModule(obj) { + + if (!obj.defines) { + console.error("Bad module definition: "+obj); + return; + } + + ensureNamespace(obj.defines); + + mm.module( obj ); + + }; + + /** + * @name ModuleManager + * @memberOf CAAT + * @namespace + */ + NS.ModuleManager= {}; + + /** + * Define global base position for modules structure. + * @param baseURL {string} + * @return {*} + */ + NS.ModuleManager.baseURL= function(baseURL) { + + if ( !baseURL ) { + return NS.Module; + } + + if (!baseURL.endsWith("/") ) { + baseURL= baseURL + "/"; + } + + ModuleManager.baseURL= baseURL; + return NS.ModuleManager; + }; + + /** + * Define a module path. Multiple module paths can be specified. + * @param module {string} + * @param path {string} + */ + NS.ModuleManager.setModulePath= function( module, path ) { + + if ( !path.endsWith("/") ) { + path= path + "/"; + } + + if ( !ModuleManager.modulePath[module] ) { + ModuleManager.modulePath[ module ]= path; + + ModuleManager.sortedModulePath.push( module ); + + /** + * Sort function so that CAAT.AB is below CAAT.AB.CD + */ + ModuleManager.sortedModulePath.sort( function(a,b) { + if (a==b) { + return 0; + } + return a + * @param p1 + * @param p2 + * @param p3 + */ + setCurve:function (p0, p1, p2, p3) { + + this.coordlist = []; + this.coordlist.push(p0); + this.coordlist.push(p1); + this.coordlist.push(p2); + this.coordlist.push(p3); + + this.update(); + + return this; + }, + /** + * Paint the contour by solving again the entire curve. + * @param director {CAAT.Director} + */ + paint:function (director) { + + var x1, y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; + + var ctx = director.ctx; + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x1, y1); + + var point = new CAAT.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + ctx.stroke(); + ctx.restore(); + + CAAT.Math.CatmullRom.superclass.paint.call(this, director); + }, + /** + * Solves the curve for any given parameter t. + * @param point {CAAT.Point} the point to store the solved value on the curve. + * @param t {number} a number in the range 0..1 + */ + solve:function (point, t) { + var c = this.coordlist; + + // Handy from CAKE. Thanks. + var af = ((-t + 2) * t - 1) * t * 0.5 + var bf = (((3 * t - 5) * t) * t + 2) * 0.5 + var cf = ((-3 * t + 4) * t + 1) * t * 0.5 + var df = ((t - 1) * t * t) * 0.5 + + point.x = c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y = c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; + + return point; + + }, + + applyAsPath:function (director) { + + var ctx = director.ctx; + + var point = new CAAT.Math.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + return this; + }, + + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 2 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 1 ]; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Curve + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Curve", + depends:["CAAT.Math.Point"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Math.Curve.prototype + */ + + /** + * A collection of CAAT.Math.Point objects. + */ + coordlist:null, + + /** + * Minimun solver step. + */ + k:0.05, + + /** + * Curve length. + */ + length:-1, + + /** + * If this segments belongs to an interactive path, the handlers will be this size. + */ + HANDLE_SIZE:20, + + /** + * Draw interactive handlers ? + */ + drawHandles:true, + + /** + * Paint the curve control points. + * @param director {CAAT.Director} + */ + paint:function (director) { + if (false === this.drawHandles) { + return; + } + + var cl = this.coordlist; + var ctx = director.ctx; + + // control points + ctx.save(); + ctx.beginPath(); + + ctx.strokeStyle = '#a0a0a0'; + ctx.moveTo(cl[0].x, cl[0].y); + ctx.lineTo(cl[1].x, cl[1].y); + ctx.stroke(); + if (this.cubic) { + ctx.moveTo(cl[2].x, cl[2].y); + ctx.lineTo(cl[3].x, cl[3].y); + ctx.stroke(); + } + + + ctx.globalAlpha = 0.5; + for (var i = 0; i < this.coordlist.length; i++) { + ctx.fillStyle = '#7f7f00'; + var w = this.HANDLE_SIZE / 2; + ctx.beginPath(); + ctx.arc(cl[i].x, cl[i].y, w, 0, 2 * Math.PI, false); + ctx.fill(); + } + + ctx.restore(); + }, + /** + * Signal the curve has been modified and recalculate curve length. + */ + update:function () { + this.calcLength(); + }, + /** + * This method must be overriden by subclasses. It is called whenever the curve must be solved for some time=t. + * The t parameter must be in the range 0..1 + * @param point {CAAT.Point} to store curve solution for t. + * @param t {number} + * @return {CAAT.Point} the point parameter. + */ + solve:function (point, t) { + }, + /** + * Get an array of points defining the curve contour. + * @param numSamples {number} number of segments to get. + */ + getContour:function (numSamples) { + var contour = [], i; + + for (i = 0; i <= numSamples; i++) { + var point = new CAAT.Math.Point(); + this.solve(point, i / numSamples); + contour.push(point); + } + + return contour; + }, + /** + * Calculates a curve bounding box. + * + * @param rectangle {CAAT.Rectangle} a rectangle to hold the bounding box. + * @return {CAAT.Rectangle} the rectangle parameter. + */ + getBoundingBox:function (rectangle) { + if (!rectangle) { + rectangle = new CAAT.Math.Rectangle(); + } + + // thanks yodesoft.com for spotting the first point is out of the BB + rectangle.setEmpty(); + rectangle.union(this.coordlist[0].x, this.coordlist[0].y); + + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + rectangle.union(pt.x, pt.y); + } + + return rectangle; + }, + /** + * Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k. This value defaults + * to .05 so at least 20 iterations will be performed. + * + * @return {number} the approximate curve length. + */ + calcLength:function () { + var x1, y1; + x1 = this.coordlist[0].x; + y1 = this.coordlist[0].y; + var llength = 0; + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + llength += Math.sqrt((pt.x - x1) * (pt.x - x1) + (pt.y - y1) * (pt.y - y1)); + x1 = pt.x; + y1 = pt.y; + } + + this.length = llength; + return llength; + }, + /** + * Return the cached curve length. + * @return {number} the cached curve length. + */ + getLength:function () { + return this.length; + }, + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 1 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 0 ]; + }, + + setPoints:function (points) { + }, + + setPoint:function (point, index) { + if (index >= 0 && index < this.coordlist.length) { + this.coordlist[index] = point; + } + }, + /** + * + * @param director <=CAAT.Director> + */ + applyAsPath:function (director) { + } + } + } + +}); + +CAAT.Module({ + + /** + * @name Dimension + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Dimension", + aliases:["CAAT.Dimension"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Dimension.prototype + */ + + /** + * Width dimension. + */ + width:0, + + /** + * Height dimension. + */ + height:0, + + __init:function (w, h) { + this.width = w; + this.height = h; + return this; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + + +CAAT.Module({ + + /** + * @name Matrix + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Matrix", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Matrix"], + onCreate : function() { + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Math.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Math.Matrix.prototype.transformRenderingContextSet_NoClamp; + }, + constants : { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + setCoordinateClamping : function( clamp ) { + if ( clamp ) { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + } else { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + } + }, + /** + * Create a scale matrix. + * @param scalex {number} x scale magnitude. + * @param scaley {number} y scale magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + scale:function (scalex, scaley) { + var m = new CAAT.Math.Matrix(); + + m.matrix[0] = scalex; + m.matrix[4] = scaley; + + return m; + }, + /** + * Create a new rotation matrix and set it up for the specified angle in radians. + * @param angle {number} + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + rotate:function (angle) { + var m = new CAAT.Math.Matrix(); + m.setRotation(angle); + return m; + }, + /** + * Create a translation matrix. + * @param x {number} x translation magnitude. + * @param y {number} y translation magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * @static + * + */ + translate:function (x, y) { + var m = new CAAT.Math.Matrix(); + + m.matrix[2] = x; + m.matrix[5] = y; + + return m; + } + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + /** + * An array of 9 numbers. + */ + matrix:null, + + __init:function () { + this.matrix = [ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 ]; + + if (typeof Float32Array !== "undefined") { + this.matrix = new Float32Array(this.matrix); + } + + return this; + }, + + /** + * Transform a point by this matrix. The parameter point will be modified with the transformation values. + * @param point {CAAT.Point}. + * @return {CAAT.Point} the parameter point. + */ + transformCoord:function (point) { + var x = point.x; + var y = point.y; + + var tm = this.matrix; + + point.x = x * tm[0] + y * tm[1] + tm[2]; + point.y = x * tm[3] + y * tm[4] + tm[5]; + + return point; + }, + + setRotation:function (angle) { + + this.identity(); + + var tm = this.matrix; + var c = Math.cos(angle); + var s = Math.sin(angle); + tm[0] = c; + tm[1] = -s; + tm[3] = s; + tm[4] = c; + + return this; + }, + + setScale:function (scalex, scaley) { + this.identity(); + + this.matrix[0] = scalex; + this.matrix[4] = scaley; + + return this; + }, + + /** + * Sets this matrix as a translation matrix. + * @param x + * @param y + */ + setTranslate:function (x, y) { + this.identity(); + + this.matrix[2] = x; + this.matrix[5] = y; + + return this; + }, + /** + * Copy into this matrix the given matrix values. + * @param matrix {CAAT.Matrix} + * @return this + */ + copy:function (matrix) { + matrix = matrix.matrix; + + var tmatrix = this.matrix; + tmatrix[0] = matrix[0]; + tmatrix[1] = matrix[1]; + tmatrix[2] = matrix[2]; + tmatrix[3] = matrix[3]; + tmatrix[4] = matrix[4]; + tmatrix[5] = matrix[5]; + tmatrix[6] = matrix[6]; + tmatrix[7] = matrix[7]; + tmatrix[8] = matrix[8]; + + return this; + }, + /** + * Set this matrix to the identity matrix. + * @return this + */ + identity:function () { + + var m = this.matrix; + m[0] = 1.0; + m[1] = 0.0; + m[2] = 0.0; + + m[3] = 0.0; + m[4] = 1.0; + m[5] = 0.0; + + m[6] = 0.0; + m[7] = 0.0; + m[8] = 1.0; + + return this; + }, + /** + * Multiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + multiply:function (m) { + + var tm = this.matrix; + var mm = m.matrix; + + var tm0 = tm[0]; + var tm1 = tm[1]; + var tm2 = tm[2]; + var tm3 = tm[3]; + var tm4 = tm[4]; + var tm5 = tm[5]; + var tm6 = tm[6]; + var tm7 = tm[7]; + var tm8 = tm[8]; + + var mm0 = mm[0]; + var mm1 = mm[1]; + var mm2 = mm[2]; + var mm3 = mm[3]; + var mm4 = mm[4]; + var mm5 = mm[5]; + var mm6 = mm[6]; + var mm7 = mm[7]; + var mm8 = mm[8]; + + tm[0] = tm0 * mm0 + tm1 * mm3 + tm2 * mm6; + tm[1] = tm0 * mm1 + tm1 * mm4 + tm2 * mm7; + tm[2] = tm0 * mm2 + tm1 * mm5 + tm2 * mm8; + tm[3] = tm3 * mm0 + tm4 * mm3 + tm5 * mm6; + tm[4] = tm3 * mm1 + tm4 * mm4 + tm5 * mm7; + tm[5] = tm3 * mm2 + tm4 * mm5 + tm5 * mm8; + tm[6] = tm6 * mm0 + tm7 * mm3 + tm8 * mm6; + tm[7] = tm6 * mm1 + tm7 * mm4 + tm8 * mm7; + tm[8] = tm6 * mm2 + tm7 * mm5 + tm8 * mm8; + + return this; + }, + /** + * Premultiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + premultiply:function (m) { + + var m00 = m.matrix[0] * this.matrix[0] + m.matrix[1] * this.matrix[3] + m.matrix[2] * this.matrix[6]; + var m01 = m.matrix[0] * this.matrix[1] + m.matrix[1] * this.matrix[4] + m.matrix[2] * this.matrix[7]; + var m02 = m.matrix[0] * this.matrix[2] + m.matrix[1] * this.matrix[5] + m.matrix[2] * this.matrix[8]; + + var m10 = m.matrix[3] * this.matrix[0] + m.matrix[4] * this.matrix[3] + m.matrix[5] * this.matrix[6]; + var m11 = m.matrix[3] * this.matrix[1] + m.matrix[4] * this.matrix[4] + m.matrix[5] * this.matrix[7]; + var m12 = m.matrix[3] * this.matrix[2] + m.matrix[4] * this.matrix[5] + m.matrix[5] * this.matrix[8]; + + var m20 = m.matrix[6] * this.matrix[0] + m.matrix[7] * this.matrix[3] + m.matrix[8] * this.matrix[6]; + var m21 = m.matrix[6] * this.matrix[1] + m.matrix[7] * this.matrix[4] + m.matrix[8] * this.matrix[7]; + var m22 = m.matrix[6] * this.matrix[2] + m.matrix[7] * this.matrix[5] + m.matrix[8] * this.matrix[8]; + + this.matrix[0] = m00; + this.matrix[1] = m01; + this.matrix[2] = m02; + + this.matrix[3] = m10; + this.matrix[4] = m11; + this.matrix[5] = m12; + + this.matrix[6] = m20; + this.matrix[7] = m21; + this.matrix[8] = m22; + + + return this; + }, + /** + * Creates a new inverse matrix from this matrix. + * @return {CAAT.Matrix} an inverse matrix. + */ + getInverse:function (out) { + var tm = this.matrix; + + var m00 = tm[0]; + var m01 = tm[1]; + var m02 = tm[2]; + var m10 = tm[3]; + var m11 = tm[4]; + var m12 = tm[5]; + var m20 = tm[6]; + var m21 = tm[7]; + var m22 = tm[8]; + + var newMatrix = out || new CAAT.Math.Matrix(); + + var determinant = m00 * (m11 * m22 - m21 * m12) - m10 * (m01 * m22 - m21 * m02) + m20 * (m01 * m12 - m11 * m02); + if (determinant === 0) { + return null; + } + + var m = newMatrix.matrix; + + m[0] = m11 * m22 - m12 * m21; + m[1] = m02 * m21 - m01 * m22; + m[2] = m01 * m12 - m02 * m11; + + m[3] = m12 * m20 - m10 * m22; + m[4] = m00 * m22 - m02 * m20; + m[5] = m02 * m10 - m00 * m12; + + m[6] = m10 * m21 - m11 * m20; + m[7] = m01 * m20 - m00 * m21; + m[8] = m00 * m11 - m01 * m10; + + newMatrix.multiplyScalar(1 / determinant); + + return newMatrix; + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i; + + for (i = 0; i < 9; i++) { + this.matrix[i] *= scalar; + } + + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_NoClamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_NoClamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_Clamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_Clamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + setModelViewMatrix:function ( x, y, sx, sy, r ) { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + mm = this.matrix; + + mm0 = 1; + mm1 = 0; + mm3 = 0; + mm4 = 1; + + mm2 = x; + mm5 = y; + + c = Math.cos(r); + s = Math.sin(r); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Matrix3 + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Matrix3", + aliases:["CAAT.Matrix3"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix3.prototype + */ + + /** + * An Array of 4 Array of 4 numbers. + */ + matrix:null, + + /** + * An array of 16 numbers. + */ + fmatrix:null, + + __init:function () { + this.matrix = [ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1] + ]; + + this.fmatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + + return this; + }, + + transformCoord:function (point) { + var x = point.x; + var y = point.y; + var z = point.z; + + point.x = x * this.matrix[0][0] + y * this.matrix[0][1] + z * this.matrix[0][2] + this.matrix[0][3]; + point.y = x * this.matrix[1][0] + y * this.matrix[1][1] + z * this.matrix[1][2] + this.matrix[1][3]; + point.z = x * this.matrix[2][0] + y * this.matrix[2][1] + z * this.matrix[2][2] + this.matrix[2][3]; + + return point; + }, + initialize:function (x0, y0, z0, x1, y1, z1, x2, y2, z2) { + this.identity(); + this.matrix[0][0] = x0; + this.matrix[0][1] = y0; + this.matrix[0][2] = z0; + + this.matrix[1][0] = x1; + this.matrix[1][1] = y1; + this.matrix[1][2] = z1; + + this.matrix[2][0] = x2; + this.matrix[2][1] = y2; + this.matrix[2][2] = z2; + + return this; + }, + initWithMatrix:function (matrixData) { + this.matrix = matrixData; + return this; + }, + flatten:function () { + var d = this.fmatrix; + var s = this.matrix; + d[ 0] = s[0][0]; + d[ 1] = s[1][0]; + d[ 2] = s[2][0]; + d[ 3] = s[3][0]; + + d[ 4] = s[0][1]; + d[ 5] = s[1][1]; + d[ 6] = s[2][1]; + d[ 7] = s[2][1]; + + d[ 8] = s[0][2]; + d[ 9] = s[1][2]; + d[10] = s[2][2]; + d[11] = s[3][2]; + + d[12] = s[0][3]; + d[13] = s[1][3]; + d[14] = s[2][3]; + d[15] = s[3][3]; + + return this.fmatrix; + }, + + /** + * Set this matrix to identity matrix. + * @return this + */ + identity:function () { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = (i === j) ? 1.0 : 0.0; + } + } + + return this; + }, + /** + * Get this matri'x internal representation data. The bakced structure is a 4x4 array of number. + */ + getMatrix:function () { + return this.matrix; + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xy axis. + * + * @param xy {Number} radians to rotate. + * + * @return this + */ + rotateXY:function (xy) { + return this.rotate(xy, 0, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xz axis. + * + * @param xz {Number} radians to rotate. + * + * @return this + */ + rotateXZ:function (xz) { + return this.rotate(0, xz, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate aroind + * yz axis. + * + * @param yz {Number} radians to rotate. + * + * @return this + */ + rotateYZ:function (yz) { + return this.rotate(0, 0, yz); + }, + /** + * + * @param xy + * @param xz + * @param yz + */ + setRotate:function (xy, xz, yz) { + var m = this.rotate(xy, xz, yz); + this.copy(m); + return this; + }, + /** + * Creates a matrix to represent arbitrary rotations around the given planes. + * @param xy {number} radians to rotate around xy plane. + * @param xz {number} radians to rotate around xz plane. + * @param yz {number} radians to rotate around yz plane. + * + * @return {CAAT.Matrix3} a newly allocated matrix. + * @static + */ + rotate:function (xy, xz, yz) { + var res = new CAAT.Math.Matrix3(); + var s, c, m; + + if (xy !== 0) { + m = new CAAT.Math.Math.Matrix3(); + s = Math.sin(xy); + c = Math.cos(xy); + m.matrix[1][1] = c; + m.matrix[1][2] = -s; + m.matrix[2][1] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (xz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(xz); + c = Math.cos(xz); + m.matrix[0][0] = c; + m.matrix[0][2] = -s; + m.matrix[2][0] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (yz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(yz); + c = Math.cos(yz); + m.matrix[0][0] = c; + m.matrix[0][1] = -s; + m.matrix[1][0] = s; + m.matrix[1][1] = c; + res.multiply(m); + } + + return res; + }, + /** + * Creates a new matrix being a copy of this matrix. + * @return {CAAT.Matrix3} a newly allocated matrix object. + */ + getClone:function () { + var m = new CAAT.Math.Matrix3(); + m.copy(this); + return m; + }, + /** + * Multiplies this matrix by another matrix. + * + * @param n {CAAT.Matrix3} a CAAT.Matrix3 object. + * @return this + */ + multiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20 + n03 * m30; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21 + n03 * m31; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22 + n03 * m32; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03 * m33; + + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20 + n13 * m30; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21 + n13 * m31; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22 + n13 * m32; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13 * m33; + + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20 + n23 * m30; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21 + n23 * m31; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22 + n23 * m32; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23 * m33; + + return this; + }, + /** + * Pre multiplies this matrix by a given matrix. + * + * @param m {CAAT.Matrix3} a CAAT.Matrix3 object. + * + * @return this + */ + premultiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03; + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13; + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23; + + return this; + }, + /** + * Set this matrix translation values to be the given parameters. + * + * @param x {number} x component of translation point. + * @param y {number} y component of translation point. + * @param z {number} z component of translation point. + * + * @return this + */ + setTranslate:function (x, y, z) { + this.identity(); + this.matrix[0][3] = x; + this.matrix[1][3] = y; + this.matrix[2][3] = z; + return this; + }, + /** + * Create a translation matrix. + * @param x {number} + * @param y {number} + * @param z {number} + * @return {CAAT.Matrix3} a new matrix. + */ + translate:function (x, y, z) { + var m = new CAAT.Math.Matrix3(); + m.setTranslate(x, y, z); + return m; + }, + setScale:function (sx, sy, sz) { + this.identity(); + this.matrix[0][0] = sx; + this.matrix[1][1] = sy; + this.matrix[2][2] = sz; + return this; + }, + scale:function (sx, sy, sz) { + var m = new CAAT.Math.Matrix3(); + m.setScale(sx, sy, sz); + return m; + }, + /** + * Set this matrix as the rotation matrix around the given axes. + * @param xy {number} radians of rotation around z axis. + * @param xz {number} radians of rotation around y axis. + * @param yz {number} radians of rotation around x axis. + * + * @return this + */ + rotateModelView:function (xy, xz, yz) { + var sxy = Math.sin(xy); + var sxz = Math.sin(xz); + var syz = Math.sin(yz); + var cxy = Math.cos(xy); + var cxz = Math.cos(xz); + var cyz = Math.cos(yz); + + this.matrix[0][0] = cxz * cxy; + this.matrix[0][1] = -cxz * sxy; + this.matrix[0][2] = sxz; + this.matrix[0][3] = 0; + this.matrix[1][0] = syz * sxz * cxy + sxy * cyz; + this.matrix[1][1] = cyz * cxy - syz * sxz * sxy; + this.matrix[1][2] = -syz * cxz; + this.matrix[1][3] = 0; + this.matrix[2][0] = syz * sxy - cyz * sxz * cxy; + this.matrix[2][1] = cyz * sxz * sxy + syz * cxy; + this.matrix[2][2] = cyz * cxz; + this.matrix[2][3] = 0; + this.matrix[3][0] = 0; + this.matrix[3][1] = 0; + this.matrix[3][2] = 0; + this.matrix[3][3] = 1; + + return this; + }, + /** + * Copy a given matrix values into this one's. + * @param m {CAAT.Matrix} a matrix + * + * @return this + */ + copy:function (m) { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = m.matrix[i][j]; + } + } + + return this; + }, + /** + * Calculate this matrix's determinant. + * @return {number} matrix determinant. + */ + calculateDeterminant:function () { + + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + return m14 * m22 * m33 * m41 + + m12 * m24 * m33 * m41 + + m14 * m23 * m31 * m42 + + m13 * m24 * m31 * m42 + + + m13 * m21 * m34 * m42 + + m11 * m23 * m34 * m42 + + m14 * m21 * m32 * m43 + + m11 * m24 * m32 * m43 + + + m13 * m22 * m31 * m44 + + m12 * m23 * m31 * m44 + + m12 * m21 * m33 * m44 + + m11 * m22 * m33 * m44 + + + m14 * m23 * m32 * m41 - + m13 * m24 * m32 * m41 - + m13 * m22 * m34 * m41 - + m12 * m23 * m34 * m41 - + + m14 * m21 * m33 * m42 - + m11 * m24 * m33 * m42 - + m14 * m22 * m31 * m43 - + m12 * m24 * m31 * m43 - + + m12 * m21 * m34 * m43 - + m11 * m22 * m34 * m43 - + m13 * m21 * m32 * m44 - + m11 * m23 * m32 * m44; + }, + /** + * Return a new matrix which is this matrix's inverse matrix. + * @return {CAAT.Matrix3} a new matrix. + */ + getInverse:function () { + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + var m2 = new CAAT.Math.Matrix3(); + m2.matrix[0][0] = m23 * m34 * m42 + m24 * m32 * m43 + m22 * m33 * m44 - m24 * m33 * m42 - m22 * m34 * m43 - m23 * m32 * m44; + m2.matrix[0][1] = m14 * m33 * m42 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44 - m13 * m34 * m42 - m14 * m32 * m43; + m2.matrix[0][2] = m13 * m24 * m42 + m12 * m23 * m44 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 - m14 * m23 * m42; + m2.matrix[0][3] = m14 * m23 * m32 + m12 * m24 * m33 + m13 * m22 * m34 - m13 * m24 * m32 - m14 * m22 * m33 - m12 * m23 * m34; + + m2.matrix[1][0] = m24 * m33 * m41 + m21 * m34 * m43 + m23 * m31 * m44 - m23 * m34 * m41 - m24 * m31 * m43 - m21 * m33 * m44; + m2.matrix[1][1] = m13 * m34 * m41 + m14 * m31 * m43 + m11 * m33 * m44 - m14 * m33 * m41 - m11 * m34 * m43 - m13 * m31 * m44; + m2.matrix[1][2] = m14 * m23 * m41 + m11 * m24 * m43 + m13 * m21 * m44 - m13 * m24 * m41 - m14 * m21 * m43 - m11 * m23 * m44; + m2.matrix[1][3] = m13 * m24 * m31 + m14 * m21 * m33 + m11 * m23 * m34 - m14 * m23 * m31 - m11 * m24 * m33 - m13 * m21 * m34; + + m2.matrix[2][0] = m22 * m34 * m41 + m24 * m31 * m42 + m21 * m32 * m44 - m24 * m32 * m41 - m21 * m34 * m42 - m22 * m31 * m44; + m2.matrix[2][1] = m14 * m32 * m41 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44 - m12 * m34 * m41 - m14 * m31 * m42; + m2.matrix[2][2] = m13 * m24 * m41 + m14 * m21 * m42 + m11 * m22 * m44 - m14 * m22 * m41 - m11 * m24 * m42 - m12 * m21 * m44; + m2.matrix[2][3] = m14 * m22 * m31 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34 - m12 * m24 * m31 - m14 * m21 * m32; + + m2.matrix[3][0] = m23 * m32 * m41 + m21 * m33 * m42 + m22 * m31 * m43 - m22 * m33 * m41 - m23 * m31 * m42 - m21 * m32 * m43; + m2.matrix[3][1] = m12 * m33 * m41 + m13 * m31 * m42 + m11 * m32 * m43 - m13 * m32 * m41 - m11 * m33 * m42 - m12 * m31 * m43; + m2.matrix[3][2] = m13 * m22 * m41 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43 - m12 * m23 * m41 - m13 * m21 * m42; + m2.matrix[3][3] = m12 * m23 * m31 + m13 * m21 * m32 + m11 * m22 * m33 - m13 * m22 * m31 - m11 * m23 * m32 - m12 * m21 * m33; + + return m2.multiplyScalar(1 / this.calculateDeterminant()); + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i, j; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + this.matrix[i][j] *= scalar; + } + } + + return this; + } + + } + } + +}); +/** + * See LICENSE file. + * + **/ +CAAT.Module({ + + /** + * @name Point + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Point", + aliases:["CAAT.Point"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Point.prototype + */ + + + /** + * point x coordinate. + */ + x:0, + + /** + * point y coordinate. + */ + y:0, + + /** + * point z coordinate. + */ + z:0, + + __init:function (xpos, ypos, zpos) { + this.x = xpos; + this.y = ypos; + this.z = zpos || 0; + return this; + }, + + /** + * Sets this point coordinates. + * @param x {number} + * @param y {number} + * @param z {number=} + * + * @return this + */ + set:function (x, y, z) { + this.x = x; + this.y = y; + this.z = z || 0; + return this; + }, + /** + * Create a new CAAT.Point equal to this one. + * @return {CAAT.Point} + */ + clone:function () { + var p = new CAAT.Math.Point(this.x, this.y, this.z); + return p; + }, + /** + * Translate this point to another position. The final point will be (point.x+x, point.y+y) + * @param x {number} + * @param y {number} + * + * @return this + */ + translate:function (x, y, z) { + this.x += x; + this.y += y; + this.z += z; + + return this; + }, + /** + * Translate this point to another point. + * @param aPoint {CAAT.Point} + * @return this + */ + translatePoint:function (aPoint) { + this.x += aPoint.x; + this.y += aPoint.y; + this.z += aPoint.z; + return this; + }, + /** + * Substract a point from this one. + * @param aPoint {CAAT.Point} + * @return this + */ + subtract:function (aPoint) { + this.x -= aPoint.x; + this.y -= aPoint.y; + this.z -= aPoint.z; + return this; + }, + /** + * Multiply this point by a scalar. + * @param factor {number} + * @return this + */ + multiply:function (factor) { + this.x *= factor; + this.y *= factor; + this.z *= factor; + return this; + }, + /** + * Rotate this point by an angle. The rotation is held by (0,0) coordinate as center. + * @param angle {number} + * @return this + */ + rotate:function (angle) { + var x = this.x, y = this.y; + this.x = x * Math.cos(angle) - Math.sin(angle) * y; + this.y = x * Math.sin(angle) + Math.cos(angle) * y; + this.z = 0; + return this; + }, + /** + * + * @param angle {number} + * @return this + */ + setAngle:function (angle) { + var len = this.getLength(); + this.x = Math.cos(angle) * len; + this.y = Math.sin(angle) * len; + this.z = 0; + return this; + }, + /** + * + * @param length {number} + * @return this + */ + setLength:function (length) { + var len = this.getLength(); + if (len)this.multiply(length / len); + else this.x = this.y = this.z = length; + return this; + }, + /** + * Normalize this point, that is, both set coordinates proportionally to values raning 0..1 + * @return this + */ + normalize:function () { + var len = this.getLength(); + this.x /= len; + this.y /= len; + this.z /= len; + return this; + }, + /** + * Return the angle from -Pi to Pi of this point. + * @return {number} + */ + getAngle:function () { + return Math.atan2(this.y, this.x); + }, + /** + * Set this point coordinates proportinally to a maximum value. + * @param max {number} + * @return this + */ + limit:function (max) { + var aLenthSquared = this.getLengthSquared(); + if (aLenthSquared + 0.01 > max * max) { + var aLength = Math.sqrt(aLenthSquared); + this.x = (this.x / aLength) * max; + this.y = (this.y / aLength) * max; + this.z = (this.z / aLength) * max; + } + return this; + }, + /** + * Get this point's lenght. + * @return {number} + */ + getLength:function () { + var length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + if (length < 0.005 && length > -0.005) return 0.000001; + return length; + + }, + /** + * Get this point's squared length. + * @return {number} + */ + getLengthSquared:function () { + var lengthSquared = this.x * this.x + this.y * this.y + this.z * this.z; + if (lengthSquared < 0.005 && lengthSquared > -0.005) return 0; + return lengthSquared; + }, + /** + * Get the distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistance:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + }, + /** + * Get the squared distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistanceSquared:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ; + }, + /** + * Get a string representation. + * @return {string} + */ + toString:function () { + return "(CAAT.Math.Point)" + + " x:" + String(Math.round(Math.floor(this.x * 10)) / 10) + + " y:" + String(Math.round(Math.floor(this.y * 10)) / 10) + + " z:" + String(Math.round(Math.floor(this.z * 10)) / 10); + } + } + } +}); +/** + * See LICENSE file. + * + */ + + +CAAT.Module( { + + /** + * @name Rectangle + * @memberOf CAAT.Math + * @constructor + */ + + + defines: "CAAT.Math.Rectangle", + aliases: ["CAAT.Rectangle"], + extendsWith: function() { + return { + + /** + * @lends CAAT.Math.Rectangle.prototype + */ + + __init : function( x,y,w,h ) { + if ( arguments.length!==4 ) { + this.setEmpty(); + } else { + this.setLocation(x,y); + this.setDimension(w,h); + } + }, + + /** + * Rectangle x position. + */ + x: 0, + + /** + * Rectangle y position. + */ + y: 0, + + /** + * Rectangle x1 position. + */ + x1: 0, + + /** + * Rectangle y1 position. + */ + y1: 0, + + /** + * Rectangle width. + */ + width: -1, + + /** + * Rectangle height. + */ + height: -1, + + setEmpty : function() { + this.width= -1; + this.height= -1; + this.x= 0; + this.y= 0; + this.x1= 0; + this.y1= 0; + return this; + }, + /** + * Set this rectangle's location. + * @param x {number} + * @param y {number} + */ + setLocation: function( x,y ) { + this.x= x; + this.y= y; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + /** + * Set this rectangle's dimension. + * @param w {number} + * @param h {number} + */ + setDimension : function( w,h ) { + this.width= w; + this.height= h; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + setBounds : function( x,y,w,h ) { + this.setLocation( x, y ); + this.setDimension( w, h ); + return this; + }, + /** + * Return whether the coordinate is inside this rectangle. + * @param px {number} + * @param py {number} + * + * @return {boolean} + */ + contains : function(px,py) { + //return px>=0 && px=0 && py=this.x && px=this.y && pythis.y1 ) { + this.y1= py; + } + if ( px>this.x1 ){ + this.x1= px; + } + + this.width= this.x1-this.x; + this.height= this.y1-this.y; + }, + unionRectangle : function( rectangle ) { + this.union( rectangle.x , rectangle.y ); + this.union( rectangle.x1, rectangle.y ); + this.union( rectangle.x, rectangle.y1 ); + this.union( rectangle.x1, rectangle.y1 ); + return this; + }, + intersects : function( r ) { + if ( r.isEmpty() || this.isEmpty() ) { + return false; + } + + if ( r.x1<= this.x ) { + return false; + } + if ( r.x >= this.x1 ) { + return false; + } + if ( r.y1<= this.y ) { + return false; + } + + return r.y < this.y1; + }, + + intersectsRect : function( x,y,w,h ) { + if ( -1===w || -1===h ) { + return false; + } + + var x1= x+w-1; + var y1= y+h-1; + + if ( x1< this.x ) { + return false; + } + if ( x > this.x1 ) { + return false; + } + if ( y1< this.y ) { + return false; + } + return y <= this.y1; + + }, + + intersect : function( i, r ) { + if ( typeof r==='undefined' ) { + r= new CAAT.Math.Rectangle(); + } + + r.x= Math.max( this.x, i.x ); + r.y= Math.max( this.y, i.y ); + r.x1=Math.min( this.x1, i.x1 ); + r.y1=Math.min( this.y1, i.y1 ); + r.width= r.x1-r.x; + r.height=r.y1-r.y; + + return r; + } + } + } +}); +/** + * See LICENSE file. + * + * Partially based on Robert Penner easing equations. + * http://www.robertpenner.com/easing/ + * + * + **/ + +CAAT.Module({ + + /** + * @name Interpolator + * @memberOf CAAT.Behavior + * @constructor + */ + + defines:"CAAT.Behavior.Interpolator", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Interpolator"], + constants : { + /** + * @lends CAAT.Behavior.Interpolator + */ + + enumerateInterpolators: function () { + return [ + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, false), 'Linear pingpong=false, inverse=false', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, false), 'Linear pingpong=true, inverse=false', + + new CAAT.Behavior.Interpolator().createBackOutInterpolator(false), 'BackOut pingpong=true, inverse=false', + new CAAT.Behavior.Interpolator().createBackOutInterpolator(true), 'BackOut pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, true), 'Linear pingpong=false, inverse=true', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, true), 'Linear pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, false), 'ExponentialIn pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, false), 'ExponentialOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, false), 'ExponentialInOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, true), 'ExponentialIn pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, true), 'ExponentialOut pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, true), 'ExponentialInOut pingpong=true, exponent=2', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, false), 'ExponentialIn pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, false), 'ExponentialOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, false), 'ExponentialInOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, true), 'ExponentialIn pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, true), 'ExponentialOut pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, true), 'ExponentialInOut pingpong=true, exponent=4', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, false), 'ExponentialIn pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, false), 'ExponentialOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, false), 'ExponentialInOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, true), 'ExponentialIn pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, true), 'ExponentialOut pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, true), 'ExponentialInOut pingpong=true, exponent=6', + + new CAAT.Behavior.Interpolator().createBounceInInterpolator(false), 'BounceIn pingpong=false', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(false), 'BounceOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(false), 'BounceInOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInInterpolator(true), 'BounceIn pingpong=true', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(true), 'BounceOut pingpong=true', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(true), 'BounceInOut pingpong=true', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, false), 'ElasticIn pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, false), 'ElasticOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, false), 'ElasticInOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, true), 'ElasticIn pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, true), 'ElasticOut pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, true), 'ElasticInOut pingpong=true, amp=1.1, d=.4', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, false), 'ElasticIn pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, false), 'ElasticOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, false), 'ElasticInOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, true), 'ElasticIn pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, true), 'ElasticOut pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, true), 'ElasticInOut pingpong=true, amp=1.0, d=.2' + ]; + }, + + parse : function( obj ) { + var name= "create"+obj.type+"Interpolator"; + var interpolator= new CAAT.Behavior.Interpolator(); + try { + interpolator[name].apply( interpolator, obj.params||[] ); + } catch(e) { + interpolator.createLinearInterpolator(false, false); + } + + return interpolator; + } + + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Interpolator.prototype + */ + + interpolated:null, // a coordinate holder for not building a new CAAT.Point for each interpolation call. + paintScale:90, // the size of the interpolation draw on screen in pixels. + + __init:function () { + this.interpolated = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * Set a linear interpolation function. + * + * @param bPingPong {boolean} + * @param bInverse {boolean} will values will be from 1 to 0 instead of 0 to 1 ?. + */ + createLinearInterpolator:function (bPingPong, bInverse) { + /** + * Linear and inverse linear interpolation function. + * @param time {number} + */ + this.getPosition = function getPosition(time) { + + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (bInverse !== null && bInverse) { + time = 1 - time; + } + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + + createBackOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = time - 1; + var overshoot = 1.70158; + + return this.interpolated.set( + orgTime, + time * time * ((overshoot + 1) * time + overshoot) + 1); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be Math.pow(time,exponent). + * This function starts with 0 and ends in values of 1. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, Math.pow(time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be 1-Math.pow(time,exponent). + * This function starts with 1 and ends in values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, 1 - Math.pow(1 - time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. Two functions will apply: + * Math.pow(time*2,exponent)/2 for the first half of the function (t<0.5) and + * 1-Math.abs(Math.pow(time*2-2,exponent))/2 for the second half (t>=.5) + * This function starts with 0 and goes to values of 1 and ends with values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + if (time * 2 < 1) { + return this.interpolated.set(orgTime, Math.pow(time * 2, exponent) / 2); + } + + return this.interpolated.set(orgTime, 1 - Math.abs(Math.pow(time * 2 - 2, exponent)) / 2); + }; + + return this; + }, + /** + * Creates a Quadric bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createQuadricBezierInterpolator:function (p0, p1, p2, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = (1 - time) * (1 - time) * p0.y + 2 * (1 - time) * time * p1.y + time * time * p2.y; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + /** + * Creates a Cubic bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param p3 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createCubicBezierInterpolator:function (p0, p1, p2, p3, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var t2 = time * time; + var t3 = time * t2; + + time = (p0.y + time * (-p0.y * 3 + time * (3 * p0.y - + p0.y * time))) + time * (3 * p1.y + time * (-6 * p1.y + + p1.y * 3 * time)) + t2 * (p2.y * 3 - p2.y * 3 * time) + + p3.y * t3; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + createElasticOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + (amplitude * Math.pow(2, -10 * time) * Math.sin((time - s) * (2 * Math.PI) / p) + 1 )); + }; + return this; + }, + createElasticInInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + -(amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p) )); + }; + + return this; + }, + createElasticInOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + time *= 2; + if (time <= 1) { + return this.interpolated.set( + time, + -0.5 * (amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + } + + return this.interpolated.set( + time, + 1 + 0.5 * (amplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + }; + + return this; + }, + /** + * @param time {number} + * @private + */ + bounce:function (time) { + if ((time /= 1) < (1 / 2.75)) { + return {x:time, y:7.5625 * time * time}; + } else if (time < (2 / 2.75)) { + return {x:time, y:7.5625 * (time -= (1.5 / 2.75)) * time + 0.75}; + } else if (time < (2.5 / 2.75)) { + return {x:time, y:7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375}; + } else { + return {x:time, y:7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375}; + } + }, + createBounceOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.bounce(time); + }; + + return this; + }, + createBounceInInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + var r = this.bounce(1 - time); + r.y = 1 - r.y; + return r; + }; + + return this; + }, + createBounceInOutInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var r; + if (time < 0.5) { + r = this.bounce(1 - time * 2); + r.y = (1 - r.y) * 0.5; + return r; + } + r = this.bounce(time * 2 - 1, bPingPong); + r.y = r.y * 0.5 + 0.5; + return r; + }; + + return this; + }, + + /** + * Paints an interpolator on screen. + * @param ctx {CanvasRenderingContext} + */ + paint:function (ctx) { + + ctx.save(); + ctx.beginPath(); + + ctx.moveTo(0, this.getPosition(0).y * this.paintScale); + + for (var i = 0; i <= this.paintScale; i++) { + ctx.lineTo(i, this.getPosition(i / this.paintScale).y * this.paintScale); + } + + ctx.strokeStyle = 'black'; + ctx.stroke(); + ctx.restore(); + }, + + /** + * Gets an array of coordinates which define the polyline of the intepolator's curve contour. + * Values for both coordinates range from 0 to 1. + * @param iSize {number} an integer indicating the number of contour segments. + * @return Array. of object of the form {x:float, y:float}. + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } +}); +/** + * See LICENSE file. + * + * Behaviors are keyframing elements. + * By using a BehaviorContainer, you can specify different actions on any animation Actor. + * An undefined number of Behaviors can be defined for each Actor. + * + * There're the following Behaviors: + * + AlphaBehavior: controls container/actor global alpha. + * + RotateBehavior: takes control of rotation affine transform. + * + ScaleBehavior: takes control of scaling on x and y axis affine transform. + * + Scale1Behavior: takes control of scaling on x or y axis affine transform. + * + PathBehavior: takes control of translating an Actor/ActorContainer across a path [ie. pathSegment collection]. + * + GenericBehavior: applies a behavior to any given target object's property, or notifies a callback. + * + * + **/ + +CAAT.Module({ + + /** + * + * Namespace for all behavior-based actor properties instrumenter objects. + * + * @name Behavior + * @memberOf CAAT + * @namespace + */ + + /** + * + * The BaseBehavior is the base class of all Behavior modifiers: + * + *
  • AlphaBehabior + *
  • RotateBehavior + *
  • ScaleBehavior + *
  • Scale1Behavior + *
  • PathBehavior + *
  • GenericBehavior + *
  • ContainerBehavior + * + * Behavior base class. + * + *

    + * A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator. + * In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same + * time interval. + *

    + * A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified + * period. + *

    + * A behavior is guaranteed to notify (if any observer is registered) on behavior expiration. + *

    + * A behavior can keep an unlimited observers. Observers are objects of the form: + *

    + * + * { + * behaviorExpired : function( behavior, time, actor); + * behaviorApplied : function( behavior, time, normalizedTime, actor, value); + * } + * + *

    + * behaviorExpired: function( behavior, time, actor). This method will be called for any registered observer when + * the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time + * granurality. + *

    + * behaviorApplied : function( behavior, time, normalizedTime, actor, value). This method will be called once per + * frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be + * called multiple times. + *

    + * Every behavior is applied to a concrete Actor. + * Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and + * is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration. + *

    + * You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify + * behaviorExpired to its registered observers. + *

    + * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. + * + * @name BaseBehavior + * @memberOf CAAT.Behavior + * @constructor + * + */ + + /** + * + * Internal behavior status values. Do not assign directly. + * + * @name Status + * @memberOf CAAT.Behavior.BaseBehavior + * @namespace + * @enum {number} + */ + + + defines: "CAAT.Behavior.BaseBehavior", + constants: { + + Status: { + /** + * @lends CAAT.Behavior.BaseBehavior.Status + */ + + /** @const @type {number}*/ NOT_STARTED: 0, + /** @const @type {number} */ STARTED: 1, + /** @const @type {number}*/ EXPIRED: 2 + }, + + /** + * @lends CAAT.Behavior.BaseBehavior + * @function + * @param obj a JSON object with a behavior definition. + */ + parse : function( obj ) { + + function findClass( qualifiedClassName ) { + var ns= qualifiedClassName.split("."); + var _global= window; + for( var i=0; i= this.behaviorStartTime) { + time = (time - this.behaviorStartTime) % this.behaviorDuration + this.behaviorStartTime; + } + } + + if (time > this.behaviorStartTime + this.behaviorDuration) { + if (this.status !== st.EXPIRED) { + this.setExpired(actor, time); + } + + return false; + } + + if (this.status === st.NOT_STARTED) { + this.status = st.STARTED; + this.fireBehaviorStartedEvent(actor, time); + } + + return this.behaviorStartTime <= time; // && time>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "opacity: " + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + } + } + } +}); +CAAT.Module({ + + /** + * @name ContainerBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.ContainerBehavior", + depends:["CAAT.Behavior.BaseBehavior", "CAAT.Behavior.GenericBehavior"], + aliases: ["CAAT.ContainerBehavior"], + extendsClass : "CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.ContainerBehavior.prototype + */ + + /** + * @inheritDoc + */ + parse : function( obj ) { + if ( obj.behaviors && obj.behaviors.length ) { + for( var i=0; i} + */ + behaviors:null, // contained behaviors array + recursiveCycleBehavior : false, + conforming : false, + + /** + * @param conforming {bool=} conform this behavior duration to that of its children. + * @inheritDoc + * @private + */ + __init:function ( conforming ) { + this.__super(); + this.behaviors = []; + if ( conforming ) { + this.conforming= true; + } + return this; + }, + + /** + * Proportionally change this container duration to its children. + * @param duration {number} new duration in ms. + * @return this; + */ + conformToDuration:function (duration) { + this.duration = duration; + + var f = duration / this.duration; + var bh; + for (var i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + bh.setFrameTime(bh.getStartTime() * f, bh.getDuration() * f); + } + + return this; + }, + + /** + * Get a behavior by mathing its id. + * @param id {object} + */ + getBehaviorById : function(id) { + for( var i=0; i= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + var obj= bh.getKeyFrameDataValues(time); + for( var pr in obj ) { + keyFrameData[pr]= obj[pr]; + } + } + } + } + + return keyFrameData; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (referenceTime, prefix) { + + var i; + var bh; + + var retValue = {}; + var time; + var cssRuleValue; + var cssProperty; + var property; + + for (i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + if (bh.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED && !(bh instanceof CAAT.Behavior.GenericBehavior)) { + + // ajustar tiempos: + // time es tiempo normalizado a duracion de comportamiento contenedor. + // 1.- desnormalizar + time = referenceTime * this.behaviorDuration; + + // 2.- calcular tiempo relativo de comportamiento respecto a contenedor + if (bh.behaviorStartTime <= time && bh.behaviorStartTime + bh.behaviorDuration >= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + cssRuleValue = bh.calculateKeyFrameData(time); + cssProperty = bh.getPropertyName(prefix); + + if (typeof retValue[cssProperty] === 'undefined') { + retValue[cssProperty] = ""; + } + + // 5.- asignar a objeto, par de propiedad/valor css + retValue[cssProperty] += cssRuleValue + " "; + } + + } + } + + + var tr = ""; + var pv; + + function xx(pr) { + if (retValue[pr]) { + tr += retValue[pr]; + } else { + if (prevValues) { + pv = prevValues[pr]; + if (pv) { + tr += pv; + retValue[pr] = pv; + } + } + } + } + + xx('translate'); + xx('rotate'); + xx('scale'); + + var keyFrameRule = ""; + + if (tr) { + keyFrameRule = '-' + prefix + '-transform: ' + tr + ';'; + } + + tr = ""; + xx('opacity'); + if (tr) { + keyFrameRule += ' opacity: ' + tr + ';'; + } + + keyFrameRule+=" -webkit-transform-origin: 0% 0%"; + + return { + rules:keyFrameRule, + ret:retValue + }; + + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize, anchorX, anchorY) { + + function toKeyFrame(obj, prevKF) { + + for( var i in prevKF ) { + if ( !obj[i] ) { + obj[i]= prevKF[i]; + } + } + + var ret= "-" + prefix + "-transform:"; + + if ( obj.x || obj.y ) { + var x= obj.x || 0; + var y= obj.y || 0; + ret+= "translate("+x+"px,"+y+"px)"; + } + + if ( obj.angle ) { + ret+= " rotate("+obj.angle+"rad)"; + } + + if ( obj.scaleX!==1 || obj.scaleY!==1 ) { + ret+= " scale("+(obj.scaleX)+","+(obj.scaleY)+")"; + } + + ret+=";"; + + if ( obj.alpha ) { + ret+= " opacity: "+obj.alpha+";"; + } + + if ( anchorX!==.5 || anchorY!==.5) { + ret+= " -" + prefix + "-transform-origin:"+ (anchorX*100) + "% " + (anchorY*100) + "%;"; + } + + return ret; + } + + if (this.duration === Number.MAX_VALUE) { + return ""; + } + + if (typeof anchorX==="undefined") { + anchorX= .5; + } + + if (typeof anchorY==="undefined") { + anchorY= .5; + } + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + + var i; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + var time; + var prevKF= {}; + + for (i = 0; i <= keyframessize; i++) { + time = this.interpolator.getPosition(i / keyframessize).y; + + var obj = this.getKeyFrameDataValues(time); + + kfd += "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + toKeyFrame(obj, prevKF) + "}\n"; + + prevKF= obj; + + } + + kfd += "}\n"; + + return kfd; + } + } + } +}); +CAAT.Module({ + /** + * @name GenericBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + defines:"CAAT.Behavior.GenericBehavior", + depends:["CAAT.Behavior.BaseBehavior"], + aliases:["CAAT.GenericBehavior"], + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.GenericBehavior.prototype + */ + + + /** + * starting value. + */ + start:0, + + /** + * ending value. + */ + end:0, + + /** + * target to apply this generic behvior. + */ + target:null, + + /** + * property to apply values to. + */ + property:null, + + /** + * this callback will be invoked for every behavior application. + */ + callback:null, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var value = this.start + time * (this.end - this.start); + if (this.callback) { + this.callback(value, this.target, actor); + } + + if (this.property) { + this.target[this.property] = value; + } + }, + + /** + * Defines the values to apply this behavior. + * + * @param start {number} initial behavior value. + * @param end {number} final behavior value. + * @param target {object} an object. Usually a CAAT.Actor. + * @param property {string} target object's property to set value to. + * @param callback {function} a function of the form function( target, value ). + */ + setValues:function (start, end, target, property, callback) { + this.start = start; + this.end = end; + this.target = target; + this.property = property; + this.callback = callback; + return this; + } + }; + } +}); +CAAT.Module({ + + /** + * @name PathBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name AUTOROTATE + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name autorotate + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + * @deprecated + */ + + defines:"CAAT.Behavior.PathBehavior", + aliases: ["CAAT.PathBehavior"], + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.SpriteImage" + ], + constants : { + + AUTOROTATE : { + + /** + * @lends CAAT.Behavior.PathBehavior.AUTOROTATE + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + }, + + autorotate: { + /** + * @lends CAAT.Behavior.PathBehavior.autorotate + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + } + }, + extendsClass : "CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.PathBehavior.prototype + * @param obj + */ + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.PathBehavior.superclass.parse.call(this,obj); + + if ( obj.SVG ) { + var parser= new CAAT.PathUtil.SVGPath(); + var path=parser.parsePath( obj.SVG ); + this.setValues(path); + } + + if ( obj.autoRotate ) { + this.autoRotate= obj.autoRotate; + } + }, + + /** + * A path to traverse. + * @type {CAAT.PathUtil.Path} + * @private + */ + path:null, + + /** + * Whether to set rotation angle while traversing the path. + * @private + */ + autoRotate:false, + + prevX:-1, // private, do not use. + prevY:-1, // private, do not use. + + /** + * Autorotation hint. + * @type {CAAT.Behavior.PathBehavior.autorotate} + * @private + */ + autoRotateOp: CAAT.Behavior.PathBehavior.autorotate.FREE, + + isOpenContour : false, + + relativeX : 0, + relativeY : 0, + + setOpenContour : function(b) { + this.isOpenContour= b; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "translate"; + }, + + setRelativeValues : function( x, y ) { + this.relativeX= x; + this.relativeY= y; + this.isRelative= true; + return this; + }, + + + /** + * Sets an actor rotation to be heading from past to current path's point. + * Take into account that this will be incompatible with rotation Behaviors + * since they will set their own rotation configuration. + * @param autorotate {boolean} + * @param autorotateOp {CAAT.PathBehavior.autorotate} whether the sprite is drawn heading to the right. + * @return this. + */ + setAutoRotate:function (autorotate, autorotateOp) { + this.autoRotate = autorotate; + if (autorotateOp !== undefined) { + this.autoRotateOp = autorotateOp; + } + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * + * @deprecated + */ + setPath:function (path) { + this.path = path; + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * @return this + */ + setValues:function (path) { + return this.setPath(path); + }, + + /** + * @see Actor.setPositionAnchor + * @deprecated + * @param tx a float with xoffset. + * @param ty a float with yoffset. + */ + setTranslation:function (tx, ty) { + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + return "translateX(" + point.x + "px) translateY(" + point.y + "px)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + var obj= { + x : point.x, + y : point.y + }; + + if ( this.autoRotate ) { + + var point2= time===0 ? point : this.path.getPosition(time -.001); + var ax = point.x - point2.x; + var ay = point.y - point2.y; + var angle = Math.atan2(ay, ax); + + obj.angle= angle; + } + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var time; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + if (!this.path) { + return { + x:actor.x, + y:actor.y + }; + } + + var point = this.path.getPosition(time, this.isOpenContour,.001); + if (this.isRelative ) { + point.x+= this.relativeX; + point.y+= this.relativeY; + } + + if (this.autoRotate) { + + if (-1 === this.prevX && -1 === this.prevY) { + this.prevX = point.x; + this.prevY = point.y; + } + + var ax = point.x - this.prevX; + var ay = point.y - this.prevY; + + if (ax === 0 && ay === 0) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } + + var angle = Math.atan2(ay, ax); + var si = CAAT.Foundation.SpriteImage; + var pba = CAAT.Behavior.PathBehavior.AUTOROTATE; + + // actor is heading left to right + if (this.autoRotateOp === pba.LEFT_TO_RIGHT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_NONE); + } + else { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + angle += Math.PI; + } + } else if (this.autoRotateOp === pba.RIGHT_TO_LEFT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + } + else { + actor.setImageTransformation(si.TR_NONE); + angle -= Math.PI; + } + } + + actor.setRotation(angle); + + this.prevX = point.x; + this.prevY = point.y; + + var modulo = Math.sqrt(ax * ax + ay * ay); + ax /= modulo; + ay /= modulo; + } + + if (this.doValueApplication) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } else { + return { + x:point.x, + y:point.y + }; + } + + + }, + + /** + * Get a point on the path. + * If the time to get the point at is in behaviors frame time, a point on the path will be returned, otherwise + * a default {x:-1, y:-1} point will be returned. + * + * @param time {number} the time at which the point will be taken from the path. + * @return {object} an object of the form {x:float y:float} + */ + positionOnTime:function (time) { + if (this.isBehaviorInTime(time, null)) { + time = this.normalizeTime(time); + return this.path.getPosition(time); + } + + return {x:-1, y:-1}; + + } + }; + } +}); +CAAT.Module({ + + /** + * @name RotateBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.RotateBehavior", + extendsClass: "CAAT.Behavior.BaseBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.RotateBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.RotateBehavior.prototype + */ + + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.RotateBehavior.superclass.parse.call(this,obj); + this.startAngle= obj.start || 0; + this.endAngle= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * Start rotation angle. + * @type {number} + * @private + */ + startAngle:0, + + /** + * End rotation angle. + * @type {number} + * @private + */ + endAngle:0, + + /** + * Rotation X anchor. + * @type {number} + * @private + */ + anchorX:.50, + + /** + * Rotation Y anchor. + * @type {number} + * @private + */ + anchorY:.50, + + rotationRelative: 0, + + setRelativeValues : function(r) { + this.rotationRelative= r; + this.isRelative= true; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "rotate"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var angle = this.startAngle + time * (this.endAngle - this.startAngle); + + if ( this.isRelative ) { + angle+= this.rotationRelative; + if (angle>=Math.PI) { + angle= (angle-2*Math.PI) + } + if ( angle<-2*Math.PI) { + angle= (angle+2*Math.PI); + } + } + + if (this.doValueApplication) { + actor.setRotationAnchored(angle, this.anchorX, this.anchorY); + } + + return angle; + + }, + + /** + * Set behavior bound values. + * if no anchorx,anchory values are supplied, the behavior will assume + * 50% for both values, that is, the actor's center. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startAngle {float} indicating the starting angle. + * @param endAngle {float} indicating the ending angle. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + */ + setValues:function (startAngle, endAngle, anchorx, anchory) { + this.startAngle = startAngle; + this.endAngle = endAngle; + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + return this; + }, + + /** + * @deprecated + * Use setValues instead + * @param start + * @param end + */ + setAngles:function (start, end) { + return this.setValues(start, end); + }, + + /** + * Set the behavior rotation anchor. Use this method when setting an exact percent + * by calling setValues is complicated. + * @see CAAT.Actor + * + * These parameters are to set a custom rotation anchor point. if anchor==CAAT.Actor.ANCHOR_CUSTOM + * the custom rotation point is set. + * @param actor + * @param rx + * @param ry + * + */ + setAnchor:function (actor, rx, ry) { + this.anchorX = rx / actor.width; + this.anchorY = ry / actor.height; + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + return "rotate(" + (this.startAngle + time * (this.endAngle - this.startAngle)) + "rad)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + angle : this.startAngle + time * (this.endAngle - this.startAngle) + }; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + + }; + + } +}); +CAAT.Module({ + /** + * @name Scale1Behavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * @name AXIS + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + */ + + /** + * @name Axis + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + * @deprecated + */ + + + defines:"CAAT.Behavior.Scale1Behavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.Scale1Behavior"], + constants : { + + AXIS : { + /** + * @lends CAAT.Behavior.Scale1Behavior.AXIS + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + }, + + Axis : { + /** + * @lends CAAT.Behavior.Scale1Behavior.Axis + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + } + }, + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Scale1Behavior.prototype + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start scale value. + * @private + */ + startScale:1, + + /** + * End scale value. + * @private + */ + endScale:1, + + /** + * Scale X anchor. + * @private + */ + anchorX:.50, + + /** + * Scale Y anchor. + * @private + */ + anchorY:.50, + + /** + * Apply on Axis X or Y ? + */ + applyOnX:true, + + parse : function( obj ) { + CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,obj); + this.startScale= obj.start || 0; + this.endScale= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + this.applyOnX= obj.axis ? obj.axis.toLowerCase()==="x" : true; + }, + + /** + * @param axis {CAAT.Behavior.Scale1Behavior.AXIS} + */ + applyOnAxis:function (axis) { + if (axis === CAAT.Behavior.Scale1Behavior.AXIS.X) { + this.applyOnX = false; + } else { + this.applyOnX = true; + } + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + var scale = this.startScale + time * (this.endScale - this.startScale); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scale) { + scale = 0.01; + } + + if (this.doValueApplication) { + if (this.applyOnX) { + actor.setScaleAnchored(scale, actor.scaleY, this.anchorX, this.anchorY); + } else { + actor.setScaleAnchored(actor.scaleX, scale, this.anchorX, this.anchorY); + } + } + + return scale; + }, + + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param start {number} initial X axis scale value. + * @param end {number} final X axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (start, end, applyOnX, anchorx, anchory) { + this.startScale = start; + this.endScale = end; + this.applyOnX = !!applyOnX; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scale; + + time = this.interpolator.getPosition(time).y; + scale = this.startScale + time * (this.endScale - this.startScale); + + return this.applyOnX ? "scaleX(" + scale + ")" : "scaleY(" + scale + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var obj= {}; + obj[ this.applyOnX ? "scaleX" : "scaleY" ]= this.startScale + time * (this.endScale - this.startScale); + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); +CAAT.Module({ + + /** + * @name ScaleBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.ScaleBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + extendsClass:"CAAT.Behavior.BaseBehavior", + aliases : ["CAAT.ScaleBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.ScaleBehavior + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start X scale value. + * @private + * @type {number} + */ + startScaleX:1, + + /** + * End X scale value. + * @private + * @type {number} + */ + endScaleX:1, + + /** + * Start Y scale value. + * @private + * @type {number} + */ + startScaleY:1, + + /** + * End Y scale value. + * @private + * @type {number} + */ + endScaleY:1, + + /** + * Scale X anchor value. + * @private + * @type {number} + */ + anchorX:.50, + + /** + * Scale Y anchor value. + * @private + * @type {number} + */ + anchorY:.50, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,obj); + this.startScaleX= (obj.scaleX && obj.scaleX.start) || 0; + this.endScaleX= (obj.scaleX && obj.scaleX.end) || 0; + this.startScaleY= (obj.scaleY && obj.scaleY.start) || 0; + this.endScaleY= (obj.scaleY && obj.scaleY.end) || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * Applies corresponding scale values for a given time. + * + * @param time the time to apply the scale for. + * @param actor the target actor to Scale. + * @return {object} an object of the form { scaleX: {float}, scaleY: {float}�} + */ + setForTime:function (time, actor) { + + var scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + var scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scaleX) { + scaleX = 0.01; + } + if (0 === scaleY) { + scaleY = 0.01; + } + + if (this.doValueApplication) { + actor.setScaleAnchored(scaleX, scaleY, this.anchorX, this.anchorY); + } + + return { scaleX:scaleX, scaleY:scaleY }; + }, + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startX {number} initial X axis scale value. + * @param endX {number} final X axis scale value. + * @param startY {number} initial Y axis scale value. + * @param endY {number} final Y axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (startX, endX, startY, endY, anchorx, anchory) { + this.startScaleX = startX; + this.endScaleX = endX; + this.startScaleY = startY; + this.endScaleY = endY; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scaleX; + var scaleY; + + time = this.interpolator.getPosition(time).y; + scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + return "scale(" + scaleX +"," + scaleY + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + scaleX : this.startScaleX + time * (this.endScaleX - this.startScaleX), + scaleY : this.startScaleY + time * (this.endScaleY - this.startScaleY) + }; + }, + + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); +/** + * + * taken from: http://www.quirksmode.org/js/detect.html + * + * 20101008 Hyperandroid. IE9 seems to identify himself as Explorer and stopped calling himself MSIE. + * Added Explorer description to browser list. Thanks @alteredq for this tip. + * + */ +CAAT.Module({ + + /** + * @name Runtime + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name BrowserInfo + * @memberOf CAAT.Module.Runtime + * @namespace + */ + + defines:"CAAT.Module.Runtime.BrowserInfo", + + constants: function() { + + /** + * @lends CAAT.Module.Runtime.BrowserInfo + */ + + function searchString(data) { + for (var i = 0; i < data.length; i++) { + var dataString = data[i].string; + var dataProp = data[i].prop; + this.versionSearchString = data[i].versionSearch || data[i].identity; + if (dataString) { + if (dataString.indexOf(data[i].subString) !== -1) + return data[i].identity; + } + else if (dataProp) + return data[i].identity; + } + } + + function searchVersion(dataString) { + var index = dataString.indexOf(this.versionSearchString); + if (index === -1) return; + return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); + } + + var dataBrowser= [ + { + string:navigator.userAgent, + subString:"Chrome", + identity:"Chrome" + }, + { string:navigator.userAgent, + subString:"OmniWeb", + versionSearch:"OmniWeb/", + identity:"OmniWeb" + }, + { + string:navigator.vendor, + subString:"Apple", + identity:"Safari", + versionSearch:"Version" + }, + { + prop:window.opera, + identity:"Opera" + }, + { + string:navigator.vendor, + subString:"iCab", + identity:"iCab" + }, + { + string:navigator.vendor, + subString:"KDE", + identity:"Konqueror" + }, + { + string:navigator.userAgent, + subString:"Firefox", + identity:"Firefox" + }, + { + string:navigator.vendor, + subString:"Camino", + identity:"Camino" + }, + { // for newer Netscapes (6+) + string:navigator.userAgent, + subString:"Netscape", + identity:"Netscape" + }, + { + string:navigator.userAgent, + subString:"MSIE", + identity:"Explorer", + versionSearch:"MSIE" + }, + { + string:navigator.userAgent, + subString:"Explorer", + identity:"Explorer", + versionSearch:"Explorer" + }, + { + string:navigator.userAgent, + subString:"Gecko", + identity:"Mozilla", + versionSearch:"rv" + }, + { // for older Netscapes (4-) + string:navigator.userAgent, + subString:"Mozilla", + identity:"Netscape", + versionSearch:"Mozilla" + } + ]; + + var dataOS=[ + { + string:navigator.platform, + subString:"Win", + identity:"Windows" + }, + { + string:navigator.platform, + subString:"Mac", + identity:"Mac" + }, + { + string:navigator.userAgent, + subString:"iPhone", + identity:"iPhone/iPod" + }, + { + string:navigator.platform, + subString:"Linux", + identity:"Linux" + } + ]; + + var browser = searchString(dataBrowser) || "An unknown browser"; + var version = searchVersion(navigator.userAgent) || + searchVersion(navigator.appVersion) || + "an unknown version"; + var OS = searchString(dataOS) || "an unknown OS"; + + var DevicePixelRatio = window.devicePixelRatio || 1; + + return { + browser: browser, + version: version, + OS: OS, + DevicePixelRatio : DevicePixelRatio + } + + } +}); +/** + * See LICENSE file. + * + * Sound implementation. + */ + +CAAT.Module({ + + /** + * @name Module + * @memberOf CAAT + * @namespace + */ + + /** + * @name Audio + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name AudioManager + * @memberOf CAAT.Module.Audio + * @constructor + */ + + defines:"CAAT.Module.Audio.AudioManager", + extendsWith:function () { + return { + + /** + * @lends CAAT.Module.Audio.AudioManager.prototype + */ + + __init:function () { + this.isFirefox= navigator.userAgent.match(/Firefox/g)!==null; + return this; + }, + + isFirefox : false, + + /** + * The only background music audio channel. + */ + musicChannel: null, + + /** + * Is music enabled ? + */ + musicEnabled:true, + + /** + * Are FX sounds enabled ? + */ + fxEnabled:true, + + /** + * A collection of Audio objects. + */ + audioCache:null, + + /** + * A cache of empty Audio objects. + */ + channels:null, + + /** + * Currently used Audio objects. + */ + workingChannels:null, + + /** + * Currently looping Audio objects. + */ + loopingChannels:[], + + /** + * available formats for audio elements. + * the system will load audio files with the extensions in this preferred order. + */ + audioFormatExtensions : [ + 'ogg', + 'wav', + 'x-wav', + 'mp3' + ], + + currentAudioFormatExtension : 'ogg', + + /** + * Audio formats. + * @dict + */ + audioTypes:{ // supported audio formats. Don't remember where i took them from :S + 'ogg': 'audio/ogg', + 'mp3': 'audio/mpeg;', + 'wav': 'audio/wav', + 'x-wav':'audio/x-wav', + 'mp4': 'audio/mp4"' + }, + + /** + * Initializes the sound subsystem by creating a fixed number of Audio channels. + * Every channel registers a handler for sound playing finalization. If a callback is set, the + * callback function will be called with the associated sound id in the cache. + * + * @param numChannels {number} number of channels to pre-create. 8 by default. + * + * @return this. + */ + initialize:function (numChannels ) { + + this.setAudioFormatExtensions( this.audioFormatExtensions ); + + this.audioCache = []; + this.channels = []; + this.workingChannels = []; + + for (var i = 0; i <= numChannels; i++) { + var channel = document.createElement('audio'); + + if (null !== channel) { + channel.finished = -1; + this.channels.push(channel); + var me = this; + channel.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + var i; + + // remove from workingChannels + for (i = 0; i < me.workingChannels.length; i++) { + if (me.workingChannels[i] === target) { + me.workingChannels.splice(i, 1); + break; + } + } + + if (target.caat_callback) { + target.caat_callback(target.caat_id); + } + + // set back to channels. + me.channels.push(target); + }, + false + ); + } + } + + this.musicChannel= this.channels.pop(); + + return this; + }, + + setAudioFormatExtensions : function( formats ) { + this.audioFormatExtensions= formats; + this.__setCurrentAudioFormatExtension(); + return this; + }, + + __setCurrentAudioFormatExtension : function( ) { + + var audio= new Audio(); + + for( var i= 0, l=this.audioFormatExtensions.length; i + * The audio element can be one of the two forms: + * + *

      + *
    1. Either an HTMLAudioElement/Audio object or a string url. + *
    2. An array of elements of the previous form. + *
    + * + *

    + * When the audio attribute is an array, this function will iterate throught the array elements + * until a suitable audio element to be played is found. When this is the case, the other array + * elements won't be taken into account. The valid form of using this addAudio method will be: + * + *

    + * 1.
    + * addAudio( id, url } ). In this case, if the resource pointed by url is + * not suitable to be played (i.e. a call to the Audio element's canPlayType method return 'no') + * no resource will be added under such id, so no sound will be played when invoking the play(id) + * method. + *

    + * 2.
    + * addAudio( id, dom_audio_tag ). In this case, the same logic than previous case is applied, but + * this time, the parameter url is expected to be an audio tag present in the html file. + *

    + * 3.
    + * addAudio( id, [array_of_url_or_domaudiotag] ). In this case, the function tries to locate a valid + * resource to be played in any of the elements contained in the array. The array element's can + * be any type of case 1 and 2. As soon as a valid resource is found, it will be associated to the + * id in the valid audio resources to be played list. + * + * @return this + */ + addAudio:function (id, array_of_url_or_domnodes, endplaying_callback) { + + if (array_of_url_or_domnodes instanceof Array) { + /* + iterate throught array elements until we can safely add an audio element. + */ + for (var i = 0; i < array_of_url_or_domnodes.length; i++) { + if (this.addAudioElement(id, array_of_url_or_domnodes[i], endplaying_callback)) { + break; + } + } + } else { + this.addAudioElement(id, array_of_url_or_domnodes, endplaying_callback); + } + + return this; + }, + /** + * Returns an audio object. + * @param aId {object} the id associated to the target Audio object. + * @return {object} the HTMLAudioElement addociated to the given id. + */ + getAudio:function (aId) { + for (var i = 0; i < this.audioCache.length; i++) { + if (this.audioCache[i].id === aId) { + return this.audioCache[i].audio; + } + } + + return null; + }, + + stopMusic : function() { + this.musicChannel.pause(); + }, + + playMusic : function(id) { + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio =this.musicChannel; + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, restart music. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + return audio; + } + } + + return this.musicChannel; + }, + + /** + * Set an audio object volume. + * @param id {object} an audio Id + * @param volume {number} volume to set. The volume value is not checked. + * + * @return this + */ + setVolume:function (id, volume) { + var audio = this.getAudio(id); + if (null != audio) { + audio.volume = volume; + } + + return this; + }, + + /** + * Plays an audio file from the cache if any sound channel is available. + * The playing sound will occupy a sound channel and when ends playing will leave + * the channel free for any other sound to be played in. + * @param id {object} an object identifying a sound in the sound cache. + * @return { id: {Object}, audio: {(Audio|HTMLAudioElement)} } + */ + play:function (id) { + if (!this.fxEnabled) { + return null; + } + + var audio = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio && this.channels.length > 0) { + var channel = this.channels.shift(); + channel.src = audio.src; +// channel.load(); + channel.volume = audio.volume; + channel.play(); + this.workingChannels.push(channel); + } else { + console.log("Can't play audio: "+id); + } + + return audio; + }, + + /** + * cancel all instances of a sound identified by id. This id is the value set + * to identify a sound. + * @param id + * @return {*} + */ + cancelPlay : function(id) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + var audio= this.workingChannels[i]; + if ( audio.caat_id===id ) { + audio.pause(); + this.channels.push(audio); + this.workingChannels.splice(i,1); + } + } + + return this; + }, + + /** + * cancel a channel sound + * @param audioObject + * @return {*} + */ + cancelPlayByChannel : function(audioObject) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + if ( this.workingChannels[i]===audioObject ) { + this.channels.push(audioObject); + this.workingChannels.splice(i,1); + return this; + } + } + + return this; + }, + + /** + * This method creates a new AudioChannel to loop the sound with. + * It returns an Audio object so that the developer can cancel the sound loop at will. + * The user must call pause() method to stop playing a loop. + *

    + * Firefox does not honor the loop property, so looping is performed by attending end playing + * event on audio elements. + * + * @return {HTMLElement} an Audio instance if a valid sound id is supplied. Null otherwise + */ + loop:function (id) { + + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio = document.createElement('audio'); + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + this.loopingChannels.push(audio); + return audio; + } + } + + return null; + }, + /** + * Cancel all playing audio channels + * Get back the playing channels to available channel list. + * + * @return this + */ + endSound:function () { + var i; + for (i = 0; i < this.workingChannels.length; i++) { + this.workingChannels[i].pause(); + this.channels.push(this.workingChannels[i]); + } + + for (i = 0; i < this.loopingChannels.length; i++) { + this.loopingChannels[i].pause(); + } + + this.workingChannels= []; + this.loopingChannels= []; + + this.stopMusic(); + + return this; + }, + setSoundEffectsEnabled:function (enable) { + this.fxEnabled = enable; + for (var i = 0; i < this.loopingChannels.length; i++) { + if (enable) { + this.loopingChannels[i].play(); + } else { + this.loopingChannels[i].pause(); + } + } + return this; + }, + isSoundEffectsEnabled:function () { + return this.fxEnabled; + }, + setMusicEnabled:function (enable) { + this.musicEnabled = enable; + this.stopMusic(); + return this; + }, + isMusicEnabled:function () { + return this.musicEnabled; + } + } + } +}); +/** + * See LICENSE file. + * + **/ +CAAT.Module({ + + /** + * @name Storage + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name LocalStorage + * @memberOf CAAT.Module.Storage + * @namespace + */ + + defines : "CAAT.Module.Storage.LocalStorage", + constants : { + + /** + * @lends CAAT.Module.Storage.LocalStorage + */ + + /** + * Stores an object in local storage. The data will be saved as JSON.stringify. + * @param key {string} key to store data under. + * @param data {object} an object. + * @return this + * + * @static + */ + save : function( key, data ) { + try { + localStorage.setItem( key, JSON.stringify(data) ); + } catch(e) { + // eat it + } + return this; + }, + /** + * Retrieve a value from local storage. + * @param key {string} the key to retrieve. + * @return {object} object stored under the key parameter. + * + * @static + */ + load : function( key, defValue ) { + try { + var v= localStorage.getItem( key ); + + return null===v ? defValue : JSON.parse(v); + } catch(e) { + return null; + } + }, + + /** + * Removes a value stored in local storage. + * @param key {string} + * @return this + * + * @static + */ + remove : function( key ) { + try { + localStorage.removeItem(key); + } catch(e) { + // eat it + } + return this; + } + }, + extendsWith : { + + } + +}); +/** + * See LICENSE file. + * + * @author: Mario Gonzalez (@onedayitwilltake) and Ibon Tolosana (@hyperandroid) + * + * Helper classes for color manipulation. + * + **/ + +CAAT.Module({ + + /** + * @name ColorUtil + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Color + * @memberOf CAAT.Module.ColorUtil + * @namespace + */ + + + defines:"CAAT.Module.ColorUtil.Color", + depends:[ + ], + constants:{ + + /** + * @lends CAAT.Module.ColorUtil.Color + */ + + /** + * Enumeration to define types of color ramps. + * @enum {number} + */ + RampEnumeration:{ + RAMP_RGBA:0, + RAMP_RGB:1, + RAMP_CHANNEL_RGB:2, + RAMP_CHANNEL_RGBA:3, + RAMP_CHANNEL_RGB_ARRAY:4, + RAMP_CHANNEL_RGBA_ARRAY:5 + }, + + /** + * HSV to RGB color conversion + *

    + * H runs from 0 to 360 degrees
    + * S and V run from 0 to 100 + *

    + * Ported from the excellent java algorithm by Eugene Vishnevsky at: + * http://www.cs.rit.edu/~ncs/color/t_convert.html + * + * @static + */ + hsvToRgb:function (h, s, v) { + var r, g, b, i, f, p, q, t; + + // Make sure our arguments stay in-range + h = Math.max(0, Math.min(360, h)); + s = Math.max(0, Math.min(100, s)); + v = Math.max(0, Math.min(100, v)); + + // We accept saturation and value arguments from 0 to 100 because that's + // how Photoshop represents those values. Internally, however, the + // saturation and value are calculated from a range of 0 to 1. We make + // That conversion here. + s /= 100; + v /= 100; + + if (s === 0) { + // Achromatic (grey) + r = g = b = v; + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + } + + h /= 60; // sector 0 to 5 + i = Math.floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch (i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + default: // case 5: + r = v; + g = p; + b = q; + } + + return new CAAT.Module.ColorUtil.Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); + }, + + /** + * Interpolate the color between two given colors. The return value will be a calculated color + * among the two given initial colors which corresponds to the 'step'th color of the 'nsteps' + * calculated colors. + * @param r0 {number} initial color red component. + * @param g0 {number} initial color green component. + * @param b0 {number} initial color blue component. + * @param r1 {number} final color red component. + * @param g1 {number} final color green component. + * @param b1 {number} final color blue component. + * @param nsteps {number} number of colors to calculate including the two given colors. If 16 is passed as value, + * 14 colors plus the two initial ones will be calculated. + * @param step {number} return this color index of all the calculated colors. + * + * @return { {r{number}, g{number}, b{number}} } return an object with the new calculated color components. + * @static + */ + interpolate:function (r0, g0, b0, r1, g1, b1, nsteps, step) { + + var r, g, b; + + if (step <= 0) { + return { + r:r0, + g:g0, + b:b0 + }; + } else if (step >= nsteps) { + return { + r:r1, + g:g1, + b:b1 + }; + } + + r = (r0 + (r1 - r0) / nsteps * step) >> 0; + g = (g0 + (g1 - g0) / nsteps * step) >> 0; + b = (b0 + (b1 - b0) / nsteps * step) >> 0; + + if (r > 255) { + r = 255; + } else if (r < 0) { + r = 0; + } + if (g > 255) { + g = 255; + } else if (g < 0) { + g = 0; + } + if (b > 255) { + b = 255; + } else if (b < 0) { + b = 0; + } + + return { + r:r, + g:g, + b:b + }; + }, + + /** + * Generate a ramp of colors from an array of given colors. + * @param fromColorsArray {[number]} an array of colors. each color is defined by an integer number from which + * color components will be extracted. Be aware of the alpha component since it will also be interpolated for + * new colors. + * @param rampSize {number} number of colors to produce. + * @param returnType {CAAT.ColorUtils.RampEnumeration} a value of CAAT.ColorUtils.RampEnumeration enumeration. + * + * @return { [{number},{number},{number},{number}] } an array of integers each of which represents a color of + * the calculated color ramp. + * + * @static + */ + makeRGBColorRamp:function (fromColorsArray, rampSize, returnType) { + + var ramp = [], nc = fromColorsArray.length - 1, chunk = rampSize / nc, i, j, + na, nr, ng, nb, + c, a0, r0, g0, b0, + c1, a1, r1, g1, b1, + da, dr, dg, db; + + for (i = 0; i < nc; i += 1) { + c = fromColorsArray[i]; + a0 = (c >> 24) & 0xff; + r0 = (c & 0xff0000) >> 16; + g0 = (c & 0xff00) >> 8; + b0 = c & 0xff; + + c1 = fromColorsArray[i + 1]; + a1 = (c1 >> 24) & 0xff; + r1 = (c1 & 0xff0000) >> 16; + g1 = (c1 & 0xff00) >> 8; + b1 = c1 & 0xff; + + da = (a1 - a0) / chunk; + dr = (r1 - r0) / chunk; + dg = (g1 - g0) / chunk; + db = (b1 - b0) / chunk; + + for (j = 0; j < chunk; j += 1) { + na = (a0 + da * j) >> 0; + nr = (r0 + dr * j) >> 0; + ng = (g0 + dg * j) >> 0; + nb = (b0 + db * j) >> 0; + + var re = CAAT.Module.ColorUtil.Color.RampEnumeration; + + switch (returnType) { + case re.RAMP_RGBA: + ramp.push('argb(' + na + ',' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_RGB: + ramp.push('rgb(' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_CHANNEL_RGB: + ramp.push(0xff000000 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA: + ramp.push(na << 24 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA_ARRAY: + ramp.push([ nr, ng, nb, na ]); + break; + case re.RAMP_CHANNEL_RGB_ARRAY: + ramp.push([ nr, ng, nb ]); + break; + } + } + } + + return ramp; + + }, + + random:function () { + var a = '0123456789abcdef'; + var c = '#'; + for (var i = 0; i < 3; i++) { + c += a[ (Math.random() * a.length) >> 0 ]; + } + return c; + } + }, + + extendsWith:{ + __init:function (r, g, b) { + this.r = r || 255; + this.g = g || 255; + this.b = b || 255; + return this; + }, + + r:255, + g:255, + b:255, + + /** + * Get color hexadecimal representation. + * @return {string} a string with color hexadecimal representation. + */ + toHex:function () { + // See: http://jsperf.com/rgb-decimal-to-hex/5 + return ('000000' + ((this.r << 16) + (this.g << 8) + this.b).toString(16)).slice(-6); + } + } +}); +/** + * See LICENSE file. + * + * Get realtime Debug information of CAAT's activity. + * Set CAAT.DEBUG=1 before any CAAT.Director object creation. + * This class creates a DOM node called 'caat-debug' and associated styles + * The debug panel is minimized by default and shows short information. It can be expanded and minimized again by clicking on it + * + */ + +CAAT.Module( { + + /** + * @name Debug + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Debug + * @memberOf CAAT.Module.Debug + * @constructor + */ + + defines : "CAAT.Module.Debug.Debug", + depends : [ + "CAAT.Event.AnimationLoop" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Debug.Debug.prototype + */ + + width: 0, + height: 0, + canvas: null, + ctx: null, + statistics: null, + framerate: null, + textContainer: null, + textFPS: null, + textEntitiesTotal: null, + textEntitiesActive: null, + textDraws: null, + textDrawTime: null, + textRAFTime: null, + textDirtyRects: null, + textDiscardDR: null, + + frameTimeAcc : 0, + frameRAFAcc : 0, + + canDebug: false, + + SCALE: 60, + + debugTpl: + " "+ + "

    "+ + "
    "+ + " CAAT Debug panel "+ + " Performance"+ + " Controls"+ + " "+ + " "+ + " Draw Time: "+ + " 5.46"+ + " ms."+ + " "+ + " "+ + " "+ + " FPS: "+ + " 48"+ + " "+ + "
    "+ + "
    "+ + "
    "+ + " "+ + "
    "+ + " "+ + " "+ + " RAF Time:"+ + " 20.76"+ + " ms."+ + " "+ + " "+ + " "+ + " Entities Total: "+ + " 41"+ + " "+ + " "+ + " "+ + " Entities Active: "+ + " 37"+ + " "+ + " "+ + " "+ + " Draws: "+ + " 0"+ + " "+ + " "+ + " "+ + " DirtyRects: "+ + " 0"+ + " "+ + " "+ + " "+ + " Discard DR: "+ + " 0"+ + " "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + " "+ + " Sound"+ + "
    "+ + "
    "+ + " "+ + " Music"+ + "
    "+ + "
    "+ + " "+ + " AA Bounding Boxes"+ + "
    "+ + "
    "+ + " "+ + " Bounding Boxes"+ + "
    "+ + "
    "+ + " "+ + " Dirty Rects"+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    ", + + + setScale : function(s) { + this.scale= s; + return this; + }, + + initialize: function(w,h) { + w= window.innerWidth; + + this.width= w; + this.height= h; + + this.framerate = { + refreshInterval: CAAT.FPS_REFRESH || 500, // refresh every ? ms, updating too quickly gives too large rounding errors + frames: 0, // number offrames since last refresh + timeLastRefresh: 0, // When was the framerate counter refreshed last + fps: 0, // current framerate + prevFps: -1, // previously drawn FPS + fpsMin: 1000, // minimum measured framerate + fpsMax: 0 // maximum measured framerate + }; + + var debugContainer= document.getElementById('caat-debug'); + if (!debugContainer) { + var wrap = document.createElement('div'); + wrap.innerHTML=this.debugTpl; + document.body.appendChild(wrap); + + eval( ""+ + " var __x= CAAT;" + + " function initCheck( name, bool, callback ) {"+ + " var elem= document.getElementById(name);"+ + " if ( elem ) {"+ + " elem.className= (bool) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " if ( callback ) {"+ + " elem.addEventListener( \"click\", (function(elem, callback) {"+ + " return function(e) {"+ + " elem.__value= !elem.__value;"+ + " elem.className= (elem.__value) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " callback(e,elem.__value);"+ + " }"+ + " })(elem, callback), false );"+ + " }"+ + " elem.__value= bool;"+ + " }"+ + " }"+ + " function setupTabs() {"+ + " var numTabs=0;"+ + " var elem;"+ + " var elemContent;"+ + " do {"+ + " elem= document.getElementById(\"caat-debug-tab\"+numTabs);"+ + " if ( elem ) {"+ + " elemContent= document.getElementById(\"caat-debug-tab\"+numTabs+\"-content\");"+ + " if ( elemContent ) {"+ + " elemContent.style.display= numTabs===0 ? 'block' : 'none';"+ + " elem.className= numTabs===0 ? \"debug_tab debug_tab_selected\" : \"debug_tab debug_tab_not_selected\";"+ + " elem.addEventListener( \"click\", (function(tabIndex) {"+ + " return function(e) {"+ + " for( var i=0; i this.framerate.timeLastRefresh + this.framerate.refreshInterval ) { + this.framerate.fps = ( ( this.framerate.frames * 1000 ) / ( tt - this.framerate.timeLastRefresh ) ) | 0; + this.framerate.fpsMin = this.framerate.frames > 0 ? Math.min( this.framerate.fpsMin, this.framerate.fps ) : this.framerate.fpsMin; + this.framerate.fpsMax = Math.max( this.framerate.fpsMax, this.framerate.fps ); + + this.textFPS.innerHTML= this.framerate.fps; + + var value= ((this.frameTimeAcc*100/this.framerate.frames)|0)/100; + this.frameTimeAcc=0; + this.textDrawTime.innerHTML= value; + + var value2= ((this.frameRAFAcc*100/this.framerate.frames)|0)/100; + this.frameRAFAcc=0; + this.textRAFTime.innerHTML= value2; + + this.framerate.timeLastRefresh = tt; + this.framerate.frames = 0; + + this.paint(value2); + } + + this.textEntitiesTotal.innerHTML= this.statistics.size_total; + this.textEntitiesActive.innerHTML= this.statistics.size_active; + this.textDirtyRects.innerHTML= this.statistics.size_dirtyRects; + this.textDraws.innerHTML= this.statistics.draws; + this.textDiscardDR.innerHTML= this.statistics.size_discarded_by_dirty_rects; + }, + + paint : function( rafValue ) { + var ctx= this.ctx; + var t=0; + + ctx.drawImage( + this.canvas, + 1, 0, this.width-1, this.height, + 0, 0, this.width-1, this.height ); + + ctx.strokeStyle= 'black'; + ctx.beginPath(); + ctx.moveTo( this.width-.5, 0 ); + ctx.lineTo( this.width-.5, this.height ); + ctx.stroke(); + + ctx.strokeStyle= '#a22'; + ctx.beginPath(); + t= this.height-((20/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + ctx.strokeStyle= '#aa2'; + ctx.beginPath(); + t= this.height-((30/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + var fps = Math.min( this.height-(this.framerate.fps/this.SCALE*this.height), 59 ); + if (-1===this.framerate.prevFps) { + this.framerate.prevFps= fps|0; + } + + ctx.strokeStyle= '#0ff';//this.framerate.fps<15 ? 'red' : this.framerate.fps<30 ? 'yellow' : 'green'; + ctx.beginPath(); + ctx.moveTo( this.width, (fps|0)-.5 ); + ctx.lineTo( this.width, this.framerate.prevFps-.5 ); + ctx.stroke(); + + this.framerate.prevFps= fps; + + + var t1= ((this.height-(rafValue/this.SCALE*this.height))>>0)-.5; + ctx.strokeStyle= '#ff0'; + ctx.beginPath(); + ctx.moveTo( this.width, t1 ); + ctx.lineTo( this.width, t1 ); + ctx.stroke(); + } + } + +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Font + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Font + * @memberOf CAAT.Module.Font + * @constructor + */ + + defines : "CAAT.Module.Font.Font", + aliases : "CAAT.Font", + depends : [ + "CAAT.Foundation.SpriteImage" + ], + constants: { + + /** + * @lends CAAT.Module.Font.Font + */ + + getFontMetrics:function (font) { + var ret; + if (CAAT.CSS_TEXT_METRICS) { + try { + ret = CAAT.Module.Font.Font.getFontMetricsCSS(font); + return ret; + } catch (e) { + + } + } + + return CAAT.Module.Font.Font.getFontMetricsNoCSS(font); + }, + + getFontMetricsNoCSS:function (font) { + + var re = /(\d+)p[x|t]\s*/i; + var res = re.exec(font); + + var height; + + if (!res) { + height = 32; // no px or pt value in font. assume 32.) + } else { + height = res[1] | 0; + } + + var ascent = height - 1; + var h = (height + height * .2) | 0; + return { + height:h, + ascent:ascent, + descent:h - ascent + } + + }, + + /** + * Totally ripped from: + * + * jQuery (offset function) + * Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas + * + * @param font + * @return {*} + */ + getFontMetricsCSS:function (font) { + + function offset(elem) { + + var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left; + var doc = elem && elem.ownerDocument; + docElem = doc.documentElement; + + box = elem.getBoundingClientRect(); + //win = getWindow( doc ); + + body = document.body; + win = doc.nodeType === 9 ? doc.defaultView || doc.parentWindow : false; + + clientTop = docElem.clientTop || body.clientTop || 0; + clientLeft = docElem.clientLeft || body.clientLeft || 0; + scrollTop = win.pageYOffset || docElem.scrollTop; + scrollLeft = win.pageXOffset || docElem.scrollLeft; + top = box.top + scrollTop - clientTop; + left = box.left + scrollLeft - clientLeft; + + return { top:top, left:left }; + } + + try { + var text = document.createElement("span"); + text.style.font = font; + text.innerHTML = "Hg"; + + var block = document.createElement("div"); + block.style.display = "inline-block"; + block.style.width = "1px"; + block.style.heigh = "0px"; + + var div = document.createElement("div"); + div.appendChild(text); + div.appendChild(block); + + + var body = document.body; + body.appendChild(div); + + try { + + var result = {}; + + block.style.verticalAlign = 'baseline'; + result.ascent = offset(block).top - offset(text).top; + + block.style.verticalAlign = 'bottom'; + result.height = offset(block).top - offset(text).top; + + result.ascent = Math.ceil(result.ascent); + result.height = Math.ceil(result.height); + + result.descent = result.height - result.ascent; + + return result; + + } finally { + body.removeChild(div); + } + } catch (e) { + return null; + } + } + }, + extendsWith:function () { + + var UNKNOWN_CHAR_WIDTH = 10; + + return { + + /** + * @lends CAAT.Module.Font.Font.prototype + */ + + fontSize:10, + fontSizeUnit:"px", + font:'Sans-Serif', + fontStyle:'', + fillStyle:'#fff', + strokeStyle:null, + strokeSize:1, + padding:0, + image:null, + charMap:null, + + height:0, + ascent:0, + descent:0, + + setPadding:function (padding) { + this.padding = padding; + return this; + }, + + setFontStyle:function (style) { + this.fontStyle = style; + return this; + }, + + setStrokeSize:function (size) { + this.strokeSize = size; + return this; + }, + + setFontSize:function (fontSize) { + this.fontSize = fontSize; + this.fontSizeUnit = 'px'; + return this; + }, + + setFont:function (font) { + this.font = font; + return this; + }, + + setFillStyle:function (style) { + this.fillStyle = style; + return this; + }, + + setStrokeStyle:function (style) { + this.strokeStyle = style; + return this; + }, + + createDefault:function (padding) { + var str = ""; + for (var i = 32; i < 128; i++) { + str = str + String.fromCharCode(i); + } + + return this.create(str, padding); + }, + + create:function (chars, padding) { + + padding = padding | 0; + this.padding = padding; + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + ctx.textBaseline = 'bottom'; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + + var textWidth = 0; + var charWidth = []; + var i; + var x; + var cchar; + + for (i = 0; i < chars.length; i++) { + var cw = Math.max(1, (ctx.measureText(chars.charAt(i)).width >> 0) + 1) + 2 * padding; + charWidth.push(cw); + textWidth += cw; + } + + + var fontMetrics = CAAT.Font.getFontMetrics(ctx.font); + var baseline = "alphabetic", yoffset, canvasheight; + + canvasheight = fontMetrics.height; + this.ascent = fontMetrics.ascent; + this.descent = fontMetrics.descent; + this.height = fontMetrics.height; + yoffset = fontMetrics.ascent; + + canvas.width = textWidth; + canvas.height = canvasheight; + ctx = canvas.getContext('2d'); + + //ctx.textBaseline= 'bottom'; + ctx.textBaseline = baseline; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + ctx.fillStyle = this.fillStyle; + ctx.strokeStyle = this.strokeStyle; + + this.charMap = {}; + + x = 0; + for (i = 0; i < chars.length; i++) { + cchar = chars.charAt(i); + ctx.fillText(cchar, x + padding, yoffset); + if (this.strokeStyle) { + ctx.beginPath(); + ctx.lineWidth = this.strokeSize; + ctx.strokeText(cchar, x + padding, yoffset); + } + this.charMap[cchar] = { + x:x + padding, + width:charWidth[i] - 2 * padding, + height: this.height + }; + x += charWidth[i]; + } + + this.image = canvas; + + return this; + }, + + setAsSpriteImage:function () { + var cm = []; + var _index = 0; + for (var i in this.charMap) { + var _char = i; + var charData = this.charMap[i]; + + cm[i] = { + id:_index++, + height:this.height, + xoffset:0, + letter:_char, + yoffset:0, + width:charData.width, + xadvance:charData.width, + x:charData.x, + y:0 + }; + } + + this.spriteImage = new CAAT.Foundation.SpriteImage().initializeAsGlyphDesigner(this.image, cm); + return this; + }, + + getAscent:function () { + return this.ascent; + }, + + getDescent:function () { + return this.descent; + }, + + stringHeight:function () { + return this.height; + }, + + getFontData:function () { + return { + height:this.height, + ascent:this.ascent, + descent:this.descent + }; + }, + + stringWidth:function (str) { + var i, l, w = 0, c; + + for (i = 0, l = str.length; i < l; i++) { + c = this.charMap[ str.charAt(i) ]; + if (c) { + w += c.width; + } else { + w += UNKNOWN_CHAR_WIDTH; + } + } + + return w; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + var height = this.image.height; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.charMap[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, 0, + w, height, + x, y, + w, height); + } + x += w; + } else { + ctx.strokeStyle = '#f00'; + ctx.strokeRect(x, y, UNKNOWN_CHAR_WIDTH, height); + x += UNKNOWN_CHAR_WIDTH; + } + } + }, + + save:function () { + var str = "image/png"; + var strData = this.image.toDataURL(str); + document.location.href = strData.replace(str, "image/octet-stream"); + }, + + drawSpriteText:function (director, time) { + this.spriteImage.drawSpriteText(director, time); + } + + } + } + +}); + +/** + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ + */ + +CAAT.Module({ + + /** + * @name CircleManager + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name PackedCircle + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + defines:"CAAT.Module.CircleManager.PackedCircle", + depends:[ + "CAAT.Module.CircleManager.PackedCircle", + "CAAT.Math.Point" + ], + constants:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle + */ + + /** @const */ BOUNDS_RULE_WRAP:1, // Wrap to otherside + /** @const */ BOUNDS_RULE_CONSTRAINT:2, // Constrain within bounds + /** @const */ BOUNDS_RULE_DESTROY:4, // Destroy when it reaches the edge + /** @const */ BOUNDS_RULE_IGNORE:8 // Ignore when reaching bounds + }, + extendsWith:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle.prototype + */ + + __init:function () { + this.boundsRule = CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE; + this.position = new CAAT.Math.Point(0, 0, 0); + this.offset = new CAAT.Math.Point(0, 0, 0); + this.targetPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * + */ + id:0, + + /** + * + */ + delegate:null, + + /** + * + */ + position:null, + + /** + * + */ + offset:null, + + /** + * + */ + targetPosition:null, // Where it wants to go + + /** + * + */ + targetChaseSpeed:0.02, + + /** + * + */ + isFixed:false, + + /** + * + */ + boundsRule:0, + + /** + * + */ + collisionMask:0, + + /** + * + */ + collisionGroup:0, + + containsPoint:function (aPoint) { + var distanceSquared = this.position.getDistanceSquared(aPoint); + return distanceSquared < this.radiusSquared; + }, + + getDistanceSquaredFromPosition:function (aPosition) { + var distanceSquared = this.position.getDistanceSquared(aPosition); + // if it's shorter than either radius, we intersect + return distanceSquared < this.radiusSquared; + }, + + intersects:function (aCircle) { + var distanceSquared = this.position.getDistanceSquared(aCircle.position); + return (distanceSquared < this.radiusSquared || distanceSquared < aCircle.radiusSquared); + }, + + /** + * ACCESSORS + */ + setPosition:function (aPosition) { + this.position = aPosition; + return this; + }, + + setDelegate:function (aDelegate) { + this.delegate = aDelegate; + return this; + }, + + setOffset:function (aPosition) { + this.offset = aPosition; + return this; + }, + + setTargetPosition:function (aTargetPosition) { + this.targetPosition = aTargetPosition; + return this; + }, + + setTargetChaseSpeed:function (aTargetChaseSpeed) { + this.targetChaseSpeed = aTargetChaseSpeed; + return this; + }, + + setIsFixed:function (value) { + this.isFixed = value; + return this; + }, + + setCollisionMask:function (aCollisionMask) { + this.collisionMask = aCollisionMask; + return this; + }, + + setCollisionGroup:function (aCollisionGroup) { + this.collisionGroup = aCollisionGroup; + return this; + }, + + setRadius:function (aRadius) { + this.radius = aRadius; + this.radiusSquared = this.radius * this.radius; + return this; + }, + + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + + dealloc:function () { + this.position = null; + this.offset = null; + this.delegate = null; + this.targetPosition = null; + } + } +}); +/** + * + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ +*/ + +CAAT.Module( { + + + /** + * @name PackedCircleManager + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + + defines : "CAAT.Module.CircleManager.PackedCircleManager", + depends : [ + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.CircleManager.PackedCircleManager.prototype + * @private + */ + + __init : function() { + this.bounds= new CAAT.Math.Rectangle(); + }, + + /** + * + */ + allCircles: [], + + /** + * + */ + numberOfCollisionPasses: 1, + + /** + * + */ + numberOfTargetingPasses: 0, + + /** + * + */ + bounds: null, + + /** + * Adds a circle to the simulation + * @param aCircle + */ + addCircle: function(aCircle) + { + aCircle.id = this.allCircles.length; + this.allCircles.push(aCircle); + return this; + }, + + /** + * Removes a circle from the simulations + * @param aCircle Circle to remove + */ + removeCircle: function(aCircle) + { + var index = 0, + found = false, + len = this.allCircles.length; + + if(len === 0) { + throw "Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!"; + } + + while (len--) { + if(this.allCircles[len] === aCircle) { + found = true; + index = len; + break; + } + } + + if(!found) { + throw "Could not locate circle in allCircles array!"; + } + + // Remove + this.allCircles[index].dealloc(); + this.allCircles[index] = null; + + return this; + }, + + /** + * Forces all circles to move to where their delegate position is + * Assumes all targets have a 'position' property! + */ + forceCirclesToMatchDelegatePositions: function() + { + var len = this.allCircles.length; + + // push toward target position + for(var n = 0; n < len; n++) + { + var aCircle = this.allCircles[n]; + if(!aCircle || !aCircle.delegate) { + continue; + } + + aCircle.position.set(aCircle.delegate.x + aCircle.offset.x, + aCircle.delegate.y + aCircle.offset.y); + } + }, + + pushAllCirclesTowardTarget: function(aTarget) + { + var v = new CAAT.Math.Point(0,0,0), + circleList = this.allCircles, + len = circleList.length; + + // push toward target position + for(var n = 0; n < this.numberOfTargetingPasses; n++) + { + for(var i = 0; i < len; i++) + { + var c = circleList[i]; + + if(c.isFixed) continue; + + v.x = c.position.x - (c.targetPosition.x+c.offset.x); + v.y = c.position.y - (c.targetPosition.y+c.offset.y); + v.multiply(c.targetChaseSpeed); + + c.position.x -= v.x; + c.position.y -= v.y; + } + } + }, + + /** + * Packs the circles towards the center of the bounds. + * Each circle will have it's own 'targetPosition' later on + */ + handleCollisions: function() + { + this.removeExpiredElements(); + + var v = new CAAT.Math.Point(0,0, 0), + circleList = this.allCircles, + len = circleList.length; + + // Collide circles + for(var n = 0; n < this.numberOfCollisionPasses; n++) + { + for(var i = 0; i < len; i++) + { + var ci = circleList[i]; + + + for (var j = i + 1; j< len; j++) + { + var cj = circleList[j]; + + if( !this.circlesCanCollide(ci, cj) ) continue; // It's us! + + var dx = cj.position.x - ci.position.x, + dy = cj.position.y - ci.position.y; + + // The distance between the two circles radii, but we're also gonna pad it a tiny bit + var r = (ci.radius + cj.radius) * 1.08, + d = ci.position.getDistanceSquared(cj.position); + + /** + * Collision detected! + */ + if (d < (r * r) - 0.02 ) + { + v.x = dx; + v.y = dy; + v.normalize(); + + var inverseForce = (r - Math.sqrt(d)) * 0.5; + v.multiply(inverseForce); + + // Move cj opposite of the collision as long as its not fixed + if(!cj.isFixed) + { + if(ci.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // ADD the velocity + cj.position.translatePoint(v); + } + + // Move ci opposite of the collision as long as its not fixed + if(!ci.isFixed) + { + if(cj.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // SUBTRACT the velocity + ci.position.subtract(v); + } + + // Emit the collision event from each circle, with itself as the first parameter +// if(this.dispatchCollisionEvents && n == this.numberOfCollisionPasses-1) +// { +// this.eventEmitter.emit('collision', cj, ci, v); +// } + } + } + } + } + }, + + handleBoundaryForCircle: function(aCircle, boundsRule) + { +// if(aCircle.boundsRule === true) return; // Ignore if being dragged + + var xpos = aCircle.position.x; + var ypos = aCircle.position.y; + + var radius = aCircle.radius; + var diameter = radius*2; + + // Toggle these on and off, + // Wrap and bounce, are opposite behaviors so pick one or the other for each axis, or bad things will happen. + var wrapXMask = 1 << 0; + var wrapYMask = 1 << 2; + var constrainXMask = 1 << 3; + var constrainYMask = 1 << 4; + var emitEvent = 1 << 5; + + // TODO: Promote to member variable + // Convert to bitmask - Uncomment the one you want, or concact your own :) + // boundsRule = wrapY; // Wrap only Y axis + // boundsRule = wrapX; // Wrap only X axis + // boundsRule = wrapXMask | wrapYMask; // Wrap both X and Y axis + boundsRule = wrapYMask | constrainXMask; // Wrap Y axis, but constrain horizontally + + // Wrap X + if(boundsRule & wrapXMask && xpos-diameter > this.bounds.right) { + aCircle.position.x = this.bounds.left + radius; + } else if(boundsRule & wrapXMask && xpos+diameter < this.bounds.left) { + aCircle.position.x = this.bounds.right - radius; + } + // Wrap Y + if(boundsRule & wrapYMask && ypos-diameter > this.bounds.bottom) { + aCircle.position.y = this.bounds.top - radius; + } else if(boundsRule & wrapYMask && ypos+diameter < this.bounds.top) { + aCircle.position.y = this.bounds.bottom + radius; + } + + // Constrain X + if(boundsRule & constrainXMask && xpos+radius >= this.bounds.right) { + aCircle.position.x = aCircle.position.x = this.bounds.right-radius; + } else if(boundsRule & constrainXMask && xpos-radius < this.bounds.left) { + aCircle.position.x = this.bounds.left + radius; + } + + // Constrain Y + if(boundsRule & constrainYMask && ypos+radius > this.bounds.bottom) { + aCircle.position.y = this.bounds.bottom - radius; + } else if(boundsRule & constrainYMask && ypos-radius < this.bounds.top) { + aCircle.position.y = this.bounds.top + radius; + } + }, + + /** + * Given an x,y position finds circle underneath and sets it to the currently grabbed circle + * @param {Number} xpos An x position + * @param {Number} ypos A y position + * @param {Number} buffer A radiusSquared around the point in question where something is considered to match + */ + getCircleAt: function(xpos, ypos, buffer) + { + var circleList = this.allCircles; + var len = circleList.length; + var grabVector = new CAAT.Math.Point(xpos, ypos, 0); + + // These are set every time a better match i found + var closestCircle = null; + var closestDistance = Number.MAX_VALUE; + + // Loop thru and find the closest match + for(var i = 0; i < len; i++) + { + var aCircle = circleList[i]; + if(!aCircle) continue; + var distanceSquared = aCircle.position.getDistanceSquared(grabVector); + + if(distanceSquared < closestDistance && distanceSquared < aCircle.radiusSquared + buffer) + { + closestDistance = distanceSquared; + closestCircle = aCircle; + } + } + + return closestCircle; + }, + + circlesCanCollide: function(circleA, circleB) + { + if(!circleA || !circleB || circleA===circleB) return false; // one is null (will be deleted next loop), or both point to same obj. +// if(circleA.delegate == null || circleB.delegate == null) return false; // This circle will be removed next loop, it's entity is already removed + +// if(circleA.isFixed & circleB.isFixed) return false; +// if(circleA.delegate .clientID === circleB.delegate.clientID) return false; // Don't let something collide with stuff it owns + + // They dont want to collide +// if((circleA.collisionGroup & circleB.collisionMask) == 0) return false; +// if((circleB.collisionGroup & circleA.collisionMask) == 0) return false; + + return true; + }, +/** + * Accessors + */ + setBounds: function(x, y, w, h) + { + this.bounds.x = x; + this.bounds.y = y; + this.bounds.width = w; + this.bounds.height = h; + }, + + setNumberOfCollisionPasses: function(value) + { + this.numberOfCollisionPasses = value; + return this; + }, + + setNumberOfTargetingPasses: function(value) + { + this.numberOfTargetingPasses = value; + return this; + }, + +/** + * Helpers + */ + sortOnDistanceToTarget: function(circleA, circleB) + { + var valueA = circleA.getDistanceSquaredFromPosition(circleA.targetPosition); + var valueB = circleB.getDistanceSquaredFromPosition(circleA.targetPosition); + var comparisonResult = 0; + + if(valueA > valueB) comparisonResult = -1; + else if(valueA < valueB) comparisonResult = 1; + + return comparisonResult; + }, + +/** + * Memory Management + */ + removeExpiredElements: function() + { + // remove null elements + for (var k = this.allCircles.length; k >= 0; k--) { + if (this.allCircles[k] === null) + this.allCircles.splice(k, 1); + } + }, + + initialize : function(overrides) + { + if (overrides) + { + for (var i in overrides) + { + this[i] = overrides[i]; + } + } + + return this; + } + } +}); +/** + * See LICENSE file. + * + * Image/Resource preloader. + * + * + **/ + +CAAT.Module( { + + + /** + * @name Preloader + * @memberOf CAAT.Module.Preloader + * @constructor + */ + + defines : "CAAT.Module.Preloader.Preloader", + extendsWith : function() { + + var descriptor= function(id, path, loader) { + + var me= this; + + this.id= id; + this.path= path; + this.image= new Image(); + this.loader= loader; + + this.image.onload= this.onload.bind(this); + this.image.onerror= this.onerror.bind(this); + + return this; + }; + + descriptor.prototype= { + id : null, + path : null, + image : null, + loader : null, + + onload : function(e) { + this.loader.__onload(this); + this.image.onload= null; + this.image.onerror= null; + }, + + onerror : function(e) { + this.loader.__onerror(this); + }, + + load : function() { + this.image.src= this.path; + }, + + clear : function() { + this.loader= null; + + } + }; + + return { + + /** + * @lends CAAT.Module.Preloader.Preloader.prototype + */ + + __init : function() { + this.elements= []; + this.baseURL= ""; + return this; + }, + + currentGroup : null, + + /** + * a list of elements to load. + * @type {Array.<{ id, image }>} + */ + elements: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Callback finished loading. + */ + cfinished: null, + + /** + * Callback element loaded. + */ + cloaded: null, + + /** + * Callback error loading. + */ + cerrored: null, + + /** + * loaded elements count. + */ + loadedCount: 0, + + baseURL : null, + + addElement : function( id, path ) { + this.elements.push( new descriptor(id,this.baseURL+path,this) ); + return this; + }, + + clear : function() { + for( var i=0; i} + */ + images: null, + + /** + * notification callback invoked for each image loaded. + */ + notificationCallback: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Start images loading asynchronous process. This method will notify every image loaded event + * and is responsibility of the caller to count the number of loaded images to see if it fits his + * needs. + * + * @param aImages {{ id:{url}, id2:{url}, ...} an object with id/url pairs. + * @param callback_loaded_one_image {function( imageloader {CAAT.ImagePreloader}, counter {number}, images {{ id:{string}, image: {Image}}} )} + * function to call on every image load. + */ + loadImages: function( aImages, callback_loaded_one_image, callback_error ) { + + if (!aImages) { + if (callback_loaded_one_image ) { + callback_loaded_one_image(0,[]); + } + } + + var me= this, i; + this.notificationCallback = callback_loaded_one_image; + this.images= []; + for( i=0; i>= 0; + + var atop = true; + var abottom = true; + var aleft = true; + var aright = true; + if (typeof areas !== 'undefined') { + if (typeof areas.top !== 'undefined') { + atop = areas.top; + } + if (typeof areas.bottom !== 'undefined') { + abottom = areas.bottom; + } + if (typeof areas.left !== 'undefined') { + aleft = areas.left; + } + if (typeof areas.right !== 'undefined') { + aright = areas.right; + } + } + + + var canvas = document.createElement('canvas'); + canvas.width = image.width; + canvas.height = image.height; + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'rgba(0,0,0,0)'; + ctx.fillRect(0, 0, image.width, image.height); + ctx.drawImage(image, 0, 0); + + var imageData = ctx.getImageData(0, 0, image.width, image.height); + var data = imageData.data; + + var i, j; + var miny = 0, maxy = canvas.height - 1; + var minx = 0, maxx = canvas.width - 1; + + var alpha = false; + + if (atop) { + for (i = 0; i < canvas.height; i++) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + // i contiene el indice del ultimo scan que no es transparente total. + miny = i; + } + + if (abottom) { + alpha = false; + for (i = canvas.height - 1; i >= miny; i--) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + maxy = i; + } + + if (aleft) { + alpha = false; + for (j = 0; j < canvas.width; j++) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + minx = j; + } + + if (aright) { + alpha = false; + for (j = canvas.width - 1; j >= minx; j--) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + maxx = j; + } + + if (0 === minx && 0 === miny && canvas.width - 1 === maxx && canvas.height - 1 === maxy) { + return canvas; + } + + var width = maxx - minx + 1; + var height = maxy - miny + 1; + var id2 = ctx.getImageData(minx, miny, width, height); + + canvas.width = width; + canvas.height = height; + ctx = canvas.getContext('2d'); + ctx.putImageData(id2, 0, 0); + + return canvas; + }, + + + createThumb:function (image, w, h, best_fit) { + w = w || 24; + h = h || 24; + var canvas = document.createElement('canvas'); + canvas.width = w; + canvas.height = h; + var ctx = canvas.getContext('2d'); + + if (best_fit) { + var max = Math.max(image.width, image.height); + var ww = image.width / max * w; + var hh = image.height / max * h; + ctx.drawImage(image, (w - ww) / 2, (h - hh) / 2, ww, hh); + } else { + ctx.drawImage(image, 0, 0, w, h); + } + + return canvas; + } + } + +}) +/** + * See LICENSE file. + * + * This file contains the definition for objects QuadTree and HashMap. + * Quadtree offers an exact list of collisioning areas, while HashMap offers a list of potentially colliding + * elements. + * Specially suited for static content. + * + **/ + +CAAT.Module({ + + /** + * @name Collision + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name QuadTree + * @memberOf CAAT.Module.Collision + * @constructor + */ + + defines:"CAAT.Module.Collision.QuadTree", + depends:[ + "CAAT.Math.Rectangle" + ], + extendsClass:"CAAT.Math.Rectangle", + extendsWith:function () { + + var QT_MAX_ELEMENTS = 1; + var QT_MIN_WIDTH = 32; + + return { + + /** + * @lends CAAT.Module.Collision.QuadTree.prototype + */ + + /** + * For each quadtree level this keeps the list of overlapping elements. + */ + bgActors:null, + + /** + * For each quadtree, this quadData keeps another 4 quadtrees up to the maximum recursion level. + */ + quadData:null, + + create:function (l, t, r, b, backgroundElements, minWidth, maxElements) { + + if (typeof minWidth === 'undefined') { + minWidth = QT_MIN_WIDTH; + } + if (typeof maxElements === 'undefined') { + maxElements = QT_MAX_ELEMENTS; + } + + var cx = (l + r) / 2; + var cy = (t + b) / 2; + + this.x = l; + this.y = t; + this.x1 = r; + this.y1 = b; + this.width = r - l; + this.height = b - t; + + this.bgActors = this.__getOverlappingActorList(backgroundElements); + + if (this.bgActors.length <= maxElements || this.width <= minWidth) { + return this; + } + + this.quadData = new Array(4); + this.quadData[0] = new CAAT.Module.Collision.QuadTree().create(l, t, cx, cy, this.bgActors); // TL + this.quadData[1] = new CAAT.Module.Collision.QuadTree().create(cx, t, r, cy, this.bgActors); // TR + this.quadData[2] = new CAAT.Module.Collision.QuadTree().create(l, cy, cx, b, this.bgActors); // BL + this.quadData[3] = new CAAT.Module.Collision.QuadTree().create(cx, cy, r, b, this.bgActors); + + return this; + }, + + __getOverlappingActorList:function (actorList) { + var tmpList = []; + for (var i = 0, l = actorList.length; i < l; i++) { + var actor = actorList[i]; + if (this.intersects(actor.AABB)) { + tmpList.push(actor); + } + } + return tmpList; + }, + + /** + * Call this method to thet the list of colliding elements with the parameter rectangle. + * @param rectangle + * @return {Array} + */ + getOverlappingActors:function (rectangle) { + var i, j, l; + var overlappingActors = []; + var qoverlappingActors; + var actors = this.bgActors; + var actor; + + if (this.quadData) { + for (i = 0; i < 4; i++) { + if (this.quadData[i].intersects(rectangle)) { + qoverlappingActors = this.quadData[i].getOverlappingActors(rectangle); + for (j = 0, l = qoverlappingActors.length; j < l; j++) { + overlappingActors.push(qoverlappingActors[j]); + } + } + } + } else { + for (i = 0, l = actors.length; i < l; i++) { + actor = actors[i]; + if (rectangle.intersects(actor.AABB)) { + overlappingActors.push(actor); + } + } + } + + return overlappingActors; + } + } + } +}); +CAAT.Module( { + + + /** + * @name SpatialHash + * @memberOf CAAT.Module.Collision + * @constructor + */ + + + defines : "CAAT.Module.Collision.SpatialHash", + aliases : ["CAAT.SpatialHash"], + depends : [ + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Collision.SpatialHash.prototype + */ + + /** + * A collection ob objects to test collision among them. + */ + elements : null, + + /** + * Space width + */ + width : null, + + /** + * Space height + */ + height : null, + + /** + * Rows to partition the space. + */ + rows : null, + + /** + * Columns to partition the space. + */ + columns : null, + + xcache : null, + ycache : null, + xycache : null, + + rectangle : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r0 : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r1 : null, + + initialize : function( w,h, rows,columns ) { + + var i, j; + + this.elements= []; + for( i=0; i>0 ); + } + + this.ycache= []; + for( i=0; i>0 ); + } + + this.xycache=[]; + for( i=0; i1 ) { // at least 2 elements could collide + this._solveCollisionCell( cell, callback ); + } + } + }, + + _solveCollisionCell : function( cell, callback ) { + var i,j; + + for( i=0; i0 ) { + this.freeChunks.splice( i++,0,{position: lp, size:ls} ); + } + if ( rs>0 ) { + this.freeChunks.splice( i,0,{position: rp, size:rs} ); + } + + return true; + } + } + + return false; + }, + log : function(index) { + if ( 0===this.freeChunks.length ) { + CAAT.log('index '+index+' empty'); + } else { + var str='index '+index; + for( var i=0; ithis.width||height>this.height) { + return null; + } + + // find first fitting point + var i,j,initialPosition= 0; + + while( initialPosition<=this.scanMapHeight-height) { + + // para buscar sitio se buscara un sitio hasta el tamano de alto del trozo. + // mas abajo no va a caber. + + // fitHorizontalPosition es un array con todas las posiciones de este scan donde + // cabe un chunk de tamano width. + var fitHorizontalPositions= null; + var foundPositionOnScan= false; + + for( ; initialPosition<=this.scanMapHeight-height; initialPosition++ ) { + fitHorizontalPositions= this.scanMap[ initialPosition ].findWhereFits( width ); + + // si no es nulo el array de resultados, quiere decir que en alguno de los puntos + // nos cabe un trozo de tamano width. + if ( null!==fitHorizontalPositions && fitHorizontalPositions.length>0 ) { + foundPositionOnScan= true; + break; + } + } + + if ( foundPositionOnScan ) { + // j es el scan donde cabe un trozo de tamano width. + // comprobamos desde este scan que en todos los scan verticales cabe el trozo. + // se comprueba que cabe en alguno de los tamanos que la rutina de busqueda horizontal + // nos ha devuelto antes. + + var minInitialPosition=Number.MAX_VALUE; + for( j=0; jb.width ? -1 : 0; + } else if ( me.criteria==='height' ) { + return a.heightb.height ? -1 : 0; + } + return aareabarea ? -1 : 0; + }); + + for( i=0; iTIME ) { + difftime= TIME; + } + + setTimeout( + function() { + endSplash(director, images, sceneCreationCallback); + }, + difftime ); + + } else { + endSplash(director, images, sceneCreationCallback); + } + + } + }; + + return scene; + } + /** + * Finish splash process by either timeout or resources allocation end. + */ + function endSplash(director, images, onEndSplashCallback) { + + director.emptyScenes(); + director.setImagesCache(images); + director.setClear( true ); + + onEndSplashCallback(director); + + /** + * Change this sentence's parameters to play with different entering-scene + * curtains. + * just perform a director.setScene(0) to play first director's scene. + */ + + director.setClear( CAAT.Foundation.Director.CLEAR_ALL ); + director.easeIn( + 0, + CAAT.Foundation.Scene.EASE_SCALE, + 2000, + false, + CAAT.Foundation.Actor.ANCHOR_CENTER, + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(2.5, .4) ); + + } + + var canvascontainer= document.getElementById(runHere); + var director; + + if ( CAAT.__CSS__ ) { // css renderer + if ( canvascontainer ) { + if ( false===canvascontainer instanceof HTMLDivElement ) { + canvascontainer= null; + } + } + + if ( canvascontainer===null ) { + canvascontainer= document.createElement('div'); // create a new DIV + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + + } else { + + if ( canvascontainer ) { + if ( canvascontainer instanceof HTMLDivElement ) { + var ncanvascontainer= document.createElement("canvas"); + canvascontainer.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } else if ( false==canvascontainer instanceof HTMLCanvasElement ) { + var ncanvascontainer= document.createElement("canvas"); + document.body.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } + } else { + canvascontainer= document.createElement('canvas'); + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + } + + + /** + * Load splash images. It is supossed the splash has some images. + */ + var imgs= []; + if ( splash_path ) { + imgs.push( {id:'splash', url: splash_path } ); + } + if ( spinner_path ) { + imgs.push( {id:'spinner', url: spinner_path } ); + } + + director.setClear( CAAT.Foundation.Director.CLEAR_DIRTY_RECTS ); + + new CAAT.Module.Preloader.ImagePreloader().loadImages( + imgs, + function on_load( counter, images ) { + + if ( counter===images.length ) { + + director.setImagesCache(images); + var splashScene= createSplashScene(director, minTime || 5000, onEndSplash); + CAAT.loop(60); + + if ( imagesURL && imagesURL.length>0 ) { + /** + * Load resources for non splash screen + */ + new CAAT.Module.Preloader.ImagePreloader().loadImages( + imagesURL, + splashScene.loadedImage + ); + } else { + splashScene.loadedImage(0,null); + } + } + } + ); + } + + } +});/** + * See LICENSE file. + * + * These classes encapsulate different kinds of paths. + * LinearPath, defines an straight line path, just 2 points. + * CurvePath, defines a path based on a Curve. Curves can be bezier quadric/cubic and catmull-rom. + * Path, is a general purpose class, which composes a path of different path segments (Linear or Curve paths). + * + * A path, has an interpolator which stablish the way the path is traversed (accelerating, by + * easing functions, etc.). Normally, interpolators will be defined by CAAT.Behavior.Interpolator instances, but + * general Paths could be used as well. + * + **/ + + +CAAT.Module({ + + /** + * @name PathUtil + * @memberOf CAAT + * @namespace + */ + + /** + * @name PathSegment + * @memberOf CAAT.PathUtil + * @constructor + */ + + defines:"CAAT.PathUtil.PathSegment", + depends:[ + "CAAT.Math.Rectangle", + "CAAT.Math.Point", + "CAAT.Math.Matrix", + "CAAT.Math.Curve" + ], + extendsWith:function () { + return { + + /** + * @lends CAAT.PathUtil.PathSegment.prototype + */ + + + __init:function () { + this.bbox = new CAAT.Math.Rectangle(); + return this; + }, + + /** + * Color to draw the segment. + */ + color:'#000', + + /** + * Segment length. + */ + length:0, + + /** + * Segment bounding box. + */ + bbox:null, + + /** + * Path this segment belongs to. + */ + parent:null, + + /** + * Set a PathSegment's parent + * @param parent + */ + setParent:function (parent) { + this.parent = parent; + return this; + }, + setColor:function (color) { + if (color) { + this.color = color; + } + return this; + }, + /** + * Get path's last coordinate. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + }, + + /** + * Get path's starting coordinate. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + }, + + /** + * Set this path segment's points information. + * @param points {Array} + */ + setPoints:function (points) { + }, + + /** + * Set a point from this path segment. + * @param point {CAAT.Point} + * @param index {integer} a point index. + */ + setPoint:function (point, index) { + }, + + /** + * Get a coordinate on path. + * The parameter time is normalized, that is, its values range from zero to one. + * zero will mean startCurvePosition and one will be endCurvePosition. Other values + * will be a position on the path relative to the path length. if the value is greater that 1, if will be set + * to modulus 1. + * @param time a float with a value between zero and 1 inclusive both. + * + * @return {CAAT.Point} + */ + getPosition:function (time) { + }, + + /** + * Gets Path length. + * @return {number} + */ + getLength:function () { + return this.length; + }, + + /** + * Gets the path bounding box (or the rectangle that contains the whole path). + * @param rectangle a CAAT.Rectangle instance with the bounding box. + * @return {CAAT.Rectangle} + */ + getBoundingBox:function () { + return this.bbox; + }, + + /** + * Gets the number of control points needed to create the path. + * Each PathSegment type can have different control points. + * @return {number} an integer with the number of control points. + */ + numControlPoints:function () { + }, + + /** + * Gets CAAT.Point instance with the 2d position of a control point. + * @param index an integer indicating the desired control point coordinate. + * @return {CAAT.Point} + */ + getControlPoint:function (index) { + }, + + /** + * Instruments the path has finished building, and that no more segments will be added to it. + * You could later add more PathSegments and endPath must be called again. + */ + endPath:function () { + }, + + /** + * Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments. + * @param iSize an integer indicating the number of segments of the contour polyline. + * + * @return {[CAAT.Point]} + */ + getContour:function (iSize) { + }, + + /** + * Recalculate internal path structures. + */ + updatePath:function (point) { + }, + + /** + * Draw this path using RenderingContext2D drawing primitives. + * The intention is to set a path or pathsegment as a clipping region. + * + * @param ctx {RenderingContext2D} + */ + applyAsPath:function (director) { + }, + + /** + * Transform this path with the given affinetransform matrix. + * @param matrix + */ + transform:function (matrix) { + }, + + drawHandle:function (ctx, x, y) { + + ctx.beginPath(); + ctx.arc( + x, + y, + CAAT.Math.Curve.prototype.HANDLE_SIZE / 2, + 0, + 2 * Math.PI, + false); + ctx.fill(); + } + } + } + +}); +CAAT.Module({ + + /** + * @name ArcPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.ArcPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + aliases:["CAAT.ArcPath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.ArcPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(); + + return this; + }, + + /** + * A collection of CAAT.Math.Point objects which defines the arc (center, start, end) + */ + points:null, + + /** + * Defined clockwise or counterclockwise ? + */ + cw:true, + + /** + * spare point for calculations + */ + newPosition:null, + + /** + * Arc radius. + */ + radius:0, + + /** + * Arc start angle. + */ + startAngle:0, + + /** + * Arc end angle. + */ + angle:2 * Math.PI, + + /** + * is a relative or absolute arc ? + */ + arcTo:false, + + setRadius:function (r) { + this.radius = r; + return this; + }, + + isArcTo:function () { + return this.arcTo; + }, + + setArcTo:function (b) { + this.arcTo = b; + return this; + }, + + initialize:function (x, y, r, angle) { + this.setInitialPosition(x, y); + this.setFinalPosition(x + r, y); + this.angle = angle || 2 * Math.PI; + return this; + }, + + applyAsPath:function (director) { + var ctx = director.ctx; + if (!this.arcTo) { + ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.angle + this.startAngle, this.cw); + } else { + ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius); + } + return this; + }, + setPoint:function (point, index) { + if (index >= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[0].x = x; + this.points[0].y = y; + } + + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + + this.updatePath(this.points[1]); + return this; + }, + /** + * An arc starts and ends in the same point. + */ + endCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(this.points[0].x, this.points[0].y); + } else { + + var angle = this.angle * time * (this.cw ? 1 : -1) + this.startAngle; + + this.newPosition.set( + this.points[0].x + this.radius * Math.cos(angle), + this.points[0].y + this.radius * Math.sin(angle) + ); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + if (!this.arcTo) { + ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.startAngle + this.angle, this.cw); + } else { + ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius); + } + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + for (var i = 0; i < iSize; i++) { + contour.push( + { + x:this.points[0].x + this.radius * Math.cos(i * Math.PI / (iSize / 2)), + y:this.points[0].y + this.radius * Math.sin(i * Math.PI / (iSize / 2)) + } + ); + } + + return contour; + }, + + getPositionFromLength:function (iLength) { + var ratio = iLength / this.length * (this.cw ? 1 : -1); + return this.getPosition(ratio); + /* + this.newPosition.set( + this.points[0].x + this.radius * Math.cos( 2*Math.PI * ratio ), + this.points[0].y + this.radius * Math.sin( 2*Math.PI * ratio ) + ); + return this.newPosition;*/ + }, + + updatePath:function (point) { + + // just move the circle, not modify radius. + if (this.points[1] === point) { + + if (!this.arcTo) { + this.radius = Math.sqrt( + ( this.points[0].x - this.points[1].x ) * ( this.points[0].x - this.points[1].x ) + + ( this.points[0].y - this.points[1].y ) * ( this.points[0].y - this.points[1].y ) + ); + } + + this.length = this.angle * this.radius; + this.startAngle = Math.atan2((this.points[1].y - this.points[0].y), (this.points[1].x - this.points[0].x)); + + } else if (this.points[0] === point) { + this.points[1].set( + this.points[0].x + this.radius * Math.cos(this.startAngle), + this.points[0].y + this.radius * Math.sin(this.startAngle) + ); + } + + this.bbox.setEmpty(); + this.bbox.x = this.points[0].x - this.radius; + this.bbox.y = this.points[0].y - this.radius; + this.bbox.x1 = this.points[0].x + this.radius; + this.bbox.y1 = this.points[0].y + this.radius; + this.bbox.width = 2 * this.radius; + this.bbox.height = 2 * this.radius; + + return this; + } + } + } + +}); +/** + * CAAT.CurvePath + */ +CAAT.Module({ + + /** + * @name CurvePath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.CurvePath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Bezier" + ], + aliases:["CAAT.CurvePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + return { + + /** + * @lends CAAT.PathUtil.CurvePath.prototype + */ + + + __init:function () { + this.__super(); + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A CAAT.Math.Curve instance. + */ + curve:null, + + /** + * spare holder for getPosition coordinate return. + * @type {CAAT.Math.Point} + */ + newPosition:null, + + applyAsPath:function (director) { + this.curve.applyAsPath(director); + return this; + }, + setPoint:function (point, index) { + if (this.curve) { + this.curve.setPoint(point, index); + } + }, + /** + * Set this curve segment's points. + * @param points {Array} + */ + setPoints:function (points) { + var curve = new CAAT.Math.Bezier(); + curve.setPoints(points); + this.curve = curve; + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier quadric instance. + * Parameters are quadric coordinates control points. + * + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @return this + */ + setQuadric:function (p0x, p0y, p1x, p1y, p2x, p2y) { + var curve = new CAAT.Math.Bezier(); + curve.setQuadric(p0x, p0y, p1x, p1y, p2x, p2y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier cubic instance. + * Parameters are cubic coordinates control points. + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @param p3x {number} + * @param p3y {number} + * @return this + */ + setCubic:function (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { + var curve = new CAAT.Math.Bezier(); + curve.setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * @inheritDoc + */ + updatePath:function (point) { + this.curve.update(); + this.length = this.curve.getLength(); + this.curve.getBoundingBox(this.bbox); + return this; + }, + /** + * @inheritDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.curve.solve(this.newPosition, time); + + return this.newPosition; + }, + /** + * Gets the coordinate on the path relative to the path length. + * @param iLength {number} the length at which the coordinate will be taken from. + * @return {CAAT.Point} a CAAT.Point instance with the coordinate on the path corresponding to the + * iLenght parameter relative to segment's length. + */ + getPositionFromLength:function (iLength) { + this.curve.solve(this.newPosition, iLength / this.length); + return this.newPosition; + }, + /** + * Get path segment's first point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.curve.coordlist[0].x; + }, + /** + * Get path segment's last point's y coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.curve.coordlist[this.curve.coordlist.length - 1].x; + }, + /** + * @inheritDoc + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + this.curve.drawHandles = bDrawHandles; + director.ctx.strokeStyle = this.color; + this.curve.paint(director, bDrawHandles); + }, + /** + * @inheritDoc + */ + numControlPoints:function () { + return this.curve.coordlist.length; + }, + /** + * @inheritDoc + * @param index + */ + getControlPoint:function (index) { + return this.curve.coordlist[index]; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.curve.endCurvePosition(); + }, + /** + * @inheritDoc + */ + startCurvePosition:function () { + return this.curve.startCurvePosition(); + }, + /** + * @inheritDoc + * @param iSize + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } + +}); +/** + * CAAT.LinearPath + */ +CAAT.Module({ + + + /** + * @name LinearPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.LinearPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point" + ], + aliases:["CAAT.LinearPath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.LinearPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A collection of points. + * @type {Array.} + */ + points:null, + + /** + * spare holder for getPosition coordinate return. + */ + newPosition:null, + + applyAsPath:function (director) { + // Fixed: Thanks https://github.com/roed + director.ctx.lineTo(this.points[1].x, this.points[1].y); + }, + setPoint:function (point, index) { + if (index === 0) { + this.points[0] = point; + } else if (index === 1) { + this.points[1] = point; + } + }, + /** + * Update this segments length and bounding box info. + */ + updatePath:function (point) { + var x = this.points[1].x - this.points[0].x; + var y = this.points[1].y - this.points[0].y; + this.length = Math.sqrt(x * x + y * y); + + this.bbox.setEmpty(); + this.bbox.union(this.points[0].x, this.points[0].y); + this.bbox.union(this.points[1].x, this.points[1].y); + + return this; + }, + setPoints:function (points) { + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + return this; + }, + /** + * Set this path segment's starting position. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + this.points[0].x = x; + this.points[0].y = y; + this.newPosition.set(x, y); + return this; + }, + /** + * Set this path segment's ending position. + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[1]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.newPosition.set( + (this.points[0].x + (this.points[1].x - this.points[0].x) * time), + (this.points[0].y + (this.points[1].y - this.points[0].y) * time)); + + return this.newPosition; + }, + getPositionFromLength:function (len) { + return this.getPosition(len / this.length); + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.moveTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + ctx.beginPath(); + this.drawHandle(ctx, this.points[0].x, this.points[0].y); + this.drawHandle(ctx, this.points[1].x, this.points[1].y); + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return 2; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + if (0 === index) { + return this.points[0]; + } else if (1 === index) { + return this.points[1]; + } + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + contour.push(this.getPosition(0).clone()); + contour.push(this.getPosition(1).clone()); + + return contour; + } + } + } +}); +CAAT.Module({ + + /** + * @name RectPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.RectPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + aliases:["CAAT.RectPath", "CAAT.ShapePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.RectPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(); + + return this; + }, + + /** + * A collection of Points. + * @type {Array.} + */ + points:null, + + /** + * Traverse this path clockwise or counterclockwise (false). + */ + cw:true, + + /** + * spare point for calculations + */ + newPosition:null, + + applyAsPath:function (director) { + var ctx = director.ctx; + + if (this.cw) { + ctx.lineTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[4].x, this.points[4].y); + } else { + ctx.lineTo(this.points[4].x, this.points[4].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[0].x, this.points[0].y); + } + return this; + }, + setPoint:function (point, index) { + if (index >= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points.push(points[0]); + this.points.push(new CAAT.Math.Point().set(points[1].x, points[0].y)); + this.points.push(points[1]); + this.points.push(new CAAT.Math.Point().set(points[0].x, points[1].y)); + this.points.push(points[0].clone()); + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[i].x = x; + this.points[i].y = y; + } + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[2].x = finalX; + this.points[2].y = finalY; + + this.points[1].x = finalX; + this.points[1].y = this.points[0].y; + + this.points[3].x = this.points[0].x; + this.points[3].y = finalY; + + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + + this.updatePath(); + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[4]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(0, 0); + } else { + var w = this.bbox.width / this.length; + var h = this.bbox.height / this.length; + var accTime = 0; + var times; + var segments; + var index = 0; + + if (this.cw) { + segments = [0, 1, 2, 3, 4]; + times = [w, h, w, h]; + } else { + segments = [4, 3, 2, 1, 0]; + times = [h, w, h, w]; + } + + while (index < times.length) { + if (accTime + times[index] < time) { + accTime += times[index]; + index++; + } else { + break; + } + } + time -= accTime; + + var p0 = segments[index]; + var p1 = segments[index + 1]; + + // index tiene el indice del segmento en tiempo. + this.newPosition.set( + (this.points[p0].x + (this.points[p1].x - this.points[p0].x) * time / times[index]), + (this.points[p0].y + (this.points[p1].y - this.points[p0].y) * time / times[index])); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[2].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.strokeRect( + this.bbox.x, this.bbox.y, + this.bbox.width, this.bbox.height); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (/*iSize*/) { + var contour = []; + + for (var i = 0; i < this.points.length; i++) { + contour.push(this.points[i]); + } + + return contour; + }, + updatePath:function (point) { + + if (point) { + if (point === this.points[0]) { + this.points[1].y = point.y; + this.points[3].x = point.x; + } else if (point === this.points[1]) { + this.points[0].y = point.y; + this.points[2].x = point.x; + } else if (point === this.points[2]) { + this.points[3].y = point.y; + this.points[1].x = point.x; + } else if (point === this.points[3]) { + this.points[0].x = point.x; + this.points[2].y = point.y; + } + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + } + + this.bbox.setEmpty(); + + for (var i = 0; i < 4; i++) { + this.bbox.union(this.points[i].x, this.points[i].y); + } + + this.length = 2 * this.bbox.width + 2 * this.bbox.height; + + this.points[0].x = this.bbox.x; + this.points[0].y = this.bbox.y; + + this.points[1].x = this.bbox.x + this.bbox.width; + this.points[1].y = this.bbox.y; + + this.points[2].x = this.bbox.x + this.bbox.width; + this.points[2].y = this.bbox.y + this.bbox.height; + + this.points[3].x = this.bbox.x; + this.points[3].y = this.bbox.y + this.bbox.height; + + this.points[4].x = this.bbox.x; + this.points[4].y = this.bbox.y; + + return this; + }, + + getPositionFromLength:function (iLength) { + return this.getPosition(iLength / (this.bbox.width * 2 + this.bbox.height * 2)); + } + } + } +}); +CAAT.Module( { + + /** + * @name Path + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines : "CAAT.PathUtil.Path", + aliases : ["CAAT.Path"], + depends : [ + "CAAT.PathUtil.PathSegment", + "CAAT.PathUtil.ArcPath", + "CAAT.PathUtil.CurvePath", + "CAAT.PathUtil.LinearPath", + "CAAT.PathUtil.RectPath", + "CAAT.Math.Bezier", + "CAAT.Math.CatmullRom", + "CAAT.Math.Point", + "CAAT.Math.Matrix" + ], + extendsClass : "CAAT.PathUtil.PathSegment", + extendsWith : { + + /** + * @lends CAAT.PathUtil.Path.prototype + */ + + + __init : function() { + this.__super(); + + this.newPosition= new CAAT.Math.Point(0,0,0); + this.pathSegments= []; + + this.behaviorList= []; + this.matrix= new CAAT.Math.Matrix(); + this.tmpMatrix= new CAAT.Math.Matrix(); + + return this; + }, + + /** + * A collection of PathSegments. + * @type {Array.} + */ + pathSegments: null, // a collection of CAAT.PathSegment instances. + + /** + * For each path segment in this path, the normalized calculated duration. + * precomputed segment duration relative to segment legnth/path length + */ + pathSegmentDurationTime: null, + + /** + * For each path segment in this path, the normalized calculated start time. + * precomputed segment start time relative to segment legnth/path length and duration. + */ + pathSegmentStartTime: null, + + /** + * spare CAAT.Math.Point to return calculated values in the path. + */ + newPosition: null, + + /** + * path length (sum of every segment length) + */ + pathLength: -1, + + /** + * starting path x position + */ + beginPathX: -1, + + /** + * starting path y position + */ + beginPathY: -1, + + /* + last path coordinates position (using when building the path). + */ + trackPathX: -1, + trackPathY: -1, + + /* + needed to drag control points. + */ + ax: -1, + ay: -1, + point: [], + + /** + * Is this path interactive ?. If so, controls points can be moved with a CAAT.Foundation.UI.PathActor. + */ + interactive: true, + + /** + * A list of behaviors to apply to this path. + * A path can be affine transformed to create a different path. + */ + behaviorList: null, + + /* rotation behavior info **/ + + /** + * Path rotation angle. + */ + rb_angle: 0, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorX: .5, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorY: .5, + + /* scale behavior info **/ + + /** + * Path X scale. + */ + sb_scaleX: 1, + + /** + * Path Y scale. + */ + sb_scaleY: 1, + + /** + * Path scale X anchor. + */ + sb_scaleAnchorX: .5, + + /** + * Path scale Y anchor. + */ + sb_scaleAnchorY: .5, + + /** + * Path translation anchor X. + */ + tAnchorX: 0, + + /** + * Path translation anchor Y. + */ + tAnchorY: 0, + + /* translate behavior info **/ + + /** + * Path translation X. + */ + tb_x: 0, + + /** + * Path translation Y. + */ + tb_y: 0, + + /* behavior affine transformation matrix **/ + + /** + * Path behaviors matrix. + */ + matrix: null, + + /** + * Spare calculation matrix. + */ + tmpMatrix: null, + + /** + * Original Path´s path segments points. + */ + pathPoints: null, + + /** + * Path bounding box width. + */ + width: 0, + + /** + * Path bounding box height. + */ + height: 0, + + /** + * Path bounding box X position. + */ + clipOffsetX : 0, + + /** + * Path bounding box Y position. + */ + clipOffsetY : 0, + + /** + * Is this path closed ? + */ + closed : false, + + /** + * Apply this path as a Canvas context path. + * You must explicitly call context.beginPath + * @param director + * @return {*} + */ + applyAsPath : function(director) { + var ctx= director.ctx; + + director.modelViewMatrix.transformRenderingContext( ctx ); + ctx.globalCompositeOperation= 'source-out'; + ctx.moveTo( + this.getFirstPathSegment().startCurvePosition().x, + this.getFirstPathSegment().startCurvePosition().y + ); + for( var i=0; i + * If a call to any method of the form addTo is called before this calling + * this method, they will assume to start at -1,-1 and probably you'll get the wrong path. + * @param px0 {number} + * @param py0 {number} + * + * @return this + */ + beginPath : function( px0, py0 ) { + this.trackPathX= px0; + this.trackPathY= py0; + this.beginPathX= px0; + this.beginPathY= py0; + return this; + }, + /** + * Close the path by adding a line path segment from the current last path + * coordinate to startCurvePosition coordinate. + *

    + * This method closes a path by setting its last path segment's last control point + * to be the first path segment's first control point. + *

    + * This method also sets the path as finished, and calculates all path's information + * such as length and bounding box. + * + * @return this + */ + closePath : function() { + + this.getLastPathSegment().setPoint( + this.getFirstPathSegment().startCurvePosition(), + this.getLastPathSegment().numControlPoints()-1 ); + + + this.trackPathX= this.beginPathX; + this.trackPathY= this.beginPathY; + + this.closed= true; + + this.endPath(); + return this; + }, + /** + * Finishes the process of building the path. It involves calculating each path segments length + * and proportional length related to a normalized path length of 1. + * It also sets current paths length. + * These calculi are needed to traverse the path appropriately. + *

    + * This method must be called explicitly, except when closing a path (that is, calling the + * method closePath) which calls this method as well. + * + * @return this + */ + endPath : function() { + + this.pathSegmentStartTime=[]; + this.pathSegmentDurationTime= []; + + this.updatePath(); + + return this; + }, + /** + * This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path. + * The returned coordinate is the corresponding to normalizing the path's length to 1, + * and then finding what path segment and what coordinate in that path segment corresponds + * for the input time parameter. + *

    + * The parameter time must be a value ranging 0..1. + * If not constrained to these values, the parameter will be modulus 1, and then, if less + * than 0, be normalized to 1+time, so that the value always ranges from 0 to 1. + *

    + * This method is needed when traversing the path throughout a CAAT.Interpolator instance. + * + * + * @param time {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate. + * 1 will return path's end coordinate. + * @param open_contour {boolean=} treat this path as an open contour. It is intended for + * open paths, and interpolators which give values above 1. see tutorial 7.1. + * @link{../../documentation/tutorials/t7-1.html} + * + * @return {CAAT.Foundation.Point} + */ + getPosition : function(time, open_contour) { + + if (open_contour && (time>=1 || time<=0) ) { + + var p0,p1,ratio, angle; + + if ( time>=1 ) { + // these values could be cached. + p0= this.__getPositionImpl( .999 ); + p1= this.endCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= time%1; + + + } else { + // these values could be cached. + p0= this.__getPositionImpl( .001 ); + p1= this.startCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= -time; + } + + var np= this.newPosition; + var length= this.getLength(); + + np.x = p1.x + (ratio * length)*Math.cos(angle); + np.y = p1.y + (ratio * length)*Math.sin(angle); + + + return np; + } + + return this.__getPositionImpl(time); + }, + + __getPositionImpl : function(time) { + + if ( time>1 || time<0 ) { + time%=1; + } + if ( time<0 ) { + time= 1+time; + } + + var ps= this.pathSegments; + var psst= this.pathSegmentStartTime; + var psdt= this.pathSegmentDurationTime; + var l= 0; + var r= ps.length; + var m; + var np= this.newPosition; + var psstv; + while( l!==r ) { + + m= ((r+l)/2)|0; + psstv= psst[m]; + if ( psstv<=time && time<=psstv+psdt[m]) { + time= psdt[m] ? + (time-psstv)/psdt[m] : + 0; + + // Clamp this segment's time to a maximum since it is relative to the path. + // thanks https://github.com/donaldducky for spotting. + if (time>1) { + time=1; + } else if (time<0 ) { + time= 0; + } + + var pointInPath= ps[m].getPosition(time); + np.x= pointInPath.x; + np.y= pointInPath.y; + return np; + } else if ( time=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + + }, + /** + * Analogously to the method getPosition, this method returns a CAAT.Point instance with + * the coordinate on the path that corresponds to the given length. The input length is + * related to path's length. + * + * @param iLength {number} a float with the target length. + * @return {CAAT.Point} + */ + getPositionFromLength : function(iLength) { + + iLength%=this.getLength(); + if (iLength<0 ) { + iLength+= this.getLength(); + } + + var accLength=0; + + for( var i=0; i0 ) { + this.pathSegmentStartTime[i]= this.pathSegmentStartTime[i-1]+this.pathSegmentDurationTime[i-1]; + } else { + this.pathSegmentStartTime[0]= 0; + } + + this.pathSegments[i].endPath(); + } + + this.extractPathPoints(); + + if ( callback ) { + callback(this); + } + + return this; + + }, + /** + * Sent by a CAAT.PathActor instance object to try to drag a path's control point. + * @param x {number} + * @param y {number} + */ + press: function(x,y) { + if (!this.interactive) { + return; + } + + var HS= CAAT.Math.Curve.prototype.HANDLE_SIZE/2; + for( var i=0; i=point.x-HS && + y>=point.y-HS && + x} + */ + setPoints : function( points ) { + if ( this.points.length===points.length ) { + for( var i=0; i=0 && index + * This class is a SVG Path parser. + * By calling the method parsePath( svgpath ) an instance of CAAT.PathUtil.Path will be built by parsing + * its contents. + * + *

    + * See demo32 + * + * @name SVGPath + * @memberOf CAAT.PathUtil + * @constructor + */ + + defines:"CAAT.PathUtil.SVGPath", + depends:[ + "CAAT.PathUtil.Path" + ], + extendsWith:function () { + + var OK = 0; + var EOF = 1; + var NAN = 2; + + function error(pathInfo, c) { + var cpos = c; + if (cpos < 0) { + cpos = 0; + } + console.log("parse error near ..." + pathInfo.substr(cpos, 20)); + } + + return { + + /** + * @lends CAAT.PathUtil.SVGPath.prototype + */ + + + __init:function () { + + }, + + /** + * @private + */ + c:0, + + /** + * @private + */ + bezierInfo:null, + + __skipBlank:function (pathInfo, c) { + var p = pathInfo.charAt(c); + while (c < pathInfo.length && (p == ' ' || p == '\n' || p == '\t' || p == ',')) { + ++c; + var p = pathInfo.charAt(c); + } + + return c; + }, + + __maybeNumber:function (pathInfo, c) { + + if (c < pathInfo.length - 2) { + + var p = pathInfo.charAt(c); + var p1 = pathInfo.charAt(c + 1); + + return p == '-' || + this.__isDigit(p) || + (p === "." && this.__isDigit(p1) ); + } + + return false; + }, + + __isDigit:function (c) { + return c >= "0" && c <= "9"; + }, + + + __getNumber:function (pathInfo, c, v, error) { + c = this.__skipBlank(pathInfo, c); + if (c < pathInfo.length) { + var nc = this.__findNumber(pathInfo, c); + if (nc !== -1) { + v.push(parseFloat(pathInfo.substr(c, nc))); + c = this.__skipBlank(pathInfo, nc); + error.pos = c; + error.result = OK; + return; + } else { + error.result = NAN; + return; + } + } + + error.result = EOF; + }, + + ____getNumbers:function (pathInfo, c, v, n, error) { + + for (var i = 0; i < n; i++) { + this.__getNumber(pathInfo, c, v, error); + if (error.result != OK) { + break; + } else { + c = error.pos; + } + } + + return c; + }, + + + __findNumber:function (pathInfo, c) { + + var p; + + if ((p = pathInfo.charAt(c)) == '-') { + ++c; + } + + if (!this.__isDigit((p = pathInfo.charAt(c)))) { + if ((p = pathInfo.charAt(c)) != '.' || !this.__isDigit(pathInfo.charAt(c + 1))) { + return -1; + } + } + + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + + if ((p = pathInfo.charAt(c)) == '.') { + ++c; + if (!this.__isDigit((p = pathInfo.charAt(c)))) { // asumo un numero [d+]\. como valido. + return c; + } + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + } + + return c; + }, + + __parseMoveTo:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + + if (error.result === OK) { + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.beginPath(numbers[0], numbers[1]); + } else { + return; + } + + if (this.__maybeNumber(pathInfo, c)) { + c = this.parseLine(pathInfo, c, absolute, path, error); + } + + error.pos = c; + }, + + __parseLine:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + + __parseLineH:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[0] += path.trackPathX; + } + numbers[1].push(path.trackPathY); + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseLineV:function (pathInfo, c, absolute, path, error) { + + var numbers = [ path.trackPathX ]; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[1] += path.trackPathY; + } + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubic:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 6, error); + if (error.result === OK) { + if (!absolute) { + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + v[4] += path.trackPathX; + v[5] += path.trackPathY; + } + + path.addCubicTo(v[0], v[1], v[2], v[3], v[4], v[5]); + + + v.shift(); + v.shift(); + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubicS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result == OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addCubicTo(x, y, v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseQuadricS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addQuadricTo(x, y, v[0], v[1]); + + this.bezierInfo = []; + bezierInfo.push(x); + bezierInfo.push(y); + bezierInfo.push(v[0]); + bezierInfo.push(v[1]); + + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + + __parseQuadric:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + path.addQuadricTo(v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseClosePath:function (pathInfo, c, path, error) { + + path.closePath(); + error.pos= c; + + }, + + /** + * This method will create a CAAT.PathUtil.Path object with as many contours as needed. + * @param pathInfo {string} a SVG path + * @return Array. + */ + parsePath:function (pathInfo) { + + this.c = 0; + this.contours= []; + + var path = new CAAT.PathUtil.Path(); + this.contours.push( path ); + + this.c = this.__skipBlank(pathInfo, this.c); + if (this.c === pathInfo.length) { + return path; + } + + var ret = { + pos:0, + result:0 + } + + while (this.c != pathInfo.length) { + var segment = pathInfo.charAt(this.c); + switch (segment) { + case 'm': + this.__parseMoveTo(pathInfo, this.c + 1, false, path, ret); + break; + case 'M': + this.__parseMoveTo(pathInfo, this.c + 1, true, path, ret); + break; + case 'c': + this.__parseCubic(pathInfo, this.c + 1, false, path, ret); + break; + case 'C': + this.__parseCubic(pathInfo, this.c + 1, true, path, ret); + break; + case 's': + this.__parseCubicS(pathInfo, this.c + 1, false, path, ret); + break; + case 'S': + this.__parseCubicS(pathInfo, this.c + 1, true, path, ret); + break; + case 'q': + this.__parseQuadric(pathInfo, this.c + 1, false, path, ret); + break; + case 'Q': + this.__parseQuadricS(pathInfo, this.c + 1, true, path, ret); + break; + case 't': + this.__parseQuadricS(pathInfo, this.c + 1, false, path, ret); + break; + case 'T': + this.__parseQuadric(pathInfo, this.c + 1, true, path, ret); + break; + case 'l': + this.__parseLine(pathInfo, this.c + 1, false, path, ret); + break; + case 'L': + this.__parseLine(pathInfo, this.c + 1, true, path, ret); + break; + case 'h': + this.__parseLineH(pathInfo, this.c + 1, false, path, ret); + break; + case 'H': + this.__parseLineH(pathInfo, this.c + 1, true, path, ret); + break; + case 'v': + this.__parseLineV(pathInfo, this.c + 1, false, path, ret); + break; + case 'V': + this.__parseLineV(pathInfo, this.c + 1, true, path, ret); + break; + case 'z': + case 'Z': + this.__parseClosePath(pathInfo, this.c + 1, path, ret); + path= new CAAT.PathUtil.Path(); + this.contours.push( path ); + break; + case 0: + break; + default: + error(pathInfo, this.c); + break; + } + + if (ret.result != OK) { + error(pathInfo, this.c); + break; + } else { + this.c = ret.pos; + } + + } // while + + var count= 0; + var fpath= null; + for( var i=0; i, + * point : { + * x: , + * y: }� + * }> + * @return {*} + */ + addTouch : function( touchInfo ) { + if ( -1===this.touches.indexOf( touchInfo ) ) { + this.touches.push( touchInfo ); + } + return this; + }, + addChangedTouch : function( touchInfo ) { + if ( -1===this.changedTouches.indexOf( touchInfo ) ) { + this.changedTouches.push( touchInfo ); + } + return this; + }, + isAltDown : function() { + return this.alt; + }, + isControlDown : function() { + return this.control; + }, + isShiftDown : function() { + return this.shift; + }, + isMetaDown: function() { + return this.meta; + }, + getSourceEvent : function() { + return this.sourceEvent; + } + } +}); +CAAT.Module( { + + /** + * @name MouseEvent + * @memberOf CAAT.Event + * @constructor + */ + + defines : "CAAT.Event.MouseEvent", + aliases : ["CAAT.MouseEvent"], + depends : [ + "CAAT.Math.Point" + ], + extendsWith : { + + /** + * @lends CAAT.Event.MouseEvent.prototype + */ + + /** + * Constructor delegate + * @private + */ + __init : function() { + this.point= new CAAT.Math.Point(0,0,0); + this.screenPoint= new CAAT.Math.Point(0,0,0); + this.touches= []; + return this; + }, + + /** + * Original mouse/touch screen coord + */ + screenPoint: null, + + /** + * Transformed in-actor coordinate + */ + point: null, + + /** + * scene time when the event was triggered. + */ + time: 0, + + /** + * Actor the event was produced in. + */ + source: null, + + /** + * Was shift pressed ? + */ + shift: false, + + /** + * Was control pressed ? + */ + control: false, + + /** + * was alt pressed ? + */ + alt: false, + + /** + * was Meta key pressed ? + */ + meta: false, + + /** + * Original mouse/touch event + */ + sourceEvent: null, + + touches : null, + + init : function( x,y,sourceEvent,source,screenPoint,time ) { + this.point.set(x,y); + this.source= source; + this.screenPoint= screenPoint; + this.alt = sourceEvent.altKey; + this.control = sourceEvent.ctrlKey; + this.shift = sourceEvent.shiftKey; + this.meta = sourceEvent.metaKey; + this.sourceEvent= sourceEvent; + this.x= x; + this.y= y; + this.time= time; + return this; + }, + isAltDown : function() { + return this.alt; + }, + isControlDown : function() { + return this.control; + }, + isShiftDown : function() { + return this.shift; + }, + isMetaDown: function() { + return this.meta; + }, + getSourceEvent : function() { + return this.sourceEvent; + } + } +}); +CAAT.Module( { + + /** + * @name Event + * @memberOf CAAT + * @namespace + */ + + /** + * @name KeyEvent + * @memberOf CAAT.Event + * @constructor + */ + + /** + * @name KEYS + * @memberOf CAAT + * @namespace + */ + + /** + * @name KEY_MODIFIERS + * @memberOf CAAT + * @namespace + */ + + defines : "CAAT.Event.KeyEvent", + aliases : "CAAT.KeyEvent", + extendsWith : { + + /** + * @lends CAAT.Event.KeyEvent.prototype + */ + + /** + * Define a key event. + * @param keyCode + * @param up_or_down + * @param modifiers + * @param originalEvent + */ + __init : function( keyCode, up_or_down, modifiers, originalEvent ) { + this.keyCode= keyCode; + this.action= up_or_down; + this.modifiers= modifiers; + this.sourceEvent= originalEvent; + + this.preventDefault= function() { + this.sourceEvent.preventDefault(); + } + + this.getKeyCode= function() { + return this.keyCode; + }; + + this.getAction= function() { + return this.action; + }; + + this.modifiers= function() { + return this.modifiers; + }; + + this.isShiftPressed= function() { + return this.modifiers.shift; + }; + + this.isControlPressed= function() { + return this.modifiers.control; + }; + + this.isAltPressed= function() { + return this.modifiers.alt; + }; + + this.getSourceEvent= function() { + return this.sourceEvent; + }; + } + }, + onCreate : function() { + + /** + * @lends CAAT + */ + + /** + * Key codes + * @type {enum} + */ + CAAT.KEYS = { + + /** @const */ ENTER:13, + /** @const */ BACKSPACE:8, + /** @const */ TAB:9, + /** @const */ SHIFT:16, + /** @const */ CTRL:17, + /** @const */ ALT:18, + /** @const */ PAUSE:19, + /** @const */ CAPSLOCK:20, + /** @const */ ESCAPE:27, + /** @const */ PAGEUP:33, + /** @const */ PAGEDOWN:34, + /** @const */ END:35, + /** @const */ HOME:36, + /** @const */ LEFT:37, + /** @const */ UP:38, + /** @const */ RIGHT:39, + /** @const */ DOWN:40, + /** @const */ INSERT:45, + /** @const */ DELETE:46, + /** @const */ 0:48, + /** @const */ 1:49, + /** @const */ 2:50, + /** @const */ 3:51, + /** @const */ 4:52, + /** @const */ 5:53, + /** @const */ 6:54, + /** @const */ 7:55, + /** @const */ 8:56, + /** @const */ 9:57, + /** @const */ a:65, + /** @const */ b:66, + /** @const */ c:67, + /** @const */ d:68, + /** @const */ e:69, + /** @const */ f:70, + /** @const */ g:71, + /** @const */ h:72, + /** @const */ i:73, + /** @const */ j:74, + /** @const */ k:75, + /** @const */ l:76, + /** @const */ m:77, + /** @const */ n:78, + /** @const */ o:79, + /** @const */ p:80, + /** @const */ q:81, + /** @const */ r:82, + /** @const */ s:83, + /** @const */ t:84, + /** @const */ u:85, + /** @const */ v:86, + /** @const */ w:87, + /** @const */ x:88, + /** @const */ y:89, + /** @const */ z:90, + /** @const */ SELECT:93, + /** @const */ NUMPAD0:96, + /** @const */ NUMPAD1:97, + /** @const */ NUMPAD2:98, + /** @const */ NUMPAD3:99, + /** @const */ NUMPAD4:100, + /** @const */ NUMPAD5:101, + /** @const */ NUMPAD6:102, + /** @const */ NUMPAD7:103, + /** @const */ NUMPAD8:104, + /** @const */ NUMPAD9:105, + /** @const */ MULTIPLY:106, + /** @const */ ADD:107, + /** @const */ SUBTRACT:109, + /** @const */ DECIMALPOINT:110, + /** @const */ DIVIDE:111, + /** @const */ F1:112, + /** @const */ F2:113, + /** @const */ F3:114, + /** @const */ F4:115, + /** @const */ F5:116, + /** @const */ F6:117, + /** @const */ F7:118, + /** @const */ F8:119, + /** @const */ F9:120, + /** @const */ F10:121, + /** @const */ F11:122, + /** @const */ F12:123, + /** @const */ NUMLOCK:144, + /** @const */ SCROLLLOCK:145, + /** @const */ SEMICOLON:186, + /** @const */ EQUALSIGN:187, + /** @const */ COMMA:188, + /** @const */ DASH:189, + /** @const */ PERIOD:190, + /** @const */ FORWARDSLASH:191, + /** @const */ GRAVEACCENT:192, + /** @const */ OPENBRACKET:219, + /** @const */ BACKSLASH:220, + /** @const */ CLOSEBRAKET:221, + /** @const */ SINGLEQUOTE:222 + }; + + /** + * @deprecated + * @type {Object} + */ + CAAT.Keys= CAAT.KEYS; + + /** + * Shift key code + * @type {Number} + */ + CAAT.SHIFT_KEY= 16; + + /** + * Control key code + * @type {Number} + */ + CAAT.CONTROL_KEY= 17; + + /** + * Alt key code + * @type {Number} + */ + CAAT.ALT_KEY= 18; + + /** + * Enter key code + * @type {Number} + */ + CAAT.ENTER_KEY= 13; + + /** + * Event modifiers. + * @type enum + */ + CAAT.KEY_MODIFIERS= { + + /** @const */ alt: false, + /** @const */ control: false, + /** @const */ shift: false + }; + } + +}); +CAAT.Module( { + defines : "CAAT.Event.Input", + depends : [ + "CAAT.Event.KeyEvent", + "CAAT.Event.MouseEvent", + "CAAT.Event.TouchEvent" + ], + onCreate : function() { + + /** + * @lends CAAT + */ + + /** + * Set the cursor. + * @param cursor + */ + CAAT.setCursor= function(cursor) { + if ( navigator.browser!=='iOS' ) { + document.body.style.cursor= cursor; + } + }; + + + /** + * Constant to set touch behavior as single touch, compatible with mouse. + * @type {Number} + * @constant + */ + CAAT.TOUCH_AS_MOUSE= 1; + + /** + * Constant to set CAAT touch behavior as multitouch. + * @type {Number} + * @contant + */ + CAAT.TOUCH_AS_MULTITOUCH= 2; + + /** + * Set CAAT touch behavior as single or multi touch. + * @type {Number} + */ + CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MOUSE; + + /** + * Array of window resize listeners. + * @type {Array} + */ + CAAT.windowResizeListeners= []; + + /** + * Register a function callback as window resize listener. + * @param f + */ + CAAT.registerResizeListener= function(f) { + CAAT.windowResizeListeners.push(f); + }; + + /** + * Remove a function callback as window resize listener. + * @param director + */ + CAAT.unregisterResizeListener= function(director) { + for( var i=0; i=this.duration ) { + this.remove= true; + if( this.callback_timeout ) { + this.callback_timeout( time, ttime, this ); + } + } else { + if ( this.callback_tick ) { + this.callback_tick( time, ttime, this ); + } + } + return this; + }, + remainingTime : function() { + return this.duration - (this.scene.time-this.startTime); + }, + /** + * Reschedules this TimerTask by changing its startTime to current scene's time. + * @param time {number} an integer indicating scene time. + * @return this + */ + reset : function( time ) { + this.remove= false; + this.startTime= time; + this.owner.ensureTimerTask(this); + return this; + }, + /** + * Cancels this timer by removing it on scene's next frame. The function callback_cancel will + * be called. + * @return this + */ + cancel : function() { + this.remove= true; + if ( null!=this.callback_cancel ) { + this.callback_cancel( this.scene.time, this.scene.time-this.startTime, this ); + } + return this; + }, + addTime : function( time ) { + this.duration+= time; + return this; + } + } +}); +/** + * See LICENSE file. + */ +CAAT.Module({ + + /** + * @name Timer + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name TimerManager + * @memberOf CAAT.Foundation.Timer + * @constructor + */ + + defines : "CAAT.Foundation.Timer.TimerManager", + aliases : ["CAAT.TimerManager"], + depends : [ + "CAAT.Foundation.Timer.TimerTask" + ], + extendsWith : { + + /** + * @lends CAAT.Foundation.Timer.TimerManager.prototype + */ + + __init:function () { + this.timerList = []; + return this; + }, + + /** + * Collection of registered timers. + * @type {CAAT.Foundation.Timer.TimerManager} + * @private + */ + timerList:null, + + /** + * Index sequence to idenfity registered timers. + * @private + */ + timerSequence:0, + + /** + * Check and apply timers in frame time. + * @param time {number} the current Scene time. + */ + checkTimers:function (time) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (!tl[i].remove) { + tl[i].checkTask(time); + } + i--; + } + }, + /** + * Make sure the timertask is contained in the timer task list by adding it to the list in case it + * is not contained. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return this + */ + ensureTimerTask:function (timertask) { + if (!this.hasTimer(timertask)) { + this.timerList.push(timertask); + } + return this; + }, + /** + * Check whether the timertask is in this scene's timer task list. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return {boolean} a boolean indicating whether the timertask is in this scene or not. + */ + hasTimer:function (timertask) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (tl[i] === timertask) { + return true; + } + i--; + } + + return false; + }, + /** + * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene + * is taken out of the Director the timer task is paused, and resumed on Scene restoration. + * + * @param startTime {number} an integer indicating the scene time this task must start executing at. + * @param duration {number} an integer indicating the timerTask duration. + * @param callback_timeout {function} timer on timeout callback function. + * @param callback_tick {function} timer on tick callback function. + * @param callback_cancel {function} timer on cancel callback function. + * + * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. + */ + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) { + + var tt = new CAAT.Foundation.Timer.TimerTask().create( + startTime, + duration, + callback_timeout, + callback_tick, + callback_cancel); + + tt.taskId = this.timerSequence++; + tt.sceneTime = scene.time; + tt.owner = this; + tt.scene = scene; + + this.timerList.push(tt); + + return tt; + }, + /** + * Removes expired timers. This method must not be called directly. + */ + removeExpiredTimers:function () { + var i; + var tl = this.timerList; + for (i = 0; i < tl.length; i++) { + if (tl[i].remove) { + tl.splice(i, 1); + } + } + } + } +}); +CAAT.Module( { + + /** + * @name Layout + * @memberOf CAAT.Foundation.UI + * @namespace + */ + + /** + * @name LayoutManager + * @memberOf CAAT.Foundation.UI.Layout + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.LayoutManager", + aliases : ["CAAT.UI.LayoutManager"], + depends : [ + "CAAT.Behavior.Interpolator" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager + */ + + /** + * @enum {number} + */ + AXIS: { + X : 0, + Y : 1 + }, + + /** + * @enum {number} + */ + ALIGNMENT : { + LEFT : 0, + RIGHT: 1, + CENTER: 2, + TOP: 3, + BOTTOM: 4, + JUSTIFY:5 + } + + }, + extendsWith : function() { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager.prototype + */ + + + __init : function( ) { + + this.newChildren= []; + this.padding= { + left: 2, + right: 2, + top: 2, + bottom: 2 + }; + + return this; + }, + + /** + * If animation enabled, new element interpolator. + */ + newElementInterpolator : new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1,.7), + + /** + * If animation enabled, relayout elements interpolator. + */ + moveElementInterpolator : new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2), + + /** + * Defines insets: + * @type {{ left, right, top, botton }} + */ + padding : null, + + /** + * Needs relayout ?? + */ + invalid : true, + + /** + * Horizontal gap between children. + */ + hgap : 2, + + /** + * Vertical gap between children. + */ + vgap : 2, + + /** + * Animate on adding/removing elements. + */ + animated : false, + + /** + * pending to be laid-out actors. + */ + newChildren : null, + + setAnimated : function( animate ) { + this.animated= animate; + return this; + }, + + setHGap : function( gap ) { + this.hgap= gap; + this.invalidateLayout(); + return this; + }, + + setVGap : function( gap ) { + this.vgap= gap; + this.invalidateLayout(); + return this; + }, + + setAllPadding : function( s ) { + this.padding.left= s; + this.padding.right= s; + this.padding.top= s; + this.padding.bottom= s; + this.invalidateLayout(); + return this; + }, + + setPadding : function( l,r, t,b ) { + this.padding.left= l; + this.padding.right= r; + this.padding.top= t; + this.padding.bottom= b; + this.invalidateLayout(); + return this; + }, + + addChild : function( child, constraints ) { + this.newChildren.push( child ); + }, + + removeChild : function( child ) { + + }, + + doLayout : function( container ) { + this.newChildren= []; + this.invalid= false; + }, + + invalidateLayout : function( container ) { + this.invalid= true; + }, + + getMinimumLayoutSize : function( container ) { + + }, + + getPreferredLayoutSize : function(container ) { + + }, + + isValid : function() { + return !this.invalid; + }, + + isInvalidated : function() { + return this.invalid; + } + } + } +}); +CAAT.Module({ + + /** + * @name BoxLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines:"CAAT.Foundation.UI.Layout.BoxLayout", + aliases:["CAAT.UI.BoxLayout"], + depends:[ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass:"CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.BoxLayout.prototype + */ + + /** + * Stack elements in this axis. + * @type {CAAT.Foundation.UI.Layout.LayoutManager} + */ + axis:CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y, + + /** + * Vertical alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + valign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + /** + * Horizontal alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + halign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + setAxis:function (axis) { + this.axis = axis; + this.invalidateLayout(); + return this; + }, + + setHorizontalAlignment:function (align) { + this.halign = align; + this.invalidateLayout(); + return this; + }, + + setVerticalAlignment:function (align) { + this.valign = align; + this.invalidateLayout(); + return this; + }, + + doLayout:function (container) { + + if (this.axis === CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y) { + this.doLayoutVertical(container); + } else { + this.doLayoutHorizontal(container); + } + + CAAT.Foundation.UI.Layout.BoxLayout.superclass.doLayout.call(this, container); + }, + + doLayoutHorizontal:function (container) { + + var computedW = 0, computedH = 0; + var yoffset = 0, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedH < actor.height) { + computedH = actor.height; + } + + computedW += actor.width; + if (i > 0) { + computedW += this.hgap; + } + } + } + + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - computedW - this.padding.right; + break; + default: + xoffset = (container.width - computedW) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - this.padding.bottom - actor.height; + break; + default: + yoffset = (container.height - actor.height) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + xoffset += actor.width + this.hgap; + } + } + + }, + + __setActorPosition:function (actor, xoffset, yoffset) { + if (this.animated) { + if (this.newChildren.indexOf(actor) !== -1) { + actor.setPosition(xoffset, yoffset); + actor.setScale(0, 0); + actor.scaleTo(1, 1, 500, 0, .5, .5, this.newElementInterpolator); + } else { + actor.moveTo(xoffset, yoffset, 500, 0, this.moveElementInterpolator); + } + } else { + actor.setPosition(xoffset, yoffset); + } + }, + + doLayoutVertical:function (container) { + + var computedW = 0, computedH = 0; + var yoffset, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedW < actor.width) { + computedW = actor.width; + } + + computedH += actor.height; + if (i > 0) { + computedH += this.vgap; + } + } + } + + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - computedH - this.padding.bottom; + break; + default: + yoffset = (container.height - computedH) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - this.padding.right - actor.width; + break; + default: + xoffset = (container.width - actor.width) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + yoffset += actor.height + this.vgap; + } + } + }, + + getPreferredLayoutSize:function (container) { + + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getPreferredSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + }, + + getMinimumLayoutSize:function (container) { + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getMinimumSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + } + } + } +}); +CAAT.Module( { + + /** + * @name BorderLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.BorderLayout", + aliases : ["CAAT.UI.BorderLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.BorderLayout.prototype + */ + + + __init : function() { + this.__super(); + return this; + }, + + /** + * An actor to position left. + */ + left : null, + + /** + * An actor to position right. + */ + right : null, + + /** + * An actor to position top. + */ + top : null, + + /** + * An actor to position botton. + */ + bottom : null, + + /** + * An actor to position center. + */ + center : null, + + addChild : function( child, constraint ) { + + if ( typeof constraint==="undefined" ) { + constraint="center"; + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.addChild.call( this, child, constraint ); + + if ( constraint==="left" ) { + this.left= child; + } else if ( constraint==="right" ) { + this.right= child; + } else if ( constraint==="top" ) { + this.top= child; + } else if ( constraint==="bottom" ) { + this.bottom= child; + } else { + //"center" + this.center= child; + } + }, + + removeChild : function( child ) { + if ( this.center===child ) { + this.center=null; + } else if ( this.left===child ) { + this.left= null; + } else if ( this.right===child ) { + this.right= null; + } else if ( this.top===child ) { + this.top= null; + } else if ( this.bottom===child ) { + this.bottom= null; + } + }, + + __getChild : function( constraint ) { + if ( constraint==="center" ) { + return this.center; + } else if ( constraint==="left" ) { + return this.left; + } else if ( constraint==="right" ) { + return this.right; + } else if ( constraint==="top" ) { + return this.top; + } else if ( constraint==="bottom" ) { + return this.bottom; + } + }, + + getMinimumLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Math.Dimension(); + + if ((c=this.__getChild("right")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("left")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getMinimumSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + getPreferredLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Dimension(); + + if ((c=this.__getChild("left")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("right")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getPreferredSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + doLayout : function( container ) { + + var top = this.padding.top; + var bottom = container.height - this.padding.bottom; + var left = this.padding.left; + var right = container.width - this.padding.right; + var c, d; + + if ((c=this.__getChild("top")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, top, right - left, d.height); + top += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, bottom - d.height, right - left, d.height); + bottom -= d.height + this.vgap; + } + if ((c=this.__getChild("right")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(right - d.width, top, d.width, bottom - top); + right -= d.width + this.hgap; + } + if ((c=this.__getChild("left")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(left, top, d.width, bottom - top); + left += d.width + this.hgap; + } + if ((c=this.__getChild("center")) != null) { + c.setBounds(left, top, right - left, bottom - top); + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.doLayout.call(this, container); + } + + + } + +}); +CAAT.Module( { + + /** + * @name GridLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.GridLayout", + aliases : ["CAAT.UI.GridLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.GridLayout.prototype + */ + + __init : function( rows, columns ) { + this.__super(); + this.rows= rows; + this.columns= columns; + + return this; + }, + + /** + * Layout elements using this number of rows. + */ + rows : 0, + + /** + * Layout elements using this number of columns. + */ + columns : 2, + + doLayout : function( container ) { + + var actors= []; + for( var i=0; i 0) { + ncols = Math.floor( (nactors + nrows - 1) / nrows ); + } else { + nrows = Math.floor( (nactors + ncols - 1) / ncols ); + } + + var totalGapsWidth = (ncols - 1) * this.hgap; + var widthWOInsets = container.width - (this.padding.left + this.padding.right); + var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols ); + var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 ); + + var totalGapsHeight = (nrows - 1) * this.vgap; + var heightWOInsets = container.height - (this.padding.top + this.padding.bottom); + var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows ); + var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 ); + + for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) { + for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) { + var i = r * ncols + c; + if (i < actors.length) { + var child= actors[i]; + if ( !child.preventLayout && child.isVisible() && child.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + if ( !this.animated ) { + child.setBounds( + x + (widthOnComponent-child.width)/2, + y, + widthOnComponent, + heightOnComponent); + } else { + if ( child.width!==widthOnComponent || child.height!==heightOnComponent ) { + child.setSize(widthOnComponent, heightOnComponent); + if ( this.newChildren.indexOf( child ) !==-1 ) { + child.setPosition( + x + (widthOnComponent-child.width)/2, + y ); + child.setScale(0.01,0.01); + child.scaleTo( 1,1, 500, 0,.5,.5, this.newElementInterpolator ); + } else { + child.moveTo( + x + (widthOnComponent-child.width)/2, + y, + 500, + 0, + this.moveElementInterpolator ); + } + } + } + } + } + } + } + + CAAT.Foundation.UI.Layout.GridLayout.superclass.doLayout.call(this, container); + }, + + getMinimumLayoutSize : function( container ) { + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getMinimumSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + }, + + getPreferredLayoutSize : function( container ) { + + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getPreferredSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + } + + } +}); +CAAT.Module( { + + /** + * Define a drawable sub-image inside a bigger image as an independant drawable item. + * + * @name SpriteImageHelper + * @memberOf CAAT.Foundation + * @constructor + * + * + * + */ + + + defines : "CAAT.Foundation.SpriteImageHelper", + + extendsWith : { + + /** + * @lends CAAT.Foundation.SpriteImageHelper.prototype + */ + + __init : function (x, y, w, h, iw, ih) { + this.x = parseFloat(x); + this.y = parseFloat(y); + this.width = parseFloat(w); + this.height = parseFloat(h); + + this.setGL(x / iw, y / ih, (x + w - 1) / iw, (y + h - 1) / ih); + return this; + }, + + x:0, + y:0, + width:0, + height:0, + u:0, + v:0, + u1:0, + v1:0, + + setGL:function (u, v, u1, v1) { + this.u = u; + this.v = v; + this.u1 = u1; + this.v1 = v1; + return this; + } + } +}); +CAAT.Module({ + + /** + * + * Define an animation frame sequence, name it and supply with a callback which be called when the + * sequence ends playing. + * + * @name SpriteImageAnimationHelper + * @memberOf CAAT.Foundation + * @constructor + */ + + defines : "CAAT.Foundation.SpriteImageAnimationHelper", + extendsWith : function() { + return { + + /** + * @lends CAAT.Foundation.SpriteImageAnimationHelper.prototype + */ + + __init : function( animation, time, onEndPlayCallback ) { + this.animation= animation; + this.time= time; + this.onEndPlayCallback= onEndPlayCallback; + return this; + }, + + /** + * A sequence of integer values defining a frame animation. + * For example [1,2,3,4,3,2,3,4,3,2] + * Array. + */ + animation : null, + + /** + * Time between any two animation frames. + */ + time : 0, + + /** + * Call this callback function when the sequence ends. + */ + onEndPlayCallback : null + + } + } +});/** + * See LICENSE file. + * + * TODO: allow set of margins, spacing, etc. to define subimages. + * + **/ + +CAAT.Module({ + + /** + * @name SpriteImage + * @memberOf CAAT.Foundation + * @constructor + */ + + + defines : "CAAT.Foundation.SpriteImage", + aliases : ["CAAT.SpriteImage"], + depends : [ + "CAAT.Foundation.SpriteImageHelper", + "CAAT.Foundation.SpriteImageAnimationHelper", + "CAAT.Math.Rectangle" + ], + constants:{ + /** + * @lends CAAT.Foundation.SpriteImage + */ + + /** @const @type {number} */ TR_NONE:0, // constants used to determine how to draw the sprite image, + /** @const @type {number} */ TR_FLIP_HORIZONTAL:1, + /** @const @type {number} */ TR_FLIP_VERTICAL:2, + /** @const @type {number} */ TR_FLIP_ALL:3, + /** @const @type {number} */ TR_FIXED_TO_SIZE:4, + /** @const @type {number} */ TR_FIXED_WIDTH_TO_SIZE:6, + /** @const @type {number} */ TR_TILE:5 + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.SpriteImage.prototype + */ + + __init:function () { + this.paint = this.paintN; + this.setAnimationImageIndex([0]); + this.mapInfo = {}; + this.animationsMap= {}; + + if ( arguments.length===1 ) { + this.initialize.call(this, arguments[0], 1, 1); + } else if ( arguments.length===3 ) { + this.initialize.apply(this, arguments); + } + return this; + }, + + /** + * an Array defining the sprite frame sequence + */ + animationImageIndex:null, + + /** + * Previous animation frame time. + */ + prevAnimationTime:-1, + + /** + * how much Scene time to take before changing an Sprite frame. + */ + changeFPS:1000, + + /** + * any of the TR_* constants. + */ + transformation:0, + + /** + * the current sprite frame + */ + spriteIndex:0, + + /** + * current index of sprite frames array. + */ + prevIndex:0, // + + /** + * current animation name + */ + currentAnimation: null, + + /** + * Image to get frames from. + */ + image:null, + + /** + * Number of rows + */ + rows:1, + + /** + * Number of columns. + */ + columns:1, + + /** + * This sprite image image´s width + */ + width:0, + + /** + * This sprite image image´s width + */ + height:0, + + /** + * For each element in the sprite image array, its size. + */ + singleWidth:0, + + /** + * For each element in the sprite image array, its height. + */ + singleHeight:0, + + scaleX:1, + scaleY:1, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetX:0, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetY:0, + + /** + * When nesting sprite images, this value is the star X position of this sprite image in the parent. + */ + parentOffsetX:0, // para especificar una subimagen dentro un textmap. + + /** + * When nesting sprite images, this value is the star Y position of this sprite image in the parent. + */ + parentOffsetY:0, + + /** + * The actor this sprite image belongs to. + */ + ownerActor:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages calculated definition map. + */ + mapInfo:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages original definition map. + */ + map:null, + + /** + * This property allows to have multiple different animations defined for one actor. + * see demo31 for a sample. + */ + animationsMap : null, + + /** + * When an animation sequence ends, this callback function will be called. + */ + callback : null, // on end animation callback + + /** + * pending: refactor -> font scale to a font object. + */ + fontScale : 1, + + getOwnerActor : function() { + return this.ownerActor; + }, + + /** + * Add an animation to this sprite image. + * An animation is defines by an array of pretend-to-be-played sprite sequence. + * + * @param name {string} animation name. + * @param array {Array} the sprite animation sequence array. It can be defined + * as number array for Grid-like sprite images or strings for a map-like sprite + * image. + * @param time {number} change animation sequence every 'time' ms. + * @param callback {function({SpriteImage},{string}} a callback function to invoke when the sprite + * animation sequence has ended. + */ + addAnimation : function( name, array, time, callback ) { + this.animationsMap[name]= new CAAT.Foundation.SpriteImageAnimationHelper(array,time,callback); + return this; + }, + + setAnimationEndCallback : function(f) { + this.callback= f; + }, + + /** + * Start playing a SpriteImage animation. + * If it does not exist, nothing happens. + * @param name + */ + playAnimation : function(name) { + if (name===this.currentAnimation) { + return this; + } + + var animation= this.animationsMap[name]; + if ( !animation ) { + return this; + } + + this.currentAnimation= name; + + this.setAnimationImageIndex( animation.animation ); + this.changeFPS= animation.time; + this.callback= animation.onEndPlayCallback; + + return this; + }, + + setOwner:function (actor) { + this.ownerActor = actor; + return this; + }, + getRows:function () { + return this.rows; + }, + getColumns:function () { + return this.columns; + }, + + getWidth:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.width; + }, + + getHeight:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.height; + }, + + getWrappedImageWidth:function () { + return this.image.width; + }, + + getWrappedImageHeight:function () { + return this.image.height; + }, + + /** + * Get a reference to the same image information (rows, columns, image and uv cache) of this + * SpriteImage. This means that re-initializing this objects image info (that is, calling initialize + * method) will change all reference's image information at the same time. + */ + getRef:function () { + var ret = new CAAT.Foundation.SpriteImage(); + ret.image = this.image; + ret.rows = this.rows; + ret.columns = this.columns; + ret.width = this.width; + ret.height = this.height; + ret.singleWidth = this.singleWidth; + ret.singleHeight = this.singleHeight; + ret.mapInfo = this.mapInfo; + ret.offsetX = this.offsetX; + ret.offsetY = this.offsetY; + ret.scaleX = this.scaleX; + ret.scaleY = this.scaleY; + ret.animationsMap= this.animationsMap; + ret.parentOffsetX= this.parentOffsetX; + ret.parentOffsetY= this.parentOffsetY; + + ret.scaleFont= this.scaleFont; + + return ret; + }, + /** + * Set horizontal displacement to draw image. Positive values means drawing the image more to the + * right. + * @param x {number} + * @return this + */ + setOffsetX:function (x) { + this.offsetX = x; + return this; + }, + /** + * Set vertical displacement to draw image. Positive values means drawing the image more to the + * bottom. + * @param y {number} + * @return this + */ + setOffsetY:function (y) { + this.offsetY = y; + return this; + }, + setOffset:function (x, y) { + this.offsetX = x; + this.offsetY = y; + return this; + }, + /** + * Initialize a grid of subimages out of a given image. + * @param image {HTMLImageElement|Image} an image object. + * @param rows {number} number of rows. + * @param columns {number} number of columns + * + * @return this + */ + initialize:function (image, rows, columns) { + + if (!image) { + console.log("Null image for SpriteImage."); + } + + if ( isString(image) ) { + image= CAAT.currentDirector.getImage(image); + } + + this.parentOffsetX= 0; + this.parentOffsetY= 0; + + this.rows = rows; + this.columns = columns; + + if ( image instanceof CAAT.Foundation.SpriteImage || image instanceof CAAT.SpriteImage ) { + this.image = image.image; + var sihelper= image.mapInfo[0]; + this.width= sihelper.width; + this.height= sihelper.height; + + this.parentOffsetX= sihelper.x; + this.parentOffsetY= sihelper.y; + + this.width= image.mapInfo[0].width; + this.height= image.mapInfo[0].height; + + } else { + this.image = image; + this.width = image.width; + this.height = image.height; + this.mapInfo = {}; + + } + + this.singleWidth = Math.floor(this.width / columns); + this.singleHeight = Math.floor(this.height / rows); + + var i, sx0, sy0; + var helper; + + if (image.__texturePage) { + image.__du = this.singleWidth / image.__texturePage.width; + image.__dv = this.singleHeight / image.__texturePage.height; + + + var w = this.singleWidth; + var h = this.singleHeight; + var mod = this.columns; + if (image.inverted) { + var t = w; + w = h; + h = t; + mod = this.rows; + } + + var xt = this.image.__tx; + var yt = this.image.__ty; + + var tp = this.image.__texturePage; + + for (i = 0; i < rows * columns; i++) { + + + var c = ((i % mod) >> 0); + var r = ((i / mod) >> 0); + + var u = xt + c * w; // esquina izq x + var v = yt + r * h; + + var u1 = u + w; + var v1 = v + h; + + helper = new CAAT.Foundation.SpriteImageHelper(u, v, (u1 - u), (v1 - v), tp.width, tp.height).setGL( + u / tp.width, + v / tp.height, + u1 / tp.width, + v1 / tp.height); + + this.mapInfo[i] = helper; + } + + } else { + for (i = 0; i < rows * columns; i++) { + sx0 = ((i % this.columns) | 0) * this.singleWidth + this.parentOffsetX; + sy0 = ((i / this.columns) | 0) * this.singleHeight + this.parentOffsetY; + + helper = new CAAT.Foundation.SpriteImageHelper(sx0, sy0, this.singleWidth, this.singleHeight, image.width, image.height); + this.mapInfo[i] = helper; + } + } + + return this; + }, + + /** + * Create elements as director.getImage values. + * Create as much as elements defined in this sprite image. + * The elements will be named prefix+ + * @param prefix + */ + addElementsAsImages : function( prefix ) { + for( var i in this.mapInfo ) { + var si= new CAAT.Foundation.SpriteImage().initialize( this.image, 1, 1 ); + si.addElement(0, this.mapInfo[i]); + si.setSpriteIndex(0); + CAAT.currentDirector.addImage( prefix+i, si ); + } + }, + + copy : function( other ) { + this.initialize(other,1,1); + this.mapInfo= other.mapInfo; + return this; + }, + + /** + * Must be used to draw actor background and the actor should have setClip(true) so that the image tiles + * properly. + * @param director + * @param time + * @param x + * @param y + */ + paintTiled:function (director, time, x, y) { + + // PENDING: study using a pattern + + var el = this.mapInfo[this.spriteIndex]; + + var r = new CAAT.Math.Rectangle(); + this.ownerActor.AABB.intersect(director.AABB, r); + + var w = this.getWidth(); + var h = this.getHeight(); + var xoff = (this.offsetX - this.ownerActor.x) % w; + if (xoff > 0) { + xoff = xoff - w; + } + var yoff = (this.offsetY - this.ownerActor.y) % h; + if (yoff > 0) { + yoff = yoff - h; + } + + var nw = (((r.width - xoff) / w) >> 0) + 1; + var nh = (((r.height - yoff) / h) >> 0) + 1; + var i, j; + var ctx = director.ctx; + + for (i = 0; i < nh; i++) { + for (j = 0; j < nw; j++) { + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (r.x - this.ownerActor.x + xoff + j * el.width) >> 0, (r.y - this.ownerActor.y + yoff + i * el.height) >> 0, + el.width, el.height); + } + } + }, + + /** + * Draws the subimage pointed by imageIndex horizontally inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedH:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0); + ctx.translate((x | 0) + el.width, y | 0); + ctx.scale(-1, 1); + + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex both horizontal and vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedHV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + ctx.translate(el.width, 0); + ctx.scale(-1, 1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintN:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + paintAtRect:function (director, time, x, y, w, h) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + w, h); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaledWidth:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, el.height); + + return this; + }, + paintChunk:function (ctx, dx, dy, x, y, w, h) { + ctx.drawImage(this.image, x, y, w, h, dx, dy, w, h); + }, + paintTile:function (ctx, index, x, y) { + var el = this.mapInfo[index]; + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex scaled to the size of w and h. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaled:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, this.ownerActor.height); + + return this; + }, + getCurrentSpriteImageCSSPosition:function () { + var el = this.mapInfo[this.spriteIndex]; + + var x = -(el.x + this.parentOffsetX - this.offsetX); + var y = -(el.y + this.parentOffsetY - this.offsetY); + + return '' + x + 'px ' + + y + 'px ' + + (this.ownerActor.transformation === CAAT.Foundation.SpriteImage.TR_TILE ? 'repeat' : 'no-repeat'); + }, + /** + * Get the number of subimages in this compoundImage + * @return {number} + */ + getNumImages:function () { + return this.rows * this.columns; + }, + + setUV:function (uvBuffer, uvIndex) { + var im = this.image; + + if (!im.__texturePage) { + return; + } + + var index = uvIndex; + var sIndex = this.spriteIndex; + var el = this.mapInfo[this.spriteIndex]; + + var u = el.u; + var v = el.v; + var u1 = el.u1; + var v1 = el.v1; + if (this.offsetX || this.offsetY) { + var w = this.ownerActor.width; + var h = this.ownerActor.height; + + var tp = im.__texturePage; + + var _u = -this.offsetX / tp.width; + var _v = -this.offsetY / tp.height; + var _u1 = (w - this.offsetX) / tp.width; + var _v1 = (h - this.offsetY) / tp.height; + + u = _u + im.__u; + v = _v + im.__v; + u1 = _u1 + im.__u; + v1 = _v1 + im.__v; + } + + if (im.inverted) { + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v; + } else { + uvBuffer[index++] = u; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + } + }, + /** + * Set the elapsed time needed to change the image index. + * @param fps an integer indicating the time in milliseconds to change. + * @return this + */ + setChangeFPS:function (fps) { + this.changeFPS = fps; + return this; + }, + /** + * Set the transformation to apply to the Sprite image. + * Any value of + *

  • TR_NONE + *
  • TR_FLIP_HORIZONTAL + *
  • TR_FLIP_VERTICAL + *
  • TR_FLIP_ALL + * + * @param transformation an integer indicating one of the previous values. + * @return this + */ + setSpriteTransformation:function (transformation) { + this.transformation = transformation; + var v = CAAT.Foundation.SpriteImage; + switch (transformation) { + case v.TR_FLIP_HORIZONTAL: + this.paint = this.paintInvertedH; + break; + case v.TR_FLIP_VERTICAL: + this.paint = this.paintInvertedV; + break; + case v.TR_FLIP_ALL: + this.paint = this.paintInvertedHV; + break; + case v.TR_FIXED_TO_SIZE: + this.paint = this.paintScaled; + break; + case v.TR_FIXED_WIDTH_TO_SIZE: + this.paint = this.paintScaledWidth; + break; + case v.TR_TILE: + this.paint = this.paintTiled; + break; + default: + this.paint = this.paintN; + } + this.ownerActor.invalidate(); + return this; + }, + + resetAnimationTime:function () { + this.prevAnimationTime = -1; + return this; + }, + + /** + * Set the sprite animation images index. This method accepts an array of objects which define indexes to + * subimages inside this sprite image. + * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of + * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages + * with size rows*columns. + * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected + * to be an array of strings which are the names of the subobjects contained in the map object. + * + * @param aAnimationImageIndex an array indicating the Sprite's frames. + */ + setAnimationImageIndex:function (aAnimationImageIndex) { + this.animationImageIndex = aAnimationImageIndex; + this.spriteIndex = aAnimationImageIndex[0]; + this.prevAnimationTime = -1; + + return this; + }, + setSpriteIndex:function (index) { + this.spriteIndex = index; + return this; + }, + + /** + * Draws the sprite image calculated and stored in spriteIndex. + * + * @param time {number} Scene time when the bounding box is to be drawn. + */ + setSpriteIndexAtTime:function (time) { + + if (this.animationImageIndex.length > 1) { + if (this.prevAnimationTime === -1) { + this.prevAnimationTime = time; + + //thanks Phloog and ghthor, well spotted. + this.spriteIndex = this.animationImageIndex[0]; + this.prevIndex= 0; + this.ownerActor.invalidate(); + } + else { + var ttime = time; + ttime -= this.prevAnimationTime; + ttime /= this.changeFPS; + ttime %= this.animationImageIndex.length; + var idx = Math.floor(ttime); +// if ( this.spriteIndex!==idx ) { + + if ( idx" : { + * id : {number}, + * height : {number}, + * xoffset : {number}, + * letter : {string}, + * yoffset : {number}, + * width : {number}, + * xadvance: {number}, + * y : {number}, + * x : {number} + * } + */ + initializeAsGlyphDesigner:function (image, map) { + this.initialize(image, 1, 1); + + var key; + var helper; + var count = 0; + + for (key in map) { + var value = map[key]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(value.x) + this.parentOffsetX, + parseFloat(value.y) + this.parentOffsetX, + parseFloat(value.width), + parseFloat(value.height), + image.width, + image.height + ); + + helper.xoffset = typeof value.xoffset === 'undefined' ? 0 : value.xoffset; + helper.yoffset = typeof value.yoffset === 'undefined' ? 0 : value.yoffset; + helper.xadvance = typeof value.xadvance === 'undefined' ? value.width : value.xadvance; + + this.mapInfo[key] = helper; + + // set a default spriteIndex + if (!count) { + this.setAnimationImageIndex([key]); + } + + count++; + } + + return this; + + }, + + + initializeAsFontMap:function (image, chars) { + this.initialize(image, 1, 1); + + var helper; + var x = 0; + + for (var i = 0; i < chars.length; i++) { + var value = chars[i]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(x) + this.parentOffsetX, + 0 + this.parentOffsetY, + parseFloat(value.width), + image.height, + image.width, + image.height + ); + + helper.xoffset = 0; + helper.yoffset = 0; + helper.xadvance = value.width; + + + x += value.width; + + this.mapInfo[chars[i].c] = helper; + + // set a default spriteIndex + if (!i) { + this.setAnimationImageIndex([chars[i].c]); + } + } + + return this; + }, + + /** + * This method creates a font sprite image based on a proportional font + * It assumes the font is evenly spaced in the image + * Example: + * var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( + * director.getImage('numbers'), + * "0123456789" + * ); + */ + + initializeAsMonoTypeFontMap:function (image, chars) { + var map = []; + var charArr = chars.split(""); + + var w = image.width / charArr.length >> 0; + + for (var i = 0; i < charArr.length; i++) { + map.push({c:charArr[i], width:w }); + } + + return this.initializeAsFontMap(image, map); + }, + + stringWidth:function (str) { + var i, l, w = 0, charInfo; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w += charInfo.xadvance * this.fontScale; + } + } + + return w; + }, + + stringHeight:function () { + if (this.fontHeight) { + return this.fontHeight * this.fontScale; + } + + var y = 0; + for (var i in this.mapInfo) { + var mi = this.mapInfo[i]; + + var h = mi.height + mi.yoffset; + if (h > y) { + y = h; + } + } + + this.fontHeight = y; + return this.fontHeight * this.fontScale; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + + for (i = 0; i < str.length; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, charInfo.y, + w, charInfo.height, + + x + charInfo.xoffset* this.fontScale, y + charInfo.yoffset* this.fontScale, + w* this.fontScale, charInfo.height* this.fontScale); + } + x += charInfo.xadvance* this.fontScale; + } + } + }, + + getFontData : function() { + var as= (this.stringHeight() *.8)>>0; + return { + height : this.stringHeight(), + ascent : as, + descent: this.stringHeight() - as + }; + + } + + } + } +}); +CAAT.Module({ + defines:"CAAT.Foundation.Actor", + aliases:[ "CAAT.Actor" ], + depends:[ + "CAAT.Event.AnimationLoop", + "CAAT.Foundation.SpriteImage", + "CAAT.Core.Constants", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.Scale1Behavior", + "CAAT.PathUtil.LinearPath", + "CAAT.Event.AnimationLoop" + ], + constants:{ + ANCHOR_CENTER:0, // constant values to determine different affine transform + ANCHOR_TOP:1, // anchors. + ANCHOR_BOTTOM:2, + ANCHOR_LEFT:3, + ANCHOR_RIGHT:4, + ANCHOR_TOP_LEFT:5, + ANCHOR_TOP_RIGHT:6, + ANCHOR_BOTTOM_LEFT:7, + ANCHOR_BOTTOM_RIGHT:8, + ANCHOR_CUSTOM:9, + + NO_CACHE:0, + CACHE_SIMPLE:1, + CACHE_DEEP:2 + }, + extendsWith:function () { + + var __index = 0; + + return { + + __init:function () { + this.behaviorList = []; + + this.styleCache = {}; + this.lifecycleListenerList = []; + this.scaleAnchor = this.ANCHOR_CENTER; + this.behaviorList = []; + + this.domElement = document.createElement('div'); + this.domElement.style['position'] = 'absolute'; + this.domElement.style['-webkit-transform'] = 'translate3d(0,0,0)'; + this.domElement.style['-webkit-transition'] = 'all 0s linear'; + this.style('display', 'none'); + + this.AABB = new CAAT.Rectangle(); + this.viewVertices = [ + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0) + ]; + + this.setVisible(true); + this.resetTransform(); + this.setScale(1, 1); + this.setRotation(0); + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrixI = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrixI = new CAAT.Math.Matrix(); + + return this; + }, + lifecycleListenerList:null, // Array of life cycle listener + behaviorList:null, // Array of behaviors to apply to the Actor + x:0, // x position on parent. In parent's local coord. system. + y:0, // y position on parent. In parent's local coord. system. + width:0, // Actor's width. In parent's local coord. system. + height:0, // Actor's height. In parent's local coord. system. + preferredSize:null, // actor's preferred size for layout. {CAAT.Dimension} + minimumSize:null, // actor's minimum size for layout. {CAAT.Dimension}, + start_time:0, // Start time in Scene time. + duration:Number.MAX_VALUE, // Actor duration in Scene time + clip:false, // should clip the Actor's content against its contour. + + tAnchorX:0, + tAnchorY:0, + scaleX:0, // transformation. width scale parameter + scaleY:0, // transformation. height scale parameter + scaleTX:.50, // transformation. scale anchor x position + scaleTY:.50, // transformation. scale anchor y position + scaleAnchor:0, // transformation. scale anchor + rotationAngle:0, // transformation. rotation angle in radians + rotationY:.50, // transformation. rotation center y + alpha:1, // alpha transparency value + rotationX:.50, // transformation. rotation center x + isGlobalAlpha:false, // is this a global alpha + frameAlpha:1, // hierarchically calculated alpha for this Actor. + expired:false, // set when the actor has been expired + discardable:false, // set when you want this actor to be removed if expired + + domParent:null, + domElement:null, + + visible:true, + + mouseEnabled:true, + + time:0, // Cache Scene time. + inFrame:false, // boolean indicating whether this Actor was present on last frame. + backgroundImage:null, + + size_active:1, // number of animated children + size_total:1, + + id:null, + + __d_ax:-1, // for drag-enabled actors. + __d_ay:-1, + gestureEnabled:false, + + AABB:null, + viewVertices:null, // model to view transformed vertices. + isAA:true, + + preventLayout : false, + + setPreventLayout : function(b) { + this.preventLayout= b; + return this; + }, + + invalidate:function () { + this.invalid = true; + return this; + }, + + invalidateLayout:function () { + if (this.parent && !this.parent.layoutInvalidated) { + this.parent.invalidateLayout(); + } + + return this; + }, + + __validateLayout:function () { + + }, + + /** + * Set this actors preferred layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setPreferredSize:function (pw, ph) { + if (!this.preferredSize) { + this.preferredSize = new CAAT.Dimension(); + } + this.preferredSize.width = pw; + this.preferredSize.height = ph; + return this; + }, + + getPreferredSize:function () { + return this.preferredSize ? this.preferredSize : + this.getMinimumSize(); + }, + + /** + * Set this actors minimum layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setMinimumSize:function (pw, ph) { + if (!this.minimumSize) { + this.minimumSize = new CAAT.Dimension(); + } + + this.minimumSize.width = pw; + this.minimumSize.height = ph; + return this; + }, + + getMinimumSize:function () { + return this.minimumSize ? this.minimumSize : + new CAAT.Dimension(this.width, this.height); + }, + + isVisible:function () { + return this.visible; + }, + + /** + * @deprecated + * @return {*} + */ + create:function () { + return this; + }, + /** + * Move this actor to a position. + * It creates and adds a new PathBehavior. + * @param x {number} new x position + * @param y {number} new y position + * @param duration {number} time to take to get to new position + * @param delay {=number} time to wait before start moving + * @param interpolator {=CAAT.Interpolator} a CAAT.Interpolator instance + */ + moveTo:function (x, y, duration, delay, interpolator) { + + if (x === this.x && y === this.y) { + return; + } + + var id = '__moveTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.PathBehavior(). + setId(id). + setValues(new CAAT.LinearPath()); + this.addBehavior(b); + } + + b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y); + b.setDelayTime(delay ? delay : 0, duration); + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param angle {number} new rotation angle + * @param duration {number} time to rotate + * @param delay {number=} millis to start rotation + * @param anchorX {number=} rotation anchor x + * @param anchorY {number=} rotation anchor y + * @param interpolator {CAAT.Interpolator=} + * @return {*} + */ + rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) { + + if (angle === this.rotationAngle) { + return; + } + + var id = '__rotateTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.RotateBehavior(). + setId(id). + setValues(0, 0, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.rotationAngle, angle, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) { + + if (this.scaleX === scaleX && this.scaleY === scaleY) { + return; + } + + var id = '__scaleTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.ScaleBehavior(). + setId(id). + setValues(1, 1, 1, 1, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Scale1Behavior.AXIS_X, + scaleX, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Scale1Behavior.AXIS_Y, + scaleY, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis + * @param scale {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) { + + if (( axis === CAAT.Scale1Behavior.AXIS_X && scale === this.scaleX) || + ( axis === CAAT.Scale1Behavior.AXIS_Y && scale === this.scaleY)) { + + return; + } + + var id = '__scaleXTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Scale1Behavior(). + setId(id). + setValues(1, 1, axis === CAAT.Scale1Behavior.AXIS_X, .5, .5); + this.addBehavior(b); + } + + b.setValues( + axis ? this.scaleX : this.scaleY, + scale, + anchorX, + anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH + * @param e + */ + touchStart:function (e) { + }, + touchMove:function (e) { + }, + touchEnd:function (e) { + }, + gestureStart:function (rotation, scaleX, scaleY) { + }, + gestureChange:function (rotation, scaleX, scaleY) { + if (this.gestureEnabled) { + this.setRotation(rotation); + this.setScale(scaleX, scaleY); + } + return this; + }, + gestureEnd:function (rotation, scaleX, scaleY) { + }, + + + /** + * Calculates the 2D bounding box in canvas coordinates of the Actor. + * This bounding box takes into account the transformations applied hierarchically for + * each Scene Actor. + * + * @private + * + */ + setScreenBounds:function () { + + var AABB = this.AABB; + var vv = this.viewVertices; + + if (this.isAA) { + var m = this.worldModelViewMatrix.matrix; + AABB.x = m[2]; + AABB.y = m[5]; + AABB.x1 = m[2] + this.width; + AABB.y1 = m[5] + this.height; + AABB.width = AABB.x1 - AABB.x; + AABB.height = AABB.y1 - AABB.y; + return this; + } + + + var vvv; + + vvv = vv[0]; + vvv.x = 0; + vvv.y = 0; + vvv = vv[1]; + vvv.x = this.width; + vvv.y = 0; + vvv = vv[2]; + vvv.x = this.width; + vvv.y = this.height; + vvv = vv[3]; + vvv.x = 0; + vvv.y = this.height; + + this.modelToView(this.viewVertices); + + var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE; + var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE; + + vvv = vv[0]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[1]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[2]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[3]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + + AABB.x = xmin; + AABB.y = ymin; + AABB.x1 = xmax; + AABB.y1 = ymax; + AABB.width = (xmax - xmin); + AABB.height = (ymax - ymin); + + return this; + }, + setGestureEnabled:function (enable) { + this.gestureEnabled = !!enable; + return this; + }, + isGestureEnabled:function () { + return this.gestureEnabled; + }, + getId:function () { + return this.id; + }, + setId:function (id) { + this.id = id; + return this; + }, + + /** + * Set this Actor's parent and connect in CSS a div with its parent. + * In case there's a parent set, previously the div will be removed from + * its old parent and reattached to the new one. + * @param parent {CAAT.ActorContainerCSS|CAAT.Actor} + * @return this + */ + setParent:function (parent) { + if (this.parent) { + try { + this.domParent.removeChild(this.domElement); + } catch (e) { + // when changing a parent, make sure the operation does not fail. + // it may happen a root node has had removed its children and all the dom hierarchy + // may have been lost. + } + } + + this.parent = parent; + if (null != parent) { + this.parent.domElement.appendChild(this.domElement); + this.domParent = this.parent.domElement; + } else { + this.domParent = null; + } + + this.dirty = true; + + return this; + }, + + /** + * Set this actor's background image. + * The need of a background image is to kept compatibility with the new CSSDirector class. + * The image parameter can be either an Image/Canvas or a CAAT.SpriteImage instance. If an image + * is supplied, it will be wrapped into a CAAT.SriteImage instance of 1 row by 1 column. + * If the actor has set an image in the background, the paint method will draw the image, otherwise + * and if set, will fill its background with a solid color. + * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one + * single image from the SpriteImage (either supplied or generated because of passing an Image or + * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth, + * height:singleHeight]. + * + * It is absolutely recommended not using a Canvas as argument. The performance + * of canvas.toDataURL (despite its result being cached) is very poor. + * + * @see CAAT.SpriteImage + * + * @param image {Image|Canvas|CAAT.SpriteImage} + * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter. + * @throws 'Invalid image object to set actor's background' in case the image parameter is not of the + * valid type. + * @return this + */ + setBackgroundImage:function (image, adjust_size_to_image) { + if (image) { + // Opera will complaint about instanceof Image, so better HTMLImageElement. + if (image instanceof HTMLImageElement) { + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } else if (image instanceof HTMLCanvasElement) { + image.src = image.toDataURL(); + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } else if (image instanceof CAAT.SpriteImage) { + if (image.image instanceof HTMLCanvasElement) { + if (!image.image.src) { + image.image.src = image.image.toDataURL(); + } + } + } else if (isString(image)) { + image= new CAAT.Foundation.SpriteImage().initialize( CAAT.currentDirector.getImage(image), 1, 1 ); + } else { + throw "Invalid image object to set actor's background"; + } + + image.setOwner(this); + this.backgroundImage = image; + if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) { + this.setSize(image.getWidth(), image.getHeight()); + } + + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } else { + this.backgroundImage = null; + this.style('background', 'none'); + } + + return this; + }, + /** + * Set the actor's SpriteImage index from animation sheet. + * @see CAAT.SpriteImage + * @param index {integer} + * + * @return this + */ + setSpriteIndex:function (index) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteIndex(index); + + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + + } + + return this; + + }, + /** + * Set this actor's background SpriteImage offset displacement. + * The values can be either positive or negative meaning the texture space of this background + * image does not start at (0,0) but at the desired position. + * @see CAAT.SpriteImage + * @param ox {integer} horizontal offset + * @param oy {integer} vertical offset + * + * @return this + */ + setBackgroundImageOffset:function (ox, oy) { + if (this.backgroundImage) { + this.backgroundImage.setOffset(ox, oy); + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } + + return this; + }, + /** + * Set this actor's background SpriteImage its animation sequence. + * In its simplet's form a SpriteImage treats a given image as an array of rows by columns + * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages. + * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the + * animation sequence + * @param ii {array} an array of integers. + */ + setAnimationImageIndex:function (ii) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationImageIndex(ii); + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } + return this; + }, + + addAnimation : function( name, array, time, callback ) { + if (this.backgroundImage) { + this.backgroundImage.addAnimation(name, array, time, callback); + } + return this; + }, + + playAnimation : function(name) { + if (this.backgroundImage) { + this.backgroundImage.playAnimation(name); + } + return this; + }, + + setAnimationEndCallback : function(f) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationEndCallback(f); + } + }, + + + setChangeFPS:function (time) { + if (this.backgroundImage) { + this.backgroundImage.setChangeFPS(time); + } + return this; + }, + /** + * This method has no effect on ActorCSS + * @param it any value from CAAT.Actor.TR_* + * @return this + */ + setImageTransformation:function (it) { + this.transformation = it; + if (it === CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE) { + this.style('background-size', '100%'); + } else if (it === CAAT.Foundation.SpriteImage.TR_NONE) { + this.style('background-size', 'auto'); + } + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {float} x position + * @param y {float} y position + * + * @return this + */ + centerOn:function (x, y) { + this.setLocation(x - this.width / 2, y - this.height / 2); + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + */ + centerAt:function (x, y) { + return this.centerOn(x, y); + }, + /** + * Set this actor invisible. + * The actor is animated but not visible. + * A container won't show any of its children if set visible to false. + * + * @param visible {boolean} set this actor visible or not. + * @return this + */ + setVisible:function (visible) { + this.visible = visible; + return this; + }, + style:function (attr, value) { + if (value !== this.styleCache[attr]) { + this.styleCache[attr] = value; + this.domElement.style[attr] = value; + } + }, + style3:function () { + + var imageop = ''; + if (this.transformation === CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL) { + imageop = ' scale(-1,1) '; + } + + this.rotationAngle = Math.round(this.rotationAngle * 100) / 100; + + var value = + "translate(" + this.x + "px," + this.y + "px) " + + "rotate(" + this.rotationAngle + "rad) scale(" + this.scaleX + "," + this.scaleY + ")" + + imageop; + + if (value !== this.styleCache['transform']) { + this.domElement.style['-ms-transform'] = value; + this.domElement.style['-webkit-transform'] = "translate3d(0,0,0) " + value; + this.domElement.style.OTransform = value; + this.domElement.style.MozTransform = value; + this.domElement.style['transform'] = value; + this.styleCache['transform'] = value; + } + + var anchor = '' + (this.rotationX * 100) + '% ' + + (this.rotationY * 100) + '% '; + + if (anchor !== this.styleCache['transform-origin']) { + this.domElement.style['transform-origin'] = anchor; + this.domElement.style['-webkit-transform-origin'] = anchor; + this.domElement.style['-ms-transform-origin'] = anchor; + this.domElement.style.OTransformOrigin = anchor; + this.domElement.style.MozTransformOrigin = anchor; + this.styleCache['transform-origin'] = anchor; + } + + return this; + }, + styleAlpha:function (alpha) { + if (this.alpha !== this.styleCache['opacity']) { + this.domElement.style['filter'] = 'alpha(opacity=' + ((this.alpha * 100) >> 0) + ')'; + this.domElement.style.Oopacity = this.alpha; + this.domElement.style.MozOpacity = this.alpha; + this.domElement.style['-khtml-opacity'] = this.alpha; + this.domElement.style.opacity = this.alpha; + this.styleCache['opacity'] = this.alpha; + } + + return this; + }, + /** + * Puts an Actor out of time line, that is, won't be transformed nor rendered. + * @return this + */ + setOutOfFrameTime:function () { + this.setFrameTime(-1, 0); + this.style('display', 'none'); + return this; + }, + /** + * Adds an Actor's life cycle listener. + * The developer must ensure the actorListener is not already a listener, otherwise + * it will notified more than once. + * @param actorListener {object} an object with at least a method of the form: + * actorLyfeCycleEvent( actor, string_event_type, long_time ) + */ + addListener:function (actorListener) { + this.lifecycleListenerList.push(actorListener); + }, + /** + * Removes an Actor's life cycle listener. + * It will only remove the first occurrence of the given actorListener. + * @param actorListener {object} an Actor's life cycle listener. + */ + removeListener:function (actorListener) { + var n = this.lifecycleListenerList.length; + while (n--) { + if (this.lifecycleListenerList[n] === actorListener) { + // remove the nth element. + this.lifecycleListenerList.splice(n, 1); + return; + } + } + }, + /** + * Set alpha composition scope. global will mean this alpha value will be its children maximum. + * If set to false, only this actor will have this alpha value. + * @param global {boolean} whether the alpha value should be propagated to children. + */ + setGlobalAlpha:function (global) { + this.isGlobalAlpha = global; + return this; + }, + /** + * Notifies the registered Actor's life cycle listener about some event. + * @param sEventType an string indicating the type of event being notified. + * @param time an integer indicating the time related to Scene's timeline when the event + * is being notified. + */ + fireEvent:function (sEventType, time) { + for (var i = 0; i < this.lifecycleListenerList.length; i++) { + this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time); + } + }, + /** + * Sets this Actor as Expired. + * If this is a Container, all the contained Actors won't be nor drawn nor will receive + * any event. That is, expiring an Actor means totally taking it out the Scene's timeline. + * @param time {number} an integer indicating the time the Actor was expired at. + * @return this. + */ + setExpired:function (time) { + this.expired = true; + this.style('display', 'none'); + this.fireEvent('expired', time); + return this; + }, + /** + * Enable or disable the event bubbling for this Actor. + * @param enable {boolean} a boolean indicating whether the event bubbling is enabled. + * @return this + */ + enableEvents:function (enable) { + this.mouseEnabled = enable; + return this; + }, + /** + * Removes all behaviors from an Actor. + * @return this + */ + emptyBehaviorList:function () { + this.behaviorList = []; + return this; + }, + /* + emptyKeyframesList : function() { + this.keyframesList= []; + }, + */ + /** + * Caches a fillStyle in the Actor. + * @param style a valid Canvas rendering context fillStyle. + * @return this + */ + setFillStyle:function (style) { + this.style('background', style); + return this; + }, + /** + * Caches a stroke style in the Actor. + * @param style a valid canvas rendering context stroke style. + * @return this + */ + setStrokeStyle:function (style) { + return this; + }, + /** + * @deprecated + * @param paint + */ + setPaint:function (paint) { + }, + /** + * Stablishes the Alpha transparency for the Actor. + * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors. + * The alpha must be between 0 and 1. + * @param alpha a float indicating the alpha value. + * @return this + */ + setAlpha:function (alpha) { + this.alpha = alpha; + return this; + }, + /** + * Remove all transformation values for the Actor. + * @return this + */ + resetTransform:function () { + this.rotationAngle = 0; + this.rotationX = .5; + this.rotationY = .5; + this.scaleX = 1; + this.scaleY = 1; + this.scaleTX = .5; + this.scaleTY = .5; + this.scaleAnchor = 0; + this.oldX = -1; + this.oldY = -1; + + this.style3(); + + this.dirty = true; + + return this; + }, + /** + * Sets the time life cycle for an Actor. + * These values are related to Scene time. + * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene. + * @param duration an integer indicating how much the Actor will last once visible. + * @return this + */ + setFrameTime:function (startTime, duration) { + this.start_time = startTime; + this.duration = duration; + this.expired = false; + this.dirty = true; + + return this; + }, + /** + * This method should me overriden by every custom Actor. + * It will be the drawing routine called by the Director to show every Actor. + * @param director the CAAT.Director instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time in which the drawing is performed. + */ + paint:function (director, time) { + }, + /** + * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER + * + * @see setScaleAnchored + * + * @param sx a float indicating a width size multiplier. + * @param sy a float indicating a height size multiplier. + * @return this + */ + setScale:function (sx, sy) { + this.setScaleAnchored(sx, sy, .5, .5); + return this; + }, + /** + * Private. + * Gets a given anchor position referred to the Actor. + * @param anchor + * @return an object of the form { x: float, y: float } + */ + getAnchor:function (anchor) { + var tx = 0, ty = 0; + + switch (anchor) { + case this.ANCHOR_CENTER: + tx = .5; + ty = .5; + break; + case this.ANCHOR_TOP: + tx = .5; + ty = 0; + break; + case this.ANCHOR_BOTTOM: + tx = .5; + ty = 1; + break; + case this.ANCHOR_LEFT: + tx = 0; + ty = .5; + break; + case this.ANCHOR_RIGHT: + tx = 1; + ty = .5; + break; + case this.ANCHOR_TOP_RIGHT: + tx = 1; + ty = 0; + break; + case this.ANCHOR_BOTTOM_LEFT: + tx = 0; + ty = 1; + break; + case this.ANCHOR_BOTTOM_RIGHT: + tx = 1; + ty = 1; + break; + case this.ANCHOR_TOP_LEFT: + tx = 0; + ty = 0; + break; + } + + return {x:tx, y:ty}; + }, + getAnchorPercent:function (anchor) { + + var anchors = [ + .50, .50, .50, 0, .50, 1.00, + 0, .50, 1.00, .50, 0, 0, + 1.00, 0, 0, 1.00, 1.00, 1.00 + ]; + + return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] }; + }, + + setGlobalAnchor:function (ax, ay) { + this.tAnchorX = ax; + this.rotationX = ax; + this.scaleTX = ax; + + this.tAnchorY = ay; + this.rotationY = ay; + this.scaleTY = ay; + + this.dirty = true; + return this; + }, + + setScaleAnchor:function (sax, say) { + this.rotationX = sax; + this.rotationY = say; + this.scaleTX = sax; + this.scaleTY = say; + + this.style3(); + + this.dirty = true; + return this; + }, + /** + * Modify the dimensions on an Actor. + * The dimension will not affect the local coordinates system in opposition + * to setSize or setBounds. + * + * @param sx {number} width scale. + * @param sy {number} height scale. + * @param anchorx {number} x anchor to perform the Scale operation. + * @param anchory {number} y anchor to perform the Scale operation. + * + * @return this; + */ + setScaleAnchored:function (sx, sy, anchorx, anchory) { + this.rotationX = anchorx; + this.rotationY = anchory; + this.scaleTX = anchorx; + this.scaleTY = anchory; + + this.scaleX = sx; + this.scaleY = sy; + + this.style3(); + + this.dirty = true; + + return this; + }, + + + /** + * A helper method for setRotationAnchored. This methods stablishes the center + * of rotation to be the center of the Actor. + * + * @param angle a float indicating the angle in radians to rotate the Actor. + * @return this + */ + setRotation:function (angle) { + this.rotationAngle = angle; + this.style3(); + this.dirty = true; + return this; + }, + + setRotationAnchor:function (rax, ray) { + this.rotationX = ray; + this.rotationY = rax; + this.style3(); + this.dirty = true; + return this; + }, + + setRotationAnchored:function (angle, rx, ry) { + this.rotationAngle = angle; + this.rotationX = rx; + this.rotationY = ry; + this.style3(); + + this.dirty = true; + return this; + }, + + /** + * Sets an Actor's dimension + * @param w a float indicating Actor's width. + * @param h a float indicating Actor's height. + * @return this + */ + setSize:function (w, h) { + this.width = w; + this.height = h; + + this.style('width', '' + w + 'px'); + this.style('height', '' + h + 'px'); + + this.dirty = true; + + return this; + }, + /** + * Set location and dimension of an Actor at once. + * + * as http://jsperf.com/drawimage-whole-pixels states, drawing at whole pixels rocks while at subpixels sucks. + * thanks @pbakaus + * + * @param x a float indicating Actor's x position. + * @param y a float indicating Actor's y position + * @param w a float indicating Actor's width + * @param h a float indicating Actor's height + * @return this + */ + setBounds:function (x, y, w, h) { + //this.x= x; + //this.y= y; + this.x = x; + this.y = y; + this.width = w; + this.height = h; + + this.setLocation(x, y); + this.setSize(w, h); + + return this; + }, + + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + this.style3(); + this.dirty = true; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + + /** + * This method sets the position of an Actor inside its parent. + * + * as http://jsperf.com/drawimage-whole-pixels states, drawing at whole pixels rocks while at subpixels sucks. + * thanks @pbakaus + * + * @param x a float indicating Actor's x position + * @param y a float indicating Actor's y position + * @return this + */ + setLocation:function (x, y) { + + this.x = x; + this.y = y; + + this.style3(); + /* + this.style('left', x+'px'); + this.style('top', y+'px'); + */ + this.dirty = true; + + return this; + }, + /** + * This method is called by the Director to know whether the actor is on Scene time. + * In case it was necessary, this method will notify any life cycle behaviors about + * an Actor expiration. + * @param time an integer indicating the Scene time. + * + * @private + * + */ + isInAnimationFrame:function (time) { + if (this.expired) { + return false; + } + + if (this.duration === Number.MAX_VALUE) { + if (this.start_time <= time) { + return true; + } else { + return false; + } + } + + if (time >= this.start_time + this.duration) { + if (!this.expired) { + this.setExpired(time); + } + return false; + } + + return this.start_time <= time && time < this.start_time + this.duration; + }, + /** + * Checks whether a coordinate is inside the Actor's bounding box. + * @param x {number} a float + * @param y {number} a float + * + * @return boolean indicating whether it is inside. + */ + contains:function (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + }, + + /** + addKeyframes : function( keyframe, start, duration, cycle ) { + this.keyframesList.push( new CAAT.KeyframesDescriptor( keyframe, start, duration, cycle ) ); + }, + + scheduleKeyframes : function( id, startTime, duration ) { + var kf= this.getKeyframesDescriptor(id); + if ( kf ) { + kf.schedule( startTime, duration ); + } + return this; + }, + + removeKeyframes : function( keyframe ) { + var kfs= this.keyframesList; + for( var i=0; i + * WARNING: every call to this method calculates + * actor's world model view matrix. + * + * @param point {CAAT.Point} a point in screen space to be transformed to model space. + * + * @return the source point object + * + * + */ + viewToModel:function (point) { + this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI); + this.worldModelViewMatrixI.transformCoord(point); + return point; + }, + /** + * Transform a local coordinate point on this Actor's coordinate system into + * another point in otherActor's coordinate system. + * @param point {CAAT.Point} + * @param otherActor {CAAT.Actor} + */ + modelToModel:function (point, otherActor) { + return otherActor.viewToModel(this.modelToView(point)); + }, + + /** + * Private + * This method does the needed point transformations across an Actor hierarchy to devise + * whether the parameter point coordinate lies inside the Actor. + * @param point an object of the form { x: float, y: float } + * + * @return null if the point is not inside the Actor. The Actor otherwise. + */ + findActorAtPosition:function (point) { + if (this.scaleX===0 || this.scaleY===0) { + return null; + } + + if (!this.mouseEnabled || !this.isInAnimationFrame(this.time)) { + return null; + } + + this.setModelViewMatrix(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.modelViewMatrixI.transformCoord(point); + return this.contains(point.x, point.y) ? this : null; + }, + /** + * Enables a default dragging routine for the Actor. + * This default dragging routine allows to: + *
  • scale the Actor by pressing shift+drag + *
  • rotate the Actor by pressing control+drag + *
  • scale non uniformly by pressing alt+shift+drag + * + * @return this + */ + enableDrag:function () { + + this.ax = 0; + this.ay = 0; + this.mx = 0; + this.my = 0; + this.asx = 1; + this.asy = 1; + this.ara = 0; + this.screenx = 0; + this.screeny = 0; + + /** + * Mouse enter handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseEnter = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + this.pointed = true; + CAAT.setCursor('move'); + }; + + /** + * Mouse exit handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseExit = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + this.pointed = false; + CAAT.setCursor('default'); + }; + + /** + * Mouse move handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseMove = function (mouseEvent) { + this.mx = mouseEvent.point.x; + this.my = mouseEvent.point.y; + }; + + /** + * Mouse up handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseUp = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + }; + + /** + * Mouse drag handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseDrag = function (mouseEvent) { + + if (this.ax === -1 || this.ay === -1) { + this.ax = mouseEvent.point.x; + this.ay = mouseEvent.point.y; + this.asx = this.scaleX; + this.asy = this.scaleY; + this.ara = this.rotationAngle; + this.screenx = mouseEvent.screenPoint.x; + this.screeny = mouseEvent.screenPoint.y; + } + + if (mouseEvent.isShiftDown()) { + var scx = (mouseEvent.screenPoint.x - this.screenx) / 100; + var scy = (mouseEvent.screenPoint.y - this.screeny) / 100; + if (!mouseEvent.isAltDown()) { + var sc = Math.max(scx, scy); + scx = sc; + scy = sc; + } + this.setScale(scx + this.asx, scy + this.asy); + + } else if (mouseEvent.isControlDown()) { + var vx = mouseEvent.screenPoint.x - this.screenx; + var vy = mouseEvent.screenPoint.y - this.screeny; + this.setRotation(-Math.atan2(vx, vy) + this.ara); + } else { + this.setLocation( + this.x + mouseEvent.point.x - this.ax, + this.y + mouseEvent.point.y - this.ay); + this.ax = mouseEvent.point.x; + this.ay = mouseEvent.point.y; + } + + + }; + + return this; + }, + /** + * Default mouseClick handler. + * Mouse click events are received after a call to mouseUp method if no dragging was in progress. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseClick:function (mouseEvent) { + }, + /** + * Default double click handler + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDblClick:function (mouseEvent) { + }, + /** + * Default mouse enter on Actor handler. + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseEnter:function (mouseEvent) { + this.pointed = true; + }, + /** + * Default mouse exit on Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseExit:function (mouseEvent) { + this.pointed = false; + }, + /** + * Default mouse move inside Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseMove:function (mouseEvent) { + }, + /** + * default mouse press in Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDown:function (mouseEvent) { + }, + /** + * default mouse release in Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseUp:function (mouseEvent) { + }, + /** + * default Actor mouse drag handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDrag:function (mouseEvent) { + }, + mouseOut:function (mouseEvent) { + }, + mouseOver:function (mouseEvent) { + }, + /** + * Draw a bounding box with on-screen coordinates regardless of the transformations + * applied to the Actor. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + }, + /** + * Private + * This method is called by the Director instance. + * It applies the list of behaviors the Actor has registered. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + animate:function (director, time) { + if (!this.isInAnimationFrame(time)) { + this.inFrame = false; + this.dirty = true; + this.style('display', 'none'); + return false; + } else { + this.style('display', this.visible ? 'block' : 'none'); + } + + for (var i = 0; i < this.behaviorList.length; i++) { + this.behaviorList[i].apply(time, this); + } + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + //this.setAlpha(this.frameAlpha); + this.styleAlpha(this.frameAlpha); + this.inFrame = true; + + this.setModelViewMatrix(false); + + if (this.dirty || this.wdirty || this.invalid) { + this.setScreenBounds(); + } + + this.dirty = false; + + if ( this.backgroundImage ) { + var bi = this.backgroundImage; + if (bi) { + var pi = bi.spriteIndex; + bi.setSpriteIndexAtTime(time); + if (pi != bi.spriteIndex) { + this.setSpriteIndex(bi.spriteIndex); + } + } + } + + //return true; + return this.AABB.intersects(director.AABB); + }, + /** + * Set this model view matrix if the actor is Dirty. + * + * @return this + */ + /* + setModelViewMatrix : function(glEnabled) { + var c,s,_m00,_m01,_m10,_m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty= false; + + if ( this.dirty ) { + + mm= this.modelViewMatrix.identity().matrix; + + mm0= mm[0]; + mm1= mm[1]; + mm2= mm[2]; + mm3= mm[3]; + mm4= mm[4]; + mm5= mm[5]; + + mm2+= this.x; + mm5+= this.y; + + if ( this.rotationAngle ) { + mm2+= mm0*this.rotationX*this.width + mm1*this.rotationY*this.height; + mm5+= mm3*this.rotationX*this.width + mm4*this.rotationY*this.height; + + c= Math.cos( this.rotationAngle ); + s= Math.sin( this.rotationAngle ); + _m00= mm0; + _m01= mm1; + _m10= mm3; + _m11= mm4; + mm0= _m00*c + _m01*s; + mm1= -_m00*s + _m01*c; + mm3= _m10*c + _m11*s; + mm4= -_m10*s + _m11*c; + + mm2+= -mm0*this.rotationX*this.width - mm1*this.rotationY*this.height; + mm5+= -mm3*this.rotationX*this.width - mm4*this.rotationY*this.height; + } + if ( this.scaleX!=1 || this.scaleY!=1 ) { + + mm2+= mm0*this.scaleTX*this.width + mm1*this.scaleTY*this.height; + mm5+= mm3*this.scaleTX*this.width + mm4*this.scaleTY*this.height; + + mm0= mm0*this.scaleX; + mm1= mm1*this.scaleY; + mm3= mm3*this.scaleX; + mm4= mm4*this.scaleY; + + mm2+= -mm0*this.scaleTX*this.width - mm1*this.scaleTY*this.height; + mm5+= -mm3*this.scaleTX*this.width - mm4*this.scaleTY*this.height; + } + + mm[0]= mm0; + mm[1]= mm1; + mm[2]= mm2; + mm[3]= mm3; + mm[4]= mm4; + mm[5]= mm5; + } + + if ( this.parent ) { + if ( this.dirty || this.parent.wdirty ) { + this.worldModelViewMatrix.copy( this.parent.worldModelViewMatrix ); + this.worldModelViewMatrix.multiply( this.modelViewMatrix ); + this.wdirty= true; + } + } else { + if ( this.dirty ) { + this.wdirty= true; + } + //this.worldModelViewMatrix.copy( this.modelViewMatrix ); + this.worldModelViewMatrix.identity(); + } + + // this.dirty= false; + + + return this; + },*/ + + setModelViewMatrix:function () { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty = false; + mm = this.modelViewMatrix.matrix; + + if (this.dirty) { + + mm0 = 1; + mm1 = 0; + //mm2= mm[2]; + mm3 = 0; + mm4 = 1; + //mm5= mm[5]; + + mm2 = this.x - this.tAnchorX * this.width; + mm5 = this.y - this.tAnchorY * this.height; + + if (this.rotationAngle) { + + var rx = this.rotationX * this.width; + var ry = this.rotationY * this.height; + + mm2 += mm0 * rx + mm1 * ry; + mm5 += mm3 * rx + mm4 * ry; + + c = Math.cos(this.rotationAngle); + s = Math.sin(this.rotationAngle); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm2 += -mm0 * rx - mm1 * ry; + mm5 += -mm3 * rx - mm4 * ry; + } + if (this.scaleX != 1 || this.scaleY != 1) { + + var sx = this.scaleTX * this.width; + var sy = this.scaleTY * this.height; + + mm2 += mm0 * sx + mm1 * sy; + mm5 += mm3 * sx + mm4 * sy; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm2 += -mm0 * sx - mm1 * sy; + mm5 += -mm3 * sx - mm4 * sy; + } + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + + if (this.parent) { + + + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA; + + if (this.dirty || this.parent.wdirty) { + this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix); + if (this.isAA) { + var mmm = this.worldModelViewMatrix.matrix; + mmm[2] += mm[2]; + mmm[5] += mm[5]; + } else { + this.worldModelViewMatrix.multiply(this.modelViewMatrix); + } + this.wdirty = true; + } + + } else { + if (this.dirty) { + this.wdirty = true; + } + + this.worldModelViewMatrix.identity(); + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1; + } + + }, + + /** + * @private. + * This method will be called by the Director to set the whole Actor pre-render process. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return boolean indicating whether the Actor isInFrameTime + */ + paintActor:function (director, time) { + + return true; + }, + /** + * @private. + * This method is called after the Director has transformed and drawn a whole frame. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * @return this + * + * @deprecated + */ + endAnimate:function (director, time) { + return this; + }, + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + /** + * Enable or disable the clipping process for this Actor. + * + * @param clip a boolean indicating whether clip is enabled. + * @return this + */ + setClip:function (clip) { + this.clip = clip; + this.style('overflow', this.clip ? 'hidden' : 'visible'); + return this; + }, + stopCacheAsBitmap : function() { + return this; + }, + + /** + * + * @param time {Number=} + * @return canvas + */ + cacheAsBitmap:function (time) { + return this; + }, + /** + * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's + * single size. + * + * @param buttonImage + * @param iNormal + * @param iOver + * @param iPress + * @param iDisabled + * @param fn + */ + setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) { + + var me = this; + + this.setBackgroundImage(buttonImage, true); + + this.iNormal = iNormal || 0; + this.iOver = iOver || this.iNormal; + this.iPress = iPress || this.iNormal; + this.iDisabled = iDisabled || this.iNormal; + this.fnOnClick = fn; + this.enabled = true; + + this.setSpriteIndex(iNormal); + + /** + * Enable or disable the button. + * @param enabled {boolean} + * @ignore + */ + this.setEnabled = function (enabled) { + this.enabled = enabled; + this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled); + return this; + }; + + /** + * This method will be called by CAAT *before* the mouseUp event is fired. + * @param event {CAAT.MouseEvent} + * @ignore + */ + this.actionPerformed = function (event) { + if (this.enabled && null !== this.fnOnClick) { + this.fnOnClick(this); + } + }; + + /** + * Button's mouse enter handler. It makes the button provide visual feedback + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + if (!this.enabled) { + return; + } + + if (this.dragging) { + this.setSpriteIndex(this.iPress); + } else { + this.setSpriteIndex(this.iOver); + } + CAAT.setCursor('pointer'); + }; + + /** + * Button's mouse exit handler. Release visual apperance. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseExit = function (mouseEvent) { + this.setSpriteIndex(this.iNormal); + CAAT.setCursor('default'); + }; + + /** + * Button's mouse down handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDown = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iPress); + }; + + /** + * Button's mouse up handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseUp = function (mouseEvent) { + this.setSpriteIndex(this.iNormal); + this.dragging = false; + }; + + /** + * Button's mouse click handler. Do nothing by default. This event handler will be + * called ONLY if it has not been drag on the button. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseClick = function (mouseEvent) { + }; + + /** + * Button's mouse drag handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.dragging = true; + }; + + this.setButtonImageIndex = function (_normal, _over, _press, _disabled) { + this.iNormal = _normal; + this.iOver = _over || this.iNormal; + this.iPress = _press || this.iNormal; + this.iDisabled = _disabled || this.iNormal; + this.setSpriteIndex(this.iNormal); + return this; + }; + + return this; + }, + + findActorById : function(id) { + return this.id===id ? this : null; + } + } + } + + + +}); +CAAT.Module({ + defines:"CAAT.Foundation.ActorContainer", + aliases:["CAAT.ActorContainer"], + depends:[ + "CAAT.Foundation.Actor", + "CAAT.Math.Rectangle" + ], + constants:{ + AddHint:{ + CONFORM:1 + } + }, + extendsClass:"CAAT.Foundation.Actor", + extendsWith:function () { + + return { + __init:function () { + this.__super(); + this.childrenList = []; + this.pendingChildrenList = []; + if (typeof hint !== 'undefined') { + this.addHint = hint; + this.boundingBox = new CAAT.Math.Rectangle(); + } + return this; + }, + + childrenList:null, // the list of children contained. + activeChildren:null, + pendingChildrenList:null, + + addHint:0, + boundingBox:null, + runion:new CAAT.Rectangle(), // Watch out. one for every container. + + layoutManager:null, // a layout manager instance. + layoutInvalidated:true, + + + setLayout:function (layout) { + this.layoutManager = layout; + return this; + }, + + setBounds:function (x, y, w, h) { + CAAT.ActorContainer.superclass.setBounds.call(this, x, y, w, h); + if (CAAT.currentDirector && !CAAT.currentDirector.inValidation) { + this.invalidateLayout(); + } + return this; + }, + + __validateLayout:function () { + + this.__validateTree(); + this.layoutInvalidated = false; + }, + + __validateTree:function () { + if (this.layoutManager && this.layoutManager.isInvalidated()) { + + CAAT.currentDirector.inValidation = true; + + this.layoutManager.doLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).__validateLayout(); + } + } + }, + + invalidateLayout:function () { + this.layoutInvalidated = true; + + if (this.layoutManager) { + this.layoutManager.invalidateLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).invalidateLayout(); + } + } + }, + + getLayout:function () { + return this.layoutManager; + }, + + + /** + * Removes all children from this ActorContainer. + * + * @return this + */ + emptyChildren:function () { + this.domElement.innerHTML = ''; + this.childrenList = []; + + return this; + }, + /** + * Private + * Paints this container and every contained children. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + paintActor:function (director, time) { + CAAT.ActorContainer.superclass.paintActor.call(this, director, time); + + for (var actor = this.activeChildren; actor; actor = actor.__next) { + if (actor.visible) { + actor.paintActor(director, time); + } + } + + return true; + }, + /** + * Private. + * Performs the animate method for this ActorContainer and every contained Actor. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return {boolean} is this actor in active children list ?? + */ + animate:function (director, time) { + + this.activeChildren = null; + var last = null; + + if (false === CAAT.ActorContainer.superclass.animate.call(this, director, time)) { + return false; + } + + this.__validateLayout(); + CAAT.currentDirector.inValidation = false; + + var i, l; + var notActive = []; + + this.size_active = 0; + this.size_total = 0; + + /** + * Incluir los actores pendientes. + * El momento es ahora, antes de procesar ninguno del contenedor. + */ + for (i = 0; i < this.pendingChildrenList.length; i++) { + var child = this.pendingChildrenList[i]; + this.addChild(child); + } + this.pendingChildrenList = []; + + + var cl = this.childrenList; + for (i = 0; i < cl.length; i++) { + var actor = cl[i]; + actor.time = time; + this.size_total += actor.size_total; + if (actor.animate(director, time)) { + if (!this.activeChildren) { + this.activeChildren = actor; + actor.__next = null; + last = actor; + } else { + actor.__next = null; + last.__next = actor; + last = actor; + } + + this.size_active += actor.size_active; + + } else { + if (actor.expired && actor.discardable) { + this.domElement.removeChild(actor.domElement); + actor.destroy(time); + cl.splice(i, 1); + } + } + } + + return true; + }, + /** + * Removes Actors from this ActorContainer which are expired and flagged as Discardable. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @deprecated + */ + endAnimate:function (director, time) { + }, + + addActorImmediately: function(child,constraint) { + return this.addChildImmediately(child,constraint); + }, + + addActor : function( child, constraint ) { + return this.addChild(child,constraint); + }, + + /** + * Adds an Actor to this Container. + * The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at + * the time of method call. + * + * This method is only used by CAAT.Director's transitionScene. + * + * @param child a CAAT.Actor instance. + * @return this. + */ + addChildImmediately:function (child, constraint) { + return this.addChild(child, constraint); + }, + /** + * Adds an Actor to this ActorContainer. + * The Actor will be added to the container AFTER frame animation, and not on method call time. + * Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this + * method directly. + * + * @param child a CAAT.Actor object instance. + * @return this + */ + addChild:function (child, constraint) { + child.setParent(this); + this.childrenList.push(child); + child.dirty = true; + + if (this.layoutManager) { + this.layoutManager.addChild(child, constraint); + this.invalidateLayout(); + } else { + /** + * if Conforming size, recalc new bountainer size. + */ + if (this.addHint === CAAT.ActorContainer.AddHint.CONFORM) { + this.recalcSize(); + } + } + + return this; + }, + + /** + * Recalc this container size by computin the union of every children bounding box. + */ + recalcSize:function () { + var bb = this.boundingBox; + bb.setEmpty(); + var cl = this.childrenList; + var ac; + for (var i = 0; i < cl.length; i++) { + ac = cl[i]; + this.runion.setBounds( + ac.x < 0 ? 0 : ac.x, + ac.y < 0 ? 0 : ac.y, + ac.width, + ac.height); + bb.unionRectangle(this.runion); + } + this.setSize(bb.x1, bb.y1); + + return this; + }, + + /** + * Add a child element and make it active in the next frame. + * @param child {CAAT.Actor} + */ + addChildDelayed:function (child) { + this.pendingChildrenList.push(child); + return this; + }, + /** + * Adds an Actor to this ActorContainer. + * + * @param child a CAAT.Actor object instance. + * + * @return this + */ + addChildAt:function (child, index) { + + if (index <= 0) { + //this.childrenList.unshift(child); // unshift unsupported on IE + child.parent = this; + child.dirty = true; + this.childrenList.splice(0, 0, child); + this.invalidateLayout(); + return this; + } else { + if (index >= this.childrenList.length) { + index = this.childrenList.length; + } + } + + child.setParent(this); + this.childrenList.splice(index, 0, child); + + this.domElement.insertBefore(child.domElement, this.domElement.childNodes[index]); + this.invalidateLayout(); + + child.dirty = true; + + return this; + }, + /** + * Find the first actor with the supplied ID. + * This method is not recommended to be used since executes a linear search. + * @param id + */ + findActorById:function (id) { + var cl = this.childrenList; + for (var i = 0, l = cl.length; i < l; i++) { + var ret= cl[i].findActorById(id); + if (null!=ret) { + return ret; + } + } + + return null; + }, + + /** + * Private + * Gets a contained Actor z-index on this ActorContainer. + * + * @param child a CAAT.Actor object instance. + * + * @return an integer indicating the Actor's z-order. + */ + findChild:function (child) { + var i = 0, + len = this.childrenList.length; + for (i = 0; i < len; i++) { + if (this.childrenList[i] === child) { + return i; + } + } + return -1; + }, + + removeChildAt:function (pos) { + var cl = this.childrenList; + var rm; + if (-1 !== pos) { + cl[pos].setParent(null); + rm = cl.splice(pos, 1); + this.invalidateLayout(); + return rm[0]; + } + + return null; + }, + /** + * Removed an Actor form this ActorContainer. + * If the Actor is not contained into this Container, nothing happends. + * + * @param child a CAAT.Actor object instance. + * + * @return this + */ + removeChild:function (child) { + var pos = this.findChild(child); + var ret = this.removeChildAt(pos); + + return ret; + }, + removeFirstChild:function () { + var first = this.childrenList.shift(); + first.setParent(null); + this.invalidateLayout(); + + return first; + }, + removeLastChild:function () { + if (this.childrenList.length) { + var last = this.childrenList.pop(); + last.setParent(null); + this.invalidateLayout(); + return last; + } + + return null; + }, + + /** + * @private + * + * Gets the Actor inside this ActorContainer at a given Screen coordinate. + * + * @param point an object of the form { x: float, y: float } + * + * @return the Actor contained inside this ActorContainer if found, or the ActorContainer itself. + */ + findActorAtPosition:function (point) { + + if (null === CAAT.ActorContainer.superclass.findActorAtPosition.call(this, point)) { + return null; + } + + // z-order + for (var i = this.childrenList.length - 1; i >= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + /** + * Destroys this ActorContainer. + * The process falls down recursively for each contained Actor into this ActorContainer. + * + * @return this + */ + destroy:function () { + for (var i = this.childrenList.length - 1; i >= 0; i--) { + this.childrenList[i].destroy(); + } + CAAT.ActorContainer.superclass.destroy.call(this); + + return this; + }, + /** + * Get number of Actors into this container. + * @return integer indicating the number of children. + */ + getNumChildren:function () { + return this.childrenList.length; + }, + getNumActiveChildren:function () { + return this.activeChildren.length; + }, + /** + * Returns the Actor at the iPosition(th) position. + * @param iPosition an integer indicating the position array. + * @return the CAAT.Actor object at position. + */ + getChildAt:function (iPosition) { + return this.childrenList[ iPosition ]; + }, + /** + * Changes an actor's ZOrder. + * @param actor the actor to change ZOrder for + * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the + * last ZOrder Actor. + */ + setZOrder:function (actor, index) { + var actorPos = this.findChild(actor); + // the actor is present + if (-1 !== actorPos) { + var cl = this.childrenList; + // trivial reject. + if (index === actorPos) { + return; + } + + if (index >= cl.length) { + cl.splice(actorPos, 1); + cl.push(actor); + } else { + var nActor = cl.splice(actorPos, 1); + if (index < 0) { + index = 0; + } else if (index > cl.length) { + index = cl.length; + } + + //this.childrenList.splice( index, 1, nActor ); + cl.splice(index, 0, nActor[0]); + } + + for (var i = 0, l = cl.length; i < l; i++) { + cl[i].domElement.style.zIndex = i; + } + + this.invalidateLayout(); + } + } + } + } +}); +/** + * See LICENSE file. + * + */ + +CAAT.Module({ + defines:"CAAT.Foundation.Scene", + depends:[ + "CAAT.Math.Point", + "CAAT.Math.Matrix", + "CAAT.PathUtil.Path", + "CAAT.Behavior.GenericBehavior", + "CAAT.Behavior.ContainerBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.AlphaBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.PathBehavior", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.Timer.TimerManager" + ], + aliases:["CAAT.Scene"], + extendsClass:"CAAT.Foundation.ActorContainer", + constants:{ + EASE_ROTATION:1, // Constant values to identify the type of Scene transition + EASE_SCALE:2, // to perform on Scene switching by the Director. + EASE_TRANSLATE:3 + }, + extendsWith:function () { + return { + + + __init:function () { + this.__super(); + this.timerList = []; + this.style('overflow', 'hidden'); + return this; + }, + + easeContainerBehaviour:null, // Behavior container used uniquely for Scene switching. + easeContainerBehaviourListener:null, // who to notify about container behaviour events. Array. + easeIn:false, // When Scene switching, this boolean identifies whether the + // Scene is being brought in, or taken away. + /** + * @deprecated + */ + EASE_ROTATION:1, // Constant values to identify the type of Scene transition + /** + * @deprecated + */ + EASE_SCALE:2, // to perform on Scene switching by the Director. + /** + * @deprecated + */ + EASE_TRANSLATE:3, + + timerList:null, // collection of CAAT.TimerTask objects. + timerSequence:0, // incremental CAAT.TimerTask id. + + paused:false, + + isPaused:function () { + return this.paused; + }, + + setPaused:function (paused) { + this.paused = paused; + }, + + /** + * Check and apply timers in frame time. + * @param time {number} the current Scene time. + */ + checkTimers:function (time) { + var i = this.timerList.length - 1; + while (i >= 0) { + if (!this.timerList[i].remove) { + this.timerList[i].checkTask(time); + } + i--; + } + }, + /** + * Make sure the timertask is contained in the timer task list by adding it to the list in case it + * is not contained. + * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. + * @return this + */ + ensureTimerTask:function (timertask) { + if (!this.hasTimer(timertask)) { + this.timerList.push(timertask); + } + return this; + }, + /** + * Check whether the timertask is in this scene's timer task list. + * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. + * @return {boolean} a boolean indicating whether the timertask is in this scene or not. + */ + hasTimer:function (timertask) { + var i = this.timerList.length - 1; + while (i >= 0) { + if (this.timerList[i] === timertask) { + return true; + } + i--; + } + + return false; + }, + /** + * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene + * is taken out of the Director the timer task is paused, and resumed on Scene restoration. + * + * @param startTime {number} an integer indicating the scene time this task must start executing at. + * @param duration {number} an integer indicating the timerTask duration. + * @param callback_timeout {function} timer on timeout callback function. + * @param callback_tick {function} timer on tick callback function. + * @param callback_cancel {function} timer on cancel callback function. + * + * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. + */ + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + + var tt = new CAAT.TimerTask().create( + startTime, + duration, + callback_timeout, + callback_tick, + callback_cancel); + + tt.taskId = this.timerSequence++; + tt.sceneTime = this.time; + tt.scene = this; + + this.timerList.push(tt); + + return tt; + }, + /** + * Removes expired timers. This method must not be called directly. + */ + removeExpiredTimers:function () { + var i; + for (i = 0; i < this.timerList.length; i++) { + if (this.timerList[i].remove) { + this.timerList.splice(i, 1); + } + } + }, + /** + * Scene animation method. + * It extendsClass Container's base behavior by adding timer control. + * @param director {CAAT.Director} a CAAT.Director instance. + * @param time {number} an integer indicating the Scene time the animation is being performed at. + */ +// animate:function (director, time) { +// this.checkTimers(time); +// CAAT.Scene.superclass.animate.call(this, director, time); +// this.removeExpiredTimers(); +// }, + /** + * Helper method to manage alpha transparency fading on Scene switch by the Director. + * @param time {number} integer indicating the time in milliseconds the fading will take. + * @param isIn {boolean} boolean indicating whether this Scene in the switch process is + * being brought in. + * + * @private + */ + createAlphaBehaviour:function (time, isIn) { + var ab = new CAAT.AlphaBehavior(); + ab.setFrameTime(0, time); + ab.startAlpha = isIn ? 0 : 1; + ab.endAlpha = isIn ? 1 : 0; + this.easeContainerBehaviour.addBehavior(ab); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslationIn:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, true, interpolator); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslationOut:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, false, interpolator); + }, + /** + * This method will setup Scene behaviours to switch an Scene via a translation. + * The anchor value can only be + *
  • CAAT.Actor.ANCHOR_LEFT + *
  • CAAT.Actor.ANCHOR_RIGHT + *
  • CAAT.Actor.ANCHOR_TOP + *
  • CAAT.Actor.ANCHOR_BOTTOM + * if any other value is specified, any of the previous ones will be applied. + * + * @param time integer indicating time in milliseconds for the Scene. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param isIn boolean indicating whether the scene will be brought in. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslation:function (time, alpha, anchor, isIn, interpolator) { + + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + this.easeIn = isIn; + + var pb = new CAAT.Behavior.PathBehavior(); + if (interpolator) { + pb.setInterpolator(interpolator); + } + + pb.setFrameTime(0, time); + + // BUGBUG anchors: 1..4 + if (anchor < 1) { + anchor = 1; + } else if (anchor > 4) { + anchor = 4; + } + + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(0, -this.height, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, 0, -this.height)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(0, this.height, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, 0, this.height)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(-this.width, 0, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, -this.width, 0)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(this.width, 0, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, this.width, 0)); + } + break; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + this.easeContainerBehaviour.addBehavior(pb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + var start = pb.path.startCurvePosition(); + this.setLocation(start.x, start.y); + + this.emptyBehaviorList(); + CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Called from CAAT.Director to bring in a Scene. + * A helper method for easeScale. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + */ + easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to take away a Scene. + * A helper method for easeScale. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator instance to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + */ + easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to bring in ot take away an Scene. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + * @param isIn boolean indicating whether the Scene is being brought in. + */ + easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.ContainerBehavior(); + + var x = 0; + var y = 0; + var x2 = 0; + var y2 = 0; + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_CENTER: + x2 = 1; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + x = 1; + x2 = 1; + y = 0; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + y = 1; + y2 = 1; + x = 0; + x2 = 1; + break; + default: + alert('scale anchor ?? ' + anchor); + } + + if (!isIn) { + var tmp; + tmp = x; + x = x2; + x2 = tmp; + + tmp = y; + y = y2; + y2 = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var sb = new CAAT.ScaleBehavior(). + setFrameTime(starttime, time). + setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + sb.setInterpolator(interpolator); + } + + this.easeContainerBehaviour.addBehavior(sb); + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Overriden method to disallow default behavior. + * Do not use directly. + */ + addBehavior:function (behaviour) { + return this; + }, + /** + * Called from CAAT.Director to use Rotations for bringing in. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationIn:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to use Rotations for taking Scenes away. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationOut:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. + * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param isIn boolean indicating whehter the Scene is brought in. + */ + easeRotation:function (time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var start = 0; + var end = 0; + + if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { + anchor = CAAT.Foundation.Actor.ANCHOR_TOP; + } + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + start = Math.PI * (Math.random() < 0.5 ? 1 : -1); + break; + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); + break; + default: + alert('rot anchor ?? ' + anchor); + } + + if (false === isIn) { + var tmp = start; + start = end; + end = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var rb = new CAAT.Behavior.RotateBehavior(). + setFrameTime(0, time). + setValues(start, end, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + rb.setInterpolator(interpolator); + } + this.easeContainerBehaviour.addBehavior(rb); + + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Registers a listener for listen for transitions events. + * Al least, the Director registers himself as Scene easing transition listener. + * When the transition is done, it restores the Scene's capability of receiving events. + * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form + * behaviorExpired( caat_behaviour, time, actor); + */ + setEaseListener:function (listener) { + this.easeContainerBehaviourListener = listener; + }, + /** + * Private. + * listener for the Scene's easeContainerBehaviour. + * @param actor + */ + behaviorExpired:function (actor) { + this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); + }, + /** + * This method should be overriden in case the developer wants to do some special actions when + * the scene has just been brought in. + */ + activated:function () { + }, + /** + * Scenes, do not expire the same way Actors do. + * It simply will be set expired=true, but the frameTime won't be modified. + * WARN: the parameter here is treated as boolean, not number. + */ + setExpired:function (bExpired) { + this.expired = bExpired; + this.style('display', bExpired ? 'none' : 'block'); + }, + /** + * An scene by default does not paint anything because has not fillStyle set. + * @param director + * @param time + */ + paint:function (director, time) { + }, + + getIn : function( out_scene ) { + + }, + + goOut : function( in_scene ) { + + } + } + } +});/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Director + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.ActorContainer + * + * @constructor + */ + + defines:"CAAT.Foundation.Director", + aliases:["CAAT.Director"], + extendsClass:"CAAT.Foundation.ActorContainer", + depends:[ + "CAAT.Core.Class", + "CAAT.Core.Constants", + + "CAAT.Foundation.ActorContainer", + "CAAT.Module.Audio.AudioManager", + "CAAT.Module.Runtime.BrowserInfo", + "CAAT.Module.Debug.Debug", + "CAAT.Math.Point", + "CAAT.Math.Rectangle", + "CAAT.Math.Matrix", + "CAAT.Foundation.Timer.TimerManager", + "CAAT.Foundation.Actor", + "CAAT.Foundation.Scene", + "CAAT.Event.AnimationLoop", + "CAAT.Event.Input", + "CAAT.Event.KeyEvent", + "CAAT.Event.MouseEvent", + "CAAT.Event.TouchEvent", + + "CAAT.WebGL.Program", + "CAAT.WebGL.ColorProgram", + "CAAT.WebGL.TextureProgram", + "CAAT.WebGL.GLU", + + "CAAT.Module.TexturePacker.TexturePageManager" + ], + constants:{ + /** + * @lends CAAT.Foundation.Director + */ + + /** @const @type {number} */ RENDER_MODE_CONTINUOUS:1, // redraw every frame + /** @const @type {number} */ RENDER_MODE_DIRTY:2, // suitable for evented CAAT. + + /** @const @type {number} */ CLEAR_DIRTY_RECTS:1, + /** @const @type {number} */ CLEAR_ALL:true, + /** @const @type {number} */ CLEAR_NONE:false, + + /** @const @type {number} */ RESIZE_NONE:1, + /** @const @type {number} */ RESIZE_WIDTH:2, + /** @const @type {number} */ RESIZE_HEIGHT:4, + /** @const @type {number} */ RESIZE_BOTH:8, + /** @const @type {number} */ RESIZE_PROPORTIONAL:16 + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Foundation.Director.prototype + */ + + __init:function () { + this.__super(); + + this.browserInfo = CAAT.Module.Runtime.BrowserInfo; + this.audioManager = new CAAT.Module.Audio.AudioManager().initialize(8); + this.scenes = []; + this.imagesCache= []; + + // input related variables initialization + this.mousePoint = new CAAT.Math.Point(0, 0, 0); + this.prevMousePoint = new CAAT.Math.Point(0, 0, 0); + this.screenMousePoint = new CAAT.Math.Point(0, 0, 0); + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + + this.cDirtyRects = []; + this.sDirtyRects = []; + this.dirtyRects = []; + for (var i = 0; i < 64; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + this.dirtyRectsIndex = 0; + this.touches = {}; + + this.timerManager = new CAAT.Foundation.Timer.TimerManager(); + this.__map= {}; + + return this; + }, + + /** + * flag indicating debug mode. It will draw affedted screen areas. + * @type {boolean} + */ + debug:false, + + /** + * Set CAAT render mode. Right now, this takes no effect. + */ + renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS, + + /** + * This method will be called before rendering any director scene. + * Use this method to calculate your physics for example. + * @private + */ + onRenderStart:null, + + /** + * This method will be called after rendering any director scene. + * Use this method to clean your physics forces for example. + * @private + */ + onRenderEnd:null, + + // input related attributes + /** + * mouse coordinate related to canvas 0,0 coord. + * @private + */ + mousePoint:null, + + /** + * previous mouse position cache. Needed for drag events. + * @private + */ + prevMousePoint:null, + + /** + * screen mouse coordinates. + * @private + */ + screenMousePoint:null, + + /** + * is the left mouse button pressed ?. + * Needed to handle dragging. + */ + isMouseDown:false, + + /** + * director's last actor receiving input. + * Needed to set capture for dragging events. + */ + lastSelectedActor:null, + + /** + * is input in drag mode ? + */ + dragging:false, + + // other attributes + + /** + * This director scene collection. + * @type {Array.} + */ + scenes:null, + + /** + * The current Scene. This and only this will receive events. + */ + currentScene:null, + + /** + * The canvas the Director draws on. + * @private + */ + canvas:null, + + /** + * This director´s canvas rendering context. + */ + ctx:null, + + /** + * director time. + * @private + */ + time:0, + + /** + * global director timeline. + * @private + */ + timeline:0, + + /** + * An array of JSON elements of the form { id:string, image:Image } + */ + imagesCache:null, + + /** + * this director´s audio manager. + * @private + */ + audioManager:null, + + /** + * Clear screen strategy: + * CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background. + * CAAT.Foundation.Director.CLEAR_DIRTY_RECTS : clear only affected actors screen area. + * CAAT.Foundation.Director.CLEAR_ALL : clear the whole canvas object. + */ + clear: CAAT.Foundation.Director.CLEAR_ALL, + + /** + * if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene. + * @private + */ + transitionScene:null, + + /** + * Some browser related information. + */ + browserInfo:null, + + /** + * 3d context + * @private + */ + gl:null, + + /** + * is WebGL enabled as renderer ? + * @private + */ + glEnabled:false, + + /** + * if webGL is on, CAAT will texture pack all images transparently. + * @private + */ + glTextureManager:null, + + /** + * The only GLSL program for webGL + * @private + */ + glTtextureProgram:null, + glColorProgram:null, + + /** + * webGL projection matrix + * @private + */ + pMatrix:null, // projection matrix + + /** + * webGL vertex array + * @private + */ + coords:null, // Float32Array + + /** + * webGL vertex indices. + * @private + */ + coordsIndex:0, + + /** + * webGL uv texture indices + * @private + */ + uv:null, + uvIndex:0, + + /** + * draw tris front_to_back or back_to_front ? + * @private + */ + front_to_back:false, + + /** + * statistics object + */ + statistics:{ + size_total:0, + size_active:0, + size_dirtyRects:0, + draws:0, + size_discarded_by_dirty_rects:0 + }, + + /** + * webGL current texture page. This minimizes webGL context changes. + * @private + */ + currentTexturePage:0, + + /** + * webGL current shader opacity. + * BUGBUG: change this by vertex colors. + * @private + */ + currentOpacity:1, + + /** + * if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned + * id. + * @private + */ + intervalId:null, + + /** + * Rendered frames counter. + */ + frameCounter:0, + + /** + * Window resize strategy. + * see CAAT.Foundation.Director.RESIZE_* constants. + * @private + */ + resize:1, + + /** + * Callback when the window is resized. + */ + onResizeCallback:null, + + /** + * Calculated gesture event scale. + * @private + */ + __gestureScale:0, + + /** + * Calculated gesture event rotation. + * @private + */ + __gestureRotation:0, + + /** + * Dirty rects cache. + * An array of CAAT.Math.Rectangle object. + * @private + */ + dirtyRects:null, // dirty rects cache. + + /** + * current dirty rects. + * @private + */ + cDirtyRects:null, // dirty rects cache. + + /** + * Currently used dirty rects. + * @private + */ + sDirtyRects:null, // scheduled dirty rects. + + /** + * Number of currently allocated dirty rects. + * @private + */ + dirtyRectsIndex:0, + + /** + * Dirty rects enabled ?? + * @private + */ + dirtyRectsEnabled:false, + + /** + * Number of dirty rects. + * @private + */ + nDirtyRects:0, + + /** + * Dirty rects count debug info. + * @private + */ + drDiscarded:0, // discarded by dirty rects. + + /** + * Is this director stopped ? + */ + stopped:false, // is stopped, this director will do nothing. + + /** + * currently unused. + * Intended to run caat in evented mode. + * @private + */ + needsRepaint:false, + + /** + * Touches information. Associate touch.id with an actor and original touch info. + * @private + */ + touches:null, + + /** + * Director´s timer manager. + * Each scene has a timerManager as well. + * The difference is the scope. Director´s timers will always be checked whereas scene´ timers + * will only be scheduled/checked when the scene is director´ current scene. + * @private + */ + timerManager:null, + + /** + * Retina display deicePixels/backingStorePixels ratio + * @private + */ + SCREEN_RATIO : 1, + + __map : null, + + clean:function () { + this.scenes = null; + this.currentScene = null; + this.imagesCache = null; + this.audioManager = null; + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + this.__gestureScale = 0; + this.__gestureRotation = 0; + this.dirty = true; + this.dirtyRects = null; + this.cDirtyRects = null; + this.dirtyRectsIndex = 0; + this.dirtyRectsEnabled = false; + this.nDirtyRects = 0; + this.onResizeCallback = null; + this.__map= {}; + return this; + }, + + cancelPlay : function(id) { + return this.audioManager.cancelPlay(id); + }, + + cancelPlayByChannel : function(audioObject) { + return this.audioManager.cancelPlayByChannel(audioObject); + }, + + setAudioFormatExtensions : function( extensions ) { + this.audioManager.setAudioFormatExtensions(extensions); + return this; + }, + + setValueForKey : function( key, value ) { + this.__map[key]= value; + return this; + }, + + getValueForKey : function( key ) { + return this.__map[key]; + }, + + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + requestRepaint:function () { + this.needsRepaint = true; + }, + + getCurrentScene:function () { + return this.currentScene; + }, + + checkDebug:function () { + if (!navigator.isCocoonJS && CAAT.DEBUG) { + var dd = new CAAT.Module.Debug.Debug().initialize(this.width, 60); + this.debugInfo = dd.debugInfo.bind(dd); + } + }, + getRenderType:function () { + return this.glEnabled ? 'WEBGL' : 'CANVAS'; + }, + windowResized:function (w, h) { + var c = CAAT.Foundation.Director; + switch (this.resize) { + case c.RESIZE_WIDTH: + this.setBounds(0, 0, w, this.height); + break; + case c.RESIZE_HEIGHT: + this.setBounds(0, 0, this.width, h); + break; + case c.RESIZE_BOTH: + this.setBounds(0, 0, w, h); + break; + case c.RESIZE_PROPORTIONAL: + this.setScaleProportional(w, h); + break; + } + + if (this.glEnabled) { + this.glReset(); + } + + if (this.onResizeCallback) { + this.onResizeCallback(this, w, h); + } + + }, + setScaleProportional:function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + + this.canvas.width = this.referenceWidth * factor; + this.canvas.height = this.referenceHeight * factor; + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + this.setScaleAnchored(factor * this.scaleX, factor * this.scaleY, 0, 0); +// this.setScaleAnchored(factor, factor, 0, 0); + + if (this.glEnabled) { + this.glReset(); + } + }, + /** + * Enable window resize events and set redimension policy. A callback functio could be supplied + * to be notified on a Director redimension event. This is necessary in the case you set a redim + * policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their + * children scenes are resized to fit the new area. But scenes content is not resized, and have + * no option of knowing so uless an onResizeCallback function is supplied. + * + * @param mode {number} RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE. + * @param onResizeCallback {function(director{CAAT.Director}, width{integer}, height{integer})} a callback + * to notify on canvas resize. + */ + enableResizeEvents:function (mode, onResizeCallback) { + var dd= CAAT.Foundation.Director; + if (mode === dd.RESIZE_BOTH || mode === dd.RESIZE_WIDTH || mode === dd.RESIZE_HEIGHT || mode === dd.RESIZE_PROPORTIONAL) { + this.referenceWidth = this.width; + this.referenceHeight = this.height; + this.resize = mode; + CAAT.registerResizeListener(this); + this.onResizeCallback = onResizeCallback; + this.windowResized(window.innerWidth, window.innerHeight); + } else { + CAAT.unregisterResizeListener(this); + this.onResizeCallback = null; + } + + return this; + }, + + __setupRetina : function() { + + if ( CAAT.RETINA_DISPLAY_ENABLED ) { + + // The world is full of opensource awesomeness. + // + // Source: http://www.html5rocks.com/en/tutorials/canvas/hidpi/ + // + var devicePixelRatio= CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio; + var backingStoreRatio = this.ctx.webkitBackingStorePixelRatio || + this.ctx.mozBackingStorePixelRatio || + this.ctx.msBackingStorePixelRatio || + this.ctx.oBackingStorePixelRatio || + this.ctx.backingStorePixelRatio || + 1; + + var ratio = devicePixelRatio / backingStoreRatio; + + if (devicePixelRatio !== backingStoreRatio) { + + var oldWidth = this.canvas.width; + var oldHeight = this.canvas.height; + + this.canvas.width = oldWidth * ratio; + this.canvas.height = oldHeight * ratio; + + this.canvas.style.width = oldWidth + 'px'; + this.canvas.style.height = oldHeight + 'px'; + + this.setScaleAnchored( ratio, ratio, 0, 0 ); + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + this.SCREEN_RATIO= ratio; + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, this.width, this.height); + } + }, + + /** + * Set this director's bounds as well as its contained scenes. + * @param x {number} ignored, will be 0. + * @param y {number} ignored, will be 0. + * @param w {number} director width. + * @param h {number} director height. + * + * @return this + */ + setBounds:function (x, y, w, h) { + + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + + if ( this.canvas.width!==w ) { + this.canvas.width = w; + } + + if ( this.canvas.height!==h ) { + this.canvas.height = h; + } + + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + if (this.glEnabled) { + this.glReset(); + } + + return this; + }, + /** + * This method performs Director initialization. Must be called once. + * If the canvas parameter is not set, it will create a Canvas itself, + * and the developer must explicitly add the canvas to the desired DOM position. + * This method will also set the Canvas dimension to the specified values + * by width and height parameters. + * + * @param width {number} a canvas width + * @param height {number} a canvas height + * @param canvas {HTMLCanvasElement=} An optional Canvas object. + * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + * and want events delivered to the correct element. + * + * @return this + */ + initialize:function (width, height, canvas, proxy) { + if ( typeof canvas!=="undefined" ) { + if ( isString(canvas) ) { + canvas= document.getElementById(canvas); + } else if ( !(canvas instanceof HTMLCanvasElement ) ) { + console.log("Canvas is a: "+canvas+" ???"); + } + } + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + this.canvas = canvas; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.setBounds(0, 0, width, height); + this.enableEvents(proxy); + + this.timeline = new Date().getTime(); + + // transition scene + if (CAAT.CACHE_SCENE_ON_CHANGE) { + this.transitionScene = new CAAT.Foundation.Scene().setBounds(0, 0, width, height); + var transitionCanvas = document.createElement('canvas'); + transitionCanvas.width = width; + transitionCanvas.height = height; + var transitionImageActor = new CAAT.Foundation.Actor().setBackgroundImage(transitionCanvas); + this.transitionScene.ctx = transitionCanvas.getContext('2d'); + this.transitionScene.addChildImmediately(transitionImageActor); + this.transitionScene.setEaseListener(this); + } + + this.checkDebug(); + + return this; + }, + glReset:function () { + this.pMatrix = CAAT.WebGL.GLU.makeOrtho(0, this.referenceWidth, this.referenceHeight, 0, -1, 1); + this.gl.viewport(0, 0, this.canvas.width, this.canvas.height); + this.glColorProgram.setMatrixUniform(this.pMatrix); + this.glTextureProgram.setMatrixUniform(this.pMatrix); + this.gl.viewportWidth = this.canvas.width; + this.gl.viewportHeight = this.canvas.height; + }, + /** + * Experimental. + * Initialize a gl enabled director. + */ + initializeGL:function (width, height, canvas, proxy) { + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + canvas.width = width; + canvas.height = height; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.referenceWidth = width; + this.referenceHeight = height; + + var i; + + try { + this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); + this.gl.viewportWidth = width; + this.gl.viewportHeight = height; + CAAT.GLRENDER = true; + } catch (e) { + } + + if (this.gl) { + this.canvas = canvas; + this.setBounds(0, 0, width, height); + + this.enableEvents(canvas); + this.timeline = new Date().getTime(); + + this.glColorProgram = new CAAT.WebGL.ColorProgram(this.gl).create().initialize(); + this.glTextureProgram = new CAAT.WebGL.TextureProgram(this.gl).create().initialize(); + this.glTextureProgram.useProgram(); + this.glReset(); + + var maxTris = 512; + this.coords = new Float32Array(maxTris * 12); + this.uv = new Float32Array(maxTris * 8); + + this.gl.clearColor(0.0, 0.0, 0.0, 255); + + if (this.front_to_back) { + this.gl.clearDepth(1.0); + this.gl.enable(this.gl.DEPTH_TEST); + this.gl.depthFunc(this.gl.LESS); + } else { + this.gl.disable(this.gl.DEPTH_TEST); + } + + this.gl.enable(this.gl.BLEND); +// Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); + this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); + this.glEnabled = true; + + this.checkDebug(); + } else { + // fallback to non gl enabled canvas. + return this.initialize(width, height, canvas); + } + + return this; + }, + /** + * Creates an initializes a Scene object. + * @return {CAAT.Scene} + */ + createScene:function () { + var scene = new CAAT.Scene(); + this.addScene(scene); + return scene; + }, + setImagesCache:function (imagesCache, tpW, tpH) { + + if (!imagesCache || !imagesCache.length ) { + return this; + } + + var i; + + if (null !== this.glTextureManager) { + this.glTextureManager.deletePages(); + this.glTextureManager = null; + } + + // delete previous image identifiers + if (this.imagesCache) { + var ids = []; + for (i = 0; i < this.imagesCache.length; i++) { + ids.push(this.imagesCache[i].id); + } + + for (i = 0; i < ids.length; i++) { + delete this.imagesCache[ ids[i] ]; + } + } + + this.imagesCache = imagesCache; + + if (imagesCache) { + for (i = 0; i < imagesCache.length; i++) { + this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; + } + } + + this.tpW = tpW || 2048; + this.tpH = tpH || 2048; + + this.updateGLPages(); + + return this; + }, + updateGLPages:function () { + if (this.glEnabled) { + + this.glTextureManager = new CAAT.Module.TexturePacker.TexturePageManager(); + this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); + + this.currentTexturePage = this.glTextureManager.pages[0]; + this.glTextureProgram.setTexture(this.currentTexturePage.texture); + } + }, + setGLTexturePage:function (tp) { + this.currentTexturePage = tp; + this.glTextureProgram.setTexture(tp.texture); + return this; + }, + /** + * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this + * function will try to recreate the whole GL texture pages. + * If many handcrafted images are to be added to the director, some performance can be achieved by calling + * director.addImage(id,image,false) many times and a final call with + * director.addImage(id,image,true) to finally command the director to create texture pages. + * + * @param id {string|object} an identitifier to retrieve the image with + * @param image {Image|HTMLCanvasElement} image to add to cache + * @param noUpdateGL {!boolean} unless otherwise stated, the director will + * try to recreate the texture pages. + */ + addImage:function (id, image, noUpdateGL) { + if (this.getImage(id)) { +// for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === id) { + this.imagesCache[i].image = image; + break; + } + } + this.imagesCache[ id ] = image; + } else { + this.imagesCache.push({ id:id, image:image }); + this.imagesCache[id] = image; + } + + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + deleteImage:function (id, noUpdateGL) { + for (var i = 0; i < this.imagesCache.length; i++) { + if (this.imagesCache[i].id === id) { + delete this.imagesCache[id]; + this.imagesCache.splice(i, 1); + break; + } + } + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + setGLCurrentOpacity:function (opacity) { + this.currentOpacity = opacity; + this.glTextureProgram.setAlpha(opacity); + }, + /** + * Render buffered elements. + * @param vertex + * @param coordsIndex + * @param uv + */ + glRender:function (vertex, coordsIndex, uv) { + + vertex = vertex || this.coords; + uv = uv || this.uv; + coordsIndex = coordsIndex || this.coordsIndex; + + var gl = this.gl; + + var numTris = coordsIndex / 12 * 2; + var numVertices = coordsIndex / 3; + + this.glTextureProgram.updateVertexBuffer(vertex); + this.glTextureProgram.updateUVBuffer(uv); + + gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); + + }, + glFlush:function () { + if (this.coordsIndex !== 0) { + this.glRender(this.coords, this.coordsIndex, this.uv); + } + this.coordsIndex = 0; + this.uvIndex = 0; + + this.statistics.draws++; + }, + + findActorAtPosition:function (point) { + + // z-order + var cl = this.childrenList; + for (var i = cl.length - 1; i >= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Math.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + + /** + * + * Reset statistics information. + * + * @private + */ + resetStats:function () { + this.statistics.size_total = 0; + this.statistics.size_active = 0; + this.statistics.draws = 0; + this.statistics.size_discarded_by_dirty_rects = 0; + }, + + /** + * This is the entry point for the animation system of the Director. + * The director is fed with the elapsed time value to maintain a virtual timeline. + * This virtual timeline will provide each Scene with its own virtual timeline, and will only + * feed time when the Scene is the current Scene, or is being switched. + * + * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be + * set up as a single clip area. + * + * @param time {number} integer indicating the elapsed time between two consecutive frames of the + * Director. + */ + render:function (time) { + + if (this.currentScene && this.currentScene.isPaused()) { + return; + } + + this.time += time; + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + var tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + + this.animate(this, this.time); + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + /** + * draw director active scenes. + */ + var ne = this.childrenList.length; + var i, tt, c; + var ctx = this.ctx; + + if (this.glEnabled) { + + this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); + this.coordsIndex = 0; + this.uvIndex = 0; + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + c.paintActorGL(this, tt); + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + } + + } + } + + this.glFlush(); + + } else { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + ctx.save(); + if (this.dirtyRectsEnabled) { + this.modelViewMatrix.transformRenderingContext(ctx); + + if (!CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + ctx.clip(); + } else { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + } else if (this.clear === CAAT.Foundation.Director.CLEAR_ALL) { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + ctx.save(); + + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + if (!CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled) { + if (this.nDirtyRects) { + c.paintActor(this, tt); + } + } else { + c.paintActor(this, tt); + } + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + ctx.restore(); + + if (CAAT.DEBUGAABB) { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + this.modelViewMatrix.transformRenderingContextSet(ctx); + c.drawScreenBoundingBox(this, tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + } + + } + } + + if (this.nDirtyRects > 0 && (!navigator.isCocoonJS && CAAT.DEBUG) && CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + + ctx.clip(); + ctx.fillStyle = 'rgba(160,255,150,.4)'; + ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + ctx.restore(); + } + + this.frameCounter++; + }, + + inDirtyRect:function (actor) { + + if (!this.dirtyRectsEnabled || CAAT.DEBUG_DIRTYRECTS) { + return true; + } + + var dr = this.cDirtyRects; + var i; + var aabb = actor.AABB; + + for (i = 0; i < dr.length; i++) { + if (dr[i].intersects(aabb)) { + return true; + } + } + + this.statistics.size_discarded_by_dirty_rects += actor.size_total; + return false; + }, + + /** + * A director is a very special kind of actor. + * Its animation routine simple sets its modelViewMatrix in case some transformation's been + * applied. + * No behaviors are allowed for Director instances. + * @param director {CAAT.Director} redundant reference to CAAT.Director itself + * @param time {number} director time. + */ + animate:function (director, time) { + + this.timerManager.checkTimers(time); + + this.setModelViewMatrix(this); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.setScreenBounds(); + + this.dirty = false; + this.invalid = false; + this.dirtyRectsIndex = -1; + this.cDirtyRects= []; + + var cl = this.childrenList; + var cli; + var i, l; + + + if (this.dirtyRectsEnabled) { + var sdr = this.sDirtyRects; + if (sdr.length) { + for (i = 0, l = sdr.length; i < l; i++) { + this.addDirtyRect(sdr[i]); + } + this.sDirtyRects = []; + } + } + + for (i = 0; i < cl.length; i++) { + cli = cl[i]; + var tt = cli.time - cli.start_time; + cli.animate(this, tt); + } + + this.timerManager.removeExpiredTimers(); + + return this; + }, + + /** + * This method is used when asynchronous operations must produce some dirty rectangle painting. + * This means that every operation out of the regular CAAT loop must add dirty rect operations + * by calling this method. + * For example setVisible() and remove. + * @param rectangle + */ + scheduleDirtyRect:function (rectangle) { + this.sDirtyRects.push(rectangle); + }, + /** + * Add a rectangle to the list of dirty screen areas which should be redrawn. + * This is the opposite method to clear the whole screen and repaint everything again. + * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this + * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or + * even lowers performance under others, so it is a developer choice to activate them via a call to + * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). + * + * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping + * rectangles will be removed and intersecting ones will be unioned. + * + * Before calling this method, check if this.dirtyRectsEnabled is true. + * + * @param rectangle {CAAT.Rectangle} + */ + addDirtyRect:function (rectangle) { + + if (rectangle.isEmpty()) { + return; + } + + var i, dr, j, drj; + var cdr = this.cDirtyRects; + + for (i = 0; i < cdr.length; i++) { + dr = cdr[i]; + if (!dr.isEmpty() && dr.intersects(rectangle)) { + var intersected = true; + while (intersected) { + dr.unionRectangle(rectangle); + + for (j = 0; j < cdr.length; j++) { + if (j !== i) { + drj = cdr[j]; + if (!drj.isEmpty() && drj.intersects(dr)) { + dr.unionRectangle(drj); + drj.setEmpty(); + break; + } + } + } + + if (j == cdr.length) { + intersected = false; + } + } + + for (j = 0; j < cdr.length; j++) { + if (cdr[j].isEmpty()) { + cdr.splice(j, 1); + } + } + + return; + } + } + + this.dirtyRectsIndex++; + + if (this.dirtyRectsIndex >= this.dirtyRects.length) { + for (i = 0; i < 32; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + } + + var r = this.dirtyRects[ this.dirtyRectsIndex ]; + + r.x = rectangle.x; + r.y = rectangle.y; + r.x1 = rectangle.x1; + r.y1 = rectangle.y1; + r.width = rectangle.width; + r.height = rectangle.height; + + this.cDirtyRects.push(r); + + }, + /** + * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of + * another Scene (transitionScene). So instead of drawing two scenes while transitioning from + * one to another, first of all an scene is drawn to offscreen, and that image is translated. + *

    + * Until the creation of this method, both scenes where drawn while transitioning with + * its performance penalty since drawing two scenes could be twice as expensive than drawing + * only one. + *

    + * Though a high performance increase, we should keep an eye on memory consumption. + * + * @param ctx a canvas.getContext('2d') instnce. + * @param scene {CAAT.Foundation.Scene} the scene to draw offscreen. + */ + renderToContext:function (ctx, scene) { + /** + * draw actors on scene. + */ + if (scene.isInAnimationFrame(this.time)) { + ctx.setTransform(1, 0, 0, 1, 0, 0); + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + ctx.clearRect(0, 0, this.width, this.height); + + var octx = this.ctx; + + this.ctx = ctx; + ctx.save(); + + /** + * to draw an scene to an offscreen canvas, we have to: + * 1.- save diector's world model view matrix + * 2.- set no transformation on director since we want the offscreen to + * be drawn 1:1. + * 3.- set world dirty flag, so that the scene will recalculate its matrices + * 4.- animate the scene + * 5.- paint the scene + * 6.- restore world model view matrix. + */ + var matmv = this.modelViewMatrix; + var matwmv = this.worldModelViewMatrix; + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrix = this.worldModelViewMatrix; + this.wdirty = true; + scene.animate(this, scene.time); + if (scene.onRenderStart) { + scene.onRenderStart(scene.time); + } + scene.paintActor(this, scene.time); + if (scene.onRenderEnd) { + scene.onRenderEnd(scene.time); + } + this.worldModelViewMatrix = matwmv; + this.modelViewMatrix = matmv; + + ctx.restore(); + + this.ctx = octx; + } + }, + /** + * Add a new Scene to Director's Scene list. By adding a Scene to the Director + * does not mean it will be immediately visible, you should explicitly call either + *

      + *
    • easeIn + *
    • easeInOut + *
    • easeInOutRandom + *
    • setScene + *
    • or any of the scene switching methods + *
    + * + * @param scene {CAAT.Foundation.Scene} + */ + addScene:function (scene) { + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + }, + + /** + * Private + * Gets a contained Scene index on this Director. + * + * @param scene a CAAT.Foundation.Scene object instance. + * + * @return {number} + */ + findScene:function (scene) { + var sl = this.scenes; + var i; + var len = sl.length; + + for (i = 0; i < len; i++) { + if (sl[i] === scene) { + return i; + } + } + return -1; + }, + + /** + * Private + * Removes a scene from this director. + * + * @param scene a CAAT.Foundation.Scene object instance or scene index. + * + * @return {number} + */ + removeScene: function(scene) { + if (typeof scene == 'number') { + this.scenes.splice(scene, 1); + } else { + var idx = this.findScene(scene); + if (idx > 0) { + this.scenes.splice(idx, 1); + } + } + }, + /** + * Get the number of scenes contained in the Director. + * @return {number} the number of scenes contained in the Director. + */ + getNumScenes:function () { + return this.scenes.length; + }, + /** + * This method offers full control over the process of switching between any given two Scenes. + * To apply this method, you must specify the type of transition to apply for each Scene and + * the anchor to keep the Scene pinned at. + *

    + * The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype: + *

      + *
    • EASE_ROTATION + *
    • EASE_SCALE + *
    • EASE_TRANSLATION + *
    + * + *

    + * The anchor will be any of these values defined in CAAT.Foundation.Actor: + *

      + *
    • ANCHOR_CENTER + *
    • ANCHOR_TOP + *
    • ANCHOR_BOTTOM + *
    • ANCHOR_LEFT + *
    • ANCHOR_RIGHT + *
    • ANCHOR_TOP_LEFT + *
    • ANCHOR_TOP_RIGHT + *
    • ANCHOR_BOTTOM_LEFT + *
    • ANCHOR_BOTTOM_RIGHT + *
    + * + *

    + * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the + * point by which the scene will scaled. + * + * @param inSceneIndex integer indicating the Scene index to bring in to the Director. + * @param typein integer indicating the type of transition to apply to the bringing in Scene. + * @param anchorin integer indicating the anchor of the bringing in Scene. + * @param outSceneIndex integer indicating the Scene index to take away from the Director. + * @param typeout integer indicating the type of transition to apply to the taking away in Scene. + * @param anchorout integer indicating the anchor of the taking away Scene. + * @param time inteter indicating the time to perform the process of switchihg between Scene object + * in milliseconds. + * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to + * the scenes. + * @param interpolatorIn CAAT.Behavior.Interpolator object to apply to entering scene. + * @param interpolatorOut CAAT.Behavior.Interpolator object to apply to exiting scene. + */ + easeInOut:function (inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { + + if (inSceneIndex === this.getCurrentSceneIndex()) { + return; + } + + var ssin = this.scenes[ inSceneIndex ]; + var sout = this.scenes[ outSceneIndex ]; + + if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) { + this.renderToContext(this.transitionScene.ctx, sout); + sout = this.transitionScene; + } + + ssin.setExpired(false); + sout.setExpired(false); + + ssin.mouseEnabled = false; + sout.mouseEnabled = false; + + ssin.resetTransform(); + sout.resetTransform(); + + ssin.setLocation(0, 0); + sout.setLocation(0, 0); + + ssin.alpha = 1; + sout.alpha = 1; + + if (typein === CAAT.Foundation.Scene.EASE_ROTATION) { + ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); + } else if (typein === CAAT.Foundation.Scene.EASE_SCALE) { + ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); + } else { + ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); + } + + if (typeout === CAAT.Foundation.Scene.EASE_ROTATION) { + sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); + } else if (typeout === CAAT.Foundation.Scene.EASE_SCALE) { + sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); + } else { + sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); + } + + this.childrenList = []; + + sout.goOut(ssin); + ssin.getIn(sout); + + this.addChild(sout); + this.addChild(ssin); + }, + /** + * This method will switch between two given Scene indexes (ie, take away scene number 2, + * and bring in scene number 5). + *

    + * It will randomly choose for each Scene the type of transition to apply and the anchor + * point of each transition type. + *

    + * It will also set for different kind of transitions the following interpolators: + *

      + *
    • EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. + *
    • EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 + *
    • EASE_TRANSLATION -> BounceOutInterpolator + *
    + * + *

    + * These are the default values, and could not be changed by now. + * This method in final instance delegates the process to easeInOutMethod. + * + * @see easeInOutMethod. + * + * @param inIndex integer indicating the entering scene index. + * @param outIndex integer indicating the exiting scene index. + * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. + * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. + */ + easeInOutRandom:function (inIndex, outIndex, time, alpha) { + + var pin = Math.random(); + var pout = Math.random(); + + var typeIn; + var interpolatorIn; + + if (pin < 0.33) { + typeIn = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorIn = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pin < 0.66) { + typeIn = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorIn = new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4); + } else { + typeIn = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorIn = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + var typeOut; + var interpolatorOut; + + if (pout < 0.33) { + typeOut = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pout < 0.66) { + typeOut = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4); + } else { + typeOut = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorOut = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + this.easeInOut( + inIndex, + typeIn, + (Math.random() * 8.99) >> 0, + + outIndex, + typeOut, + (Math.random() * 8.99) >> 0, + + time, + alpha, + + interpolatorIn, + interpolatorOut); + + }, + /** + * This method changes Director's current Scene to the scene index indicated by + * inSceneIndex parameter. The Scene running in the director won't be eased out. + * + * @see {CAAT.Interpolator} + * @see {CAAT.Actor} + * @see {CAAT.Scene} + * + * @param inSceneIndex integer indicating the new Scene to set as current. + * @param type integer indicating the type of transition to apply to bring the new current + * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, + * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. + * @param time integer indicating how much time in milliseconds the Scene entrance will take. + * @param alpha boolean indicating whether alpha transparency fading will be applied to the + * entereing Scene. + * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of + * CAAT.Actor.prototype.ANCHOR_* values. + * @param interpolator an CAAT.Interpolator object indicating the interpolation function to + * apply. + */ + easeIn:function (inSceneIndex, type, time, alpha, anchor, interpolator) { + var sin = this.scenes[ inSceneIndex ]; + if (type === CAAT.Foundation.Scene.EASE_ROTATION) { + sin.easeRotationIn(time, alpha, anchor, interpolator); + } else if (type === CAAT.Foundation.Scene.EASE_SCALE) { + sin.easeScaleIn(0, time, alpha, anchor, interpolator); + } else { + sin.easeTranslationIn(time, alpha, anchor, interpolator); + } + this.childrenList = []; + this.addChild(sin); + + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + sin.mouseEnabled = false; + sin.setExpired(false); + }, + /** + * Changes (or sets) the current Director scene to the index + * parameter. There will be no transition on scene change. + * @param scene {number or scene object} an integer indicating the index of the target Scene or the target Scene itself + * to be shown. + */ + setScene:function (scene) { + var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene); + var sin = this.scenes[ sceneIndex ]; + this.childrenList = []; + this.addChild(sin); + this.currentScene = sin; + + sin.setExpired(false); + sin.mouseEnabled = true; + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + + sin.getIn(); + sin.activated(); + }, + /** + * This method will change the current Scene by the Scene indicated as parameter. + * It will apply random values for anchor and transition type. + * @see easeInOutRandom + * + * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. + * @param time {number} an integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToScene:function (iNewSceneIndex, time, alpha, transition) { + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (!transition) { + this.setScene(iNewSceneIndex); + } + else { + this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToPrevScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex - 1); + } + else { + this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToNextScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex + 1); + } + else { + this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); + } + }, + mouseEnter:function (mouseEvent) { + }, + mouseExit:function (mouseEvent) { + }, + mouseMove:function (mouseEvent) { + }, + mouseDown:function (mouseEvent) { + }, + mouseUp:function (mouseEvent) { + }, + mouseDrag:function (mouseEvent) { + }, + /** + * Scene easing listener. Notifies scenes when they're about to be activated (set as current + * director's scene). + * + * @param scene {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director. + * @param b_easeIn {boolean} scene enters or exits ? + */ + easeEnd:function (scene, b_easeIn) { + // scene is going out + if (!b_easeIn) { + + scene.setExpired(true); + } else { + this.currentScene = scene; + this.currentScene.activated(); + } + + scene.mouseEnabled = true; + scene.emptyBehaviorList(); + }, + /** + * Return the index for a given Scene object contained in the Director. + * @param scene {CAAT.Foundation.Scene} + */ + getSceneIndex:function (scene) { + for (var i = 0; i < this.scenes.length; i++) { + if (this.scenes[i] === scene) { + return i; + } + } + return -1; + }, + /** + * Get a concrete director's scene. + * @param index {number} an integer indicating the scene index. + * @return {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob. + */ + getScene:function (index) { + return this.scenes[index]; + }, + getSceneById : function(id) { + for( var i=0; iimagesCache + * where you can store a JSON of the form + * [ { id: imageId, image: imageObject } ]. + * This structure will be used as a resources cache. + * There's a CAAT.Module.ImagePreloader class to preload resources and + * generate this structure on loading finalization. + * + * @param sId {object} an String identifying a resource. + */ + getImage:function (sId) { + var ret = this.imagesCache[sId]; + if (ret) { + return ret; + } + + //for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === sId) { + return this.imagesCache[i].image; + } + } + + return null; + }, + musicPlay: function(id) { + return this.audioManager.playMusic(id); + }, + musicStop : function() { + this.audioManager.stopMusic(); + }, + /** + * Adds an audio to the cache. + * + * @see CAAT.Module.Audio.AudioManager.addAudio + * @return this + */ + addAudio:function (id, url) { + this.audioManager.addAudio(id, url); + return this; + }, + /** + * Plays the audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + */ + audioPlay:function (id) { + return this.audioManager.play(id); + }, + /** + * Loops an audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + * + * @return {HTMLElement|null} the value from audioManager.loop + */ + audioLoop:function (id) { + return this.audioManager.loop(id); + }, + endSound:function () { + return this.audioManager.endSound(); + }, + setSoundEffectsEnabled:function (enabled) { + return this.audioManager.setSoundEffectsEnabled(enabled); + }, + setMusicEnabled:function (enabled) { + return this.audioManager.setMusicEnabled(enabled); + }, + isMusicEnabled:function () { + return this.audioManager.isMusicEnabled(); + }, + isSoundEffectsEnabled:function () { + return this.audioManager.isSoundEffectsEnabled(); + }, + setVolume:function (id, volume) { + return this.audioManager.setVolume(id, volume); + }, + /** + * Removes Director's scenes. + */ + emptyScenes:function () { + this.scenes = []; + }, + /** + * Adds an scene to this Director. + * @param scene {CAAT.Foundation.Scene} a scene object. + */ + addChild:function (scene) { + scene.parent = this; + this.childrenList.push(scene); + }, + /** + * @Deprecated use CAAT.loop instead. + * @param fps + * @param callback + * @param callback2 + */ + loop:function (fps, callback, callback2) { + if (callback2) { + this.onRenderStart = callback; + this.onRenderEnd = callback2; + } else if (callback) { + this.onRenderEnd = callback; + } + CAAT.loop(); + }, + /** + * Starts the director animation.If no scene is explicitly selected, the current Scene will + * be the first scene added to the Director. + *

    + * The fps parameter will set the animation quality. Higher values, + * means CAAT will try to render more frames in the same second (at the + * expense of cpu power at least until hardware accelerated canvas rendering + * context are available). A value of 60 is a high frame rate and should not be exceeded. + * + */ + renderFrame:function () { + + CAAT.currentDirector = this; + + if (this.stopped) { + return; + } + + var t = new Date().getTime(), + delta = t - this.timeline; + + /* + check for massive frame time. if for example the current browser tab is minified or taken out of + foreground, the system will account for a bit time interval. minify that impact by lowering down + the elapsed time (virtual timelines FTW) + */ + if (delta > 500) { + delta = 500; + } + + if (this.onRenderStart) { + this.onRenderStart(delta); + } + + this.render(delta); + + if (this.debugInfo) { + this.debugInfo(this.statistics); + } + + this.timeline = t; + + if (this.onRenderEnd) { + this.onRenderEnd(delta); + } + + this.needsRepaint = false; + }, + + /** + * If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement. + */ + resetTimeline:function () { + this.timeline = new Date().getTime(); + }, + + endLoop:function () { + }, + /** + * This method states whether the director must clear background before rendering + * each frame. + * + * The clearing method could be: + * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. + * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled + * will have their areas redrawn. + * + CAAT.Director.CLEAR_NONE. clears nothing. + * + * @param clear {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} + * @return this. + */ + setClear:function (clear) { + this.clear = clear; + if (this.clear === CAAT.Foundation.Director.CLEAR_DIRTY_RECTS) { + this.dirtyRectsEnabled = true; + } else { + this.dirtyRectsEnabled= false; + } + return this; + }, + /** + * Get this Director's AudioManager instance. + * @return {CAAT.AudioManager} the AudioManager instance. + */ + getAudioManager:function () { + return this.audioManager; + }, + /** + * Acculumate dom elements position to properly offset on-screen mouse/touch events. + * @param node + */ + cumulateOffset:function (node, parent, prop) { + var left = prop + 'Left'; + var top = prop + 'Top'; + var x = 0, y = 0, style; + + while (navigator.browser !== 'iOS' && node && node.style) { + if (node.currentStyle) { + style = node.currentStyle['position']; + } else { + style = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); + style = style ? style.getPropertyValue('position') : null; + } + +// if (!/^(relative|absolute|fixed)$/.test(style)) { + if (!/^(fixed)$/.test(style)) { + x += node[left]; + y += node[top]; + node = node[parent]; + } else { + break; + } + } + + return { + x:x, + y:y, + style:style + }; + }, + getOffset:function (node) { + var res = this.cumulateOffset(node, 'offsetParent', 'offset'); + if (res.style === 'fixed') { + var res2 = this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); + return { + x:res.x + res2.x, + y:res.y + res2.y + }; + } + + return { + x:res.x, + y:res.y + }; + }, + /** + * Normalize input event coordinates to be related to (0,0) canvas position. + * @param point {CAAT.Math.Point} canvas coordinate. + * @param e {MouseEvent} a mouse event from an input event. + */ + getCanvasCoord:function (point, e) { + + var pt = new CAAT.Math.Point(); + var posx = 0; + var posy = 0; + if (!e) e = window.event; + + if (e.pageX || e.pageY) { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) { + posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + + var offset = this.getOffset(this.canvas); + + posx -= offset.x; + posy -= offset.y; + + posx*= this.SCREEN_RATIO; + posy*= this.SCREEN_RATIO; + + ////////////// + // transformar coordenada inversamente con affine transform de director. + + pt.x = posx; + pt.y = posy; + if (!this.modelViewMatrixI) { + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + } + this.modelViewMatrixI.transformCoord(pt); + posx = pt.x; + posy = pt.y + + point.set(posx, posy); + this.screenMousePoint.set(posx, posy); + + }, + + __mouseDownHandler:function (e) { + + /* + was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no + button was presses. Then, send a mouseUp for the previos actor, and return; + */ + if (this.dragging && this.lastSelectedActor) { + this.__mouseUpHandler(e); + return; + } + + this.getCanvasCoord(this.mousePoint, e); + this.isMouseDown = true; + var lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + var pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseDown( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y))); + } + + this.lastSelectedActor = lactor; + }, + + __mouseUpHandler:function (e) { + + this.isMouseDown = false; + this.getCanvasCoord(this.mousePoint, e); + + var pos = null; + var lactor = this.lastSelectedActor; + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + if (lactor.actionPerformed && lactor.contains(pos.x, pos.y)) { + lactor.actionPerformed(e) + } + + lactor.mouseUp( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + + if (!this.dragging && null !== lactor) { + if (lactor.contains(pos.x, pos.y)) { + lactor.mouseClick( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + } + + this.dragging = false; + this.in_ = false; +// CAAT.setCursor('default'); + }, + + __mouseMoveHandler:function (e) { + //this.getCanvasCoord(this.mousePoint, e); + + var lactor; + var pos; + + var ct = this.currentScene ? this.currentScene.time : 0; + + // drag + + if (this.isMouseDown && null!==this.lastSelectedActor) { + + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + // check for mouse move threshold. + if (!this.dragging) { + if (Math.abs(this.prevMousePoint.x - pos.x) < CAAT.DRAG_THRESHOLD_X && + Math.abs(this.prevMousePoint.y - pos.y) < CAAT.DRAG_THRESHOLD_Y) { + return; + } + } + + this.dragging = true; + + var px = lactor.x; + var py = lactor.y; + lactor.mouseDrag( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y), + ct)); + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + /** + * Element has not moved after drag, so treat it as a button. + */ + if (px === lactor.x && py === lactor.y) { + + var contains = lactor.contains(pos.x, pos.y); + + if (this.in_ && !contains) { + lactor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = false; + } + + if (!this.in_ && contains) { + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = true; + } + } + + return; + } + + // mouse move. + this.in_ = true; + + lactor = this.findActorAtPosition(this.mousePoint); + + // cambiamos de actor. + if (lactor !== this.lastSelectedActor) { + if (null !== this.lastSelectedActor) { + + pos = this.lastSelectedActor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + this.lastSelectedActor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + ct)); + } + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + } + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + if (null !== lactor) { + + lactor.mouseMove( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + this.lastSelectedActor = lactor; + }, + + __mouseOutHandler:function (e) { + + if (this.dragging) { + return; + } + + if (null !== this.lastSelectedActor) { + + this.getCanvasCoord(this.mousePoint, e); + var pos = new CAAT.Math.Point(this.mousePoint.x, this.mousePoint.y, 0); + this.lastSelectedActor.viewToModel(pos); + + var ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time); + + this.lastSelectedActor.mouseExit(ev); + this.lastSelectedActor.mouseOut(ev); + if (!this.dragging) { + this.lastSelectedActor = null; + } + } else { + this.isMouseDown = false; + this.in_ = false; + + } + + }, + + __mouseOverHandler:function (e) { + + if (this.dragging) { + return; + } + + var lactor; + var pos, ev; + + if (null == this.lastSelectedActor) { + lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene ? this.currentScene.time : 0); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + } + + this.lastSelectedActor = lactor; + } else { + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + + } + }, + + __mouseDBLClickHandler:function (e) { + + this.getCanvasCoord(this.mousePoint, e); + if (null !== this.lastSelectedActor) { + /* + var pos = this.lastSelectedActor.viewToModel( + new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + */ + this.lastSelectedActor.mouseDblClick( + new CAAT.Event.MouseEvent().init( + this.mousePoint.x, + this.mousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + /** + * Same as mouseDown but not preventing event. + * Will only take care of first touch. + * @param e + */ + __touchStartHandler:function (e) { + + if (e.target === this.canvas) { + e.preventDefault(); + e.returnValue = false; + + e = e.targetTouches[0]; + + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + return; + } + + this.touching = true; + + this.__mouseDownHandler(e); + } + }, + + __touchEndHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + e = e.changedTouches[0]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + + this.touching = false; + + this.__mouseUpHandler(e); + } + }, + + __touchMoveHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + if (this.gesturing) { + return; + } + + for (var i = 0; i < e.targetTouches.length; i++) { + var ee = e.targetTouches[i]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, ee); + this.__mouseMoveHandler(ee); + } + } + }, + + __gestureStart:function (scale, rotation) { + this.gesturing = true; + this.__gestureRotation = this.lastSelectedActor.rotationAngle; + this.__gestureSX = this.lastSelectedActor.scaleX - 1; + this.__gestureSY = this.lastSelectedActor.scaleY - 1; + }, + + __gestureChange:function (scale, rotation) { + if (typeof scale === 'undefined' || typeof rotation === 'undefined') { + return; + } + + if (this.lastSelectedActor !== null && this.lastSelectedActor.isGestureEnabled()) { + this.lastSelectedActor.setRotation(rotation * Math.PI / 180 + this.__gestureRotation); + + this.lastSelectedActor.setScale( + this.__gestureSX + scale, + this.__gestureSY + scale); + } + + }, + + __gestureEnd:function (scale, rotation) { + this.gesturing = false; + this.__gestureRotation = 0; + this.__gestureScale = 0; + }, + + __touchEndHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i, j; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var _touch = e.changedTouches[i]; + var id = _touch.identifier; + recent.push(id); + } + + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + if (this.touches[ touchId ]) { + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addChangedTouch(this.touches[ touchId ].touch); + } + } + + /** + * remove ended touch info. + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + delete this.touches[id]; + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchEnd(touch); + } + }, + + __touchMoveHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + + if (this.touches[ id ]) { + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + + var actor = this.touches[ id ].actor; + mp = actor.viewToModel(mp); + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchMove(touch); + } + }, + + __touchCancelHandleMT:function (e) { + this.__touchEndHandlerMT(e); + }, + + __touchStartHandlerMT:function (e) { + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + var allInCanvas = true; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + allInCanvas = false; + continue; + } + + var actor = this.findActorAtPosition(mp); + if (actor !== null) { + mp = actor.viewToModel(mp); + + if (!this.touches[ id ]) { + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchStart(touch); + } + + }, + + __findTouchFirstActor:function () { + + var t = Number.MAX_VALUE; + var actor = null; + for (var pr in this.touches) { + + var touch = this.touches[pr]; + + if (touch.touch.time && touch.touch.time < t && touch.actor.isGestureEnabled()) { + actor = touch.actor; + t = touch.touch.time; + } + } + return actor; + }, + + __gesturedActor:null, + __touchGestureStartHandleMT:function (e) { + var actor = this.__findTouchFirstActor(); + + if (actor !== null && actor.isGestureEnabled()) { + this.__gesturedActor = actor; + this.__gestureRotation = actor.rotationAngle; + this.__gestureSX = actor.scaleX - 1; + this.__gestureSY = actor.scaleY - 1; + + + actor.gestureStart( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + }, + + __touchGestureEndHandleMT:function (e) { + + if (null !== this.__gesturedActor && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureEnd( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + + this.__gestureRotation = 0; + this.__gestureScale = 0; + + + }, + + __touchGestureChangeHandleMT:function (e) { + + if (this.__gesturedActor !== null && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureChange( + e.rotation * Math.PI / 180, + this.__gestureSX + e.scale, + this.__gestureSY + e.scale); + } + }, + + + addHandlers:function (canvas) { + + var me = this; + + window.addEventListener('mouseup', function (e) { + if (me.touching) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseUpHandler(e); + + me.touching = false; + } + }, false); + + window.addEventListener('mousedown', function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + me.touching = true; + + me.__mouseDownHandler(e); + } + }, false); + + window.addEventListener('mouseover', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseOverHandler(e); + } + }, false); + + window.addEventListener('mouseout', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseOutHandler(e); + } + }, false); + + window.addEventListener('mousemove', function (e) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (!me.dragging && ( mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height )) { + return; + } + me.__mouseMoveHandler(e); + }, false); + + window.addEventListener("dblclick", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseDBLClickHandler(e); + } + }, false); + + if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MOUSE) { + canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); + canvas.addEventListener("gesturestart", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureStart(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gestureend", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureEnd(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gesturechange", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureChange(e.scale, e.rotation); + } + }, false); + } else if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MULTITOUCH) { + canvas.addEventListener("touchstart", this.__touchStartHandlerMT.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandlerMT.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandlerMT.bind(this), false); + canvas.addEventListener("touchcancel", this.__touchCancelHandleMT.bind(this), false); + + canvas.addEventListener("gesturestart", this.__touchGestureStartHandleMT.bind(this), false); + canvas.addEventListener("gestureend", this.__touchGestureEndHandleMT.bind(this), false); + canvas.addEventListener("gesturechange", this.__touchGestureChangeHandleMT.bind(this), false); + } + + }, + + enableEvents:function (onElement) { + CAAT.RegisterDirector(this); + this.in_ = false; + this.createEventHandler(onElement); + }, + + createEventHandler:function (onElement) { + //var canvas= this.canvas; + this.in_ = false; + //this.addHandlers(canvas); + this.addHandlers(onElement); + } + } + }, + + onCreate:function () { + + if (typeof CAAT.__CSS__!=="undefined") { + + CAAT.Foundation.Director.prototype.clip = true; + CAAT.Foundation.Director.prototype.glEnabled = false; + + CAAT.Foundation.Director.prototype.getRenderType = function () { + return 'CSS'; + }; + + CAAT.Foundation.Director.prototype.setScaleProportional = function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + this.setScaleAnchored(factor, factor, 0, 0); + + this.eventHandler.style.width = '' + this.referenceWidth + 'px'; + this.eventHandler.style.height = '' + this.referenceHeight + 'px'; + }; + + CAAT.Foundation.Director.prototype.setBounds = function (x, y, w, h) { + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, w, h); + } + this.eventHandler.style.width = w + 'px'; + this.eventHandler.style.height = h + 'px'; + + return this; + }; + + /** + * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most + * div in the document hierarchy (z-index 999999). + * @param width + * @param height + * @param domElement + * @param proxy + */ + CAAT.Foundation.Director.prototype.initialize = function (width, height, domElement, proxy) { + + this.timeline = new Date().getTime(); + this.domElement = domElement; + this.style('position', 'absolute'); + this.style('width', '' + width + 'px'); + this.style('height', '' + height + 'px'); + this.style('overflow', 'hidden'); + + this.enableEvents(domElement); + + this.setBounds(0, 0, width, height); + + this.checkDebug(); + return this; + }; + + CAAT.Foundation.Director.prototype.render = function (time) { + + this.time += time; + this.animate(this, time); + + /** + * draw director active scenes. + */ + var i, l, tt; + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + c.paintActor(this, tt); + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_discarded_by_dirtyRects += this.drDiscarded; + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + + } + + } + } + + this.frameCounter++; + }; + + CAAT.Foundation.Director.prototype.addScene = function (scene) { + scene.setVisible(true); + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + + this.domElement.appendChild(scene.domElement); + }; + + CAAT.Foundation.Director.prototype.emptyScenes = function () { + this.scenes = []; + this.domElement.innerHTML = ''; + this.createEventHandler(); + }; + + CAAT.Foundation.Director.prototype.setClear = function (clear) { + return this; + }; + + CAAT.Foundation.Director.prototype.createEventHandler = function () { + this.eventHandler = document.createElement('div'); + this.domElement.appendChild(this.eventHandler); + + this.eventHandler.style.position = 'absolute'; + this.eventHandler.style.left = '0'; + this.eventHandler.style.top = '0'; + this.eventHandler.style.zIndex = 999999; + this.eventHandler.style.width = '' + this.width + 'px'; + this.eventHandler.style.height = '' + this.height + 'px'; + + this.canvas = this.eventHandler; + this.in_ = false; + + this.addHandlers(this.canvas); + }; + + CAAT.Foundation.Director.prototype.inDirtyRect = function () { + return true; + } + } + } +}); +/** + * See LICENSE file. + * + * In this file we'll be adding every useful Actor that is specific for certain purpose. + * + * + CAAT.Dock: a docking container that zooms in/out its actors. + * + */ + +CAAT.Module( { + + /** + * @name UI + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name Dock + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.Dock", + aliases : ["CAAT.Dock"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer", + "CAAT.Behavior.GenericBehavior" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Dock + */ + + /** + * @const + */ + OP_LAYOUT_BOTTOM: 0, + /** + * @const + */ + OP_LAYOUT_TOP: 1, + /** + * @const + */ + OP_LAYOUT_LEFT: 2, + /** + * @const + */ + OP_LAYOUT_RIGHT: 3 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Dock.prototype + */ + + /** + * scene the actor is in. + */ + scene: null, + + /** + * resetting dimension timer task. + */ + ttask: null, + + /** + * min contained actor size. + */ + minSize: 0, + + /** + * max contained actor size + */ + maxSize: 0, + + /** + * aproximated number of elements affected. + */ + range: 2, + + /** + * Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_* + */ + layoutOp: 0, + + initialize : function(scene) { + this.scene= scene; + return this; + }, + /** + * Set the number of elements that will be affected (zoomed) when the mouse is inside the component. + * @param range {number} a number. Defaults to 2. + */ + setApplicationRange : function( range ) { + this.range= range; + return this; + }, + /** + * Set layout orientation. Choose from + *

      + *
    • CAAT.Dock.OP_LAYOUT_BOTTOM + *
    • CAAT.Dock.OP_LAYOUT_TOP + *
    • CAAT.Dock.OP_LAYOUT_BOTTOM + *
    • CAAT.Dock.OP_LAYOUT_RIGHT + *
    + * By default, the layou operation is OP_LAYOUT_BOTTOM, that is, elements zoom bottom anchored. + * + * @param lo {number} one of CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_TOP, + * CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_RIGHT. + * + * @return this + */ + setLayoutOp : function( lo ) { + this.layoutOp= lo; + return this; + }, + /** + * + * Set maximum and minimum size of docked elements. By default, every contained actor will be + * of 'min' size, and will be scaled up to 'max' size. + * + * @param min {number} + * @param max {number} + * @return this + */ + setSizes : function( min, max ) { + this.minSize= min; + this.maxSize= max; + + for( var i=0; isetLayoutOp. + * + * @private + */ + layout : function() { + var i,actor; + + var c= CAAT.Foundation.UI.Dock; + + if ( this.layoutOp===c.OP_LAYOUT_BOTTOM || this.layoutOp===c.OP_LAYOUT_TOP ) { + + var currentWidth=0, currentX=0; + + for( i=0; i index + this.range) { + wwidth = this.minSize; + } else if (i === index) { + wwidth = this.maxSize; + } else if (i < index) { + wwidth= + this.minSize + + (this.maxSize-this.minSize) * + (Math.cos((i - index - across + 1) / this.range * Math.PI) + 1) / + 2; + } else { + wwidth= + this.minSize + + (this.maxSize-this.minSize)* + (Math.cos( (i - index - across) / this.range * Math.PI) + 1) / + 2; + } + + actor.height= wwidth; + actor.width= wwidth; + } + + this.layout(); + }, + /** + * Perform the process of exiting the docking element, that is, animate elements to the minimum + * size. + * + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseExit : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + } + + var me= this; + this.ttask= this.scene.createTimer( + this.scene.time, + 100, + function timeout(sceneTime, time, timerTask) { + me.actorNotPointed(); + }, + null, + null); + }, + /** + * Perform the beginning of docking elements. + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseEnter : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + this.ttask= null; + } + }, + /** + * Adds an actor to Dock. + *

    + * Be aware that actor mouse functions must be set prior to calling this method. The Dock actor + * needs set his own actor input events functions for mouseEnter, mouseExit and mouseMove and + * will then chain to the original methods set by the developer. + * + * @param actor {CAAT.Actor} a CAAT.Actor instance. + * + * @return this + */ + addChild : function(actor) { + var me= this; + + actor.__Dock_mouseEnter= actor.mouseEnter; + actor.__Dock_mouseExit= actor.mouseExit; + actor.__Dock_mouseMove= actor.mouseMove; + + /** + * @ignore + * @param mouseEvent + */ + actor.mouseEnter= function(mouseEvent) { + me.actorMouseEnter(mouseEvent); + this.__Dock_mouseEnter(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseExit= function(mouseEvent) { + me.actorMouseExit(mouseEvent); + this.__Dock_mouseExit(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseMove= function(mouseEvent) { + me.actorPointed( mouseEvent.point.x, mouseEvent.point.y, mouseEvent.source ); + this.__Dock_mouseMove(mouseEvent); + }; + + actor.width= this.minSize; + actor.height= this.minSize; + + return CAAT.Foundation.UI.Dock.superclass.addChild.call(this,actor); + } + } + +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module( { + + /** + * @name InterpolatorActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.InterpolatorActor", + aliases : ["CAAT.InterpolatorActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.InterpolatorActor.prototype + */ + + /** + * The interpolator instance to draw. + * @type {CAAT.Behavior.Interpolator} + */ + interpolator: null, + + /** + * This interpolator´s contour. + * @type {Array.} + */ + contour: null, // interpolator contour cache + + /** + * Number of samples to calculate a contour. + */ + S: 50, // contour samples. + + /** + * padding when drawing the interpolator. + */ + gap: 5, // border size in pixels. + + /** + * Sets a padding border size. By default is 5 pixels. + * @param gap {number} border size in pixels. + * @return this + */ + setGap : function( gap ) { + this.gap= gap; + return this; + }, + /** + * Sets the CAAT.Interpolator instance to draw. + * + * @param interpolator a CAAT.Interpolator instance. + * @param size an integer indicating the number of polyline segments so draw to show the CAAT.Interpolator + * instance. + * + * @return this + */ + setInterpolator : function( interpolator, size ) { + this.interpolator= interpolator; + this.contour= interpolator.getContour(size || this.S); + + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Director} + * @param time {number} scene time. + */ + paint : function( director, time ) { + + CAAT.InterpolatorActor.superclass.paint.call(this,director,time); + + if ( this.backgroundImage ) { + return this; + } + + if ( this.interpolator ) { + + var canvas= director.ctx; + + var xs= (this.width-2*this.gap); + var ys= (this.height-2*this.gap); + + canvas.beginPath(); + canvas.moveTo( + this.gap + xs*this.contour[0].x, + -this.gap + this.height - ys*this.contour[0].y); + + for( var i=1; i>0)+1)*ts; + }, + + setFillStyle : function( style ) { + this.fill= style; + }, + + setStrokeStyle : function( style ) { + this.stroke= style; + }, + + setStrokeSize : function( size ) { + this.strokeSize= size; + }, + + setAlignment : function( alignment ) { + this.alignment= alignment; + }, + + setFontSize : function( size ) { + if ( size!==this.fontSize ) { + this.fontSize= size; + this.__setFont(); + } + } + }; + + /** + * This class keeps track of styles, images, and the current applied style. + */ + var renderContext= function() { + this.text= ""; + return this; + }; + + renderContext.prototype= { + + x : 0, + y : 0, + width : 0, + text : null, + + crcs : null, // current rendering context style + rcs : null, // rendering content styles stack + + styles : null, + images : null, + + lines : null, + + documentHeight : 0, + + anchorStack : null, + + __nextLine : function() { + this.x= 0; + this.currentLine= new DocumentLine( + CAAT.Module.Font.Font.getFontMetrics( this.crcs.sfont) ); + this.lines.push( this.currentLine ); + }, + + /** + * + * @param image {CAAT.SpriteImage} + * @param r {number=} + * @param c {number=} + * @private + */ + __image : function( image, r, c ) { + + + var image_width; + + if ( typeof r!=="undefined" && typeof c!=="undefined" ) { + image_width= image.getWidth(); + } else { + image_width= ( image instanceof CAAT.Foundation.SpriteImage ) ? image.getWidth() : image.getWrappedImageWidth(); + } + + // la imagen cabe en este sitio. + if ( this.width ) { + if ( image_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + this.currentLine.addElementImage( new DocumentElementImage( + this.x, + image, + r, + c, + this.crcs.clone(), + this.__getCurrentAnchor() ) ); + + this.x+= image_width; + }, + + __text : function() { + + if ( this.text.length===0 ) { + return; + } + + var text_width= this.ctx.measureText(this.text).width; + + // la palabra cabe en este sitio. + if ( this.width ) { + if ( text_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + //this.crcs.text( this.text, this.x, this.y ); + this.currentLine.addElement( new DocumentElementText( + this.text, + this.x, + text_width, + 0, //this.crcs.__getProperty("fontSize"), calculated later + this.crcs.clone(), + this.__getCurrentAnchor() ) ) ; + + this.x+= text_width; + + this.text=""; + }, + + fchar : function( _char ) { + + if ( _char===' ' ) { + + this.__text(); + + this.x+= this.ctx.measureText(_char).width; + if ( this.width ) { + if ( this.x > this.width ) { + this.__nextLine(); + } + } + } else { + this.text+= _char; + } + }, + + end : function() { + if ( this.text.length>0 ) { + this.__text(); + } + + var y=0; + var lastLineEstimatedDescent= 0; + for( var i=0; i>0; + } + + this.lines[i].setY(y); + } + + this.documentHeight= y + lastLineEstimatedDescent; + }, + + getDocumentHeight : function() { + return this.documentHeight; + }, + + __getCurrentAnchor : function() { + if ( this.anchorStack.length ) { + return this.anchorStack[ this.anchorStack.length-1 ]; + } + + return null; + }, + + __resetAppliedStyles : function() { + this.rcs= []; + this.__pushDefaultStyles(); + }, + + __pushDefaultStyles : function() { + this.crcs= new renderContextStyle(this.ctx).setDefault( this.styles["default"] ); + this.rcs.push( this.crcs ); + }, + + __pushStyle : function( style ) { + var pcrcs= this.crcs; + this.crcs= new renderContextStyle(this.ctx); + this.crcs.chain= pcrcs; + this.crcs.setStyle( style ); + this.crcs.applyStyle( ); + + this.rcs.push( this.crcs ); + }, + + __popStyle : function() { + // make sure you don't remove default style. + if ( this.rcs.length>1 ) { + this.rcs.pop(); + this.crcs= this.rcs[ this.rcs.length-1 ]; + this.crcs.applyStyle(); + } + }, + + __popAnchor : function() { + if ( this.anchorStack.length> 0 ) { + this.anchorStack.pop(); + } + }, + + __pushAnchor : function( anchor ) { + this.anchorStack.push( anchor ); + }, + + start : function( ctx, styles, images, width ) { + this.x=0; + this.y=0; + this.width= typeof width!=="undefined" ? width : 0; + this.ctx= ctx; + this.lines= []; + this.styles= styles; + this.images= images; + this.anchorStack= []; + + this.__resetAppliedStyles(); + this.__nextLine(); + + }, + + setTag : function( tag ) { + + var pairs, style; + + this.__text(); + + tag= tag.toLowerCase(); + if ( tag==='b' ) { + this.crcs.setBold( true ); + } else if ( tag==='/b' ) { + this.crcs.setBold( false ); + } else if ( tag==='i' ) { + this.crcs.setItalic( true ); + } else if ( tag==='/i' ) { + this.crcs.setItalic( false ); + } else if ( tag==='stroked' ) { + this.crcs.setStroked( true ); + } else if ( tag==='/stroked' ) { + this.crcs.setStroked( false ); + } else if ( tag==='filled' ) { + this.crcs.setFilled( true ); + } else if ( tag==='/filled' ) { + this.crcs.setFilled( false ); + } else if ( tag==='tab' ) { + this.x= this.crcs.getTabPos( this.x ); + } else if ( tag==='br' ) { + this.__nextLine(); + } else if ( tag==='/a' ) { + this.__popAnchor(); + } else if ( tag==='/style' ) { + if ( this.rcs.length>1 ) { + this.__popStyle(); + } else { + /** + * underflow pop de estilos. eres un cachondo. + */ + } + } else { + if ( tag.indexOf("fillcolor")===0 ) { + pairs= tag.split("="); + this.crcs.setFillStyle( pairs[1] ); + } else if ( tag.indexOf("strokecolor")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeStyle( pairs[1] ); + } else if ( tag.indexOf("strokesize")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeSize( pairs[1]|0 ); + } else if ( tag.indexOf("fontsize")===0 ) { + pairs= tag.split("="); + this.crcs.setFontSize( pairs[1]|0 ); + } else if ( tag.indexOf("style")===0 ) { + pairs= tag.split("="); + style= this.styles[ pairs[1] ]; + if ( style ) { + this.__pushStyle( style ); + } + } else if ( tag.indexOf("image")===0) { + pairs= tag.split("=")[1].split(","); + var image= pairs[0]; + if ( this.images[image] ) { + var r= 0, c=0; + if ( pairs.length>=3 ) { + r= pairs[1]|0; + c= pairs[2]|0; + } + this.__image( this.images[image], r, c ); + } else if (CAAT.currentDirector.getImage(image) ) { + this.__image( CAAT.currentDirector.getImage(image) ); + } + } else if ( tag.indexOf("a=")===0 ) { + pairs= tag.split("="); + this.__pushAnchor( pairs[1] ); + } + } + } + }; + + /** + * Abstract document element. + * The document contains a collection of DocumentElementText and DocumentElementImage. + * @param anchor + * @param style + */ + var DocumentElement= function( anchor, style ) { + this.link= anchor; + this.style= style; + return this; + }; + + DocumentElement.prototype= { + x : null, + y : null, + width : null, + height : null, + + style : null, + + link : null, + + isLink : function() { + return this.link; + }, + + setLink : function( link ) { + this.link= link; + return this; + }, + + getLink : function() { + return this.link; + }, + + contains : function(x,y) { + return false; + } + + }; + + /** + * This class represents an image in the document. + * @param x + * @param image + * @param r + * @param c + * @param style + * @param anchor + */ + var DocumentElementImage= function( x, image, r, c, style, anchor ) { + + DocumentElementImage.superclass.constructor.call(this, anchor, style); + + this.x= x; + this.image= image; + this.row= r; + this.column= c; + this.width= image.getWidth(); + this.height= image.getHeight(); + + if ( this.image instanceof CAAT.SpriteImage || this.image instanceof CAAT.Foundation.SpriteImage ) { + + if ( typeof r==="undefined" || typeof c==="undefined" ) { + this.spriteIndex= 0; + } else { + this.spriteIndex= r*image.columns+c; + } + this.paint= this.paintSI; + } + + return this; + }; + + DocumentElementImage.prototype= { + image : null, + row : null, + column : null, + spriteIndex : null, + + paint : function( ctx ) { + this.style.image( ctx ); + ctx.drawImage( this.image, this.x, -this.height+1); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + paintSI : function( ctx ) { + this.style.image( ctx ); + this.image.setSpriteIndex( this.spriteIndex ); + this.image.paint( { ctx: ctx }, 0, this.x, -this.height+1 ); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + getHeight : function() { + return this.image instanceof CAAT.Foundation.SpriteImage ? this.image.getHeight() : this.image.height; + }, + + getFontMetrics : function() { + return null; + }, + + contains : function(x,y) { + return x>=this.x && x<=this.x+this.width && y>=this.y && y= this.x && x<=this.x+this.width && + y>= this.y && y<= this.y+this.height; + }, + + setYPosition : function( baseline ) { + this.bl= baseline; + this.y= baseline - this.fm.ascent; + } + }; + + extend( DocumentElementImage, DocumentElement ); + extend( DocumentElementText, DocumentElement ); + + /** + * This class represents a document line. + * It contains a collection of DocumentElement objects. + */ + var DocumentLine= function( defaultFontMetrics ) { + this.elements= []; + this.defaultFontMetrics= defaultFontMetrics; + return this; + }; + + DocumentLine.prototype= { + elements : null, + width : 0, + height : 0, + defaultHeight : 0, // default line height in case it is empty. + y : 0, + x : 0, + alignment : null, + + baselinePos : 0, + + addElement : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + this.alignment= element.style.__getProperty("alignment"); + }, + + addElementImage : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + }, + + getHeight : function() { + return this.height; + }, + + setY : function( y ) { + this.y= y; + }, + + getY : function() { + return this.y; + }, + + paint : function( ctx ) { + ctx.save(); + ctx.translate(this.x,this.y + this.baselinePos ); + + for( var i=0; i= JUSTIFY_RATIO && this.elements.length>1 ) { + var remaining= width - this.width; + + var forEachElement= (remaining/(this.elements.length-1))|0; + for( j=1; j biggestFont.ascent ) { + biggestFont= fm; + } + } + } else { // no FontMetrics, it is an image. + if (!biggestImage) { + biggestImage= elem; + } else { + if ( elem.getHeight() > elem.getHeight() ) { + biggestImage= elem; + } + } + } + } + + this.baselinePos= Math.max( + biggestFont ? biggestFont.ascent : this.defaultFontMetrics.ascent, + biggestImage ? biggestImage.getHeight() : this.defaultFontMetrics.ascent ); + this.height= this.baselinePos + (biggestFont!=null ? biggestFont.descent : this.defaultFontMetrics.descent ); + + for( i=0; i' and see whether it matches a tag + tag_closes_at_pos= text.indexOf('>', i+1); + if ( -1!==tag_closes_at_pos ) { + tag= text.substr( i+1, tag_closes_at_pos-i-1 ); + if ( tag.indexOf("<")!==-1 ) { + this.rc.fchar( _char ); + i+=1; + } else { + this.rc.setTag( tag ); + i= tag_closes_at_pos+1; + } + } + } else { + this.rc.fchar( _char ); + i+= 1; + } + } + + this.rc.end(); + this.lines= this.rc.lines; + + this.__calculateDocumentDimension( typeof width==="undefined" ? 0 : width ); + this.setLinesAlignment(); + + ctx.restore(); + + this.setPreferredSize( this.documentWidth, this.documentHeight ); + this.invalidateLayout(); + + this.setDocumentPosition(); + + if ( cached ) { + this.cacheAsBitmap(0,cached); + } + + if ( this.matchTextSize ) { + this.width= this.preferredSize.width; + this.height= this.preferredSize.height; + } + + return this; + }, + + setVerticalAlignment : function( align ) { + this.valignment= align; + this.setDocumentPosition(); + return this; + }, + + setHorizontalAlignment : function( align ) { + this.halignment= align; + this.setDocumentPosition(); + return this; + }, + + setDocumentPosition : function( halign, valign ) { + + if ( typeof halign!=="undefined" ) { + this.setHorizontalAlignment(halign); + } + if ( typeof valign!=="undefined" ) { + this.setVerticalAlignment(valign); + } + + var xo=0, yo=0; + + if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + yo= (this.height - this.documentHeight )/2; + } else if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM ) { + yo= this.height - this.documentHeight; + } + + if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + xo= (this.width - this.documentWidth )/2; + } else if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT ) { + xo= this.width - this.documentWidth; + } + + this.documentX= xo; + this.documentY= yo; + }, + + __calculateDocumentDimension : function( suggestedWidth ) { + var i; + var y= 0; + + this.documentWidth= 0; + this.documentHeight= 0; + for( i=0; i=x && line.y+line.height>=y ) { + return line.__getElementAt( x - line.x, y - line.y ); + } + } + + return null; + }, + + mouseExit : function(e) { + CAAT.setCursor( "default"); + }, + + mouseMove : function(e) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem && elem.getLink() ) { + CAAT.setCursor( "pointer"); + } else { + CAAT.setCursor( "default"); + } + }, + + mouseClick : function(e) { + if ( this.clickCallback ) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem.getLink() ) { + this.clickCallback( elem.getLink() ); + } + } + }, + + setClickCallback : function( callback ) { + this.clickCallback= callback; + return this; + } + } + + } + +}); +/** + * See LICENSE file. + * + * An actor to show the path and its handles in the scene graph. + * + **/ +CAAT.Module( { + + /** + * @name PathActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.PathActor", + aliases : ["CAAT.PathActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.PathActor.prototype + */ + + /** + * Path to draw. + * @type {CAAT.PathUtil.Path} + */ + path : null, + + /** + * Calculated path´s bounding box. + */ + pathBoundingRectangle : null, + + /** + * draw the bounding rectangle too ? + */ + bOutline : false, + + /** + * Outline the path in this color. + */ + outlineColor : 'black', + + /** + * If the path is interactive, some handlers are shown to modify the path. + * This callback function will be called when the path is interactively changed. + */ + onUpdateCallback : null, + + /** + * Set this path as interactive. + */ + interactive : false, + + /** + * Return the contained path. + * @return {CAAT.Path} + */ + getPath : function() { + return this.path; + }, + + /** + * Sets the path to manage. + * @param path {CAAT.PathUtil.PathSegment} + * @return this + */ + setPath : function(path) { + this.path= path; + if ( path!=null ) { + this.pathBoundingRectangle= path.getBoundingBox(); + this.setInteractive( this.interactive ); + } + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Foundation.Director} + * @param time {number}. Scene time. + */ + paint : function(director, time) { + + CAAT.Foundation.UI.PathActor.superclass.paint.call( this, director, time ); + + if ( !this.path ) { + return; + } + + var ctx= director.ctx; + + ctx.strokeStyle='#000'; + this.path.paint(director, this.interactive); + + if ( this.bOutline ) { + ctx.strokeStyle= this.outlineColor; + ctx.strokeRect( + this.pathBoundingRectangle.x, + this.pathBoundingRectangle.y, + this.pathBoundingRectangle.width, + this.pathBoundingRectangle.height + ); + } + }, + /** + * Enables/disables drawing of the contained path's bounding box. + * @param show {boolean} whether to show the bounding box + * @param color {=string} optional parameter defining the path's bounding box stroke style. + */ + showBoundingBox : function(show, color) { + this.bOutline= show; + if ( show && color ) { + this.outlineColor= color; + } + return this; + }, + /** + * Set the contained path as interactive. This means it can be changed on the fly by manipulation + * of its control points. + * @param interactive + */ + setInteractive : function(interactive) { + this.interactive= interactive; + if ( this.path ) { + this.path.setInteractive(interactive); + } + return this; + }, + setOnUpdateCallback : function( fn ) { + this.onUpdateCallback= fn; + return this; + }, + /** + * Route mouse dragging functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDrag : function(mouseEvent) { + this.path.drag(mouseEvent.point.x, mouseEvent.point.y, this.onUpdateCallback); + }, + /** + * Route mouse down functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDown : function(mouseEvent) { + this.path.press(mouseEvent.point.x, mouseEvent.point.y); + }, + /** + * Route mouse up functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseUp : function(mouseEvent) { + this.path.release(); + } + } +}); +CAAT.Module({ + + /** + * @name ShapeActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.ShapeActor", + aliases : ["CAAT.ShapeActor"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor + */ + + /** @const */ SHAPE_CIRCLE: 0, // Constants to describe different shapes. + /** @const */ SHAPE_RECTANGLE:1 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + + /** + * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default, + * so if no explicit call to setShape was made, nothing would be drawn. + */ + this.setShape( CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ); + return this; + }, + + /** + * Define this actor shape: rectangle or circle + */ + shape: 0, // shape type. One of the constant SHAPE_* values + + /** + * Set this shape composite operation when drawing it. + */ + compositeOp: null, // a valid canvas rendering context string describing compositeOps. + + /** + * Stroke the shape with this line width. + */ + lineWidth: 1, + + /** + * Stroke the shape with this line cap. + */ + lineCap: null, + + /** + * Stroke the shape with this line Join. + */ + lineJoin: null, + + /** + * Stroke the shape with this line mitter limit. + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets shape type. + * No check for parameter validity is performed. + * Set paint method according to the shape. + * @param iShape an integer with any of the SHAPE_* constants. + * @return this + */ + setShape : function(iShape) { + this.shape= iShape; + this.paint= this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ? + this.paintCircle : + this.paintRectangle; + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * Draws the shape. + * Applies the values of fillStype, strokeStyle, compositeOp, etc. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director,time) { + }, + /** + * @private + * Draws a circle. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintCircle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.stroke(); + } + }, + /** + * + * Private + * Draws a Rectangle. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintRectangle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.fillRect(0,0,this.width,this.height); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.strokeRect(0,0,this.width,this.height); + ctx.stroke(); + } + } + } + +}); +CAAT.Module( { + + /** + * @name StarActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.StarActor", + aliases : ["CAAT.StarActor"], + depends : [ + "CAAT.Foundation.ActorContainer" + ], + extendsClass : "CAAT.Foundation.ActorContainer", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.StarActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + return this; + }, + + /** + * Number of star peaks. + */ + nPeaks: 0, + + /** + * Maximum radius. + */ + maxRadius: 0, + + /** + * Minimum radius. + */ + minRadius: 0, + + /** + * Staring angle in radians. + */ + initialAngle: 0, + + /** + * Draw the star with this composite operation. + */ + compositeOp: null, + + /** + * + */ + lineWidth: 1, + + /** + * + */ + lineCap: null, + + /** + * + */ + lineJoin: null, + + /** + * + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets whether the star will be color filled. + * @param filled {boolean} + * @deprecated + */ + setFilled : function( filled ) { + return this; + }, + /** + * Sets whether the star will be outlined. + * @param outlined {boolean} + * @deprecated + */ + setOutlined : function( outlined ) { + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * + * @param angle {number} number in radians. + */ + setInitialAngle : function(angle) { + this.initialAngle= angle; + return this; + }, + /** + * Initialize the star values. + *

    + * The star actor will be of size 2*maxRadius. + * + * @param nPeaks {number} number of star points. + * @param maxRadius {number} maximum star radius + * @param minRadius {number} minimum star radius + * + * @return this + */ + initialize : function(nPeaks, maxRadius, minRadius) { + this.setSize( 2*maxRadius, 2*maxRadius ); + + this.nPeaks= nPeaks; + this.maxRadius= maxRadius; + this.minRadius= minRadius; + + return this; + }, + /** + * Paint the star. + * + * @param director {CAAT.Director} + * @param timer {number} + */ + paint : function(director, timer) { + + var ctx= director.ctx; + var centerX= this.width/2; + var centerY= this.height/2; + var r1= this.maxRadius; + var r2= this.minRadius; + var ix= centerX + r1*Math.cos(this.initialAngle); + var iy= centerY + r1*Math.sin(this.initialAngle); + + ctx.lineWidth= this.lineWidth; + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + + ctx.beginPath(); + ctx.moveTo(ix,iy); + + for( var i=1; i>0; + this.fontData= { + height : this.font.singleHeight, + ascent : as, + descent: this.font.singleHeight - as + }; +*/ + return this; + } + + if ( this.font instanceof CAAT.Module.Font.Font ) { + this.textWidth= this.font.stringWidth( this.text ); + this.textHeight=this.font.stringHeight(); + this.width= this.textWidth; + this.height= this.textHeight; + this.fontData= this.font.getFontData(); + return this; + } + + var ctx= director.ctx; + + ctx.save(); + ctx.font= this.font; + + this.textWidth= ctx.measureText( this.text ).width; + if (this.width===0) { + this.width= this.textWidth; + } +/* + var pos= this.font.indexOf("px"); + if (-1===pos) { + pos= this.font.indexOf("pt"); + } + if ( -1===pos ) { + // no pt or px, so guess a size: 32. why not ? + this.textHeight= 32; + } else { + var s = this.font.substring(0, pos ); + this.textHeight= parseInt(s,10); + } +*/ + + this.textHeight= this.fontData.height; + this.setSize( this.textWidth, this.textHeight ); + + ctx.restore(); + + return this; + }, + + __calcFontData : function() { + this.fontData= CAAT.Module.Font.Font.getFontMetrics( this.font ); + }, + + /** + * Custom paint method for TextActor instances. + * If the path attribute is set, the text will be drawn traversing the path. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director, time) { + + if (!this.text) { + return; + } + + CAAT.Foundation.UI.TextActor.superclass.paint.call(this, director, time ); + + if ( this.cached ) { + // cacheAsBitmap sets this actor's background image as a representation of itself. + // So if after drawing the background it was cached, we're done. + return; + } + + if ( null===this.text) { + return; + } + + if ( this.textWidth===0 || this.textHeight===0 ) { + this.calcTextSize(director); + } + + var ctx= director.ctx; + + if ( this.font instanceof CAAT.Module.Font.Font || this.font instanceof CAAT.Foundation.SpriteImage ) { + this.drawSpriteText(director,time); + return; + } + + if( null!==this.font ) { + ctx.font= this.font; + } + + /** + * always draw text with middle or bottom, top is buggy in FF. + * @type {String} + */ + ctx.textBaseline="alphabetic"; + + if (null===this.path) { + + if ( null!==this.textAlign ) { + ctx.textAlign= this.textAlign; + } + + var tx=0; + if ( this.textAlign==='center') { + tx= (this.width/2)|0; + } else if ( this.textAlign==='right' ) { + tx= this.width; + } + + if ( this.fill ) { + if ( null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + ctx.fillText( this.text, tx, this.fontData.ascent ); + } + + if ( this.outline ) { + if (null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + ctx.lineWidth= this.lineWidth; + ctx.beginPath(); + ctx.strokeText( this.text, tx, this.fontData.ascent ); + } + } + else { + this.drawOnPath(director,time); + } + }, + /** + * Private. + * Draw the text traversing a path. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawOnPath : function(director, time) { + + var ctx= director.ctx; + + if ( this.fill && null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + + if ( this.outline && null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i>0, p0.y>>0 ); + } else { + ctx.translate( p0.x, p0.y ); + } + ctx.rotate( angle ); + if ( this.fill ) { + ctx.fillText(caracter,0,0); + } + if ( this.outline ) { + ctx.beginPath(); + ctx.lineWidth= this.lineWidth; + ctx.strokeText(caracter,0,0); + } + + ctx.restore(); + + textWidth+= charWidth; + } + }, + + /** + * Private. + * Draw the text using a sprited font instead of a canvas font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteText: function(director, time) { + if (null===this.path) { + this.font.drawText( this.text, director.ctx, 0, 0); + } else { + this.drawSpriteTextOnPath(director, time); + } + }, + + /** + * Private. + * Draw the text traversing a path using a sprited font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteTextOnPath: function(director, time) { + var context= director.ctx; + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i NOT solved."))},removeDependency:function(a){for(var b=0;b Can't extend non-existant class: "+this.baseClass);return}}else b=f;b.extend(this.extendWith,this.constants,this.name,this.aliases,{decorated:this.decorated});console.log("Created module: "+this.name);this.callback&&this.callback()}};var h=function(a,b){this.path=a;this.module=b;return this};h.prototype={path:null,processed:false,module:null,setProcessed:function(){this.processed=true},isProcessed:function(){return this.processed}};var i=function(){this.nodes=[];this.loadedFiles=[]; +this.path={};this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};i.baseURL="";i.modulePath={};i.sortedModulePath=[];i.symbol={};i.prototype={nodes:null,loadedFiles:null,solveListener:null,readyListener:null,orderedSolvedModules:null,addSolvedListener:function(a,b){this.solveListener.push({name:a,callback:b})},solved:function(a){var b;for(b=0;b catched "+ +d+" on module "+a.defines+" preCreation.")}if(!a.depends)a.depends=[];if((b=a.depends)&&!isArray(b))b=[b],a.depends=b;for(c=0;c=0&&b>0,b[5]>>0);return this},transformRenderingContext_Clamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2]>>0,b[5]>>0);return this},setModelViewMatrix:function(a,b,c,d,e){var f,g,h,i,j,k;k= +this.matrix;d=1;j=g=0;i=1;c=Math.cos(e);e=Math.sin(e);f=d;h=j;d=f*c+g*e;g=-f*e+g*c;j=h*c+i*e;i=-h*e+i*c;d*=this.scaleX;g*=this.scaleY;j*=this.scaleX;i*=this.scaleY;k[0]=d;k[1]=g;k[2]=a;k[3]=j;k[4]=i;k[5]=b}}}}); +CAAT.Module({defines:"CAAT.Math.Matrix3",aliases:["CAAT.Matrix3"],extendsWith:function(){return{matrix:null,fmatrix:null,__init:function(){this.matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];this.fmatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return this},transformCoord:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.matrix[0][0]+c*this.matrix[0][1]+d*this.matrix[0][2]+this.matrix[0][3];a.y=b*this.matrix[1][0]+c*this.matrix[1][1]+d*this.matrix[1][2]+this.matrix[1][3];a.z=b*this.matrix[2][0]+c*this.matrix[2][1]+ +d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,i){this.identity();this.matrix[0][0]=a;this.matrix[0][1]=b;this.matrix[0][2]=c;this.matrix[1][0]=d;this.matrix[1][1]=e;this.matrix[1][2]=f;this.matrix[2][0]=g;this.matrix[2][1]=h;this.matrix[2][2]=i;return this},initWithMatrix:function(a){this.matrix=a;return this},flatten:function(){var a=this.fmatrix,b=this.matrix;a[0]=b[0][0];a[1]=b[1][0];a[2]=b[2][0];a[3]=b[3][0];a[4]=b[0][1];a[5]=b[1][1];a[6]=b[2][1];a[7]=b[2][1]; +a[8]=b[0][2];a[9]=b[1][2];a[10]=b[2][2];a[11]=b[3][2];a[12]=b[0][3];a[13]=b[1][3];a[14]=b[2][3];a[15]=b[3][3];return this.fmatrix},identity:function(){for(var a=0;a<4;a++)for(var b=0;b<4;b++)this.matrix[a][b]=a===b?1:0;return this},getMatrix:function(){return this.matrix},rotateXY:function(a){return this.rotate(a,0,0)},rotateXZ:function(a){return this.rotate(0,a,0)},rotateYZ:function(a){return this.rotate(0,0,a)},setRotate:function(a,b,c){this.copy(this.rotate(a,b,c));return this},rotate:function(a, +b,c){var d=new CAAT.Math.Matrix3,e,f;a!==0&&(f=new CAAT.Math.Math.Matrix3,e=Math.sin(a),a=Math.cos(a),f.matrix[1][1]=a,f.matrix[1][2]=-e,f.matrix[2][1]=e,f.matrix[2][2]=a,d.multiply(f));b!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(b),a=Math.cos(b),f.matrix[0][0]=a,f.matrix[0][2]=-e,f.matrix[2][0]=e,f.matrix[2][2]=a,d.multiply(f));c!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(c),a=Math.cos(c),f.matrix[0][0]=a,f.matrix[0][1]=-e,f.matrix[1][0]=e,f.matrix[1][1]=a,d.multiply(f));return d},getClone:function(){var a= +new CAAT.Math.Matrix3;a.copy(this);return a},multiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1],q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],z=n[2][3],A=n[3][0],B=n[3][1],C=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*v+f*A;this.matrix[0][1]=c*p+d*t+e*x+f*B;this.matrix[0][2]=c*q+d*s+e*y+f*C;this.matrix[0][3]= +c*r+d*w+e*z+f*n;this.matrix[1][0]=g*a+h*u+i*v+j*A;this.matrix[1][1]=g*p+h*t+i*x+j*B;this.matrix[1][2]=g*q+h*s+i*y+j*C;this.matrix[1][3]=g*r+h*w+i*z+j*n;this.matrix[2][0]=k*a+m*u+o*v+b*A;this.matrix[2][1]=k*p+m*t+o*x+b*B;this.matrix[2][2]=k*q+m*s+o*y+b*C;this.matrix[2][3]=k*r+m*w+o*z+b*n;return this},premultiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1], +q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*v;this.matrix[0][1]=c*p+d*t+e*x;this.matrix[0][2]=c*q+d*s+e*y;this.matrix[0][3]=c*r+d*w+e*n+f;this.matrix[1][0]=g*a+h*u+i*v;this.matrix[1][1]=g*p+h*t+i*x;this.matrix[1][2]=g*q+h*s+i*y;this.matrix[1][3]=g*r+h*w+i*n+j;this.matrix[2][0]=k*a+m*u+o*v;this.matrix[2][1]=k*p+m*t+o*x;this.matrix[2][2]=k*q+m*s+o*y;this.matrix[2][3]=k*r+m*w+o*n+b;return this},setTranslate:function(a, +b,c){this.identity();this.matrix[0][3]=a;this.matrix[1][3]=b;this.matrix[2][3]=c;return this},translate:function(a,b,c){var d=new CAAT.Math.Matrix3;d.setTranslate(a,b,c);return d},setScale:function(a,b,c){this.identity();this.matrix[0][0]=a;this.matrix[1][1]=b;this.matrix[2][2]=c;return this},scale:function(a,b,c){var d=new CAAT.Math.Matrix3;d.setScale(a,b,c);return d},rotateModelView:function(a,b,c){var d=Math.sin(a),e=Math.sin(b),f=Math.sin(c),a=Math.cos(a),b=Math.cos(b),c=Math.cos(c);this.matrix[0][0]= +b*a;this.matrix[0][1]=-b*d;this.matrix[0][2]=e;this.matrix[0][3]=0;this.matrix[1][0]=f*e*a+d*c;this.matrix[1][1]=c*a-f*e*d;this.matrix[1][2]=-f*b;this.matrix[1][3]=0;this.matrix[2][0]=f*d-c*e*a;this.matrix[2][1]=c*e*d+f*a;this.matrix[2][2]=c*b;this.matrix[2][3]=0;this.matrix[3][0]=0;this.matrix[3][1]=0;this.matrix[3][2]=0;this.matrix[3][3]=1;return this},copy:function(a){for(var b=0;b<4;b++)for(var c=0;c<4;c++)this.matrix[b][c]=a.matrix[b][c];return this},calculateDeterminant:function(){var a=this.matrix, +b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],o=a[2][3],n=a[3][0],p=a[3][1],q=a[3][2],a=a[3][3];return e*g*m*n+c*i*m*n+e*h*j*p+d*i*j*p+d*f*o*p+b*h*o*p+e*f*k*q+b*i*k*q+d*g*j*a+c*h*j*a+c*f*m*a+b*g*m*a+e*h*k*n-d*i*k*n-d*g*o*n-c*h*o*n-e*f*m*p-b*i*m*p-e*g*j*q-c*i*j*q-c*f*o*q-b*g*o*q-d*f*k*a-b*h*k*a},getInverse:function(){var a=this.matrix,b=a[0][0],c=a[0][1],d=a[0][2],e=a[0][3],f=a[1][0],g=a[1][1],h=a[1][2],i=a[1][3],j=a[2][0],k=a[2][1],m= +a[2][2],o=a[2][3],n=a[3][0],p=a[3][1],q=a[3][2],a=a[3][3],r=new CAAT.Math.Matrix3;r.matrix[0][0]=h*o*p+i*k*q+g*m*a-i*m*p-g*o*q-h*k*a;r.matrix[0][1]=e*m*p+c*o*q+d*k*a-c*m*a-d*o*p-e*k*q;r.matrix[0][2]=d*i*p+c*h*a+e*g*q-c*i*q-d*g*a-e*h*p;r.matrix[0][3]=e*h*k+c*i*m+d*g*o-d*i*k-e*g*m-c*h*o;r.matrix[1][0]=i*m*n+f*o*q+h*j*a-h*o*n-i*j*q-f*m*a;r.matrix[1][1]=d*o*n+e*j*q+b*m*a-e*m*n-b*o*q-d*j*a;r.matrix[1][2]=e*h*n+b*i*q+d*f*a-d*i*n-e*f*q-b*h*a;r.matrix[1][3]=d*i*j+e*f*m+b*h*o-e*h*j-b*i*m-d*f*o;r.matrix[2][0]= +g*o*n+i*j*p+f*k*a-i*k*n-f*o*p-g*j*a;r.matrix[2][1]=e*k*n+b*o*p+c*j*a-b*k*a-c*o*n-e*j*p;r.matrix[2][2]=d*i*n+e*f*p+b*g*a-e*g*n-b*i*p-c*f*a;r.matrix[2][3]=e*g*j+b*i*k+c*f*o-b*g*o-c*i*j-e*f*k;r.matrix[3][0]=h*k*n+f*m*p+g*j*q-g*m*n-h*j*p-f*k*q;r.matrix[3][1]=c*m*n+d*j*p+b*k*q-d*k*n-b*m*p-c*j*q;r.matrix[3][2]=d*g*n+b*h*p+c*f*q-b*g*q-c*h*n-d*f*p;r.matrix[3][3]=c*h*j+d*f*k+b*g*m-d*g*j-b*h*k-c*f*m;return r.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;b<4;b++)for(c= +0;c<4;c++)this.matrix[b][c]*=a;return this}}}}); +CAAT.Module({defines:"CAAT.Math.Point",aliases:["CAAT.Point"],extendsWith:function(){return{x:0,y:0,z:0,__init:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},set:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},clone:function(){return new CAAT.Math.Point(this.x,this.y,this.z)},translate:function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this},translatePoint:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},subtract:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z; +return this},multiply:function(a){this.x*=a;this.y*=a;this.z*=a;return this},rotate:function(a){var b=this.x,c=this.y;this.x=b*Math.cos(a)-Math.sin(a)*c;this.y=b*Math.sin(a)+Math.cos(a)*c;this.z=0;return this},setAngle:function(a){var b=this.getLength();this.x=Math.cos(a)*b;this.y=Math.sin(a)*b;this.z=0;return this},setLength:function(a){var b=this.getLength();b?this.multiply(a/b):this.x=this.y=this.z=a;return this},normalize:function(){var a=this.getLength();this.x/=a;this.y/=a;this.z/=a;return this}, +getAngle:function(){return Math.atan2(this.y,this.x)},limit:function(a){var b=this.getLengthSquared();if(b+0.01>a*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b* +b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Math.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}}}); +CAAT.Module({defines:"CAAT.Math.Rectangle",aliases:["CAAT.Rectangle"],extendsWith:function(){return{__init:function(a,b,c,d){arguments.length!==4?this.setEmpty():(this.setLocation(a,b),this.setDimension(c,d))},x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b; +this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d);return this},contains:function(a,b){return a>=this.x&&a=this.y&&bthis.y1)this.y1= +b;if(a>this.x1)this.x1=a;this.width=this.x1-this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1,a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1<=this.x?false:a.x>=this.x1?false:a.y1<=this.y?false:a.ythis.x1?false:b+d-1=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!== +e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e=0,f=this.lifecycleListenerList.length;e>=0;for(var d= +"@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}}}}); +CAAT.Module({defines:"CAAT.Behavior.ContainerBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Behavior.GenericBehavior"],aliases:["CAAT.ContainerBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{parse:function(a){if(a.behaviors&&a.behaviors.length)for(var b=0;b=d)){d=(d-c.behaviorStartTime)/c.behaviorDuration; +c=c.getKeyFrameDataValues(d);for(var f in c)e[f]=c[f]}return e},calculateKeyFrameData:function(a,b){function c(a){if(f[a])h+=f[a];else if(prevValues&&(i=prevValues[a]))h+=i,f[a]=i}var d,e,f={},g;for(d=0;d=g&&(g=(g-e.behaviorStartTime)/e.behaviorDuration,g=e.calculateKeyFrameData(g), +e=e.getPropertyName(b),typeof f[e]==="undefined"&&(f[e]=""),f[e]+=g+" "));var h="",i;c("translate");c("rotate");c("scale");d="";h&&(d="-"+b+"-transform: "+h+";");h="";c("opacity");h&&(d+=" opacity: "+h+";");d+=" -webkit-transform-origin: 0% 0%";return{rules:d,ret:f}},calculateKeyFramesData:function(a,b,c,d,e){if(this.duration===Number.MAX_VALUE)return"";typeof d==="undefined"&&(d=0.5);typeof e==="undefined"&&(e=0.5);typeof c==="undefined"&&(c=100);for(var f="@-"+a+"-keyframes "+b+" {",g,h={},b=0;b<= +c;b++){g=this.interpolator.getPosition(b/c).y;g=this.getKeyFrameDataValues(g);var i=""+b/c*100+"%{",j=g,k=void 0;for(k in h)j[k]||(j[k]=h[k]);h="-"+a+"-transform:";if(j.x||j.y)h+="translate("+(j.x||0)+"px,"+(j.y||0)+"px)";j.angle&&(h+=" rotate("+j.angle+"rad)");if(j.scaleX!==1||j.scaleY!==1)h+=" scale("+j.scaleX+","+j.scaleY+")";h+=";";j.alpha&&(h+=" opacity: "+j.alpha+";");if(d!==0.5||e!==0.5)h+=" -"+a+"-transform-origin:"+d*100+"% "+e*100+"%;";f+=i+h+"}\n";h=g}f+="}\n";return f}}}}); +CAAT.Module({defines:"CAAT.Behavior.GenericBehavior",depends:["CAAT.Behavior.BaseBehavior"],aliases:["CAAT.GenericBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{start:0,end:0,target:null,property:null,callback:null,setForTime:function(a,b){var c=this.start+a*(this.end-this.start);this.callback&&this.callback(c,this.target,b);this.property&&(this.target[this.property]=c)},setValues:function(a,b,c,d,e){this.start=a;this.end=b;this.target=c;this.property=d;this.callback= +e;return this}}}}); +CAAT.Module({defines:"CAAT.Behavior.PathBehavior",aliases:["CAAT.PathBehavior"],depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.SpriteImage"],constants:{AUTOROTATE:{LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2},autorotate:{LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1,FREE:2}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{parse:function(a){CAAT.Behavior.PathBehavior.superclass.parse.call(this,a);a.SVG&&this.setValues((new CAAT.PathUtil.SVGPath).parsePath(a.SVG));if(a.autoRotate)this.autoRotate=a.autoRotate}, +path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,isOpenContour:false,relativeX:0,relativeY:0,setOpenContour:function(a){this.isOpenContour=a;return this},getPropertyName:function(){return"translate"},setRelativeValues:function(a,b){this.relativeX=a;this.relativeY=b;this.isRelative=true;return this},setAutoRotate:function(a,b){this.autoRotate=a;if(b!==void 0)this.autoRotateOp=b;return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(){return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.path.getPosition(a);return"translateX("+a.x+"px) translateY("+a.y+"px)"},getKeyFrameDataValues:function(a){var a=this.interpolator.getPosition(a).y,b=this.path.getPosition(a),c={x:b.x,y:b.y};if(this.autoRotate)a=a===0?b:this.path.getPosition(a-0.0010),b=Math.atan2(b.y-a.y,b.x-a.x),c.angle=b;return c},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d, +e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;e+="}";return e},setForTime:function(a,b){if(!this.path)return{x:b.x,y:b.y};var c=this.path.getPosition(a,this.isOpenContour,0.0010);this.isRelative&&(c.x+=this.relativeX,c.y+=this.relativeY);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f= +Math.atan2(e,d),g=CAAT.Foundation.SpriteImage,h=CAAT.Behavior.PathBehavior.AUTOROTATE;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL),f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x, +c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}}}}); +CAAT.Module({defines:"CAAT.Behavior.RotateBehavior",extendsClass:"CAAT.Behavior.BaseBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.RotateBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},parse:function(a){CAAT.Behavior.RotateBehavior.superclass.parse.call(this,a);this.startAngle=a.start||0;this.endAngle=a.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX): +0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5},startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,rotationRelative:0,setRelativeValues:function(a){this.rotationRelative=a;this.isRelative=true;return this},getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);this.isRelative&&(c+=this.rotationRelative,c>=Math.PI&&(c-=2*Math.PI),c<-2*Math.PI&&(c+=2*Math.PI));this.doValueApplication&&b.setRotationAnchored(c, +this.anchorX,this.anchorY);return c},setValues:function(a,b,c,d){this.startAngle=a;this.endAngle=b;if(typeof c!=="undefined"&&typeof d!=="undefined")this.anchorX=c,this.anchorY=d;return this},setAngles:function(a,b){return this.setValues(a,b)},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"rotate("+(this.startAngle+a*(this.endAngle-this.startAngle))+"rad)"},getKeyFrameDataValues:function(a){a= +this.interpolator.getPosition(a).y;return{angle:this.startAngle+a*(this.endAngle-this.startAngle)}},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX*100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Behavior.Scale1Behavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.Scale1Behavior"],constants:{AXIS:{X:0,Y:1},Axis:{X:0,Y:1}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startScale:1,endScale:1,anchorX:0.5,anchorY:0.5,applyOnX:true,parse:function(a){CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,a);this.startScale= +a.start||0;this.endScale=a.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX):0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5;this.applyOnX=a.axis?a.axis.toLowerCase()==="x":true},applyOnAxis:function(a){this.applyOnX=a===CAAT.Behavior.Scale1Behavior.AXIS.X?false:true},getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScale+a*(this.endScale-this.startScale);0===c&&(c=0.01);this.doValueApplication&&(this.applyOnX?b.setScaleAnchored(c, +b.scaleY,this.anchorX,this.anchorY):b.setScaleAnchored(b.scaleX,c,this.anchorX,this.anchorY));return c},setValues:function(a,b,c,d,e){this.startScale=a;this.endScale=b;this.applyOnX=!!c;if(typeof d!=="undefined"&&typeof e!=="undefined")this.anchorX=d,this.anchorY=e;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;a=this.startScale+a*(this.endScale-this.startScale);return this.applyOnX? +"scaleX("+a+")":"scaleY("+a+")"},getKeyFrameDataValues:function(a){var a=this.interpolator.getPosition(a).y,b={};b[this.applyOnX?"scaleX":"scaleY"]=this.startScale+a*(this.endScale-this.startScale);return b},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX*100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Behavior.ScaleBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],extendsClass:"CAAT.Behavior.BaseBehavior",aliases:["CAAT.ScaleBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startScaleX:1,endScaleX:1,startScaleY:1,endScaleY:1,anchorX:0.5,anchorY:0.5,parse:function(a){CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,a);this.startScaleX=a.scaleX&&a.scaleX.start|| +0;this.endScaleX=a.scaleX&&a.scaleX.end||0;this.startScaleY=a.scaleY&&a.scaleY.start||0;this.endScaleY=a.scaleY&&a.scaleY.end||0;this.anchorX=typeof a.anchorX!=="undefined"?parseInt(a.anchorX):0.5;this.anchorY=typeof a.anchorY!=="undefined"?parseInt(a.anchorY):0.5},getPropertyName:function(){return"scale"},setForTime:function(a,b){var c=this.startScaleX+a*(this.endScaleX-this.startScaleX),d=this.startScaleY+a*(this.endScaleY-this.startScaleY);0===c&&(c=0.01);0===d&&(d=0.01);this.doValueApplication&& +b.setScaleAnchored(c,d,this.anchorX,this.anchorY);return{scaleX:c,scaleY:d}},setValues:function(a,b,c,d,e,f){this.startScaleX=a;this.endScaleX=b;this.startScaleY=c;this.endScaleY=d;if(typeof e!=="undefined"&&typeof f!=="undefined")this.anchorX=e,this.anchorY=f;return this},setAnchor:function(a,b,c){this.anchorX=b/a.width;this.anchorY=c/a.height;return this},calculateKeyFrameData:function(a){a=this.interpolator.getPosition(a).y;return"scale("+(this.startScaleX+a*(this.endScaleX-this.startScaleX))+ +","+(this.startScaleY+a*(this.endScaleY-this.startScaleY))+")"},getKeyFrameDataValues:function(a){a=this.interpolator.getPosition(a).y;return{scaleX:this.startScaleX+a*(this.endScaleX-this.startScaleX),scaleY:this.startScaleY+a*(this.endScaleY-this.startScaleY)}},calculateKeyFramesData:function(a,b,c){typeof c==="undefined"&&(c=100);c>>=0;for(var d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+this.anchorX* +100+"% "+this.anchorY*100+"% }\n",e+=d;e+="}\n";return e}}}}); +CAAT.Module({defines:"CAAT.Module.Runtime.BrowserInfo",constants:function(){function a(a){for(var b=0;b0?(a=this.channels.shift(),a.src=b.src,a.volume=b.volume,a.play(),this.workingChannels.push(a)):console.log("Can't play audio: "+a);return b},cancelPlay:function(a){for(var b=0;this.workingChannels.length;b++){var c=this.workingChannels[b];c.caat_id===a&&(c.pause(),this.channels.push(c),this.workingChannels.splice(b,1))}return this},cancelPlayByChannel:function(a){for(var b=0;this.workingChannels.length;b++)if(this.workingChannels[b]=== +a){this.channels.push(a);this.workingChannels.splice(b,1);break}return this},loop:function(a){if(!this.musicEnabled)return null;a=this.getAudio(a);if(null!==a){var b=document.createElement("audio");if(null!==b)return b.src=a.src,b.preload="auto",this.isFirefox?b.addEventListener("ended",function(a){a.target.currentTime=0},false):b.loop=true,b.load(),b.play(),this.loopingChannels.push(b),b}return null},endSound:function(){var a;for(a=0;a=g)return{r:d,g:e,b:f};a=a+(d-a)/g*h>>0;b=b+(e-b)/g*h>>0;c=c+(f-c)/g*h>>0;a>255?a=255:a<0&&(a=0);b>255?b=255:b<0&&(b=0);c>255?c=255:c<0&&(c=0);return{r:a,g:b,b:c}},makeRGBColorRamp:function(a,b,c){var d= +[],e=a.length-1;b/=e;var f,g,h,i,j,k,m,o,n,p,q,r,u,t;for(f=0;f>24&255;n=(m&16711680)>>16;p=(m&65280)>>8;m&=255;g=a[f+1];q=g>>24&255;r=(g&16711680)>>16;u=(g&65280)>>8;g&=255;q=(q-o)/b;r=(r-n)/b;u=(u-p)/b;t=(g-m)/b;for(g=0;g>0;i=n+r*g>>0;j=p+u*g>>0;k=m+t*g>>0;var s=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case s.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+k+")");break;case s.RAMP_RGB:d.push("rgb("+i+","+j+","+k+")");break;case s.RAMP_CHANNEL_RGB:d.push(4278190080| +i<<16|j<<8|k);break;case s.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|k);break;case s.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,k,h]);break;case s.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,k])}}}return d},random:function(){for(var a="#",b=0;b<3;b++)a+="0123456789abcdef"[Math.random()*16>>0];return a}},extendsWith:{__init:function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this},r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}}); +CAAT.Module({defines:"CAAT.Module.Debug.Debug",depends:["CAAT.Event.AnimationLoop"],extendsWith:{width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,textDiscardDR:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'

    CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
    RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0 Discard DR: 0
    Sound
    Music
    AA Bounding Boxes
    Bounding Boxes
    Dirty Rects
    ', +setScale:function(a){this.scale=a;return this},initialize:function(a,b){this.width=a=window.innerWidth;this.height=b;this.framerate={refreshInterval:CAAT.FPS_REFRESH||500,frames:0,timeLastRefresh:0,fps:0,prevFps:-1,fpsMin:1E3,fpsMax:0};if(!document.getElementById("caat-debug")){var c=document.createElement("div");c.innerHTML=this.debugTpl;document.body.appendChild(c);eval(' var __x= CAAT; function initCheck( name, bool, callback ) { var elem= document.getElementById(name); if ( elem ) { elem.className= (bool) ? "checkbox_enabled" : "checkbox_disabled"; if ( callback ) { elem.addEventListener( "click", (function(elem, callback) { return function(e) { elem.__value= !elem.__value; elem.className= (elem.__value) ? "checkbox_enabled" : "checkbox_disabled"; callback(e,elem.__value); } })(elem, callback), false ); } elem.__value= bool; } } function setupTabs() { var numTabs=0; var elem; var elemContent; do { elem= document.getElementById("caat-debug-tab"+numTabs); if ( elem ) { elemContent= document.getElementById("caat-debug-tab"+numTabs+"-content"); if ( elemContent ) { elemContent.style.display= numTabs===0 ? \'block\' : \'none\'; elem.className= numTabs===0 ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; elem.addEventListener( "click", (function(tabIndex) { return function(e) { for( var i=0; ithis.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps= +this.framerate.frames*1E3/(a-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this.framerate.fpsMin;this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps);this.textFPS.innerHTML=this.framerate.fps;var b=(this.frameTimeAcc*100/this.framerate.frames|0)/100;this.frameTimeAcc=0;this.textDrawTime.innerHTML=b;b=(this.frameRAFAcc*100/this.framerate.frames|0)/100;this.frameRAFAcc=0;this.textRAFTime.innerHTML= +b;this.framerate.timeLastRefresh=a;this.framerate.frames=0;this.paint(b)}this.textEntitiesTotal.innerHTML=this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws;this.textDiscardDR.innerHTML=this.statistics.size_discarded_by_dirty_rects},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle= +"black";b.beginPath();b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle= +"#0ff";b.beginPath();b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}}); +CAAT.Module({defines:"CAAT.Module.Font.Font",aliases:"CAAT.Font",depends:["CAAT.Foundation.SpriteImage"],constants:{getFontMetrics:function(a){var b;if(CAAT.CSS_TEXT_METRICS)try{return b=CAAT.Module.Font.Font.getFontMetricsCSS(a)}catch(c){}return CAAT.Module.Font.Font.getFontMetricsNoCSS(a)},getFontMetricsNoCSS:function(a){var a=/(\d+)p[x|t]\s*/i.exec(a),b;b=a?a[1]|0:32;a=b-1;b=b+b*0.2|0;return{height:b,ascent:a,descent:b-a}},getFontMetricsCSS:function(a){function b(a){var b,c,d;d=a&&a.ownerDocument; +b=d.documentElement;a=a.getBoundingClientRect();c=document.body;d=d.nodeType===9?d.defaultView||d.parentWindow:false;return{top:a.top+(d.pageYOffset||b.scrollTop)-(b.clientTop||c.clientTop||0),left:a.left+(d.pageXOffset||b.scrollLeft)-(b.clientLeft||c.clientLeft||0)}}try{var c=document.createElement("span");c.style.font=a;c.innerHTML="Hg";var d=document.createElement("div");d.style.display="inline-block";d.style.width="1px";d.style.heigh="0px";var e=document.createElement("div");e.appendChild(c); +e.appendChild(d);var f=document.body;f.appendChild(e);try{return a={},d.style.verticalAlign="baseline",a.ascent=b(d).top-b(c).top,d.style.verticalAlign="bottom",a.height=b(d).top-b(c).top,a.ascent=Math.ceil(a.ascent),a.height=Math.ceil(a.height),a.descent=a.height-a.ascent,a}finally{f.removeChild(e)}}catch(g){return null}}},extendsWith:function(){return{fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,strokeSize:1,padding:0,image:null,charMap:null,height:0, +ascent:0,descent:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setStrokeSize:function(a){this.strokeSize=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle=a;return this},createDefault:function(a){for(var b="",c=32;c<128;c++)b+=String.fromCharCode(c);return this.create(b, +a)},create:function(a,b){b|=0;this.padding=b;var c=document.createElement("canvas"),d=c.getContext("2d");d.textBaseline="bottom";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;var e=0,f=[],g,h;for(g=0;g>0)+1)+2*b;f.push(i);e+=i}g=CAAT.Font.getFontMetrics(d.font);d=g.height;this.ascent=g.ascent;this.descent=g.descent;this.height=g.height;i=g.ascent;c.width=e;c.height=d;d=c.getContext("2d");d.textBaseline= +"alphabetic";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g0&&g.height>0&&b.drawImage(this.image,g.x,0,h,i,c,d,h,i),c+=h):(b.strokeStyle="#f00",b.strokeRect(c,d,10,i),c+=10)},save:function(){var a=this.image.toDataURL("image/png");document.location.href=a.replace("image/png","image/octet-stream")},drawSpriteText:function(a,b){this.spriteImage.drawSpriteText(a,b)}}}}); +CAAT.Module({defines:"CAAT.Module.CircleManager.PackedCircle",depends:["CAAT.Module.CircleManager.PackedCircle","CAAT.Math.Point"],constants:{BOUNDS_RULE_WRAP:1,BOUNDS_RULE_CONSTRAINT:2,BOUNDS_RULE_DESTROY:4,BOUNDS_RULE_IGNORE:8},extendsWith:{__init:function(){this.boundsRule=CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE;this.position=new CAAT.Math.Point(0,0,0);this.offset=new CAAT.Math.Point(0,0,0);this.targetPosition=new CAAT.Math.Point(0,0,0);return this},id:0,delegate:null,position:null, +offset:null,targetPosition:null,targetChaseSpeed:0.02,isFixed:false,boundsRule:0,collisionMask:0,collisionGroup:0,containsPoint:function(a){return this.position.getDistanceSquared(a)this.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-ethis.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-ed?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}}); +CAAT.Module({defines:"CAAT.Module.Preloader.Preloader",extendsWith:function(){var a=function(a,c,d){this.id=a;this.path=c;this.image=new Image;this.loader=d;this.image.onload=this.onload.bind(this);this.image.onerror=this.onerror.bind(this);return this};a.prototype={id:null,path:null,image:null,loader:null,onload:function(){this.loader.__onload(this);this.image.onload=null;this.image.onerror=null},onerror:function(){this.loader.__onerror(this)},load:function(){this.image.src=this.path},clear:function(){this.loader= +null}};return{__init:function(){this.elements=[];this.baseURL="";return this},currentGroup:null,elements:null,imageCounter:0,cfinished:null,cloaded:null,cerrored:null,loadedCount:0,baseURL:null,addElement:function(b,c){this.elements.push(new a(b,this.baseURL+c,this));return this},clear:function(){for(var a=0;a>=0;var d=true,e=true,f=true,g=true;if(typeof c!== +"undefined"){if(typeof c.top!=="undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,o=c.width-1,n=false;if(d){for(d=0;db){n=true;break}if(n)break}a=d}if(e){n=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){n=true;break}if(n)break}k=d}if(f){n=false;for(j=0;jb){n=true;break}if(n)break}m=j}if(g){n=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){n=true;break}if(n)break}o=j}if(0===m&&0===a&&c.width-1===o&&c.height-1===k)return c;b=o-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height= +e;h=c.getContext("2d");h.putImageData(f,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}}); +CAAT.Module({defines:"CAAT.Module.Collision.QuadTree",depends:["CAAT.Math.Rectangle"],extendsClass:"CAAT.Math.Rectangle",extendsWith:function(){return{bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]= +(new CAAT.Module.Collision.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,i,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ +a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; +for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;bb&&(g=b),setTimeout(function(){j(a,e,c)},g)):j(a,e,c)}};return g}function j(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(true);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,false,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, +0.4))}var c=document.getElementById(c),k;if(CAAT.__CSS__)c&&false===c instanceof HTMLDivElement&&(c=null),c===null&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var m=document.createElement("canvas");c.appendChild(m);c=m}else false==c instanceof HTMLCanvasElement&&(m=document.createElement("canvas"),document.body.appendChild(m),c=m);else c=document.createElement("canvas"),document.body.appendChild(c);k=(new CAAT.Foundation.Director).initialize(a|| +800,b||600,c);a=[];g&&a.push({id:"splash",url:g});h&&a.push({id:"spinner",url:h});k.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){k.setImagesCache(b);var c=i(k,d||5E3,f);CAAT.loop(60);e&&e.length>0?(new CAAT.Module.Preloader.ImagePreloader).loadImages(e,c.loadedImage):c.loadedImage(0,null)}})}}}); +(function(){CAAT.CSS={};CAAT.CSS.PREFIX=function(){for(var a="",b=["WebKit","Moz","O"],c=0;c=0;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;f>=0;f--)if((e[f].type===window.CSSRule.WEBKIT_KEYFRAMES_RULE||e[f].type===window.CSSRule.MOZ_KEYFRAMES_RULE)&&e[f].name===a)return{sheetIndex:c,index:f}}catch(g){}return null};CAAT.CSS.getCSSKeyframes= +function(a){for(var b=document.styleSheets,c=b.length-1;c>=0;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;f>=0;f--)if((e[f].type===window.CSSRule.WEBKIT_KEYFRAMES_RULE||e[f].type===window.CSSRule.MOZ_KEYFRAMES_RULE)&&e[f].name===a)return e[f]}catch(g){}return null}})(); +CAAT.Module({defines:"CAAT.PathUtil.PathSegment",depends:["CAAT.Math.Rectangle","CAAT.Math.Point","CAAT.Math.Matrix","CAAT.Math.Curve"],extendsWith:function(){return{__init:function(){this.bbox=new CAAT.Math.Rectangle;return this},color:"#000",length:0,bbox:null,parent:null,setParent:function(a){this.parent=a;return this},setColor:function(a){if(a)this.color=a;return this},endCurvePosition:function(){},startCurvePosition:function(){},setPoints:function(){},setPoint:function(){},getPosition:function(){}, +getLength:function(){return this.length},getBoundingBox:function(){return this.bbox},numControlPoints:function(){},getControlPoint:function(){},endPath:function(){},getContour:function(){},updatePath:function(){},applyAsPath:function(){},transform:function(){},drawHandle:function(a,b,c){a.beginPath();a.arc(b,c,CAAT.Math.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false);a.fill()}}}}); +CAAT.Module({defines:"CAAT.PathUtil.ArcPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.ArcPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point;return this},points:null,cw:true,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:false,setRadius:function(a){this.radius= +a;return this},isArcTo:function(){return this.arcTo},setArcTo:function(a){this.arcTo=a;return this},initialize:function(a,b,c,d){this.setInitialPosition(a,b);this.setFinalPosition(a+c,b);this.angle=d||2*Math.PI;return this},applyAsPath:function(a){a=a.ctx;this.arcTo?a.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):a.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.angle+this.startAngle,this.cw);return this},setPoint:function(a,b){b>=0&& +b1||a<0)a%=1;a<0&&(a=1+a);-1===this.length?this.newPosition.set(this.points[0].x,this.points[0].y):(a=this.angle*a*(this.cw?1:-1)+this.startAngle,this.newPosition.set(this.points[0].x+this.radius*Math.cos(a),this.points[0].y+this.radius*Math.sin(a)));return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save(); +c.strokeStyle=this.color;c.beginPath();this.arcTo?c.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):c.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.startAngle+this.angle,this.cw);c.stroke();if(b){c.globalAlpha=0.5;c.fillStyle="#7f7f00";for(var d=0;d1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition, +a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x},finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]}, +endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/a,y:this.getPosition(c/a).y});return b}}}}); +CAAT.Module({defines:"CAAT.PathUtil.LinearPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point"],aliases:["CAAT.LinearPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point(0,0,0);return this},points:null,newPosition:null,applyAsPath:function(a){a.ctx.lineTo(this.points[1].x,this.points[1].y)},setPoint:function(a, +b){b===0?this.points[0]=a:b===1&&(this.points[1]=a)},updatePath:function(){var a=this.points[1].x-this.points[0].x,b=this.points[1].y-this.points[0].y;this.length=Math.sqrt(a*a+b*b);this.bbox.setEmpty();this.bbox.union(this.points[0].x,this.points[0].y);this.bbox.union(this.points[1].x,this.points[1].y);return this},setPoints:function(a){this.points[0]=a[0];this.points[1]=a[1];this.updatePath();return this},setInitialPosition:function(a,b){this.points[0].x=a;this.points[0].y=b;this.newPosition.set(a, +b);return this},setFinalPosition:function(a,b){this.points[1].x=a;this.points[1].y=b;return this},endCurvePosition:function(){return this.points[1]},startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x}, +finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0]; +else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); +CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; +return this},points:null,cw:true,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x, +this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1; +a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c,b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;f=1||a<=0)){var c,d,e;a>=1?(c=this.__getPositionImpl(0.999),d=this.endCurvePosition(),e=Math.atan2(d.y-c.y,d.x-c.x),c=a%1):(c=this.__getPositionImpl(0.0010),d=this.startCurvePosition(),e=Math.atan2(d.y-c.y,d.x-c.x),c=-a);var f=this.newPosition,g=this.getLength(); +f.x=d.x+c*g*Math.cos(e);f.y=d.y+c*g*Math.sin(e);return f}return this.__getPositionImpl(a)},__getPositionImpl:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,i;e!==f;)if(g=(f+e)/2|0,i=c[g],i<=a&&a<=i+d[g])return a=d[g]?(a-i)/d[g]:0,a>1?a=1:a<0&&(a=0),a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;else a0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();b&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Math.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b="0"&&a<="9"},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(c=this.duration?(this.remove=true,this.callback_timeout&&this.callback_timeout(a,b,this)): +this.callback_tick&&this.callback_tick(a,b,this);return this},remainingTime:function(){return this.duration-(this.scene.time-this.startTime)},reset:function(a){this.remove=false;this.startTime=a;this.owner.ensureTimerTask(this);return this},cancel:function(){this.remove=true;null!=this.callback_cancel&&this.callback_cancel(this.scene.time,this.scene.time-this.startTime,this);return this},addTime:function(a){this.duration+=a;return this}}}); +CAAT.Module({defines:"CAAT.Foundation.Timer.TimerManager",aliases:["CAAT.TimerManager"],depends:["CAAT.Foundation.Timer.TimerTask"],extendsWith:{__init:function(){this.timerList=[];return this},timerList:null,timerSequence:0,checkTimers:function(a){for(var b=this.timerList,c=b.length-1;c>=0;)b[c].remove||b[c].checkTask(a),c--},ensureTimerTask:function(a){this.hasTimer(a)||this.timerList.push(a);return this},hasTimer:function(a){for(var b=this.timerList,c=b.length-1;c>=0;){if(b[c]===a)return true; +c--}return false},createTimer:function(a,b,c,d,e,f){a=(new CAAT.Foundation.Timer.TimerTask).create(a,b,c,d,e);a.taskId=this.timerSequence++;a.sceneTime=f.time;a.owner=this;a.scene=f;this.timerList.push(a);return a},removeExpiredTimers:function(){var a,b=this.timerList;for(a=0;a0&&(b+=this.hgap)}switch(this.halign){case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT:b=this.padding.left;break;case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT:b=a.width-b-this.padding.right;break;default:b=(a.width-b)/2}for(e=0,f=a.getNumChildren();e0&&(c+=this.vgap)}switch(this.valign){case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP:b=this.padding.top;break;case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM:b=a.height-c-this.padding.bottom;break;default:b=(a.height-c)/2}for(d=0,e=a.getNumChildren();d0?g=Math.floor((e+f-1)/f):f=Math.floor((e+g-1)/g);for(var c=(g-1)*this.hgap,d=a.width-(this.padding.left+this.padding.right),e=Math.floor((d-c)/g),h=(f-1)*this.vgap,i=a.height-(this.padding.top+this.padding.bottom),j=Math.floor((i-h)/f),h=Math.floor((i-(j*f+h))/2),i=0,k=this.padding.left+Math.floor((d-(e*g+c))/2);i0?c=Math.ceil((d+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g0?c=Math.ceil((d+b-1)/b):b=Math.ceil((d+c-1)/c);for(g=0;g>0)*e;var k=i+(d/h>>0)*f,m=g+e,o=k+f;g=(new CAAT.Foundation.SpriteImageHelper(g,k,m-g,o-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,o/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(f-=d);var g=(this.offsetY-this.ownerActor.y)%e;g>0&&(g-=e);for(var d=((c.width-f)/d>>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx,a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a, +b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a, +b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex]; +a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a,b,c,d,e,f,g){a.drawImage(this.image,d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+ +d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return""+-(a.x+this.parentOffsetX-this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat": +"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]= +g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case b.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint= +this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this},setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1){if(this.prevAnimationTime===-1)this.prevAnimationTime= +a,this.spriteIndex=this.animationImageIndex[0],this.prevIndex=0;else{var b=a;b-=this.prevAnimationTime;b/=this.changeFPS;b%=this.animationImageIndex.length;b=Math.floor(b);b>0,f=0;fa&&(a=c)}this.fontHeight=a;return this.fontHeight*this.fontScale},drawText:function(a,b,c,d){var e,f,g;for(e=0;e0&&f.height>0&&b.drawImage(this.image,f.x,f.y,g,f.height,c+f.xoffset*this.fontScale,d+f.yoffset*this.fontScale,g*this.fontScale,f.height*this.fontScale),c+=f.xadvance*this.fontScale}, +getFontData:function(){var a=this.stringHeight()*0.8>>0;return{height:this.stringHeight(),ascent:a,descent:this.stringHeight()-a}}}}}); +CAAT.Module({defines:"CAAT.Foundation.Actor",aliases:["CAAT.Actor"],depends:"CAAT.Math.Dimension,CAAT.Event.AnimationLoop,CAAT.Foundation.SpriteImage,CAAT.Core.Constants,CAAT.Behavior.PathBehavior,CAAT.Behavior.RotateBehavior,CAAT.Behavior.ScaleBehavior,CAAT.Behavior.Scale1Behavior,CAAT.PathUtil.LinearPath,CAAT.Event.AnimationLoop".split(","),constants:{ANCHOR_CENTER:0,ANCHOR_TOP:1,ANCHOR_BOTTOM:2,ANCHOR_LEFT:3,ANCHOR_RIGHT:4,ANCHOR_TOP_LEFT:5,ANCHOR_TOP_RIGHT:6,ANCHOR_BOTTOM_LEFT:7,ANCHOR_BOTTOM_RIGHT:8, +ANCHOR_CUSTOM:9,CACHE_NONE:0,CACHE_SIMPLE:1,CACHE_DEEP:2},extendsWith:function(){var a=0;return{__init:function(){this.behaviorList=[];this.lifecycleListenerList=[];this.AABB=new CAAT.Math.Rectangle;this.viewVertices=[new CAAT.Math.Point(0,0,0),new CAAT.Math.Point(0,0,0),new CAAT.Math.Point(0,0,0),new CAAT.Math.Point(0,0,0)];this.scaleAnchor=CAAT.Foundation.Actor.ANCHOR_CENTER;this.modelViewMatrix=new CAAT.Math.Matrix;this.worldModelViewMatrix=new CAAT.Math.Matrix;this.resetTransform();this.setScale(1, +1);this.setRotation(0);this.id=a++;return this},__super:null,lifecycleListenerList:null,behaviorList:null,parent:null,x:0,y:0,width:0,height:0,preferredSize:null,minimumSize:null,start_time:0,duration:Number.MAX_VALUE,clip:false,clipPath:null,tAnchorX:0,tAnchorY:0,scaleX:1,scaleY:1,scaleTX:0.5,scaleTY:0.5,scaleAnchor:0,rotationAngle:0,rotationY:0.5,rotationX:0.5,alpha:1,isGlobalAlpha:false,frameAlpha:1,expired:false,discardable:false,pointed:false,mouseEnabled:true,visible:true,fillStyle:null,strokeStyle:null, +time:0,AABB:null,viewVertices:null,inFrame:false,dirty:true,wdirty:true,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:false,backgroundImage:null,id:null,size_active:1,size_total:1,__d_ax:-1,__d_ay:-1,gestureEnabled:false,invalid:true,cached:0,preventLayout:false,isAA:true,isCachedActor:false,setCachedActor:function(a){this.isCachedActor=a;return this},setPreventLayout:function(a){this.preventLayout=a;return this},invalidateLayout:function(){this.parent&& +!this.parent.layoutInvalidated&&this.parent.invalidateLayout();return this},__validateLayout:function(){},setPreferredSize:function(a,c){if(!this.preferredSize)this.preferredSize=new CAAT.Math.Dimension;this.preferredSize.width=a;this.preferredSize.height=c;return this},getPreferredSize:function(){return this.preferredSize?this.preferredSize:this.getMinimumSize()},setMinimumSize:function(a,c){if(!this.minimumSize)this.minimumSize=new CAAT.Math.Dimension;this.minimumSize.width=a;this.minimumSize.height= +c;return this},getMinimumSize:function(){return this.minimumSize?this.minimumSize:new CAAT.Math.Dimension(this.width,this.height)},create:function(){return this},moveTo:function(a,c,d,e,f,g){if(!(a===this.x&&c===this.y)){var h=this.getBehavior("__moveTo");h||(h=(new CAAT.Behavior.PathBehavior).setId("__moveTo").setValues(new CAAT.PathUtil.LinearPath),this.addBehavior(h));h.path.setInitialPosition(this.x,this.y).setFinalPosition(a,c);h.setDelayTime(e?e:0,d);f&&h.setInterpolator(f);if(g)h.lifecycleListenerList= +[],h.addListener({behaviorExpired:function(a,b,c){g(a,b,c)}});return this}},rotateTo:function(a,c,d,e,f,g){if(a!==this.rotationAngle){var h=this.getBehavior("__rotateTo");h||(h=(new CAAT.Behavior.RotateBehavior).setId("__rotateTo").setValues(0,0,0.5,0.5),this.addBehavior(h));h.setValues(this.rotationAngle,a,e,f).setDelayTime(d?d:0,c);g&&h.setInterpolator(g);return this}},scaleTo:function(a,c,d,e,f,g,h){if(!(this.scaleX===a&&this.scaleY===c)){var i=this.getBehavior("__scaleTo");i||(i=(new CAAT.Behavior.ScaleBehavior).setId("__scaleTo").setValues(1, +1,1,1,0.5,0.5),this.addBehavior(i));i.setValues(this.scaleX,a,this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this}},scaleXTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Behavior.Scale1Behavior.AXIS_X,a,c,d,e,f,g)},scaleYTo:function(a,c,d,e,f,g){return this.__scale1To(CAAT.Behavior.Scale1Behavior.AXIS_Y,a,c,d,e,f,g)},__scale1To:function(a,c,d,e,f,g,h){if(!(a===CAAT.Behavior.Scale1Behavior.AXIS_X&&c===this.scaleX||a===CAAT.Behavior.Scale1Behavior.AXIS_Y&&c===this.scaleY)){var i= +this.getBehavior("__scaleXTo");i||(i=(new CAAT.Behavior.Scale1Behavior).setId("__scaleXTo").setValues(1,1,a===CAAT.Behavior.Scale1Behavior.AXIS_X,0.5,0.5),this.addBehavior(i));i.setValues(a?this.scaleX:this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&i.setInterpolator(h);return this}},touchStart:function(){},touchMove:function(){},touchEnd:function(){},gestureStart:function(){},gestureChange:function(a,c,d){this.gestureEnabled&&(this.setRotation(a),this.setScale(c,d));return this},gestureEnd:function(){}, +isVisible:function(){return this.visible},invalidate:function(){this.invalid=true;return this},setGestureEnabled:function(a){this.gestureEnabled=!!a;return this},isGestureEnabled:function(){return this.gestureEnabled},getId:function(){return this.id},setId:function(a){this.id=a;return this},setParent:function(a){this.parent=a;return this},setBackgroundImage:function(a,c){if(a){a=a instanceof CAAT.Foundation.SpriteImage?a.getRef():isString(a)?(new CAAT.Foundation.SpriteImage).initialize(CAAT.currentDirector.getImage(a), +1,1):(new CAAT.Foundation.SpriteImage).initialize(a,1,1);a.setOwner(this);this.backgroundImage=a;if(typeof c==="undefined"||c)this.width=a.getWidth(),this.height=a.getHeight();this.glEnabled=true;this.invalidate()}else this.backgroundImage=null;return this},setSpriteIndex:function(a){this.backgroundImage&&(this.backgroundImage.setSpriteIndex(a),this.invalidate());return this},setBackgroundImageOffset:function(a,c){this.backgroundImage&&this.backgroundImage.setOffset(a,c);return this},setAnimationImageIndex:function(a){this.backgroundImage&& +(this.backgroundImage.resetAnimationTime(),this.backgroundImage.setAnimationImageIndex(a),this.invalidate());return this},addAnimation:function(a,c,d,e){this.backgroundImage&&this.backgroundImage.addAnimation(a,c,d,e);return this},playAnimation:function(a){this.backgroundImage&&this.backgroundImage.playAnimation(a);return this},setAnimationEndCallback:function(a){this.backgroundImage&&this.backgroundImage.setAnimationEndCallback(a);return this},resetAnimationTime:function(){this.backgroundImage&& +(this.backgroundImage.resetAnimationTime(),this.invalidate());return this},setChangeFPS:function(a){this.backgroundImage&&this.backgroundImage.setChangeFPS(a);return this},setImageTransformation:function(a){this.backgroundImage&&this.backgroundImage.setSpriteTransformation(a);return this},centerOn:function(a,c){this.setPosition(a-this.width/2,c-this.height/2);return this},centerAt:function(a,c){this.setPosition(a-this.width*(0.5-this.tAnchorX),c-this.height*(0.5-this.tAnchorY));return this},getTextureGLPage:function(){return this.backgroundImage.image.__texturePage}, +setVisible:function(a){this.invalidate();CAAT.currentDirector&&CAAT.currentDirector.dirtyRectsEnabled&&!a&&this.visible&&CAAT.currentDirector.scheduleDirtyRect(this.AABB);if(a&&!this.visible)this.dirty=true;this.visible=a;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},removeListener:function(a){for(var c=this.lifecycleListenerList.length;c--;)if(this.lifecycleListenerList[c]===a){this.lifecycleListenerList.splice(c, +1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=a;return this},fireEvent:function(a,c){for(var d=0;d=this.start_time+ +this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&c>=0&&af)f=d.x;if(d.yh)h=d.y;d=c[1];if(d.xf)f=d.x;if(d.yh)h=d.y;d=c[2];if(d.xf)f=d.x;if(d.yh)h=d.y;d=c[3];if(d.xf)f=d.x;if(d.yh)h=d.y;a.x=e;a.y=g;a.x1=f;a.y1=h;a.width=f-e;a.height=h-g;return this},paintActor:function(a,c){if(!this.visible||!a.inDirtyRect(this))return true;var d=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha: +1;d.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(d);this.worldModelViewMatrix.transformRenderingContext(d);this.clip&&(d.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):d.rect(0,0,this.width,this.height),d.clip());this.paint(a,c);return true},__paintActor:function(a,c){if(!this.visible)return true;var d=a.ctx;this.frameAlpha=this.alpha;var e=this.worldModelViewMatrix.matrix;d.setTransform(e[0],e[3],e[1],e[4],e[2],e[5],this.frameAlpha);this.paint(a,c);return true}, +paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);if(!this.__vv)this.__vv=new Float32Array(12);this.setGLCoords(this.__vv,0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var c=a.coordsIndex;this.setGLCoords(a.coords,c);a.coordsIndex=c+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,c){var d=this.viewVertices; +a[c++]=d[0].x;a[c++]=d[0].y;a[c++]=0;a[c++]=d[1].x;a[c++]=d[1].y;a[c++]=0;a[c++]=d[2].x;a[c++]=d[2].y;a[c++]=0;a[c++]=d[3].x;a[c++]=d[3].y;a[c]=0},setUV:function(a,c){this.backgroundImage.setUV(a,c)},glNeedsFlush:function(a){return this.getTextureGLPage()!==a.currentTexturePage?true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var c=this.getTextureGLPage();c!==a.currentTexturePage&&a.setGLTexturePage(c);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)}, +endAnimate:function(){return this},initialize:function(a){if(a)for(var c in a)this[c]=a[c];return this},setClip:function(a,c){this.clip=a;this.clipPath=c;return this},isCached:function(){return this.cached},stopCacheAsBitmap:function(){if(this.cached)this.backgroundImage=null,this.cached=CAAT.Foundation.Actor.CACHE_NONE},cacheAsBitmap:function(a,c){if(this.width<=0||this.height<=0)return this;var a=a||0,d=document.createElement("canvas");d.width=this.width;d.height=this.height;var e=d.getContext("2d"); +CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,a);var e={ctx:e,modelViewMatrix:new CAAT.Math.Matrix,worldModelViewMatrix:new CAAT.Math.Matrix,dirtyRectsEnabled:false,inDirtyRect:function(){return true},AABB:new CAAT.Math.Rectangle(0,0,this.width,this.height)},f=this.modelViewMatrix,g=this.worldModelViewMatrix;this.modelViewMatrix=new CAAT.Math.Matrix;this.worldModelViewMatrix=new CAAT.Math.Matrix;this.cached=CAAT.Foundation.Actor.CACHE_NONE;if(typeof c==="undefined")c=CAAT.Foundation.Actor.CACHE_SIMPLE; +c===CAAT.Foundation.Actor.CACHE_DEEP?(this.animate(e,a),this.paintActor(e,a)):this instanceof CAAT.Foundation.ActorContainer||this instanceof CAAT.ActorContainer?CAAT.Foundation.ActorContainer.superclass.paintActor.call(this,e,a):(this.animate(e,a),this.paintActor(e,a));this.setBackgroundImage(d);this.cached=c;this.modelViewMatrix=f;this.worldModelViewMatrix=g;return this},resetAsButton:function(){this.actionPerformed=null;this.mouseEnter=function(){};this.mouseExit=function(){};this.mouseDown=function(){}; +this.mouseUp=function(){};this.mouseClick=function(){};this.mouseDrag=function(){};return this},setAsButton:function(a,c,d,e,f,g){this.setBackgroundImage(a,true);this.iNormal=c||0;this.iOver=d||this.iNormal;this.iPress=e||this.iNormal;this.iDisabled=f||this.iNormal;this.fnOnClick=g;this.enabled=true;this.setSpriteIndex(c);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&&this.fnOnClick&& +this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging= +true};this.setButtonImageIndex=function(a,b,c,d){this.iNormal=a||0;this.iOver=b||this.iNormal;this.iPress=c||this.iNormal;this.iDisabled=d||this.iNormal;this.setSpriteIndex(this.iNormal);return this};return this},findActorById:function(a){return this.id===a?this:null}}}}); +CAAT.Module({defines:"CAAT.Foundation.ActorContainer",aliases:["CAAT.ActorContainer"],depends:["CAAT.Foundation.Actor","CAAT.Math.Point","CAAT.Math.Rectangle"],constants:{ADDHINT:{CONFORM:1},AddHint:{CONFORM:1}},extendsClass:"CAAT.Foundation.Actor",extendsWith:function(){var a=CAAT.Foundation.Actor.CACHE_DEEP,b=CAAT.Foundation.ActorContainer.superclass,c=b.drawScreenBoundingBox,d=b.paintActor,e=b.paintActorGL,f=b.animate,g=b.findActorAtPosition,h=b.destroy;return{__init:function(a){this.__super(); +this.childrenList=[];this.activeChildren=[];this.pendingChildrenList=[];if(typeof a!=="undefined")this.addHint=a,this.boundingBox=new CAAT.Math.Rectangle;return this},childrenList:null,activeChildren:null,pendingChildrenList:null,addHint:0,boundingBox:null,runion:new CAAT.Math.Rectangle,layoutManager:null,layoutInvalidated:true,setLayout:function(a){this.layoutManager=a;return this},setBounds:function(a,b,c,d){CAAT.Foundation.ActorContainer.superclass.setBounds.call(this,a,b,c,d);CAAT.currentDirector&& +!CAAT.currentDirector.inValidation&&this.invalidateLayout();return this},__validateLayout:function(){this.__validateTree();this.layoutInvalidated=false},__validateTree:function(){if(this.layoutManager&&this.layoutManager.isInvalidated()){CAAT.currentDirector.inValidation=true;this.layoutManager.doLayout(this);for(var a=0;a=this.childrenList.length)b=this.childrenList.length;a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);this.invalidateLayout();return this},findActorById:function(a){if(CAAT.Foundation.ActorContainer.superclass.findActorById.call(this,a))return this;for(var b=this.childrenList,c=0,d=b.length;c=0&&a=0;b--){var c=this.childrenList[b],d=new CAAT.Math.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this}, +destroy:function(){for(var a=this.childrenList,b=a.length-1;b>=0;b--)a[b].destroy();h.call(this);return this},getNumChildren:function(){return this.childrenList.length},getNumActiveChildren:function(){return this.activeChildren.length},getChildAt:function(a){return this.childrenList[a]},setZOrder:function(a,b){var c=this.findChild(a);if(-1!==c){var d=this.childrenList;if(b!==c){if(b>=d.length)d.splice(c,1),d.push(a);else{c=d.splice(c,1);if(b<0)b=0;else if(b>d.length)b=d.length;d.splice(b,0,c[0])}this.invalidateLayout()}}}}}}); +CAAT.Module({defines:"CAAT.Foundation.Scene",depends:"CAAT.Math.Point,CAAT.Math.Matrix,CAAT.PathUtil.Path,CAAT.Behavior.GenericBehavior,CAAT.Behavior.ContainerBehavior,CAAT.Behavior.ScaleBehavior,CAAT.Behavior.AlphaBehavior,CAAT.Behavior.RotateBehavior,CAAT.Behavior.PathBehavior,CAAT.Foundation.ActorContainer,CAAT.Foundation.Timer.TimerManager".split(","),aliases:["CAAT.Scene"],extendsClass:"CAAT.Foundation.ActorContainer",constants:{EASE_ROTATION:1,EASE_SCALE:2,EASE_TRANSLATE:3},extendsWith:function(){return{__init:function(){this.__super(); +this.timerManager=new CAAT.TimerManager;this.fillStyle=null;this.isGlobalAlpha=true;return this},easeContainerBehaviour:null,easeContainerBehaviourListener:null,easeIn:false,paused:false,timerManager:null,isPaused:function(){return this.paused},setPaused:function(a){this.paused=a},createTimer:function(a,b,c,d,e){return this.timerManager.createTimer(a,b,c,d,e,this)},setTimeout:function(a,b,c,d){return this.timerManager.createTimer(this.time,a,b,c,d,this)},createAlphaBehaviour:function(a,b){var c=new CAAT.Behavior.AlphaBehavior; +c.setFrameTime(0,a);c.startAlpha=b?0:1;c.endAlpha=b?1:0;this.easeContainerBehaviour.addBehavior(c)},easeTranslationIn:function(a,b,c,d){this.easeTranslation(a,b,c,true,d)},easeTranslationOut:function(a,b,c,d){this.easeTranslation(a,b,c,false,d)},easeTranslation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;this.easeIn=d;var f=new CAAT.Behavior.PathBehavior;e&&f.setInterpolator(e);f.setFrameTime(0,a);c<1?c=1:c>4&&(c=4);switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:d? +(f.setPath((new CAAT.PathUtil.Path).setLinear(0,-this.height+1,0,0)),this.setPosition(0,-this.height+1)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,0,-this.height+1)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_BOTTOM:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(0,this.height-1,0,0)),this.setPosition(0,this.height-1)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,0,this.height-1)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_LEFT:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(-this.width+ +1,0,0,0)),this.setPosition(-this.width+1,0)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,-this.width+1,0)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_RIGHT:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(this.width-1,0,0,0)),this.setPosition(this.width-1,0)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,this.width-1,0)),this.setPosition(0,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time, +a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn=false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:case CAAT.Foundation.Actor.ANCHOR_CENTER:j= +i=1;break;case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:j=h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var k;k=g;g=i;i=k;k=h;h=j;j=k}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.Behavior.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time, +b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this},easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var f=0,g=0;if(c==CAAT.Foundation.Actor.ANCHOR_CENTER)c= +CAAT.Foundation.Actor.ANCHOR_TOP;switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:f=Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false=== +d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,d);b=this.getAnchorPercent(c);f=(new CAAT.Behavior.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a}, +behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a},paint:function(a){if(this.fillStyle)a=a.ctx,a.fillStyle=this.fillStyle,a.fillRect(0,0,this.width,this.height)},findActorAtPosition:function(a){var b,c,d=new CAAT.Math.Point;if(this.inputList){var e=this.inputList;for(b=0;b=this.inputList.length&&(b=this.inputList.length-1);b=this.inputList[b];typeof c==="undefined"||c>=b.length?b.push(a):c<=0?b.unshift(a):b.splice(c,0,a);return this},emptyInputList:function(a){a<0?a=0:a>=this.inputList.length&& +(a=this.inputList.length-1);this.inputList[a]=[];return this},removeActorFromInputList:function(a,b){if(typeof b==="undefined"){var c,d;for(c=0;c=this.inputList.length&&(b=this.inputList.length-1);e=this.inputList[b];for(d=0;d=0;b--){var c=this.childrenList[b],d=new CAAT.Math.Point(a.x, +a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0;this.statistics.size_discarded_by_dirty_rects=0},render:function(a){if(!this.currentScene||!this.currentScene.isPaused()){this.time+=a;for(e=0,l=this.childrenList.length;e0&&!navigator.isCocoonJS&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;b=this.cDirtyRects;for(e=0;e=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.Math.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height; +this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.setTransform(1,0,0,1,0,0);a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);var c=this.ctx;this.ctx=a;a.save();var d=this.modelViewMatrix,e=this.worldModelViewMatrix;this.modelViewMatrix=this.worldModelViewMatrix=new CAAT.Math.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time); +this.worldModelViewMatrix=e;this.modelViewMatrix=d;a.restore();this.ctx=c}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a=this.scenes[a];d=this.scenes[d];if(!CAAT.__CSS__&&CAAT.CACHE_SCENE_ON_CHANGE)this.renderToContext(this.transitionScene.ctx,d),d=this.transitionScene; +a.setExpired(false);d.setExpired(false);a.mouseEnabled=false;d.mouseEnabled=false;a.resetTransform();d.resetTransform();a.setLocation(0,0);d.setLocation(0,0);a.alpha=1;d.alpha=1;b===CAAT.Foundation.Scene.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Foundation.Scene.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Foundation.Scene.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Foundation.Scene.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList= +[];d.goOut(a);a.getIn(d);this.addChild(d);this.addChild(a)}},easeInOutRandom:function(a,b,c,d){var e=Math.random(),f=Math.random(),g;e<0.33?(e=CAAT.Foundation.Scene.EASE_ROTATION,g=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Foundation.Scene.EASE_SCALE,g=(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Foundation.Scene.EASE_TRANSLATE,g=(new CAAT.Behavior.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Foundation.Scene.EASE_ROTATION, +h=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Foundation.Scene.EASE_SCALE,h=(new CAAT.Behavior.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Foundation.Scene.EASE_TRANSLATE,h=(new CAAT.Behavior.Interpolator).createBounceOutInterpolator());this.easeInOut(a,e,Math.random()*8.99>>0,b,f,Math.random()*8.99>>0,c,d,g,h)},easeIn:function(a,b,c,d,e,f){a=this.scenes[a];b===CAAT.Foundation.Scene.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Foundation.Scene.EASE_SCALE? +a.easeScaleIn(0,c,d,e,f):a.easeTranslationIn(c,d,e,f);this.childrenList=[];this.addChild(a);a.resetTransform();a.setLocation(0,0);a.alpha=1;a.mouseEnabled=false;a.setExpired(false)},setScene:function(a){a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(false);a.mouseEnabled=true;a.resetTransform();a.setLocation(0,0);a.alpha=1;a.getIn();a.activated()},switchToScene:function(a,b,c,d){var e=this.getSceneIndex(this.currentScene);d?this.easeInOutRandom(a,e,b,c):this.setScene(a)}, +switchToPrevScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===0||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);this.getNumScenes()<=1||d===this.getNumScenes()-1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},easeEnd:function(a, +b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(true);a.mouseEnabled=true;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;b500&&(b=500);if(this.onRenderStart)this.onRenderStart(b);this.render(b);this.debugInfo&&this.debugInfo(this.statistics);this.timeline=a;if(this.onRenderEnd)this.onRenderEnd(b);this.needsRepaint=false}},resetTimeline:function(){this.timeline= +(new Date).getTime()},endLoop:function(){},setClear:function(a){this.clear=a;this.dirtyRectsEnabled=this.clear===CAAT.Foundation.Director.CLEAR_DIRTY_RECTS?true:false;return this},getAudioManager:function(){return this.audioManager},cumulateOffset:function(a,b,c){var d=c+"Left";c+="Top";for(var e=0,f=0,g;navigator.browser!=="iOS"&&a&&a.style;)if(g=a.currentStyle?a.currentStyle.position:(g=(a.ownerDocument.defaultView||a.ownerDocument.parentWindow).getComputedStyle(a,null))?g.getPropertyValue("position"): +null,/^(fixed)$/.test(g))break;else e+=a[d],f+=a[c],a=a[b];return{x:e,y:f,style:g}},getOffset:function(a){var b=this.cumulateOffset(a,"offsetParent","offset");return b.style==="fixed"?(a=this.cumulateOffset(a,a.parentNode?"parentNode":"parentElement","scroll"),{x:b.x+a.x,y:b.y+a.y}):{x:b.x,y:b.y}},getCanvasCoord:function(a,b){var c=new CAAT.Math.Point,d=0,e=0;if(!b)b=window.event;if(b.pageX||b.pageY)d=b.pageX,e=b.pageY;else if(b.clientX||b.clientY)d=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft, +e=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var f=this.getOffset(this.canvas);d-=f.x;e-=f.y;d*=this.SCREEN_RATIO;e*=this.SCREEN_RATIO;c.x=d;c.y=e;if(!this.modelViewMatrixI)this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(c);d=c.x;e=c.y;a.set(d,e);this.screenMousePoint.set(d,e)},__mouseDownHandler:function(a){if(this.dragging&&this.lastSelectedActor)this.__mouseUpHandler(a);else{this.getCanvasCoord(this.mousePoint,a);this.isMouseDown= +true;var b=this.findActorAtPosition(this.mousePoint);if(null!==b){var c=b.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.Event.MouseEvent).init(c.x,c.y,a,b,new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y)))}this.lastSelectedActor=b}},__mouseUpHandler:function(a){this.isMouseDown=false;this.getCanvasCoord(this.mousePoint,a);var b=null,c=this.lastSelectedActor;null!==c&&(b=c.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x, +this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.Event.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time)));!this.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.Event.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){var b,c,d=this.currentScene?this.currentScene.time:0;if(this.isMouseDown&&null!==this.lastSelectedActor){if(b= +this.lastSelectedActor,c=b.viewToModel(new CAAT.Math.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),this.dragging||!(Math.abs(this.prevMousePoint.x-c.x)=this.width||b.y>=this.height))this.touching=true,this.__mouseDownHandler(a)}},__touchEndHandler:function(a){if(this.touching)a.preventDefault(),a.returnValue=false,a=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=false,this.__mouseUpHandler(a)},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),a.returnValue=false,!this.gesturing))for(var b=0;b=this.width||f.y>=this.height)){var g=this.findActorAtPosition(f);g!==null&&(f=g.viewToModel(f),this.touches[e]||(this.touches[e]={actor:g,touch:new CAAT.Event.TouchInfo(e,f.x,f.y,g)},c.push(e)))}}e={};for(b=0;b=b.width||d.y>=b.height))b.touching=true,b.__mouseDownHandler(c)}},false);window.addEventListener("mouseover",function(c){if(c.target===a&&!b.dragging){c.preventDefault();c.cancelBubble=true;c.stopPropagation&&c.stopPropagation();var d=b.mousePoint; +b.getCanvasCoord(d,c);d.x<0||d.y<0||d.x>=b.width||d.y>=b.height||b.__mouseOverHandler(c)}},false);window.addEventListener("mouseout",function(c){if(c.target===a&&!b.dragging)c.preventDefault(),c.cancelBubble=true,c.stopPropagation&&c.stopPropagation(),b.getCanvasCoord(b.mousePoint,c),b.__mouseOutHandler(c)},false);window.addEventListener("mousemove",function(a){a.preventDefault();a.cancelBubble=true;a.stopPropagation&&a.stopPropagation();var d=b.mousePoint;b.getCanvasCoord(d,a);(b.dragging||!(d.x< +0||d.y<0||d.x>=b.width||d.y>=b.height))&&b.__mouseMoveHandler(a)},false);window.addEventListener("dblclick",function(c){if(c.target===a){c.preventDefault();c.cancelBubble=true;c.stopPropagation&&c.stopPropagation();var d=b.mousePoint;b.getCanvasCoord(d,c);d.x<0||d.y<0||d.x>=b.width||d.y>=b.height||b.__mouseDBLClickHandler(c)}},false);CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MOUSE?(a.addEventListener("touchstart",this.__touchStartHandler.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandler.bind(this), +false),a.addEventListener("touchend",this.__touchEndHandler.bind(this),false),a.addEventListener("gesturestart",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureStart(c.scale,c.rotation)},false),a.addEventListener("gestureend",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureEnd(c.scale,c.rotation)},false),a.addEventListener("gesturechange",function(c){if(c.target===a)c.preventDefault(),c.returnValue=false,b.__gestureChange(c.scale,c.rotation)}, +false)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this),false),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),false),a.addEventListener("touchcancel",this.__touchCancelHandleMT.bind(this),false),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),false),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this), +false),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),false))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=false;this.createEventHandler(a)},createEventHandler:function(a){this.in_=false;this.addHandlers(a)}}},onCreate:function(){if(typeof CAAT.__CSS__!=="undefined")CAAT.Foundation.Director.prototype.clip=true,CAAT.Foundation.Director.prototype.glEnabled=false,CAAT.Foundation.Director.prototype.getRenderType=function(){return"CSS"},CAAT.Foundation.Director.prototype.setScaleProportional= +function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.eventHandler.style.width=""+this.referenceWidth+"px";this.eventHandler.style.height=""+this.referenceHeight+"px"},CAAT.Foundation.Director.prototype.setBounds=function(a,b,c,d){CAAT.Foundation.Director.superclass.setBounds.call(this,a,b,c,d);for(a=0;ad+this.range?this.minSize:a===d?this.maxSize:a>0)+1)*b},setFillStyle:function(a){this.fill=a},setStrokeStyle:function(a){this.stroke= +a},setStrokeSize:function(a){this.strokeSize=a},setAlignment:function(a){this.alignment=a},setFontSize:function(a){if(a!==this.fontSize)this.fontSize=a,this.__setFont()}};var b=function(){this.text="";return this};b.prototype={x:0,y:0,width:0,text:null,crcs:null,rcs:null,styles:null,images:null,lines:null,documentHeight:0,anchorStack:null,__nextLine:function(){this.x=0;this.currentLine=new f(CAAT.Module.Font.Font.getFontMetrics(this.crcs.sfont));this.lines.push(this.currentLine)},__image:function(a, +b,c){var e;e=typeof b!=="undefined"&&typeof c!=="undefined"?a.getWidth():a instanceof CAAT.Foundation.SpriteImage?a.getWidth():a.getWrappedImageWidth();this.width&&e+this.x>this.width&&this.x>0&&this.__nextLine();this.currentLine.addElementImage(new d(this.x,a,b,c,this.crcs.clone(),this.__getCurrentAnchor()));this.x+=e},__text:function(){if(this.text.length!==0){var a=this.ctx.measureText(this.text).width;this.width&&a+this.x>this.width&&this.x>0&&this.__nextLine();this.currentLine.addElement(new e(this.text, +this.x,a,0,this.crcs.clone(),this.__getCurrentAnchor()));this.x+=a;this.text=""}},fchar:function(a){a===" "?(this.__text(),this.x+=this.ctx.measureText(a).width,this.width&&this.x>this.width&&this.__nextLine()):this.text+=a},end:function(){this.text.length>0&&this.__text();for(var a=0,b=0,c=0;c>0);this.lines[c].setY(a)}this.documentHeight=a+b},getDocumentHeight:function(){return this.documentHeight}, +__getCurrentAnchor:function(){return this.anchorStack.length?this.anchorStack[this.anchorStack.length-1]:null},__resetAppliedStyles:function(){this.rcs=[];this.__pushDefaultStyles()},__pushDefaultStyles:function(){this.crcs=(new a(this.ctx)).setDefault(this.styles["default"]);this.rcs.push(this.crcs)},__pushStyle:function(b){var c=this.crcs;this.crcs=new a(this.ctx);this.crcs.chain=c;this.crcs.setStyle(b);this.crcs.applyStyle();this.rcs.push(this.crcs)},__popStyle:function(){if(this.rcs.length>1)this.rcs.pop(), +this.crcs=this.rcs[this.rcs.length-1],this.crcs.applyStyle()},__popAnchor:function(){this.anchorStack.length>0&&this.anchorStack.pop()},__pushAnchor:function(a){this.anchorStack.push(a)},start:function(a,b,c,d){this.y=this.x=0;this.width=typeof d!=="undefined"?d:0;this.ctx=a;this.lines=[];this.styles=b;this.images=c;this.anchorStack=[];this.__resetAppliedStyles();this.__nextLine()},setTag:function(a){this.__text();a=a.toLowerCase();if(a==="b")this.crcs.setBold(true);else if(a==="/b")this.crcs.setBold(false); +else if(a==="i")this.crcs.setItalic(true);else if(a==="/i")this.crcs.setItalic(false);else if(a==="stroked")this.crcs.setStroked(true);else if(a==="/stroked")this.crcs.setStroked(false);else if(a==="filled")this.crcs.setFilled(true);else if(a==="/filled")this.crcs.setFilled(false);else if(a==="tab")this.x=this.crcs.getTabPos(this.x);else if(a==="br")this.__nextLine();else if(a==="/a")this.__popAnchor();else if(a==="/style")this.rcs.length>1&&this.__popStyle();else if(a.indexOf("fillcolor")===0)a= +a.split("="),this.crcs.setFillStyle(a[1]);else if(a.indexOf("strokecolor")===0)a=a.split("="),this.crcs.setStrokeStyle(a[1]);else if(a.indexOf("strokesize")===0)a=a.split("="),this.crcs.setStrokeSize(a[1]|0);else if(a.indexOf("fontsize")===0)a=a.split("="),this.crcs.setFontSize(a[1]|0);else if(a.indexOf("style")===0)a=a.split("="),(a=this.styles[a[1]])&&this.__pushStyle(a);else if(a.indexOf("image")===0){var a=a.split("=")[1].split(","),b=a[0];if(this.images[b]){var c=0,d=0;a.length>=3&&(c=a[1]|0, +d=a[2]|0);this.__image(this.images[b],c,d)}else CAAT.currentDirector.getImage(b)&&this.__image(CAAT.currentDirector.getImage(b))}else a.indexOf("a=")===0&&(a=a.split("="),this.__pushAnchor(a[1]))}};var c=function(a,b){this.link=a;this.style=b;return this};c.prototype={x:null,y:null,width:null,height:null,style:null,link:null,isLink:function(){return this.link},setLink:function(a){this.link=a;return this},getLink:function(){return this.link},contains:function(){return false}};var d=function(a,b,c, +e,f,m){d.superclass.constructor.call(this,m,f);this.x=a;this.image=b;this.row=c;this.column=e;this.width=b.getWidth();this.height=b.getHeight();if(this.image instanceof CAAT.SpriteImage||this.image instanceof CAAT.Foundation.SpriteImage)this.spriteIndex=typeof c==="undefined"||typeof e==="undefined"?0:c*b.columns+e,this.paint=this.paintSI;return this};d.prototype={image:null,row:null,column:null,spriteIndex:null,paint:function(a){this.style.image(a);a.drawImage(this.image,this.x,-this.height+1)}, +paintSI:function(a){this.style.image(a);this.image.setSpriteIndex(this.spriteIndex);this.image.paint({ctx:a},0,this.x,-this.height+1)},getHeight:function(){return this.image instanceof CAAT.Foundation.SpriteImage?this.image.getHeight():this.image.height},getFontMetrics:function(){return null},contains:function(a,b){return a>=this.x&&a<=this.x+this.width&&b>=this.y&&b=this.x&&a<=this.x+this.width&&b>=this.y&&b<=this.y+this.height},setYPosition:function(a){this.bl=a;this.y=a-this.fm.ascent}}; +extend(d,c);extend(e,c);var f=function(a){this.elements=[];this.defaultFontMetrics=a;return this};f.prototype={elements:null,width:0,height:0,defaultHeight:0,y:0,x:0,alignment:null,baselinePos:0,addElement:function(a){this.width=Math.max(this.width,a.x+a.width);this.height=Math.max(this.height,a.height);this.elements.push(a);this.alignment=a.style.__getProperty("alignment")},addElementImage:function(a){this.width=Math.max(this.width,a.x+a.width);this.height=Math.max(this.height,a.height);this.elements.push(a)}, +getHeight:function(){return this.height},setY:function(a){this.y=a},getY:function(){return this.y},paint:function(a){a.save();a.translate(this.x,this.y+this.baselinePos);for(var b=0;b=0.6&&this.elements.length>1){var c=a-this.width,c=c/(this.elements.length- +1)|0;for(b=1;ba.ascent&&(a=e):a=e:b?d.getHeight()>d.getHeight()&&(b=d):b=d}this.baselinePos=Math.max(a?a.ascent:this.defaultFontMetrics.ascent,b?b.getHeight():this.defaultFontMetrics.ascent);this.height= +this.baselinePos+(a!=null?a.descent:this.defaultFontMetrics.descent);for(c=0;c", +d+1),-1!==o&&(n=f.substr(d+1,o-d-1),n.indexOf("<")!==-1?(this.rc.fchar(p),d+=1):(this.rc.setTag(n),d=o+1))):(this.rc.fchar(p),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension(typeof b==="undefined"?0:b);this.setLinesAlignment();q.restore();this.setPreferredSize(this.documentWidth,this.documentHeight);this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);if(this.matchTextSize)this.width=this.preferredSize.width,this.height=this.preferredSize.height; +return this}},setVerticalAlignment:function(a){this.valignment=a;this.setDocumentPosition();return this},setHorizontalAlignment:function(a){this.halignment=a;this.setDocumentPosition();return this},setDocumentPosition:function(a,b){typeof a!=="undefined"&&this.setHorizontalAlignment(a);typeof b!=="undefined"&&this.setVerticalAlignment(b);var c=0,d=0;this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?d=(this.height-this.documentHeight)/2:this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM&& +(d=this.height-this.documentHeight);this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?c=(this.width-this.documentWidth)/2:this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT&&(c=this.width-this.documentWidth);this.documentX=c;this.documentY=d},__calculateDocumentDimension:function(a){var b,c=0;for(b=this.documentHeight=this.documentWidth=0;b=a&&d.y+d.height>=b)return d.__getElementAt(a-d.x,b-d.y)}return null},mouseExit:function(){CAAT.setCursor("default")},mouseMove:function(a){(a=this.__getDocumentElementAt(a.x,a.y))&&a.getLink()?CAAT.setCursor("pointer"):CAAT.setCursor("default")},mouseClick:function(a){this.clickCallback&&(a=this.__getDocumentElementAt(a.x,a.y),a.getLink()&& +this.clickCallback(a.getLink()))},setClickCallback:function(a){this.clickCallback=a;return this}}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.PathActor",aliases:["CAAT.PathActor"],depends:["CAAT.Foundation.Actor"],extendsClass:"CAAT.Foundation.Actor",extendsWith:{path:null,pathBoundingRectangle:null,bOutline:false,outlineColor:"black",onUpdateCallback:null,interactive:false,getPath:function(){return this.path},setPath:function(a){this.path=a;if(a!=null)this.pathBoundingRectangle=a.getBoundingBox(),this.setInteractive(this.interactive);return this},paint:function(a,b){CAAT.Foundation.UI.PathActor.superclass.paint.call(this, +a,b);if(this.path){var c=a.ctx;c.strokeStyle="#000";this.path.paint(a,this.interactive);if(this.bOutline)c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height)}},showBoundingBox:function(a,b){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= +a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= +a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= +a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ +2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, +this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); +CAAT.Module({defines:"CAAT.Foundation.UI.StarActor",aliases:["CAAT.StarActor"],depends:["CAAT.Foundation.ActorContainer"],extendsClass:"CAAT.Foundation.ActorContainer",extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";return this},nPeaks:0,maxRadius:0,minRadius:0,initialAngle:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap=a;return this},setLineJoin:function(a){this.lineJoin= +a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setFilled:function(){return this},setOutlined:function(){return this},setCompositeOp:function(a){this.compositeOp=a;return this},setInitialAngle:function(a){this.initialAngle=a;return this},initialize:function(a,b,c){this.setSize(2*b,2*b);this.nPeaks= +a;this.maxRadius=b;this.minRadius=c;return this},paint:function(a){var a=a.ctx,b=this.width/2,c=this.height/2,d=this.maxRadius,e=this.minRadius,f=b+d*Math.cos(this.initialAngle),g=c+d*Math.sin(this.initialAngle);a.lineWidth=this.lineWidth;if(this.lineCap)a.lineCap=this.lineCap;if(this.lineJoin)a.lineJoin=this.lineJoin;if(this.miterLimit)a.miterLimit=this.miterLimit;a.globalCompositeOperation=this.compositeOp;a.beginPath();a.moveTo(f,g);for(f=1;f>0,e.y>>0):c.translate(e.x,e.y);c.rotate(f);this.fill&&c.fillText(h,0,0);if(this.outline)c.beginPath(),c.lineWidth=this.lineWidth,c.strokeText(h,0,0);c.restore();d+=i}},drawSpriteText:function(a,b){null===this.path?this.font.drawText(this.text,a.ctx,0,0):this.drawSpriteTextOnPath(a,b)},drawSpriteTextOnPath:function(a,b){for(var c=a.ctx,d=this.sign*this.pathInterpolator.getPosition(b% +this.pathDuration/this.pathDuration).y*this.path.getLength(),e=new CAAT.Math.Point(0,0,0),f=new CAAT.Math.Point(0,0,0),g=0;g NOT solved.") + ); + }, + + removeDependency : function( modulename ) { + for( var i=0; i Can't extend non-existant class: "+this.baseClass ); + return; + } + + } else { + c= Class; + } + + c= c.extend( this.extendWith, this.constants, this.name, this.aliases, { decorated : this.decorated } ); + + console.log("Created module: "+this.name); + + if ( this.callback ) { + this.callback(); + } + + } + }; + + var ScriptFile= function(path, module) { + this.path= path; + this.module= module; + return this; + } + + ScriptFile.prototype= { + path : null, + processed: false, + module: null, + + setProcessed : function() { + this.processed= true; + }, + + isProcessed : function() { + return this.processed; + } + }; + + var ModuleManager= function() { + this.nodes= []; + this.loadedFiles= []; + this.path= {}; + this.solveListener= []; + this.orderedSolvedModules= []; + this.readyListener= []; + + return this; + }; + + ModuleManager.baseURL= ""; + ModuleManager.modulePath= {}; + ModuleManager.sortedModulePath= []; + ModuleManager.symbol= {}; + + ModuleManager.prototype= { + + nodes: null, // built nodes. + loadedFiles:null, // list of loaded files. avoid loading each file more than once + solveListener: null, // listener for a module solved + readyListener: null, // listener for all modules solved + orderedSolvedModules: null, // order in which modules where solved. + + addSolvedListener : function( modulename, callback ) { + this.solveListener.push( { + name : modulename, + callback : callback + }); + }, + + solved : function( module ) { + var i; + + for( i=0; i "+obj.defines+" onPrecreation"); + try { + obj.onPreCreate(); + } catch(e) { + console.log(" -> catched "+e+" on module "+obj.defines+" preCreation."); + } + } + + if (!obj.depends ) { + obj.depends= []; + } + + var dependencies= obj.depends; + + if ( dependencies ) { + if ( !isArray(dependencies) ) { + dependencies= [ dependencies ]; + obj.depends= dependencies; + } + } + + // elimina dependencias ya resueltas en otras cargas. + i=0; + while( i=}, // dependencies class names + * extendsClass{string}, // class to extend from + * extensdWith{object}, // actual prototype to extend + * aliases{Array} // other class names + * } + * + * @name Module + * @memberof CAAT + * @static + * + * @param obj {object} + */ + NS.Module= function loadModule(obj) { + + if (!obj.defines) { + console.error("Bad module definition: "+obj); + return; + } + + ensureNamespace(obj.defines); + + mm.module( obj ); + + }; + + /** + * @name ModuleManager + * @memberOf CAAT + * @namespace + */ + NS.ModuleManager= {}; + + /** + * Define global base position for modules structure. + * @param baseURL {string} + * @return {*} + */ + NS.ModuleManager.baseURL= function(baseURL) { + + if ( !baseURL ) { + return NS.Module; + } + + if (!baseURL.endsWith("/") ) { + baseURL= baseURL + "/"; + } + + ModuleManager.baseURL= baseURL; + return NS.ModuleManager; + }; + + /** + * Define a module path. Multiple module paths can be specified. + * @param module {string} + * @param path {string} + */ + NS.ModuleManager.setModulePath= function( module, path ) { + + if ( !path.endsWith("/") ) { + path= path + "/"; + } + + if ( !ModuleManager.modulePath[module] ) { + ModuleManager.modulePath[ module ]= path; + + ModuleManager.sortedModulePath.push( module ); + + /** + * Sort function so that CAAT.AB is below CAAT.AB.CD + */ + ModuleManager.sortedModulePath.sort( function(a,b) { + if (a==b) { + return 0; + } + return a + * @param p1 + * @param p2 + * @param p3 + */ + setCurve:function (p0, p1, p2, p3) { + + this.coordlist = []; + this.coordlist.push(p0); + this.coordlist.push(p1); + this.coordlist.push(p2); + this.coordlist.push(p3); + + this.update(); + + return this; + }, + /** + * Paint the contour by solving again the entire curve. + * @param director {CAAT.Director} + */ + paint:function (director) { + + var x1, y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; + + var ctx = director.ctx; + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x1, y1); + + var point = new CAAT.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + ctx.stroke(); + ctx.restore(); + + CAAT.Math.CatmullRom.superclass.paint.call(this, director); + }, + /** + * Solves the curve for any given parameter t. + * @param point {CAAT.Point} the point to store the solved value on the curve. + * @param t {number} a number in the range 0..1 + */ + solve:function (point, t) { + var c = this.coordlist; + + // Handy from CAKE. Thanks. + var af = ((-t + 2) * t - 1) * t * 0.5 + var bf = (((3 * t - 5) * t) * t + 2) * 0.5 + var cf = ((-3 * t + 4) * t + 1) * t * 0.5 + var df = ((t - 1) * t * t) * 0.5 + + point.x = c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y = c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; + + return point; + + }, + + applyAsPath:function (director) { + + var ctx = director.ctx; + + var point = new CAAT.Math.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + return this; + }, + + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 2 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 1 ]; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Curve + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Curve", + depends:["CAAT.Math.Point"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Math.Curve.prototype + */ + + /** + * A collection of CAAT.Math.Point objects. + */ + coordlist:null, + + /** + * Minimun solver step. + */ + k:0.05, + + /** + * Curve length. + */ + length:-1, + + /** + * If this segments belongs to an interactive path, the handlers will be this size. + */ + HANDLE_SIZE:20, + + /** + * Draw interactive handlers ? + */ + drawHandles:true, + + /** + * Paint the curve control points. + * @param director {CAAT.Director} + */ + paint:function (director) { + if (false === this.drawHandles) { + return; + } + + var cl = this.coordlist; + var ctx = director.ctx; + + // control points + ctx.save(); + ctx.beginPath(); + + ctx.strokeStyle = '#a0a0a0'; + ctx.moveTo(cl[0].x, cl[0].y); + ctx.lineTo(cl[1].x, cl[1].y); + ctx.stroke(); + if (this.cubic) { + ctx.moveTo(cl[2].x, cl[2].y); + ctx.lineTo(cl[3].x, cl[3].y); + ctx.stroke(); + } + + + ctx.globalAlpha = 0.5; + for (var i = 0; i < this.coordlist.length; i++) { + ctx.fillStyle = '#7f7f00'; + var w = this.HANDLE_SIZE / 2; + ctx.beginPath(); + ctx.arc(cl[i].x, cl[i].y, w, 0, 2 * Math.PI, false); + ctx.fill(); + } + + ctx.restore(); + }, + /** + * Signal the curve has been modified and recalculate curve length. + */ + update:function () { + this.calcLength(); + }, + /** + * This method must be overriden by subclasses. It is called whenever the curve must be solved for some time=t. + * The t parameter must be in the range 0..1 + * @param point {CAAT.Point} to store curve solution for t. + * @param t {number} + * @return {CAAT.Point} the point parameter. + */ + solve:function (point, t) { + }, + /** + * Get an array of points defining the curve contour. + * @param numSamples {number} number of segments to get. + */ + getContour:function (numSamples) { + var contour = [], i; + + for (i = 0; i <= numSamples; i++) { + var point = new CAAT.Math.Point(); + this.solve(point, i / numSamples); + contour.push(point); + } + + return contour; + }, + /** + * Calculates a curve bounding box. + * + * @param rectangle {CAAT.Rectangle} a rectangle to hold the bounding box. + * @return {CAAT.Rectangle} the rectangle parameter. + */ + getBoundingBox:function (rectangle) { + if (!rectangle) { + rectangle = new CAAT.Math.Rectangle(); + } + + // thanks yodesoft.com for spotting the first point is out of the BB + rectangle.setEmpty(); + rectangle.union(this.coordlist[0].x, this.coordlist[0].y); + + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + rectangle.union(pt.x, pt.y); + } + + return rectangle; + }, + /** + * Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k. This value defaults + * to .05 so at least 20 iterations will be performed. + * + * @return {number} the approximate curve length. + */ + calcLength:function () { + var x1, y1; + x1 = this.coordlist[0].x; + y1 = this.coordlist[0].y; + var llength = 0; + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + llength += Math.sqrt((pt.x - x1) * (pt.x - x1) + (pt.y - y1) * (pt.y - y1)); + x1 = pt.x; + y1 = pt.y; + } + + this.length = llength; + return llength; + }, + /** + * Return the cached curve length. + * @return {number} the cached curve length. + */ + getLength:function () { + return this.length; + }, + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 1 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 0 ]; + }, + + setPoints:function (points) { + }, + + setPoint:function (point, index) { + if (index >= 0 && index < this.coordlist.length) { + this.coordlist[index] = point; + } + }, + /** + * + * @param director <=CAAT.Director> + */ + applyAsPath:function (director) { + } + } + } + +}); + +CAAT.Module({ + + /** + * @name Dimension + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Dimension", + aliases:["CAAT.Dimension"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Dimension.prototype + */ + + /** + * Width dimension. + */ + width:0, + + /** + * Height dimension. + */ + height:0, + + __init:function (w, h) { + this.width = w; + this.height = h; + return this; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + + +CAAT.Module({ + + /** + * @name Matrix + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Matrix", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Matrix"], + onCreate : function() { + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Math.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Math.Matrix.prototype.transformRenderingContextSet_NoClamp; + }, + constants : { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + setCoordinateClamping : function( clamp ) { + if ( clamp ) { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + } else { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + } + }, + /** + * Create a scale matrix. + * @param scalex {number} x scale magnitude. + * @param scaley {number} y scale magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + scale:function (scalex, scaley) { + var m = new CAAT.Math.Matrix(); + + m.matrix[0] = scalex; + m.matrix[4] = scaley; + + return m; + }, + /** + * Create a new rotation matrix and set it up for the specified angle in radians. + * @param angle {number} + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + rotate:function (angle) { + var m = new CAAT.Math.Matrix(); + m.setRotation(angle); + return m; + }, + /** + * Create a translation matrix. + * @param x {number} x translation magnitude. + * @param y {number} y translation magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * @static + * + */ + translate:function (x, y) { + var m = new CAAT.Math.Matrix(); + + m.matrix[2] = x; + m.matrix[5] = y; + + return m; + } + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + /** + * An array of 9 numbers. + */ + matrix:null, + + __init:function () { + this.matrix = [ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 ]; + + if (typeof Float32Array !== "undefined") { + this.matrix = new Float32Array(this.matrix); + } + + return this; + }, + + /** + * Transform a point by this matrix. The parameter point will be modified with the transformation values. + * @param point {CAAT.Point}. + * @return {CAAT.Point} the parameter point. + */ + transformCoord:function (point) { + var x = point.x; + var y = point.y; + + var tm = this.matrix; + + point.x = x * tm[0] + y * tm[1] + tm[2]; + point.y = x * tm[3] + y * tm[4] + tm[5]; + + return point; + }, + + setRotation:function (angle) { + + this.identity(); + + var tm = this.matrix; + var c = Math.cos(angle); + var s = Math.sin(angle); + tm[0] = c; + tm[1] = -s; + tm[3] = s; + tm[4] = c; + + return this; + }, + + setScale:function (scalex, scaley) { + this.identity(); + + this.matrix[0] = scalex; + this.matrix[4] = scaley; + + return this; + }, + + /** + * Sets this matrix as a translation matrix. + * @param x + * @param y + */ + setTranslate:function (x, y) { + this.identity(); + + this.matrix[2] = x; + this.matrix[5] = y; + + return this; + }, + /** + * Copy into this matrix the given matrix values. + * @param matrix {CAAT.Matrix} + * @return this + */ + copy:function (matrix) { + matrix = matrix.matrix; + + var tmatrix = this.matrix; + tmatrix[0] = matrix[0]; + tmatrix[1] = matrix[1]; + tmatrix[2] = matrix[2]; + tmatrix[3] = matrix[3]; + tmatrix[4] = matrix[4]; + tmatrix[5] = matrix[5]; + tmatrix[6] = matrix[6]; + tmatrix[7] = matrix[7]; + tmatrix[8] = matrix[8]; + + return this; + }, + /** + * Set this matrix to the identity matrix. + * @return this + */ + identity:function () { + + var m = this.matrix; + m[0] = 1.0; + m[1] = 0.0; + m[2] = 0.0; + + m[3] = 0.0; + m[4] = 1.0; + m[5] = 0.0; + + m[6] = 0.0; + m[7] = 0.0; + m[8] = 1.0; + + return this; + }, + /** + * Multiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + multiply:function (m) { + + var tm = this.matrix; + var mm = m.matrix; + + var tm0 = tm[0]; + var tm1 = tm[1]; + var tm2 = tm[2]; + var tm3 = tm[3]; + var tm4 = tm[4]; + var tm5 = tm[5]; + var tm6 = tm[6]; + var tm7 = tm[7]; + var tm8 = tm[8]; + + var mm0 = mm[0]; + var mm1 = mm[1]; + var mm2 = mm[2]; + var mm3 = mm[3]; + var mm4 = mm[4]; + var mm5 = mm[5]; + var mm6 = mm[6]; + var mm7 = mm[7]; + var mm8 = mm[8]; + + tm[0] = tm0 * mm0 + tm1 * mm3 + tm2 * mm6; + tm[1] = tm0 * mm1 + tm1 * mm4 + tm2 * mm7; + tm[2] = tm0 * mm2 + tm1 * mm5 + tm2 * mm8; + tm[3] = tm3 * mm0 + tm4 * mm3 + tm5 * mm6; + tm[4] = tm3 * mm1 + tm4 * mm4 + tm5 * mm7; + tm[5] = tm3 * mm2 + tm4 * mm5 + tm5 * mm8; + tm[6] = tm6 * mm0 + tm7 * mm3 + tm8 * mm6; + tm[7] = tm6 * mm1 + tm7 * mm4 + tm8 * mm7; + tm[8] = tm6 * mm2 + tm7 * mm5 + tm8 * mm8; + + return this; + }, + /** + * Premultiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + premultiply:function (m) { + + var m00 = m.matrix[0] * this.matrix[0] + m.matrix[1] * this.matrix[3] + m.matrix[2] * this.matrix[6]; + var m01 = m.matrix[0] * this.matrix[1] + m.matrix[1] * this.matrix[4] + m.matrix[2] * this.matrix[7]; + var m02 = m.matrix[0] * this.matrix[2] + m.matrix[1] * this.matrix[5] + m.matrix[2] * this.matrix[8]; + + var m10 = m.matrix[3] * this.matrix[0] + m.matrix[4] * this.matrix[3] + m.matrix[5] * this.matrix[6]; + var m11 = m.matrix[3] * this.matrix[1] + m.matrix[4] * this.matrix[4] + m.matrix[5] * this.matrix[7]; + var m12 = m.matrix[3] * this.matrix[2] + m.matrix[4] * this.matrix[5] + m.matrix[5] * this.matrix[8]; + + var m20 = m.matrix[6] * this.matrix[0] + m.matrix[7] * this.matrix[3] + m.matrix[8] * this.matrix[6]; + var m21 = m.matrix[6] * this.matrix[1] + m.matrix[7] * this.matrix[4] + m.matrix[8] * this.matrix[7]; + var m22 = m.matrix[6] * this.matrix[2] + m.matrix[7] * this.matrix[5] + m.matrix[8] * this.matrix[8]; + + this.matrix[0] = m00; + this.matrix[1] = m01; + this.matrix[2] = m02; + + this.matrix[3] = m10; + this.matrix[4] = m11; + this.matrix[5] = m12; + + this.matrix[6] = m20; + this.matrix[7] = m21; + this.matrix[8] = m22; + + + return this; + }, + /** + * Creates a new inverse matrix from this matrix. + * @return {CAAT.Matrix} an inverse matrix. + */ + getInverse:function (out) { + var tm = this.matrix; + + var m00 = tm[0]; + var m01 = tm[1]; + var m02 = tm[2]; + var m10 = tm[3]; + var m11 = tm[4]; + var m12 = tm[5]; + var m20 = tm[6]; + var m21 = tm[7]; + var m22 = tm[8]; + + var newMatrix = out || new CAAT.Math.Matrix(); + + var determinant = m00 * (m11 * m22 - m21 * m12) - m10 * (m01 * m22 - m21 * m02) + m20 * (m01 * m12 - m11 * m02); + if (determinant === 0) { + return null; + } + + var m = newMatrix.matrix; + + m[0] = m11 * m22 - m12 * m21; + m[1] = m02 * m21 - m01 * m22; + m[2] = m01 * m12 - m02 * m11; + + m[3] = m12 * m20 - m10 * m22; + m[4] = m00 * m22 - m02 * m20; + m[5] = m02 * m10 - m00 * m12; + + m[6] = m10 * m21 - m11 * m20; + m[7] = m01 * m20 - m00 * m21; + m[8] = m00 * m11 - m01 * m10; + + newMatrix.multiplyScalar(1 / determinant); + + return newMatrix; + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i; + + for (i = 0; i < 9; i++) { + this.matrix[i] *= scalar; + } + + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_NoClamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_NoClamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_Clamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_Clamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + setModelViewMatrix:function ( x, y, sx, sy, r ) { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + mm = this.matrix; + + mm0 = 1; + mm1 = 0; + mm3 = 0; + mm4 = 1; + + mm2 = x; + mm5 = y; + + c = Math.cos(r); + s = Math.sin(r); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + } + } +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Matrix3 + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Matrix3", + aliases:["CAAT.Matrix3"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix3.prototype + */ + + /** + * An Array of 4 Array of 4 numbers. + */ + matrix:null, + + /** + * An array of 16 numbers. + */ + fmatrix:null, + + __init:function () { + this.matrix = [ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1] + ]; + + this.fmatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + + return this; + }, + + transformCoord:function (point) { + var x = point.x; + var y = point.y; + var z = point.z; + + point.x = x * this.matrix[0][0] + y * this.matrix[0][1] + z * this.matrix[0][2] + this.matrix[0][3]; + point.y = x * this.matrix[1][0] + y * this.matrix[1][1] + z * this.matrix[1][2] + this.matrix[1][3]; + point.z = x * this.matrix[2][0] + y * this.matrix[2][1] + z * this.matrix[2][2] + this.matrix[2][3]; + + return point; + }, + initialize:function (x0, y0, z0, x1, y1, z1, x2, y2, z2) { + this.identity(); + this.matrix[0][0] = x0; + this.matrix[0][1] = y0; + this.matrix[0][2] = z0; + + this.matrix[1][0] = x1; + this.matrix[1][1] = y1; + this.matrix[1][2] = z1; + + this.matrix[2][0] = x2; + this.matrix[2][1] = y2; + this.matrix[2][2] = z2; + + return this; + }, + initWithMatrix:function (matrixData) { + this.matrix = matrixData; + return this; + }, + flatten:function () { + var d = this.fmatrix; + var s = this.matrix; + d[ 0] = s[0][0]; + d[ 1] = s[1][0]; + d[ 2] = s[2][0]; + d[ 3] = s[3][0]; + + d[ 4] = s[0][1]; + d[ 5] = s[1][1]; + d[ 6] = s[2][1]; + d[ 7] = s[2][1]; + + d[ 8] = s[0][2]; + d[ 9] = s[1][2]; + d[10] = s[2][2]; + d[11] = s[3][2]; + + d[12] = s[0][3]; + d[13] = s[1][3]; + d[14] = s[2][3]; + d[15] = s[3][3]; + + return this.fmatrix; + }, + + /** + * Set this matrix to identity matrix. + * @return this + */ + identity:function () { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = (i === j) ? 1.0 : 0.0; + } + } + + return this; + }, + /** + * Get this matri'x internal representation data. The bakced structure is a 4x4 array of number. + */ + getMatrix:function () { + return this.matrix; + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xy axis. + * + * @param xy {Number} radians to rotate. + * + * @return this + */ + rotateXY:function (xy) { + return this.rotate(xy, 0, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xz axis. + * + * @param xz {Number} radians to rotate. + * + * @return this + */ + rotateXZ:function (xz) { + return this.rotate(0, xz, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate aroind + * yz axis. + * + * @param yz {Number} radians to rotate. + * + * @return this + */ + rotateYZ:function (yz) { + return this.rotate(0, 0, yz); + }, + /** + * + * @param xy + * @param xz + * @param yz + */ + setRotate:function (xy, xz, yz) { + var m = this.rotate(xy, xz, yz); + this.copy(m); + return this; + }, + /** + * Creates a matrix to represent arbitrary rotations around the given planes. + * @param xy {number} radians to rotate around xy plane. + * @param xz {number} radians to rotate around xz plane. + * @param yz {number} radians to rotate around yz plane. + * + * @return {CAAT.Matrix3} a newly allocated matrix. + * @static + */ + rotate:function (xy, xz, yz) { + var res = new CAAT.Math.Matrix3(); + var s, c, m; + + if (xy !== 0) { + m = new CAAT.Math.Math.Matrix3(); + s = Math.sin(xy); + c = Math.cos(xy); + m.matrix[1][1] = c; + m.matrix[1][2] = -s; + m.matrix[2][1] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (xz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(xz); + c = Math.cos(xz); + m.matrix[0][0] = c; + m.matrix[0][2] = -s; + m.matrix[2][0] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (yz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(yz); + c = Math.cos(yz); + m.matrix[0][0] = c; + m.matrix[0][1] = -s; + m.matrix[1][0] = s; + m.matrix[1][1] = c; + res.multiply(m); + } + + return res; + }, + /** + * Creates a new matrix being a copy of this matrix. + * @return {CAAT.Matrix3} a newly allocated matrix object. + */ + getClone:function () { + var m = new CAAT.Math.Matrix3(); + m.copy(this); + return m; + }, + /** + * Multiplies this matrix by another matrix. + * + * @param n {CAAT.Matrix3} a CAAT.Matrix3 object. + * @return this + */ + multiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20 + n03 * m30; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21 + n03 * m31; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22 + n03 * m32; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03 * m33; + + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20 + n13 * m30; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21 + n13 * m31; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22 + n13 * m32; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13 * m33; + + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20 + n23 * m30; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21 + n23 * m31; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22 + n23 * m32; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23 * m33; + + return this; + }, + /** + * Pre multiplies this matrix by a given matrix. + * + * @param m {CAAT.Matrix3} a CAAT.Matrix3 object. + * + * @return this + */ + premultiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03; + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13; + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23; + + return this; + }, + /** + * Set this matrix translation values to be the given parameters. + * + * @param x {number} x component of translation point. + * @param y {number} y component of translation point. + * @param z {number} z component of translation point. + * + * @return this + */ + setTranslate:function (x, y, z) { + this.identity(); + this.matrix[0][3] = x; + this.matrix[1][3] = y; + this.matrix[2][3] = z; + return this; + }, + /** + * Create a translation matrix. + * @param x {number} + * @param y {number} + * @param z {number} + * @return {CAAT.Matrix3} a new matrix. + */ + translate:function (x, y, z) { + var m = new CAAT.Math.Matrix3(); + m.setTranslate(x, y, z); + return m; + }, + setScale:function (sx, sy, sz) { + this.identity(); + this.matrix[0][0] = sx; + this.matrix[1][1] = sy; + this.matrix[2][2] = sz; + return this; + }, + scale:function (sx, sy, sz) { + var m = new CAAT.Math.Matrix3(); + m.setScale(sx, sy, sz); + return m; + }, + /** + * Set this matrix as the rotation matrix around the given axes. + * @param xy {number} radians of rotation around z axis. + * @param xz {number} radians of rotation around y axis. + * @param yz {number} radians of rotation around x axis. + * + * @return this + */ + rotateModelView:function (xy, xz, yz) { + var sxy = Math.sin(xy); + var sxz = Math.sin(xz); + var syz = Math.sin(yz); + var cxy = Math.cos(xy); + var cxz = Math.cos(xz); + var cyz = Math.cos(yz); + + this.matrix[0][0] = cxz * cxy; + this.matrix[0][1] = -cxz * sxy; + this.matrix[0][2] = sxz; + this.matrix[0][3] = 0; + this.matrix[1][0] = syz * sxz * cxy + sxy * cyz; + this.matrix[1][1] = cyz * cxy - syz * sxz * sxy; + this.matrix[1][2] = -syz * cxz; + this.matrix[1][3] = 0; + this.matrix[2][0] = syz * sxy - cyz * sxz * cxy; + this.matrix[2][1] = cyz * sxz * sxy + syz * cxy; + this.matrix[2][2] = cyz * cxz; + this.matrix[2][3] = 0; + this.matrix[3][0] = 0; + this.matrix[3][1] = 0; + this.matrix[3][2] = 0; + this.matrix[3][3] = 1; + + return this; + }, + /** + * Copy a given matrix values into this one's. + * @param m {CAAT.Matrix} a matrix + * + * @return this + */ + copy:function (m) { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = m.matrix[i][j]; + } + } + + return this; + }, + /** + * Calculate this matrix's determinant. + * @return {number} matrix determinant. + */ + calculateDeterminant:function () { + + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + return m14 * m22 * m33 * m41 + + m12 * m24 * m33 * m41 + + m14 * m23 * m31 * m42 + + m13 * m24 * m31 * m42 + + + m13 * m21 * m34 * m42 + + m11 * m23 * m34 * m42 + + m14 * m21 * m32 * m43 + + m11 * m24 * m32 * m43 + + + m13 * m22 * m31 * m44 + + m12 * m23 * m31 * m44 + + m12 * m21 * m33 * m44 + + m11 * m22 * m33 * m44 + + + m14 * m23 * m32 * m41 - + m13 * m24 * m32 * m41 - + m13 * m22 * m34 * m41 - + m12 * m23 * m34 * m41 - + + m14 * m21 * m33 * m42 - + m11 * m24 * m33 * m42 - + m14 * m22 * m31 * m43 - + m12 * m24 * m31 * m43 - + + m12 * m21 * m34 * m43 - + m11 * m22 * m34 * m43 - + m13 * m21 * m32 * m44 - + m11 * m23 * m32 * m44; + }, + /** + * Return a new matrix which is this matrix's inverse matrix. + * @return {CAAT.Matrix3} a new matrix. + */ + getInverse:function () { + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + var m2 = new CAAT.Math.Matrix3(); + m2.matrix[0][0] = m23 * m34 * m42 + m24 * m32 * m43 + m22 * m33 * m44 - m24 * m33 * m42 - m22 * m34 * m43 - m23 * m32 * m44; + m2.matrix[0][1] = m14 * m33 * m42 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44 - m13 * m34 * m42 - m14 * m32 * m43; + m2.matrix[0][2] = m13 * m24 * m42 + m12 * m23 * m44 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 - m14 * m23 * m42; + m2.matrix[0][3] = m14 * m23 * m32 + m12 * m24 * m33 + m13 * m22 * m34 - m13 * m24 * m32 - m14 * m22 * m33 - m12 * m23 * m34; + + m2.matrix[1][0] = m24 * m33 * m41 + m21 * m34 * m43 + m23 * m31 * m44 - m23 * m34 * m41 - m24 * m31 * m43 - m21 * m33 * m44; + m2.matrix[1][1] = m13 * m34 * m41 + m14 * m31 * m43 + m11 * m33 * m44 - m14 * m33 * m41 - m11 * m34 * m43 - m13 * m31 * m44; + m2.matrix[1][2] = m14 * m23 * m41 + m11 * m24 * m43 + m13 * m21 * m44 - m13 * m24 * m41 - m14 * m21 * m43 - m11 * m23 * m44; + m2.matrix[1][3] = m13 * m24 * m31 + m14 * m21 * m33 + m11 * m23 * m34 - m14 * m23 * m31 - m11 * m24 * m33 - m13 * m21 * m34; + + m2.matrix[2][0] = m22 * m34 * m41 + m24 * m31 * m42 + m21 * m32 * m44 - m24 * m32 * m41 - m21 * m34 * m42 - m22 * m31 * m44; + m2.matrix[2][1] = m14 * m32 * m41 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44 - m12 * m34 * m41 - m14 * m31 * m42; + m2.matrix[2][2] = m13 * m24 * m41 + m14 * m21 * m42 + m11 * m22 * m44 - m14 * m22 * m41 - m11 * m24 * m42 - m12 * m21 * m44; + m2.matrix[2][3] = m14 * m22 * m31 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34 - m12 * m24 * m31 - m14 * m21 * m32; + + m2.matrix[3][0] = m23 * m32 * m41 + m21 * m33 * m42 + m22 * m31 * m43 - m22 * m33 * m41 - m23 * m31 * m42 - m21 * m32 * m43; + m2.matrix[3][1] = m12 * m33 * m41 + m13 * m31 * m42 + m11 * m32 * m43 - m13 * m32 * m41 - m11 * m33 * m42 - m12 * m31 * m43; + m2.matrix[3][2] = m13 * m22 * m41 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43 - m12 * m23 * m41 - m13 * m21 * m42; + m2.matrix[3][3] = m12 * m23 * m31 + m13 * m21 * m32 + m11 * m22 * m33 - m13 * m22 * m31 - m11 * m23 * m32 - m12 * m21 * m33; + + return m2.multiplyScalar(1 / this.calculateDeterminant()); + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i, j; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + this.matrix[i][j] *= scalar; + } + } + + return this; + } + + } + } + +}); +/** + * See LICENSE file. + * + **/ +CAAT.Module({ + + /** + * @name Point + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Point", + aliases:["CAAT.Point"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Point.prototype + */ + + + /** + * point x coordinate. + */ + x:0, + + /** + * point y coordinate. + */ + y:0, + + /** + * point z coordinate. + */ + z:0, + + __init:function (xpos, ypos, zpos) { + this.x = xpos; + this.y = ypos; + this.z = zpos || 0; + return this; + }, + + /** + * Sets this point coordinates. + * @param x {number} + * @param y {number} + * @param z {number=} + * + * @return this + */ + set:function (x, y, z) { + this.x = x; + this.y = y; + this.z = z || 0; + return this; + }, + /** + * Create a new CAAT.Point equal to this one. + * @return {CAAT.Point} + */ + clone:function () { + var p = new CAAT.Math.Point(this.x, this.y, this.z); + return p; + }, + /** + * Translate this point to another position. The final point will be (point.x+x, point.y+y) + * @param x {number} + * @param y {number} + * + * @return this + */ + translate:function (x, y, z) { + this.x += x; + this.y += y; + this.z += z; + + return this; + }, + /** + * Translate this point to another point. + * @param aPoint {CAAT.Point} + * @return this + */ + translatePoint:function (aPoint) { + this.x += aPoint.x; + this.y += aPoint.y; + this.z += aPoint.z; + return this; + }, + /** + * Substract a point from this one. + * @param aPoint {CAAT.Point} + * @return this + */ + subtract:function (aPoint) { + this.x -= aPoint.x; + this.y -= aPoint.y; + this.z -= aPoint.z; + return this; + }, + /** + * Multiply this point by a scalar. + * @param factor {number} + * @return this + */ + multiply:function (factor) { + this.x *= factor; + this.y *= factor; + this.z *= factor; + return this; + }, + /** + * Rotate this point by an angle. The rotation is held by (0,0) coordinate as center. + * @param angle {number} + * @return this + */ + rotate:function (angle) { + var x = this.x, y = this.y; + this.x = x * Math.cos(angle) - Math.sin(angle) * y; + this.y = x * Math.sin(angle) + Math.cos(angle) * y; + this.z = 0; + return this; + }, + /** + * + * @param angle {number} + * @return this + */ + setAngle:function (angle) { + var len = this.getLength(); + this.x = Math.cos(angle) * len; + this.y = Math.sin(angle) * len; + this.z = 0; + return this; + }, + /** + * + * @param length {number} + * @return this + */ + setLength:function (length) { + var len = this.getLength(); + if (len)this.multiply(length / len); + else this.x = this.y = this.z = length; + return this; + }, + /** + * Normalize this point, that is, both set coordinates proportionally to values raning 0..1 + * @return this + */ + normalize:function () { + var len = this.getLength(); + this.x /= len; + this.y /= len; + this.z /= len; + return this; + }, + /** + * Return the angle from -Pi to Pi of this point. + * @return {number} + */ + getAngle:function () { + return Math.atan2(this.y, this.x); + }, + /** + * Set this point coordinates proportinally to a maximum value. + * @param max {number} + * @return this + */ + limit:function (max) { + var aLenthSquared = this.getLengthSquared(); + if (aLenthSquared + 0.01 > max * max) { + var aLength = Math.sqrt(aLenthSquared); + this.x = (this.x / aLength) * max; + this.y = (this.y / aLength) * max; + this.z = (this.z / aLength) * max; + } + return this; + }, + /** + * Get this point's lenght. + * @return {number} + */ + getLength:function () { + var length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + if (length < 0.005 && length > -0.005) return 0.000001; + return length; + + }, + /** + * Get this point's squared length. + * @return {number} + */ + getLengthSquared:function () { + var lengthSquared = this.x * this.x + this.y * this.y + this.z * this.z; + if (lengthSquared < 0.005 && lengthSquared > -0.005) return 0; + return lengthSquared; + }, + /** + * Get the distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistance:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + }, + /** + * Get the squared distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistanceSquared:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ; + }, + /** + * Get a string representation. + * @return {string} + */ + toString:function () { + return "(CAAT.Math.Point)" + + " x:" + String(Math.round(Math.floor(this.x * 10)) / 10) + + " y:" + String(Math.round(Math.floor(this.y * 10)) / 10) + + " z:" + String(Math.round(Math.floor(this.z * 10)) / 10); + } + } + } +}); +/** + * See LICENSE file. + * + */ + + +CAAT.Module( { + + /** + * @name Rectangle + * @memberOf CAAT.Math + * @constructor + */ + + + defines: "CAAT.Math.Rectangle", + aliases: ["CAAT.Rectangle"], + extendsWith: function() { + return { + + /** + * @lends CAAT.Math.Rectangle.prototype + */ + + __init : function( x,y,w,h ) { + if ( arguments.length!==4 ) { + this.setEmpty(); + } else { + this.setLocation(x,y); + this.setDimension(w,h); + } + }, + + /** + * Rectangle x position. + */ + x: 0, + + /** + * Rectangle y position. + */ + y: 0, + + /** + * Rectangle x1 position. + */ + x1: 0, + + /** + * Rectangle y1 position. + */ + y1: 0, + + /** + * Rectangle width. + */ + width: -1, + + /** + * Rectangle height. + */ + height: -1, + + setEmpty : function() { + this.width= -1; + this.height= -1; + this.x= 0; + this.y= 0; + this.x1= 0; + this.y1= 0; + return this; + }, + /** + * Set this rectangle's location. + * @param x {number} + * @param y {number} + */ + setLocation: function( x,y ) { + this.x= x; + this.y= y; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + /** + * Set this rectangle's dimension. + * @param w {number} + * @param h {number} + */ + setDimension : function( w,h ) { + this.width= w; + this.height= h; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + setBounds : function( x,y,w,h ) { + this.setLocation( x, y ); + this.setDimension( w, h ); + return this; + }, + /** + * Return whether the coordinate is inside this rectangle. + * @param px {number} + * @param py {number} + * + * @return {boolean} + */ + contains : function(px,py) { + //return px>=0 && px=0 && py=this.x && px=this.y && pythis.y1 ) { + this.y1= py; + } + if ( px>this.x1 ){ + this.x1= px; + } + + this.width= this.x1-this.x; + this.height= this.y1-this.y; + }, + unionRectangle : function( rectangle ) { + this.union( rectangle.x , rectangle.y ); + this.union( rectangle.x1, rectangle.y ); + this.union( rectangle.x, rectangle.y1 ); + this.union( rectangle.x1, rectangle.y1 ); + return this; + }, + intersects : function( r ) { + if ( r.isEmpty() || this.isEmpty() ) { + return false; + } + + if ( r.x1<= this.x ) { + return false; + } + if ( r.x >= this.x1 ) { + return false; + } + if ( r.y1<= this.y ) { + return false; + } + + return r.y < this.y1; + }, + + intersectsRect : function( x,y,w,h ) { + if ( -1===w || -1===h ) { + return false; + } + + var x1= x+w-1; + var y1= y+h-1; + + if ( x1< this.x ) { + return false; + } + if ( x > this.x1 ) { + return false; + } + if ( y1< this.y ) { + return false; + } + return y <= this.y1; + + }, + + intersect : function( i, r ) { + if ( typeof r==='undefined' ) { + r= new CAAT.Math.Rectangle(); + } + + r.x= Math.max( this.x, i.x ); + r.y= Math.max( this.y, i.y ); + r.x1=Math.min( this.x1, i.x1 ); + r.y1=Math.min( this.y1, i.y1 ); + r.width= r.x1-r.x; + r.height=r.y1-r.y; + + return r; + } + } + } +}); +/** + * See LICENSE file. + * + * Partially based on Robert Penner easing equations. + * http://www.robertpenner.com/easing/ + * + * + **/ + +CAAT.Module({ + + /** + * @name Interpolator + * @memberOf CAAT.Behavior + * @constructor + */ + + defines:"CAAT.Behavior.Interpolator", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Interpolator"], + constants : { + /** + * @lends CAAT.Behavior.Interpolator + */ + + enumerateInterpolators: function () { + return [ + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, false), 'Linear pingpong=false, inverse=false', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, false), 'Linear pingpong=true, inverse=false', + + new CAAT.Behavior.Interpolator().createBackOutInterpolator(false), 'BackOut pingpong=true, inverse=false', + new CAAT.Behavior.Interpolator().createBackOutInterpolator(true), 'BackOut pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, true), 'Linear pingpong=false, inverse=true', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, true), 'Linear pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, false), 'ExponentialIn pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, false), 'ExponentialOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, false), 'ExponentialInOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, true), 'ExponentialIn pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, true), 'ExponentialOut pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, true), 'ExponentialInOut pingpong=true, exponent=2', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, false), 'ExponentialIn pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, false), 'ExponentialOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, false), 'ExponentialInOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, true), 'ExponentialIn pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, true), 'ExponentialOut pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, true), 'ExponentialInOut pingpong=true, exponent=4', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, false), 'ExponentialIn pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, false), 'ExponentialOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, false), 'ExponentialInOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, true), 'ExponentialIn pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, true), 'ExponentialOut pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, true), 'ExponentialInOut pingpong=true, exponent=6', + + new CAAT.Behavior.Interpolator().createBounceInInterpolator(false), 'BounceIn pingpong=false', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(false), 'BounceOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(false), 'BounceInOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInInterpolator(true), 'BounceIn pingpong=true', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(true), 'BounceOut pingpong=true', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(true), 'BounceInOut pingpong=true', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, false), 'ElasticIn pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, false), 'ElasticOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, false), 'ElasticInOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, true), 'ElasticIn pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, true), 'ElasticOut pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, true), 'ElasticInOut pingpong=true, amp=1.1, d=.4', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, false), 'ElasticIn pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, false), 'ElasticOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, false), 'ElasticInOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, true), 'ElasticIn pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, true), 'ElasticOut pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, true), 'ElasticInOut pingpong=true, amp=1.0, d=.2' + ]; + }, + + parse : function( obj ) { + var name= "create"+obj.type+"Interpolator"; + var interpolator= new CAAT.Behavior.Interpolator(); + try { + interpolator[name].apply( interpolator, obj.params||[] ); + } catch(e) { + interpolator.createLinearInterpolator(false, false); + } + + return interpolator; + } + + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Interpolator.prototype + */ + + interpolated:null, // a coordinate holder for not building a new CAAT.Point for each interpolation call. + paintScale:90, // the size of the interpolation draw on screen in pixels. + + __init:function () { + this.interpolated = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * Set a linear interpolation function. + * + * @param bPingPong {boolean} + * @param bInverse {boolean} will values will be from 1 to 0 instead of 0 to 1 ?. + */ + createLinearInterpolator:function (bPingPong, bInverse) { + /** + * Linear and inverse linear interpolation function. + * @param time {number} + */ + this.getPosition = function getPosition(time) { + + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (bInverse !== null && bInverse) { + time = 1 - time; + } + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + + createBackOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = time - 1; + var overshoot = 1.70158; + + return this.interpolated.set( + orgTime, + time * time * ((overshoot + 1) * time + overshoot) + 1); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be Math.pow(time,exponent). + * This function starts with 0 and ends in values of 1. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, Math.pow(time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be 1-Math.pow(time,exponent). + * This function starts with 1 and ends in values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, 1 - Math.pow(1 - time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. Two functions will apply: + * Math.pow(time*2,exponent)/2 for the first half of the function (t<0.5) and + * 1-Math.abs(Math.pow(time*2-2,exponent))/2 for the second half (t>=.5) + * This function starts with 0 and goes to values of 1 and ends with values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + if (time * 2 < 1) { + return this.interpolated.set(orgTime, Math.pow(time * 2, exponent) / 2); + } + + return this.interpolated.set(orgTime, 1 - Math.abs(Math.pow(time * 2 - 2, exponent)) / 2); + }; + + return this; + }, + /** + * Creates a Quadric bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createQuadricBezierInterpolator:function (p0, p1, p2, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = (1 - time) * (1 - time) * p0.y + 2 * (1 - time) * time * p1.y + time * time * p2.y; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + /** + * Creates a Cubic bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param p3 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createCubicBezierInterpolator:function (p0, p1, p2, p3, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var t2 = time * time; + var t3 = time * t2; + + time = (p0.y + time * (-p0.y * 3 + time * (3 * p0.y - + p0.y * time))) + time * (3 * p1.y + time * (-6 * p1.y + + p1.y * 3 * time)) + t2 * (p2.y * 3 - p2.y * 3 * time) + + p3.y * t3; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + createElasticOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + (amplitude * Math.pow(2, -10 * time) * Math.sin((time - s) * (2 * Math.PI) / p) + 1 )); + }; + return this; + }, + createElasticInInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + -(amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p) )); + }; + + return this; + }, + createElasticInOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + time *= 2; + if (time <= 1) { + return this.interpolated.set( + time, + -0.5 * (amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + } + + return this.interpolated.set( + time, + 1 + 0.5 * (amplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + }; + + return this; + }, + /** + * @param time {number} + * @private + */ + bounce:function (time) { + if ((time /= 1) < (1 / 2.75)) { + return {x:time, y:7.5625 * time * time}; + } else if (time < (2 / 2.75)) { + return {x:time, y:7.5625 * (time -= (1.5 / 2.75)) * time + 0.75}; + } else if (time < (2.5 / 2.75)) { + return {x:time, y:7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375}; + } else { + return {x:time, y:7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375}; + } + }, + createBounceOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.bounce(time); + }; + + return this; + }, + createBounceInInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + var r = this.bounce(1 - time); + r.y = 1 - r.y; + return r; + }; + + return this; + }, + createBounceInOutInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var r; + if (time < 0.5) { + r = this.bounce(1 - time * 2); + r.y = (1 - r.y) * 0.5; + return r; + } + r = this.bounce(time * 2 - 1, bPingPong); + r.y = r.y * 0.5 + 0.5; + return r; + }; + + return this; + }, + + /** + * Paints an interpolator on screen. + * @param ctx {CanvasRenderingContext} + */ + paint:function (ctx) { + + ctx.save(); + ctx.beginPath(); + + ctx.moveTo(0, this.getPosition(0).y * this.paintScale); + + for (var i = 0; i <= this.paintScale; i++) { + ctx.lineTo(i, this.getPosition(i / this.paintScale).y * this.paintScale); + } + + ctx.strokeStyle = 'black'; + ctx.stroke(); + ctx.restore(); + }, + + /** + * Gets an array of coordinates which define the polyline of the intepolator's curve contour. + * Values for both coordinates range from 0 to 1. + * @param iSize {number} an integer indicating the number of contour segments. + * @return Array. of object of the form {x:float, y:float}. + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } +}); +/** + * See LICENSE file. + * + * Behaviors are keyframing elements. + * By using a BehaviorContainer, you can specify different actions on any animation Actor. + * An undefined number of Behaviors can be defined for each Actor. + * + * There're the following Behaviors: + * + AlphaBehavior: controls container/actor global alpha. + * + RotateBehavior: takes control of rotation affine transform. + * + ScaleBehavior: takes control of scaling on x and y axis affine transform. + * + Scale1Behavior: takes control of scaling on x or y axis affine transform. + * + PathBehavior: takes control of translating an Actor/ActorContainer across a path [ie. pathSegment collection]. + * + GenericBehavior: applies a behavior to any given target object's property, or notifies a callback. + * + * + **/ + +CAAT.Module({ + + /** + * + * Namespace for all behavior-based actor properties instrumenter objects. + * + * @name Behavior + * @memberOf CAAT + * @namespace + */ + + /** + * + * The BaseBehavior is the base class of all Behavior modifiers: + * + *
  • AlphaBehabior + *
  • RotateBehavior + *
  • ScaleBehavior + *
  • Scale1Behavior + *
  • PathBehavior + *
  • GenericBehavior + *
  • ContainerBehavior + * + * Behavior base class. + * + *

    + * A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator. + * In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same + * time interval. + *

    + * A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified + * period. + *

    + * A behavior is guaranteed to notify (if any observer is registered) on behavior expiration. + *

    + * A behavior can keep an unlimited observers. Observers are objects of the form: + *

    + * + * { + * behaviorExpired : function( behavior, time, actor); + * behaviorApplied : function( behavior, time, normalizedTime, actor, value); + * } + * + *

    + * behaviorExpired: function( behavior, time, actor). This method will be called for any registered observer when + * the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time + * granurality. + *

    + * behaviorApplied : function( behavior, time, normalizedTime, actor, value). This method will be called once per + * frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be + * called multiple times. + *

    + * Every behavior is applied to a concrete Actor. + * Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and + * is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration. + *

    + * You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify + * behaviorExpired to its registered observers. + *

    + * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. + * + * @name BaseBehavior + * @memberOf CAAT.Behavior + * @constructor + * + */ + + /** + * + * Internal behavior status values. Do not assign directly. + * + * @name Status + * @memberOf CAAT.Behavior.BaseBehavior + * @namespace + * @enum {number} + */ + + + defines: "CAAT.Behavior.BaseBehavior", + constants: { + + Status: { + /** + * @lends CAAT.Behavior.BaseBehavior.Status + */ + + /** @const @type {number}*/ NOT_STARTED: 0, + /** @const @type {number} */ STARTED: 1, + /** @const @type {number}*/ EXPIRED: 2 + }, + + /** + * @lends CAAT.Behavior.BaseBehavior + * @function + * @param obj a JSON object with a behavior definition. + */ + parse : function( obj ) { + + function findClass( qualifiedClassName ) { + var ns= qualifiedClassName.split("."); + var _global= window; + for( var i=0; i= this.behaviorStartTime) { + time = (time - this.behaviorStartTime) % this.behaviorDuration + this.behaviorStartTime; + } + } + + if (time > this.behaviorStartTime + this.behaviorDuration) { + if (this.status !== st.EXPIRED) { + this.setExpired(actor, time); + } + + return false; + } + + if (this.status === st.NOT_STARTED) { + this.status = st.STARTED; + this.fireBehaviorStartedEvent(actor, time); + } + + return this.behaviorStartTime <= time; // && time>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "opacity: " + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + } + } + } +}); +CAAT.Module({ + + /** + * @name ContainerBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.ContainerBehavior", + depends:["CAAT.Behavior.BaseBehavior", "CAAT.Behavior.GenericBehavior"], + aliases: ["CAAT.ContainerBehavior"], + extendsClass : "CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.ContainerBehavior.prototype + */ + + /** + * @inheritDoc + */ + parse : function( obj ) { + if ( obj.behaviors && obj.behaviors.length ) { + for( var i=0; i} + */ + behaviors:null, // contained behaviors array + recursiveCycleBehavior : false, + conforming : false, + + /** + * @param conforming {bool=} conform this behavior duration to that of its children. + * @inheritDoc + * @private + */ + __init:function ( conforming ) { + this.__super(); + this.behaviors = []; + if ( conforming ) { + this.conforming= true; + } + return this; + }, + + /** + * Proportionally change this container duration to its children. + * @param duration {number} new duration in ms. + * @return this; + */ + conformToDuration:function (duration) { + this.duration = duration; + + var f = duration / this.duration; + var bh; + for (var i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + bh.setFrameTime(bh.getStartTime() * f, bh.getDuration() * f); + } + + return this; + }, + + /** + * Get a behavior by mathing its id. + * @param id {object} + */ + getBehaviorById : function(id) { + for( var i=0; i= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + var obj= bh.getKeyFrameDataValues(time); + for( var pr in obj ) { + keyFrameData[pr]= obj[pr]; + } + } + } + } + + return keyFrameData; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (referenceTime, prefix) { + + var i; + var bh; + + var retValue = {}; + var time; + var cssRuleValue; + var cssProperty; + var property; + + for (i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + if (bh.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED && !(bh instanceof CAAT.Behavior.GenericBehavior)) { + + // ajustar tiempos: + // time es tiempo normalizado a duracion de comportamiento contenedor. + // 1.- desnormalizar + time = referenceTime * this.behaviorDuration; + + // 2.- calcular tiempo relativo de comportamiento respecto a contenedor + if (bh.behaviorStartTime <= time && bh.behaviorStartTime + bh.behaviorDuration >= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + cssRuleValue = bh.calculateKeyFrameData(time); + cssProperty = bh.getPropertyName(prefix); + + if (typeof retValue[cssProperty] === 'undefined') { + retValue[cssProperty] = ""; + } + + // 5.- asignar a objeto, par de propiedad/valor css + retValue[cssProperty] += cssRuleValue + " "; + } + + } + } + + + var tr = ""; + var pv; + + function xx(pr) { + if (retValue[pr]) { + tr += retValue[pr]; + } else { + if (prevValues) { + pv = prevValues[pr]; + if (pv) { + tr += pv; + retValue[pr] = pv; + } + } + } + } + + xx('translate'); + xx('rotate'); + xx('scale'); + + var keyFrameRule = ""; + + if (tr) { + keyFrameRule = '-' + prefix + '-transform: ' + tr + ';'; + } + + tr = ""; + xx('opacity'); + if (tr) { + keyFrameRule += ' opacity: ' + tr + ';'; + } + + keyFrameRule+=" -webkit-transform-origin: 0% 0%"; + + return { + rules:keyFrameRule, + ret:retValue + }; + + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize, anchorX, anchorY) { + + function toKeyFrame(obj, prevKF) { + + for( var i in prevKF ) { + if ( !obj[i] ) { + obj[i]= prevKF[i]; + } + } + + var ret= "-" + prefix + "-transform:"; + + if ( obj.x || obj.y ) { + var x= obj.x || 0; + var y= obj.y || 0; + ret+= "translate("+x+"px,"+y+"px)"; + } + + if ( obj.angle ) { + ret+= " rotate("+obj.angle+"rad)"; + } + + if ( obj.scaleX!==1 || obj.scaleY!==1 ) { + ret+= " scale("+(obj.scaleX)+","+(obj.scaleY)+")"; + } + + ret+=";"; + + if ( obj.alpha ) { + ret+= " opacity: "+obj.alpha+";"; + } + + if ( anchorX!==.5 || anchorY!==.5) { + ret+= " -" + prefix + "-transform-origin:"+ (anchorX*100) + "% " + (anchorY*100) + "%;"; + } + + return ret; + } + + if (this.duration === Number.MAX_VALUE) { + return ""; + } + + if (typeof anchorX==="undefined") { + anchorX= .5; + } + + if (typeof anchorY==="undefined") { + anchorY= .5; + } + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + + var i; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + var time; + var prevKF= {}; + + for (i = 0; i <= keyframessize; i++) { + time = this.interpolator.getPosition(i / keyframessize).y; + + var obj = this.getKeyFrameDataValues(time); + + kfd += "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + toKeyFrame(obj, prevKF) + "}\n"; + + prevKF= obj; + + } + + kfd += "}\n"; + + return kfd; + } + } + } +}); +CAAT.Module({ + /** + * @name GenericBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + defines:"CAAT.Behavior.GenericBehavior", + depends:["CAAT.Behavior.BaseBehavior"], + aliases:["CAAT.GenericBehavior"], + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.GenericBehavior.prototype + */ + + + /** + * starting value. + */ + start:0, + + /** + * ending value. + */ + end:0, + + /** + * target to apply this generic behvior. + */ + target:null, + + /** + * property to apply values to. + */ + property:null, + + /** + * this callback will be invoked for every behavior application. + */ + callback:null, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var value = this.start + time * (this.end - this.start); + if (this.callback) { + this.callback(value, this.target, actor); + } + + if (this.property) { + this.target[this.property] = value; + } + }, + + /** + * Defines the values to apply this behavior. + * + * @param start {number} initial behavior value. + * @param end {number} final behavior value. + * @param target {object} an object. Usually a CAAT.Actor. + * @param property {string} target object's property to set value to. + * @param callback {function} a function of the form function( target, value ). + */ + setValues:function (start, end, target, property, callback) { + this.start = start; + this.end = end; + this.target = target; + this.property = property; + this.callback = callback; + return this; + } + }; + } +}); +CAAT.Module({ + + /** + * @name PathBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name AUTOROTATE + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name autorotate + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + * @deprecated + */ + + defines:"CAAT.Behavior.PathBehavior", + aliases: ["CAAT.PathBehavior"], + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.SpriteImage" + ], + constants : { + + AUTOROTATE : { + + /** + * @lends CAAT.Behavior.PathBehavior.AUTOROTATE + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + }, + + autorotate: { + /** + * @lends CAAT.Behavior.PathBehavior.autorotate + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + } + }, + extendsClass : "CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.PathBehavior.prototype + * @param obj + */ + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.PathBehavior.superclass.parse.call(this,obj); + + if ( obj.SVG ) { + var parser= new CAAT.PathUtil.SVGPath(); + var path=parser.parsePath( obj.SVG ); + this.setValues(path); + } + + if ( obj.autoRotate ) { + this.autoRotate= obj.autoRotate; + } + }, + + /** + * A path to traverse. + * @type {CAAT.PathUtil.Path} + * @private + */ + path:null, + + /** + * Whether to set rotation angle while traversing the path. + * @private + */ + autoRotate:false, + + prevX:-1, // private, do not use. + prevY:-1, // private, do not use. + + /** + * Autorotation hint. + * @type {CAAT.Behavior.PathBehavior.autorotate} + * @private + */ + autoRotateOp: CAAT.Behavior.PathBehavior.autorotate.FREE, + + isOpenContour : false, + + relativeX : 0, + relativeY : 0, + + setOpenContour : function(b) { + this.isOpenContour= b; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "translate"; + }, + + setRelativeValues : function( x, y ) { + this.relativeX= x; + this.relativeY= y; + this.isRelative= true; + return this; + }, + + + /** + * Sets an actor rotation to be heading from past to current path's point. + * Take into account that this will be incompatible with rotation Behaviors + * since they will set their own rotation configuration. + * @param autorotate {boolean} + * @param autorotateOp {CAAT.PathBehavior.autorotate} whether the sprite is drawn heading to the right. + * @return this. + */ + setAutoRotate:function (autorotate, autorotateOp) { + this.autoRotate = autorotate; + if (autorotateOp !== undefined) { + this.autoRotateOp = autorotateOp; + } + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * + * @deprecated + */ + setPath:function (path) { + this.path = path; + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * @return this + */ + setValues:function (path) { + return this.setPath(path); + }, + + /** + * @see Actor.setPositionAnchor + * @deprecated + * @param tx a float with xoffset. + * @param ty a float with yoffset. + */ + setTranslation:function (tx, ty) { + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + return "translateX(" + point.x + "px) translateY(" + point.y + "px)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + var obj= { + x : point.x, + y : point.y + }; + + if ( this.autoRotate ) { + + var point2= time===0 ? point : this.path.getPosition(time -.001); + var ax = point.x - point2.x; + var ay = point.y - point2.y; + var angle = Math.atan2(ay, ax); + + obj.angle= angle; + } + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var time; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + if (!this.path) { + return { + x:actor.x, + y:actor.y + }; + } + + var point = this.path.getPosition(time, this.isOpenContour,.001); + if (this.isRelative ) { + point.x+= this.relativeX; + point.y+= this.relativeY; + } + + if (this.autoRotate) { + + if (-1 === this.prevX && -1 === this.prevY) { + this.prevX = point.x; + this.prevY = point.y; + } + + var ax = point.x - this.prevX; + var ay = point.y - this.prevY; + + if (ax === 0 && ay === 0) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } + + var angle = Math.atan2(ay, ax); + var si = CAAT.Foundation.SpriteImage; + var pba = CAAT.Behavior.PathBehavior.AUTOROTATE; + + // actor is heading left to right + if (this.autoRotateOp === pba.LEFT_TO_RIGHT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_NONE); + } + else { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + angle += Math.PI; + } + } else if (this.autoRotateOp === pba.RIGHT_TO_LEFT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + } + else { + actor.setImageTransformation(si.TR_NONE); + angle -= Math.PI; + } + } + + actor.setRotation(angle); + + this.prevX = point.x; + this.prevY = point.y; + + var modulo = Math.sqrt(ax * ax + ay * ay); + ax /= modulo; + ay /= modulo; + } + + if (this.doValueApplication) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } else { + return { + x:point.x, + y:point.y + }; + } + + + }, + + /** + * Get a point on the path. + * If the time to get the point at is in behaviors frame time, a point on the path will be returned, otherwise + * a default {x:-1, y:-1} point will be returned. + * + * @param time {number} the time at which the point will be taken from the path. + * @return {object} an object of the form {x:float y:float} + */ + positionOnTime:function (time) { + if (this.isBehaviorInTime(time, null)) { + time = this.normalizeTime(time); + return this.path.getPosition(time); + } + + return {x:-1, y:-1}; + + } + }; + } +}); +CAAT.Module({ + + /** + * @name RotateBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.RotateBehavior", + extendsClass: "CAAT.Behavior.BaseBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.RotateBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.RotateBehavior.prototype + */ + + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.RotateBehavior.superclass.parse.call(this,obj); + this.startAngle= obj.start || 0; + this.endAngle= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * Start rotation angle. + * @type {number} + * @private + */ + startAngle:0, + + /** + * End rotation angle. + * @type {number} + * @private + */ + endAngle:0, + + /** + * Rotation X anchor. + * @type {number} + * @private + */ + anchorX:.50, + + /** + * Rotation Y anchor. + * @type {number} + * @private + */ + anchorY:.50, + + rotationRelative: 0, + + setRelativeValues : function(r) { + this.rotationRelative= r; + this.isRelative= true; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "rotate"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var angle = this.startAngle + time * (this.endAngle - this.startAngle); + + if ( this.isRelative ) { + angle+= this.rotationRelative; + if (angle>=Math.PI) { + angle= (angle-2*Math.PI) + } + if ( angle<-2*Math.PI) { + angle= (angle+2*Math.PI); + } + } + + if (this.doValueApplication) { + actor.setRotationAnchored(angle, this.anchorX, this.anchorY); + } + + return angle; + + }, + + /** + * Set behavior bound values. + * if no anchorx,anchory values are supplied, the behavior will assume + * 50% for both values, that is, the actor's center. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startAngle {float} indicating the starting angle. + * @param endAngle {float} indicating the ending angle. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + */ + setValues:function (startAngle, endAngle, anchorx, anchory) { + this.startAngle = startAngle; + this.endAngle = endAngle; + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + return this; + }, + + /** + * @deprecated + * Use setValues instead + * @param start + * @param end + */ + setAngles:function (start, end) { + return this.setValues(start, end); + }, + + /** + * Set the behavior rotation anchor. Use this method when setting an exact percent + * by calling setValues is complicated. + * @see CAAT.Actor + * + * These parameters are to set a custom rotation anchor point. if anchor==CAAT.Actor.ANCHOR_CUSTOM + * the custom rotation point is set. + * @param actor + * @param rx + * @param ry + * + */ + setAnchor:function (actor, rx, ry) { + this.anchorX = rx / actor.width; + this.anchorY = ry / actor.height; + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + return "rotate(" + (this.startAngle + time * (this.endAngle - this.startAngle)) + "rad)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + angle : this.startAngle + time * (this.endAngle - this.startAngle) + }; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + + }; + + } +}); +CAAT.Module({ + /** + * @name Scale1Behavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * @name AXIS + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + */ + + /** + * @name Axis + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + * @deprecated + */ + + + defines:"CAAT.Behavior.Scale1Behavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.Scale1Behavior"], + constants : { + + AXIS : { + /** + * @lends CAAT.Behavior.Scale1Behavior.AXIS + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + }, + + Axis : { + /** + * @lends CAAT.Behavior.Scale1Behavior.Axis + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + } + }, + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Scale1Behavior.prototype + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start scale value. + * @private + */ + startScale:1, + + /** + * End scale value. + * @private + */ + endScale:1, + + /** + * Scale X anchor. + * @private + */ + anchorX:.50, + + /** + * Scale Y anchor. + * @private + */ + anchorY:.50, + + /** + * Apply on Axis X or Y ? + */ + applyOnX:true, + + parse : function( obj ) { + CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,obj); + this.startScale= obj.start || 0; + this.endScale= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + this.applyOnX= obj.axis ? obj.axis.toLowerCase()==="x" : true; + }, + + /** + * @param axis {CAAT.Behavior.Scale1Behavior.AXIS} + */ + applyOnAxis:function (axis) { + if (axis === CAAT.Behavior.Scale1Behavior.AXIS.X) { + this.applyOnX = false; + } else { + this.applyOnX = true; + } + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + var scale = this.startScale + time * (this.endScale - this.startScale); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scale) { + scale = 0.01; + } + + if (this.doValueApplication) { + if (this.applyOnX) { + actor.setScaleAnchored(scale, actor.scaleY, this.anchorX, this.anchorY); + } else { + actor.setScaleAnchored(actor.scaleX, scale, this.anchorX, this.anchorY); + } + } + + return scale; + }, + + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param start {number} initial X axis scale value. + * @param end {number} final X axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (start, end, applyOnX, anchorx, anchory) { + this.startScale = start; + this.endScale = end; + this.applyOnX = !!applyOnX; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scale; + + time = this.interpolator.getPosition(time).y; + scale = this.startScale + time * (this.endScale - this.startScale); + + return this.applyOnX ? "scaleX(" + scale + ")" : "scaleY(" + scale + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var obj= {}; + obj[ this.applyOnX ? "scaleX" : "scaleY" ]= this.startScale + time * (this.endScale - this.startScale); + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); +CAAT.Module({ + + /** + * @name ScaleBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.ScaleBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + extendsClass:"CAAT.Behavior.BaseBehavior", + aliases : ["CAAT.ScaleBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.ScaleBehavior + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start X scale value. + * @private + * @type {number} + */ + startScaleX:1, + + /** + * End X scale value. + * @private + * @type {number} + */ + endScaleX:1, + + /** + * Start Y scale value. + * @private + * @type {number} + */ + startScaleY:1, + + /** + * End Y scale value. + * @private + * @type {number} + */ + endScaleY:1, + + /** + * Scale X anchor value. + * @private + * @type {number} + */ + anchorX:.50, + + /** + * Scale Y anchor value. + * @private + * @type {number} + */ + anchorY:.50, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,obj); + this.startScaleX= (obj.scaleX && obj.scaleX.start) || 0; + this.endScaleX= (obj.scaleX && obj.scaleX.end) || 0; + this.startScaleY= (obj.scaleY && obj.scaleY.start) || 0; + this.endScaleY= (obj.scaleY && obj.scaleY.end) || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * Applies corresponding scale values for a given time. + * + * @param time the time to apply the scale for. + * @param actor the target actor to Scale. + * @return {object} an object of the form { scaleX: {float}, scaleY: {float}�} + */ + setForTime:function (time, actor) { + + var scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + var scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scaleX) { + scaleX = 0.01; + } + if (0 === scaleY) { + scaleY = 0.01; + } + + if (this.doValueApplication) { + actor.setScaleAnchored(scaleX, scaleY, this.anchorX, this.anchorY); + } + + return { scaleX:scaleX, scaleY:scaleY }; + }, + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startX {number} initial X axis scale value. + * @param endX {number} final X axis scale value. + * @param startY {number} initial Y axis scale value. + * @param endY {number} final Y axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (startX, endX, startY, endY, anchorx, anchory) { + this.startScaleX = startX; + this.endScaleX = endX; + this.startScaleY = startY; + this.endScaleY = endY; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scaleX; + var scaleY; + + time = this.interpolator.getPosition(time).y; + scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + return "scale(" + scaleX +"," + scaleY + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + scaleX : this.startScaleX + time * (this.endScaleX - this.startScaleX), + scaleY : this.startScaleY + time * (this.endScaleY - this.startScaleY) + }; + }, + + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); +/** + * + * taken from: http://www.quirksmode.org/js/detect.html + * + * 20101008 Hyperandroid. IE9 seems to identify himself as Explorer and stopped calling himself MSIE. + * Added Explorer description to browser list. Thanks @alteredq for this tip. + * + */ +CAAT.Module({ + + /** + * @name Runtime + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name BrowserInfo + * @memberOf CAAT.Module.Runtime + * @namespace + */ + + defines:"CAAT.Module.Runtime.BrowserInfo", + + constants: function() { + + /** + * @lends CAAT.Module.Runtime.BrowserInfo + */ + + function searchString(data) { + for (var i = 0; i < data.length; i++) { + var dataString = data[i].string; + var dataProp = data[i].prop; + this.versionSearchString = data[i].versionSearch || data[i].identity; + if (dataString) { + if (dataString.indexOf(data[i].subString) !== -1) + return data[i].identity; + } + else if (dataProp) + return data[i].identity; + } + } + + function searchVersion(dataString) { + var index = dataString.indexOf(this.versionSearchString); + if (index === -1) return; + return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); + } + + var dataBrowser= [ + { + string:navigator.userAgent, + subString:"Chrome", + identity:"Chrome" + }, + { string:navigator.userAgent, + subString:"OmniWeb", + versionSearch:"OmniWeb/", + identity:"OmniWeb" + }, + { + string:navigator.vendor, + subString:"Apple", + identity:"Safari", + versionSearch:"Version" + }, + { + prop:window.opera, + identity:"Opera" + }, + { + string:navigator.vendor, + subString:"iCab", + identity:"iCab" + }, + { + string:navigator.vendor, + subString:"KDE", + identity:"Konqueror" + }, + { + string:navigator.userAgent, + subString:"Firefox", + identity:"Firefox" + }, + { + string:navigator.vendor, + subString:"Camino", + identity:"Camino" + }, + { // for newer Netscapes (6+) + string:navigator.userAgent, + subString:"Netscape", + identity:"Netscape" + }, + { + string:navigator.userAgent, + subString:"MSIE", + identity:"Explorer", + versionSearch:"MSIE" + }, + { + string:navigator.userAgent, + subString:"Explorer", + identity:"Explorer", + versionSearch:"Explorer" + }, + { + string:navigator.userAgent, + subString:"Gecko", + identity:"Mozilla", + versionSearch:"rv" + }, + { // for older Netscapes (4-) + string:navigator.userAgent, + subString:"Mozilla", + identity:"Netscape", + versionSearch:"Mozilla" + } + ]; + + var dataOS=[ + { + string:navigator.platform, + subString:"Win", + identity:"Windows" + }, + { + string:navigator.platform, + subString:"Mac", + identity:"Mac" + }, + { + string:navigator.userAgent, + subString:"iPhone", + identity:"iPhone/iPod" + }, + { + string:navigator.platform, + subString:"Linux", + identity:"Linux" + } + ]; + + var browser = searchString(dataBrowser) || "An unknown browser"; + var version = searchVersion(navigator.userAgent) || + searchVersion(navigator.appVersion) || + "an unknown version"; + var OS = searchString(dataOS) || "an unknown OS"; + + var DevicePixelRatio = window.devicePixelRatio || 1; + + return { + browser: browser, + version: version, + OS: OS, + DevicePixelRatio : DevicePixelRatio + } + + } +}); +/** + * See LICENSE file. + * + * Sound implementation. + */ + +CAAT.Module({ + + /** + * @name Module + * @memberOf CAAT + * @namespace + */ + + /** + * @name Audio + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name AudioManager + * @memberOf CAAT.Module.Audio + * @constructor + */ + + defines:"CAAT.Module.Audio.AudioManager", + extendsWith:function () { + return { + + /** + * @lends CAAT.Module.Audio.AudioManager.prototype + */ + + __init:function () { + this.isFirefox= navigator.userAgent.match(/Firefox/g)!==null; + return this; + }, + + isFirefox : false, + + /** + * The only background music audio channel. + */ + musicChannel: null, + + /** + * Is music enabled ? + */ + musicEnabled:true, + + /** + * Are FX sounds enabled ? + */ + fxEnabled:true, + + /** + * A collection of Audio objects. + */ + audioCache:null, + + /** + * A cache of empty Audio objects. + */ + channels:null, + + /** + * Currently used Audio objects. + */ + workingChannels:null, + + /** + * Currently looping Audio objects. + */ + loopingChannels:[], + + /** + * available formats for audio elements. + * the system will load audio files with the extensions in this preferred order. + */ + audioFormatExtensions : [ + 'ogg', + 'wav', + 'x-wav', + 'mp3' + ], + + currentAudioFormatExtension : 'ogg', + + /** + * Audio formats. + * @dict + */ + audioTypes:{ // supported audio formats. Don't remember where i took them from :S + 'ogg': 'audio/ogg', + 'mp3': 'audio/mpeg;', + 'wav': 'audio/wav', + 'x-wav':'audio/x-wav', + 'mp4': 'audio/mp4"' + }, + + /** + * Initializes the sound subsystem by creating a fixed number of Audio channels. + * Every channel registers a handler for sound playing finalization. If a callback is set, the + * callback function will be called with the associated sound id in the cache. + * + * @param numChannels {number} number of channels to pre-create. 8 by default. + * + * @return this. + */ + initialize:function (numChannels ) { + + this.setAudioFormatExtensions( this.audioFormatExtensions ); + + this.audioCache = []; + this.channels = []; + this.workingChannels = []; + + for (var i = 0; i <= numChannels; i++) { + var channel = document.createElement('audio'); + + if (null !== channel) { + channel.finished = -1; + this.channels.push(channel); + var me = this; + channel.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + var i; + + // remove from workingChannels + for (i = 0; i < me.workingChannels.length; i++) { + if (me.workingChannels[i] === target) { + me.workingChannels.splice(i, 1); + break; + } + } + + if (target.caat_callback) { + target.caat_callback(target.caat_id); + } + + // set back to channels. + me.channels.push(target); + }, + false + ); + } + } + + this.musicChannel= this.channels.pop(); + + return this; + }, + + setAudioFormatExtensions : function( formats ) { + this.audioFormatExtensions= formats; + this.__setCurrentAudioFormatExtension(); + return this; + }, + + __setCurrentAudioFormatExtension : function( ) { + + var audio= new Audio(); + + for( var i= 0, l=this.audioFormatExtensions.length; i + * The audio element can be one of the two forms: + * + *

      + *
    1. Either an HTMLAudioElement/Audio object or a string url. + *
    2. An array of elements of the previous form. + *
    + * + *

    + * When the audio attribute is an array, this function will iterate throught the array elements + * until a suitable audio element to be played is found. When this is the case, the other array + * elements won't be taken into account. The valid form of using this addAudio method will be: + * + *

    + * 1.
    + * addAudio( id, url } ). In this case, if the resource pointed by url is + * not suitable to be played (i.e. a call to the Audio element's canPlayType method return 'no') + * no resource will be added under such id, so no sound will be played when invoking the play(id) + * method. + *

    + * 2.
    + * addAudio( id, dom_audio_tag ). In this case, the same logic than previous case is applied, but + * this time, the parameter url is expected to be an audio tag present in the html file. + *

    + * 3.
    + * addAudio( id, [array_of_url_or_domaudiotag] ). In this case, the function tries to locate a valid + * resource to be played in any of the elements contained in the array. The array element's can + * be any type of case 1 and 2. As soon as a valid resource is found, it will be associated to the + * id in the valid audio resources to be played list. + * + * @return this + */ + addAudio:function (id, array_of_url_or_domnodes, endplaying_callback) { + + if (array_of_url_or_domnodes instanceof Array) { + /* + iterate throught array elements until we can safely add an audio element. + */ + for (var i = 0; i < array_of_url_or_domnodes.length; i++) { + if (this.addAudioElement(id, array_of_url_or_domnodes[i], endplaying_callback)) { + break; + } + } + } else { + this.addAudioElement(id, array_of_url_or_domnodes, endplaying_callback); + } + + return this; + }, + /** + * Returns an audio object. + * @param aId {object} the id associated to the target Audio object. + * @return {object} the HTMLAudioElement addociated to the given id. + */ + getAudio:function (aId) { + for (var i = 0; i < this.audioCache.length; i++) { + if (this.audioCache[i].id === aId) { + return this.audioCache[i].audio; + } + } + + return null; + }, + + stopMusic : function() { + this.musicChannel.pause(); + }, + + playMusic : function(id) { + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio =this.musicChannel; + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, restart music. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + return audio; + } + } + + return this.musicChannel; + }, + + /** + * Set an audio object volume. + * @param id {object} an audio Id + * @param volume {number} volume to set. The volume value is not checked. + * + * @return this + */ + setVolume:function (id, volume) { + var audio = this.getAudio(id); + if (null != audio) { + audio.volume = volume; + } + + return this; + }, + + /** + * Plays an audio file from the cache if any sound channel is available. + * The playing sound will occupy a sound channel and when ends playing will leave + * the channel free for any other sound to be played in. + * @param id {object} an object identifying a sound in the sound cache. + * @return { id: {Object}, audio: {(Audio|HTMLAudioElement)} } + */ + play:function (id) { + if (!this.fxEnabled) { + return null; + } + + var audio = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio && this.channels.length > 0) { + var channel = this.channels.shift(); + channel.src = audio.src; +// channel.load(); + channel.volume = audio.volume; + channel.play(); + this.workingChannels.push(channel); + } else { + console.log("Can't play audio: "+id); + } + + return audio; + }, + + /** + * cancel all instances of a sound identified by id. This id is the value set + * to identify a sound. + * @param id + * @return {*} + */ + cancelPlay : function(id) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + var audio= this.workingChannels[i]; + if ( audio.caat_id===id ) { + audio.pause(); + this.channels.push(audio); + this.workingChannels.splice(i,1); + } + } + + return this; + }, + + /** + * cancel a channel sound + * @param audioObject + * @return {*} + */ + cancelPlayByChannel : function(audioObject) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + if ( this.workingChannels[i]===audioObject ) { + this.channels.push(audioObject); + this.workingChannels.splice(i,1); + return this; + } + } + + return this; + }, + + /** + * This method creates a new AudioChannel to loop the sound with. + * It returns an Audio object so that the developer can cancel the sound loop at will. + * The user must call pause() method to stop playing a loop. + *

    + * Firefox does not honor the loop property, so looping is performed by attending end playing + * event on audio elements. + * + * @return {HTMLElement} an Audio instance if a valid sound id is supplied. Null otherwise + */ + loop:function (id) { + + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio = document.createElement('audio'); + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + this.loopingChannels.push(audio); + return audio; + } + } + + return null; + }, + /** + * Cancel all playing audio channels + * Get back the playing channels to available channel list. + * + * @return this + */ + endSound:function () { + var i; + for (i = 0; i < this.workingChannels.length; i++) { + this.workingChannels[i].pause(); + this.channels.push(this.workingChannels[i]); + } + + for (i = 0; i < this.loopingChannels.length; i++) { + this.loopingChannels[i].pause(); + } + + this.workingChannels= []; + this.loopingChannels= []; + + this.stopMusic(); + + return this; + }, + setSoundEffectsEnabled:function (enable) { + this.fxEnabled = enable; + for (var i = 0; i < this.loopingChannels.length; i++) { + if (enable) { + this.loopingChannels[i].play(); + } else { + this.loopingChannels[i].pause(); + } + } + return this; + }, + isSoundEffectsEnabled:function () { + return this.fxEnabled; + }, + setMusicEnabled:function (enable) { + this.musicEnabled = enable; + this.stopMusic(); + return this; + }, + isMusicEnabled:function () { + return this.musicEnabled; + } + } + } +}); +/** + * See LICENSE file. + * + **/ +CAAT.Module({ + + /** + * @name Storage + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name LocalStorage + * @memberOf CAAT.Module.Storage + * @namespace + */ + + defines : "CAAT.Module.Storage.LocalStorage", + constants : { + + /** + * @lends CAAT.Module.Storage.LocalStorage + */ + + /** + * Stores an object in local storage. The data will be saved as JSON.stringify. + * @param key {string} key to store data under. + * @param data {object} an object. + * @return this + * + * @static + */ + save : function( key, data ) { + try { + localStorage.setItem( key, JSON.stringify(data) ); + } catch(e) { + // eat it + } + return this; + }, + /** + * Retrieve a value from local storage. + * @param key {string} the key to retrieve. + * @return {object} object stored under the key parameter. + * + * @static + */ + load : function( key, defValue ) { + try { + var v= localStorage.getItem( key ); + + return null===v ? defValue : JSON.parse(v); + } catch(e) { + return null; + } + }, + + /** + * Removes a value stored in local storage. + * @param key {string} + * @return this + * + * @static + */ + remove : function( key ) { + try { + localStorage.removeItem(key); + } catch(e) { + // eat it + } + return this; + } + }, + extendsWith : { + + } + +}); +/** + * See LICENSE file. + * + * @author: Mario Gonzalez (@onedayitwilltake) and Ibon Tolosana (@hyperandroid) + * + * Helper classes for color manipulation. + * + **/ + +CAAT.Module({ + + /** + * @name ColorUtil + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Color + * @memberOf CAAT.Module.ColorUtil + * @namespace + */ + + + defines:"CAAT.Module.ColorUtil.Color", + depends:[ + ], + constants:{ + + /** + * @lends CAAT.Module.ColorUtil.Color + */ + + /** + * Enumeration to define types of color ramps. + * @enum {number} + */ + RampEnumeration:{ + RAMP_RGBA:0, + RAMP_RGB:1, + RAMP_CHANNEL_RGB:2, + RAMP_CHANNEL_RGBA:3, + RAMP_CHANNEL_RGB_ARRAY:4, + RAMP_CHANNEL_RGBA_ARRAY:5 + }, + + /** + * HSV to RGB color conversion + *

    + * H runs from 0 to 360 degrees
    + * S and V run from 0 to 100 + *

    + * Ported from the excellent java algorithm by Eugene Vishnevsky at: + * http://www.cs.rit.edu/~ncs/color/t_convert.html + * + * @static + */ + hsvToRgb:function (h, s, v) { + var r, g, b, i, f, p, q, t; + + // Make sure our arguments stay in-range + h = Math.max(0, Math.min(360, h)); + s = Math.max(0, Math.min(100, s)); + v = Math.max(0, Math.min(100, v)); + + // We accept saturation and value arguments from 0 to 100 because that's + // how Photoshop represents those values. Internally, however, the + // saturation and value are calculated from a range of 0 to 1. We make + // That conversion here. + s /= 100; + v /= 100; + + if (s === 0) { + // Achromatic (grey) + r = g = b = v; + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + } + + h /= 60; // sector 0 to 5 + i = Math.floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch (i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + default: // case 5: + r = v; + g = p; + b = q; + } + + return new CAAT.Module.ColorUtil.Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); + }, + + /** + * Interpolate the color between two given colors. The return value will be a calculated color + * among the two given initial colors which corresponds to the 'step'th color of the 'nsteps' + * calculated colors. + * @param r0 {number} initial color red component. + * @param g0 {number} initial color green component. + * @param b0 {number} initial color blue component. + * @param r1 {number} final color red component. + * @param g1 {number} final color green component. + * @param b1 {number} final color blue component. + * @param nsteps {number} number of colors to calculate including the two given colors. If 16 is passed as value, + * 14 colors plus the two initial ones will be calculated. + * @param step {number} return this color index of all the calculated colors. + * + * @return { {r{number}, g{number}, b{number}} } return an object with the new calculated color components. + * @static + */ + interpolate:function (r0, g0, b0, r1, g1, b1, nsteps, step) { + + var r, g, b; + + if (step <= 0) { + return { + r:r0, + g:g0, + b:b0 + }; + } else if (step >= nsteps) { + return { + r:r1, + g:g1, + b:b1 + }; + } + + r = (r0 + (r1 - r0) / nsteps * step) >> 0; + g = (g0 + (g1 - g0) / nsteps * step) >> 0; + b = (b0 + (b1 - b0) / nsteps * step) >> 0; + + if (r > 255) { + r = 255; + } else if (r < 0) { + r = 0; + } + if (g > 255) { + g = 255; + } else if (g < 0) { + g = 0; + } + if (b > 255) { + b = 255; + } else if (b < 0) { + b = 0; + } + + return { + r:r, + g:g, + b:b + }; + }, + + /** + * Generate a ramp of colors from an array of given colors. + * @param fromColorsArray {[number]} an array of colors. each color is defined by an integer number from which + * color components will be extracted. Be aware of the alpha component since it will also be interpolated for + * new colors. + * @param rampSize {number} number of colors to produce. + * @param returnType {CAAT.ColorUtils.RampEnumeration} a value of CAAT.ColorUtils.RampEnumeration enumeration. + * + * @return { [{number},{number},{number},{number}] } an array of integers each of which represents a color of + * the calculated color ramp. + * + * @static + */ + makeRGBColorRamp:function (fromColorsArray, rampSize, returnType) { + + var ramp = [], nc = fromColorsArray.length - 1, chunk = rampSize / nc, i, j, + na, nr, ng, nb, + c, a0, r0, g0, b0, + c1, a1, r1, g1, b1, + da, dr, dg, db; + + for (i = 0; i < nc; i += 1) { + c = fromColorsArray[i]; + a0 = (c >> 24) & 0xff; + r0 = (c & 0xff0000) >> 16; + g0 = (c & 0xff00) >> 8; + b0 = c & 0xff; + + c1 = fromColorsArray[i + 1]; + a1 = (c1 >> 24) & 0xff; + r1 = (c1 & 0xff0000) >> 16; + g1 = (c1 & 0xff00) >> 8; + b1 = c1 & 0xff; + + da = (a1 - a0) / chunk; + dr = (r1 - r0) / chunk; + dg = (g1 - g0) / chunk; + db = (b1 - b0) / chunk; + + for (j = 0; j < chunk; j += 1) { + na = (a0 + da * j) >> 0; + nr = (r0 + dr * j) >> 0; + ng = (g0 + dg * j) >> 0; + nb = (b0 + db * j) >> 0; + + var re = CAAT.Module.ColorUtil.Color.RampEnumeration; + + switch (returnType) { + case re.RAMP_RGBA: + ramp.push('argb(' + na + ',' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_RGB: + ramp.push('rgb(' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_CHANNEL_RGB: + ramp.push(0xff000000 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA: + ramp.push(na << 24 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA_ARRAY: + ramp.push([ nr, ng, nb, na ]); + break; + case re.RAMP_CHANNEL_RGB_ARRAY: + ramp.push([ nr, ng, nb ]); + break; + } + } + } + + return ramp; + + }, + + random:function () { + var a = '0123456789abcdef'; + var c = '#'; + for (var i = 0; i < 3; i++) { + c += a[ (Math.random() * a.length) >> 0 ]; + } + return c; + } + }, + + extendsWith:{ + __init:function (r, g, b) { + this.r = r || 255; + this.g = g || 255; + this.b = b || 255; + return this; + }, + + r:255, + g:255, + b:255, + + /** + * Get color hexadecimal representation. + * @return {string} a string with color hexadecimal representation. + */ + toHex:function () { + // See: http://jsperf.com/rgb-decimal-to-hex/5 + return ('000000' + ((this.r << 16) + (this.g << 8) + this.b).toString(16)).slice(-6); + } + } +}); +/** + * See LICENSE file. + * + * Get realtime Debug information of CAAT's activity. + * Set CAAT.DEBUG=1 before any CAAT.Director object creation. + * This class creates a DOM node called 'caat-debug' and associated styles + * The debug panel is minimized by default and shows short information. It can be expanded and minimized again by clicking on it + * + */ + +CAAT.Module( { + + /** + * @name Debug + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Debug + * @memberOf CAAT.Module.Debug + * @constructor + */ + + defines : "CAAT.Module.Debug.Debug", + depends : [ + "CAAT.Event.AnimationLoop" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Debug.Debug.prototype + */ + + width: 0, + height: 0, + canvas: null, + ctx: null, + statistics: null, + framerate: null, + textContainer: null, + textFPS: null, + textEntitiesTotal: null, + textEntitiesActive: null, + textDraws: null, + textDrawTime: null, + textRAFTime: null, + textDirtyRects: null, + textDiscardDR: null, + + frameTimeAcc : 0, + frameRAFAcc : 0, + + canDebug: false, + + SCALE: 60, + + debugTpl: + " "+ + "

    "+ + "
    "+ + " CAAT Debug panel "+ + " Performance"+ + " Controls"+ + " "+ + " "+ + " Draw Time: "+ + " 5.46"+ + " ms."+ + " "+ + " "+ + " "+ + " FPS: "+ + " 48"+ + " "+ + "
    "+ + "
    "+ + "
    "+ + " "+ + "
    "+ + " "+ + " "+ + " RAF Time:"+ + " 20.76"+ + " ms."+ + " "+ + " "+ + " "+ + " Entities Total: "+ + " 41"+ + " "+ + " "+ + " "+ + " Entities Active: "+ + " 37"+ + " "+ + " "+ + " "+ + " Draws: "+ + " 0"+ + " "+ + " "+ + " "+ + " DirtyRects: "+ + " 0"+ + " "+ + " "+ + " "+ + " Discard DR: "+ + " 0"+ + " "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + " "+ + " Sound"+ + "
    "+ + "
    "+ + " "+ + " Music"+ + "
    "+ + "
    "+ + " "+ + " AA Bounding Boxes"+ + "
    "+ + "
    "+ + " "+ + " Bounding Boxes"+ + "
    "+ + "
    "+ + " "+ + " Dirty Rects"+ + "
    "+ + "
    "+ + "
    "+ + "
    "+ + "
    ", + + + setScale : function(s) { + this.scale= s; + return this; + }, + + initialize: function(w,h) { + w= window.innerWidth; + + this.width= w; + this.height= h; + + this.framerate = { + refreshInterval: CAAT.FPS_REFRESH || 500, // refresh every ? ms, updating too quickly gives too large rounding errors + frames: 0, // number offrames since last refresh + timeLastRefresh: 0, // When was the framerate counter refreshed last + fps: 0, // current framerate + prevFps: -1, // previously drawn FPS + fpsMin: 1000, // minimum measured framerate + fpsMax: 0 // maximum measured framerate + }; + + var debugContainer= document.getElementById('caat-debug'); + if (!debugContainer) { + var wrap = document.createElement('div'); + wrap.innerHTML=this.debugTpl; + document.body.appendChild(wrap); + + eval( ""+ + " var __x= CAAT;" + + " function initCheck( name, bool, callback ) {"+ + " var elem= document.getElementById(name);"+ + " if ( elem ) {"+ + " elem.className= (bool) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " if ( callback ) {"+ + " elem.addEventListener( \"click\", (function(elem, callback) {"+ + " return function(e) {"+ + " elem.__value= !elem.__value;"+ + " elem.className= (elem.__value) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " callback(e,elem.__value);"+ + " }"+ + " })(elem, callback), false );"+ + " }"+ + " elem.__value= bool;"+ + " }"+ + " }"+ + " function setupTabs() {"+ + " var numTabs=0;"+ + " var elem;"+ + " var elemContent;"+ + " do {"+ + " elem= document.getElementById(\"caat-debug-tab\"+numTabs);"+ + " if ( elem ) {"+ + " elemContent= document.getElementById(\"caat-debug-tab\"+numTabs+\"-content\");"+ + " if ( elemContent ) {"+ + " elemContent.style.display= numTabs===0 ? 'block' : 'none';"+ + " elem.className= numTabs===0 ? \"debug_tab debug_tab_selected\" : \"debug_tab debug_tab_not_selected\";"+ + " elem.addEventListener( \"click\", (function(tabIndex) {"+ + " return function(e) {"+ + " for( var i=0; i this.framerate.timeLastRefresh + this.framerate.refreshInterval ) { + this.framerate.fps = ( ( this.framerate.frames * 1000 ) / ( tt - this.framerate.timeLastRefresh ) ) | 0; + this.framerate.fpsMin = this.framerate.frames > 0 ? Math.min( this.framerate.fpsMin, this.framerate.fps ) : this.framerate.fpsMin; + this.framerate.fpsMax = Math.max( this.framerate.fpsMax, this.framerate.fps ); + + this.textFPS.innerHTML= this.framerate.fps; + + var value= ((this.frameTimeAcc*100/this.framerate.frames)|0)/100; + this.frameTimeAcc=0; + this.textDrawTime.innerHTML= value; + + var value2= ((this.frameRAFAcc*100/this.framerate.frames)|0)/100; + this.frameRAFAcc=0; + this.textRAFTime.innerHTML= value2; + + this.framerate.timeLastRefresh = tt; + this.framerate.frames = 0; + + this.paint(value2); + } + + this.textEntitiesTotal.innerHTML= this.statistics.size_total; + this.textEntitiesActive.innerHTML= this.statistics.size_active; + this.textDirtyRects.innerHTML= this.statistics.size_dirtyRects; + this.textDraws.innerHTML= this.statistics.draws; + this.textDiscardDR.innerHTML= this.statistics.size_discarded_by_dirty_rects; + }, + + paint : function( rafValue ) { + var ctx= this.ctx; + var t=0; + + ctx.drawImage( + this.canvas, + 1, 0, this.width-1, this.height, + 0, 0, this.width-1, this.height ); + + ctx.strokeStyle= 'black'; + ctx.beginPath(); + ctx.moveTo( this.width-.5, 0 ); + ctx.lineTo( this.width-.5, this.height ); + ctx.stroke(); + + ctx.strokeStyle= '#a22'; + ctx.beginPath(); + t= this.height-((20/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + ctx.strokeStyle= '#aa2'; + ctx.beginPath(); + t= this.height-((30/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + var fps = Math.min( this.height-(this.framerate.fps/this.SCALE*this.height), 59 ); + if (-1===this.framerate.prevFps) { + this.framerate.prevFps= fps|0; + } + + ctx.strokeStyle= '#0ff';//this.framerate.fps<15 ? 'red' : this.framerate.fps<30 ? 'yellow' : 'green'; + ctx.beginPath(); + ctx.moveTo( this.width, (fps|0)-.5 ); + ctx.lineTo( this.width, this.framerate.prevFps-.5 ); + ctx.stroke(); + + this.framerate.prevFps= fps; + + + var t1= ((this.height-(rafValue/this.SCALE*this.height))>>0)-.5; + ctx.strokeStyle= '#ff0'; + ctx.beginPath(); + ctx.moveTo( this.width, t1 ); + ctx.lineTo( this.width, t1 ); + ctx.stroke(); + } + } + +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Font + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Font + * @memberOf CAAT.Module.Font + * @constructor + */ + + defines : "CAAT.Module.Font.Font", + aliases : "CAAT.Font", + depends : [ + "CAAT.Foundation.SpriteImage" + ], + constants: { + + /** + * @lends CAAT.Module.Font.Font + */ + + getFontMetrics:function (font) { + var ret; + if (CAAT.CSS_TEXT_METRICS) { + try { + ret = CAAT.Module.Font.Font.getFontMetricsCSS(font); + return ret; + } catch (e) { + + } + } + + return CAAT.Module.Font.Font.getFontMetricsNoCSS(font); + }, + + getFontMetricsNoCSS:function (font) { + + var re = /(\d+)p[x|t]\s*/i; + var res = re.exec(font); + + var height; + + if (!res) { + height = 32; // no px or pt value in font. assume 32.) + } else { + height = res[1] | 0; + } + + var ascent = height - 1; + var h = (height + height * .2) | 0; + return { + height:h, + ascent:ascent, + descent:h - ascent + } + + }, + + /** + * Totally ripped from: + * + * jQuery (offset function) + * Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas + * + * @param font + * @return {*} + */ + getFontMetricsCSS:function (font) { + + function offset(elem) { + + var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left; + var doc = elem && elem.ownerDocument; + docElem = doc.documentElement; + + box = elem.getBoundingClientRect(); + //win = getWindow( doc ); + + body = document.body; + win = doc.nodeType === 9 ? doc.defaultView || doc.parentWindow : false; + + clientTop = docElem.clientTop || body.clientTop || 0; + clientLeft = docElem.clientLeft || body.clientLeft || 0; + scrollTop = win.pageYOffset || docElem.scrollTop; + scrollLeft = win.pageXOffset || docElem.scrollLeft; + top = box.top + scrollTop - clientTop; + left = box.left + scrollLeft - clientLeft; + + return { top:top, left:left }; + } + + try { + var text = document.createElement("span"); + text.style.font = font; + text.innerHTML = "Hg"; + + var block = document.createElement("div"); + block.style.display = "inline-block"; + block.style.width = "1px"; + block.style.heigh = "0px"; + + var div = document.createElement("div"); + div.appendChild(text); + div.appendChild(block); + + + var body = document.body; + body.appendChild(div); + + try { + + var result = {}; + + block.style.verticalAlign = 'baseline'; + result.ascent = offset(block).top - offset(text).top; + + block.style.verticalAlign = 'bottom'; + result.height = offset(block).top - offset(text).top; + + result.ascent = Math.ceil(result.ascent); + result.height = Math.ceil(result.height); + + result.descent = result.height - result.ascent; + + return result; + + } finally { + body.removeChild(div); + } + } catch (e) { + return null; + } + } + }, + extendsWith:function () { + + var UNKNOWN_CHAR_WIDTH = 10; + + return { + + /** + * @lends CAAT.Module.Font.Font.prototype + */ + + fontSize:10, + fontSizeUnit:"px", + font:'Sans-Serif', + fontStyle:'', + fillStyle:'#fff', + strokeStyle:null, + strokeSize:1, + padding:0, + image:null, + charMap:null, + + height:0, + ascent:0, + descent:0, + + setPadding:function (padding) { + this.padding = padding; + return this; + }, + + setFontStyle:function (style) { + this.fontStyle = style; + return this; + }, + + setStrokeSize:function (size) { + this.strokeSize = size; + return this; + }, + + setFontSize:function (fontSize) { + this.fontSize = fontSize; + this.fontSizeUnit = 'px'; + return this; + }, + + setFont:function (font) { + this.font = font; + return this; + }, + + setFillStyle:function (style) { + this.fillStyle = style; + return this; + }, + + setStrokeStyle:function (style) { + this.strokeStyle = style; + return this; + }, + + createDefault:function (padding) { + var str = ""; + for (var i = 32; i < 128; i++) { + str = str + String.fromCharCode(i); + } + + return this.create(str, padding); + }, + + create:function (chars, padding) { + + padding = padding | 0; + this.padding = padding; + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + ctx.textBaseline = 'bottom'; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + + var textWidth = 0; + var charWidth = []; + var i; + var x; + var cchar; + + for (i = 0; i < chars.length; i++) { + var cw = Math.max(1, (ctx.measureText(chars.charAt(i)).width >> 0) + 1) + 2 * padding; + charWidth.push(cw); + textWidth += cw; + } + + + var fontMetrics = CAAT.Font.getFontMetrics(ctx.font); + var baseline = "alphabetic", yoffset, canvasheight; + + canvasheight = fontMetrics.height; + this.ascent = fontMetrics.ascent; + this.descent = fontMetrics.descent; + this.height = fontMetrics.height; + yoffset = fontMetrics.ascent; + + canvas.width = textWidth; + canvas.height = canvasheight; + ctx = canvas.getContext('2d'); + + //ctx.textBaseline= 'bottom'; + ctx.textBaseline = baseline; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + ctx.fillStyle = this.fillStyle; + ctx.strokeStyle = this.strokeStyle; + + this.charMap = {}; + + x = 0; + for (i = 0; i < chars.length; i++) { + cchar = chars.charAt(i); + ctx.fillText(cchar, x + padding, yoffset); + if (this.strokeStyle) { + ctx.beginPath(); + ctx.lineWidth = this.strokeSize; + ctx.strokeText(cchar, x + padding, yoffset); + } + this.charMap[cchar] = { + x:x + padding, + width:charWidth[i] - 2 * padding, + height: this.height + }; + x += charWidth[i]; + } + + this.image = canvas; + + return this; + }, + + setAsSpriteImage:function () { + var cm = []; + var _index = 0; + for (var i in this.charMap) { + var _char = i; + var charData = this.charMap[i]; + + cm[i] = { + id:_index++, + height:this.height, + xoffset:0, + letter:_char, + yoffset:0, + width:charData.width, + xadvance:charData.width, + x:charData.x, + y:0 + }; + } + + this.spriteImage = new CAAT.Foundation.SpriteImage().initializeAsGlyphDesigner(this.image, cm); + return this; + }, + + getAscent:function () { + return this.ascent; + }, + + getDescent:function () { + return this.descent; + }, + + stringHeight:function () { + return this.height; + }, + + getFontData:function () { + return { + height:this.height, + ascent:this.ascent, + descent:this.descent + }; + }, + + stringWidth:function (str) { + var i, l, w = 0, c; + + for (i = 0, l = str.length; i < l; i++) { + c = this.charMap[ str.charAt(i) ]; + if (c) { + w += c.width; + } else { + w += UNKNOWN_CHAR_WIDTH; + } + } + + return w; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + var height = this.image.height; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.charMap[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, 0, + w, height, + x, y, + w, height); + } + x += w; + } else { + ctx.strokeStyle = '#f00'; + ctx.strokeRect(x, y, UNKNOWN_CHAR_WIDTH, height); + x += UNKNOWN_CHAR_WIDTH; + } + } + }, + + save:function () { + var str = "image/png"; + var strData = this.image.toDataURL(str); + document.location.href = strData.replace(str, "image/octet-stream"); + }, + + drawSpriteText:function (director, time) { + this.spriteImage.drawSpriteText(director, time); + } + + } + } + +}); + +/** + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ + */ + +CAAT.Module({ + + /** + * @name CircleManager + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name PackedCircle + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + defines:"CAAT.Module.CircleManager.PackedCircle", + depends:[ + "CAAT.Module.CircleManager.PackedCircle", + "CAAT.Math.Point" + ], + constants:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle + */ + + /** @const */ BOUNDS_RULE_WRAP:1, // Wrap to otherside + /** @const */ BOUNDS_RULE_CONSTRAINT:2, // Constrain within bounds + /** @const */ BOUNDS_RULE_DESTROY:4, // Destroy when it reaches the edge + /** @const */ BOUNDS_RULE_IGNORE:8 // Ignore when reaching bounds + }, + extendsWith:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle.prototype + */ + + __init:function () { + this.boundsRule = CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE; + this.position = new CAAT.Math.Point(0, 0, 0); + this.offset = new CAAT.Math.Point(0, 0, 0); + this.targetPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * + */ + id:0, + + /** + * + */ + delegate:null, + + /** + * + */ + position:null, + + /** + * + */ + offset:null, + + /** + * + */ + targetPosition:null, // Where it wants to go + + /** + * + */ + targetChaseSpeed:0.02, + + /** + * + */ + isFixed:false, + + /** + * + */ + boundsRule:0, + + /** + * + */ + collisionMask:0, + + /** + * + */ + collisionGroup:0, + + containsPoint:function (aPoint) { + var distanceSquared = this.position.getDistanceSquared(aPoint); + return distanceSquared < this.radiusSquared; + }, + + getDistanceSquaredFromPosition:function (aPosition) { + var distanceSquared = this.position.getDistanceSquared(aPosition); + // if it's shorter than either radius, we intersect + return distanceSquared < this.radiusSquared; + }, + + intersects:function (aCircle) { + var distanceSquared = this.position.getDistanceSquared(aCircle.position); + return (distanceSquared < this.radiusSquared || distanceSquared < aCircle.radiusSquared); + }, + + /** + * ACCESSORS + */ + setPosition:function (aPosition) { + this.position = aPosition; + return this; + }, + + setDelegate:function (aDelegate) { + this.delegate = aDelegate; + return this; + }, + + setOffset:function (aPosition) { + this.offset = aPosition; + return this; + }, + + setTargetPosition:function (aTargetPosition) { + this.targetPosition = aTargetPosition; + return this; + }, + + setTargetChaseSpeed:function (aTargetChaseSpeed) { + this.targetChaseSpeed = aTargetChaseSpeed; + return this; + }, + + setIsFixed:function (value) { + this.isFixed = value; + return this; + }, + + setCollisionMask:function (aCollisionMask) { + this.collisionMask = aCollisionMask; + return this; + }, + + setCollisionGroup:function (aCollisionGroup) { + this.collisionGroup = aCollisionGroup; + return this; + }, + + setRadius:function (aRadius) { + this.radius = aRadius; + this.radiusSquared = this.radius * this.radius; + return this; + }, + + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + + dealloc:function () { + this.position = null; + this.offset = null; + this.delegate = null; + this.targetPosition = null; + } + } +}); +/** + * + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ +*/ + +CAAT.Module( { + + + /** + * @name PackedCircleManager + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + + defines : "CAAT.Module.CircleManager.PackedCircleManager", + depends : [ + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.CircleManager.PackedCircleManager.prototype + * @private + */ + + __init : function() { + this.bounds= new CAAT.Math.Rectangle(); + }, + + /** + * + */ + allCircles: [], + + /** + * + */ + numberOfCollisionPasses: 1, + + /** + * + */ + numberOfTargetingPasses: 0, + + /** + * + */ + bounds: null, + + /** + * Adds a circle to the simulation + * @param aCircle + */ + addCircle: function(aCircle) + { + aCircle.id = this.allCircles.length; + this.allCircles.push(aCircle); + return this; + }, + + /** + * Removes a circle from the simulations + * @param aCircle Circle to remove + */ + removeCircle: function(aCircle) + { + var index = 0, + found = false, + len = this.allCircles.length; + + if(len === 0) { + throw "Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!"; + } + + while (len--) { + if(this.allCircles[len] === aCircle) { + found = true; + index = len; + break; + } + } + + if(!found) { + throw "Could not locate circle in allCircles array!"; + } + + // Remove + this.allCircles[index].dealloc(); + this.allCircles[index] = null; + + return this; + }, + + /** + * Forces all circles to move to where their delegate position is + * Assumes all targets have a 'position' property! + */ + forceCirclesToMatchDelegatePositions: function() + { + var len = this.allCircles.length; + + // push toward target position + for(var n = 0; n < len; n++) + { + var aCircle = this.allCircles[n]; + if(!aCircle || !aCircle.delegate) { + continue; + } + + aCircle.position.set(aCircle.delegate.x + aCircle.offset.x, + aCircle.delegate.y + aCircle.offset.y); + } + }, + + pushAllCirclesTowardTarget: function(aTarget) + { + var v = new CAAT.Math.Point(0,0,0), + circleList = this.allCircles, + len = circleList.length; + + // push toward target position + for(var n = 0; n < this.numberOfTargetingPasses; n++) + { + for(var i = 0; i < len; i++) + { + var c = circleList[i]; + + if(c.isFixed) continue; + + v.x = c.position.x - (c.targetPosition.x+c.offset.x); + v.y = c.position.y - (c.targetPosition.y+c.offset.y); + v.multiply(c.targetChaseSpeed); + + c.position.x -= v.x; + c.position.y -= v.y; + } + } + }, + + /** + * Packs the circles towards the center of the bounds. + * Each circle will have it's own 'targetPosition' later on + */ + handleCollisions: function() + { + this.removeExpiredElements(); + + var v = new CAAT.Math.Point(0,0, 0), + circleList = this.allCircles, + len = circleList.length; + + // Collide circles + for(var n = 0; n < this.numberOfCollisionPasses; n++) + { + for(var i = 0; i < len; i++) + { + var ci = circleList[i]; + + + for (var j = i + 1; j< len; j++) + { + var cj = circleList[j]; + + if( !this.circlesCanCollide(ci, cj) ) continue; // It's us! + + var dx = cj.position.x - ci.position.x, + dy = cj.position.y - ci.position.y; + + // The distance between the two circles radii, but we're also gonna pad it a tiny bit + var r = (ci.radius + cj.radius) * 1.08, + d = ci.position.getDistanceSquared(cj.position); + + /** + * Collision detected! + */ + if (d < (r * r) - 0.02 ) + { + v.x = dx; + v.y = dy; + v.normalize(); + + var inverseForce = (r - Math.sqrt(d)) * 0.5; + v.multiply(inverseForce); + + // Move cj opposite of the collision as long as its not fixed + if(!cj.isFixed) + { + if(ci.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // ADD the velocity + cj.position.translatePoint(v); + } + + // Move ci opposite of the collision as long as its not fixed + if(!ci.isFixed) + { + if(cj.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // SUBTRACT the velocity + ci.position.subtract(v); + } + + // Emit the collision event from each circle, with itself as the first parameter +// if(this.dispatchCollisionEvents && n == this.numberOfCollisionPasses-1) +// { +// this.eventEmitter.emit('collision', cj, ci, v); +// } + } + } + } + } + }, + + handleBoundaryForCircle: function(aCircle, boundsRule) + { +// if(aCircle.boundsRule === true) return; // Ignore if being dragged + + var xpos = aCircle.position.x; + var ypos = aCircle.position.y; + + var radius = aCircle.radius; + var diameter = radius*2; + + // Toggle these on and off, + // Wrap and bounce, are opposite behaviors so pick one or the other for each axis, or bad things will happen. + var wrapXMask = 1 << 0; + var wrapYMask = 1 << 2; + var constrainXMask = 1 << 3; + var constrainYMask = 1 << 4; + var emitEvent = 1 << 5; + + // TODO: Promote to member variable + // Convert to bitmask - Uncomment the one you want, or concact your own :) + // boundsRule = wrapY; // Wrap only Y axis + // boundsRule = wrapX; // Wrap only X axis + // boundsRule = wrapXMask | wrapYMask; // Wrap both X and Y axis + boundsRule = wrapYMask | constrainXMask; // Wrap Y axis, but constrain horizontally + + // Wrap X + if(boundsRule & wrapXMask && xpos-diameter > this.bounds.right) { + aCircle.position.x = this.bounds.left + radius; + } else if(boundsRule & wrapXMask && xpos+diameter < this.bounds.left) { + aCircle.position.x = this.bounds.right - radius; + } + // Wrap Y + if(boundsRule & wrapYMask && ypos-diameter > this.bounds.bottom) { + aCircle.position.y = this.bounds.top - radius; + } else if(boundsRule & wrapYMask && ypos+diameter < this.bounds.top) { + aCircle.position.y = this.bounds.bottom + radius; + } + + // Constrain X + if(boundsRule & constrainXMask && xpos+radius >= this.bounds.right) { + aCircle.position.x = aCircle.position.x = this.bounds.right-radius; + } else if(boundsRule & constrainXMask && xpos-radius < this.bounds.left) { + aCircle.position.x = this.bounds.left + radius; + } + + // Constrain Y + if(boundsRule & constrainYMask && ypos+radius > this.bounds.bottom) { + aCircle.position.y = this.bounds.bottom - radius; + } else if(boundsRule & constrainYMask && ypos-radius < this.bounds.top) { + aCircle.position.y = this.bounds.top + radius; + } + }, + + /** + * Given an x,y position finds circle underneath and sets it to the currently grabbed circle + * @param {Number} xpos An x position + * @param {Number} ypos A y position + * @param {Number} buffer A radiusSquared around the point in question where something is considered to match + */ + getCircleAt: function(xpos, ypos, buffer) + { + var circleList = this.allCircles; + var len = circleList.length; + var grabVector = new CAAT.Math.Point(xpos, ypos, 0); + + // These are set every time a better match i found + var closestCircle = null; + var closestDistance = Number.MAX_VALUE; + + // Loop thru and find the closest match + for(var i = 0; i < len; i++) + { + var aCircle = circleList[i]; + if(!aCircle) continue; + var distanceSquared = aCircle.position.getDistanceSquared(grabVector); + + if(distanceSquared < closestDistance && distanceSquared < aCircle.radiusSquared + buffer) + { + closestDistance = distanceSquared; + closestCircle = aCircle; + } + } + + return closestCircle; + }, + + circlesCanCollide: function(circleA, circleB) + { + if(!circleA || !circleB || circleA===circleB) return false; // one is null (will be deleted next loop), or both point to same obj. +// if(circleA.delegate == null || circleB.delegate == null) return false; // This circle will be removed next loop, it's entity is already removed + +// if(circleA.isFixed & circleB.isFixed) return false; +// if(circleA.delegate .clientID === circleB.delegate.clientID) return false; // Don't let something collide with stuff it owns + + // They dont want to collide +// if((circleA.collisionGroup & circleB.collisionMask) == 0) return false; +// if((circleB.collisionGroup & circleA.collisionMask) == 0) return false; + + return true; + }, +/** + * Accessors + */ + setBounds: function(x, y, w, h) + { + this.bounds.x = x; + this.bounds.y = y; + this.bounds.width = w; + this.bounds.height = h; + }, + + setNumberOfCollisionPasses: function(value) + { + this.numberOfCollisionPasses = value; + return this; + }, + + setNumberOfTargetingPasses: function(value) + { + this.numberOfTargetingPasses = value; + return this; + }, + +/** + * Helpers + */ + sortOnDistanceToTarget: function(circleA, circleB) + { + var valueA = circleA.getDistanceSquaredFromPosition(circleA.targetPosition); + var valueB = circleB.getDistanceSquaredFromPosition(circleA.targetPosition); + var comparisonResult = 0; + + if(valueA > valueB) comparisonResult = -1; + else if(valueA < valueB) comparisonResult = 1; + + return comparisonResult; + }, + +/** + * Memory Management + */ + removeExpiredElements: function() + { + // remove null elements + for (var k = this.allCircles.length; k >= 0; k--) { + if (this.allCircles[k] === null) + this.allCircles.splice(k, 1); + } + }, + + initialize : function(overrides) + { + if (overrides) + { + for (var i in overrides) + { + this[i] = overrides[i]; + } + } + + return this; + } + } +}); +/** + * See LICENSE file. + * + * Image/Resource preloader. + * + * + **/ + +CAAT.Module( { + + + /** + * @name Preloader + * @memberOf CAAT.Module.Preloader + * @constructor + */ + + defines : "CAAT.Module.Preloader.Preloader", + extendsWith : function() { + + var descriptor= function(id, path, loader) { + + var me= this; + + this.id= id; + this.path= path; + this.image= new Image(); + this.loader= loader; + + this.image.onload= this.onload.bind(this); + this.image.onerror= this.onerror.bind(this); + + return this; + }; + + descriptor.prototype= { + id : null, + path : null, + image : null, + loader : null, + + onload : function(e) { + this.loader.__onload(this); + this.image.onload= null; + this.image.onerror= null; + }, + + onerror : function(e) { + this.loader.__onerror(this); + }, + + load : function() { + this.image.src= this.path; + }, + + clear : function() { + this.loader= null; + + } + }; + + return { + + /** + * @lends CAAT.Module.Preloader.Preloader.prototype + */ + + __init : function() { + this.elements= []; + this.baseURL= ""; + return this; + }, + + currentGroup : null, + + /** + * a list of elements to load. + * @type {Array.<{ id, image }>} + */ + elements: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Callback finished loading. + */ + cfinished: null, + + /** + * Callback element loaded. + */ + cloaded: null, + + /** + * Callback error loading. + */ + cerrored: null, + + /** + * loaded elements count. + */ + loadedCount: 0, + + baseURL : null, + + addElement : function( id, path ) { + this.elements.push( new descriptor(id,this.baseURL+path,this) ); + return this; + }, + + clear : function() { + for( var i=0; i} + */ + images: null, + + /** + * notification callback invoked for each image loaded. + */ + notificationCallback: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Start images loading asynchronous process. This method will notify every image loaded event + * and is responsibility of the caller to count the number of loaded images to see if it fits his + * needs. + * + * @param aImages {{ id:{url}, id2:{url}, ...} an object with id/url pairs. + * @param callback_loaded_one_image {function( imageloader {CAAT.ImagePreloader}, counter {number}, images {{ id:{string}, image: {Image}}} )} + * function to call on every image load. + */ + loadImages: function( aImages, callback_loaded_one_image, callback_error ) { + + if (!aImages) { + if (callback_loaded_one_image ) { + callback_loaded_one_image(0,[]); + } + } + + var me= this, i; + this.notificationCallback = callback_loaded_one_image; + this.images= []; + for( i=0; i>= 0; + + var atop = true; + var abottom = true; + var aleft = true; + var aright = true; + if (typeof areas !== 'undefined') { + if (typeof areas.top !== 'undefined') { + atop = areas.top; + } + if (typeof areas.bottom !== 'undefined') { + abottom = areas.bottom; + } + if (typeof areas.left !== 'undefined') { + aleft = areas.left; + } + if (typeof areas.right !== 'undefined') { + aright = areas.right; + } + } + + + var canvas = document.createElement('canvas'); + canvas.width = image.width; + canvas.height = image.height; + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'rgba(0,0,0,0)'; + ctx.fillRect(0, 0, image.width, image.height); + ctx.drawImage(image, 0, 0); + + var imageData = ctx.getImageData(0, 0, image.width, image.height); + var data = imageData.data; + + var i, j; + var miny = 0, maxy = canvas.height - 1; + var minx = 0, maxx = canvas.width - 1; + + var alpha = false; + + if (atop) { + for (i = 0; i < canvas.height; i++) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + // i contiene el indice del ultimo scan que no es transparente total. + miny = i; + } + + if (abottom) { + alpha = false; + for (i = canvas.height - 1; i >= miny; i--) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + maxy = i; + } + + if (aleft) { + alpha = false; + for (j = 0; j < canvas.width; j++) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + minx = j; + } + + if (aright) { + alpha = false; + for (j = canvas.width - 1; j >= minx; j--) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + maxx = j; + } + + if (0 === minx && 0 === miny && canvas.width - 1 === maxx && canvas.height - 1 === maxy) { + return canvas; + } + + var width = maxx - minx + 1; + var height = maxy - miny + 1; + var id2 = ctx.getImageData(minx, miny, width, height); + + canvas.width = width; + canvas.height = height; + ctx = canvas.getContext('2d'); + ctx.putImageData(id2, 0, 0); + + return canvas; + }, + + + createThumb:function (image, w, h, best_fit) { + w = w || 24; + h = h || 24; + var canvas = document.createElement('canvas'); + canvas.width = w; + canvas.height = h; + var ctx = canvas.getContext('2d'); + + if (best_fit) { + var max = Math.max(image.width, image.height); + var ww = image.width / max * w; + var hh = image.height / max * h; + ctx.drawImage(image, (w - ww) / 2, (h - hh) / 2, ww, hh); + } else { + ctx.drawImage(image, 0, 0, w, h); + } + + return canvas; + } + } + +}) +/** + * See LICENSE file. + * + * This file contains the definition for objects QuadTree and HashMap. + * Quadtree offers an exact list of collisioning areas, while HashMap offers a list of potentially colliding + * elements. + * Specially suited for static content. + * + **/ + +CAAT.Module({ + + /** + * @name Collision + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name QuadTree + * @memberOf CAAT.Module.Collision + * @constructor + */ + + defines:"CAAT.Module.Collision.QuadTree", + depends:[ + "CAAT.Math.Rectangle" + ], + extendsClass:"CAAT.Math.Rectangle", + extendsWith:function () { + + var QT_MAX_ELEMENTS = 1; + var QT_MIN_WIDTH = 32; + + return { + + /** + * @lends CAAT.Module.Collision.QuadTree.prototype + */ + + /** + * For each quadtree level this keeps the list of overlapping elements. + */ + bgActors:null, + + /** + * For each quadtree, this quadData keeps another 4 quadtrees up to the maximum recursion level. + */ + quadData:null, + + create:function (l, t, r, b, backgroundElements, minWidth, maxElements) { + + if (typeof minWidth === 'undefined') { + minWidth = QT_MIN_WIDTH; + } + if (typeof maxElements === 'undefined') { + maxElements = QT_MAX_ELEMENTS; + } + + var cx = (l + r) / 2; + var cy = (t + b) / 2; + + this.x = l; + this.y = t; + this.x1 = r; + this.y1 = b; + this.width = r - l; + this.height = b - t; + + this.bgActors = this.__getOverlappingActorList(backgroundElements); + + if (this.bgActors.length <= maxElements || this.width <= minWidth) { + return this; + } + + this.quadData = new Array(4); + this.quadData[0] = new CAAT.Module.Collision.QuadTree().create(l, t, cx, cy, this.bgActors); // TL + this.quadData[1] = new CAAT.Module.Collision.QuadTree().create(cx, t, r, cy, this.bgActors); // TR + this.quadData[2] = new CAAT.Module.Collision.QuadTree().create(l, cy, cx, b, this.bgActors); // BL + this.quadData[3] = new CAAT.Module.Collision.QuadTree().create(cx, cy, r, b, this.bgActors); + + return this; + }, + + __getOverlappingActorList:function (actorList) { + var tmpList = []; + for (var i = 0, l = actorList.length; i < l; i++) { + var actor = actorList[i]; + if (this.intersects(actor.AABB)) { + tmpList.push(actor); + } + } + return tmpList; + }, + + /** + * Call this method to thet the list of colliding elements with the parameter rectangle. + * @param rectangle + * @return {Array} + */ + getOverlappingActors:function (rectangle) { + var i, j, l; + var overlappingActors = []; + var qoverlappingActors; + var actors = this.bgActors; + var actor; + + if (this.quadData) { + for (i = 0; i < 4; i++) { + if (this.quadData[i].intersects(rectangle)) { + qoverlappingActors = this.quadData[i].getOverlappingActors(rectangle); + for (j = 0, l = qoverlappingActors.length; j < l; j++) { + overlappingActors.push(qoverlappingActors[j]); + } + } + } + } else { + for (i = 0, l = actors.length; i < l; i++) { + actor = actors[i]; + if (rectangle.intersects(actor.AABB)) { + overlappingActors.push(actor); + } + } + } + + return overlappingActors; + } + } + } +}); +CAAT.Module( { + + + /** + * @name SpatialHash + * @memberOf CAAT.Module.Collision + * @constructor + */ + + + defines : "CAAT.Module.Collision.SpatialHash", + aliases : ["CAAT.SpatialHash"], + depends : [ + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Collision.SpatialHash.prototype + */ + + /** + * A collection ob objects to test collision among them. + */ + elements : null, + + /** + * Space width + */ + width : null, + + /** + * Space height + */ + height : null, + + /** + * Rows to partition the space. + */ + rows : null, + + /** + * Columns to partition the space. + */ + columns : null, + + xcache : null, + ycache : null, + xycache : null, + + rectangle : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r0 : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r1 : null, + + initialize : function( w,h, rows,columns ) { + + var i, j; + + this.elements= []; + for( i=0; i>0 ); + } + + this.ycache= []; + for( i=0; i>0 ); + } + + this.xycache=[]; + for( i=0; i1 ) { // at least 2 elements could collide + this._solveCollisionCell( cell, callback ); + } + } + }, + + _solveCollisionCell : function( cell, callback ) { + var i,j; + + for( i=0; i0 ) { + this.freeChunks.splice( i++,0,{position: lp, size:ls} ); + } + if ( rs>0 ) { + this.freeChunks.splice( i,0,{position: rp, size:rs} ); + } + + return true; + } + } + + return false; + }, + log : function(index) { + if ( 0===this.freeChunks.length ) { + CAAT.log('index '+index+' empty'); + } else { + var str='index '+index; + for( var i=0; ithis.width||height>this.height) { + return null; + } + + // find first fitting point + var i,j,initialPosition= 0; + + while( initialPosition<=this.scanMapHeight-height) { + + // para buscar sitio se buscara un sitio hasta el tamano de alto del trozo. + // mas abajo no va a caber. + + // fitHorizontalPosition es un array con todas las posiciones de este scan donde + // cabe un chunk de tamano width. + var fitHorizontalPositions= null; + var foundPositionOnScan= false; + + for( ; initialPosition<=this.scanMapHeight-height; initialPosition++ ) { + fitHorizontalPositions= this.scanMap[ initialPosition ].findWhereFits( width ); + + // si no es nulo el array de resultados, quiere decir que en alguno de los puntos + // nos cabe un trozo de tamano width. + if ( null!==fitHorizontalPositions && fitHorizontalPositions.length>0 ) { + foundPositionOnScan= true; + break; + } + } + + if ( foundPositionOnScan ) { + // j es el scan donde cabe un trozo de tamano width. + // comprobamos desde este scan que en todos los scan verticales cabe el trozo. + // se comprueba que cabe en alguno de los tamanos que la rutina de busqueda horizontal + // nos ha devuelto antes. + + var minInitialPosition=Number.MAX_VALUE; + for( j=0; jb.width ? -1 : 0; + } else if ( me.criteria==='height' ) { + return a.heightb.height ? -1 : 0; + } + return aareabarea ? -1 : 0; + }); + + for( i=0; iTIME ) { + difftime= TIME; + } + + setTimeout( + function() { + endSplash(director, images, sceneCreationCallback); + }, + difftime ); + + } else { + endSplash(director, images, sceneCreationCallback); + } + + } + }; + + return scene; + } + /** + * Finish splash process by either timeout or resources allocation end. + */ + function endSplash(director, images, onEndSplashCallback) { + + director.emptyScenes(); + director.setImagesCache(images); + director.setClear( true ); + + onEndSplashCallback(director); + + /** + * Change this sentence's parameters to play with different entering-scene + * curtains. + * just perform a director.setScene(0) to play first director's scene. + */ + + director.setClear( CAAT.Foundation.Director.CLEAR_ALL ); + director.easeIn( + 0, + CAAT.Foundation.Scene.EASE_SCALE, + 2000, + false, + CAAT.Foundation.Actor.ANCHOR_CENTER, + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(2.5, .4) ); + + } + + var canvascontainer= document.getElementById(runHere); + var director; + + if ( CAAT.__CSS__ ) { // css renderer + if ( canvascontainer ) { + if ( false===canvascontainer instanceof HTMLDivElement ) { + canvascontainer= null; + } + } + + if ( canvascontainer===null ) { + canvascontainer= document.createElement('div'); // create a new DIV + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + + } else { + + if ( canvascontainer ) { + if ( canvascontainer instanceof HTMLDivElement ) { + var ncanvascontainer= document.createElement("canvas"); + canvascontainer.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } else if ( false==canvascontainer instanceof HTMLCanvasElement ) { + var ncanvascontainer= document.createElement("canvas"); + document.body.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } + } else { + canvascontainer= document.createElement('canvas'); + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + } + + + /** + * Load splash images. It is supossed the splash has some images. + */ + var imgs= []; + if ( splash_path ) { + imgs.push( {id:'splash', url: splash_path } ); + } + if ( spinner_path ) { + imgs.push( {id:'spinner', url: spinner_path } ); + } + + director.setClear( CAAT.Foundation.Director.CLEAR_DIRTY_RECTS ); + + new CAAT.Module.Preloader.ImagePreloader().loadImages( + imgs, + function on_load( counter, images ) { + + if ( counter===images.length ) { + + director.setImagesCache(images); + var splashScene= createSplashScene(director, minTime || 5000, onEndSplash); + CAAT.loop(60); + + if ( imagesURL && imagesURL.length>0 ) { + /** + * Load resources for non splash screen + */ + new CAAT.Module.Preloader.ImagePreloader().loadImages( + imagesURL, + splashScene.loadedImage + ); + } else { + splashScene.loadedImage(0,null); + } + } + } + ); + } + + } +});/** + * See LICENSE file. + * + * This object manages CSS3 transitions reflecting applying behaviors. + * + **/ + +(function() { + + /** + * @name CSS + * @memberOf CAAT + * @namespace + */ + + CAAT.CSS= {}; + + /** + * @lends CAAT.CSS + */ + + + /** + * Guess a browser custom prefix. + * @type {*} + */ + CAAT.CSS.PREFIX= (function() { + + var prefix = ""; + var prefixes = ['WebKit', 'Moz', 'O']; + var keyframes= ""; + + // guess this browser vendor prefix. + for (var i = 0; i < prefixes.length; i++) { + if (window[prefixes[i] + 'CSSKeyframeRule']) { + prefix = prefixes[i].toLowerCase(); + break; + } + } + + CAAT.CSS.PROP_ANIMATION= '-'+prefix+'-animation'; + + return prefix; + })(); + + /** + * Apply a given @key-frames animation to a DOM element. + * @param domElement {DOMElement} + * @param name {string} animation name + * @param duration_millis {number} + * @param delay_millis {number} + * @param forever {boolean} + */ + CAAT.CSS.applyKeyframe= function( domElement, name, duration_millis, delay_millis, forever ) { + domElement.style[CAAT.CSS.PROP_ANIMATION]= name+' '+(duration_millis/1000)+'s '+(delay_millis/1000)+'s linear both '+(forever ? 'infinite' : '') ; + }; + + /** + * Remove a @key-frames animation from the stylesheet. + * @param name + */ + CAAT.CSS.unregisterKeyframes= function( name ) { + var index= CAAT.CSS.getCSSKeyframesIndex(name); + if ( null!==index ) { + document.styleSheets[ index.sheetIndex ].deleteRule( index.index ); + } + }; + + /** + * + * @param kfDescriptor {object} + * { + * name{string}, + * behavior{CAAT.Behavior}, + * size{!number}, + * overwrite{boolean} + * } + * } + */ + CAAT.CSS.registerKeyframes= function( kfDescriptor ) { + + var name= kfDescriptor.name; + var behavior= kfDescriptor.behavior; + var size= kfDescriptor.size; + var overwrite= kfDescriptor.overwrite; + + if ( typeof name==='undefined' || typeof behavior==='undefined' ) { + throw 'Keyframes must be defined by a name and a CAAT.Behavior instance.'; + } + + if ( typeof size==='undefined' ) { + size= 100; + } + if ( typeof overwrite==='undefined' ) { + overwrite= false; + } + + // find if keyframes has already a name set. + var cssRulesIndex= CAAT.CSS.getCSSKeyframesIndex(name); + if (null!==cssRulesIndex && !overwrite) { + return; + } + + var keyframesRule= behavior.calculateKeyFramesData(CAAT.CSS.PREFIX, name, size, kfDescriptor.anchorX, kfDescriptor.anchorY ); + + if (document.styleSheets) { + if ( !document.styleSheets.length) { + var s = document.createElement('style'); + s.type="text/css"; + + document.getElementsByTagName('head')[ 0 ].appendChild(s); + } + + if ( null!==cssRulesIndex ) { + document.styleSheets[ cssRulesIndex.sheetIndex ].deleteRule( cssRulesIndex.index ); + } + + var index= cssRulesIndex ? cssRulesIndex.sheetIndex : 0; + document.styleSheets[ index ].insertRule( keyframesRule, 0 ); + } + + return keyframesRule; + }; + + CAAT.CSS.getCSSKeyframesIndex= function(name) { + var ss = document.styleSheets; + for (var i = ss.length - 1; i >= 0; i--) { + try { + var s = ss[i], + rs = s.cssRules ? s.cssRules : + s.rules ? s.rules : + []; + + for (var j = rs.length - 1; j >= 0; j--) { + if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE || + rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) { + + return { + sheetIndex : i, + index: j + }; + } + } + } catch(e) { + } + } + + return null; + }; + + CAAT.CSS.getCSSKeyframes= function(name) { + + var ss = document.styleSheets; + for (var i = ss.length - 1; i >= 0; i--) { + try { + var s = ss[i], + rs = s.cssRules ? s.cssRules : + s.rules ? s.rules : + []; + + for (var j = rs.length - 1; j >= 0; j--) { + if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE || + rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) { + + return rs[j]; + } + } + } + catch(e) { + } + } + return null; + }; + + + +})(); +/** + * See LICENSE file. + * + * These classes encapsulate different kinds of paths. + * LinearPath, defines an straight line path, just 2 points. + * CurvePath, defines a path based on a Curve. Curves can be bezier quadric/cubic and catmull-rom. + * Path, is a general purpose class, which composes a path of different path segments (Linear or Curve paths). + * + * A path, has an interpolator which stablish the way the path is traversed (accelerating, by + * easing functions, etc.). Normally, interpolators will be defined by CAAT.Behavior.Interpolator instances, but + * general Paths could be used as well. + * + **/ + + +CAAT.Module({ + + /** + * @name PathUtil + * @memberOf CAAT + * @namespace + */ + + /** + * @name PathSegment + * @memberOf CAAT.PathUtil + * @constructor + */ + + defines:"CAAT.PathUtil.PathSegment", + depends:[ + "CAAT.Math.Rectangle", + "CAAT.Math.Point", + "CAAT.Math.Matrix", + "CAAT.Math.Curve" + ], + extendsWith:function () { + return { + + /** + * @lends CAAT.PathUtil.PathSegment.prototype + */ + + + __init:function () { + this.bbox = new CAAT.Math.Rectangle(); + return this; + }, + + /** + * Color to draw the segment. + */ + color:'#000', + + /** + * Segment length. + */ + length:0, + + /** + * Segment bounding box. + */ + bbox:null, + + /** + * Path this segment belongs to. + */ + parent:null, + + /** + * Set a PathSegment's parent + * @param parent + */ + setParent:function (parent) { + this.parent = parent; + return this; + }, + setColor:function (color) { + if (color) { + this.color = color; + } + return this; + }, + /** + * Get path's last coordinate. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + }, + + /** + * Get path's starting coordinate. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + }, + + /** + * Set this path segment's points information. + * @param points {Array} + */ + setPoints:function (points) { + }, + + /** + * Set a point from this path segment. + * @param point {CAAT.Point} + * @param index {integer} a point index. + */ + setPoint:function (point, index) { + }, + + /** + * Get a coordinate on path. + * The parameter time is normalized, that is, its values range from zero to one. + * zero will mean startCurvePosition and one will be endCurvePosition. Other values + * will be a position on the path relative to the path length. if the value is greater that 1, if will be set + * to modulus 1. + * @param time a float with a value between zero and 1 inclusive both. + * + * @return {CAAT.Point} + */ + getPosition:function (time) { + }, + + /** + * Gets Path length. + * @return {number} + */ + getLength:function () { + return this.length; + }, + + /** + * Gets the path bounding box (or the rectangle that contains the whole path). + * @param rectangle a CAAT.Rectangle instance with the bounding box. + * @return {CAAT.Rectangle} + */ + getBoundingBox:function () { + return this.bbox; + }, + + /** + * Gets the number of control points needed to create the path. + * Each PathSegment type can have different control points. + * @return {number} an integer with the number of control points. + */ + numControlPoints:function () { + }, + + /** + * Gets CAAT.Point instance with the 2d position of a control point. + * @param index an integer indicating the desired control point coordinate. + * @return {CAAT.Point} + */ + getControlPoint:function (index) { + }, + + /** + * Instruments the path has finished building, and that no more segments will be added to it. + * You could later add more PathSegments and endPath must be called again. + */ + endPath:function () { + }, + + /** + * Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments. + * @param iSize an integer indicating the number of segments of the contour polyline. + * + * @return {[CAAT.Point]} + */ + getContour:function (iSize) { + }, + + /** + * Recalculate internal path structures. + */ + updatePath:function (point) { + }, + + /** + * Draw this path using RenderingContext2D drawing primitives. + * The intention is to set a path or pathsegment as a clipping region. + * + * @param ctx {RenderingContext2D} + */ + applyAsPath:function (director) { + }, + + /** + * Transform this path with the given affinetransform matrix. + * @param matrix + */ + transform:function (matrix) { + }, + + drawHandle:function (ctx, x, y) { + + ctx.beginPath(); + ctx.arc( + x, + y, + CAAT.Math.Curve.prototype.HANDLE_SIZE / 2, + 0, + 2 * Math.PI, + false); + ctx.fill(); + } + } + } + +}); +CAAT.Module({ + + /** + * @name ArcPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.ArcPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + aliases:["CAAT.ArcPath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.ArcPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(); + + return this; + }, + + /** + * A collection of CAAT.Math.Point objects which defines the arc (center, start, end) + */ + points:null, + + /** + * Defined clockwise or counterclockwise ? + */ + cw:true, + + /** + * spare point for calculations + */ + newPosition:null, + + /** + * Arc radius. + */ + radius:0, + + /** + * Arc start angle. + */ + startAngle:0, + + /** + * Arc end angle. + */ + angle:2 * Math.PI, + + /** + * is a relative or absolute arc ? + */ + arcTo:false, + + setRadius:function (r) { + this.radius = r; + return this; + }, + + isArcTo:function () { + return this.arcTo; + }, + + setArcTo:function (b) { + this.arcTo = b; + return this; + }, + + initialize:function (x, y, r, angle) { + this.setInitialPosition(x, y); + this.setFinalPosition(x + r, y); + this.angle = angle || 2 * Math.PI; + return this; + }, + + applyAsPath:function (director) { + var ctx = director.ctx; + if (!this.arcTo) { + ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.angle + this.startAngle, this.cw); + } else { + ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius); + } + return this; + }, + setPoint:function (point, index) { + if (index >= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[0].x = x; + this.points[0].y = y; + } + + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + + this.updatePath(this.points[1]); + return this; + }, + /** + * An arc starts and ends in the same point. + */ + endCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(this.points[0].x, this.points[0].y); + } else { + + var angle = this.angle * time * (this.cw ? 1 : -1) + this.startAngle; + + this.newPosition.set( + this.points[0].x + this.radius * Math.cos(angle), + this.points[0].y + this.radius * Math.sin(angle) + ); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + if (!this.arcTo) { + ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.startAngle + this.angle, this.cw); + } else { + ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius); + } + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + for (var i = 0; i < iSize; i++) { + contour.push( + { + x:this.points[0].x + this.radius * Math.cos(i * Math.PI / (iSize / 2)), + y:this.points[0].y + this.radius * Math.sin(i * Math.PI / (iSize / 2)) + } + ); + } + + return contour; + }, + + getPositionFromLength:function (iLength) { + var ratio = iLength / this.length * (this.cw ? 1 : -1); + return this.getPosition(ratio); + /* + this.newPosition.set( + this.points[0].x + this.radius * Math.cos( 2*Math.PI * ratio ), + this.points[0].y + this.radius * Math.sin( 2*Math.PI * ratio ) + ); + return this.newPosition;*/ + }, + + updatePath:function (point) { + + // just move the circle, not modify radius. + if (this.points[1] === point) { + + if (!this.arcTo) { + this.radius = Math.sqrt( + ( this.points[0].x - this.points[1].x ) * ( this.points[0].x - this.points[1].x ) + + ( this.points[0].y - this.points[1].y ) * ( this.points[0].y - this.points[1].y ) + ); + } + + this.length = this.angle * this.radius; + this.startAngle = Math.atan2((this.points[1].y - this.points[0].y), (this.points[1].x - this.points[0].x)); + + } else if (this.points[0] === point) { + this.points[1].set( + this.points[0].x + this.radius * Math.cos(this.startAngle), + this.points[0].y + this.radius * Math.sin(this.startAngle) + ); + } + + this.bbox.setEmpty(); + this.bbox.x = this.points[0].x - this.radius; + this.bbox.y = this.points[0].y - this.radius; + this.bbox.x1 = this.points[0].x + this.radius; + this.bbox.y1 = this.points[0].y + this.radius; + this.bbox.width = 2 * this.radius; + this.bbox.height = 2 * this.radius; + + return this; + } + } + } + +}); +/** + * CAAT.CurvePath + */ +CAAT.Module({ + + /** + * @name CurvePath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.CurvePath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Bezier" + ], + aliases:["CAAT.CurvePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + return { + + /** + * @lends CAAT.PathUtil.CurvePath.prototype + */ + + + __init:function () { + this.__super(); + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A CAAT.Math.Curve instance. + */ + curve:null, + + /** + * spare holder for getPosition coordinate return. + * @type {CAAT.Math.Point} + */ + newPosition:null, + + applyAsPath:function (director) { + this.curve.applyAsPath(director); + return this; + }, + setPoint:function (point, index) { + if (this.curve) { + this.curve.setPoint(point, index); + } + }, + /** + * Set this curve segment's points. + * @param points {Array} + */ + setPoints:function (points) { + var curve = new CAAT.Math.Bezier(); + curve.setPoints(points); + this.curve = curve; + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier quadric instance. + * Parameters are quadric coordinates control points. + * + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @return this + */ + setQuadric:function (p0x, p0y, p1x, p1y, p2x, p2y) { + var curve = new CAAT.Math.Bezier(); + curve.setQuadric(p0x, p0y, p1x, p1y, p2x, p2y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier cubic instance. + * Parameters are cubic coordinates control points. + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @param p3x {number} + * @param p3y {number} + * @return this + */ + setCubic:function (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { + var curve = new CAAT.Math.Bezier(); + curve.setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * @inheritDoc + */ + updatePath:function (point) { + this.curve.update(); + this.length = this.curve.getLength(); + this.curve.getBoundingBox(this.bbox); + return this; + }, + /** + * @inheritDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.curve.solve(this.newPosition, time); + + return this.newPosition; + }, + /** + * Gets the coordinate on the path relative to the path length. + * @param iLength {number} the length at which the coordinate will be taken from. + * @return {CAAT.Point} a CAAT.Point instance with the coordinate on the path corresponding to the + * iLenght parameter relative to segment's length. + */ + getPositionFromLength:function (iLength) { + this.curve.solve(this.newPosition, iLength / this.length); + return this.newPosition; + }, + /** + * Get path segment's first point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.curve.coordlist[0].x; + }, + /** + * Get path segment's last point's y coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.curve.coordlist[this.curve.coordlist.length - 1].x; + }, + /** + * @inheritDoc + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + this.curve.drawHandles = bDrawHandles; + director.ctx.strokeStyle = this.color; + this.curve.paint(director, bDrawHandles); + }, + /** + * @inheritDoc + */ + numControlPoints:function () { + return this.curve.coordlist.length; + }, + /** + * @inheritDoc + * @param index + */ + getControlPoint:function (index) { + return this.curve.coordlist[index]; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.curve.endCurvePosition(); + }, + /** + * @inheritDoc + */ + startCurvePosition:function () { + return this.curve.startCurvePosition(); + }, + /** + * @inheritDoc + * @param iSize + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } + +}); +/** + * CAAT.LinearPath + */ +CAAT.Module({ + + + /** + * @name LinearPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.LinearPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point" + ], + aliases:["CAAT.LinearPath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.LinearPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A collection of points. + * @type {Array.} + */ + points:null, + + /** + * spare holder for getPosition coordinate return. + */ + newPosition:null, + + applyAsPath:function (director) { + // Fixed: Thanks https://github.com/roed + director.ctx.lineTo(this.points[1].x, this.points[1].y); + }, + setPoint:function (point, index) { + if (index === 0) { + this.points[0] = point; + } else if (index === 1) { + this.points[1] = point; + } + }, + /** + * Update this segments length and bounding box info. + */ + updatePath:function (point) { + var x = this.points[1].x - this.points[0].x; + var y = this.points[1].y - this.points[0].y; + this.length = Math.sqrt(x * x + y * y); + + this.bbox.setEmpty(); + this.bbox.union(this.points[0].x, this.points[0].y); + this.bbox.union(this.points[1].x, this.points[1].y); + + return this; + }, + setPoints:function (points) { + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + return this; + }, + /** + * Set this path segment's starting position. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + this.points[0].x = x; + this.points[0].y = y; + this.newPosition.set(x, y); + return this; + }, + /** + * Set this path segment's ending position. + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[1]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.newPosition.set( + (this.points[0].x + (this.points[1].x - this.points[0].x) * time), + (this.points[0].y + (this.points[1].y - this.points[0].y) * time)); + + return this.newPosition; + }, + getPositionFromLength:function (len) { + return this.getPosition(len / this.length); + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.moveTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + ctx.beginPath(); + this.drawHandle(ctx, this.points[0].x, this.points[0].y); + this.drawHandle(ctx, this.points[1].x, this.points[1].y); + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return 2; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + if (0 === index) { + return this.points[0]; + } else if (1 === index) { + return this.points[1]; + } + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + contour.push(this.getPosition(0).clone()); + contour.push(this.getPosition(1).clone()); + + return contour; + } + } + } +}); +CAAT.Module({ + + /** + * @name RectPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.RectPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + aliases:["CAAT.RectPath", "CAAT.ShapePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.RectPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(); + + return this; + }, + + /** + * A collection of Points. + * @type {Array.} + */ + points:null, + + /** + * Traverse this path clockwise or counterclockwise (false). + */ + cw:true, + + /** + * spare point for calculations + */ + newPosition:null, + + applyAsPath:function (director) { + var ctx = director.ctx; + + if (this.cw) { + ctx.lineTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[4].x, this.points[4].y); + } else { + ctx.lineTo(this.points[4].x, this.points[4].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[0].x, this.points[0].y); + } + return this; + }, + setPoint:function (point, index) { + if (index >= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points.push(points[0]); + this.points.push(new CAAT.Math.Point().set(points[1].x, points[0].y)); + this.points.push(points[1]); + this.points.push(new CAAT.Math.Point().set(points[0].x, points[1].y)); + this.points.push(points[0].clone()); + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[i].x = x; + this.points[i].y = y; + } + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[2].x = finalX; + this.points[2].y = finalY; + + this.points[1].x = finalX; + this.points[1].y = this.points[0].y; + + this.points[3].x = this.points[0].x; + this.points[3].y = finalY; + + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + + this.updatePath(); + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[4]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(0, 0); + } else { + var w = this.bbox.width / this.length; + var h = this.bbox.height / this.length; + var accTime = 0; + var times; + var segments; + var index = 0; + + if (this.cw) { + segments = [0, 1, 2, 3, 4]; + times = [w, h, w, h]; + } else { + segments = [4, 3, 2, 1, 0]; + times = [h, w, h, w]; + } + + while (index < times.length) { + if (accTime + times[index] < time) { + accTime += times[index]; + index++; + } else { + break; + } + } + time -= accTime; + + var p0 = segments[index]; + var p1 = segments[index + 1]; + + // index tiene el indice del segmento en tiempo. + this.newPosition.set( + (this.points[p0].x + (this.points[p1].x - this.points[p0].x) * time / times[index]), + (this.points[p0].y + (this.points[p1].y - this.points[p0].y) * time / times[index])); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[2].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.strokeRect( + this.bbox.x, this.bbox.y, + this.bbox.width, this.bbox.height); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (/*iSize*/) { + var contour = []; + + for (var i = 0; i < this.points.length; i++) { + contour.push(this.points[i]); + } + + return contour; + }, + updatePath:function (point) { + + if (point) { + if (point === this.points[0]) { + this.points[1].y = point.y; + this.points[3].x = point.x; + } else if (point === this.points[1]) { + this.points[0].y = point.y; + this.points[2].x = point.x; + } else if (point === this.points[2]) { + this.points[3].y = point.y; + this.points[1].x = point.x; + } else if (point === this.points[3]) { + this.points[0].x = point.x; + this.points[2].y = point.y; + } + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + } + + this.bbox.setEmpty(); + + for (var i = 0; i < 4; i++) { + this.bbox.union(this.points[i].x, this.points[i].y); + } + + this.length = 2 * this.bbox.width + 2 * this.bbox.height; + + this.points[0].x = this.bbox.x; + this.points[0].y = this.bbox.y; + + this.points[1].x = this.bbox.x + this.bbox.width; + this.points[1].y = this.bbox.y; + + this.points[2].x = this.bbox.x + this.bbox.width; + this.points[2].y = this.bbox.y + this.bbox.height; + + this.points[3].x = this.bbox.x; + this.points[3].y = this.bbox.y + this.bbox.height; + + this.points[4].x = this.bbox.x; + this.points[4].y = this.bbox.y; + + return this; + }, + + getPositionFromLength:function (iLength) { + return this.getPosition(iLength / (this.bbox.width * 2 + this.bbox.height * 2)); + } + } + } +}); +CAAT.Module( { + + /** + * @name Path + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines : "CAAT.PathUtil.Path", + aliases : ["CAAT.Path"], + depends : [ + "CAAT.PathUtil.PathSegment", + "CAAT.PathUtil.ArcPath", + "CAAT.PathUtil.CurvePath", + "CAAT.PathUtil.LinearPath", + "CAAT.PathUtil.RectPath", + "CAAT.Math.Bezier", + "CAAT.Math.CatmullRom", + "CAAT.Math.Point", + "CAAT.Math.Matrix" + ], + extendsClass : "CAAT.PathUtil.PathSegment", + extendsWith : { + + /** + * @lends CAAT.PathUtil.Path.prototype + */ + + + __init : function() { + this.__super(); + + this.newPosition= new CAAT.Math.Point(0,0,0); + this.pathSegments= []; + + this.behaviorList= []; + this.matrix= new CAAT.Math.Matrix(); + this.tmpMatrix= new CAAT.Math.Matrix(); + + return this; + }, + + /** + * A collection of PathSegments. + * @type {Array.} + */ + pathSegments: null, // a collection of CAAT.PathSegment instances. + + /** + * For each path segment in this path, the normalized calculated duration. + * precomputed segment duration relative to segment legnth/path length + */ + pathSegmentDurationTime: null, + + /** + * For each path segment in this path, the normalized calculated start time. + * precomputed segment start time relative to segment legnth/path length and duration. + */ + pathSegmentStartTime: null, + + /** + * spare CAAT.Math.Point to return calculated values in the path. + */ + newPosition: null, + + /** + * path length (sum of every segment length) + */ + pathLength: -1, + + /** + * starting path x position + */ + beginPathX: -1, + + /** + * starting path y position + */ + beginPathY: -1, + + /* + last path coordinates position (using when building the path). + */ + trackPathX: -1, + trackPathY: -1, + + /* + needed to drag control points. + */ + ax: -1, + ay: -1, + point: [], + + /** + * Is this path interactive ?. If so, controls points can be moved with a CAAT.Foundation.UI.PathActor. + */ + interactive: true, + + /** + * A list of behaviors to apply to this path. + * A path can be affine transformed to create a different path. + */ + behaviorList: null, + + /* rotation behavior info **/ + + /** + * Path rotation angle. + */ + rb_angle: 0, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorX: .5, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorY: .5, + + /* scale behavior info **/ + + /** + * Path X scale. + */ + sb_scaleX: 1, + + /** + * Path Y scale. + */ + sb_scaleY: 1, + + /** + * Path scale X anchor. + */ + sb_scaleAnchorX: .5, + + /** + * Path scale Y anchor. + */ + sb_scaleAnchorY: .5, + + /** + * Path translation anchor X. + */ + tAnchorX: 0, + + /** + * Path translation anchor Y. + */ + tAnchorY: 0, + + /* translate behavior info **/ + + /** + * Path translation X. + */ + tb_x: 0, + + /** + * Path translation Y. + */ + tb_y: 0, + + /* behavior affine transformation matrix **/ + + /** + * Path behaviors matrix. + */ + matrix: null, + + /** + * Spare calculation matrix. + */ + tmpMatrix: null, + + /** + * Original Path´s path segments points. + */ + pathPoints: null, + + /** + * Path bounding box width. + */ + width: 0, + + /** + * Path bounding box height. + */ + height: 0, + + /** + * Path bounding box X position. + */ + clipOffsetX : 0, + + /** + * Path bounding box Y position. + */ + clipOffsetY : 0, + + /** + * Is this path closed ? + */ + closed : false, + + /** + * Apply this path as a Canvas context path. + * You must explicitly call context.beginPath + * @param director + * @return {*} + */ + applyAsPath : function(director) { + var ctx= director.ctx; + + director.modelViewMatrix.transformRenderingContext( ctx ); + ctx.globalCompositeOperation= 'source-out'; + ctx.moveTo( + this.getFirstPathSegment().startCurvePosition().x, + this.getFirstPathSegment().startCurvePosition().y + ); + for( var i=0; i + * If a call to any method of the form addTo is called before this calling + * this method, they will assume to start at -1,-1 and probably you'll get the wrong path. + * @param px0 {number} + * @param py0 {number} + * + * @return this + */ + beginPath : function( px0, py0 ) { + this.trackPathX= px0; + this.trackPathY= py0; + this.beginPathX= px0; + this.beginPathY= py0; + return this; + }, + /** + * Close the path by adding a line path segment from the current last path + * coordinate to startCurvePosition coordinate. + *

    + * This method closes a path by setting its last path segment's last control point + * to be the first path segment's first control point. + *

    + * This method also sets the path as finished, and calculates all path's information + * such as length and bounding box. + * + * @return this + */ + closePath : function() { + + this.getLastPathSegment().setPoint( + this.getFirstPathSegment().startCurvePosition(), + this.getLastPathSegment().numControlPoints()-1 ); + + + this.trackPathX= this.beginPathX; + this.trackPathY= this.beginPathY; + + this.closed= true; + + this.endPath(); + return this; + }, + /** + * Finishes the process of building the path. It involves calculating each path segments length + * and proportional length related to a normalized path length of 1. + * It also sets current paths length. + * These calculi are needed to traverse the path appropriately. + *

    + * This method must be called explicitly, except when closing a path (that is, calling the + * method closePath) which calls this method as well. + * + * @return this + */ + endPath : function() { + + this.pathSegmentStartTime=[]; + this.pathSegmentDurationTime= []; + + this.updatePath(); + + return this; + }, + /** + * This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path. + * The returned coordinate is the corresponding to normalizing the path's length to 1, + * and then finding what path segment and what coordinate in that path segment corresponds + * for the input time parameter. + *

    + * The parameter time must be a value ranging 0..1. + * If not constrained to these values, the parameter will be modulus 1, and then, if less + * than 0, be normalized to 1+time, so that the value always ranges from 0 to 1. + *

    + * This method is needed when traversing the path throughout a CAAT.Interpolator instance. + * + * + * @param time {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate. + * 1 will return path's end coordinate. + * @param open_contour {boolean=} treat this path as an open contour. It is intended for + * open paths, and interpolators which give values above 1. see tutorial 7.1. + * @link{../../documentation/tutorials/t7-1.html} + * + * @return {CAAT.Foundation.Point} + */ + getPosition : function(time, open_contour) { + + if (open_contour && (time>=1 || time<=0) ) { + + var p0,p1,ratio, angle; + + if ( time>=1 ) { + // these values could be cached. + p0= this.__getPositionImpl( .999 ); + p1= this.endCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= time%1; + + + } else { + // these values could be cached. + p0= this.__getPositionImpl( .001 ); + p1= this.startCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= -time; + } + + var np= this.newPosition; + var length= this.getLength(); + + np.x = p1.x + (ratio * length)*Math.cos(angle); + np.y = p1.y + (ratio * length)*Math.sin(angle); + + + return np; + } + + return this.__getPositionImpl(time); + }, + + __getPositionImpl : function(time) { + + if ( time>1 || time<0 ) { + time%=1; + } + if ( time<0 ) { + time= 1+time; + } + + var ps= this.pathSegments; + var psst= this.pathSegmentStartTime; + var psdt= this.pathSegmentDurationTime; + var l= 0; + var r= ps.length; + var m; + var np= this.newPosition; + var psstv; + while( l!==r ) { + + m= ((r+l)/2)|0; + psstv= psst[m]; + if ( psstv<=time && time<=psstv+psdt[m]) { + time= psdt[m] ? + (time-psstv)/psdt[m] : + 0; + + // Clamp this segment's time to a maximum since it is relative to the path. + // thanks https://github.com/donaldducky for spotting. + if (time>1) { + time=1; + } else if (time<0 ) { + time= 0; + } + + var pointInPath= ps[m].getPosition(time); + np.x= pointInPath.x; + np.y= pointInPath.y; + return np; + } else if ( time=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + + }, + /** + * Analogously to the method getPosition, this method returns a CAAT.Point instance with + * the coordinate on the path that corresponds to the given length. The input length is + * related to path's length. + * + * @param iLength {number} a float with the target length. + * @return {CAAT.Point} + */ + getPositionFromLength : function(iLength) { + + iLength%=this.getLength(); + if (iLength<0 ) { + iLength+= this.getLength(); + } + + var accLength=0; + + for( var i=0; i0 ) { + this.pathSegmentStartTime[i]= this.pathSegmentStartTime[i-1]+this.pathSegmentDurationTime[i-1]; + } else { + this.pathSegmentStartTime[0]= 0; + } + + this.pathSegments[i].endPath(); + } + + this.extractPathPoints(); + + if ( callback ) { + callback(this); + } + + return this; + + }, + /** + * Sent by a CAAT.PathActor instance object to try to drag a path's control point. + * @param x {number} + * @param y {number} + */ + press: function(x,y) { + if (!this.interactive) { + return; + } + + var HS= CAAT.Math.Curve.prototype.HANDLE_SIZE/2; + for( var i=0; i=point.x-HS && + y>=point.y-HS && + x} + */ + setPoints : function( points ) { + if ( this.points.length===points.length ) { + for( var i=0; i=0 && index + * This class is a SVG Path parser. + * By calling the method parsePath( svgpath ) an instance of CAAT.PathUtil.Path will be built by parsing + * its contents. + * + *

    + * See demo32 + * + * @name SVGPath + * @memberOf CAAT.PathUtil + * @constructor + */ + + defines:"CAAT.PathUtil.SVGPath", + depends:[ + "CAAT.PathUtil.Path" + ], + extendsWith:function () { + + var OK = 0; + var EOF = 1; + var NAN = 2; + + function error(pathInfo, c) { + var cpos = c; + if (cpos < 0) { + cpos = 0; + } + console.log("parse error near ..." + pathInfo.substr(cpos, 20)); + } + + return { + + /** + * @lends CAAT.PathUtil.SVGPath.prototype + */ + + + __init:function () { + + }, + + /** + * @private + */ + c:0, + + /** + * @private + */ + bezierInfo:null, + + __skipBlank:function (pathInfo, c) { + var p = pathInfo.charAt(c); + while (c < pathInfo.length && (p == ' ' || p == '\n' || p == '\t' || p == ',')) { + ++c; + var p = pathInfo.charAt(c); + } + + return c; + }, + + __maybeNumber:function (pathInfo, c) { + + if (c < pathInfo.length - 2) { + + var p = pathInfo.charAt(c); + var p1 = pathInfo.charAt(c + 1); + + return p == '-' || + this.__isDigit(p) || + (p === "." && this.__isDigit(p1) ); + } + + return false; + }, + + __isDigit:function (c) { + return c >= "0" && c <= "9"; + }, + + + __getNumber:function (pathInfo, c, v, error) { + c = this.__skipBlank(pathInfo, c); + if (c < pathInfo.length) { + var nc = this.__findNumber(pathInfo, c); + if (nc !== -1) { + v.push(parseFloat(pathInfo.substr(c, nc))); + c = this.__skipBlank(pathInfo, nc); + error.pos = c; + error.result = OK; + return; + } else { + error.result = NAN; + return; + } + } + + error.result = EOF; + }, + + ____getNumbers:function (pathInfo, c, v, n, error) { + + for (var i = 0; i < n; i++) { + this.__getNumber(pathInfo, c, v, error); + if (error.result != OK) { + break; + } else { + c = error.pos; + } + } + + return c; + }, + + + __findNumber:function (pathInfo, c) { + + var p; + + if ((p = pathInfo.charAt(c)) == '-') { + ++c; + } + + if (!this.__isDigit((p = pathInfo.charAt(c)))) { + if ((p = pathInfo.charAt(c)) != '.' || !this.__isDigit(pathInfo.charAt(c + 1))) { + return -1; + } + } + + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + + if ((p = pathInfo.charAt(c)) == '.') { + ++c; + if (!this.__isDigit((p = pathInfo.charAt(c)))) { // asumo un numero [d+]\. como valido. + return c; + } + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + } + + return c; + }, + + __parseMoveTo:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + + if (error.result === OK) { + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.beginPath(numbers[0], numbers[1]); + } else { + return; + } + + if (this.__maybeNumber(pathInfo, c)) { + c = this.parseLine(pathInfo, c, absolute, path, error); + } + + error.pos = c; + }, + + __parseLine:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + + __parseLineH:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[0] += path.trackPathX; + } + numbers[1].push(path.trackPathY); + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseLineV:function (pathInfo, c, absolute, path, error) { + + var numbers = [ path.trackPathX ]; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[1] += path.trackPathY; + } + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubic:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 6, error); + if (error.result === OK) { + if (!absolute) { + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + v[4] += path.trackPathX; + v[5] += path.trackPathY; + } + + path.addCubicTo(v[0], v[1], v[2], v[3], v[4], v[5]); + + + v.shift(); + v.shift(); + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubicS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result == OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addCubicTo(x, y, v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseQuadricS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addQuadricTo(x, y, v[0], v[1]); + + this.bezierInfo = []; + bezierInfo.push(x); + bezierInfo.push(y); + bezierInfo.push(v[0]); + bezierInfo.push(v[1]); + + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + + __parseQuadric:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + path.addQuadricTo(v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseClosePath:function (pathInfo, c, path, error) { + + path.closePath(); + error.pos= c; + + }, + + /** + * This method will create a CAAT.PathUtil.Path object with as many contours as needed. + * @param pathInfo {string} a SVG path + * @return Array. + */ + parsePath:function (pathInfo) { + + this.c = 0; + this.contours= []; + + var path = new CAAT.PathUtil.Path(); + this.contours.push( path ); + + this.c = this.__skipBlank(pathInfo, this.c); + if (this.c === pathInfo.length) { + return path; + } + + var ret = { + pos:0, + result:0 + } + + while (this.c != pathInfo.length) { + var segment = pathInfo.charAt(this.c); + switch (segment) { + case 'm': + this.__parseMoveTo(pathInfo, this.c + 1, false, path, ret); + break; + case 'M': + this.__parseMoveTo(pathInfo, this.c + 1, true, path, ret); + break; + case 'c': + this.__parseCubic(pathInfo, this.c + 1, false, path, ret); + break; + case 'C': + this.__parseCubic(pathInfo, this.c + 1, true, path, ret); + break; + case 's': + this.__parseCubicS(pathInfo, this.c + 1, false, path, ret); + break; + case 'S': + this.__parseCubicS(pathInfo, this.c + 1, true, path, ret); + break; + case 'q': + this.__parseQuadric(pathInfo, this.c + 1, false, path, ret); + break; + case 'Q': + this.__parseQuadricS(pathInfo, this.c + 1, true, path, ret); + break; + case 't': + this.__parseQuadricS(pathInfo, this.c + 1, false, path, ret); + break; + case 'T': + this.__parseQuadric(pathInfo, this.c + 1, true, path, ret); + break; + case 'l': + this.__parseLine(pathInfo, this.c + 1, false, path, ret); + break; + case 'L': + this.__parseLine(pathInfo, this.c + 1, true, path, ret); + break; + case 'h': + this.__parseLineH(pathInfo, this.c + 1, false, path, ret); + break; + case 'H': + this.__parseLineH(pathInfo, this.c + 1, true, path, ret); + break; + case 'v': + this.__parseLineV(pathInfo, this.c + 1, false, path, ret); + break; + case 'V': + this.__parseLineV(pathInfo, this.c + 1, true, path, ret); + break; + case 'z': + case 'Z': + this.__parseClosePath(pathInfo, this.c + 1, path, ret); + path= new CAAT.PathUtil.Path(); + this.contours.push( path ); + break; + case 0: + break; + default: + error(pathInfo, this.c); + break; + } + + if (ret.result != OK) { + error(pathInfo, this.c); + break; + } else { + this.c = ret.pos; + } + + } // while + + var count= 0; + var fpath= null; + for( var i=0; i, + * point : { + * x: , + * y: }� + * }> + * @return {*} + */ + addTouch : function( touchInfo ) { + if ( -1===this.touches.indexOf( touchInfo ) ) { + this.touches.push( touchInfo ); + } + return this; + }, + addChangedTouch : function( touchInfo ) { + if ( -1===this.changedTouches.indexOf( touchInfo ) ) { + this.changedTouches.push( touchInfo ); + } + return this; + }, + isAltDown : function() { + return this.alt; + }, + isControlDown : function() { + return this.control; + }, + isShiftDown : function() { + return this.shift; + }, + isMetaDown: function() { + return this.meta; + }, + getSourceEvent : function() { + return this.sourceEvent; + } + } +}); +CAAT.Module( { + + /** + * @name MouseEvent + * @memberOf CAAT.Event + * @constructor + */ + + defines : "CAAT.Event.MouseEvent", + aliases : ["CAAT.MouseEvent"], + depends : [ + "CAAT.Math.Point" + ], + extendsWith : { + + /** + * @lends CAAT.Event.MouseEvent.prototype + */ + + /** + * Constructor delegate + * @private + */ + __init : function() { + this.point= new CAAT.Math.Point(0,0,0); + this.screenPoint= new CAAT.Math.Point(0,0,0); + this.touches= []; + return this; + }, + + /** + * Original mouse/touch screen coord + */ + screenPoint: null, + + /** + * Transformed in-actor coordinate + */ + point: null, + + /** + * scene time when the event was triggered. + */ + time: 0, + + /** + * Actor the event was produced in. + */ + source: null, + + /** + * Was shift pressed ? + */ + shift: false, + + /** + * Was control pressed ? + */ + control: false, + + /** + * was alt pressed ? + */ + alt: false, + + /** + * was Meta key pressed ? + */ + meta: false, + + /** + * Original mouse/touch event + */ + sourceEvent: null, + + touches : null, + + init : function( x,y,sourceEvent,source,screenPoint,time ) { + this.point.set(x,y); + this.source= source; + this.screenPoint= screenPoint; + this.alt = sourceEvent.altKey; + this.control = sourceEvent.ctrlKey; + this.shift = sourceEvent.shiftKey; + this.meta = sourceEvent.metaKey; + this.sourceEvent= sourceEvent; + this.x= x; + this.y= y; + this.time= time; + return this; + }, + isAltDown : function() { + return this.alt; + }, + isControlDown : function() { + return this.control; + }, + isShiftDown : function() { + return this.shift; + }, + isMetaDown: function() { + return this.meta; + }, + getSourceEvent : function() { + return this.sourceEvent; + } + } +}); +CAAT.Module( { + + /** + * @name Event + * @memberOf CAAT + * @namespace + */ + + /** + * @name KeyEvent + * @memberOf CAAT.Event + * @constructor + */ + + /** + * @name KEYS + * @memberOf CAAT + * @namespace + */ + + /** + * @name KEY_MODIFIERS + * @memberOf CAAT + * @namespace + */ + + defines : "CAAT.Event.KeyEvent", + aliases : "CAAT.KeyEvent", + extendsWith : { + + /** + * @lends CAAT.Event.KeyEvent.prototype + */ + + /** + * Define a key event. + * @param keyCode + * @param up_or_down + * @param modifiers + * @param originalEvent + */ + __init : function( keyCode, up_or_down, modifiers, originalEvent ) { + this.keyCode= keyCode; + this.action= up_or_down; + this.modifiers= modifiers; + this.sourceEvent= originalEvent; + + this.preventDefault= function() { + this.sourceEvent.preventDefault(); + } + + this.getKeyCode= function() { + return this.keyCode; + }; + + this.getAction= function() { + return this.action; + }; + + this.modifiers= function() { + return this.modifiers; + }; + + this.isShiftPressed= function() { + return this.modifiers.shift; + }; + + this.isControlPressed= function() { + return this.modifiers.control; + }; + + this.isAltPressed= function() { + return this.modifiers.alt; + }; + + this.getSourceEvent= function() { + return this.sourceEvent; + }; + } + }, + onCreate : function() { + + /** + * @lends CAAT + */ + + /** + * Key codes + * @type {enum} + */ + CAAT.KEYS = { + + /** @const */ ENTER:13, + /** @const */ BACKSPACE:8, + /** @const */ TAB:9, + /** @const */ SHIFT:16, + /** @const */ CTRL:17, + /** @const */ ALT:18, + /** @const */ PAUSE:19, + /** @const */ CAPSLOCK:20, + /** @const */ ESCAPE:27, + /** @const */ PAGEUP:33, + /** @const */ PAGEDOWN:34, + /** @const */ END:35, + /** @const */ HOME:36, + /** @const */ LEFT:37, + /** @const */ UP:38, + /** @const */ RIGHT:39, + /** @const */ DOWN:40, + /** @const */ INSERT:45, + /** @const */ DELETE:46, + /** @const */ 0:48, + /** @const */ 1:49, + /** @const */ 2:50, + /** @const */ 3:51, + /** @const */ 4:52, + /** @const */ 5:53, + /** @const */ 6:54, + /** @const */ 7:55, + /** @const */ 8:56, + /** @const */ 9:57, + /** @const */ a:65, + /** @const */ b:66, + /** @const */ c:67, + /** @const */ d:68, + /** @const */ e:69, + /** @const */ f:70, + /** @const */ g:71, + /** @const */ h:72, + /** @const */ i:73, + /** @const */ j:74, + /** @const */ k:75, + /** @const */ l:76, + /** @const */ m:77, + /** @const */ n:78, + /** @const */ o:79, + /** @const */ p:80, + /** @const */ q:81, + /** @const */ r:82, + /** @const */ s:83, + /** @const */ t:84, + /** @const */ u:85, + /** @const */ v:86, + /** @const */ w:87, + /** @const */ x:88, + /** @const */ y:89, + /** @const */ z:90, + /** @const */ SELECT:93, + /** @const */ NUMPAD0:96, + /** @const */ NUMPAD1:97, + /** @const */ NUMPAD2:98, + /** @const */ NUMPAD3:99, + /** @const */ NUMPAD4:100, + /** @const */ NUMPAD5:101, + /** @const */ NUMPAD6:102, + /** @const */ NUMPAD7:103, + /** @const */ NUMPAD8:104, + /** @const */ NUMPAD9:105, + /** @const */ MULTIPLY:106, + /** @const */ ADD:107, + /** @const */ SUBTRACT:109, + /** @const */ DECIMALPOINT:110, + /** @const */ DIVIDE:111, + /** @const */ F1:112, + /** @const */ F2:113, + /** @const */ F3:114, + /** @const */ F4:115, + /** @const */ F5:116, + /** @const */ F6:117, + /** @const */ F7:118, + /** @const */ F8:119, + /** @const */ F9:120, + /** @const */ F10:121, + /** @const */ F11:122, + /** @const */ F12:123, + /** @const */ NUMLOCK:144, + /** @const */ SCROLLLOCK:145, + /** @const */ SEMICOLON:186, + /** @const */ EQUALSIGN:187, + /** @const */ COMMA:188, + /** @const */ DASH:189, + /** @const */ PERIOD:190, + /** @const */ FORWARDSLASH:191, + /** @const */ GRAVEACCENT:192, + /** @const */ OPENBRACKET:219, + /** @const */ BACKSLASH:220, + /** @const */ CLOSEBRAKET:221, + /** @const */ SINGLEQUOTE:222 + }; + + /** + * @deprecated + * @type {Object} + */ + CAAT.Keys= CAAT.KEYS; + + /** + * Shift key code + * @type {Number} + */ + CAAT.SHIFT_KEY= 16; + + /** + * Control key code + * @type {Number} + */ + CAAT.CONTROL_KEY= 17; + + /** + * Alt key code + * @type {Number} + */ + CAAT.ALT_KEY= 18; + + /** + * Enter key code + * @type {Number} + */ + CAAT.ENTER_KEY= 13; + + /** + * Event modifiers. + * @type enum + */ + CAAT.KEY_MODIFIERS= { + + /** @const */ alt: false, + /** @const */ control: false, + /** @const */ shift: false + }; + } + +}); +CAAT.Module( { + defines : "CAAT.Event.Input", + depends : [ + "CAAT.Event.KeyEvent", + "CAAT.Event.MouseEvent", + "CAAT.Event.TouchEvent" + ], + onCreate : function() { + + /** + * @lends CAAT + */ + + /** + * Set the cursor. + * @param cursor + */ + CAAT.setCursor= function(cursor) { + if ( navigator.browser!=='iOS' ) { + document.body.style.cursor= cursor; + } + }; + + + /** + * Constant to set touch behavior as single touch, compatible with mouse. + * @type {Number} + * @constant + */ + CAAT.TOUCH_AS_MOUSE= 1; + + /** + * Constant to set CAAT touch behavior as multitouch. + * @type {Number} + * @contant + */ + CAAT.TOUCH_AS_MULTITOUCH= 2; + + /** + * Set CAAT touch behavior as single or multi touch. + * @type {Number} + */ + CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MOUSE; + + /** + * Array of window resize listeners. + * @type {Array} + */ + CAAT.windowResizeListeners= []; + + /** + * Register a function callback as window resize listener. + * @param f + */ + CAAT.registerResizeListener= function(f) { + CAAT.windowResizeListeners.push(f); + }; + + /** + * Remove a function callback as window resize listener. + * @param director + */ + CAAT.unregisterResizeListener= function(director) { + for( var i=0; i=this.duration ) { + this.remove= true; + if( this.callback_timeout ) { + this.callback_timeout( time, ttime, this ); + } + } else { + if ( this.callback_tick ) { + this.callback_tick( time, ttime, this ); + } + } + return this; + }, + remainingTime : function() { + return this.duration - (this.scene.time-this.startTime); + }, + /** + * Reschedules this TimerTask by changing its startTime to current scene's time. + * @param time {number} an integer indicating scene time. + * @return this + */ + reset : function( time ) { + this.remove= false; + this.startTime= time; + this.owner.ensureTimerTask(this); + return this; + }, + /** + * Cancels this timer by removing it on scene's next frame. The function callback_cancel will + * be called. + * @return this + */ + cancel : function() { + this.remove= true; + if ( null!=this.callback_cancel ) { + this.callback_cancel( this.scene.time, this.scene.time-this.startTime, this ); + } + return this; + }, + addTime : function( time ) { + this.duration+= time; + return this; + } + } +}); +/** + * See LICENSE file. + */ +CAAT.Module({ + + /** + * @name Timer + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name TimerManager + * @memberOf CAAT.Foundation.Timer + * @constructor + */ + + defines : "CAAT.Foundation.Timer.TimerManager", + aliases : ["CAAT.TimerManager"], + depends : [ + "CAAT.Foundation.Timer.TimerTask" + ], + extendsWith : { + + /** + * @lends CAAT.Foundation.Timer.TimerManager.prototype + */ + + __init:function () { + this.timerList = []; + return this; + }, + + /** + * Collection of registered timers. + * @type {CAAT.Foundation.Timer.TimerManager} + * @private + */ + timerList:null, + + /** + * Index sequence to idenfity registered timers. + * @private + */ + timerSequence:0, + + /** + * Check and apply timers in frame time. + * @param time {number} the current Scene time. + */ + checkTimers:function (time) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (!tl[i].remove) { + tl[i].checkTask(time); + } + i--; + } + }, + /** + * Make sure the timertask is contained in the timer task list by adding it to the list in case it + * is not contained. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return this + */ + ensureTimerTask:function (timertask) { + if (!this.hasTimer(timertask)) { + this.timerList.push(timertask); + } + return this; + }, + /** + * Check whether the timertask is in this scene's timer task list. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return {boolean} a boolean indicating whether the timertask is in this scene or not. + */ + hasTimer:function (timertask) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (tl[i] === timertask) { + return true; + } + i--; + } + + return false; + }, + /** + * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene + * is taken out of the Director the timer task is paused, and resumed on Scene restoration. + * + * @param startTime {number} an integer indicating the scene time this task must start executing at. + * @param duration {number} an integer indicating the timerTask duration. + * @param callback_timeout {function} timer on timeout callback function. + * @param callback_tick {function} timer on tick callback function. + * @param callback_cancel {function} timer on cancel callback function. + * + * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. + */ + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) { + + var tt = new CAAT.Foundation.Timer.TimerTask().create( + startTime, + duration, + callback_timeout, + callback_tick, + callback_cancel); + + tt.taskId = this.timerSequence++; + tt.sceneTime = scene.time; + tt.owner = this; + tt.scene = scene; + + this.timerList.push(tt); + + return tt; + }, + /** + * Removes expired timers. This method must not be called directly. + */ + removeExpiredTimers:function () { + var i; + var tl = this.timerList; + for (i = 0; i < tl.length; i++) { + if (tl[i].remove) { + tl.splice(i, 1); + } + } + } + } +}); +CAAT.Module( { + + /** + * @name Layout + * @memberOf CAAT.Foundation.UI + * @namespace + */ + + /** + * @name LayoutManager + * @memberOf CAAT.Foundation.UI.Layout + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.LayoutManager", + aliases : ["CAAT.UI.LayoutManager"], + depends : [ + "CAAT.Behavior.Interpolator" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager + */ + + /** + * @enum {number} + */ + AXIS: { + X : 0, + Y : 1 + }, + + /** + * @enum {number} + */ + ALIGNMENT : { + LEFT : 0, + RIGHT: 1, + CENTER: 2, + TOP: 3, + BOTTOM: 4, + JUSTIFY:5 + } + + }, + extendsWith : function() { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager.prototype + */ + + + __init : function( ) { + + this.newChildren= []; + this.padding= { + left: 2, + right: 2, + top: 2, + bottom: 2 + }; + + return this; + }, + + /** + * If animation enabled, new element interpolator. + */ + newElementInterpolator : new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1,.7), + + /** + * If animation enabled, relayout elements interpolator. + */ + moveElementInterpolator : new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2), + + /** + * Defines insets: + * @type {{ left, right, top, botton }} + */ + padding : null, + + /** + * Needs relayout ?? + */ + invalid : true, + + /** + * Horizontal gap between children. + */ + hgap : 2, + + /** + * Vertical gap between children. + */ + vgap : 2, + + /** + * Animate on adding/removing elements. + */ + animated : false, + + /** + * pending to be laid-out actors. + */ + newChildren : null, + + setAnimated : function( animate ) { + this.animated= animate; + return this; + }, + + setHGap : function( gap ) { + this.hgap= gap; + this.invalidateLayout(); + return this; + }, + + setVGap : function( gap ) { + this.vgap= gap; + this.invalidateLayout(); + return this; + }, + + setAllPadding : function( s ) { + this.padding.left= s; + this.padding.right= s; + this.padding.top= s; + this.padding.bottom= s; + this.invalidateLayout(); + return this; + }, + + setPadding : function( l,r, t,b ) { + this.padding.left= l; + this.padding.right= r; + this.padding.top= t; + this.padding.bottom= b; + this.invalidateLayout(); + return this; + }, + + addChild : function( child, constraints ) { + this.newChildren.push( child ); + }, + + removeChild : function( child ) { + + }, + + doLayout : function( container ) { + this.newChildren= []; + this.invalid= false; + }, + + invalidateLayout : function( container ) { + this.invalid= true; + }, + + getMinimumLayoutSize : function( container ) { + + }, + + getPreferredLayoutSize : function(container ) { + + }, + + isValid : function() { + return !this.invalid; + }, + + isInvalidated : function() { + return this.invalid; + } + } + } +}); +CAAT.Module({ + + /** + * @name BoxLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines:"CAAT.Foundation.UI.Layout.BoxLayout", + aliases:["CAAT.UI.BoxLayout"], + depends:[ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass:"CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.BoxLayout.prototype + */ + + /** + * Stack elements in this axis. + * @type {CAAT.Foundation.UI.Layout.LayoutManager} + */ + axis:CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y, + + /** + * Vertical alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + valign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + /** + * Horizontal alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + halign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + setAxis:function (axis) { + this.axis = axis; + this.invalidateLayout(); + return this; + }, + + setHorizontalAlignment:function (align) { + this.halign = align; + this.invalidateLayout(); + return this; + }, + + setVerticalAlignment:function (align) { + this.valign = align; + this.invalidateLayout(); + return this; + }, + + doLayout:function (container) { + + if (this.axis === CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y) { + this.doLayoutVertical(container); + } else { + this.doLayoutHorizontal(container); + } + + CAAT.Foundation.UI.Layout.BoxLayout.superclass.doLayout.call(this, container); + }, + + doLayoutHorizontal:function (container) { + + var computedW = 0, computedH = 0; + var yoffset = 0, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedH < actor.height) { + computedH = actor.height; + } + + computedW += actor.width; + if (i > 0) { + computedW += this.hgap; + } + } + } + + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - computedW - this.padding.right; + break; + default: + xoffset = (container.width - computedW) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - this.padding.bottom - actor.height; + break; + default: + yoffset = (container.height - actor.height) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + xoffset += actor.width + this.hgap; + } + } + + }, + + __setActorPosition:function (actor, xoffset, yoffset) { + if (this.animated) { + if (this.newChildren.indexOf(actor) !== -1) { + actor.setPosition(xoffset, yoffset); + actor.setScale(0, 0); + actor.scaleTo(1, 1, 500, 0, .5, .5, this.newElementInterpolator); + } else { + actor.moveTo(xoffset, yoffset, 500, 0, this.moveElementInterpolator); + } + } else { + actor.setPosition(xoffset, yoffset); + } + }, + + doLayoutVertical:function (container) { + + var computedW = 0, computedH = 0; + var yoffset, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedW < actor.width) { + computedW = actor.width; + } + + computedH += actor.height; + if (i > 0) { + computedH += this.vgap; + } + } + } + + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - computedH - this.padding.bottom; + break; + default: + yoffset = (container.height - computedH) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - this.padding.right - actor.width; + break; + default: + xoffset = (container.width - actor.width) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + yoffset += actor.height + this.vgap; + } + } + }, + + getPreferredLayoutSize:function (container) { + + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getPreferredSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + }, + + getMinimumLayoutSize:function (container) { + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getMinimumSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + } + } + } +}); +CAAT.Module( { + + /** + * @name BorderLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.BorderLayout", + aliases : ["CAAT.UI.BorderLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.BorderLayout.prototype + */ + + + __init : function() { + this.__super(); + return this; + }, + + /** + * An actor to position left. + */ + left : null, + + /** + * An actor to position right. + */ + right : null, + + /** + * An actor to position top. + */ + top : null, + + /** + * An actor to position botton. + */ + bottom : null, + + /** + * An actor to position center. + */ + center : null, + + addChild : function( child, constraint ) { + + if ( typeof constraint==="undefined" ) { + constraint="center"; + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.addChild.call( this, child, constraint ); + + if ( constraint==="left" ) { + this.left= child; + } else if ( constraint==="right" ) { + this.right= child; + } else if ( constraint==="top" ) { + this.top= child; + } else if ( constraint==="bottom" ) { + this.bottom= child; + } else { + //"center" + this.center= child; + } + }, + + removeChild : function( child ) { + if ( this.center===child ) { + this.center=null; + } else if ( this.left===child ) { + this.left= null; + } else if ( this.right===child ) { + this.right= null; + } else if ( this.top===child ) { + this.top= null; + } else if ( this.bottom===child ) { + this.bottom= null; + } + }, + + __getChild : function( constraint ) { + if ( constraint==="center" ) { + return this.center; + } else if ( constraint==="left" ) { + return this.left; + } else if ( constraint==="right" ) { + return this.right; + } else if ( constraint==="top" ) { + return this.top; + } else if ( constraint==="bottom" ) { + return this.bottom; + } + }, + + getMinimumLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Math.Dimension(); + + if ((c=this.__getChild("right")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("left")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getMinimumSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + getPreferredLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Dimension(); + + if ((c=this.__getChild("left")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("right")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getPreferredSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + doLayout : function( container ) { + + var top = this.padding.top; + var bottom = container.height - this.padding.bottom; + var left = this.padding.left; + var right = container.width - this.padding.right; + var c, d; + + if ((c=this.__getChild("top")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, top, right - left, d.height); + top += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, bottom - d.height, right - left, d.height); + bottom -= d.height + this.vgap; + } + if ((c=this.__getChild("right")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(right - d.width, top, d.width, bottom - top); + right -= d.width + this.hgap; + } + if ((c=this.__getChild("left")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(left, top, d.width, bottom - top); + left += d.width + this.hgap; + } + if ((c=this.__getChild("center")) != null) { + c.setBounds(left, top, right - left, bottom - top); + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.doLayout.call(this, container); + } + + + } + +}); +CAAT.Module( { + + /** + * @name GridLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.GridLayout", + aliases : ["CAAT.UI.GridLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.GridLayout.prototype + */ + + __init : function( rows, columns ) { + this.__super(); + this.rows= rows; + this.columns= columns; + + return this; + }, + + /** + * Layout elements using this number of rows. + */ + rows : 0, + + /** + * Layout elements using this number of columns. + */ + columns : 2, + + doLayout : function( container ) { + + var actors= []; + for( var i=0; i 0) { + ncols = Math.floor( (nactors + nrows - 1) / nrows ); + } else { + nrows = Math.floor( (nactors + ncols - 1) / ncols ); + } + + var totalGapsWidth = (ncols - 1) * this.hgap; + var widthWOInsets = container.width - (this.padding.left + this.padding.right); + var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols ); + var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 ); + + var totalGapsHeight = (nrows - 1) * this.vgap; + var heightWOInsets = container.height - (this.padding.top + this.padding.bottom); + var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows ); + var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 ); + + for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) { + for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) { + var i = r * ncols + c; + if (i < actors.length) { + var child= actors[i]; + if ( !child.preventLayout && child.isVisible() && child.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + if ( !this.animated ) { + child.setBounds( + x + (widthOnComponent-child.width)/2, + y, + widthOnComponent, + heightOnComponent); + } else { + if ( child.width!==widthOnComponent || child.height!==heightOnComponent ) { + child.setSize(widthOnComponent, heightOnComponent); + if ( this.newChildren.indexOf( child ) !==-1 ) { + child.setPosition( + x + (widthOnComponent-child.width)/2, + y ); + child.setScale(0.01,0.01); + child.scaleTo( 1,1, 500, 0,.5,.5, this.newElementInterpolator ); + } else { + child.moveTo( + x + (widthOnComponent-child.width)/2, + y, + 500, + 0, + this.moveElementInterpolator ); + } + } + } + } + } + } + } + + CAAT.Foundation.UI.Layout.GridLayout.superclass.doLayout.call(this, container); + }, + + getMinimumLayoutSize : function( container ) { + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getMinimumSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + }, + + getPreferredLayoutSize : function( container ) { + + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getPreferredSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + } + + } +}); +CAAT.Module( { + + /** + * Define a drawable sub-image inside a bigger image as an independant drawable item. + * + * @name SpriteImageHelper + * @memberOf CAAT.Foundation + * @constructor + * + * + * + */ + + + defines : "CAAT.Foundation.SpriteImageHelper", + + extendsWith : { + + /** + * @lends CAAT.Foundation.SpriteImageHelper.prototype + */ + + __init : function (x, y, w, h, iw, ih) { + this.x = parseFloat(x); + this.y = parseFloat(y); + this.width = parseFloat(w); + this.height = parseFloat(h); + + this.setGL(x / iw, y / ih, (x + w - 1) / iw, (y + h - 1) / ih); + return this; + }, + + x:0, + y:0, + width:0, + height:0, + u:0, + v:0, + u1:0, + v1:0, + + setGL:function (u, v, u1, v1) { + this.u = u; + this.v = v; + this.u1 = u1; + this.v1 = v1; + return this; + } + } +}); +CAAT.Module({ + + /** + * + * Define an animation frame sequence, name it and supply with a callback which be called when the + * sequence ends playing. + * + * @name SpriteImageAnimationHelper + * @memberOf CAAT.Foundation + * @constructor + */ + + defines : "CAAT.Foundation.SpriteImageAnimationHelper", + extendsWith : function() { + return { + + /** + * @lends CAAT.Foundation.SpriteImageAnimationHelper.prototype + */ + + __init : function( animation, time, onEndPlayCallback ) { + this.animation= animation; + this.time= time; + this.onEndPlayCallback= onEndPlayCallback; + return this; + }, + + /** + * A sequence of integer values defining a frame animation. + * For example [1,2,3,4,3,2,3,4,3,2] + * Array. + */ + animation : null, + + /** + * Time between any two animation frames. + */ + time : 0, + + /** + * Call this callback function when the sequence ends. + */ + onEndPlayCallback : null + + } + } +});/** + * See LICENSE file. + * + * TODO: allow set of margins, spacing, etc. to define subimages. + * + **/ + +CAAT.Module({ + + /** + * @name SpriteImage + * @memberOf CAAT.Foundation + * @constructor + */ + + + defines : "CAAT.Foundation.SpriteImage", + aliases : ["CAAT.SpriteImage"], + depends : [ + "CAAT.Foundation.SpriteImageHelper", + "CAAT.Foundation.SpriteImageAnimationHelper", + "CAAT.Math.Rectangle" + ], + constants:{ + /** + * @lends CAAT.Foundation.SpriteImage + */ + + /** @const @type {number} */ TR_NONE:0, // constants used to determine how to draw the sprite image, + /** @const @type {number} */ TR_FLIP_HORIZONTAL:1, + /** @const @type {number} */ TR_FLIP_VERTICAL:2, + /** @const @type {number} */ TR_FLIP_ALL:3, + /** @const @type {number} */ TR_FIXED_TO_SIZE:4, + /** @const @type {number} */ TR_FIXED_WIDTH_TO_SIZE:6, + /** @const @type {number} */ TR_TILE:5 + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.SpriteImage.prototype + */ + + __init:function () { + this.paint = this.paintN; + this.setAnimationImageIndex([0]); + this.mapInfo = {}; + this.animationsMap= {}; + + if ( arguments.length===1 ) { + this.initialize.call(this, arguments[0], 1, 1); + } else if ( arguments.length===3 ) { + this.initialize.apply(this, arguments); + } + return this; + }, + + /** + * an Array defining the sprite frame sequence + */ + animationImageIndex:null, + + /** + * Previous animation frame time. + */ + prevAnimationTime:-1, + + /** + * how much Scene time to take before changing an Sprite frame. + */ + changeFPS:1000, + + /** + * any of the TR_* constants. + */ + transformation:0, + + /** + * the current sprite frame + */ + spriteIndex:0, + + /** + * current index of sprite frames array. + */ + prevIndex:0, // + + /** + * current animation name + */ + currentAnimation: null, + + /** + * Image to get frames from. + */ + image:null, + + /** + * Number of rows + */ + rows:1, + + /** + * Number of columns. + */ + columns:1, + + /** + * This sprite image image´s width + */ + width:0, + + /** + * This sprite image image´s width + */ + height:0, + + /** + * For each element in the sprite image array, its size. + */ + singleWidth:0, + + /** + * For each element in the sprite image array, its height. + */ + singleHeight:0, + + scaleX:1, + scaleY:1, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetX:0, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetY:0, + + /** + * When nesting sprite images, this value is the star X position of this sprite image in the parent. + */ + parentOffsetX:0, // para especificar una subimagen dentro un textmap. + + /** + * When nesting sprite images, this value is the star Y position of this sprite image in the parent. + */ + parentOffsetY:0, + + /** + * The actor this sprite image belongs to. + */ + ownerActor:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages calculated definition map. + */ + mapInfo:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages original definition map. + */ + map:null, + + /** + * This property allows to have multiple different animations defined for one actor. + * see demo31 for a sample. + */ + animationsMap : null, + + /** + * When an animation sequence ends, this callback function will be called. + */ + callback : null, // on end animation callback + + /** + * pending: refactor -> font scale to a font object. + */ + fontScale : 1, + + getOwnerActor : function() { + return this.ownerActor; + }, + + /** + * Add an animation to this sprite image. + * An animation is defines by an array of pretend-to-be-played sprite sequence. + * + * @param name {string} animation name. + * @param array {Array} the sprite animation sequence array. It can be defined + * as number array for Grid-like sprite images or strings for a map-like sprite + * image. + * @param time {number} change animation sequence every 'time' ms. + * @param callback {function({SpriteImage},{string}} a callback function to invoke when the sprite + * animation sequence has ended. + */ + addAnimation : function( name, array, time, callback ) { + this.animationsMap[name]= new CAAT.Foundation.SpriteImageAnimationHelper(array,time,callback); + return this; + }, + + setAnimationEndCallback : function(f) { + this.callback= f; + }, + + /** + * Start playing a SpriteImage animation. + * If it does not exist, nothing happens. + * @param name + */ + playAnimation : function(name) { + if (name===this.currentAnimation) { + return this; + } + + var animation= this.animationsMap[name]; + if ( !animation ) { + return this; + } + + this.currentAnimation= name; + + this.setAnimationImageIndex( animation.animation ); + this.changeFPS= animation.time; + this.callback= animation.onEndPlayCallback; + + return this; + }, + + setOwner:function (actor) { + this.ownerActor = actor; + return this; + }, + getRows:function () { + return this.rows; + }, + getColumns:function () { + return this.columns; + }, + + getWidth:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.width; + }, + + getHeight:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.height; + }, + + getWrappedImageWidth:function () { + return this.image.width; + }, + + getWrappedImageHeight:function () { + return this.image.height; + }, + + /** + * Get a reference to the same image information (rows, columns, image and uv cache) of this + * SpriteImage. This means that re-initializing this objects image info (that is, calling initialize + * method) will change all reference's image information at the same time. + */ + getRef:function () { + var ret = new CAAT.Foundation.SpriteImage(); + ret.image = this.image; + ret.rows = this.rows; + ret.columns = this.columns; + ret.width = this.width; + ret.height = this.height; + ret.singleWidth = this.singleWidth; + ret.singleHeight = this.singleHeight; + ret.mapInfo = this.mapInfo; + ret.offsetX = this.offsetX; + ret.offsetY = this.offsetY; + ret.scaleX = this.scaleX; + ret.scaleY = this.scaleY; + ret.animationsMap= this.animationsMap; + ret.parentOffsetX= this.parentOffsetX; + ret.parentOffsetY= this.parentOffsetY; + + ret.scaleFont= this.scaleFont; + + return ret; + }, + /** + * Set horizontal displacement to draw image. Positive values means drawing the image more to the + * right. + * @param x {number} + * @return this + */ + setOffsetX:function (x) { + this.offsetX = x; + return this; + }, + /** + * Set vertical displacement to draw image. Positive values means drawing the image more to the + * bottom. + * @param y {number} + * @return this + */ + setOffsetY:function (y) { + this.offsetY = y; + return this; + }, + setOffset:function (x, y) { + this.offsetX = x; + this.offsetY = y; + return this; + }, + /** + * Initialize a grid of subimages out of a given image. + * @param image {HTMLImageElement|Image} an image object. + * @param rows {number} number of rows. + * @param columns {number} number of columns + * + * @return this + */ + initialize:function (image, rows, columns) { + + if (!image) { + console.log("Null image for SpriteImage."); + } + + if ( isString(image) ) { + image= CAAT.currentDirector.getImage(image); + } + + this.parentOffsetX= 0; + this.parentOffsetY= 0; + + this.rows = rows; + this.columns = columns; + + if ( image instanceof CAAT.Foundation.SpriteImage || image instanceof CAAT.SpriteImage ) { + this.image = image.image; + var sihelper= image.mapInfo[0]; + this.width= sihelper.width; + this.height= sihelper.height; + + this.parentOffsetX= sihelper.x; + this.parentOffsetY= sihelper.y; + + this.width= image.mapInfo[0].width; + this.height= image.mapInfo[0].height; + + } else { + this.image = image; + this.width = image.width; + this.height = image.height; + this.mapInfo = {}; + + } + + this.singleWidth = Math.floor(this.width / columns); + this.singleHeight = Math.floor(this.height / rows); + + var i, sx0, sy0; + var helper; + + if (image.__texturePage) { + image.__du = this.singleWidth / image.__texturePage.width; + image.__dv = this.singleHeight / image.__texturePage.height; + + + var w = this.singleWidth; + var h = this.singleHeight; + var mod = this.columns; + if (image.inverted) { + var t = w; + w = h; + h = t; + mod = this.rows; + } + + var xt = this.image.__tx; + var yt = this.image.__ty; + + var tp = this.image.__texturePage; + + for (i = 0; i < rows * columns; i++) { + + + var c = ((i % mod) >> 0); + var r = ((i / mod) >> 0); + + var u = xt + c * w; // esquina izq x + var v = yt + r * h; + + var u1 = u + w; + var v1 = v + h; + + helper = new CAAT.Foundation.SpriteImageHelper(u, v, (u1 - u), (v1 - v), tp.width, tp.height).setGL( + u / tp.width, + v / tp.height, + u1 / tp.width, + v1 / tp.height); + + this.mapInfo[i] = helper; + } + + } else { + for (i = 0; i < rows * columns; i++) { + sx0 = ((i % this.columns) | 0) * this.singleWidth + this.parentOffsetX; + sy0 = ((i / this.columns) | 0) * this.singleHeight + this.parentOffsetY; + + helper = new CAAT.Foundation.SpriteImageHelper(sx0, sy0, this.singleWidth, this.singleHeight, image.width, image.height); + this.mapInfo[i] = helper; + } + } + + return this; + }, + + /** + * Create elements as director.getImage values. + * Create as much as elements defined in this sprite image. + * The elements will be named prefix+ + * @param prefix + */ + addElementsAsImages : function( prefix ) { + for( var i in this.mapInfo ) { + var si= new CAAT.Foundation.SpriteImage().initialize( this.image, 1, 1 ); + si.addElement(0, this.mapInfo[i]); + si.setSpriteIndex(0); + CAAT.currentDirector.addImage( prefix+i, si ); + } + }, + + copy : function( other ) { + this.initialize(other,1,1); + this.mapInfo= other.mapInfo; + return this; + }, + + /** + * Must be used to draw actor background and the actor should have setClip(true) so that the image tiles + * properly. + * @param director + * @param time + * @param x + * @param y + */ + paintTiled:function (director, time, x, y) { + + // PENDING: study using a pattern + + var el = this.mapInfo[this.spriteIndex]; + + var r = new CAAT.Math.Rectangle(); + this.ownerActor.AABB.intersect(director.AABB, r); + + var w = this.getWidth(); + var h = this.getHeight(); + var xoff = (this.offsetX - this.ownerActor.x) % w; + if (xoff > 0) { + xoff = xoff - w; + } + var yoff = (this.offsetY - this.ownerActor.y) % h; + if (yoff > 0) { + yoff = yoff - h; + } + + var nw = (((r.width - xoff) / w) >> 0) + 1; + var nh = (((r.height - yoff) / h) >> 0) + 1; + var i, j; + var ctx = director.ctx; + + for (i = 0; i < nh; i++) { + for (j = 0; j < nw; j++) { + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (r.x - this.ownerActor.x + xoff + j * el.width) >> 0, (r.y - this.ownerActor.y + yoff + i * el.height) >> 0, + el.width, el.height); + } + } + }, + + /** + * Draws the subimage pointed by imageIndex horizontally inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedH:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0); + ctx.translate((x | 0) + el.width, y | 0); + ctx.scale(-1, 1); + + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex both horizontal and vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedHV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + ctx.translate(el.width, 0); + ctx.scale(-1, 1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintN:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + paintAtRect:function (director, time, x, y, w, h) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + w, h); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaledWidth:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, el.height); + + return this; + }, + paintChunk:function (ctx, dx, dy, x, y, w, h) { + ctx.drawImage(this.image, x, y, w, h, dx, dy, w, h); + }, + paintTile:function (ctx, index, x, y) { + var el = this.mapInfo[index]; + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex scaled to the size of w and h. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaled:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, this.ownerActor.height); + + return this; + }, + getCurrentSpriteImageCSSPosition:function () { + var el = this.mapInfo[this.spriteIndex]; + + var x = -(el.x + this.parentOffsetX - this.offsetX); + var y = -(el.y + this.parentOffsetY - this.offsetY); + + return '' + x + 'px ' + + y + 'px ' + + (this.ownerActor.transformation === CAAT.Foundation.SpriteImage.TR_TILE ? 'repeat' : 'no-repeat'); + }, + /** + * Get the number of subimages in this compoundImage + * @return {number} + */ + getNumImages:function () { + return this.rows * this.columns; + }, + + setUV:function (uvBuffer, uvIndex) { + var im = this.image; + + if (!im.__texturePage) { + return; + } + + var index = uvIndex; + var sIndex = this.spriteIndex; + var el = this.mapInfo[this.spriteIndex]; + + var u = el.u; + var v = el.v; + var u1 = el.u1; + var v1 = el.v1; + if (this.offsetX || this.offsetY) { + var w = this.ownerActor.width; + var h = this.ownerActor.height; + + var tp = im.__texturePage; + + var _u = -this.offsetX / tp.width; + var _v = -this.offsetY / tp.height; + var _u1 = (w - this.offsetX) / tp.width; + var _v1 = (h - this.offsetY) / tp.height; + + u = _u + im.__u; + v = _v + im.__v; + u1 = _u1 + im.__u; + v1 = _v1 + im.__v; + } + + if (im.inverted) { + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v; + } else { + uvBuffer[index++] = u; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + } + }, + /** + * Set the elapsed time needed to change the image index. + * @param fps an integer indicating the time in milliseconds to change. + * @return this + */ + setChangeFPS:function (fps) { + this.changeFPS = fps; + return this; + }, + /** + * Set the transformation to apply to the Sprite image. + * Any value of + *

  • TR_NONE + *
  • TR_FLIP_HORIZONTAL + *
  • TR_FLIP_VERTICAL + *
  • TR_FLIP_ALL + * + * @param transformation an integer indicating one of the previous values. + * @return this + */ + setSpriteTransformation:function (transformation) { + this.transformation = transformation; + var v = CAAT.Foundation.SpriteImage; + switch (transformation) { + case v.TR_FLIP_HORIZONTAL: + this.paint = this.paintInvertedH; + break; + case v.TR_FLIP_VERTICAL: + this.paint = this.paintInvertedV; + break; + case v.TR_FLIP_ALL: + this.paint = this.paintInvertedHV; + break; + case v.TR_FIXED_TO_SIZE: + this.paint = this.paintScaled; + break; + case v.TR_FIXED_WIDTH_TO_SIZE: + this.paint = this.paintScaledWidth; + break; + case v.TR_TILE: + this.paint = this.paintTiled; + break; + default: + this.paint = this.paintN; + } + this.ownerActor.invalidate(); + return this; + }, + + resetAnimationTime:function () { + this.prevAnimationTime = -1; + return this; + }, + + /** + * Set the sprite animation images index. This method accepts an array of objects which define indexes to + * subimages inside this sprite image. + * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of + * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages + * with size rows*columns. + * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected + * to be an array of strings which are the names of the subobjects contained in the map object. + * + * @param aAnimationImageIndex an array indicating the Sprite's frames. + */ + setAnimationImageIndex:function (aAnimationImageIndex) { + this.animationImageIndex = aAnimationImageIndex; + this.spriteIndex = aAnimationImageIndex[0]; + this.prevAnimationTime = -1; + + return this; + }, + setSpriteIndex:function (index) { + this.spriteIndex = index; + return this; + }, + + /** + * Draws the sprite image calculated and stored in spriteIndex. + * + * @param time {number} Scene time when the bounding box is to be drawn. + */ + setSpriteIndexAtTime:function (time) { + + if (this.animationImageIndex.length > 1) { + if (this.prevAnimationTime === -1) { + this.prevAnimationTime = time; + + //thanks Phloog and ghthor, well spotted. + this.spriteIndex = this.animationImageIndex[0]; + this.prevIndex= 0; + this.ownerActor.invalidate(); + } + else { + var ttime = time; + ttime -= this.prevAnimationTime; + ttime /= this.changeFPS; + ttime %= this.animationImageIndex.length; + var idx = Math.floor(ttime); +// if ( this.spriteIndex!==idx ) { + + if ( idx" : { + * id : {number}, + * height : {number}, + * xoffset : {number}, + * letter : {string}, + * yoffset : {number}, + * width : {number}, + * xadvance: {number}, + * y : {number}, + * x : {number} + * } + */ + initializeAsGlyphDesigner:function (image, map) { + this.initialize(image, 1, 1); + + var key; + var helper; + var count = 0; + + for (key in map) { + var value = map[key]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(value.x) + this.parentOffsetX, + parseFloat(value.y) + this.parentOffsetX, + parseFloat(value.width), + parseFloat(value.height), + image.width, + image.height + ); + + helper.xoffset = typeof value.xoffset === 'undefined' ? 0 : value.xoffset; + helper.yoffset = typeof value.yoffset === 'undefined' ? 0 : value.yoffset; + helper.xadvance = typeof value.xadvance === 'undefined' ? value.width : value.xadvance; + + this.mapInfo[key] = helper; + + // set a default spriteIndex + if (!count) { + this.setAnimationImageIndex([key]); + } + + count++; + } + + return this; + + }, + + + initializeAsFontMap:function (image, chars) { + this.initialize(image, 1, 1); + + var helper; + var x = 0; + + for (var i = 0; i < chars.length; i++) { + var value = chars[i]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(x) + this.parentOffsetX, + 0 + this.parentOffsetY, + parseFloat(value.width), + image.height, + image.width, + image.height + ); + + helper.xoffset = 0; + helper.yoffset = 0; + helper.xadvance = value.width; + + + x += value.width; + + this.mapInfo[chars[i].c] = helper; + + // set a default spriteIndex + if (!i) { + this.setAnimationImageIndex([chars[i].c]); + } + } + + return this; + }, + + /** + * This method creates a font sprite image based on a proportional font + * It assumes the font is evenly spaced in the image + * Example: + * var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( + * director.getImage('numbers'), + * "0123456789" + * ); + */ + + initializeAsMonoTypeFontMap:function (image, chars) { + var map = []; + var charArr = chars.split(""); + + var w = image.width / charArr.length >> 0; + + for (var i = 0; i < charArr.length; i++) { + map.push({c:charArr[i], width:w }); + } + + return this.initializeAsFontMap(image, map); + }, + + stringWidth:function (str) { + var i, l, w = 0, charInfo; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w += charInfo.xadvance * this.fontScale; + } + } + + return w; + }, + + stringHeight:function () { + if (this.fontHeight) { + return this.fontHeight * this.fontScale; + } + + var y = 0; + for (var i in this.mapInfo) { + var mi = this.mapInfo[i]; + + var h = mi.height + mi.yoffset; + if (h > y) { + y = h; + } + } + + this.fontHeight = y; + return this.fontHeight * this.fontScale; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + + for (i = 0; i < str.length; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, charInfo.y, + w, charInfo.height, + + x + charInfo.xoffset* this.fontScale, y + charInfo.yoffset* this.fontScale, + w* this.fontScale, charInfo.height* this.fontScale); + } + x += charInfo.xadvance* this.fontScale; + } + } + }, + + getFontData : function() { + var as= (this.stringHeight() *.8)>>0; + return { + height : this.stringHeight(), + ascent : as, + descent: this.stringHeight() - as + }; + + } + + } + } +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + + + + /** + * + * CAAT.Foundation is the base namespace for all the core animation elements. + * + * @name Foundation + * @namespace + * @memberOf CAAT + * + */ + + /** + * + * CAAT.Foundation.Actor is the base animable element. It is the base object for Director, Scene and + * Container. + *

    CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance. + * An Actor has entity, it has a size, position and can have input sent to it. Everything that has a + * visual representation is an Actor, including Director and Scene objects.

    + *

    This object has functionality for:

    + *
      + *
    1. Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
    2. + *
    3. Set affine transforms (rotation, scale and translation).
    4. + *
    5. Define life cycle.
    6. + *
    7. Manage alpha transparency.
    8. + *
    9. Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.
    10. + *
    11. Compose transformations. A container Actor will transform its children before they apply their own transformation.
    12. + *
    13. Clipping capabilities. Either rectangular or arbitrary shapes.
    14. + *
    15. The API is developed to allow method chaining when possible.
    16. + *
    17. Handle input (either mouse events, touch, multitouch, keys and accelerometer).
    18. + *
    19. Show an image.
    20. + *
    21. Show some image animations.
    22. + *
    23. etc.
    24. + *
    + * + * @name Actor + * @memberOf CAAT.Foundation + * @constructor + * + */ + + defines:"CAAT.Foundation.Actor", + aliases: [ "CAAT.Actor" ], + depends: [ + "CAAT.Math.Dimension", + "CAAT.Event.AnimationLoop", + "CAAT.Foundation.SpriteImage", + "CAAT.Core.Constants", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.Scale1Behavior", + "CAAT.PathUtil.LinearPath", + "CAAT.Event.AnimationLoop" + ], + constants : { + /** + * @lends CAAT.Foundation.Actor + */ + + /** @const @type {number} */ ANCHOR_CENTER:0, // constant values to determine different affine transform + /** @const @type {number} */ ANCHOR_TOP:1, // anchors. + /** @const @type {number} */ ANCHOR_BOTTOM:2, + /** @const @type {number} */ ANCHOR_LEFT:3, + /** @const @type {number} */ ANCHOR_RIGHT:4, + /** @const @type {number} */ ANCHOR_TOP_LEFT:5, + /** @const @type {number} */ ANCHOR_TOP_RIGHT:6, + /** @const @type {number} */ ANCHOR_BOTTOM_LEFT:7, + /** @const @type {number} */ ANCHOR_BOTTOM_RIGHT:8, + /** @const @type {number} */ ANCHOR_CUSTOM:9, + + /** @const @type {number} */ CACHE_NONE:0, + /** @const @type {number} */ CACHE_SIMPLE:1, + /** @const @type {number} */ CACHE_DEEP:2 + }, + + extendsWith : function () { + + var __index = 0; + + return { + + /** + * @lends CAAT.Foundation.Actor.prototype + */ + + __init:function () { + this.behaviorList = []; + this.lifecycleListenerList = []; + this.AABB = new CAAT.Math.Rectangle(); + this.viewVertices = [ + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0) + ]; + + this.scaleAnchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrixI = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrixI = new CAAT.Math.Matrix(); + + this.resetTransform(); + this.setScale(1, 1); + this.setRotation(0); + + this.id = __index++; + + return this; + }, + + /** + * @type {object} + */ + __super : null, + + /** + * A collection of this Actors lifecycle observers. + * @type { Array.<{actorLifeCycleEvent : function( CAAT.Foundation.Actor, string, number ) }> } + */ + lifecycleListenerList:null, + + /** + * A collection of behaviors to modify this actor´s properties. + * @type { Array. } + */ + behaviorList:null, + + /** + * This actor's parent container. + * @type { CAAT.Foundation.ActorContainer } + */ + parent:null, // Parent of this Actor. May be Scene. + + /** + * x position on parent. In parent's local coord. system. + * @type {number} + */ + x:0, + /** + * y position on parent. In parent's local coord. system. + * @type {number} + */ + y:0, + + /** + * Actor's width. In parent's local coord. system. + * @type {number} + */ + width:0, + + /** + * Actor's height. In parent's local coord. system. + * @type {number} + */ + height:0, + + /** + * actor´s layout preferred size. + * @type {CAAT.Math.Dimension} + */ + preferredSize:null, + + /** + * actor's layout minimum size. + * @type {CAAT.Math.Dimension} + */ + minimumSize:null, + + /** + * Marks since when this actor, relative to scene time, is going to be animated/drawn. + * @type {number} + */ + start_time:0, + + /** + * Marks from the time this actor is going to be animated, during how much time. + * Forever by default. + * @type {number} + */ + duration:Number.MAX_VALUE, + + /** + * Will this actor be clipped before being drawn on screen ? + * @type {boolean} + */ + clip:false, + + /** + * If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise, + * clipPath contains a reference to a CAAT.PathUtil.Path object. + * @type {CAAT.PathUtil.Path} + */ + clipPath:null, + + /** + * Translation x anchor. 0..1 + * @type {number} + */ + tAnchorX:0, + + /** + * Translation y anchor. 0..1 + * @type {number} + */ + tAnchorY:0, + + /** + * ScaleX value. + * @type {number} + */ + scaleX:1, // transformation. width scale parameter + + /** + * ScaleY value. + * @type {number} + */ + scaleY:1, // transformation. height scale parameter + + /** + * Scale Anchor X. Value 0-1 + * @type {number} + */ + scaleTX:.50, // transformation. scale anchor x position + + /** + * Scale Anchor Y. Value 0-1 + * @type {number} + */ + scaleTY:.50, // transformation. scale anchor y position + + /** + * A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value. + * @type {CAAT.Foundation.Actor.ANCHOR_*} + */ + scaleAnchor:0, // transformation. scale anchor + + /** + * This actor´s rotation angle in radians. + * @type {number} + */ + rotationAngle:0, // transformation. rotation angle in radians + + /** + * Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + * @type {number} + */ + rotationY:.50, // transformation. rotation center y + + /** + * Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + * @type {number} + */ + rotationX:.50, // transformation. rotation center x + + /** + * Transparency value. 0 is totally transparent, 1 is totally opaque. + * @type {number} + */ + alpha:1, // alpha transparency value + + /** + * true to make all children transparent, false, only this actor/container will be transparent. + * @type {boolean} + */ + isGlobalAlpha:false, // is this a global alpha + + /** + * @type {number} + * @private + */ + frameAlpha:1, // hierarchically calculated alpha for this Actor. + + /** + * Mark this actor as expired, or out of the scene time. + * @type {boolean} + */ + expired:false, + + /** + * Mark this actor as discardable. If an actor is expired and mark as discardable, if will be + * removed from its parent. + * @type {boolean} + */ + discardable:false, // set when you want this actor to be removed if expired + + /** + * @type {boolean} + */ + pointed:false, // is the mouse pointer inside this actor + + /** + * Enable or disable input on this actor. By default, all actors receive input. + * See also priority lists. + * see demo4 for an example of input and priority lists. + * @type {boolean} + */ + mouseEnabled:true, // events enabled ? + + /** + * Make this actor visible or not. + * An invisible actor avoids making any calculation, applying any behavior on it. + * @type {boolean} + */ + visible:true, + + /** + * any canvas rendering valid fill style. + * @type {string} + */ + fillStyle:null, + + /** + * any canvas rendering valid stroke style. + * @type {string} + */ + strokeStyle:null, + + /** + * This actor´s scene time. + * @type {number} + */ + time:0, // Cache Scene time. + + /** + * This rectangle keeps the axis aligned bounding box in screen coords of this actor. + * In can be used, among other uses, to realize whether two given actors collide regardless + * the affine transformation is being applied on them. + * @type {CAAT.Math.Rectangle} + */ + AABB:null, + + /** + * These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding + * box. If the actor is not rotated, viewVertices and AABB define the same bounding box. + * @type {Array.} + */ + viewVertices:null, // model to view transformed vertices. + + /** + * Is this actor processed in the last frame ? + * @type {boolean} + */ + inFrame:false, // boolean indicating whether this Actor was present on last frame. + + /** + * Local matrix dirtyness flag. + * @type {boolean} + * @private + */ + dirty:true, // model view is dirty ? + + /** + * Global matrix dirtyness flag. + * @type {boolean} + * @private + */ + wdirty:true, // world model view is dirty ? + + /** + * @type {number} + * @private + */ + oldX:-1, + + /** + * @type {number} + * @private + */ + oldY:-1, + + /** + * This actor´s affine transformation matrix. + * @type {CAAT.Math.Matrix} + */ + modelViewMatrix:null, // model view matrix. + + /** + * This actor´s world affine transformation matrix. + * @type {CAAT.Math.Matrix} + */ + worldModelViewMatrix:null, // world model view matrix. + + /** + * @type {CAAT.Math.Matrix} + */ + modelViewMatrixI:null, // model view matrix. + + /** + * @type {CAAT.Math.Matrix} + */ + worldModelViewMatrixI:null, // world model view matrix. + + /** + * Is this actor enabled on WebGL ? + * @type {boolean} + */ + glEnabled:false, + + /** + * Define this actor´s background image. + * See SpriteImage object. + * @type {CAAT.Foundation.SpriteImage} + */ + backgroundImage:null, + + /** + * Set this actor´ id so that it can be later identified easily. + * @type {object} + */ + id:null, + + /** + * debug info. + * @type {number} + */ + size_active:1, // number of animated children + + /** + * debug info. + * @type {number} + */ + size_total:1, + + __d_ax:-1, // for drag-enabled actors. + __d_ay:-1, + + /** + * Is gesture recognition enabled on this actor ?? + * @type {boolean} + */ + gestureEnabled:false, + + /** + * If dirty rects are enabled, this flag indicates the rendering engine to invalidate this + * actor´s screen area. + * @type {boolean} + */ + invalid:true, + + /** + * Caching as bitmap strategy. Suitable to cache very complex actors. + * + * 0 : no cache. + * CACHE_SIMPLE : if a container, only cache the container. + * CACHE_DEEP : if a container, cache the container and recursively all of its children. + * + * @type {number} + */ + cached:0, // 0 no, CACHE_SIMPLE | CACHE_DEEP + + /** + * Exclude this actor from automatic layout on its parent. + * @type {boolean} + */ + preventLayout : false, + + /** + * is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated. + * @type {boolean} + * @private + */ + isAA:true, + + /** + * if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some + * internal properties. + */ + isCachedActor : false, + + setCachedActor : function(cached) { + this.isCachedActor= cached; + return this; + }, + + /** + * Make this actor not be laid out. + */ + setPreventLayout : function(b) { + this.preventLayout= b; + return this; + }, + + invalidateLayout:function () { + if (this.parent && !this.parent.layoutInvalidated) { + this.parent.invalidateLayout(); + } + + return this; + }, + + __validateLayout:function () { + + }, + + /** + * Set this actors preferred layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setPreferredSize:function (pw, ph) { + if (!this.preferredSize) { + this.preferredSize = new CAAT.Math.Dimension(); + } + this.preferredSize.width = pw; + this.preferredSize.height = ph; + return this; + }, + + getPreferredSize:function () { + return this.preferredSize ? this.preferredSize : + this.getMinimumSize(); + }, + + /** + * Set this actors minimum layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setMinimumSize:function (pw, ph) { + if (!this.minimumSize) { + this.minimumSize = new CAAT.Math.Dimension(); + } + + this.minimumSize.width = pw; + this.minimumSize.height = ph; + return this; + }, + + getMinimumSize:function () { + return this.minimumSize ? this.minimumSize : + new CAAT.Math.Dimension(this.width, this.height); + }, + + /** + * @deprecated + * @return {*} + */ + create:function () { + return this; + }, + /** + * Move this actor to a position. + * It creates and adds a new PathBehavior. + * @param x {number} new x position + * @param y {number} new y position + * @param duration {number} time to take to get to new position + * @param delay {=number} time to wait before start moving + * @param interpolator {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance + */ + moveTo:function (x, y, duration, delay, interpolator, callback) { + + if (x === this.x && y === this.y) { + return; + } + + var id = '__moveTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.PathBehavior(). + setId(id). + setValues(new CAAT.PathUtil.LinearPath()); + this.addBehavior(b); + } + + b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y); + b.setDelayTime(delay ? delay : 0, duration); + if (interpolator) { + b.setInterpolator(interpolator); + } + + if (callback) { + b.lifecycleListenerList = []; + b.addListener({ + behaviorExpired:function (behavior, time, actor) { + callback(behavior, time, actor); + } + }); + } + + return this; + }, + + /** + * + * @param angle {number} new rotation angle + * @param duration {number} time to rotate + * @param delay {number=} millis to start rotation + * @param anchorX {number=} rotation anchor x + * @param anchorY {number=} rotation anchor y + * @param interpolator {CAAT.Behavior.Interpolator=} + * @return {*} + */ + rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) { + + if (angle === this.rotationAngle) { + return; + } + + var id = '__rotateTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.RotateBehavior(). + setId(id). + setValues(0, 0, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.rotationAngle, angle, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) { + + if (this.scaleX === scaleX && this.scaleY === scaleY) { + return; + } + + var id = '__scaleTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.ScaleBehavior(). + setId(id). + setValues(1, 1, 1, 1, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Behavior.Scale1Behavior.AXIS_X, + scaleX, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Behavior.Scale1Behavior.AXIS_Y, + scaleY, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis + * @param scale {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Bahavior.Interpolator} + * @return {*} + */ + __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) { + + if (( axis === CAAT.Behavior.Scale1Behavior.AXIS_X && scale === this.scaleX) || + ( axis === CAAT.Behavior.Scale1Behavior.AXIS_Y && scale === this.scaleY)) { + + return; + } + + var id = '__scaleXTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.Scale1Behavior(). + setId(id). + setValues(1, 1, axis === CAAT.Behavior.Scale1Behavior.AXIS_X, .5, .5); + this.addBehavior(b); + } + + b.setValues( + axis ? this.scaleX : this.scaleY, + scale, + anchorX, + anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH + * @param e + */ + touchStart:function (e) { + }, + touchMove:function (e) { + }, + touchEnd:function (e) { + }, + gestureStart:function (rotation, scaleX, scaleY) { + }, + gestureChange:function (rotation, scaleX, scaleY) { + if (this.gestureEnabled) { + this.setRotation(rotation); + this.setScale(scaleX, scaleY); + } + return this; + }, + gestureEnd:function (rotation, scaleX, scaleY) { + }, + + isVisible:function () { + return this.visible; + }, + + invalidate:function () { + this.invalid = true; + return this; + }, + setGestureEnabled:function (enable) { + this.gestureEnabled = !!enable; + return this; + }, + isGestureEnabled:function () { + return this.gestureEnabled; + }, + getId:function () { + return this.id; + }, + setId:function (id) { + this.id = id; + return this; + }, + /** + * Set this actor's parent. + * @param parent {CAAT.Foundation.ActorContainer} + * @return this + */ + setParent:function (parent) { + this.parent = parent; + return this; + }, + /** + * Set this actor's background image. + * The need of a background image is to kept compatibility with the new CSSDirector class. + * The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image + * is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column. + * If the actor has set an image in the background, the paint method will draw the image, otherwise + * and if set, will fill its background with a solid color. + * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one + * single image from the SpriteImage (either supplied or generated because of passing an Image or + * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth, + * height:singleHeight]. + * + * WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance. + * + * @see CAAT.Foundation.SpriteImage + * + * @param image {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage} + * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter. + * + * @return this + */ + setBackgroundImage:function (image, adjust_size_to_image) { + if (image) { + if (!(image instanceof CAAT.Foundation.SpriteImage)) { + if ( isString(image) ) { + image = new CAAT.Foundation.SpriteImage().initialize(CAAT.currentDirector.getImage(image), 1, 1); + } else { + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } + } else { + image= image.getRef(); + } + + image.setOwner(this); + this.backgroundImage = image; + if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) { + this.width = image.getWidth(); + this.height = image.getHeight(); + } + + this.glEnabled = true; + + this.invalidate(); + + } else { + this.backgroundImage = null; + } + + return this; + }, + /** + * Set the actor's SpriteImage index from animation sheet. + * @see CAAT.Foundation.SpriteImage + * @param index {number} + * + * @return this + */ + setSpriteIndex:function (index) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteIndex(index); + this.invalidate(); + } + + return this; + + }, + /** + * Set this actor's background SpriteImage offset displacement. + * The values can be either positive or negative meaning the texture space of this background + * image does not start at (0,0) but at the desired position. + * @see CAAT.Foundation.SpriteImage + * @param ox {number} horizontal offset + * @param oy {number} vertical offset + * + * @return this + */ + setBackgroundImageOffset:function (ox, oy) { + if (this.backgroundImage) { + this.backgroundImage.setOffset(ox, oy); + } + + return this; + }, + /** + * Set this actor's background SpriteImage its animation sequence. + * In its simplet's form a SpriteImage treats a given image as an array of rows by columns + * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages. + * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the + * animation sequence + * @param ii {Array} an array of integers. + */ + setAnimationImageIndex:function (ii) { + if (this.backgroundImage) { + this.backgroundImage.resetAnimationTime(); + this.backgroundImage.setAnimationImageIndex(ii); + this.invalidate(); + } + return this; + }, + + addAnimation : function( name, array, time, callback ) { + if (this.backgroundImage) { + this.backgroundImage.addAnimation(name, array, time, callback); + } + return this; + }, + + playAnimation : function(name) { + if (this.backgroundImage) { + this.backgroundImage.playAnimation(name); + } + return this; + }, + + setAnimationEndCallback : function(f) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationEndCallback(f); + } + return this; + }, + + resetAnimationTime:function () { + if (this.backgroundImage) { + this.backgroundImage.resetAnimationTime(); + this.invalidate(); + } + return this; + }, + + setChangeFPS:function (time) { + if (this.backgroundImage) { + this.backgroundImage.setChangeFPS(time); + } + return this; + + }, + /** + * Set this background image transformation. + * If GL is enabled, this parameter has no effect. + * @param it any value from CAAT.Foundation.SpriteImage.TR_* + * @return this + */ + setImageTransformation:function (it) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteTransformation(it); + } + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + * @deprecated + */ + centerOn:function (x, y) { + this.setPosition(x - this.width / 2, y - this.height / 2); + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + */ + centerAt:function (x, y) { + this.setPosition( + x - this.width * (.5 - this.tAnchorX ), + y - this.height * (.5 - this.tAnchorY ) ); + return this; + }, + /** + * If GL is enables, get this background image's texture page, otherwise it will fail. + * @return {CAAT.GLTexturePage} + */ + getTextureGLPage:function () { + return this.backgroundImage.image.__texturePage; + }, + /** + * Set this actor invisible. + * The actor is animated but not visible. + * A container won't show any of its children if set visible to false. + * + * @param visible {boolean} set this actor visible or not. + * @return this + */ + setVisible:function (visible) { + this.invalidate(); + // si estoy visible y quiero hacerme no visible + if (CAAT.currentDirector && CAAT.currentDirector.dirtyRectsEnabled && !visible && this.visible) { + // if dirty rects, add this actor + CAAT.currentDirector.scheduleDirtyRect(this.AABB); + } + + if ( visible && !this.visible) { + this.dirty= true; + } + + this.visible = visible; + return this; + }, + /** + * Puts an Actor out of time line, that is, won't be transformed nor rendered. + * @return this + */ + setOutOfFrameTime:function () { + this.setFrameTime(-1, 0); + return this; + }, + /** + * Adds an Actor's life cycle listener. + * The developer must ensure the actorListener is not already a listener, otherwise + * it will notified more than once. + * @param actorListener {object} an object with at least a method of the form: + * actorLyfeCycleEvent( actor, string_event_type, long_time ) + */ + addListener:function (actorListener) { + this.lifecycleListenerList.push(actorListener); + return this; + }, + /** + * Removes an Actor's life cycle listener. + * It will only remove the first occurrence of the given actorListener. + * @param actorListener {object} an Actor's life cycle listener. + */ + removeListener:function (actorListener) { + var n = this.lifecycleListenerList.length; + while (n--) { + if (this.lifecycleListenerList[n] === actorListener) { + // remove the nth element. + this.lifecycleListenerList.splice(n, 1); + return; + } + } + }, + /** + * Set alpha composition scope. global will mean this alpha value will be its children maximum. + * If set to false, only this actor will have this alpha value. + * @param global {boolean} whether the alpha value should be propagated to children. + */ + setGlobalAlpha:function (global) { + this.isGlobalAlpha = global; + return this; + }, + /** + * Notifies the registered Actor's life cycle listener about some event. + * @param sEventType an string indicating the type of event being notified. + * @param time an integer indicating the time related to Scene's timeline when the event + * is being notified. + */ + fireEvent:function (sEventType, time) { + for (var i = 0; i < this.lifecycleListenerList.length; i++) { + this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time); + } + }, + /** + * Sets this Actor as Expired. + * If this is a Container, all the contained Actors won't be nor drawn nor will receive + * any event. That is, expiring an Actor means totally taking it out the Scene's timeline. + * @param time {number} an integer indicating the time the Actor was expired at. + * @return this. + */ + setExpired:function (time) { + this.expired = true; + this.fireEvent('expired', time); + return this; + }, + /** + * Enable or disable the event bubbling for this Actor. + * @param enable {boolean} a boolean indicating whether the event bubbling is enabled. + * @return this + */ + enableEvents:function (enable) { + this.mouseEnabled = enable; + return this; + }, + /** + * Removes all behaviors from an Actor. + * @return this + */ + emptyBehaviorList:function () { + this.behaviorList = []; + return this; + }, + /** + * Caches a fillStyle in the Actor. + * @param style a valid Canvas rendering context fillStyle. + * @return this + */ + setFillStyle:function (style) { + this.fillStyle = style; + this.invalidate(); + return this; + }, + /** + * Caches a stroke style in the Actor. + * @param style a valid canvas rendering context stroke style. + * @return this + */ + setStrokeStyle:function (style) { + this.strokeStyle = style; + this.invalidate(); + return this; + }, + /** + * @deprecated + * @param paint + */ + setPaint:function (paint) { + return this.setFillStyle(paint); + }, + /** + * Stablishes the Alpha transparency for the Actor. + * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors. + * The alpha must be between 0 and 1. + * @param alpha a float indicating the alpha value. + * @return this + */ + setAlpha:function (alpha) { + this.alpha = alpha; + this.invalidate(); + return this; + }, + /** + * Remove all transformation values for the Actor. + * @return this + */ + resetTransform:function () { + this.rotationAngle = 0; + this.rotationX = .5; + this.rotationY = .5; + this.scaleX = 1; + this.scaleY = 1; + this.scaleTX = .5; + this.scaleTY = .5; + this.scaleAnchor = 0; + this.oldX = -1; + this.oldY = -1; + this.dirty = true; + + return this; + }, + /** + * Sets the time life cycle for an Actor. + * These values are related to Scene time. + * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene. + * @param duration an integer indicating how much the Actor will last once visible. + * @return this + */ + setFrameTime:function (startTime, duration) { + this.start_time = startTime; + this.duration = duration; + this.expired = false; + this.dirty = true; + + return this; + }, + /** + * This method should me overriden by every custom Actor. + * It will be the drawing routine called by the Director to show every Actor. + * @param director {CAAT.Foundation.Director} instance that contains the Scene the Actor is in. + * @param time {number} indicating the Scene time in which the drawing is performed. + */ + paint:function (director, time) { + if (this.backgroundImage) { + this.backgroundImage.paint(director, time, 0, 0); + } else if (this.fillStyle) { + var ctx = director.ctx; + ctx.fillStyle = this.fillStyle; + ctx.fillRect(0, 0, this.width, this.height); + } + + }, + /** + * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER + * + * @see setScaleAnchored + * + * @param sx a float indicating a width size multiplier. + * @param sy a float indicating a height size multiplier. + * @return this + */ + setScale:function (sx, sy) { + this.scaleX = sx; + this.scaleY = sy; + this.dirty = true; + return this; + }, + getAnchorPercent:function (anchor) { + + var anchors = [ + .50, .50, .50, 0, .50, 1.00, + 0, .50, 1.00, .50, 0, 0, + 1.00, 0, 0, 1.00, 1.00, 1.00 + ]; + + return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] }; + }, + /** + * Private. + * Gets a given anchor position referred to the Actor. + * @param anchor + * @return an object of the form { x: float, y: float } + */ + getAnchor:function (anchor) { + var tx = 0, ty = 0; + + var A= CAAT.Foundation.Actor; + + switch (anchor) { + case A.ANCHOR_CENTER: + tx = .5; + ty = .5; + break; + case A.ANCHOR_TOP: + tx = .5; + ty = 0; + break; + case A.ANCHOR_BOTTOM: + tx = .5; + ty = 1; + break; + case A.ANCHOR_LEFT: + tx = 0; + ty = .5; + break; + case A.ANCHOR_RIGHT: + tx = 1; + ty = .5; + break; + case A.ANCHOR_TOP_RIGHT: + tx = 1; + ty = 0; + break; + case A.ANCHOR_BOTTOM_LEFT: + tx = 0; + ty = 1; + break; + case A.ANCHOR_BOTTOM_RIGHT: + tx = 1; + ty = 1; + break; + case A.ANCHOR_TOP_LEFT: + tx = 0; + ty = 0; + break; + } + + return {x:tx, y:ty}; + }, + + setGlobalAnchor:function (ax, ay) { + this.tAnchorX = ax; + this.rotationX = ax; + this.scaleTX = ax; + + this.tAnchorY = ay; + this.rotationY = ay; + this.scaleTY = ay; + + this.dirty = true; + return this; + }, + + setScaleAnchor:function (sax, say) { + this.scaleTX = sax; + this.scaleTY = say; + this.dirty = true; + return this; + }, + /** + * Modify the dimensions on an Actor. + * The dimension will not affect the local coordinates system in opposition + * to setSize or setBounds. + * + * @param sx {number} width scale. + * @param sy {number} height scale. + * @param anchorx {number} x anchor to perform the Scale operation. + * @param anchory {number} y anchor to perform the Scale operation. + * + * @return this; + */ + setScaleAnchored:function (sx, sy, anchorx, anchory) { + this.scaleTX = anchorx; + this.scaleTY = anchory; + + this.scaleX = sx; + this.scaleY = sy; + + this.dirty = true; + + return this; + }, + + setRotationAnchor:function (rax, ray) { + this.rotationX = ray; + this.rotationY = rax; + this.dirty = true; + return this; + }, + /** + * A helper method for setRotationAnchored. This methods stablishes the center + * of rotation to be the center of the Actor. + * + * @param angle a float indicating the angle in radians to rotate the Actor. + * @return this + */ + setRotation:function (angle) { + this.rotationAngle = angle; + this.dirty = true; + return this; + }, + /** + * This method sets Actor rotation around a given position. + * @param angle {number} indicating the angle in radians to rotate the Actor. + * @param rx {number} value in the range 0..1 + * @param ry {number} value in the range 0..1 + * @return this; + */ + setRotationAnchored:function (angle, rx, ry) { + this.rotationAngle = angle; + this.rotationX = rx; + this.rotationY = ry; + this.dirty = true; + return this; + }, + /** + * Sets an Actor's dimension + * @param w a float indicating Actor's width. + * @param h a float indicating Actor's height. + * @return this + */ + setSize:function (w, h) { + + this.width = w; + this.height = h; + + this.dirty = true; + + return this; + }, + /** + * Set location and dimension of an Actor at once. + * + * @param x{number} a float indicating Actor's x position. + * @param y{number} a float indicating Actor's y position + * @param w{number} a float indicating Actor's width + * @param h{number} a float indicating Actor's height + * @return this + */ + setBounds:function (x, y, w, h) { + + this.x = x; + this.y = y; + this.width = w; + this.height = h; + + this.dirty = true; + + return this; + }, + /** + * This method sets the position of an Actor inside its parent. + * + * @param x{number} a float indicating Actor's x position + * @param y{number} a float indicating Actor's y position + * @return this + * + * @deprecated + */ + setLocation:function (x, y) { + this.x = x; + this.y = y; + this.oldX = x; + this.oldY = y; + + this.dirty = true; + + return this; + }, + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + + /** + * This method is called by the Director to know whether the actor is on Scene time. + * In case it was necessary, this method will notify any life cycle behaviors about + * an Actor expiration. + * @param time {number} time indicating the Scene time. + * + * @private + * + */ + isInAnimationFrame:function (time) { + if (this.expired) { + return false; + } + + if (this.duration === Number.MAX_VALUE) { + return this.start_time <= time; + } + + if (time >= this.start_time + this.duration) { + if (!this.expired) { + this.setExpired(time); + } + + return false; + } + + return this.start_time <= time && time < this.start_time + this.duration; + }, + /** + * Checks whether a coordinate is inside the Actor's bounding box. + * @param x {number} a float + * @param y {number} a float + * + * @return boolean indicating whether it is inside. + */ + contains:function (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + }, + + /** + * Add a Behavior to the Actor. + * An Actor accepts an undefined number of Behaviors. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + * @return this + */ + addBehavior:function (behavior) { + this.behaviorList.push(behavior); + return this; + }, + + /** + * Remove a Behavior from the Actor. + * If the Behavior is not present at the actor behavior collection nothing happends. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + */ + removeBehaviour:function (behavior) { + var c = this.behaviorList; + var n = c.length - 1; + while (n) { + if (c[n] === behavior) { + c.splice(n, 1); + return this; + } + } + return this; + }, + /** + * Remove a Behavior with id param as behavior identifier from this actor. + * This function will remove ALL behavior instances with the given id. + * + * @param id {number} an integer. + * return this; + */ + removeBehaviorById:function (id) { + var c = this.behaviorList; + for (var n = 0; n < c.length; n++) { + if (c[n].id === id) { + c.splice(n, 1); + } + } + + return this; + + }, + getBehavior:function (id) { + var c = this.behaviorList; + for (var n = 0; n < c.length; n++) { + var cc = c[n]; + if (cc.id === id) { + return cc; + } + } + return null; + }, + /** + * Set discardable property. If an actor is discardable, upon expiration will be removed from + * scene graph and hence deleted. + * @param discardable {boolean} a boolean indicating whether the Actor is discardable. + * @return this + */ + setDiscardable:function (discardable) { + this.discardable = discardable; + return this; + }, + /** + * This method will be called internally by CAAT when an Actor is expired, and at the + * same time, is flagged as discardable. + * It notifies the Actor life cycle listeners about the destruction event. + * + * @param time an integer indicating the time at wich the Actor has been destroyed. + * + * @private + * + */ + destroy:function (time) { + if (this.parent) { + this.parent.removeChild(this); + } + + this.fireEvent('destroyed', time); + if ( !this.isCachedActor ) { + this.clean(); + } + + }, + + clean : function() { + this.backgroundImage= null; + this.emptyBehaviorList(); + this.lifecycleListenerList= []; + }, + + /** + * Transform a point or array of points in model space to view space. + * + * @param point {CAAT.Math.Point|Array} an object of the form {x : float, y: float} + * + * @return the source transformed elements. + * + * @private + * + */ + modelToView:function (point) { + var x, y, pt, tm; + + if (this.dirty) { + this.setModelViewMatrix(); + } + + tm = this.worldModelViewMatrix.matrix; + + if (point instanceof Array) { + for (var i = 0; i < point.length; i++) { + //this.worldModelViewMatrix.transformCoord(point[i]); + pt = point[i]; + x = pt.x; + y = pt.y; + pt.x = x * tm[0] + y * tm[1] + tm[2]; + pt.y = x * tm[3] + y * tm[4] + tm[5]; + } + } + else { +// this.worldModelViewMatrix.transformCoord(point); + x = point.x; + y = point.y; + point.x = x * tm[0] + y * tm[1] + tm[2]; + point.y = x * tm[3] + y * tm[4] + tm[5]; + } + + return point; + }, + /** + * Transform a local coordinate point on this Actor's coordinate system into + * another point in otherActor's coordinate system. + * @param point {CAAT.Math.Point} + * @param otherActor {CAAT.Math.Actor} + */ + modelToModel:function (point, otherActor) { + if (this.dirty) { + this.setModelViewMatrix(); + } + + return otherActor.viewToModel(this.modelToView(point)); + }, + /** + * Transform a point from model to view space. + *

    + * WARNING: every call to this method calculates + * actor's world model view matrix. + * + * @param point {CAAT.Math.Point} a point in screen space to be transformed to model space. + * + * @return the source point object + * + * + */ + viewToModel:function (point) { + if (this.dirty) { + this.setModelViewMatrix(); + } + this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI); + this.worldModelViewMatrixI.transformCoord(point); + return point; + }, + /** + * Private + * This method does the needed point transformations across an Actor hierarchy to devise + * whether the parameter point coordinate lies inside the Actor. + * @param point {CAAT.Math.Point} + * + * @return null if the point is not inside the Actor. The Actor otherwise. + */ + findActorAtPosition:function (point) { + if (this.scaleX===0 || this.scaleY===0) { + return null; + } + if (!this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time)) { + return null; + } + + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.modelViewMatrixI.transformCoord(point); + return this.contains(point.x, point.y) ? this : null; + }, + /** + * Enables a default dragging routine for the Actor. + * This default dragging routine allows to: + *

  • scale the Actor by pressing shift+drag + *
  • rotate the Actor by pressing control+drag + *
  • scale non uniformly by pressing alt+shift+drag + * + * @return this + */ + enableDrag:function () { + + this.ax = 0; + this.ay = 0; + this.asx = 1; + this.asy = 1; + this.ara = 0; + this.screenx = 0; + this.screeny = 0; + + /** + * Mouse enter handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + this.pointed = true; + CAAT.setCursor('move'); + }; + + /** + * Mouse exit handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseExit = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + this.pointed = false; + CAAT.setCursor('default'); + }; + + /** + * Mouse move handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseMove = function (mouseEvent) { + }; + + /** + * Mouse up handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseUp = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + }; + + /** + * Mouse drag handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + + var pt; + + pt = this.modelToView(new CAAT.Math.Point(mouseEvent.x, mouseEvent.y)); + this.parent.viewToModel(pt); + + if (this.__d_ax === -1 || this.__d_ay === -1) { + this.__d_ax = pt.x; + this.__d_ay = pt.y; + this.__d_asx = this.scaleX; + this.__d_asy = this.scaleY; + this.__d_ara = this.rotationAngle; + this.__d_screenx = mouseEvent.screenPoint.x; + this.__d_screeny = mouseEvent.screenPoint.y; + } + + if (mouseEvent.isShiftDown()) { + var scx = (mouseEvent.screenPoint.x - this.__d_screenx) / 100; + var scy = (mouseEvent.screenPoint.y - this.__d_screeny) / 100; + if (!mouseEvent.isAltDown()) { + var sc = Math.max(scx, scy); + scx = sc; + scy = sc; + } + this.setScale(scx + this.__d_asx, scy + this.__d_asy); + + } else if (mouseEvent.isControlDown()) { + var vx = mouseEvent.screenPoint.x - this.__d_screenx; + var vy = mouseEvent.screenPoint.y - this.__d_screeny; + this.setRotation(-Math.atan2(vx, vy) + this.__d_ara); + } else { + this.x += pt.x - this.__d_ax; + this.y += pt.y - this.__d_ay; + } + + this.__d_ax = pt.x; + this.__d_ay = pt.y; + }; + + return this; + }, + disableDrag:function () { + + this.mouseEnter = function (mouseEvent) { + }; + this.mouseExit = function (mouseEvent) { + }; + this.mouseMove = function (mouseEvent) { + }; + this.mouseUp = function (mouseEvent) { + }; + this.mouseDrag = function (mouseEvent) { + }; + + return this; + }, + /** + * Default mouseClick handler. + * Mouse click events are received after a call to mouseUp method if no dragging was in progress. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseClick:function (mouseEvent) { + }, + /** + * Default double click handler + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDblClick:function (mouseEvent) { + }, + /** + * Default mouse enter on Actor handler. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseEnter:function (mouseEvent) { + this.pointed = true; + }, + /** + * Default mouse exit on Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseExit:function (mouseEvent) { + this.pointed = false; + }, + /** + * Default mouse move inside Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseMove:function (mouseEvent) { + }, + /** + * default mouse press in Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDown:function (mouseEvent) { + }, + /** + * default mouse release in Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseUp:function (mouseEvent) { + }, + mouseOut:function (mouseEvent) { + }, + mouseOver:function (mouseEvent) { + }, + /** + * default Actor mouse drag handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDrag:function (mouseEvent) { + }, + /** + * Draw a bounding box with on-screen coordinates regardless of the transformations + * applied to the Actor. + * + * @param director {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in. + * @param time {number} integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + if (null !== this.AABB && this.inFrame) { + var s = this.AABB; + var ctx = director.ctx; + ctx.strokeStyle = CAAT.DEBUGAABBCOLOR; + ctx.strokeRect(.5 + (s.x | 0), .5 + (s.y | 0), s.width | 0, s.height | 0); + if (CAAT.DEBUGBB) { + var vv = this.viewVertices; + ctx.beginPath(); + ctx.lineTo(vv[0].x, vv[0].y); + ctx.lineTo(vv[1].x, vv[1].y); + ctx.lineTo(vv[2].x, vv[2].y); + ctx.lineTo(vv[3].x, vv[3].y); + ctx.closePath(); + ctx.strokeStyle = CAAT.DEBUGBBCOLOR; + ctx.stroke(); + } + } + }, + /** + * Private + * This method is called by the Director instance. + * It applies the list of behaviors the Actor has registered. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + animate:function (director, time) { + + if (!this.visible) { + return false; + } + + var i; + + if (!this.isInAnimationFrame(time)) { + this.inFrame = false; + this.dirty = true; + return false; + } + + if (this.x !== this.oldX || this.y !== this.oldY) { + this.dirty = true; + this.oldX = this.x; + this.oldY = this.y; + } + + for (i = 0; i < this.behaviorList.length; i++) { + this.behaviorList[i].apply(time, this); + } + + if (this.clipPath) { + this.clipPath.applyBehaviors(time); + } + + // transformation stuff. + this.setModelViewMatrix(); + + if (this.dirty || this.wdirty || this.invalid) { + if (director.dirtyRectsEnabled) { + director.addDirtyRect(this.AABB); + } + this.setScreenBounds(); + if (director.dirtyRectsEnabled) { + director.addDirtyRect(this.AABB); + } + } + this.dirty = false; + this.invalid = false; + + this.inFrame = true; + + if ( this.backgroundImage ) { + this.backgroundImage.setSpriteIndexAtTime(time); + } + + return this.AABB.intersects(director.AABB); + //return true; + }, + /** + * Set this model view matrix if the actor is Dirty. + * + mm[2]+= this.x; + mm[5]+= this.y; + if ( this.rotationAngle ) { + this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) ); + this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle ); + } + if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) { + this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) ); + this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) ); + } + * + * @return this + */ + setModelViewMatrix:function () { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty = false; + mm = this.modelViewMatrix.matrix; + + if (this.dirty) { + + mm0 = 1; + mm1 = 0; + //mm2= mm[2]; + mm3 = 0; + mm4 = 1; + //mm5= mm[5]; + + mm2 = this.x - this.tAnchorX * this.width; + mm5 = this.y - this.tAnchorY * this.height; + + if (this.rotationAngle) { + + var rx = this.rotationX * this.width; + var ry = this.rotationY * this.height; + + mm2 += mm0 * rx + mm1 * ry; + mm5 += mm3 * rx + mm4 * ry; + + c = Math.cos(this.rotationAngle); + s = Math.sin(this.rotationAngle); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm2 += -mm0 * rx - mm1 * ry; + mm5 += -mm3 * rx - mm4 * ry; + } + if (this.scaleX != 1 || this.scaleY != 1) { + + var sx = this.scaleTX * this.width; + var sy = this.scaleTY * this.height; + + mm2 += mm0 * sx + mm1 * sy; + mm5 += mm3 * sx + mm4 * sy; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm2 += -mm0 * sx - mm1 * sy; + mm5 += -mm3 * sx - mm4 * sy; + } + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + + if (this.parent) { + + + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA; + + if (this.dirty || this.parent.wdirty) { + this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix); + if (this.isAA) { + var mmm = this.worldModelViewMatrix.matrix; + mmm[2] += mm[2]; + mmm[5] += mm[5]; + } else { + this.worldModelViewMatrix.multiply(this.modelViewMatrix); + } + this.wdirty = true; + } + + } else { + if (this.dirty) { + this.wdirty = true; + } + + this.worldModelViewMatrix.identity(); + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1; + } + + +//if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) { + // screen bounding boxes will always be calculated. + /* + if ( this.dirty || this.wdirty || this.invalid ) { + if ( director.dirtyRectsEnabled ) { + director.addDirtyRect( this.AABB ); + } + this.setScreenBounds(); + if ( director.dirtyRectsEnabled ) { + director.addDirtyRect( this.AABB ); + } + } + this.dirty= false; + this.invalid= false; + */ + }, + /** + * Calculates the 2D bounding box in canvas coordinates of the Actor. + * This bounding box takes into account the transformations applied hierarchically for + * each Scene Actor. + * + * @private + * + */ + setScreenBounds:function () { + + var AABB = this.AABB; + var vv = this.viewVertices; + var vvv, m, x, y, w, h; + + if (this.isAA) { + m = this.worldModelViewMatrix.matrix; + x = m[2]; + y = m[5]; + w = this.width; + h = this.height; + AABB.x = x; + AABB.y = y; + AABB.x1 = x + w; + AABB.y1 = y + h; + AABB.width = w; + AABB.height = h; + + if (CAAT.GLRENDER) { + vvv = vv[0]; + vvv.x = x; + vvv.y = y; + vvv = vv[1]; + vvv.x = x + w; + vvv.y = y; + vvv = vv[2]; + vvv.x = x + w; + vvv.y = y + h; + vvv = vv[3]; + vvv.x = x; + vvv.y = y + h; + } + + return this; + } + + vvv = vv[0]; + vvv.x = 0; + vvv.y = 0; + vvv = vv[1]; + vvv.x = this.width; + vvv.y = 0; + vvv = vv[2]; + vvv.x = this.width; + vvv.y = this.height; + vvv = vv[3]; + vvv.x = 0; + vvv.y = this.height; + + this.modelToView(this.viewVertices); + + var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE; + var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE; + + vvv = vv[0]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[1]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[2]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[3]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + + AABB.x = xmin; + AABB.y = ymin; + AABB.x1 = xmax; + AABB.y1 = ymax; + AABB.width = (xmax - xmin); + AABB.height = (ymax - ymin); + + return this; + }, + /** + * @private. + * This method will be called by the Director to set the whole Actor pre-render process. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return boolean indicating whether the Actor isInFrameTime + */ + paintActor:function (director, time) { + + if (!this.visible || !director.inDirtyRect(this)) { + return true; + } + + var ctx = director.ctx; + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + ctx.globalAlpha = this.frameAlpha; + + director.modelViewMatrix.transformRenderingContextSet(ctx); + this.worldModelViewMatrix.transformRenderingContext(ctx); + + if (this.clip) { + ctx.beginPath(); + if (!this.clipPath) { + ctx.rect(0, 0, this.width, this.height); + } else { + this.clipPath.applyAsPath(director); + } + ctx.clip(); + } + + this.paint(director, time); + + return true; + }, + /** + * for js2native + * @param director + * @param time + */ + __paintActor:function (director, time) { + if (!this.visible) { + return true; + } + var ctx = director.ctx; + + // global opt: set alpha as owns alpha, not take globalAlpha procedure. + this.frameAlpha = this.alpha; + + var m = this.worldModelViewMatrix.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha); + this.paint(director, time); + return true; + }, + + /** + * Set coordinates and uv values for this actor. + * This function uses Director's coords and indexCoords values. + * @param director + * @param time + */ + paintActorGL:function (director, time) { + + this.frameAlpha = this.parent.frameAlpha * this.alpha; + + if (!this.glEnabled || !this.visible) { + return; + } + + if (this.glNeedsFlush(director)) { + director.glFlush(); + this.glSetShader(director); + + if (!this.__uv) { + this.__uv = new Float32Array(8); + } + if (!this.__vv) { + this.__vv = new Float32Array(12); + } + + this.setGLCoords(this.__vv, 0); + this.setUV(this.__uv, 0); + director.glRender(this.__vv, 12, this.__uv); + + return; + } + + var glCoords = director.coords; + var glCoordsIndex = director.coordsIndex; + + ////////////////// XYZ + this.setGLCoords(glCoords, glCoordsIndex); + director.coordsIndex = glCoordsIndex + 12; + + ////////////////// UV + this.setUV(director.uv, director.uvIndex); + director.uvIndex += 8; + }, + /** + * TODO: set GLcoords for different image transformations. + * + * @param glCoords + * @param glCoordsIndex + */ + setGLCoords:function (glCoords, glCoordsIndex) { + + var vv = this.viewVertices; + glCoords[glCoordsIndex++] = vv[0].x; + glCoords[glCoordsIndex++] = vv[0].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[1].x; + glCoords[glCoordsIndex++] = vv[1].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[2].x; + glCoords[glCoordsIndex++] = vv[2].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[3].x; + glCoords[glCoordsIndex++] = vv[3].y; + glCoords[glCoordsIndex ] = 0; + + }, + /** + * Set UV for this actor's quad. + * + * @param uvBuffer {Float32Array} + * @param uvIndex {number} + */ + setUV:function (uvBuffer, uvIndex) { + this.backgroundImage.setUV(uvBuffer, uvIndex); + }, + /** + * Test for compulsory gl flushing: + * 1.- opacity has changed. + * 2.- texture page has changed. + * + */ + glNeedsFlush:function (director) { + if (this.getTextureGLPage() !== director.currentTexturePage) { + return true; + } + if (this.frameAlpha !== director.currentOpacity) { + return true; + } + return false; + }, + /** + * Change texture shader program parameters. + * @param director + */ + glSetShader:function (director) { + + var tp = this.getTextureGLPage(); + if (tp !== director.currentTexturePage) { + director.setGLTexturePage(tp); + } + + if (this.frameAlpha !== director.currentOpacity) { + director.setGLCurrentOpacity(this.frameAlpha); + } + }, + /** + * @private. + * This method is called after the Director has transformed and drawn a whole frame. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * @return this + * + * @deprecated + */ + endAnimate:function (director, time) { + return this; + }, + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + /** + * Set this Actor's clipping area. + * @param enable {boolean} enable clip area. + * @param clipPath {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set, + * a rectangle will be used. + */ + setClip:function (enable, clipPath) { + this.clip = enable; + this.clipPath = clipPath; + return this; + }, + + isCached : function() { + return this.cached; + }, + + stopCacheAsBitmap:function () { + if (this.cached) { + this.backgroundImage = null; + this.cached = CAAT.Foundation.Actor.CACHE_NONE; + } + }, + + /** + * + * @param time {Number=} + * @param stragegy {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP} + * @return this + */ + cacheAsBitmap:function (time, strategy) { + + if (this.width<=0 || this.height<=0 ) { + return this; + } + + time = time || 0; + var canvas = document.createElement('canvas'); + canvas.width = this.width; + canvas.height = this.height; + var ctx = canvas.getContext('2d'); + + CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,time); + + var director = { + ctx:ctx, + modelViewMatrix: new CAAT.Math.Matrix(), + worldModelViewMatrix: new CAAT.Math.Matrix(), + dirtyRectsEnabled:false, + inDirtyRect:function () { + return true; + }, + AABB : new CAAT.Math.Rectangle(0,0,this.width,this.height) + }; + + var pmv = this.modelViewMatrix; + var pwmv = this.worldModelViewMatrix; + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + + this.cached = CAAT.Foundation.Actor.CACHE_NONE; + + if ( typeof strategy==="undefined" ) { + strategy= CAAT.Foundation.Actor.CACHE_SIMPLE; + } + if ( strategy===CAAT.Foundation.Actor.CACHE_DEEP ) { + this.animate(director, time ); + this.paintActor(director, time); + } else { + if ( this instanceof CAAT.Foundation.ActorContainer || this instanceof CAAT.ActorContainer ) { + CAAT.Foundation.ActorContainer.superclass.paintActor.call(this, director, time); + } else { + this.animate(director, time ); + this.paintActor(director, time); + } + } + this.setBackgroundImage(canvas); + + this.cached = strategy; + + this.modelViewMatrix = pmv; + this.worldModelViewMatrix = pwmv; + + return this; + }, + resetAsButton : function() { + this.actionPerformed= null; + this.mouseEnter= function() {}; + this.mouseExit= function() {}; + this.mouseDown= function() {}; + this.mouseUp= function() {}; + this.mouseClick= function() {}; + this.mouseDrag= function() {}; + return this; + }, + /** + * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's + * single size. + * + * @param buttonImage {CAAT.Foundation.SpriteImage} sprite image with button's state images. + * @param iNormal {number} button's normal state image index + * @param iOver {number} button's mouse over state image index + * @param iPress {number} button's pressed state image index + * @param iDisabled {number} button's disabled state image index + * @param fn {function(button{CAAT.Foundation.Actor})} callback function + */ + setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) { + + var me = this; + + this.setBackgroundImage(buttonImage, true); + + this.iNormal = iNormal || 0; + this.iOver = iOver || this.iNormal; + this.iPress = iPress || this.iNormal; + this.iDisabled = iDisabled || this.iNormal; + this.fnOnClick = fn; + this.enabled = true; + + this.setSpriteIndex(iNormal); + + /** + * Enable or disable the button. + * @param enabled {boolean} + * @ignore + */ + this.setEnabled = function (enabled) { + this.enabled = enabled; + this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled); + return this; + }; + + /** + * This method will be called by CAAT *before* the mouseUp event is fired. + * @param event {CAAT.Event.MouseEvent} + * @ignore + */ + this.actionPerformed = function (event) { + if (this.enabled && this.fnOnClick) { + this.fnOnClick(this); + } + }; + + /** + * Button's mouse enter handler. It makes the button provide visual feedback + * @param mouseEvent {CAAT.Event.MouseEvent} + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + if (!this.enabled) { + return; + } + + if (this.dragging) { + this.setSpriteIndex(this.iPress); + } else { + this.setSpriteIndex(this.iOver); + } + CAAT.setCursor('pointer'); + }; + + /** + * Button's mouse exit handler. Release visual apperance. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseExit = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iNormal); + CAAT.setCursor('default'); + }; + + /** + * Button's mouse down handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDown = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iPress); + }; + + /** + * Button's mouse up handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseUp = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iNormal); + this.dragging = false; + }; + + /** + * Button's mouse click handler. Do nothing by default. This event handler will be + * called ONLY if it has not been drag on the button. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseClick = function (mouseEvent) { + }; + + /** + * Button's mouse drag handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.dragging = true; + }; + + this.setButtonImageIndex = function (_normal, _over, _press, _disabled) { + this.iNormal = _normal || 0; + this.iOver = _over || this.iNormal; + this.iPress = _press || this.iNormal; + this.iDisabled = _disabled || this.iNormal; + this.setSpriteIndex(this.iNormal); + return this; + }; + + return this; + }, + + findActorById : function(id) { + return this.id===id ? this : null; + } + } + } +}); +CAAT.Module({ + + /** + * @name ActorContainer + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.Actor + * @constructor + */ + + /** + * @name ADDHINT + * @memberOf CAAT.Foundation.ActorContainer + * @namespace + */ + + /** + * @name AddHint + * @memberOf CAAT.Foundation.ActorContainer + * @namespace + * @deprecated + */ + + defines:"CAAT.Foundation.ActorContainer", + aliases:["CAAT.ActorContainer"], + depends:[ + "CAAT.Foundation.Actor", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + constants : { + + /** + * @lends CAAT.Foundation.ActorContainer + * */ + + ADDHINT:{ + + /** + * @lends CAAT.Foundation.ActorContainer.ADDHINT + */ + + /** @const */ CONFORM:1 + }, + + AddHint : { + + /** + * @lends CAAT.Foundation.ActorContainer.AddHint + */ + /** @const */ CONFORM:1 + } + }, + extendsClass : "CAAT.Foundation.Actor", + extendsWith : function () { + + + + var __CD = CAAT.Foundation.Actor.CACHE_DEEP; + + var sc= CAAT.Foundation.ActorContainer.superclass; + var sc_drawScreenBoundingBox= sc.drawScreenBoundingBox; + var sc_paintActor= sc.paintActor; + var sc_paintActorGL= sc.paintActorGL; + var sc_animate= sc.animate; + var sc_findActorAtPosition = sc.findActorAtPosition; + var sc_destroy = sc.destroy; + + return { + + /** + * + * @lends CAAT.Foundation.ActorContainer.prototype + */ + + /** + * Constructor delegate + * @param hint {CAAT.Foundation.ActorContainer.AddHint} + * @return {*} + * @private + */ + __init:function (hint) { + + this.__super(); + + this.childrenList = []; + this.activeChildren = []; + this.pendingChildrenList = []; + if (typeof hint !== 'undefined') { + this.addHint = hint; + this.boundingBox = new CAAT.Math.Rectangle(); + } + return this; + }, + + /** + * This container children. + * @type {Array.} + */ + childrenList:null, + + /** + * This container active children. + * @type {Array.} + * @private + */ + activeChildren:null, + + /** + * This container pending to be added children. + * @type {Array.} + * @private + */ + pendingChildrenList:null, + + /** + * Container redimension policy when adding children: + * 0 : no resize. + * CAAT.Foundation.ActorContainer.AddHint.CONFORM : resize container to a bounding box. + * + * @type {number} + * @private + */ + addHint:0, + + /** + * If container redimension on children add, use this rectangle as bounding box store. + * @type {CAAT.Math.Rectangle} + * @private + */ + boundingBox:null, + + /** + * Spare rectangle to avoid new allocations when adding children to this container. + * @type {CAAT.Math.Rectangle} + * @private + */ + runion:new CAAT.Math.Rectangle(), // Watch out. one for every container. + + /** + * Define a layout manager for this container that enforces children position and/or sizes. + * @see demo26 for an example of layouts. + * @type {CAAT.Foundation.UI.Layout.LayoutManager} + */ + layoutManager:null, // a layout manager instance. + + /** + * @type {boolean} + */ + layoutInvalidated:true, + + setLayout:function (layout) { + this.layoutManager = layout; + return this; + }, + + setBounds:function (x, y, w, h) { + CAAT.Foundation.ActorContainer.superclass.setBounds.call(this, x, y, w, h); + if (CAAT.currentDirector && !CAAT.currentDirector.inValidation) { + this.invalidateLayout(); + } + return this; + }, + + __validateLayout:function () { + + this.__validateTree(); + this.layoutInvalidated = false; + }, + + __validateTree:function () { + if (this.layoutManager && this.layoutManager.isInvalidated()) { + + CAAT.currentDirector.inValidation = true; + + this.layoutManager.doLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).__validateLayout(); + } + } + }, + + invalidateLayout:function () { + this.layoutInvalidated = true; + + if (this.layoutManager) { + this.layoutManager.invalidateLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).invalidateLayout(); + } + } + }, + + getLayout:function () { + return this.layoutManager; + }, + + /** + * Draws this ActorContainer and all of its children screen bounding box. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + + if (!this.inFrame) { + return; + } + + var cl = this.activeChildren; + for (var i = 0; i < cl.length; i++) { + cl[i].drawScreenBoundingBox(director, time); + } + sc_drawScreenBoundingBox.call(this, director, time); + }, + /** + * Removes all children from this ActorContainer. + * + * @return this + */ + emptyChildren:function () { + this.childrenList = []; + + return this; + }, + /** + * Private + * Paints this container and every contained children. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + paintActor:function (director, time) { + + if (!this.visible) { + return false; + } + + var ctx = director.ctx; + + ctx.save(); + + if (!sc_paintActor.call(this, director, time)) { + return false; + } + + if (this.cached === __CD) { + return false; + } + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent ? this.parent.frameAlpha : 1; + } + + for (var i = 0, l = this.activeChildren.length; i < l; ++i) { + var actor = this.activeChildren[i]; + + if (actor.visible) { + ctx.save(); + actor.paintActor(director, time); + ctx.restore(); + } + } + + if (this.postPaint) { + this.postPaint( director, time ); + } + + ctx.restore(); + + return true; + }, + __paintActor:function (director, time) { + if (!this.visible) { + return true; + } + + var ctx = director.ctx; + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + var m = this.worldModelViewMatrix.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha); + this.paint(director, time); + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent ? this.parent.frameAlpha : 1; + } + + for (var i = 0, l = this.activeChildren.length; i < l; ++i) { + var actor = this.activeChildren[i]; + actor.paintActor(director, time); + } + return true; + }, + paintActorGL:function (director, time) { + + var i, l, c; + + if (!this.visible) { + return true; + } + + sc_paintActorGL.call(this, director, time); + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent.frameAlpha; + } + + for (i = 0, l = this.activeChildren.length; i < l; ++i) { + c = this.activeChildren[i]; + c.paintActorGL(director, time); + } + + }, + /** + * Private. + * Performs the animate method for this ActorContainer and every contained Actor. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return {boolean} is this actor in active children list ?? + */ + animate:function (director, time) { + + if (!this.visible) { + return false; + } + + this.activeChildren = []; + var last = null; + + if (false === sc_animate.call(this, director, time)) { + return false; + } + + if (this.cached === __CD) { + return true; + } + + this.__validateLayout(); + CAAT.currentDirector.inValidation = false; + + var i, l; + + /** + * Incluir los actores pendientes. + * El momento es ahora, antes de procesar ninguno del contenedor. + */ + var pcl = this.pendingChildrenList; + for (i = 0; i < pcl.length; i++) { + var child = pcl[i]; + this.addChildImmediately(child.child, child.constraint); + } + + this.pendingChildrenList = []; + var markDelete = []; + + var cl = this.childrenList; + this.size_active = 1; + this.size_total = 1; + for (i = 0; i < cl.length; i++) { + var actor = cl[i]; + actor.time = time; + this.size_total += actor.size_total; + if (actor.animate(director, time)) { + this.activeChildren.push(actor); + this.size_active += actor.size_active; + } else { + if (actor.expired && actor.discardable) { + markDelete.push(actor); + } + } + } + + for (i = 0, l = markDelete.length; i < l; i++) { + var md = markDelete[i]; + md.destroy(time); + if (director.dirtyRectsEnabled) { + director.addDirtyRect(md.AABB); + } + } + + return true; + }, + /** + * Removes Actors from this ActorContainer which are expired and flagged as Discardable. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @deprecated + */ + endAnimate:function (director, time) { + }, + /** + * Adds an Actor to this Container. + * The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at + * the time of method call. + * + * This method is only used by director's transitionScene. + * + * @param child {CAAT.Foundation.Actor} + * @param constraint {object} + * @return this. + */ + addChildImmediately:function (child, constraint) { + return this.addChild(child, constraint); + }, + + addActorImmediately: function(child,constraint) { + return this.addChildImmediately(child,constraint); + }, + + addActor : function( child, constraint ) { + return this.addChild(child,constraint); + }, + + /** + * Adds an Actor to this ActorContainer. + * The Actor will be added to the container AFTER frame animation, and not on method call time. + * Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this + * method directly. + * + * If the container has addingHint as CAAT.Foundation.ActorContainer.AddHint.CONFORM, new continer size will be + * calculated by summing up the union of every client actor bounding box. + * This method will not take into acount actor's affine transformations, so the bounding box will be + * AABB. + * + * @param child {CAAT.Foundation.Actor} object instance. + * @param constraint {object} + * @return this + */ + addChild:function (child, constraint) { + + if (child.parent != null) { + throw('adding to a container an element with parent.'); + } + + child.parent = this; + this.childrenList.push(child); + child.dirty = true; + + if (this.layoutManager) { + this.layoutManager.addChild(child, constraint); + this.invalidateLayout(); + } else { + /** + * if Conforming size, recalc new bountainer size. + */ + if (this.addHint === CAAT.Foundation.ActorContainer.AddHint.CONFORM) { + this.recalcSize(); + } + } + + return this; + }, + + /** + * Recalc this container size by computing the union of every children bounding box. + */ + recalcSize:function () { + var bb = this.boundingBox; + bb.setEmpty(); + var cl = this.childrenList; + var ac; + for (var i = 0; i < cl.length; i++) { + ac = cl[i]; + this.runion.setBounds( + ac.x < 0 ? 0 : ac.x, + ac.y < 0 ? 0 : ac.y, + ac.width, + ac.height); + bb.unionRectangle(this.runion); + } + this.setSize(bb.x1, bb.y1); + + return this; + }, + + /** + * Add a child element and make it active in the next frame. + * @param child {CAAT.Foundation.Actor} + */ + addChildDelayed:function (child, constraint) { + this.pendingChildrenList.push({ child:child, constraint: constraint }); + return this; + }, + /** + * Adds an Actor to this ActorContainer. + * + * @param child {CAAT.Foundation.Actor}. + * @param index {number} + * + * @return this + */ + addChildAt:function (child, index) { + + if (index <= 0) { + child.parent = this; + child.dirty = true; + this.childrenList.splice(0, 0, child); + this.invalidateLayout(); + return this; + } else { + if (index >= this.childrenList.length) { + index = this.childrenList.length; + } + } + + child.parent = this; + child.dirty = true; + this.childrenList.splice(index, 0, child); + this.invalidateLayout(); + + return this; + }, + /** + * Find the first actor with the supplied ID. + * This method is not recommended to be used since executes a linear search. + * @param id + */ + findActorById:function (id) { + + if ( CAAT.Foundation.ActorContainer.superclass.findActorById.call(this,id) ) { + return this; + } + + var cl = this.childrenList; + for (var i = 0, l = cl.length; i < l; i++) { + var ret= cl[i].findActorById(id); + if (null!=ret) { + return ret; + } + } + + return null; + }, + /** + * Private + * Gets a contained Actor z-index on this ActorContainer. + * + * @param child a CAAT.Foundation.Actor object instance. + * + * @return {number} + */ + findChild:function (child) { + var cl = this.childrenList; + var i; + var len = cl.length; + + for (i = 0; i < len; i++) { + if (cl[i] === child) { + return i; + } + } + return -1; + }, + removeChildAt:function (pos) { + var cl = this.childrenList; + var rm; + if (-1 !== pos && pos>=0 && pos= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Math.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + /** + * Destroys this ActorContainer. + * The process falls down recursively for each contained Actor into this ActorContainer. + * + * @return this + */ + destroy:function () { + var cl = this.childrenList; + for (var i = cl.length - 1; i >= 0; i--) { + cl[i].destroy(); + } + sc_destroy.call(this); + + return this; + }, + /** + * Get number of Actors into this container. + * @return integer indicating the number of children. + */ + getNumChildren:function () { + return this.childrenList.length; + }, + getNumActiveChildren:function () { + return this.activeChildren.length; + }, + /** + * Returns the Actor at the iPosition(th) position. + * @param iPosition an integer indicating the position array. + * @return the CAAT.Foundation.Actor object at position. + */ + getChildAt:function (iPosition) { + return this.childrenList[ iPosition ]; + }, + /** + * Changes an actor's ZOrder. + * @param actor the actor to change ZOrder for + * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the + * last ZOrder Actor. + */ + setZOrder:function (actor, index) { + var actorPos = this.findChild(actor); + // the actor is present + if (-1 !== actorPos) { + var cl = this.childrenList; + // trivial reject. + if (index === actorPos) { + return; + } + + if (index >= cl.length) { + cl.splice(actorPos, 1); + cl.push(actor); + } else { + var nActor = cl.splice(actorPos, 1); + if (index < 0) { + index = 0; + } else if (index > cl.length) { + index = cl.length; + } + + cl.splice(index, 0, nActor[0]); + } + + this.invalidateLayout(); + } + } + } + + } +}); +/** + * See LICENSE file. + * + */ + +CAAT.Module({ + + /** + * @name Scene + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.ActorContainer + * + * @constructor + * + */ + + defines:"CAAT.Foundation.Scene", + depends: [ + "CAAT.Math.Point", + "CAAT.Math.Matrix", + "CAAT.PathUtil.Path", + "CAAT.Behavior.GenericBehavior", + "CAAT.Behavior.ContainerBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.AlphaBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.PathBehavior", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.Timer.TimerManager" + ], + aliases:["CAAT.Scene"], + extendsClass:"CAAT.Foundation.ActorContainer", + constants:{ + /** + * @lends CAAT.Foundation.Scene + */ + + /** @const @type {number} */ EASE_ROTATION:1, // Constant values to identify the type of Scene transition + /** @const @type {number} */ EASE_SCALE:2, // to perform on Scene switching by the Director. + /** @const @type {number} */ EASE_TRANSLATE:3 + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Foundation.Scene.prototype + */ + + __init:function () { + this.__super(); + this.timerManager = new CAAT.TimerManager(); + this.fillStyle = null; + this.isGlobalAlpha = true; + return this; + }, + + /** + * Behavior container used uniquely for Scene switching. + * @type {CAAT.Behavior.ContainerBehavior} + * @private + */ + easeContainerBehaviour:null, + + /** + * Array of container behaviour events observer. + * @private + */ + easeContainerBehaviourListener:null, + + /** + * When Scene switching, this boolean identifies whether the Scene is being brought in, or taken away. + * @type {boolean} + * @private + */ + easeIn:false, + + + /** + * is this scene paused ? + * @type {boolean} + * @private + */ + paused:false, + + /** + * This scene´s timer manager. + * @type {CAAT.Foundation.Timer.TimerManager} + * @private + */ + timerManager:null, + + isPaused:function () { + return this.paused; + }, + + setPaused:function (paused) { + this.paused = paused; + }, + + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + setTimeout:function (duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(this.time, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + /** + * Helper method to manage alpha transparency fading on Scene switch by the Director. + * @param time {number} time in milliseconds then fading will taableIne. + * @param isIn {boolean} whether this Scene is being brought in. + * + * @private + */ + createAlphaBehaviour:function (time, isIn) { + var ab = new CAAT.Behavior.AlphaBehavior(); + ab.setFrameTime(0, time); + ab.startAlpha = isIn ? 0 : 1; + ab.endAlpha = isIn ? 1 : 0; + this.easeContainerBehaviour.addBehavior(ab); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslationIn:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, true, interpolator); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time {number} time in milliseconds for the Scene to be taken away. + * @param alpha {boolean} fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslationOut:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, false, interpolator); + }, + /** + * This method will setup Scene behaviours to switch an Scene via a translation. + * The anchor value can only be + *
  • CAAT.Actor.ANCHOR_LEFT + *
  • CAAT.Actor.ANCHOR_RIGHT + *
  • CAAT.Actor.ANCHOR_TOP + *
  • CAAT.Actor.ANCHOR_BOTTOM + * if any other value is specified, any of the previous ones will be applied. + * + * @param time {number} time in milliseconds for the Scene. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {numnber} Scene switch anchor. + * @param isIn {boolean} whether the scene will be brought in. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslation:function (time, alpha, anchor, isIn, interpolator) { + + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + this.easeIn = isIn; + + var pb = new CAAT.Behavior.PathBehavior(); + if (interpolator) { + pb.setInterpolator(interpolator); + } + + pb.setFrameTime(0, time); + + // BUGBUG anchors: 1..4 + if (anchor < 1) { + anchor = 1; + } else if (anchor > 4) { + anchor = 4; + } + + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, -this.height + 1, 0, 0)); + this.setPosition(0,-this.height+1); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, -this.height + 1)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, this.height - 1, 0, 0)); + this.setPosition(0,this.height-1); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, this.height - 1)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(-this.width + 1, 0, 0, 0)); + this.setPosition(-this.width+1,0); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, -this.width + 1, 0)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(this.width - 1, 0, 0, 0)); + this.setPosition(this.width-1,0); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, this.width - 1, 0)); + this.setPosition(0,0); + } + break; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + this.easeContainerBehaviour.addBehavior(pb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Called from CAAT.Foundation.Director to bring in a Scene. + * A helper method for easeScale. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + */ + easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Foundation.Director to take away a Scene. + * A helper method for easeScale. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + **/ + easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Foundation.Director to bring in ot take away an Scene. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + * @param isIn boolean indicating whether the Scene is being brought in. + */ + easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var x = 0; + var y = 0; + var x2 = 0; + var y2 = 0; + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_CENTER: + x2 = 1; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + x = 1; + x2 = 1; + y = 0; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + y = 1; + y2 = 1; + x = 0; + x2 = 1; + break; + default: + alert('scale anchor ?? ' + anchor); + } + + if (!isIn) { + var tmp; + tmp = x; + x = x2; + x2 = tmp; + + tmp = y; + y = y2; + y2 = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var sb = new CAAT.Behavior.ScaleBehavior(). + setFrameTime(starttime, time). + setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + sb.setInterpolator(interpolator); + } + + this.easeContainerBehaviour.addBehavior(sb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Overriden method to disallow default behavior. + * Do not use directly. + */ + addBehavior:function (behaviour) { + return this; + }, + /** + * Called from CAAT.Director to use Rotations for bringing in. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationIn:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to use Rotations for taking Scenes away. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationOut:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. + * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param isIn boolean indicating whehter the Scene is brought in. + */ + easeRotation:function (time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var start = 0; + var end = 0; + + if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { + anchor = CAAT.Foundation.Actor.ANCHOR_TOP; + } + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + start = Math.PI * (Math.random() < 0.5 ? 1 : -1); + break; + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); + break; + default: + alert('rot anchor ?? ' + anchor); + } + + if (false === isIn) { + var tmp = start; + start = end; + end = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var rb = new CAAT.Behavior.RotateBehavior(). + setFrameTime(0, time). + setValues(start, end, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + rb.setInterpolator(interpolator); + } + this.easeContainerBehaviour.addBehavior(rb); + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Registers a listener for listen for transitions events. + * Al least, the Director registers himself as Scene easing transition listener. + * When the transition is done, it restores the Scene's capability of receiving events. + * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form + * behaviorExpired( caat_behaviour, time, actor); + */ + setEaseListener:function (listener) { + this.easeContainerBehaviourListener = listener; + }, + /** + * Private. + * listener for the Scene's easeContainerBehaviour. + * @param actor + */ + behaviorExpired:function (actor) { + this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); + }, + /** + * This method should be overriden in case the developer wants to do some special actions when + * the scene has just been brought in. + */ + activated:function () { + }, + /** + * Scenes, do not expire the same way Actors do. + * It simply will be set expired=true, but the frameTime won't be modified. + */ + setExpired:function (bExpired) { + this.expired = bExpired; + }, + /** + * An scene by default does not paint anything because has not fillStyle set. + * @param director + * @param time + */ + paint:function (director, time) { + + if (this.fillStyle) { + var ctx = director.ctx; + ctx.fillStyle = this.fillStyle; + ctx.fillRect(0, 0, this.width, this.height); + } + }, + /** + * Find a pointed actor at position point. + * This method tries lo find the correctly pointed actor in two different ways. + * + first of all, if inputList is defined, it will look for an actor in it. + * + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. + * @param point + */ + findActorAtPosition:function (point) { + var i, j; + + var p = new CAAT.Math.Point(); + + if (this.inputList) { + var il = this.inputList; + for (i = 0; i < il.length; i++) { + var ill = il[i]; + for (j = 0; j < ill.length; j++) { + if ( ill[j].visible ) { + p.set(point.x, point.y); + var modelViewMatrixI = ill[j].worldModelViewMatrix.getInverse(); + modelViewMatrixI.transformCoord(p); + if (ill[j].contains(p.x, p.y)) { + return ill[j]; + } + } + } + } + } + + p.set(point.x, point.y); + return CAAT.Foundation.Scene.superclass.findActorAtPosition.call(this, p); + }, + + /** + * Enable a number of input lists. + * These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed + * actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance. + * The system will traverse the whole lists in order trying to find a pointed actor. + * + * Elements are added to each list either in head or tail. + * + * @param size number of lists. + */ + enableInputList:function (size) { + this.inputList = []; + for (var i = 0; i < size; i++) { + this.inputList.push([]); + } + + return this; + }, + + /** + * Add an actor to a given inputList. + * @param actor an actor instance + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists. + * @param position the position on the selected inputList to add the actor at. This value will be + * clamped to the number of available lists. + */ + addActorToInputList:function (actor, index, position) { + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + var il = this.inputList[index]; + + if (typeof position === "undefined" || position >= il.length) { + il.push(actor); + } else if (position <= 0) { + il.unshift(actor); + } else { + il.splice(position, 0, actor); + } + + return this; + }, + + /** + * Remove all elements from an input list. + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists so take care when emptying a non existant inputList index since you could end up emptying + * an undesired input list. + */ + emptyInputList:function (index) { + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + this.inputList[index] = []; + return this; + }, + + /** + * remove an actor from a given input list index. + * If no index is supplied, the actor will be removed from every input list. + * @param actor + * @param index an optional input list index. This value will be clamped to the number of + * available lists. + */ + removeActorFromInputList:function (actor, index) { + if (typeof index === "undefined") { + var i, j; + for (i = 0; i < this.inputList.length; i++) { + var il = this.inputList[i]; + for (j = 0; j < il.length; j++) { + if (il[j] == actor) { + il.splice(j, 1); + } + } + } + return this; + } + + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + var il = this.inputList[index]; + for (j = 0; j < il.length; j++) { + if (il[j] == actor) { + il.splice(j, 1); + } + } + + return this; + }, + + getIn : function( out_scene ) { + + }, + + goOut : function( in_scene ) { + + } + + } + } + + +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Director + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.ActorContainer + * + * @constructor + */ + + defines:"CAAT.Foundation.Director", + aliases:["CAAT.Director"], + extendsClass:"CAAT.Foundation.ActorContainer", + depends:[ + "CAAT.Core.Class", + "CAAT.Core.Constants", + + "CAAT.Foundation.ActorContainer", + "CAAT.Module.Audio.AudioManager", + "CAAT.Module.Runtime.BrowserInfo", + "CAAT.Module.Debug.Debug", + "CAAT.Math.Point", + "CAAT.Math.Rectangle", + "CAAT.Math.Matrix", + "CAAT.Foundation.Timer.TimerManager", + "CAAT.Foundation.Actor", + "CAAT.Foundation.Scene", + "CAAT.Event.AnimationLoop", + "CAAT.Event.Input", + "CAAT.Event.KeyEvent", + "CAAT.Event.MouseEvent", + "CAAT.Event.TouchEvent", + + "CAAT.WebGL.Program", + "CAAT.WebGL.ColorProgram", + "CAAT.WebGL.TextureProgram", + "CAAT.WebGL.GLU", + + "CAAT.Module.TexturePacker.TexturePageManager" + ], + constants:{ + /** + * @lends CAAT.Foundation.Director + */ + + /** @const @type {number} */ RENDER_MODE_CONTINUOUS:1, // redraw every frame + /** @const @type {number} */ RENDER_MODE_DIRTY:2, // suitable for evented CAAT. + + /** @const @type {number} */ CLEAR_DIRTY_RECTS:1, + /** @const @type {number} */ CLEAR_ALL:true, + /** @const @type {number} */ CLEAR_NONE:false, + + /** @const @type {number} */ RESIZE_NONE:1, + /** @const @type {number} */ RESIZE_WIDTH:2, + /** @const @type {number} */ RESIZE_HEIGHT:4, + /** @const @type {number} */ RESIZE_BOTH:8, + /** @const @type {number} */ RESIZE_PROPORTIONAL:16 + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Foundation.Director.prototype + */ + + __init:function () { + this.__super(); + + this.browserInfo = CAAT.Module.Runtime.BrowserInfo; + this.audioManager = new CAAT.Module.Audio.AudioManager().initialize(8); + this.scenes = []; + this.imagesCache= []; + + // input related variables initialization + this.mousePoint = new CAAT.Math.Point(0, 0, 0); + this.prevMousePoint = new CAAT.Math.Point(0, 0, 0); + this.screenMousePoint = new CAAT.Math.Point(0, 0, 0); + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + + this.cDirtyRects = []; + this.sDirtyRects = []; + this.dirtyRects = []; + for (var i = 0; i < 64; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + this.dirtyRectsIndex = 0; + this.touches = {}; + + this.timerManager = new CAAT.Foundation.Timer.TimerManager(); + this.__map= {}; + + return this; + }, + + /** + * flag indicating debug mode. It will draw affedted screen areas. + * @type {boolean} + */ + debug:false, + + /** + * Set CAAT render mode. Right now, this takes no effect. + */ + renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS, + + /** + * This method will be called before rendering any director scene. + * Use this method to calculate your physics for example. + * @private + */ + onRenderStart:null, + + /** + * This method will be called after rendering any director scene. + * Use this method to clean your physics forces for example. + * @private + */ + onRenderEnd:null, + + // input related attributes + /** + * mouse coordinate related to canvas 0,0 coord. + * @private + */ + mousePoint:null, + + /** + * previous mouse position cache. Needed for drag events. + * @private + */ + prevMousePoint:null, + + /** + * screen mouse coordinates. + * @private + */ + screenMousePoint:null, + + /** + * is the left mouse button pressed ?. + * Needed to handle dragging. + */ + isMouseDown:false, + + /** + * director's last actor receiving input. + * Needed to set capture for dragging events. + */ + lastSelectedActor:null, + + /** + * is input in drag mode ? + */ + dragging:false, + + // other attributes + + /** + * This director scene collection. + * @type {Array.} + */ + scenes:null, + + /** + * The current Scene. This and only this will receive events. + */ + currentScene:null, + + /** + * The canvas the Director draws on. + * @private + */ + canvas:null, + + /** + * This director´s canvas rendering context. + */ + ctx:null, + + /** + * director time. + * @private + */ + time:0, + + /** + * global director timeline. + * @private + */ + timeline:0, + + /** + * An array of JSON elements of the form { id:string, image:Image } + */ + imagesCache:null, + + /** + * this director´s audio manager. + * @private + */ + audioManager:null, + + /** + * Clear screen strategy: + * CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background. + * CAAT.Foundation.Director.CLEAR_DIRTY_RECTS : clear only affected actors screen area. + * CAAT.Foundation.Director.CLEAR_ALL : clear the whole canvas object. + */ + clear: CAAT.Foundation.Director.CLEAR_ALL, + + /** + * if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene. + * @private + */ + transitionScene:null, + + /** + * Some browser related information. + */ + browserInfo:null, + + /** + * 3d context + * @private + */ + gl:null, + + /** + * is WebGL enabled as renderer ? + * @private + */ + glEnabled:false, + + /** + * if webGL is on, CAAT will texture pack all images transparently. + * @private + */ + glTextureManager:null, + + /** + * The only GLSL program for webGL + * @private + */ + glTtextureProgram:null, + glColorProgram:null, + + /** + * webGL projection matrix + * @private + */ + pMatrix:null, // projection matrix + + /** + * webGL vertex array + * @private + */ + coords:null, // Float32Array + + /** + * webGL vertex indices. + * @private + */ + coordsIndex:0, + + /** + * webGL uv texture indices + * @private + */ + uv:null, + uvIndex:0, + + /** + * draw tris front_to_back or back_to_front ? + * @private + */ + front_to_back:false, + + /** + * statistics object + */ + statistics:{ + size_total:0, + size_active:0, + size_dirtyRects:0, + draws:0, + size_discarded_by_dirty_rects:0 + }, + + /** + * webGL current texture page. This minimizes webGL context changes. + * @private + */ + currentTexturePage:0, + + /** + * webGL current shader opacity. + * BUGBUG: change this by vertex colors. + * @private + */ + currentOpacity:1, + + /** + * if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned + * id. + * @private + */ + intervalId:null, + + /** + * Rendered frames counter. + */ + frameCounter:0, + + /** + * Window resize strategy. + * see CAAT.Foundation.Director.RESIZE_* constants. + * @private + */ + resize:1, + + /** + * Callback when the window is resized. + */ + onResizeCallback:null, + + /** + * Calculated gesture event scale. + * @private + */ + __gestureScale:0, + + /** + * Calculated gesture event rotation. + * @private + */ + __gestureRotation:0, + + /** + * Dirty rects cache. + * An array of CAAT.Math.Rectangle object. + * @private + */ + dirtyRects:null, // dirty rects cache. + + /** + * current dirty rects. + * @private + */ + cDirtyRects:null, // dirty rects cache. + + /** + * Currently used dirty rects. + * @private + */ + sDirtyRects:null, // scheduled dirty rects. + + /** + * Number of currently allocated dirty rects. + * @private + */ + dirtyRectsIndex:0, + + /** + * Dirty rects enabled ?? + * @private + */ + dirtyRectsEnabled:false, + + /** + * Number of dirty rects. + * @private + */ + nDirtyRects:0, + + /** + * Dirty rects count debug info. + * @private + */ + drDiscarded:0, // discarded by dirty rects. + + /** + * Is this director stopped ? + */ + stopped:false, // is stopped, this director will do nothing. + + /** + * currently unused. + * Intended to run caat in evented mode. + * @private + */ + needsRepaint:false, + + /** + * Touches information. Associate touch.id with an actor and original touch info. + * @private + */ + touches:null, + + /** + * Director´s timer manager. + * Each scene has a timerManager as well. + * The difference is the scope. Director´s timers will always be checked whereas scene´ timers + * will only be scheduled/checked when the scene is director´ current scene. + * @private + */ + timerManager:null, + + /** + * Retina display deicePixels/backingStorePixels ratio + * @private + */ + SCREEN_RATIO : 1, + + __map : null, + + clean:function () { + this.scenes = null; + this.currentScene = null; + this.imagesCache = null; + this.audioManager = null; + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + this.__gestureScale = 0; + this.__gestureRotation = 0; + this.dirty = true; + this.dirtyRects = null; + this.cDirtyRects = null; + this.dirtyRectsIndex = 0; + this.dirtyRectsEnabled = false; + this.nDirtyRects = 0; + this.onResizeCallback = null; + this.__map= {}; + return this; + }, + + cancelPlay : function(id) { + return this.audioManager.cancelPlay(id); + }, + + cancelPlayByChannel : function(audioObject) { + return this.audioManager.cancelPlayByChannel(audioObject); + }, + + setAudioFormatExtensions : function( extensions ) { + this.audioManager.setAudioFormatExtensions(extensions); + return this; + }, + + setValueForKey : function( key, value ) { + this.__map[key]= value; + return this; + }, + + getValueForKey : function( key ) { + return this.__map[key]; + }, + + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + requestRepaint:function () { + this.needsRepaint = true; + }, + + getCurrentScene:function () { + return this.currentScene; + }, + + checkDebug:function () { + if (!navigator.isCocoonJS && CAAT.DEBUG) { + var dd = new CAAT.Module.Debug.Debug().initialize(this.width, 60); + this.debugInfo = dd.debugInfo.bind(dd); + } + }, + getRenderType:function () { + return this.glEnabled ? 'WEBGL' : 'CANVAS'; + }, + windowResized:function (w, h) { + var c = CAAT.Foundation.Director; + switch (this.resize) { + case c.RESIZE_WIDTH: + this.setBounds(0, 0, w, this.height); + break; + case c.RESIZE_HEIGHT: + this.setBounds(0, 0, this.width, h); + break; + case c.RESIZE_BOTH: + this.setBounds(0, 0, w, h); + break; + case c.RESIZE_PROPORTIONAL: + this.setScaleProportional(w, h); + break; + } + + if (this.glEnabled) { + this.glReset(); + } + + if (this.onResizeCallback) { + this.onResizeCallback(this, w, h); + } + + }, + setScaleProportional:function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + + this.canvas.width = this.referenceWidth * factor; + this.canvas.height = this.referenceHeight * factor; + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + this.setScaleAnchored(factor * this.scaleX, factor * this.scaleY, 0, 0); +// this.setScaleAnchored(factor, factor, 0, 0); + + if (this.glEnabled) { + this.glReset(); + } + }, + /** + * Enable window resize events and set redimension policy. A callback functio could be supplied + * to be notified on a Director redimension event. This is necessary in the case you set a redim + * policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their + * children scenes are resized to fit the new area. But scenes content is not resized, and have + * no option of knowing so uless an onResizeCallback function is supplied. + * + * @param mode {number} RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE. + * @param onResizeCallback {function(director{CAAT.Director}, width{integer}, height{integer})} a callback + * to notify on canvas resize. + */ + enableResizeEvents:function (mode, onResizeCallback) { + var dd= CAAT.Foundation.Director; + if (mode === dd.RESIZE_BOTH || mode === dd.RESIZE_WIDTH || mode === dd.RESIZE_HEIGHT || mode === dd.RESIZE_PROPORTIONAL) { + this.referenceWidth = this.width; + this.referenceHeight = this.height; + this.resize = mode; + CAAT.registerResizeListener(this); + this.onResizeCallback = onResizeCallback; + this.windowResized(window.innerWidth, window.innerHeight); + } else { + CAAT.unregisterResizeListener(this); + this.onResizeCallback = null; + } + + return this; + }, + + __setupRetina : function() { + + if ( CAAT.RETINA_DISPLAY_ENABLED ) { + + // The world is full of opensource awesomeness. + // + // Source: http://www.html5rocks.com/en/tutorials/canvas/hidpi/ + // + var devicePixelRatio= CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio; + var backingStoreRatio = this.ctx.webkitBackingStorePixelRatio || + this.ctx.mozBackingStorePixelRatio || + this.ctx.msBackingStorePixelRatio || + this.ctx.oBackingStorePixelRatio || + this.ctx.backingStorePixelRatio || + 1; + + var ratio = devicePixelRatio / backingStoreRatio; + + if (devicePixelRatio !== backingStoreRatio) { + + var oldWidth = this.canvas.width; + var oldHeight = this.canvas.height; + + this.canvas.width = oldWidth * ratio; + this.canvas.height = oldHeight * ratio; + + this.canvas.style.width = oldWidth + 'px'; + this.canvas.style.height = oldHeight + 'px'; + + this.setScaleAnchored( ratio, ratio, 0, 0 ); + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + this.SCREEN_RATIO= ratio; + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, this.width, this.height); + } + }, + + /** + * Set this director's bounds as well as its contained scenes. + * @param x {number} ignored, will be 0. + * @param y {number} ignored, will be 0. + * @param w {number} director width. + * @param h {number} director height. + * + * @return this + */ + setBounds:function (x, y, w, h) { + + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + + if ( this.canvas.width!==w ) { + this.canvas.width = w; + } + + if ( this.canvas.height!==h ) { + this.canvas.height = h; + } + + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + if (this.glEnabled) { + this.glReset(); + } + + return this; + }, + /** + * This method performs Director initialization. Must be called once. + * If the canvas parameter is not set, it will create a Canvas itself, + * and the developer must explicitly add the canvas to the desired DOM position. + * This method will also set the Canvas dimension to the specified values + * by width and height parameters. + * + * @param width {number} a canvas width + * @param height {number} a canvas height + * @param canvas {HTMLCanvasElement=} An optional Canvas object. + * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + * and want events delivered to the correct element. + * + * @return this + */ + initialize:function (width, height, canvas, proxy) { + if ( typeof canvas!=="undefined" ) { + if ( isString(canvas) ) { + canvas= document.getElementById(canvas); + } else if ( !(canvas instanceof HTMLCanvasElement ) ) { + console.log("Canvas is a: "+canvas+" ???"); + } + } + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + this.canvas = canvas; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.setBounds(0, 0, width, height); + this.enableEvents(proxy); + + this.timeline = new Date().getTime(); + + // transition scene + if (CAAT.CACHE_SCENE_ON_CHANGE) { + this.transitionScene = new CAAT.Foundation.Scene().setBounds(0, 0, width, height); + var transitionCanvas = document.createElement('canvas'); + transitionCanvas.width = width; + transitionCanvas.height = height; + var transitionImageActor = new CAAT.Foundation.Actor().setBackgroundImage(transitionCanvas); + this.transitionScene.ctx = transitionCanvas.getContext('2d'); + this.transitionScene.addChildImmediately(transitionImageActor); + this.transitionScene.setEaseListener(this); + } + + this.checkDebug(); + + return this; + }, + glReset:function () { + this.pMatrix = CAAT.WebGL.GLU.makeOrtho(0, this.referenceWidth, this.referenceHeight, 0, -1, 1); + this.gl.viewport(0, 0, this.canvas.width, this.canvas.height); + this.glColorProgram.setMatrixUniform(this.pMatrix); + this.glTextureProgram.setMatrixUniform(this.pMatrix); + this.gl.viewportWidth = this.canvas.width; + this.gl.viewportHeight = this.canvas.height; + }, + /** + * Experimental. + * Initialize a gl enabled director. + */ + initializeGL:function (width, height, canvas, proxy) { + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + canvas.width = width; + canvas.height = height; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.referenceWidth = width; + this.referenceHeight = height; + + var i; + + try { + this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); + this.gl.viewportWidth = width; + this.gl.viewportHeight = height; + CAAT.GLRENDER = true; + } catch (e) { + } + + if (this.gl) { + this.canvas = canvas; + this.setBounds(0, 0, width, height); + + this.enableEvents(canvas); + this.timeline = new Date().getTime(); + + this.glColorProgram = new CAAT.WebGL.ColorProgram(this.gl).create().initialize(); + this.glTextureProgram = new CAAT.WebGL.TextureProgram(this.gl).create().initialize(); + this.glTextureProgram.useProgram(); + this.glReset(); + + var maxTris = 512; + this.coords = new Float32Array(maxTris * 12); + this.uv = new Float32Array(maxTris * 8); + + this.gl.clearColor(0.0, 0.0, 0.0, 255); + + if (this.front_to_back) { + this.gl.clearDepth(1.0); + this.gl.enable(this.gl.DEPTH_TEST); + this.gl.depthFunc(this.gl.LESS); + } else { + this.gl.disable(this.gl.DEPTH_TEST); + } + + this.gl.enable(this.gl.BLEND); +// Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); + this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); + this.glEnabled = true; + + this.checkDebug(); + } else { + // fallback to non gl enabled canvas. + return this.initialize(width, height, canvas); + } + + return this; + }, + /** + * Creates an initializes a Scene object. + * @return {CAAT.Scene} + */ + createScene:function () { + var scene = new CAAT.Scene(); + this.addScene(scene); + return scene; + }, + setImagesCache:function (imagesCache, tpW, tpH) { + + if (!imagesCache || !imagesCache.length ) { + return this; + } + + var i; + + if (null !== this.glTextureManager) { + this.glTextureManager.deletePages(); + this.glTextureManager = null; + } + + // delete previous image identifiers + if (this.imagesCache) { + var ids = []; + for (i = 0; i < this.imagesCache.length; i++) { + ids.push(this.imagesCache[i].id); + } + + for (i = 0; i < ids.length; i++) { + delete this.imagesCache[ ids[i] ]; + } + } + + this.imagesCache = imagesCache; + + if (imagesCache) { + for (i = 0; i < imagesCache.length; i++) { + this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; + } + } + + this.tpW = tpW || 2048; + this.tpH = tpH || 2048; + + this.updateGLPages(); + + return this; + }, + updateGLPages:function () { + if (this.glEnabled) { + + this.glTextureManager = new CAAT.Module.TexturePacker.TexturePageManager(); + this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); + + this.currentTexturePage = this.glTextureManager.pages[0]; + this.glTextureProgram.setTexture(this.currentTexturePage.texture); + } + }, + setGLTexturePage:function (tp) { + this.currentTexturePage = tp; + this.glTextureProgram.setTexture(tp.texture); + return this; + }, + /** + * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this + * function will try to recreate the whole GL texture pages. + * If many handcrafted images are to be added to the director, some performance can be achieved by calling + * director.addImage(id,image,false) many times and a final call with + * director.addImage(id,image,true) to finally command the director to create texture pages. + * + * @param id {string|object} an identitifier to retrieve the image with + * @param image {Image|HTMLCanvasElement} image to add to cache + * @param noUpdateGL {!boolean} unless otherwise stated, the director will + * try to recreate the texture pages. + */ + addImage:function (id, image, noUpdateGL) { + if (this.getImage(id)) { +// for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === id) { + this.imagesCache[i].image = image; + break; + } + } + this.imagesCache[ id ] = image; + } else { + this.imagesCache.push({ id:id, image:image }); + this.imagesCache[id] = image; + } + + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + deleteImage:function (id, noUpdateGL) { + for (var i = 0; i < this.imagesCache.length; i++) { + if (this.imagesCache[i].id === id) { + delete this.imagesCache[id]; + this.imagesCache.splice(i, 1); + break; + } + } + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + setGLCurrentOpacity:function (opacity) { + this.currentOpacity = opacity; + this.glTextureProgram.setAlpha(opacity); + }, + /** + * Render buffered elements. + * @param vertex + * @param coordsIndex + * @param uv + */ + glRender:function (vertex, coordsIndex, uv) { + + vertex = vertex || this.coords; + uv = uv || this.uv; + coordsIndex = coordsIndex || this.coordsIndex; + + var gl = this.gl; + + var numTris = coordsIndex / 12 * 2; + var numVertices = coordsIndex / 3; + + this.glTextureProgram.updateVertexBuffer(vertex); + this.glTextureProgram.updateUVBuffer(uv); + + gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); + + }, + glFlush:function () { + if (this.coordsIndex !== 0) { + this.glRender(this.coords, this.coordsIndex, this.uv); + } + this.coordsIndex = 0; + this.uvIndex = 0; + + this.statistics.draws++; + }, + + findActorAtPosition:function (point) { + + // z-order + var cl = this.childrenList; + for (var i = cl.length - 1; i >= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Math.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + + /** + * + * Reset statistics information. + * + * @private + */ + resetStats:function () { + this.statistics.size_total = 0; + this.statistics.size_active = 0; + this.statistics.draws = 0; + this.statistics.size_discarded_by_dirty_rects = 0; + }, + + /** + * This is the entry point for the animation system of the Director. + * The director is fed with the elapsed time value to maintain a virtual timeline. + * This virtual timeline will provide each Scene with its own virtual timeline, and will only + * feed time when the Scene is the current Scene, or is being switched. + * + * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be + * set up as a single clip area. + * + * @param time {number} integer indicating the elapsed time between two consecutive frames of the + * Director. + */ + render:function (time) { + + if (this.currentScene && this.currentScene.isPaused()) { + return; + } + + this.time += time; + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + var tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + + this.animate(this, this.time); + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + /** + * draw director active scenes. + */ + var ne = this.childrenList.length; + var i, tt, c; + var ctx = this.ctx; + + if (this.glEnabled) { + + this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); + this.coordsIndex = 0; + this.uvIndex = 0; + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + c.paintActorGL(this, tt); + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + } + + } + } + + this.glFlush(); + + } else { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + ctx.save(); + if (this.dirtyRectsEnabled) { + this.modelViewMatrix.transformRenderingContext(ctx); + + if (!CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + ctx.clip(); + } else { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + } else if (this.clear === CAAT.Foundation.Director.CLEAR_ALL) { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + ctx.save(); + + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + if (!CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled) { + if (this.nDirtyRects) { + c.paintActor(this, tt); + } + } else { + c.paintActor(this, tt); + } + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + ctx.restore(); + + if (CAAT.DEBUGAABB) { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + this.modelViewMatrix.transformRenderingContextSet(ctx); + c.drawScreenBoundingBox(this, tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + } + + } + } + + if (this.nDirtyRects > 0 && (!navigator.isCocoonJS && CAAT.DEBUG) && CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + + ctx.clip(); + ctx.fillStyle = 'rgba(160,255,150,.4)'; + ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + ctx.restore(); + } + + this.frameCounter++; + }, + + inDirtyRect:function (actor) { + + if (!this.dirtyRectsEnabled || CAAT.DEBUG_DIRTYRECTS) { + return true; + } + + var dr = this.cDirtyRects; + var i; + var aabb = actor.AABB; + + for (i = 0; i < dr.length; i++) { + if (dr[i].intersects(aabb)) { + return true; + } + } + + this.statistics.size_discarded_by_dirty_rects += actor.size_total; + return false; + }, + + /** + * A director is a very special kind of actor. + * Its animation routine simple sets its modelViewMatrix in case some transformation's been + * applied. + * No behaviors are allowed for Director instances. + * @param director {CAAT.Director} redundant reference to CAAT.Director itself + * @param time {number} director time. + */ + animate:function (director, time) { + + this.timerManager.checkTimers(time); + + this.setModelViewMatrix(this); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.setScreenBounds(); + + this.dirty = false; + this.invalid = false; + this.dirtyRectsIndex = -1; + this.cDirtyRects= []; + + var cl = this.childrenList; + var cli; + var i, l; + + + if (this.dirtyRectsEnabled) { + var sdr = this.sDirtyRects; + if (sdr.length) { + for (i = 0, l = sdr.length; i < l; i++) { + this.addDirtyRect(sdr[i]); + } + this.sDirtyRects = []; + } + } + + for (i = 0; i < cl.length; i++) { + cli = cl[i]; + var tt = cli.time - cli.start_time; + cli.animate(this, tt); + } + + this.timerManager.removeExpiredTimers(); + + return this; + }, + + /** + * This method is used when asynchronous operations must produce some dirty rectangle painting. + * This means that every operation out of the regular CAAT loop must add dirty rect operations + * by calling this method. + * For example setVisible() and remove. + * @param rectangle + */ + scheduleDirtyRect:function (rectangle) { + this.sDirtyRects.push(rectangle); + }, + /** + * Add a rectangle to the list of dirty screen areas which should be redrawn. + * This is the opposite method to clear the whole screen and repaint everything again. + * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this + * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or + * even lowers performance under others, so it is a developer choice to activate them via a call to + * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). + * + * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping + * rectangles will be removed and intersecting ones will be unioned. + * + * Before calling this method, check if this.dirtyRectsEnabled is true. + * + * @param rectangle {CAAT.Rectangle} + */ + addDirtyRect:function (rectangle) { + + if (rectangle.isEmpty()) { + return; + } + + var i, dr, j, drj; + var cdr = this.cDirtyRects; + + for (i = 0; i < cdr.length; i++) { + dr = cdr[i]; + if (!dr.isEmpty() && dr.intersects(rectangle)) { + var intersected = true; + while (intersected) { + dr.unionRectangle(rectangle); + + for (j = 0; j < cdr.length; j++) { + if (j !== i) { + drj = cdr[j]; + if (!drj.isEmpty() && drj.intersects(dr)) { + dr.unionRectangle(drj); + drj.setEmpty(); + break; + } + } + } + + if (j == cdr.length) { + intersected = false; + } + } + + for (j = 0; j < cdr.length; j++) { + if (cdr[j].isEmpty()) { + cdr.splice(j, 1); + } + } + + return; + } + } + + this.dirtyRectsIndex++; + + if (this.dirtyRectsIndex >= this.dirtyRects.length) { + for (i = 0; i < 32; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + } + + var r = this.dirtyRects[ this.dirtyRectsIndex ]; + + r.x = rectangle.x; + r.y = rectangle.y; + r.x1 = rectangle.x1; + r.y1 = rectangle.y1; + r.width = rectangle.width; + r.height = rectangle.height; + + this.cDirtyRects.push(r); + + }, + /** + * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of + * another Scene (transitionScene). So instead of drawing two scenes while transitioning from + * one to another, first of all an scene is drawn to offscreen, and that image is translated. + *

    + * Until the creation of this method, both scenes where drawn while transitioning with + * its performance penalty since drawing two scenes could be twice as expensive than drawing + * only one. + *

    + * Though a high performance increase, we should keep an eye on memory consumption. + * + * @param ctx a canvas.getContext('2d') instnce. + * @param scene {CAAT.Foundation.Scene} the scene to draw offscreen. + */ + renderToContext:function (ctx, scene) { + /** + * draw actors on scene. + */ + if (scene.isInAnimationFrame(this.time)) { + ctx.setTransform(1, 0, 0, 1, 0, 0); + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + ctx.clearRect(0, 0, this.width, this.height); + + var octx = this.ctx; + + this.ctx = ctx; + ctx.save(); + + /** + * to draw an scene to an offscreen canvas, we have to: + * 1.- save diector's world model view matrix + * 2.- set no transformation on director since we want the offscreen to + * be drawn 1:1. + * 3.- set world dirty flag, so that the scene will recalculate its matrices + * 4.- animate the scene + * 5.- paint the scene + * 6.- restore world model view matrix. + */ + var matmv = this.modelViewMatrix; + var matwmv = this.worldModelViewMatrix; + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrix = this.worldModelViewMatrix; + this.wdirty = true; + scene.animate(this, scene.time); + if (scene.onRenderStart) { + scene.onRenderStart(scene.time); + } + scene.paintActor(this, scene.time); + if (scene.onRenderEnd) { + scene.onRenderEnd(scene.time); + } + this.worldModelViewMatrix = matwmv; + this.modelViewMatrix = matmv; + + ctx.restore(); + + this.ctx = octx; + } + }, + /** + * Add a new Scene to Director's Scene list. By adding a Scene to the Director + * does not mean it will be immediately visible, you should explicitly call either + *

      + *
    • easeIn + *
    • easeInOut + *
    • easeInOutRandom + *
    • setScene + *
    • or any of the scene switching methods + *
    + * + * @param scene {CAAT.Foundation.Scene} + */ + addScene:function (scene) { + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + }, + + /** + * Private + * Gets a contained Scene index on this Director. + * + * @param scene a CAAT.Foundation.Scene object instance. + * + * @return {number} + */ + findScene:function (scene) { + var sl = this.scenes; + var i; + var len = sl.length; + + for (i = 0; i < len; i++) { + if (sl[i] === scene) { + return i; + } + } + return -1; + }, + + /** + * Private + * Removes a scene from this director. + * + * @param scene a CAAT.Foundation.Scene object instance or scene index. + * + * @return {number} + */ + removeScene: function(scene) { + if (typeof scene == 'number') { + this.scenes.splice(scene, 1); + } else { + var idx = this.findScene(scene); + if (idx > 0) { + this.scenes.splice(idx, 1); + } + } + }, + /** + * Get the number of scenes contained in the Director. + * @return {number} the number of scenes contained in the Director. + */ + getNumScenes:function () { + return this.scenes.length; + }, + /** + * This method offers full control over the process of switching between any given two Scenes. + * To apply this method, you must specify the type of transition to apply for each Scene and + * the anchor to keep the Scene pinned at. + *

    + * The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype: + *

      + *
    • EASE_ROTATION + *
    • EASE_SCALE + *
    • EASE_TRANSLATION + *
    + * + *

    + * The anchor will be any of these values defined in CAAT.Foundation.Actor: + *

      + *
    • ANCHOR_CENTER + *
    • ANCHOR_TOP + *
    • ANCHOR_BOTTOM + *
    • ANCHOR_LEFT + *
    • ANCHOR_RIGHT + *
    • ANCHOR_TOP_LEFT + *
    • ANCHOR_TOP_RIGHT + *
    • ANCHOR_BOTTOM_LEFT + *
    • ANCHOR_BOTTOM_RIGHT + *
    + * + *

    + * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the + * point by which the scene will scaled. + * + * @param inSceneIndex integer indicating the Scene index to bring in to the Director. + * @param typein integer indicating the type of transition to apply to the bringing in Scene. + * @param anchorin integer indicating the anchor of the bringing in Scene. + * @param outSceneIndex integer indicating the Scene index to take away from the Director. + * @param typeout integer indicating the type of transition to apply to the taking away in Scene. + * @param anchorout integer indicating the anchor of the taking away Scene. + * @param time inteter indicating the time to perform the process of switchihg between Scene object + * in milliseconds. + * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to + * the scenes. + * @param interpolatorIn CAAT.Behavior.Interpolator object to apply to entering scene. + * @param interpolatorOut CAAT.Behavior.Interpolator object to apply to exiting scene. + */ + easeInOut:function (inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { + + if (inSceneIndex === this.getCurrentSceneIndex()) { + return; + } + + var ssin = this.scenes[ inSceneIndex ]; + var sout = this.scenes[ outSceneIndex ]; + + if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) { + this.renderToContext(this.transitionScene.ctx, sout); + sout = this.transitionScene; + } + + ssin.setExpired(false); + sout.setExpired(false); + + ssin.mouseEnabled = false; + sout.mouseEnabled = false; + + ssin.resetTransform(); + sout.resetTransform(); + + ssin.setLocation(0, 0); + sout.setLocation(0, 0); + + ssin.alpha = 1; + sout.alpha = 1; + + if (typein === CAAT.Foundation.Scene.EASE_ROTATION) { + ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); + } else if (typein === CAAT.Foundation.Scene.EASE_SCALE) { + ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); + } else { + ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); + } + + if (typeout === CAAT.Foundation.Scene.EASE_ROTATION) { + sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); + } else if (typeout === CAAT.Foundation.Scene.EASE_SCALE) { + sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); + } else { + sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); + } + + this.childrenList = []; + + sout.goOut(ssin); + ssin.getIn(sout); + + this.addChild(sout); + this.addChild(ssin); + }, + /** + * This method will switch between two given Scene indexes (ie, take away scene number 2, + * and bring in scene number 5). + *

    + * It will randomly choose for each Scene the type of transition to apply and the anchor + * point of each transition type. + *

    + * It will also set for different kind of transitions the following interpolators: + *

      + *
    • EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. + *
    • EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 + *
    • EASE_TRANSLATION -> BounceOutInterpolator + *
    + * + *

    + * These are the default values, and could not be changed by now. + * This method in final instance delegates the process to easeInOutMethod. + * + * @see easeInOutMethod. + * + * @param inIndex integer indicating the entering scene index. + * @param outIndex integer indicating the exiting scene index. + * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. + * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. + */ + easeInOutRandom:function (inIndex, outIndex, time, alpha) { + + var pin = Math.random(); + var pout = Math.random(); + + var typeIn; + var interpolatorIn; + + if (pin < 0.33) { + typeIn = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorIn = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pin < 0.66) { + typeIn = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorIn = new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4); + } else { + typeIn = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorIn = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + var typeOut; + var interpolatorOut; + + if (pout < 0.33) { + typeOut = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pout < 0.66) { + typeOut = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4); + } else { + typeOut = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorOut = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + this.easeInOut( + inIndex, + typeIn, + (Math.random() * 8.99) >> 0, + + outIndex, + typeOut, + (Math.random() * 8.99) >> 0, + + time, + alpha, + + interpolatorIn, + interpolatorOut); + + }, + /** + * This method changes Director's current Scene to the scene index indicated by + * inSceneIndex parameter. The Scene running in the director won't be eased out. + * + * @see {CAAT.Interpolator} + * @see {CAAT.Actor} + * @see {CAAT.Scene} + * + * @param inSceneIndex integer indicating the new Scene to set as current. + * @param type integer indicating the type of transition to apply to bring the new current + * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, + * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. + * @param time integer indicating how much time in milliseconds the Scene entrance will take. + * @param alpha boolean indicating whether alpha transparency fading will be applied to the + * entereing Scene. + * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of + * CAAT.Actor.prototype.ANCHOR_* values. + * @param interpolator an CAAT.Interpolator object indicating the interpolation function to + * apply. + */ + easeIn:function (inSceneIndex, type, time, alpha, anchor, interpolator) { + var sin = this.scenes[ inSceneIndex ]; + if (type === CAAT.Foundation.Scene.EASE_ROTATION) { + sin.easeRotationIn(time, alpha, anchor, interpolator); + } else if (type === CAAT.Foundation.Scene.EASE_SCALE) { + sin.easeScaleIn(0, time, alpha, anchor, interpolator); + } else { + sin.easeTranslationIn(time, alpha, anchor, interpolator); + } + this.childrenList = []; + this.addChild(sin); + + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + sin.mouseEnabled = false; + sin.setExpired(false); + }, + /** + * Changes (or sets) the current Director scene to the index + * parameter. There will be no transition on scene change. + * @param scene {number or scene object} an integer indicating the index of the target Scene or the target Scene itself + * to be shown. + */ + setScene:function (scene) { + var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene); + var sin = this.scenes[ sceneIndex ]; + this.childrenList = []; + this.addChild(sin); + this.currentScene = sin; + + sin.setExpired(false); + sin.mouseEnabled = true; + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + + sin.getIn(); + sin.activated(); + }, + /** + * This method will change the current Scene by the Scene indicated as parameter. + * It will apply random values for anchor and transition type. + * @see easeInOutRandom + * + * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. + * @param time {number} an integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToScene:function (iNewSceneIndex, time, alpha, transition) { + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (!transition) { + this.setScene(iNewSceneIndex); + } + else { + this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToPrevScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex - 1); + } + else { + this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToNextScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex + 1); + } + else { + this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); + } + }, + mouseEnter:function (mouseEvent) { + }, + mouseExit:function (mouseEvent) { + }, + mouseMove:function (mouseEvent) { + }, + mouseDown:function (mouseEvent) { + }, + mouseUp:function (mouseEvent) { + }, + mouseDrag:function (mouseEvent) { + }, + /** + * Scene easing listener. Notifies scenes when they're about to be activated (set as current + * director's scene). + * + * @param scene {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director. + * @param b_easeIn {boolean} scene enters or exits ? + */ + easeEnd:function (scene, b_easeIn) { + // scene is going out + if (!b_easeIn) { + + scene.setExpired(true); + } else { + this.currentScene = scene; + this.currentScene.activated(); + } + + scene.mouseEnabled = true; + scene.emptyBehaviorList(); + }, + /** + * Return the index for a given Scene object contained in the Director. + * @param scene {CAAT.Foundation.Scene} + */ + getSceneIndex:function (scene) { + for (var i = 0; i < this.scenes.length; i++) { + if (this.scenes[i] === scene) { + return i; + } + } + return -1; + }, + /** + * Get a concrete director's scene. + * @param index {number} an integer indicating the scene index. + * @return {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob. + */ + getScene:function (index) { + return this.scenes[index]; + }, + getSceneById : function(id) { + for( var i=0; iimagesCache + * where you can store a JSON of the form + * [ { id: imageId, image: imageObject } ]. + * This structure will be used as a resources cache. + * There's a CAAT.Module.ImagePreloader class to preload resources and + * generate this structure on loading finalization. + * + * @param sId {object} an String identifying a resource. + */ + getImage:function (sId) { + var ret = this.imagesCache[sId]; + if (ret) { + return ret; + } + + //for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === sId) { + return this.imagesCache[i].image; + } + } + + return null; + }, + musicPlay: function(id) { + return this.audioManager.playMusic(id); + }, + musicStop : function() { + this.audioManager.stopMusic(); + }, + /** + * Adds an audio to the cache. + * + * @see CAAT.Module.Audio.AudioManager.addAudio + * @return this + */ + addAudio:function (id, url) { + this.audioManager.addAudio(id, url); + return this; + }, + /** + * Plays the audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + */ + audioPlay:function (id) { + return this.audioManager.play(id); + }, + /** + * Loops an audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + * + * @return {HTMLElement|null} the value from audioManager.loop + */ + audioLoop:function (id) { + return this.audioManager.loop(id); + }, + endSound:function () { + return this.audioManager.endSound(); + }, + setSoundEffectsEnabled:function (enabled) { + return this.audioManager.setSoundEffectsEnabled(enabled); + }, + setMusicEnabled:function (enabled) { + return this.audioManager.setMusicEnabled(enabled); + }, + isMusicEnabled:function () { + return this.audioManager.isMusicEnabled(); + }, + isSoundEffectsEnabled:function () { + return this.audioManager.isSoundEffectsEnabled(); + }, + setVolume:function (id, volume) { + return this.audioManager.setVolume(id, volume); + }, + /** + * Removes Director's scenes. + */ + emptyScenes:function () { + this.scenes = []; + }, + /** + * Adds an scene to this Director. + * @param scene {CAAT.Foundation.Scene} a scene object. + */ + addChild:function (scene) { + scene.parent = this; + this.childrenList.push(scene); + }, + /** + * @Deprecated use CAAT.loop instead. + * @param fps + * @param callback + * @param callback2 + */ + loop:function (fps, callback, callback2) { + if (callback2) { + this.onRenderStart = callback; + this.onRenderEnd = callback2; + } else if (callback) { + this.onRenderEnd = callback; + } + CAAT.loop(); + }, + /** + * Starts the director animation.If no scene is explicitly selected, the current Scene will + * be the first scene added to the Director. + *

    + * The fps parameter will set the animation quality. Higher values, + * means CAAT will try to render more frames in the same second (at the + * expense of cpu power at least until hardware accelerated canvas rendering + * context are available). A value of 60 is a high frame rate and should not be exceeded. + * + */ + renderFrame:function () { + + CAAT.currentDirector = this; + + if (this.stopped) { + return; + } + + var t = new Date().getTime(), + delta = t - this.timeline; + + /* + check for massive frame time. if for example the current browser tab is minified or taken out of + foreground, the system will account for a bit time interval. minify that impact by lowering down + the elapsed time (virtual timelines FTW) + */ + if (delta > 500) { + delta = 500; + } + + if (this.onRenderStart) { + this.onRenderStart(delta); + } + + this.render(delta); + + if (this.debugInfo) { + this.debugInfo(this.statistics); + } + + this.timeline = t; + + if (this.onRenderEnd) { + this.onRenderEnd(delta); + } + + this.needsRepaint = false; + }, + + /** + * If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement. + */ + resetTimeline:function () { + this.timeline = new Date().getTime(); + }, + + endLoop:function () { + }, + /** + * This method states whether the director must clear background before rendering + * each frame. + * + * The clearing method could be: + * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. + * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled + * will have their areas redrawn. + * + CAAT.Director.CLEAR_NONE. clears nothing. + * + * @param clear {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} + * @return this. + */ + setClear:function (clear) { + this.clear = clear; + if (this.clear === CAAT.Foundation.Director.CLEAR_DIRTY_RECTS) { + this.dirtyRectsEnabled = true; + } else { + this.dirtyRectsEnabled= false; + } + return this; + }, + /** + * Get this Director's AudioManager instance. + * @return {CAAT.AudioManager} the AudioManager instance. + */ + getAudioManager:function () { + return this.audioManager; + }, + /** + * Acculumate dom elements position to properly offset on-screen mouse/touch events. + * @param node + */ + cumulateOffset:function (node, parent, prop) { + var left = prop + 'Left'; + var top = prop + 'Top'; + var x = 0, y = 0, style; + + while (navigator.browser !== 'iOS' && node && node.style) { + if (node.currentStyle) { + style = node.currentStyle['position']; + } else { + style = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); + style = style ? style.getPropertyValue('position') : null; + } + +// if (!/^(relative|absolute|fixed)$/.test(style)) { + if (!/^(fixed)$/.test(style)) { + x += node[left]; + y += node[top]; + node = node[parent]; + } else { + break; + } + } + + return { + x:x, + y:y, + style:style + }; + }, + getOffset:function (node) { + var res = this.cumulateOffset(node, 'offsetParent', 'offset'); + if (res.style === 'fixed') { + var res2 = this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); + return { + x:res.x + res2.x, + y:res.y + res2.y + }; + } + + return { + x:res.x, + y:res.y + }; + }, + /** + * Normalize input event coordinates to be related to (0,0) canvas position. + * @param point {CAAT.Math.Point} canvas coordinate. + * @param e {MouseEvent} a mouse event from an input event. + */ + getCanvasCoord:function (point, e) { + + var pt = new CAAT.Math.Point(); + var posx = 0; + var posy = 0; + if (!e) e = window.event; + + if (e.pageX || e.pageY) { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) { + posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + + var offset = this.getOffset(this.canvas); + + posx -= offset.x; + posy -= offset.y; + + posx*= this.SCREEN_RATIO; + posy*= this.SCREEN_RATIO; + + ////////////// + // transformar coordenada inversamente con affine transform de director. + + pt.x = posx; + pt.y = posy; + if (!this.modelViewMatrixI) { + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + } + this.modelViewMatrixI.transformCoord(pt); + posx = pt.x; + posy = pt.y + + point.set(posx, posy); + this.screenMousePoint.set(posx, posy); + + }, + + __mouseDownHandler:function (e) { + + /* + was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no + button was presses. Then, send a mouseUp for the previos actor, and return; + */ + if (this.dragging && this.lastSelectedActor) { + this.__mouseUpHandler(e); + return; + } + + this.getCanvasCoord(this.mousePoint, e); + this.isMouseDown = true; + var lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + var pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseDown( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y))); + } + + this.lastSelectedActor = lactor; + }, + + __mouseUpHandler:function (e) { + + this.isMouseDown = false; + this.getCanvasCoord(this.mousePoint, e); + + var pos = null; + var lactor = this.lastSelectedActor; + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + if (lactor.actionPerformed && lactor.contains(pos.x, pos.y)) { + lactor.actionPerformed(e) + } + + lactor.mouseUp( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + + if (!this.dragging && null !== lactor) { + if (lactor.contains(pos.x, pos.y)) { + lactor.mouseClick( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + } + + this.dragging = false; + this.in_ = false; +// CAAT.setCursor('default'); + }, + + __mouseMoveHandler:function (e) { + //this.getCanvasCoord(this.mousePoint, e); + + var lactor; + var pos; + + var ct = this.currentScene ? this.currentScene.time : 0; + + // drag + + if (this.isMouseDown && null!==this.lastSelectedActor) { + + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + // check for mouse move threshold. + if (!this.dragging) { + if (Math.abs(this.prevMousePoint.x - pos.x) < CAAT.DRAG_THRESHOLD_X && + Math.abs(this.prevMousePoint.y - pos.y) < CAAT.DRAG_THRESHOLD_Y) { + return; + } + } + + this.dragging = true; + + var px = lactor.x; + var py = lactor.y; + lactor.mouseDrag( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y), + ct)); + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + /** + * Element has not moved after drag, so treat it as a button. + */ + if (px === lactor.x && py === lactor.y) { + + var contains = lactor.contains(pos.x, pos.y); + + if (this.in_ && !contains) { + lactor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = false; + } + + if (!this.in_ && contains) { + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = true; + } + } + + return; + } + + // mouse move. + this.in_ = true; + + lactor = this.findActorAtPosition(this.mousePoint); + + // cambiamos de actor. + if (lactor !== this.lastSelectedActor) { + if (null !== this.lastSelectedActor) { + + pos = this.lastSelectedActor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + this.lastSelectedActor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + ct)); + } + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + } + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + if (null !== lactor) { + + lactor.mouseMove( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + this.lastSelectedActor = lactor; + }, + + __mouseOutHandler:function (e) { + + if (this.dragging) { + return; + } + + if (null !== this.lastSelectedActor) { + + this.getCanvasCoord(this.mousePoint, e); + var pos = new CAAT.Math.Point(this.mousePoint.x, this.mousePoint.y, 0); + this.lastSelectedActor.viewToModel(pos); + + var ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time); + + this.lastSelectedActor.mouseExit(ev); + this.lastSelectedActor.mouseOut(ev); + if (!this.dragging) { + this.lastSelectedActor = null; + } + } else { + this.isMouseDown = false; + this.in_ = false; + + } + + }, + + __mouseOverHandler:function (e) { + + if (this.dragging) { + return; + } + + var lactor; + var pos, ev; + + if (null == this.lastSelectedActor) { + lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene ? this.currentScene.time : 0); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + } + + this.lastSelectedActor = lactor; + } else { + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + + } + }, + + __mouseDBLClickHandler:function (e) { + + this.getCanvasCoord(this.mousePoint, e); + if (null !== this.lastSelectedActor) { + /* + var pos = this.lastSelectedActor.viewToModel( + new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + */ + this.lastSelectedActor.mouseDblClick( + new CAAT.Event.MouseEvent().init( + this.mousePoint.x, + this.mousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + /** + * Same as mouseDown but not preventing event. + * Will only take care of first touch. + * @param e + */ + __touchStartHandler:function (e) { + + if (e.target === this.canvas) { + e.preventDefault(); + e.returnValue = false; + + e = e.targetTouches[0]; + + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + return; + } + + this.touching = true; + + this.__mouseDownHandler(e); + } + }, + + __touchEndHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + e = e.changedTouches[0]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + + this.touching = false; + + this.__mouseUpHandler(e); + } + }, + + __touchMoveHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + if (this.gesturing) { + return; + } + + for (var i = 0; i < e.targetTouches.length; i++) { + var ee = e.targetTouches[i]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, ee); + this.__mouseMoveHandler(ee); + } + } + }, + + __gestureStart:function (scale, rotation) { + this.gesturing = true; + this.__gestureRotation = this.lastSelectedActor.rotationAngle; + this.__gestureSX = this.lastSelectedActor.scaleX - 1; + this.__gestureSY = this.lastSelectedActor.scaleY - 1; + }, + + __gestureChange:function (scale, rotation) { + if (typeof scale === 'undefined' || typeof rotation === 'undefined') { + return; + } + + if (this.lastSelectedActor !== null && this.lastSelectedActor.isGestureEnabled()) { + this.lastSelectedActor.setRotation(rotation * Math.PI / 180 + this.__gestureRotation); + + this.lastSelectedActor.setScale( + this.__gestureSX + scale, + this.__gestureSY + scale); + } + + }, + + __gestureEnd:function (scale, rotation) { + this.gesturing = false; + this.__gestureRotation = 0; + this.__gestureScale = 0; + }, + + __touchEndHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i, j; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var _touch = e.changedTouches[i]; + var id = _touch.identifier; + recent.push(id); + } + + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + if (this.touches[ touchId ]) { + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addChangedTouch(this.touches[ touchId ].touch); + } + } + + /** + * remove ended touch info. + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + delete this.touches[id]; + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchEnd(touch); + } + }, + + __touchMoveHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + + if (this.touches[ id ]) { + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + + var actor = this.touches[ id ].actor; + mp = actor.viewToModel(mp); + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchMove(touch); + } + }, + + __touchCancelHandleMT:function (e) { + this.__touchEndHandlerMT(e); + }, + + __touchStartHandlerMT:function (e) { + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + var allInCanvas = true; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + allInCanvas = false; + continue; + } + + var actor = this.findActorAtPosition(mp); + if (actor !== null) { + mp = actor.viewToModel(mp); + + if (!this.touches[ id ]) { + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchStart(touch); + } + + }, + + __findTouchFirstActor:function () { + + var t = Number.MAX_VALUE; + var actor = null; + for (var pr in this.touches) { + + var touch = this.touches[pr]; + + if (touch.touch.time && touch.touch.time < t && touch.actor.isGestureEnabled()) { + actor = touch.actor; + t = touch.touch.time; + } + } + return actor; + }, + + __gesturedActor:null, + __touchGestureStartHandleMT:function (e) { + var actor = this.__findTouchFirstActor(); + + if (actor !== null && actor.isGestureEnabled()) { + this.__gesturedActor = actor; + this.__gestureRotation = actor.rotationAngle; + this.__gestureSX = actor.scaleX - 1; + this.__gestureSY = actor.scaleY - 1; + + + actor.gestureStart( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + }, + + __touchGestureEndHandleMT:function (e) { + + if (null !== this.__gesturedActor && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureEnd( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + + this.__gestureRotation = 0; + this.__gestureScale = 0; + + + }, + + __touchGestureChangeHandleMT:function (e) { + + if (this.__gesturedActor !== null && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureChange( + e.rotation * Math.PI / 180, + this.__gestureSX + e.scale, + this.__gestureSY + e.scale); + } + }, + + + addHandlers:function (canvas) { + + var me = this; + + window.addEventListener('mouseup', function (e) { + if (me.touching) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseUpHandler(e); + + me.touching = false; + } + }, false); + + window.addEventListener('mousedown', function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + me.touching = true; + + me.__mouseDownHandler(e); + } + }, false); + + window.addEventListener('mouseover', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseOverHandler(e); + } + }, false); + + window.addEventListener('mouseout', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseOutHandler(e); + } + }, false); + + window.addEventListener('mousemove', function (e) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (!me.dragging && ( mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height )) { + return; + } + me.__mouseMoveHandler(e); + }, false); + + window.addEventListener("dblclick", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseDBLClickHandler(e); + } + }, false); + + if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MOUSE) { + canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); + canvas.addEventListener("gesturestart", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureStart(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gestureend", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureEnd(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gesturechange", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureChange(e.scale, e.rotation); + } + }, false); + } else if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MULTITOUCH) { + canvas.addEventListener("touchstart", this.__touchStartHandlerMT.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandlerMT.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandlerMT.bind(this), false); + canvas.addEventListener("touchcancel", this.__touchCancelHandleMT.bind(this), false); + + canvas.addEventListener("gesturestart", this.__touchGestureStartHandleMT.bind(this), false); + canvas.addEventListener("gestureend", this.__touchGestureEndHandleMT.bind(this), false); + canvas.addEventListener("gesturechange", this.__touchGestureChangeHandleMT.bind(this), false); + } + + }, + + enableEvents:function (onElement) { + CAAT.RegisterDirector(this); + this.in_ = false; + this.createEventHandler(onElement); + }, + + createEventHandler:function (onElement) { + //var canvas= this.canvas; + this.in_ = false; + //this.addHandlers(canvas); + this.addHandlers(onElement); + } + } + }, + + onCreate:function () { + + if (typeof CAAT.__CSS__!=="undefined") { + + CAAT.Foundation.Director.prototype.clip = true; + CAAT.Foundation.Director.prototype.glEnabled = false; + + CAAT.Foundation.Director.prototype.getRenderType = function () { + return 'CSS'; + }; + + CAAT.Foundation.Director.prototype.setScaleProportional = function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + this.setScaleAnchored(factor, factor, 0, 0); + + this.eventHandler.style.width = '' + this.referenceWidth + 'px'; + this.eventHandler.style.height = '' + this.referenceHeight + 'px'; + }; + + CAAT.Foundation.Director.prototype.setBounds = function (x, y, w, h) { + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, w, h); + } + this.eventHandler.style.width = w + 'px'; + this.eventHandler.style.height = h + 'px'; + + return this; + }; + + /** + * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most + * div in the document hierarchy (z-index 999999). + * @param width + * @param height + * @param domElement + * @param proxy + */ + CAAT.Foundation.Director.prototype.initialize = function (width, height, domElement, proxy) { + + this.timeline = new Date().getTime(); + this.domElement = domElement; + this.style('position', 'absolute'); + this.style('width', '' + width + 'px'); + this.style('height', '' + height + 'px'); + this.style('overflow', 'hidden'); + + this.enableEvents(domElement); + + this.setBounds(0, 0, width, height); + + this.checkDebug(); + return this; + }; + + CAAT.Foundation.Director.prototype.render = function (time) { + + this.time += time; + this.animate(this, time); + + /** + * draw director active scenes. + */ + var i, l, tt; + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + c.paintActor(this, tt); + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_discarded_by_dirtyRects += this.drDiscarded; + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + + } + + } + } + + this.frameCounter++; + }; + + CAAT.Foundation.Director.prototype.addScene = function (scene) { + scene.setVisible(true); + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + + this.domElement.appendChild(scene.domElement); + }; + + CAAT.Foundation.Director.prototype.emptyScenes = function () { + this.scenes = []; + this.domElement.innerHTML = ''; + this.createEventHandler(); + }; + + CAAT.Foundation.Director.prototype.setClear = function (clear) { + return this; + }; + + CAAT.Foundation.Director.prototype.createEventHandler = function () { + this.eventHandler = document.createElement('div'); + this.domElement.appendChild(this.eventHandler); + + this.eventHandler.style.position = 'absolute'; + this.eventHandler.style.left = '0'; + this.eventHandler.style.top = '0'; + this.eventHandler.style.zIndex = 999999; + this.eventHandler.style.width = '' + this.width + 'px'; + this.eventHandler.style.height = '' + this.height + 'px'; + + this.canvas = this.eventHandler; + this.in_ = false; + + this.addHandlers(this.canvas); + }; + + CAAT.Foundation.Director.prototype.inDirtyRect = function () { + return true; + } + } + } +}); +/** + * See LICENSE file. + * + * In this file we'll be adding every useful Actor that is specific for certain purpose. + * + * + CAAT.Dock: a docking container that zooms in/out its actors. + * + */ + +CAAT.Module( { + + /** + * @name UI + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name Dock + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.Dock", + aliases : ["CAAT.Dock"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer", + "CAAT.Behavior.GenericBehavior" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Dock + */ + + /** + * @const + */ + OP_LAYOUT_BOTTOM: 0, + /** + * @const + */ + OP_LAYOUT_TOP: 1, + /** + * @const + */ + OP_LAYOUT_LEFT: 2, + /** + * @const + */ + OP_LAYOUT_RIGHT: 3 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Dock.prototype + */ + + /** + * scene the actor is in. + */ + scene: null, + + /** + * resetting dimension timer task. + */ + ttask: null, + + /** + * min contained actor size. + */ + minSize: 0, + + /** + * max contained actor size + */ + maxSize: 0, + + /** + * aproximated number of elements affected. + */ + range: 2, + + /** + * Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_* + */ + layoutOp: 0, + + initialize : function(scene) { + this.scene= scene; + return this; + }, + /** + * Set the number of elements that will be affected (zoomed) when the mouse is inside the component. + * @param range {number} a number. Defaults to 2. + */ + setApplicationRange : function( range ) { + this.range= range; + return this; + }, + /** + * Set layout orientation. Choose from + *

      + *
    • CAAT.Dock.OP_LAYOUT_BOTTOM + *
    • CAAT.Dock.OP_LAYOUT_TOP + *
    • CAAT.Dock.OP_LAYOUT_BOTTOM + *
    • CAAT.Dock.OP_LAYOUT_RIGHT + *
    + * By default, the layou operation is OP_LAYOUT_BOTTOM, that is, elements zoom bottom anchored. + * + * @param lo {number} one of CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_TOP, + * CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_RIGHT. + * + * @return this + */ + setLayoutOp : function( lo ) { + this.layoutOp= lo; + return this; + }, + /** + * + * Set maximum and minimum size of docked elements. By default, every contained actor will be + * of 'min' size, and will be scaled up to 'max' size. + * + * @param min {number} + * @param max {number} + * @return this + */ + setSizes : function( min, max ) { + this.minSize= min; + this.maxSize= max; + + for( var i=0; isetLayoutOp. + * + * @private + */ + layout : function() { + var i,actor; + + var c= CAAT.Foundation.UI.Dock; + + if ( this.layoutOp===c.OP_LAYOUT_BOTTOM || this.layoutOp===c.OP_LAYOUT_TOP ) { + + var currentWidth=0, currentX=0; + + for( i=0; i index + this.range) { + wwidth = this.minSize; + } else if (i === index) { + wwidth = this.maxSize; + } else if (i < index) { + wwidth= + this.minSize + + (this.maxSize-this.minSize) * + (Math.cos((i - index - across + 1) / this.range * Math.PI) + 1) / + 2; + } else { + wwidth= + this.minSize + + (this.maxSize-this.minSize)* + (Math.cos( (i - index - across) / this.range * Math.PI) + 1) / + 2; + } + + actor.height= wwidth; + actor.width= wwidth; + } + + this.layout(); + }, + /** + * Perform the process of exiting the docking element, that is, animate elements to the minimum + * size. + * + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseExit : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + } + + var me= this; + this.ttask= this.scene.createTimer( + this.scene.time, + 100, + function timeout(sceneTime, time, timerTask) { + me.actorNotPointed(); + }, + null, + null); + }, + /** + * Perform the beginning of docking elements. + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseEnter : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + this.ttask= null; + } + }, + /** + * Adds an actor to Dock. + *

    + * Be aware that actor mouse functions must be set prior to calling this method. The Dock actor + * needs set his own actor input events functions for mouseEnter, mouseExit and mouseMove and + * will then chain to the original methods set by the developer. + * + * @param actor {CAAT.Actor} a CAAT.Actor instance. + * + * @return this + */ + addChild : function(actor) { + var me= this; + + actor.__Dock_mouseEnter= actor.mouseEnter; + actor.__Dock_mouseExit= actor.mouseExit; + actor.__Dock_mouseMove= actor.mouseMove; + + /** + * @ignore + * @param mouseEvent + */ + actor.mouseEnter= function(mouseEvent) { + me.actorMouseEnter(mouseEvent); + this.__Dock_mouseEnter(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseExit= function(mouseEvent) { + me.actorMouseExit(mouseEvent); + this.__Dock_mouseExit(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseMove= function(mouseEvent) { + me.actorPointed( mouseEvent.point.x, mouseEvent.point.y, mouseEvent.source ); + this.__Dock_mouseMove(mouseEvent); + }; + + actor.width= this.minSize; + actor.height= this.minSize; + + return CAAT.Foundation.UI.Dock.superclass.addChild.call(this,actor); + } + } + +}); +/** + * See LICENSE file. + * + **/ + +CAAT.Module( { + + /** + * @name InterpolatorActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.InterpolatorActor", + aliases : ["CAAT.InterpolatorActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.InterpolatorActor.prototype + */ + + /** + * The interpolator instance to draw. + * @type {CAAT.Behavior.Interpolator} + */ + interpolator: null, + + /** + * This interpolator´s contour. + * @type {Array.} + */ + contour: null, // interpolator contour cache + + /** + * Number of samples to calculate a contour. + */ + S: 50, // contour samples. + + /** + * padding when drawing the interpolator. + */ + gap: 5, // border size in pixels. + + /** + * Sets a padding border size. By default is 5 pixels. + * @param gap {number} border size in pixels. + * @return this + */ + setGap : function( gap ) { + this.gap= gap; + return this; + }, + /** + * Sets the CAAT.Interpolator instance to draw. + * + * @param interpolator a CAAT.Interpolator instance. + * @param size an integer indicating the number of polyline segments so draw to show the CAAT.Interpolator + * instance. + * + * @return this + */ + setInterpolator : function( interpolator, size ) { + this.interpolator= interpolator; + this.contour= interpolator.getContour(size || this.S); + + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Director} + * @param time {number} scene time. + */ + paint : function( director, time ) { + + CAAT.InterpolatorActor.superclass.paint.call(this,director,time); + + if ( this.backgroundImage ) { + return this; + } + + if ( this.interpolator ) { + + var canvas= director.ctx; + + var xs= (this.width-2*this.gap); + var ys= (this.height-2*this.gap); + + canvas.beginPath(); + canvas.moveTo( + this.gap + xs*this.contour[0].x, + -this.gap + this.height - ys*this.contour[0].y); + + for( var i=1; i>0)+1)*ts; + }, + + setFillStyle : function( style ) { + this.fill= style; + }, + + setStrokeStyle : function( style ) { + this.stroke= style; + }, + + setStrokeSize : function( size ) { + this.strokeSize= size; + }, + + setAlignment : function( alignment ) { + this.alignment= alignment; + }, + + setFontSize : function( size ) { + if ( size!==this.fontSize ) { + this.fontSize= size; + this.__setFont(); + } + } + }; + + /** + * This class keeps track of styles, images, and the current applied style. + */ + var renderContext= function() { + this.text= ""; + return this; + }; + + renderContext.prototype= { + + x : 0, + y : 0, + width : 0, + text : null, + + crcs : null, // current rendering context style + rcs : null, // rendering content styles stack + + styles : null, + images : null, + + lines : null, + + documentHeight : 0, + + anchorStack : null, + + __nextLine : function() { + this.x= 0; + this.currentLine= new DocumentLine( + CAAT.Module.Font.Font.getFontMetrics( this.crcs.sfont) ); + this.lines.push( this.currentLine ); + }, + + /** + * + * @param image {CAAT.SpriteImage} + * @param r {number=} + * @param c {number=} + * @private + */ + __image : function( image, r, c ) { + + + var image_width; + + if ( typeof r!=="undefined" && typeof c!=="undefined" ) { + image_width= image.getWidth(); + } else { + image_width= ( image instanceof CAAT.Foundation.SpriteImage ) ? image.getWidth() : image.getWrappedImageWidth(); + } + + // la imagen cabe en este sitio. + if ( this.width ) { + if ( image_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + this.currentLine.addElementImage( new DocumentElementImage( + this.x, + image, + r, + c, + this.crcs.clone(), + this.__getCurrentAnchor() ) ); + + this.x+= image_width; + }, + + __text : function() { + + if ( this.text.length===0 ) { + return; + } + + var text_width= this.ctx.measureText(this.text).width; + + // la palabra cabe en este sitio. + if ( this.width ) { + if ( text_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + //this.crcs.text( this.text, this.x, this.y ); + this.currentLine.addElement( new DocumentElementText( + this.text, + this.x, + text_width, + 0, //this.crcs.__getProperty("fontSize"), calculated later + this.crcs.clone(), + this.__getCurrentAnchor() ) ) ; + + this.x+= text_width; + + this.text=""; + }, + + fchar : function( _char ) { + + if ( _char===' ' ) { + + this.__text(); + + this.x+= this.ctx.measureText(_char).width; + if ( this.width ) { + if ( this.x > this.width ) { + this.__nextLine(); + } + } + } else { + this.text+= _char; + } + }, + + end : function() { + if ( this.text.length>0 ) { + this.__text(); + } + + var y=0; + var lastLineEstimatedDescent= 0; + for( var i=0; i>0; + } + + this.lines[i].setY(y); + } + + this.documentHeight= y + lastLineEstimatedDescent; + }, + + getDocumentHeight : function() { + return this.documentHeight; + }, + + __getCurrentAnchor : function() { + if ( this.anchorStack.length ) { + return this.anchorStack[ this.anchorStack.length-1 ]; + } + + return null; + }, + + __resetAppliedStyles : function() { + this.rcs= []; + this.__pushDefaultStyles(); + }, + + __pushDefaultStyles : function() { + this.crcs= new renderContextStyle(this.ctx).setDefault( this.styles["default"] ); + this.rcs.push( this.crcs ); + }, + + __pushStyle : function( style ) { + var pcrcs= this.crcs; + this.crcs= new renderContextStyle(this.ctx); + this.crcs.chain= pcrcs; + this.crcs.setStyle( style ); + this.crcs.applyStyle( ); + + this.rcs.push( this.crcs ); + }, + + __popStyle : function() { + // make sure you don't remove default style. + if ( this.rcs.length>1 ) { + this.rcs.pop(); + this.crcs= this.rcs[ this.rcs.length-1 ]; + this.crcs.applyStyle(); + } + }, + + __popAnchor : function() { + if ( this.anchorStack.length> 0 ) { + this.anchorStack.pop(); + } + }, + + __pushAnchor : function( anchor ) { + this.anchorStack.push( anchor ); + }, + + start : function( ctx, styles, images, width ) { + this.x=0; + this.y=0; + this.width= typeof width!=="undefined" ? width : 0; + this.ctx= ctx; + this.lines= []; + this.styles= styles; + this.images= images; + this.anchorStack= []; + + this.__resetAppliedStyles(); + this.__nextLine(); + + }, + + setTag : function( tag ) { + + var pairs, style; + + this.__text(); + + tag= tag.toLowerCase(); + if ( tag==='b' ) { + this.crcs.setBold( true ); + } else if ( tag==='/b' ) { + this.crcs.setBold( false ); + } else if ( tag==='i' ) { + this.crcs.setItalic( true ); + } else if ( tag==='/i' ) { + this.crcs.setItalic( false ); + } else if ( tag==='stroked' ) { + this.crcs.setStroked( true ); + } else if ( tag==='/stroked' ) { + this.crcs.setStroked( false ); + } else if ( tag==='filled' ) { + this.crcs.setFilled( true ); + } else if ( tag==='/filled' ) { + this.crcs.setFilled( false ); + } else if ( tag==='tab' ) { + this.x= this.crcs.getTabPos( this.x ); + } else if ( tag==='br' ) { + this.__nextLine(); + } else if ( tag==='/a' ) { + this.__popAnchor(); + } else if ( tag==='/style' ) { + if ( this.rcs.length>1 ) { + this.__popStyle(); + } else { + /** + * underflow pop de estilos. eres un cachondo. + */ + } + } else { + if ( tag.indexOf("fillcolor")===0 ) { + pairs= tag.split("="); + this.crcs.setFillStyle( pairs[1] ); + } else if ( tag.indexOf("strokecolor")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeStyle( pairs[1] ); + } else if ( tag.indexOf("strokesize")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeSize( pairs[1]|0 ); + } else if ( tag.indexOf("fontsize")===0 ) { + pairs= tag.split("="); + this.crcs.setFontSize( pairs[1]|0 ); + } else if ( tag.indexOf("style")===0 ) { + pairs= tag.split("="); + style= this.styles[ pairs[1] ]; + if ( style ) { + this.__pushStyle( style ); + } + } else if ( tag.indexOf("image")===0) { + pairs= tag.split("=")[1].split(","); + var image= pairs[0]; + if ( this.images[image] ) { + var r= 0, c=0; + if ( pairs.length>=3 ) { + r= pairs[1]|0; + c= pairs[2]|0; + } + this.__image( this.images[image], r, c ); + } else if (CAAT.currentDirector.getImage(image) ) { + this.__image( CAAT.currentDirector.getImage(image) ); + } + } else if ( tag.indexOf("a=")===0 ) { + pairs= tag.split("="); + this.__pushAnchor( pairs[1] ); + } + } + } + }; + + /** + * Abstract document element. + * The document contains a collection of DocumentElementText and DocumentElementImage. + * @param anchor + * @param style + */ + var DocumentElement= function( anchor, style ) { + this.link= anchor; + this.style= style; + return this; + }; + + DocumentElement.prototype= { + x : null, + y : null, + width : null, + height : null, + + style : null, + + link : null, + + isLink : function() { + return this.link; + }, + + setLink : function( link ) { + this.link= link; + return this; + }, + + getLink : function() { + return this.link; + }, + + contains : function(x,y) { + return false; + } + + }; + + /** + * This class represents an image in the document. + * @param x + * @param image + * @param r + * @param c + * @param style + * @param anchor + */ + var DocumentElementImage= function( x, image, r, c, style, anchor ) { + + DocumentElementImage.superclass.constructor.call(this, anchor, style); + + this.x= x; + this.image= image; + this.row= r; + this.column= c; + this.width= image.getWidth(); + this.height= image.getHeight(); + + if ( this.image instanceof CAAT.SpriteImage || this.image instanceof CAAT.Foundation.SpriteImage ) { + + if ( typeof r==="undefined" || typeof c==="undefined" ) { + this.spriteIndex= 0; + } else { + this.spriteIndex= r*image.columns+c; + } + this.paint= this.paintSI; + } + + return this; + }; + + DocumentElementImage.prototype= { + image : null, + row : null, + column : null, + spriteIndex : null, + + paint : function( ctx ) { + this.style.image( ctx ); + ctx.drawImage( this.image, this.x, -this.height+1); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + paintSI : function( ctx ) { + this.style.image( ctx ); + this.image.setSpriteIndex( this.spriteIndex ); + this.image.paint( { ctx: ctx }, 0, this.x, -this.height+1 ); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + getHeight : function() { + return this.image instanceof CAAT.Foundation.SpriteImage ? this.image.getHeight() : this.image.height; + }, + + getFontMetrics : function() { + return null; + }, + + contains : function(x,y) { + return x>=this.x && x<=this.x+this.width && y>=this.y && y= this.x && x<=this.x+this.width && + y>= this.y && y<= this.y+this.height; + }, + + setYPosition : function( baseline ) { + this.bl= baseline; + this.y= baseline - this.fm.ascent; + } + }; + + extend( DocumentElementImage, DocumentElement ); + extend( DocumentElementText, DocumentElement ); + + /** + * This class represents a document line. + * It contains a collection of DocumentElement objects. + */ + var DocumentLine= function( defaultFontMetrics ) { + this.elements= []; + this.defaultFontMetrics= defaultFontMetrics; + return this; + }; + + DocumentLine.prototype= { + elements : null, + width : 0, + height : 0, + defaultHeight : 0, // default line height in case it is empty. + y : 0, + x : 0, + alignment : null, + + baselinePos : 0, + + addElement : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + this.alignment= element.style.__getProperty("alignment"); + }, + + addElementImage : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + }, + + getHeight : function() { + return this.height; + }, + + setY : function( y ) { + this.y= y; + }, + + getY : function() { + return this.y; + }, + + paint : function( ctx ) { + ctx.save(); + ctx.translate(this.x,this.y + this.baselinePos ); + + for( var i=0; i= JUSTIFY_RATIO && this.elements.length>1 ) { + var remaining= width - this.width; + + var forEachElement= (remaining/(this.elements.length-1))|0; + for( j=1; j biggestFont.ascent ) { + biggestFont= fm; + } + } + } else { // no FontMetrics, it is an image. + if (!biggestImage) { + biggestImage= elem; + } else { + if ( elem.getHeight() > elem.getHeight() ) { + biggestImage= elem; + } + } + } + } + + this.baselinePos= Math.max( + biggestFont ? biggestFont.ascent : this.defaultFontMetrics.ascent, + biggestImage ? biggestImage.getHeight() : this.defaultFontMetrics.ascent ); + this.height= this.baselinePos + (biggestFont!=null ? biggestFont.descent : this.defaultFontMetrics.descent ); + + for( i=0; i' and see whether it matches a tag + tag_closes_at_pos= text.indexOf('>', i+1); + if ( -1!==tag_closes_at_pos ) { + tag= text.substr( i+1, tag_closes_at_pos-i-1 ); + if ( tag.indexOf("<")!==-1 ) { + this.rc.fchar( _char ); + i+=1; + } else { + this.rc.setTag( tag ); + i= tag_closes_at_pos+1; + } + } + } else { + this.rc.fchar( _char ); + i+= 1; + } + } + + this.rc.end(); + this.lines= this.rc.lines; + + this.__calculateDocumentDimension( typeof width==="undefined" ? 0 : width ); + this.setLinesAlignment(); + + ctx.restore(); + + this.setPreferredSize( this.documentWidth, this.documentHeight ); + this.invalidateLayout(); + + this.setDocumentPosition(); + + if ( cached ) { + this.cacheAsBitmap(0,cached); + } + + if ( this.matchTextSize ) { + this.width= this.preferredSize.width; + this.height= this.preferredSize.height; + } + + return this; + }, + + setVerticalAlignment : function( align ) { + this.valignment= align; + this.setDocumentPosition(); + return this; + }, + + setHorizontalAlignment : function( align ) { + this.halignment= align; + this.setDocumentPosition(); + return this; + }, + + setDocumentPosition : function( halign, valign ) { + + if ( typeof halign!=="undefined" ) { + this.setHorizontalAlignment(halign); + } + if ( typeof valign!=="undefined" ) { + this.setVerticalAlignment(valign); + } + + var xo=0, yo=0; + + if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + yo= (this.height - this.documentHeight )/2; + } else if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM ) { + yo= this.height - this.documentHeight; + } + + if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + xo= (this.width - this.documentWidth )/2; + } else if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT ) { + xo= this.width - this.documentWidth; + } + + this.documentX= xo; + this.documentY= yo; + }, + + __calculateDocumentDimension : function( suggestedWidth ) { + var i; + var y= 0; + + this.documentWidth= 0; + this.documentHeight= 0; + for( i=0; i=x && line.y+line.height>=y ) { + return line.__getElementAt( x - line.x, y - line.y ); + } + } + + return null; + }, + + mouseExit : function(e) { + CAAT.setCursor( "default"); + }, + + mouseMove : function(e) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem && elem.getLink() ) { + CAAT.setCursor( "pointer"); + } else { + CAAT.setCursor( "default"); + } + }, + + mouseClick : function(e) { + if ( this.clickCallback ) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem.getLink() ) { + this.clickCallback( elem.getLink() ); + } + } + }, + + setClickCallback : function( callback ) { + this.clickCallback= callback; + return this; + } + } + + } + +}); +/** + * See LICENSE file. + * + * An actor to show the path and its handles in the scene graph. + * + **/ +CAAT.Module( { + + /** + * @name PathActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.PathActor", + aliases : ["CAAT.PathActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.PathActor.prototype + */ + + /** + * Path to draw. + * @type {CAAT.PathUtil.Path} + */ + path : null, + + /** + * Calculated path´s bounding box. + */ + pathBoundingRectangle : null, + + /** + * draw the bounding rectangle too ? + */ + bOutline : false, + + /** + * Outline the path in this color. + */ + outlineColor : 'black', + + /** + * If the path is interactive, some handlers are shown to modify the path. + * This callback function will be called when the path is interactively changed. + */ + onUpdateCallback : null, + + /** + * Set this path as interactive. + */ + interactive : false, + + /** + * Return the contained path. + * @return {CAAT.Path} + */ + getPath : function() { + return this.path; + }, + + /** + * Sets the path to manage. + * @param path {CAAT.PathUtil.PathSegment} + * @return this + */ + setPath : function(path) { + this.path= path; + if ( path!=null ) { + this.pathBoundingRectangle= path.getBoundingBox(); + this.setInteractive( this.interactive ); + } + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Foundation.Director} + * @param time {number}. Scene time. + */ + paint : function(director, time) { + + CAAT.Foundation.UI.PathActor.superclass.paint.call( this, director, time ); + + if ( !this.path ) { + return; + } + + var ctx= director.ctx; + + ctx.strokeStyle='#000'; + this.path.paint(director, this.interactive); + + if ( this.bOutline ) { + ctx.strokeStyle= this.outlineColor; + ctx.strokeRect( + this.pathBoundingRectangle.x, + this.pathBoundingRectangle.y, + this.pathBoundingRectangle.width, + this.pathBoundingRectangle.height + ); + } + }, + /** + * Enables/disables drawing of the contained path's bounding box. + * @param show {boolean} whether to show the bounding box + * @param color {=string} optional parameter defining the path's bounding box stroke style. + */ + showBoundingBox : function(show, color) { + this.bOutline= show; + if ( show && color ) { + this.outlineColor= color; + } + return this; + }, + /** + * Set the contained path as interactive. This means it can be changed on the fly by manipulation + * of its control points. + * @param interactive + */ + setInteractive : function(interactive) { + this.interactive= interactive; + if ( this.path ) { + this.path.setInteractive(interactive); + } + return this; + }, + setOnUpdateCallback : function( fn ) { + this.onUpdateCallback= fn; + return this; + }, + /** + * Route mouse dragging functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDrag : function(mouseEvent) { + this.path.drag(mouseEvent.point.x, mouseEvent.point.y, this.onUpdateCallback); + }, + /** + * Route mouse down functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDown : function(mouseEvent) { + this.path.press(mouseEvent.point.x, mouseEvent.point.y); + }, + /** + * Route mouse up functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseUp : function(mouseEvent) { + this.path.release(); + } + } +}); +CAAT.Module({ + + /** + * @name ShapeActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.ShapeActor", + aliases : ["CAAT.ShapeActor"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor + */ + + /** @const */ SHAPE_CIRCLE: 0, // Constants to describe different shapes. + /** @const */ SHAPE_RECTANGLE:1 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + + /** + * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default, + * so if no explicit call to setShape was made, nothing would be drawn. + */ + this.setShape( CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ); + return this; + }, + + /** + * Define this actor shape: rectangle or circle + */ + shape: 0, // shape type. One of the constant SHAPE_* values + + /** + * Set this shape composite operation when drawing it. + */ + compositeOp: null, // a valid canvas rendering context string describing compositeOps. + + /** + * Stroke the shape with this line width. + */ + lineWidth: 1, + + /** + * Stroke the shape with this line cap. + */ + lineCap: null, + + /** + * Stroke the shape with this line Join. + */ + lineJoin: null, + + /** + * Stroke the shape with this line mitter limit. + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets shape type. + * No check for parameter validity is performed. + * Set paint method according to the shape. + * @param iShape an integer with any of the SHAPE_* constants. + * @return this + */ + setShape : function(iShape) { + this.shape= iShape; + this.paint= this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ? + this.paintCircle : + this.paintRectangle; + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * Draws the shape. + * Applies the values of fillStype, strokeStyle, compositeOp, etc. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director,time) { + }, + /** + * @private + * Draws a circle. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintCircle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.stroke(); + } + }, + /** + * + * Private + * Draws a Rectangle. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintRectangle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.fillRect(0,0,this.width,this.height); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.strokeRect(0,0,this.width,this.height); + ctx.stroke(); + } + } + } + +}); +CAAT.Module( { + + /** + * @name StarActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.StarActor", + aliases : ["CAAT.StarActor"], + depends : [ + "CAAT.Foundation.ActorContainer" + ], + extendsClass : "CAAT.Foundation.ActorContainer", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.StarActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + return this; + }, + + /** + * Number of star peaks. + */ + nPeaks: 0, + + /** + * Maximum radius. + */ + maxRadius: 0, + + /** + * Minimum radius. + */ + minRadius: 0, + + /** + * Staring angle in radians. + */ + initialAngle: 0, + + /** + * Draw the star with this composite operation. + */ + compositeOp: null, + + /** + * + */ + lineWidth: 1, + + /** + * + */ + lineCap: null, + + /** + * + */ + lineJoin: null, + + /** + * + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets whether the star will be color filled. + * @param filled {boolean} + * @deprecated + */ + setFilled : function( filled ) { + return this; + }, + /** + * Sets whether the star will be outlined. + * @param outlined {boolean} + * @deprecated + */ + setOutlined : function( outlined ) { + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * + * @param angle {number} number in radians. + */ + setInitialAngle : function(angle) { + this.initialAngle= angle; + return this; + }, + /** + * Initialize the star values. + *

    + * The star actor will be of size 2*maxRadius. + * + * @param nPeaks {number} number of star points. + * @param maxRadius {number} maximum star radius + * @param minRadius {number} minimum star radius + * + * @return this + */ + initialize : function(nPeaks, maxRadius, minRadius) { + this.setSize( 2*maxRadius, 2*maxRadius ); + + this.nPeaks= nPeaks; + this.maxRadius= maxRadius; + this.minRadius= minRadius; + + return this; + }, + /** + * Paint the star. + * + * @param director {CAAT.Director} + * @param timer {number} + */ + paint : function(director, timer) { + + var ctx= director.ctx; + var centerX= this.width/2; + var centerY= this.height/2; + var r1= this.maxRadius; + var r2= this.minRadius; + var ix= centerX + r1*Math.cos(this.initialAngle); + var iy= centerY + r1*Math.sin(this.initialAngle); + + ctx.lineWidth= this.lineWidth; + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + + ctx.beginPath(); + ctx.moveTo(ix,iy); + + for( var i=1; i>0; + this.fontData= { + height : this.font.singleHeight, + ascent : as, + descent: this.font.singleHeight - as + }; +*/ + return this; + } + + if ( this.font instanceof CAAT.Module.Font.Font ) { + this.textWidth= this.font.stringWidth( this.text ); + this.textHeight=this.font.stringHeight(); + this.width= this.textWidth; + this.height= this.textHeight; + this.fontData= this.font.getFontData(); + return this; + } + + var ctx= director.ctx; + + ctx.save(); + ctx.font= this.font; + + this.textWidth= ctx.measureText( this.text ).width; + if (this.width===0) { + this.width= this.textWidth; + } +/* + var pos= this.font.indexOf("px"); + if (-1===pos) { + pos= this.font.indexOf("pt"); + } + if ( -1===pos ) { + // no pt or px, so guess a size: 32. why not ? + this.textHeight= 32; + } else { + var s = this.font.substring(0, pos ); + this.textHeight= parseInt(s,10); + } +*/ + + this.textHeight= this.fontData.height; + this.setSize( this.textWidth, this.textHeight ); + + ctx.restore(); + + return this; + }, + + __calcFontData : function() { + this.fontData= CAAT.Module.Font.Font.getFontMetrics( this.font ); + }, + + /** + * Custom paint method for TextActor instances. + * If the path attribute is set, the text will be drawn traversing the path. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director, time) { + + if (!this.text) { + return; + } + + CAAT.Foundation.UI.TextActor.superclass.paint.call(this, director, time ); + + if ( this.cached ) { + // cacheAsBitmap sets this actor's background image as a representation of itself. + // So if after drawing the background it was cached, we're done. + return; + } + + if ( null===this.text) { + return; + } + + if ( this.textWidth===0 || this.textHeight===0 ) { + this.calcTextSize(director); + } + + var ctx= director.ctx; + + if ( this.font instanceof CAAT.Module.Font.Font || this.font instanceof CAAT.Foundation.SpriteImage ) { + this.drawSpriteText(director,time); + return; + } + + if( null!==this.font ) { + ctx.font= this.font; + } + + /** + * always draw text with middle or bottom, top is buggy in FF. + * @type {String} + */ + ctx.textBaseline="alphabetic"; + + if (null===this.path) { + + if ( null!==this.textAlign ) { + ctx.textAlign= this.textAlign; + } + + var tx=0; + if ( this.textAlign==='center') { + tx= (this.width/2)|0; + } else if ( this.textAlign==='right' ) { + tx= this.width; + } + + if ( this.fill ) { + if ( null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + ctx.fillText( this.text, tx, this.fontData.ascent ); + } + + if ( this.outline ) { + if (null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + ctx.lineWidth= this.lineWidth; + ctx.beginPath(); + ctx.strokeText( this.text, tx, this.fontData.ascent ); + } + } + else { + this.drawOnPath(director,time); + } + }, + /** + * Private. + * Draw the text traversing a path. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawOnPath : function(director, time) { + + var ctx= director.ctx; + + if ( this.fill && null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + + if ( this.outline && null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i>0, p0.y>>0 ); + } else { + ctx.translate( p0.x, p0.y ); + } + ctx.rotate( angle ); + if ( this.fill ) { + ctx.fillText(caracter,0,0); + } + if ( this.outline ) { + ctx.beginPath(); + ctx.lineWidth= this.lineWidth; + ctx.strokeText(caracter,0,0); + } + + ctx.restore(); + + textWidth+= charWidth; + } + }, + + /** + * Private. + * Draw the text using a sprited font instead of a canvas font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteText: function(director, time) { + if (null===this.path) { + this.font.drawText( this.text, director.ctx, 0, 0); + } else { + this.drawSpriteTextOnPath(director, time); + } + }, + + /** + * Private. + * Draw the text traversing a path using a sprited font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteTextOnPath: function(director, time) { + var context= director.ctx; + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i + + #caat-debug { + z-index: 10000; + position:fixed; + bottom:0; + left:0; + width:100%; + background-color: rgba(0,0,0,0.8); + + } + + #caat-debug.caat_debug_max { + margin-bottom: 0px; + } + + .caat_debug_bullet { + display:inline-block; + background-color:#f00; + width:8px; + height:8px; + border-radius: 4px; + margin-left:10px; + margin-right:2px; + } + + .caat_debug_description { + font-size:11px; + font-family: helvetica, arial; + color: #aaa; + display: inline-block; + } + + .caat_debug_value { + font-size:11px; + font-family: helvetica, arial; + color: #fff; + width:25px; + text-align: right; + display: inline-block; + margin-right: .3em; + } + + .caat_debug_indicator { + float: right; + } + + #debug_tabs { + border-top: 1px solid #888; + height:25px; + } + + .tab_max_min { + font-family: helvetica, arial; + font-size: 12px; + font-weight: bold; + color: #888; + border-right: 1px solid #888; + float: left; + cursor: pointer; + padding-left: 5px; + padding-right: 5px; + padding-top: 5px; + height: 20px; + } + + .debug_tabs_content_hidden { + display: none; + width: 100%; + } + + .debug_tabs_content_visible { + display: block; + width: 100%; + } + + .checkbox_enabled { + display:inline-block; + background-color:#eee; + border: 1px solid #eee; + width:6px; + height:8px; + margin-left:12px; + margin-right:2px; + cursor: pointer; + } + + .checkbox_disabled { + display:inline-block; + width:6px; + height:8px; + background-color: #333; + border: 1px solid #eee; + margin-left:12px; + margin-right:2px; + cursor: pointer; + } + + .checkbox_description { + font-size:11px; + font-family: helvetica, arial; + color: #fff; + + } + + .debug_tab { + font-family: helvetica, arial; + font-size: 12px; + color: #fff; + border-right: 1px solid #888; + float: left; + padding-left: 5px; + padding-right: 5px; + height: 20px; + padding-top: 5px; + cursor: default; + } + + .debug_tab_selected { + background-color: #444; + cursor: default; + } + + .debug_tab_not_selected { + background-color: #000; + cursor: pointer; + } + + + + +

    +
    + CAAT Debug panel + Performance + Controls + + + + Draw Time: + 5.46 + ms. + + + + FPS: + 48 + +
    + +
    +
    + +
    + + + RAF Time: + 20.76 + ms. + + + + Entities Total: + 41 + + + + Entities Active: + 37 + + + + Draws: + 0 + +
    +
    +
    +
    +
    + + Sound +
    +
    + + Music +
    +
    + + AA Bounding Boxes +
    +
    + + Bounding Boxes +
    +
    +
    +
    + +
    + + diff --git a/CAAT/documentation/demos/demo-resources/img/anim1.png b/CAAT/documentation/demos/demo-resources/img/anim1.png new file mode 100644 index 0000000..79081c7 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim1.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/anim2.png b/CAAT/documentation/demos/demo-resources/img/anim2.png new file mode 100644 index 0000000..adae744 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim2.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/anim3.png b/CAAT/documentation/demos/demo-resources/img/anim3.png new file mode 100644 index 0000000..5075ef4 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim3.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/anim4.png b/CAAT/documentation/demos/demo-resources/img/anim4.png new file mode 100644 index 0000000..8ea7864 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim4.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/anim5.png b/CAAT/documentation/demos/demo-resources/img/anim5.png new file mode 100644 index 0000000..793fa58 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim5.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/anim6.png b/CAAT/documentation/demos/demo-resources/img/anim6.png new file mode 100644 index 0000000..0612699 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/anim6.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/burbu1.png b/CAAT/documentation/demos/demo-resources/img/burbu1.png new file mode 100644 index 0000000..f043642 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/burbu1.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/burbu2.png b/CAAT/documentation/demos/demo-resources/img/burbu2.png new file mode 100644 index 0000000..ec9c027 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/burbu2.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/burbu3.png b/CAAT/documentation/demos/demo-resources/img/burbu3.png new file mode 100644 index 0000000..417a237 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/burbu3.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/burbu4.png b/CAAT/documentation/demos/demo-resources/img/burbu4.png new file mode 100644 index 0000000..8cc820d Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/burbu4.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/font.txt b/CAAT/documentation/demos/demo-resources/img/font.txt new file mode 100755 index 0000000..32f59f2 --- /dev/null +++ b/CAAT/documentation/demos/demo-resources/img/font.txt @@ -0,0 +1,453 @@ +info face="LeagueGothic" size=123 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=2,2 +common lineHeight=145 base=114 scaleW=1024 scaleH=1024 pages=1 packed=0 +page id=0 file="ibasketfont.png" +chars count=169 +char id=124 x=2 y=2 width=22 height=144 xoffset=5 yoffset=1 xadvance=21 page=0 chnl=0 letter="|" +char id=125 x=26 y=2 width=43 height=130 xoffset=3 yoffset=11 xadvance=41 page=0 chnl=0 letter="}" +char id=123 x=71 y=2 width=43 height=130 xoffset=4 yoffset=11 xadvance=41 page=0 chnl=0 letter="{" +char id=197 x=116 y=2 width=50 height=126 xoffset=1 yoffset=-12 xadvance=46 page=0 chnl=0 letter="Å" +char id=199 x=168 y=2 width=44 height=126 xoffset=4 yoffset=11 xadvance=43 page=0 chnl=0 letter="Ç" +char id=255 x=214 y=2 width=42 height=126 xoffset=1 yoffset=12 xadvance=38 page=0 chnl=0 letter="ÿ" +char id=253 x=258 y=2 width=42 height=125 xoffset=1 yoffset=13 xadvance=38 page=0 chnl=0 letter="ý" +char id=254 x=302 y=2 width=42 height=125 xoffset=5 yoffset=12 xadvance=41 page=0 chnl=0 letter="þ" +char id=41 x=346 y=2 width=37 height=125 xoffset=2 yoffset=7 xadvance=34 page=0 chnl=0 letter=")" +char id=40 x=385 y=2 width=35 height=125 xoffset=4 yoffset=7 xadvance=34 page=0 chnl=0 letter="(" +char id=106 x=422 y=2 width=30 height=125 xoffset=-3 yoffset=12 xadvance=22 page=0 chnl=0 letter="j" +char id=92 x=454 y=2 width=52 height=124 xoffset=0 yoffset=1 xadvance=48 page=0 chnl=0 letter="\" +char id=220 x=508 y=2 width=46 height=123 xoffset=5 yoffset=-8 xadvance=45 page=0 chnl=0 letter="Ü" +char id=214 x=556 y=2 width=45 height=123 xoffset=4 yoffset=-8 xadvance=44 page=0 chnl=0 letter="Ö" +char id=196 x=603 y=2 width=49 height=122 xoffset=1 yoffset=-8 xadvance=46 page=0 chnl=0 letter="Ä" +char id=217 x=654 y=2 width=46 height=122 xoffset=5 yoffset=-7 xadvance=45 page=0 chnl=0 letter="Ù" +char id=218 x=702 y=2 width=46 height=122 xoffset=5 yoffset=-7 xadvance=45 page=0 chnl=0 letter="Ú" +char id=219 x=750 y=2 width=46 height=122 xoffset=5 yoffset=-7 xadvance=45 page=0 chnl=0 letter="Û" +char id=36 x=798 y=2 width=45 height=122 xoffset=2 yoffset=5 xadvance=42 page=0 chnl=0 letter="$" +char id=210 x=845 y=2 width=45 height=122 xoffset=4 yoffset=-7 xadvance=44 page=0 chnl=0 letter="Ò" +char id=211 x=892 y=2 width=45 height=122 xoffset=4 yoffset=-7 xadvance=44 page=0 chnl=0 letter="Ó" +char id=212 x=939 y=2 width=45 height=122 xoffset=4 yoffset=-7 xadvance=44 page=0 chnl=0 letter="Ô" +char id=213 x=2 y=148 width=45 height=122 xoffset=4 yoffset=-7 xadvance=44 page=0 chnl=0 letter="Õ" +char id=203 x=49 y=148 width=36 height=122 xoffset=5 yoffset=-8 xadvance=38 page=0 chnl=0 letter="Ë" +char id=207 x=87 y=148 width=34 height=122 xoffset=-3 yoffset=-8 xadvance=22 page=0 chnl=0 letter="Ï" +char id=195 x=123 y=148 width=50 height=121 xoffset=1 yoffset=-7 xadvance=46 page=0 chnl=0 letter="Ã" +char id=209 x=175 y=148 width=49 height=121 xoffset=5 yoffset=-7 xadvance=49 page=0 chnl=0 letter="Ñ" +char id=192 x=226 y=148 width=49 height=121 xoffset=1 yoffset=-7 xadvance=46 page=0 chnl=0 letter="À" +char id=193 x=277 y=148 width=49 height=121 xoffset=1 yoffset=-7 xadvance=46 page=0 chnl=0 letter="Á" +char id=194 x=328 y=148 width=49 height=121 xoffset=1 yoffset=-7 xadvance=46 page=0 chnl=0 letter="Â" +char id=221 x=379 y=148 width=47 height=121 xoffset=1 yoffset=-7 xadvance=42 page=0 chnl=0 letter="Ý" +char id=200 x=428 y=148 width=36 height=121 xoffset=5 yoffset=-7 xadvance=38 page=0 chnl=0 letter="È" +char id=201 x=466 y=148 width=36 height=121 xoffset=5 yoffset=-7 xadvance=38 page=0 chnl=0 letter="É" +char id=202 x=504 y=148 width=36 height=121 xoffset=5 yoffset=-7 xadvance=38 page=0 chnl=0 letter="Ê" +char id=206 x=542 y=148 width=36 height=121 xoffset=-4 yoffset=-7 xadvance=22 page=0 chnl=0 letter="Î" +char id=204 x=580 y=148 width=25 height=121 xoffset=-0 yoffset=-7 xadvance=24 page=0 chnl=0 letter="Ì" +char id=205 x=607 y=148 width=25 height=121 xoffset=5 yoffset=-7 xadvance=24 page=0 chnl=0 letter="Í" +char id=91 x=634 y=148 width=29 height=115 xoffset=5 yoffset=12 xadvance=32 page=0 chnl=0 letter="[" +char id=93 x=665 y=148 width=29 height=115 xoffset=3 yoffset=12 xadvance=32 page=0 chnl=0 letter="]" +char id=162 x=696 y=148 width=40 height=113 xoffset=4 yoffset=8 xadvance=38 page=0 chnl=0 letter="¢" +char id=126 x=738 y=148 width=76 height=112 xoffset=7 yoffset=2 xadvance=77 page=0 chnl=0 letter="~" +char id=47 x=816 y=148 width=48 height=111 xoffset=0 yoffset=12 xadvance=43 page=0 chnl=0 letter="/" +char id=81 x=866 y=148 width=45 height=110 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="Q" +char id=229 x=913 y=148 width=44 height=106 xoffset=3 yoffset=9 xadvance=41 page=0 chnl=0 letter="å" +char id=169 x=2 y=272 width=101 height=104 xoffset=3 yoffset=11 xadvance=99 page=0 chnl=0 letter="©" +char id=174 x=105 y=272 width=101 height=104 xoffset=3 yoffset=11 xadvance=99 page=0 chnl=0 letter="®" +char id=37 x=208 y=272 width=62 height=104 xoffset=3 yoffset=11 xadvance=60 page=0 chnl=0 letter="%" +char id=163 x=272 y=272 width=54 height=104 xoffset=0 yoffset=11 xadvance=49 page=0 chnl=0 letter="£" +char id=64 x=328 y=272 width=54 height=104 xoffset=4 yoffset=11 xadvance=52 page=0 chnl=0 letter="@" +char id=38 x=384 y=272 width=54 height=104 xoffset=3 yoffset=11 xadvance=51 page=0 chnl=0 letter="&" +char id=103 x=440 y=272 width=47 height=104 xoffset=1 yoffset=34 xadvance=42 page=0 chnl=0 letter="g" +char id=71 x=489 y=272 width=46 height=104 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="G" +char id=216 x=537 y=272 width=45 height=104 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="Ø" +char id=83 x=584 y=272 width=45 height=104 xoffset=2 yoffset=11 xadvance=42 page=0 chnl=0 letter="S" +char id=79 x=631 y=272 width=45 height=104 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="O" +char id=48 x=678 y=272 width=45 height=104 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="0" +char id=67 x=725 y=272 width=44 height=104 xoffset=4 yoffset=11 xadvance=43 page=0 chnl=0 letter="C" +char id=51 x=771 y=272 width=44 height=104 xoffset=3 yoffset=11 xadvance=41 page=0 chnl=0 letter="3" +char id=56 x=817 y=272 width=44 height=104 xoffset=3 yoffset=11 xadvance=42 page=0 chnl=0 letter="8" +char id=57 x=863 y=272 width=44 height=104 xoffset=3 yoffset=11 xadvance=42 page=0 chnl=0 letter="9" +char id=54 x=909 y=272 width=44 height=104 xoffset=4 yoffset=11 xadvance=42 page=0 chnl=0 letter="6" +char id=240 x=955 y=272 width=41 height=104 xoffset=5 yoffset=11 xadvance=40 page=0 chnl=0 letter="ð" +char id=50 x=2 y=378 width=46 height=103 xoffset=3 yoffset=11 xadvance=44 page=0 chnl=0 letter="2" +char id=85 x=50 y=378 width=46 height=103 xoffset=5 yoffset=12 xadvance=45 page=0 chnl=0 letter="U" +char id=223 x=98 y=378 width=46 height=103 xoffset=4 yoffset=11 xadvance=44 page=0 chnl=0 letter="ß" +char id=228 x=146 y=378 width=44 height=103 xoffset=3 yoffset=12 xadvance=41 page=0 chnl=0 letter="ä" +char id=53 x=192 y=378 width=43 height=103 xoffset=4 yoffset=12 xadvance=42 page=0 chnl=0 letter="5" +char id=100 x=237 y=378 width=42 height=103 xoffset=4 yoffset=12 xadvance=41 page=0 chnl=0 letter="d" +char id=113 x=281 y=378 width=42 height=103 xoffset=4 yoffset=34 xadvance=41 page=0 chnl=0 letter="q" +char id=252 x=325 y=378 width=42 height=103 xoffset=5 yoffset=12 xadvance=41 page=0 chnl=0 letter="ü" +char id=121 x=369 y=378 width=42 height=103 xoffset=1 yoffset=35 xadvance=38 page=0 chnl=0 letter="y" +char id=98 x=413 y=378 width=42 height=103 xoffset=5 yoffset=12 xadvance=41 page=0 chnl=0 letter="b" +char id=112 x=457 y=378 width=42 height=103 xoffset=5 yoffset=34 xadvance=41 page=0 chnl=0 letter="p" +char id=235 x=501 y=378 width=41 height=103 xoffset=4 yoffset=12 xadvance=40 page=0 chnl=0 letter="ë" +char id=246 x=544 y=378 width=41 height=103 xoffset=4 yoffset=12 xadvance=39 page=0 chnl=0 letter="ö" +char id=231 x=587 y=378 width=40 height=103 xoffset=4 yoffset=34 xadvance=39 page=0 chnl=0 letter="ç" +char id=74 x=629 y=378 width=30 height=103 xoffset=1 yoffset=12 xadvance=25 page=0 chnl=0 letter="J" +char id=35 x=661 y=378 width=74 height=102 xoffset=3 yoffset=12 xadvance=74 page=0 chnl=0 letter="#" +char id=198 x=737 y=378 width=68 height=102 xoffset=1 yoffset=12 xadvance=66 page=0 chnl=0 letter="Æ" +char id=87 x=807 y=378 width=66 height=102 xoffset=1 yoffset=12 xadvance=62 page=0 chnl=0 letter="W" +char id=77 x=875 y=378 width=55 height=102 xoffset=5 yoffset=12 xadvance=60 page=0 chnl=0 letter="M" +char id=208 x=932 y=378 width=50 height=102 xoffset=1 yoffset=12 xadvance=46 page=0 chnl=0 letter="Ð" +char id=78 x=2 y=483 width=49 height=102 xoffset=5 yoffset=12 xadvance=49 page=0 chnl=0 letter="N" +char id=65 x=53 y=483 width=49 height=102 xoffset=1 yoffset=12 xadvance=46 page=0 chnl=0 letter="A" +char id=88 x=104 y=483 width=48 height=102 xoffset=1 yoffset=12 xadvance=44 page=0 chnl=0 letter="X" +char id=72 x=154 y=483 width=47 height=102 xoffset=5 yoffset=12 xadvance=47 page=0 chnl=0 letter="H" +char id=75 x=203 y=483 width=47 height=102 xoffset=5 yoffset=12 xadvance=46 page=0 chnl=0 letter="K" +char id=89 x=252 y=483 width=47 height=102 xoffset=1 yoffset=12 xadvance=42 page=0 chnl=0 letter="Y" +char id=68 x=301 y=483 width=46 height=102 xoffset=5 yoffset=12 xadvance=46 page=0 chnl=0 letter="D" +char id=86 x=349 y=483 width=46 height=102 xoffset=1 yoffset=12 xadvance=43 page=0 chnl=0 letter="V" +char id=165 x=397 y=483 width=46 height=102 xoffset=1 yoffset=12 xadvance=43 page=0 chnl=0 letter="¥" +char id=66 x=445 y=483 width=45 height=102 xoffset=5 yoffset=12 xadvance=45 page=0 chnl=0 letter="B" +char id=82 x=492 y=483 width=45 height=102 xoffset=5 yoffset=12 xadvance=44 page=0 chnl=0 letter="R" +char id=227 x=539 y=483 width=44 height=102 xoffset=3 yoffset=13 xadvance=41 page=0 chnl=0 letter="ã" +char id=52 x=585 y=483 width=44 height=102 xoffset=1 yoffset=12 xadvance=41 page=0 chnl=0 letter="4" +char id=222 x=631 y=483 width=44 height=102 xoffset=5 yoffset=12 xadvance=44 page=0 chnl=0 letter="Þ" +char id=80 x=677 y=483 width=44 height=102 xoffset=5 yoffset=12 xadvance=43 page=0 chnl=0 letter="P" +char id=84 x=723 y=483 width=44 height=102 xoffset=0 yoffset=12 xadvance=39 page=0 chnl=0 letter="T" +char id=224 x=769 y=483 width=44 height=102 xoffset=3 yoffset=13 xadvance=41 page=0 chnl=0 letter="à" +char id=225 x=815 y=483 width=44 height=102 xoffset=3 yoffset=13 xadvance=41 page=0 chnl=0 letter="á" +char id=226 x=861 y=483 width=44 height=102 xoffset=3 yoffset=13 xadvance=41 page=0 chnl=0 letter="â" +char id=63 x=907 y=483 width=43 height=102 xoffset=1 yoffset=12 xadvance=39 page=0 chnl=0 letter="?" +char id=191 x=952 y=483 width=42 height=102 xoffset=2 yoffset=36 xadvance=39 page=0 chnl=0 letter="¿" +char id=249 x=2 y=587 width=42 height=102 xoffset=5 yoffset=13 xadvance=41 page=0 chnl=0 letter="ù" +char id=250 x=46 y=587 width=42 height=102 xoffset=5 yoffset=13 xadvance=41 page=0 chnl=0 letter="ú" +char id=251 x=90 y=587 width=42 height=102 xoffset=5 yoffset=13 xadvance=41 page=0 chnl=0 letter="û" +char id=104 x=134 y=587 width=42 height=102 xoffset=5 yoffset=12 xadvance=41 page=0 chnl=0 letter="h" +char id=245 x=178 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=39 page=0 chnl=0 letter="õ" +char id=232 x=221 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=40 page=0 chnl=0 letter="è" +char id=233 x=264 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=40 page=0 chnl=0 letter="é" +char id=234 x=307 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=40 page=0 chnl=0 letter="ê" +char id=242 x=350 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=39 page=0 chnl=0 letter="ò" +char id=243 x=393 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=39 page=0 chnl=0 letter="ó" +char id=244 x=436 y=587 width=41 height=102 xoffset=4 yoffset=13 xadvance=39 page=0 chnl=0 letter="ô" +char id=90 x=479 y=587 width=41 height=102 xoffset=1 yoffset=12 xadvance=38 page=0 chnl=0 letter="Z" +char id=107 x=522 y=587 width=39 height=102 xoffset=5 yoffset=12 xadvance=38 page=0 chnl=0 letter="k" +char id=55 x=563 y=587 width=39 height=102 xoffset=0 yoffset=12 xadvance=35 page=0 chnl=0 letter="7" +char id=70 x=604 y=587 width=38 height=102 xoffset=5 yoffset=12 xadvance=37 page=0 chnl=0 letter="F" +char id=76 x=644 y=587 width=36 height=102 xoffset=5 yoffset=12 xadvance=36 page=0 chnl=0 letter="L" +char id=69 x=682 y=587 width=36 height=102 xoffset=5 yoffset=12 xadvance=38 page=0 chnl=0 letter="E" +char id=239 x=720 y=587 width=34 height=102 xoffset=-3 yoffset=12 xadvance=22 page=0 chnl=0 letter="ï" +char id=102 x=756 y=587 width=33 height=102 xoffset=1 yoffset=12 xadvance=29 page=0 chnl=0 letter="f" +char id=49 x=791 y=587 width=33 height=102 xoffset=1 yoffset=12 xadvance=29 page=0 chnl=0 letter="1" +char id=108 x=826 y=587 width=23 height=102 xoffset=5 yoffset=12 xadvance=22 page=0 chnl=0 letter="l" +char id=33 x=851 y=587 width=20 height=102 xoffset=4 yoffset=12 xadvance=23 page=0 chnl=0 letter="!" +char id=161 x=873 y=587 width=20 height=102 xoffset=4 yoffset=35 xadvance=23 page=0 chnl=0 letter="¡" +char id=73 x=895 y=587 width=19 height=102 xoffset=5 yoffset=12 xadvance=23 page=0 chnl=0 letter="I" +char id=105 x=916 y=587 width=18 height=102 xoffset=5 yoffset=12 xadvance=22 page=0 chnl=0 letter="i" +char id=241 x=936 y=587 width=42 height=101 xoffset=5 yoffset=13 xadvance=41 page=0 chnl=0 letter="ñ" +char id=238 x=980 y=587 width=36 height=101 xoffset=-4 yoffset=13 xadvance=22 page=0 chnl=0 letter="î" +char id=236 x=2 y=691 width=25 height=101 xoffset=-2 yoffset=13 xadvance=22 page=0 chnl=0 letter="ì" +char id=237 x=29 y=691 width=25 height=101 xoffset=5 yoffset=13 xadvance=22 page=0 chnl=0 letter="í" +char id=116 x=56 y=691 width=34 height=96 xoffset=1 yoffset=19 xadvance=30 page=0 chnl=0 letter="t" +char id=59 x=92 y=691 width=18 height=95 xoffset=4 yoffset=35 xadvance=22 page=0 chnl=0 letter=";" +char id=248 x=112 y=691 width=41 height=88 xoffset=4 yoffset=31 xadvance=39 page=0 chnl=0 letter="ø" +char id=230 x=155 y=691 width=62 height=81 xoffset=3 yoffset=34 xadvance=59 page=0 chnl=0 letter="æ" +char id=97 x=219 y=691 width=44 height=81 xoffset=3 yoffset=34 xadvance=41 page=0 chnl=0 letter="a" +char id=101 x=265 y=691 width=41 height=81 xoffset=4 yoffset=34 xadvance=40 page=0 chnl=0 letter="e" +char id=111 x=308 y=691 width=41 height=81 xoffset=4 yoffset=34 xadvance=39 page=0 chnl=0 letter="o" +char id=115 x=351 y=691 width=41 height=81 xoffset=2 yoffset=34 xadvance=38 page=0 chnl=0 letter="s" +char id=99 x=394 y=691 width=40 height=81 xoffset=4 yoffset=34 xadvance=39 page=0 chnl=0 letter="c" +char id=109 x=436 y=691 width=62 height=80 xoffset=5 yoffset=34 xadvance=61 page=0 chnl=0 letter="m" +char id=117 x=500 y=691 width=42 height=80 xoffset=5 yoffset=35 xadvance=41 page=0 chnl=0 letter="u" +char id=110 x=544 y=691 width=42 height=80 xoffset=5 yoffset=34 xadvance=41 page=0 chnl=0 letter="n" +char id=114 x=588 y=691 width=31 height=80 xoffset=5 yoffset=34 xadvance=30 page=0 chnl=0 letter="r" +char id=119 x=621 y=691 width=57 height=79 xoffset=1 yoffset=35 xadvance=54 page=0 chnl=0 letter="w" +char id=120 x=680 y=691 width=41 height=79 xoffset=1 yoffset=35 xadvance=37 page=0 chnl=0 letter="x" +char id=118 x=723 y=691 width=40 height=79 xoffset=1 yoffset=35 xadvance=36 page=0 chnl=0 letter="v" +char id=122 x=765 y=691 width=36 height=79 xoffset=1 yoffset=35 xadvance=32 page=0 chnl=0 letter="z" +char id=58 x=803 y=691 width=18 height=79 xoffset=4 yoffset=35 xadvance=22 page=0 chnl=0 letter=":" +char id=60 x=823 y=691 width=60 height=78 xoffset=4 yoffset=26 xadvance=64 page=0 chnl=0 letter="<" +char id=62 x=885 y=691 width=60 height=78 xoffset=4 yoffset=26 xadvance=64 page=0 chnl=0 letter=">" +char id=43 x=947 y=691 width=60 height=63 xoffset=4 yoffset=33 xadvance=64 page=0 chnl=0 letter="+" +char id=94 x=2 y=794 width=65 height=53 xoffset=3 yoffset=12 xadvance=66 page=0 chnl=0 letter="^" +char id=61 x=69 y=794 width=60 height=45 xoffset=4 yoffset=40 xadvance=64 page=0 chnl=0 letter="=" +char id=34 x=131 y=794 width=18 height=45 xoffset=3 yoffset=12 xadvance=20 page=0 chnl=0 letter=""" +char id=42 x=151 y=794 width=37 height=42 xoffset=4 yoffset=12 xadvance=41 page=0 chnl=0 letter="*" +char id=39 x=190 y=794 width=18 height=41 xoffset=3 yoffset=12 xadvance=19 page=0 chnl=0 letter="'" +char id=44 x=210 y=794 width=18 height=41 xoffset=3 yoffset=89 xadvance=19 page=0 chnl=0 letter="," +char id=184 x=230 y=794 width=16 height=28 xoffset=26 yoffset=109 xadvance=62 page=0 chnl=0 letter="¸" +char id=46 x=248 y=794 width=18 height=25 xoffset=3 yoffset=89 xadvance=19 page=0 chnl=0 letter="." +char id=183 x=268 y=794 width=18 height=25 xoffset=0 yoffset=50 xadvance=13 page=0 chnl=0 letter="·" +char id=168 x=288 y=794 width=34 height=24 xoffset=16 yoffset=12 xadvance=62 page=0 chnl=0 letter="¨" +char id=96 x=324 y=794 width=25 height=23 xoffset=18 yoffset=13 xadvance=62 page=0 chnl=0 letter="`" +char id=180 x=351 y=794 width=25 height=23 xoffset=25 yoffset=13 xadvance=62 page=0 chnl=0 letter="´" +char id=45 x=378 y=794 width=23 height=23 xoffset=4 yoffset=64 xadvance=27 page=0 chnl=0 letter="-" +char id=95 x=403 y=794 width=69 height=22 xoffset=4 yoffset=112 xadvance=73 page=0 chnl=0 letter="_" +char id=175 x=474 y=794 width=29 height=21 xoffset=19 yoffset=14 xadvance=62 page=0 chnl=0 letter="¯" +char id=32 x=611 y=794 width=0 height=0 xoffset=19 yoffset=114 xadvance=19 page=0 chnl=0 letter="space" +kernings count=279 +kerning first=40 second=84 amount=-3 +kerning first=40 second=70 amount=-3 +kerning first=162 second=127 amount=-2 +kerning first=162 second=128 amount=-2 +kerning first=162 second=129 amount=-2 +kerning first=162 second=130 amount=-2 +kerning first=162 second=131 amount=-2 +kerning first=162 second=132 amount=-2 +kerning first=162 second=134 amount=-2 +kerning first=162 second=135 amount=-2 +kerning first=162 second=136 amount=-2 +kerning first=162 second=137 amount=-2 +kerning first=162 second=138 amount=-2 +kerning first=162 second=139 amount=-2 +kerning first=162 second=140 amount=-2 +kerning first=162 second=141 amount=-2 +kerning first=162 second=142 amount=-2 +kerning first=162 second=143 amount=-2 +kerning first=162 second=144 amount=-2 +kerning first=162 second=145 amount=-2 +kerning first=162 second=146 amount=-2 +kerning first=162 second=147 amount=-2 +kerning first=162 second=148 amount=-2 +kerning first=162 second=149 amount=-2 +kerning first=162 second=150 amount=-2 +kerning first=162 second=151 amount=-2 +kerning first=162 second=152 amount=-2 +kerning first=162 second=153 amount=-2 +kerning first=162 second=154 amount=-2 +kerning first=162 second=156 amount=-2 +kerning first=162 second=157 amount=-2 +kerning first=162 second=158 amount=-2 +kerning first=162 second=159 amount=-2 +kerning first=162 second=164 amount=-2 +kerning first=162 second=166 amount=-2 +kerning first=162 second=167 amount=-2 +kerning first=162 second=170 amount=-2 +kerning first=162 second=171 amount=-2 +kerning first=162 second=172 amount=-2 +kerning first=162 second=173 amount=-2 +kerning first=162 second=176 amount=-2 +kerning first=162 second=177 amount=-2 +kerning first=162 second=178 amount=-2 +kerning first=162 second=179 amount=-2 +kerning first=162 second=181 amount=-2 +kerning first=162 second=182 amount=-2 +kerning first=162 second=185 amount=-2 +kerning first=162 second=186 amount=-2 +kerning first=162 second=187 amount=-2 +kerning first=162 second=188 amount=-2 +kerning first=162 second=189 amount=-2 +kerning first=162 second=190 amount=-2 +kerning first=162 second=215 amount=-2 +kerning first=162 second=247 amount=-2 +kerning first=47 second=84 amount=-1 +kerning first=169 second=84 amount=-2 +kerning first=169 second=70 amount=-3 +kerning first=37 second=127 amount=-1 +kerning first=37 second=128 amount=-1 +kerning first=37 second=129 amount=-1 +kerning first=37 second=130 amount=-1 +kerning first=37 second=131 amount=-1 +kerning first=37 second=132 amount=-1 +kerning first=37 second=134 amount=-1 +kerning first=37 second=135 amount=-1 +kerning first=37 second=136 amount=-1 +kerning first=37 second=137 amount=-1 +kerning first=37 second=138 amount=-1 +kerning first=37 second=139 amount=-1 +kerning first=37 second=140 amount=-1 +kerning first=37 second=141 amount=-1 +kerning first=37 second=142 amount=-1 +kerning first=37 second=143 amount=-1 +kerning first=37 second=144 amount=-1 +kerning first=37 second=145 amount=-1 +kerning first=37 second=146 amount=-1 +kerning first=37 second=147 amount=-1 +kerning first=37 second=148 amount=-1 +kerning first=37 second=149 amount=-1 +kerning first=37 second=150 amount=-1 +kerning first=37 second=151 amount=-1 +kerning first=37 second=152 amount=-1 +kerning first=37 second=153 amount=-1 +kerning first=37 second=154 amount=-1 +kerning first=37 second=156 amount=-1 +kerning first=37 second=157 amount=-1 +kerning first=37 second=158 amount=-1 +kerning first=37 second=159 amount=-1 +kerning first=37 second=164 amount=-1 +kerning first=37 second=166 amount=-1 +kerning first=37 second=167 amount=-1 +kerning first=37 second=170 amount=-1 +kerning first=37 second=171 amount=-1 +kerning first=37 second=172 amount=-1 +kerning first=37 second=173 amount=-1 +kerning first=37 second=176 amount=-1 +kerning first=37 second=177 amount=-1 +kerning first=37 second=178 amount=-1 +kerning first=37 second=179 amount=-1 +kerning first=37 second=181 amount=-1 +kerning first=37 second=182 amount=-1 +kerning first=37 second=185 amount=-1 +kerning first=37 second=186 amount=-1 +kerning first=37 second=187 amount=-1 +kerning first=37 second=188 amount=-1 +kerning first=37 second=189 amount=-1 +kerning first=37 second=190 amount=-1 +kerning first=37 second=215 amount=-1 +kerning first=37 second=247 amount=-1 +kerning first=103 second=111 amount=-1 +kerning first=103 second=44 amount=1 +kerning first=79 second=84 amount=-1 +kerning first=50 second=68 amount=-2 +kerning first=50 second=70 amount=1 +kerning first=121 second=97 amount=-1 +kerning first=198 second=76 amount=-1 +kerning first=65 second=83 amount=-1 +kerning first=65 second=121 amount=-1 +kerning first=65 second=89 amount=-3 +kerning first=65 second=86 amount=-3 +kerning first=65 second=84 amount=-3 +kerning first=72 second=85 amount=-3 +kerning first=72 second=246 amount=-5 +kerning first=72 second=234 amount=-3 +kerning first=72 second=244 amount=-5 +kerning first=72 second=180 amount=-3 +kerning first=75 second=127 amount=-1 +kerning first=75 second=128 amount=-1 +kerning first=75 second=129 amount=-1 +kerning first=75 second=130 amount=-1 +kerning first=75 second=131 amount=-1 +kerning first=75 second=132 amount=-1 +kerning first=75 second=134 amount=-1 +kerning first=75 second=135 amount=-1 +kerning first=75 second=136 amount=-1 +kerning first=75 second=137 amount=-1 +kerning first=75 second=138 amount=-1 +kerning first=75 second=139 amount=-1 +kerning first=75 second=140 amount=-1 +kerning first=75 second=141 amount=-1 +kerning first=75 second=142 amount=-1 +kerning first=75 second=143 amount=-1 +kerning first=75 second=144 amount=-1 +kerning first=75 second=145 amount=-1 +kerning first=75 second=146 amount=-1 +kerning first=75 second=147 amount=-1 +kerning first=75 second=148 amount=-1 +kerning first=75 second=149 amount=-1 +kerning first=75 second=150 amount=-1 +kerning first=75 second=151 amount=-1 +kerning first=75 second=152 amount=-1 +kerning first=75 second=153 amount=-1 +kerning first=75 second=154 amount=-1 +kerning first=75 second=156 amount=-1 +kerning first=75 second=157 amount=-1 +kerning first=75 second=158 amount=-1 +kerning first=75 second=159 amount=-1 +kerning first=75 second=164 amount=-1 +kerning first=75 second=166 amount=-1 +kerning first=75 second=167 amount=-1 +kerning first=75 second=170 amount=-1 +kerning first=75 second=171 amount=-1 +kerning first=75 second=172 amount=-1 +kerning first=75 second=173 amount=-1 +kerning first=75 second=176 amount=-1 +kerning first=75 second=177 amount=-1 +kerning first=75 second=178 amount=-1 +kerning first=75 second=179 amount=-1 +kerning first=75 second=181 amount=-1 +kerning first=75 second=182 amount=-1 +kerning first=75 second=185 amount=-1 +kerning first=75 second=186 amount=-1 +kerning first=75 second=187 amount=-1 +kerning first=75 second=188 amount=-1 +kerning first=75 second=189 amount=-1 +kerning first=75 second=190 amount=-1 +kerning first=75 second=215 amount=-1 +kerning first=75 second=247 amount=-1 +kerning first=89 second=100 amount=-3 +kerning first=89 second=65 amount=-3 +kerning first=89 second=97 amount=-5 +kerning first=89 second=111 amount=-5 +kerning first=86 second=65 amount=-3 +kerning first=86 second=97 amount=-2 +kerning first=86 second=111 amount=-2 +kerning first=86 second=110 amount=-1 +kerning first=52 second=51 amount=1 +kerning first=52 second=56 amount=1 +kerning first=80 second=200 amount=-2 +kerning first=80 second=111 amount=-1 +kerning first=84 second=121 amount=-1 +kerning first=84 second=65 amount=-3 +kerning first=84 second=84 amount=1 +kerning first=84 second=97 amount=-4 +kerning first=84 second=111 amount=-3 +kerning first=84 second=110 amount=-3 +kerning first=84 second=120 amount=-2 +kerning first=107 second=111 amount=-1 +kerning first=55 second=52 amount=-1 +kerning first=55 second=49 amount=1 +kerning first=70 second=38 amount=-1 +kerning first=70 second=97 amount=-1 +kerning first=70 second=111 amount=-1 +kerning first=76 second=65 amount=1 +kerning first=76 second=89 amount=-2 +kerning first=102 second=102 amount=-1 +kerning first=73 second=84 amount=-1 +kerning first=105 second=115 amount=-1 +kerning first=116 second=116 amount=-1 +kerning first=116 second=122 amount=1 +kerning first=97 second=102 amount=-1 +kerning first=97 second=116 amount=-1 +kerning first=111 second=121 amount=-1 +kerning first=111 second=102 amount=-1 +kerning first=111 second=116 amount=-1 +kerning first=111 second=97 amount=-1 +kerning first=115 second=116 amount=-1 +kerning first=117 second=121 amount=-1 +kerning first=117 second=116 amount=-1 +kerning first=110 second=116 amount=-1 +kerning first=110 second=97 amount=-1 +kerning first=110 second=115 amount=-1 +kerning first=114 second=97 amount=-1 +kerning first=114 second=115 amount=-1 +kerning first=42 second=84 amount=-3 +kerning first=96 second=84 amount=-2 +kerning first=96 second=127 amount=-4 +kerning first=96 second=128 amount=-4 +kerning first=96 second=129 amount=-4 +kerning first=96 second=130 amount=-4 +kerning first=96 second=131 amount=-4 +kerning first=96 second=132 amount=-4 +kerning first=96 second=134 amount=-4 +kerning first=96 second=135 amount=-4 +kerning first=96 second=136 amount=-4 +kerning first=96 second=137 amount=-4 +kerning first=96 second=138 amount=-4 +kerning first=96 second=139 amount=-4 +kerning first=96 second=140 amount=-4 +kerning first=96 second=141 amount=-4 +kerning first=96 second=142 amount=-4 +kerning first=96 second=143 amount=-4 +kerning first=96 second=144 amount=-4 +kerning first=96 second=145 amount=-4 +kerning first=96 second=146 amount=-4 +kerning first=96 second=147 amount=-4 +kerning first=96 second=148 amount=-4 +kerning first=96 second=149 amount=-4 +kerning first=96 second=150 amount=-4 +kerning first=96 second=151 amount=-4 +kerning first=96 second=152 amount=-4 +kerning first=96 second=153 amount=-4 +kerning first=96 second=154 amount=-4 +kerning first=96 second=156 amount=-4 +kerning first=96 second=157 amount=-4 +kerning first=96 second=158 amount=-4 +kerning first=96 second=159 amount=-4 +kerning first=96 second=164 amount=-4 +kerning first=96 second=166 amount=-4 +kerning first=96 second=167 amount=-4 +kerning first=96 second=170 amount=-4 +kerning first=96 second=171 amount=-4 +kerning first=96 second=172 amount=-4 +kerning first=96 second=173 amount=-4 +kerning first=96 second=176 amount=-4 +kerning first=96 second=177 amount=-4 +kerning first=96 second=178 amount=-4 +kerning first=96 second=179 amount=-4 +kerning first=96 second=181 amount=-4 +kerning first=96 second=182 amount=-4 +kerning first=96 second=185 amount=-4 +kerning first=96 second=186 amount=-4 +kerning first=96 second=187 amount=-4 +kerning first=96 second=188 amount=-4 +kerning first=96 second=189 amount=-4 +kerning first=96 second=190 amount=-4 +kerning first=96 second=215 amount=-4 +kerning first=96 second=247 amount=-4 +kerning first=45 second=55 amount=-2 diff --git a/CAAT/documentation/demos/demo-resources/img/hoppy.png b/CAAT/documentation/demos/demo-resources/img/hoppy.png new file mode 100644 index 0000000..a0195f1 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/hoppy.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/logo.png b/CAAT/documentation/demos/demo-resources/img/logo.png new file mode 100644 index 0000000..8fdbfac Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/logo.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/logo_big.png b/CAAT/documentation/demos/demo-resources/img/logo_big.png new file mode 100644 index 0000000..276ebfa Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/logo_big.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/map.json b/CAAT/documentation/demos/demo-resources/img/map.json new file mode 100644 index 0000000..97343e8 --- /dev/null +++ b/CAAT/documentation/demos/demo-resources/img/map.json @@ -0,0 +1,60 @@ +{"frames": { + +"font.png": +{ + "frame": {"x":2,"y":2,"w":1014,"h":844}, + "rotated": false, + "trimmed": true, + "spriteSourceSize": {"x":2,"y":1,"w":1014,"h":844}, + "sourceSize": {"w":1024,"h":1024} +}, +"info.png": +{ + "frame": {"x":433,"y":848,"w":126,"h":86}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":126,"h":86}, + "sourceSize": {"w":126,"h":86} +}, +"level.png": +{ + "frame": {"x":561,"y":848,"w":170,"h":77}, + "rotated": false, + "trimmed": true, + "spriteSourceSize": {"x":0,"y":0,"w":170,"h":77}, + "sourceSize": {"w":170,"h":81} +}, +"madewith.png": +{ + "frame": {"x":433,"y":936,"w":159,"h":83}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":159,"h":83}, + "sourceSize": {"w":159,"h":83} +}, +"nube1.png": +{ + "frame": {"x":234,"y":848,"w":197,"h":137}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":197,"h":137}, + "sourceSize": {"w":197,"h":137} +}, +"nube2.png": +{ + "frame": {"x":2,"y":848,"w":230,"h":150}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":230,"h":150}, + "sourceSize": {"w":230,"h":150} +}}, +"meta": { + "app": "http://www.codeandweb.com/texturepacker ", + "version": "1.0", + "image": "map.png", + "format": "RGBA8888", + "size": {"w":1024,"h":1024}, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:642f35ed72fb5b2d7903ed79e8dab930$" +} +} diff --git a/CAAT/documentation/demos/demo-resources/img/map.png b/CAAT/documentation/demos/demo-resources/img/map.png new file mode 100644 index 0000000..b69485b Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/map.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/naranja.png b/CAAT/documentation/demos/demo-resources/img/naranja.png new file mode 100644 index 0000000..fd6d63e Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/naranja.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/numbers.png b/CAAT/documentation/demos/demo-resources/img/numbers.png new file mode 100644 index 0000000..d4bec64 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/numbers.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/numerospuntos.png b/CAAT/documentation/demos/demo-resources/img/numerospuntos.png new file mode 100644 index 0000000..4aaf375 Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/numerospuntos.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/rugby.png b/CAAT/documentation/demos/demo-resources/img/rugby.png new file mode 100644 index 0000000..21895ce Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/rugby.png differ diff --git a/CAAT/documentation/demos/demo-resources/img/stars.png b/CAAT/documentation/demos/demo-resources/img/stars.png new file mode 100644 index 0000000..787ed7c Binary files /dev/null and b/CAAT/documentation/demos/demo-resources/img/stars.png differ diff --git a/CAAT/documentation/demos/demo1/path_org.html b/CAAT/documentation/demos/demo1/path_org.html new file mode 100644 index 0000000..6a8e2dd --- /dev/null +++ b/CAAT/documentation/demos/demo1/path_org.html @@ -0,0 +1,397 @@ + + + + + + CAAT example: Actors across a Path and Interpolators + + + + + + +
    + + +
    + +
    +
    +

    Path management

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Drag path handles.
    • +
    • Click on interpolators to traverse the path with different velocities.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Constructing a Path and adding segments to it.
    • +
    • Setting positional anchors.
    • +
    • What does a call to closePath means in opposition to endPath.
    • +
    • Showing a path by associating it to a PathActor.
    • +
    • Path management by calling setInteractive method.
    • +
    • CAAT.Interpolator on path behavior.
    • +
    • CompoundImage management.
    • +
    • SpriteActor definition.
    • +
    • Show interpolators by Wrapping them into InterpolatorActor.
    • +
    • Management of CAAT.Dock actor to elegantly show interpolators.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo10/Garden.js b/CAAT/documentation/demos/demo10/Garden.js new file mode 100644 index 0000000..746dca9 --- /dev/null +++ b/CAAT/documentation/demos/demo10/Garden.js @@ -0,0 +1,190 @@ +CAAT.Module({ + + defines:"HN.Garden", + depends:[ + "CAAT.Foundation.Actor", + "HN.Grass" + ], + extendsClass: "CAAT.Foundation.Actor", + extendsWith:function () { + + + return { + grass:null, + ambient:1, + stars:null, + firefly_radius:10, + num_fireflyes:40, + num_stars:512, + fireflyColor:[ '#ffff00', '#7fff00', '#c0c000' ], + backgroundEnabled:true, + + initialize:function (ctx, size, maxGrassHeight) { + this.grass = []; + + for (var i = 0; i < size; i++) { + var g = new HN.Grass(); + g.initialize( + this.width, + this.height, + 50, // min grass height + maxGrassHeight, // max grass height + 20, // grass max initial random angle + 40 // max random angle for animation + ); + this.grass.push(g); + } + + this.stars = []; + for (i = 0; i < this.num_stars; i++) { + this.stars.push(Math.floor(Math.random() * (this.width - 10) + 5)); + this.stars.push(Math.floor(Math.random() * (this.height - 10) + 5)); + } + + if (this.backgroundEnabled) { + this.lerp(ctx, 0, 2000); + } + + return this; + }, + paint:function (director, time) { + + + var ctx = director.ctx; + + if (this.backgroundEnabled) { + ctx.fillStyle = this.gradient; + ctx.fillRect(0, 0, this.width, this.height); + + // draw stars if ambient below .3 -> night + if (this.ambient < .3) { + + // modify stars translucency by ambient (as transitioning to day, make them dissapear). + ctx.globalAlpha = 1 - ((this.ambient - .05) / .25); + + // as well as making them dimmer + var intensity = 1 - (this.ambient / 2 - .05) / .25; + + // how white do you want the stars to be ?? + var c = Math.floor(192 * intensity); + var strc = 'rgb(' + c + ',' + c + ',' + c + ')'; + ctx.strokeStyle = strc; + + // first num_fireflyes coordinates are fireflyes themshelves. + for (var j = this.num_fireflyes * 2; j < this.stars.length; j += 2) { + var inc = 1; + if (j % 3 == 0) { + inc = 1.5; + } else if (j % 11 == 0) { + inc = 2.5; + } + this.stars[j] = (this.stars[j] + .1 * inc) % this.width; + + var y = this.stars[j + 1]; + ctx.strokeRect(this.stars[j], this.stars[j + 1], 1, 1); + + } + } + + ctx.globalAlpha = 1; + } + + // draw fireflyes + + for (var i = 0; i < this.num_fireflyes * 2; i += 2) { + ctx.fillStyle = this.fireflyColor[i % 3]; + var angle = Math.PI * 2 * Math.sin(time * 3E-4) + i * Math.PI / 50; + var radius = this.firefly_radius * Math.cos(time * 3E-4); + var fy = this.height - this.height * .3 + + .5 * this.stars[i + 1] + + 20 * Math.sin(time * 3E-4) + // move vertically with time + radius * Math.sin(angle); + + if (fy < director.height) { + ctx.beginPath(); + ctx.arc( + this.width / 2 + + .5 * this.stars[i] + + 150 * Math.cos(time * 3E-4) + // move horizontally with time + (radius + 20 * Math.cos((i % 5) * Math.PI / 3600)) * Math.cos(angle), + + fy, + + 2, + 0, + Math.PI * 2, + false); + ctx.fill(); + } + } + + for (var i = 0; i < this.grass.length; i++) { + this.grass[i].paint(ctx, time, this.ambient); + } + + + if (this.backgroundEnabled) { + // lerp. + if (time > this.nextLerpTime) { + this.lerpindex = Math.floor((time - this.nextLerpTime) / this.nextLerpTime); + if ((time - this.nextLerpTime) % this.nextLerpTime < this.lerpTime) { + this.lerp(ctx, (time - this.nextLerpTime) % this.nextLerpTime, this.lerpTime); + } + } + } + }, + + gradient:null, + lerpTime:10000, // time taken to fade sky colors + nextLerpTime:15000, // after fading, how much time to wait to fade colors again. + colors:[ + [ 0x00, 0x3f, 0x7f, //0x00, 0x00, 0x3f, + 0x00, 0x3f, 0x7f, + 0x1f, 0x5f, 0xc0, + 0x3f, 0xa0, 0xff ], + + [ 0x00, 0x3f, 0x7f, + 0xa0, 0x5f, 0x7f, + 0xff, 0x90, 0xe0, + 0xff, 0x90, 0x00 ], + + [ 0x00, 0x3f, 0x7f, //0x00, 0x00, 0x00, + 0x00, 0x2f, 0x7f, + 0x00, 0x28, 0x50, + 0x00, 0x1f, 0x3f ], + + [ 0x00, 0x3f, 0x7f, //0x1f, 0x00, 0x5f, + 0x3f, 0x2f, 0xa0, + 0xa0, 0x1f, 0x1f, + 0xff, 0x7f, 0x00 ] + ], + + ambients:[ 1, .35, .05, .5 ], // ambient intensities for each sky color + lerpindex:0, // start with this sky index. + + /** + * fade sky colors + */ + lerp:function (ctx, time, last) { + this.gradient = ctx.createLinearGradient(0, 0, 0, this.height); + + var i0 = this.lerpindex % this.colors.length; + var i1 = (this.lerpindex + 1) % this.colors.length; + + for (var i = 0; i < 4; i++) { + var rgb = 'rgb('; + for (var j = 0; j < 3; j++) { + rgb += Math.floor((this.colors[i1][i * 3 + j] - this.colors[i0][i * 3 + j]) * time / last + this.colors[i0][i * 3 + j]); + if (j < 2) rgb += ','; + } + rgb += ')'; + this.gradient.addColorStop(i / 3, rgb); + } + + this.ambient = (this.ambients[i1] - this.ambients[i0]) * time / last + this.ambients[i0]; + } + + } + + } +}); \ No newline at end of file diff --git a/CAAT/documentation/demos/demo10/Grass.js b/CAAT/documentation/demos/demo10/Grass.js new file mode 100644 index 0000000..9c323e4 --- /dev/null +++ b/CAAT/documentation/demos/demo10/Grass.js @@ -0,0 +1,82 @@ +CAAT.Module( { + defines : "HN.Grass", + extendsWith : { + + alto_hierba:0, // grass height + maxAngle:0, // maximum grass rotation angle (wind movement) + angle:0, // construction angle. thus, every grass is different to others + coords:null, // quadric bezier curves coordinates + color:null, // grass color. modified by ambient component. + offset_control_point:3, // grass base size. greater values, wider at the basement. + + + initialize:function (canvasWidth, canvasHeight, minHeight, maxHeight, angleMax, initialMaxAngle) { + + // grass start position + var sx = Math.floor(Math.random() * canvasWidth); + var sy = canvasHeight; + + var offset_control_x = 2; + + + this.alto_hierba = minHeight + Math.random() * maxHeight; + this.maxAngle = 10 + Math.random() * angleMax; + this.angle = Math.random() * initialMaxAngle * (Math.random() < .5 ? 1 : -1) * Math.PI / 180; + + // hand crafted value. modify offset_control_x to play with grass curvature slope. + var csx = sx - offset_control_x; + + // curvatura de la hierba. - menor, curva mas tiesa. +valor, hierba lacia. + // grass curvature. greater values make grass bender. + var csy = sy - this.alto_hierba / 2; + + var psx = csx; + var psy = csy; + + // the bigger offset_control_point, the wider on its basement. + this.offset_control_point = 10; + var dx = sx + this.offset_control_point; + var dy = sy; + + this.coords = [sx, sy, csx, csy, psx, psy, dx, dy]; + + // grass color. + this.color = [16 + Math.floor(Math.random() * 32), + 100 + Math.floor(Math.random() * 155), + 16 + Math.floor(Math.random() * 32) ]; + + }, + + /** + * paint every grass. + * @param ctx is the canvas2drendering context + * @param time for grass animation. + * @param ambient parameter to dim or brighten every grass. + * @returns nothing + */ + paint:function (ctx, time, ambient) { + // grass peak position. how much to rotate the peak. + // less values (ie the .0005), will make as if there were a softer wind. + var inc_punta_hierba = Math.sin(time * .0005); + + // rotate the point, so grass curves are modified accordingly. If just moved horizontally, the curbe would + // end by being unstable with undesired visuals. + var ang = this.angle + Math.PI / 2 + inc_punta_hierba * Math.PI / 180 * (this.maxAngle * Math.cos(time * .0002)); + var px = this.coords[0] + this.offset_control_point + this.alto_hierba * Math.cos(ang); + var py = this.coords[1] - this.alto_hierba * Math.sin(ang); + + ctx.beginPath(); + ctx.moveTo(this.coords[0], this.coords[1]); + ctx.bezierCurveTo(this.coords[0], this.coords[1], this.coords[2], this.coords[3], px, py); + + ctx.bezierCurveTo(px, py, this.coords[4], this.coords[5], this.coords[6], this.coords[7]); + ctx.closePath(); + ctx.fillStyle = 'rgb(' + + Math.floor(this.color[0] * ambient) + ',' + + Math.floor(this.color[1] * ambient) + ',' + + Math.floor(this.color[2] * ambient) + ')'; + ctx.fill(); + + } + } +}); diff --git a/CAAT/documentation/demos/demo10/garden_org.html b/CAAT/documentation/demos/demo10/garden_org.html new file mode 100644 index 0000000..349b83d --- /dev/null +++ b/CAAT/documentation/demos/demo10/garden_org.html @@ -0,0 +1,143 @@ + + + + + + CAAT example: Grass at breeze procedural Actors + + + + + + +
    + + +
    + +
    +
    +

    Grass at breeze procedural Actors

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Wrapping shapes into actors.
    • +
    • Managing Timers.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo11/PackedCircleScene.js b/CAAT/documentation/demos/demo11/PackedCircleScene.js new file mode 100644 index 0000000..1b4783d --- /dev/null +++ b/CAAT/documentation/demos/demo11/PackedCircleScene.js @@ -0,0 +1,152 @@ +CAAT.Module( { + defines : "Circles.PackedCircleScene", + depends : [ + "CAAT.Math.Point", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.UI.ShapeActor", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.AlphaBehavior", + "CAAT.Behavior.Interpolator", + "CAAT.Module.CircleManager.PackedCircleManager", + "CAAT.Module.CircleManager.PackedCircle", + "CAAT.Module.ColorUtil.Color" + ], + extendsWith : { + packedCirleManager:null, + director:null, + scene:null, + root:null, + mousePosition:null, + sineOffset:1212, // some arbitary number i liked + + initDirector:function (director) { + this.mousePosition = new CAAT.Math.Point(director.width / 2, director.height / 2); + this.director = director; + this.scene = director.createScene(); + this.root = new CAAT.Foundation.ActorContainer(). + setBounds(0, 0, director.width, director.height); + this.scene.addChild(this.root); + + // Collision simulation + this.packedCirleManager = new CAAT.Module.CircleManager.PackedCircleManager(); + this.packedCirleManager.setBounds(0, 0, director.width, director.height); + this.packedCirleManager.setNumberOfCollisionPasses(2); + this.packedCirleManager.setNumberOfTargetingPasses(1); + + // Create a bunch of circles! + var rgb = new CAAT.Module.ColorUtil.Color(0, 0, 0), + total = 75; + for (var i = 0; i < total; i++) { + // Size + var aRadius = Math.random() * 25 + 9; + + // color it + var hue = (360 - ((i / total) * 360) ), // HSV uses 0 - 360 + hex = new CAAT.Module.ColorUtil.Color.hsvToRgb(hue, 80, 99).toHex(); // Convert to hex value + + var circleActor = new CAAT.Foundation.UI.ShapeActor() + .setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE) + .setLocation(Math.random() * director.width, Math.random() * director.height) + .setSize(aRadius * 2, aRadius * 2)// Size is in diameters + .setFillStyle('#' + hex); + + + // The 'packedCircle' in the simulation is considered completely separate entity than the circleActor itself + var packedCircle = new CAAT.Module.CircleManager.PackedCircle() + .setDelegate(circleActor) + .setRadius(aRadius) + .setCollisionMask(1)// packedCircle instnace - will collide against this group + .setCollisionGroup(1)// packedCircle instance - is in this group + .setTargetPosition(this.mousePosition) + .setTargetChaseSpeed(Math.random() * 0.02); + + // disable mouse on specific circle + packedCircle.mouseEnabled = false; + + this.animateInUsingScale(circleActor, this.scene.time + Math.random() * 3000, 500, 0.1, 1); + + // Add to the collision simulation + this.packedCirleManager.addCircle(packedCircle); + + // Add actor to the scene + this.root.addChild(circleActor); + } + + // Force all packedCircles to move to the position of their delegates + this.packedCirleManager.forceCirclesToMatchDelegatePositions(); + + var me = this; + + this.root.mouseMove = function (mouseEvent) { + me.mousePosition.set(mouseEvent.x, mouseEvent.y); + }; + + this.scene.onRenderEnd = function (director, delta) { + + me.packedCirleManager.pushAllCirclesTowardTarget(); + me.packedCirleManager.handleCollisions(); + me.sineOffset += 0.01; + var circleList = me.packedCirleManager.allCircles, + len = circleList.length; + + // color it + var longestDistance = 40000 + Math.sin(me.sineOffset) * 30000; + if (longestDistance < 0) longestDistance *= -1; // abs + while (len--) { + var packedCircle = circleList[len]; + var circleActor = packedCircle.delegate; + var distanceFromTarget = packedCircle.position.getDistanceSquared(packedCircle.targetPosition); + if (distanceFromTarget > longestDistance) distanceFromTarget = longestDistance; + + var amplitude = (distanceFromTarget / longestDistance); + var hue = 360 - (amplitude * 95); + + circleActor.x = packedCircle.position.x - packedCircle.radius; + circleActor.y = packedCircle.position.y - packedCircle.radius; + // color + circleActor.setFillStyle('#' + CAAT.Module.ColorUtil.Color.hsvToRgb(hue, 95, 99).toHex()); + + // Here we are doing an interesting trick. + // By randomly changing the targetChaseSpeed +/- 0.002 randomly + // we introduce a seemingly complex hive behavior whereby certain circles + // seem to want to 'leave' sometimes, and others decide to force their way to the center more strongly + if (Math.random() < 0.2) + packedCircle.setTargetChaseSpeed(packedCircle.targetChaseSpeed + Math.random() * 0.004 - 0.002); + } + }; + }, + + /** + * Adds a CAAT.ScaleBehavior to the entity, used on animate in + */ + animateInUsingScale:function (actor, starTime, endTime, startScale, endScale) { + var scaleBehavior = new CAAT.Behavior.ScaleBehavior(); + scaleBehavior.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + actor.scaleX = actor.scaleY = scaleBehavior.startScaleX = scaleBehavior.startScaleY = startScale; // Fall from the 'sky' ! + scaleBehavior.endScaleX = scaleBehavior.endScaleY = endScale; + scaleBehavior.setFrameTime(starTime, starTime + endTime); + scaleBehavior.setCycle(false); + scaleBehavior.setInterpolator(new CAAT.Behavior.Interpolator().createBounceOutInterpolator(false)); + actor.addBehavior(scaleBehavior); + + return scaleBehavior; + }, + + /** + * Adds a CAAT.ScaleBehavior to the entity, used on animate in + */ + animateInUsingAlpha:function (actor, starTime, endTime, startAlpha, endAlpha) { + var fadeBehavior = new CAAT.Behavior.AlphaBehavior(); + + fadeBehavior.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + actor.alpha = fadeBehavior.startAlpha = startAlpha; + fadeBehavior.endAlpha = endAlpha; + fadeBehavior.setFrameTime(starTime, endTime); + fadeBehavior.setCycle(false); + fadeBehavior.setInterpolator(new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, false)); + actor.addBehavior(fadeBehavior); + + return fadeBehavior; + } + } +}); \ No newline at end of file diff --git a/CAAT/documentation/demos/demo11/circles_org.html b/CAAT/documentation/demos/demo11/circles_org.html new file mode 100644 index 0000000..29a955c --- /dev/null +++ b/CAAT/documentation/demos/demo11/circles_org.html @@ -0,0 +1,184 @@ + + + + + + CAAT example: Packed Circle - Collision detection + + + + + + +
    + + +
    + +
    +
    +

    Packed Circle Collision Detection

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Move your mouse over the experiment.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Usage of collision circular detection module.
    • +
    • Built-in color utils usage.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo12+1/transitions_org.html b/CAAT/documentation/demos/demo12+1/transitions_org.html new file mode 100644 index 0000000..d0ec4af --- /dev/null +++ b/CAAT/documentation/demos/demo12+1/transitions_org.html @@ -0,0 +1,247 @@ + + + + + + CAAT example: Scene Transitions + + + + + + +
    + + +
    + +
    +
    +

    Scene Transitions

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Scene transitions.
    • +
    • Show how events are disabled until the entering scene is in (finished transition)
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo12/box2d_org.html b/CAAT/documentation/demos/demo12/box2d_org.html new file mode 100644 index 0000000..5e456ca --- /dev/null +++ b/CAAT/documentation/demos/demo12/box2d_org.html @@ -0,0 +1,439 @@ + + + + + + CAAT example: Box2D integration + + + + + + +
    + + +
    + +
    +
    +

    CAAT & Box2D

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Mouse click to generate an impulse on screen Bodies.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Minimum integration of box2d and CAAT.
    • +
    • Edge and circular body definition.
    • +
    • Lifecycle of a CAAT actor and its box2d delegate.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo14/timers_org.html b/CAAT/documentation/demos/demo14/timers_org.html new file mode 100644 index 0000000..4716a66 --- /dev/null +++ b/CAAT/documentation/demos/demo14/timers_org.html @@ -0,0 +1,267 @@ + + + + + + CAAT example: Scene Timers + + + + + + +
    + + +
    + +
    +
    +

    Scene Timers

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Scene transitions.
    • +
    • Shows timers are per scene.
    • +
    • Resetting timers.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo15/logofrenzy_org.html b/CAAT/documentation/demos/demo15/logofrenzy_org.html new file mode 100644 index 0000000..0c14cd8 --- /dev/null +++ b/CAAT/documentation/demos/demo15/logofrenzy_org.html @@ -0,0 +1,220 @@ + + + + + + CAAT example: SpriteImage in action + + + + + + +
    + + +
    + +
    +
    +

    SpriteImage

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • SpriteImage optimum usage.
    • +
    • Adding PathBehaviors.
    • +
    • Correct CompoundBehavior usage.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo16/mask_org.html b/CAAT/documentation/demos/demo16/mask_org.html new file mode 100644 index 0000000..6ec74c2 --- /dev/null +++ b/CAAT/documentation/demos/demo16/mask_org.html @@ -0,0 +1,313 @@ + + + + + CAAT example: The Masked Fishpond + + + + + + +
    + + +
    + +
    +
    +

    Masking with arbitrary paths

    +
    +
    + +
    +
    +
    +

    + How to use: +

    +
      +
    • Click to select different clipping masks.
    • +
    + +

    + This demo features the following elements: +

    +
      +
    • Applying arbirtrary clip mask.
    • +
    • Apply mask behaviors (like in actors).
    • +
    • Define a path for mask traversing.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo17/video_org.html b/CAAT/documentation/demos/demo17/video_org.html new file mode 100644 index 0000000..ff8630c --- /dev/null +++ b/CAAT/documentation/demos/demo17/video_org.html @@ -0,0 +1,200 @@ + + + + + CAAT example: Video tag integration + + + + + + +
    + + +
    + +
    +
    +

    Video tag integration

    +
    +
    + +
    +
    +
    +

    + How to use: +

    +
      +
    • Move the mouse over the screen.
    • +
    + +

    + This demo features the following elements: +

    +
      +
    • Video tag integration.
    • +
    +
    +
    +
    +
    +
    + +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo18/keys_org.html b/CAAT/documentation/demos/demo18/keys_org.html new file mode 100644 index 0000000..f94e120 --- /dev/null +++ b/CAAT/documentation/demos/demo18/keys_org.html @@ -0,0 +1,260 @@ + + + + + + CAAT example: Keyboard management + + + + + + +
    + + +
    + +
    +
    +

    Keyboard management

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Use arrow keys to move elements across the screen.
    • +
    • Click on actors to select them.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Create events per frame. It is achieved by creating a 'forever' timer and setting a callback on timer tick.
    • +
    • Register a CAAT keyListener function.
    • +
    • Correctly interpret key events.
    • +
    +
    +
    +
    + + +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo19/collision.html b/CAAT/documentation/demos/demo19/collision.html new file mode 100644 index 0000000..b21349a --- /dev/null +++ b/CAAT/documentation/demos/demo19/collision.html @@ -0,0 +1,443 @@ + + + + + + CAAT example: Quadtree based collision detection + + + + + + +
    + + +
    + +
    +
    +

    Quadtree based collision detection

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Cursor keys.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Dirty-rectangles based canvas cleaning.
    • +
    • Built-in key events dispatch.
    • +
    • Multi key-press mechanishm.
    • +
    • Character movement in pixels/sec.
    • +
    • Built-in Quadtree usage.
    • +
    • Built-in Spatialhash usage.
    • +
    • Quadtree collision zone identification.
    • +
    • Spatial Hashmap collision zone identification.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo2/Fish.js b/CAAT/documentation/demos/demo2/Fish.js new file mode 100644 index 0000000..8eec9ee --- /dev/null +++ b/CAAT/documentation/demos/demo2/Fish.js @@ -0,0 +1,265 @@ +/** + * @license + * + * The MIT License + * Copyright (c) 2010-2011 Ibon Tolosana, Hyperandroid || http://labs.hyperandroid.com/ + + * 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. + * + */ + +CAAT.Module( { + defines : "CAAT.Procedural.Fish", + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + __init : function() { + this.__super(); + this.tail= []; + this.tail1= []; + this.tail2= []; + this.head1= []; + this.head2= []; + + return this; + }, + + tail: null, + tail1: null, + tail2: null, + head1: null, + head2: null, + maxAngle: 45, + bodyColor: 'red', + f1: 0, + f2: 0, + f3: 0, + f4: 0, + tailSize: 0, + timeOffset: 0, // para que las colas se muevan a distinta frecuencia. + headProportion: 0, // proporcion desde donde tiene la cabeza. + antihead: false, + + headStart: 0, + + setBodyColor : function(color) { + this.bodyColor= color; + return this; + }, + /** + * born method must be called after Actor complete definition. + */ + born : function() { + this.f1= ((Math.random()*2)>>0)/1000 + .002; + this.f2= ((Math.random()*2)>>0)/1000 + .002; + this.f3= ((Math.random()*5)>>0)/1000; + this.f4= ((Math.random()*5)>>0)/1000; + + this.tailSize= (Math.random()*3+2)>>0; + this.timeOffset= (Math.random()*10000); + + this.antihead= Math.random()<.25; + if ( this.antihead ) { + this.headProportion= Math.random()*.25+.65; + if ( this.headProportion<.8 ) { + this.headProportion=.8; + } + } else { + this.headProportion= Math.random()*.25+.6; + } + + this.maxAngle= 40+25*Math.random(); + + var w= this.width; + var h= this.height; + + var w2= w/2; + var h2= h/2; + + this.headStart= this.antihead ? w : w*this.headProportion; + + this.tail[0]= 0; + this.tail[1]= h2; + + + /////////////--------------- + + + + + // tail son 1 y 2 punto de control, y el ultimo punto de la cubica. + // ek primer punto fijo sera tail. + this.tail1[0]= w2; + this.tail1[1]= h2; + + this.tail1[2]= w2; + this.tail1[3]= 0; + + this.tail1[4]= this.headStart; + this.tail1[5]= 0; + + this.headpos= w; + if ( this.antihead ) { + this.headpos= w*this.headProportion; + } + + this.head1[0]= this.headpos; + this.head1[1]= 0; + this.head1[2]= this.headpos; + this.head1[3]= h2; + + this.head2[0]= this.headpos; + this.head2[1]= h; + this.head2[2]= this.headStart; + this.head2[3]= h; + + + this.tail2[0]= w2; + this.tail2[1]= h; + + this.tail2[2]= w2; + this.tail2[3]= h2; + + return this; + }, + paint : function(director, time) { + var ctx= director.ctx; + + time+= this.timeOffset; + + var w= this.width; + var h= this.height; + var w2= w/2; + var w4= w2/2; + var h2= h/2; + + + // .002 .003 + var ang= Math.cos(time*this.f1)*this.maxAngle*Math.sin(time*this.f2)*Math.PI/180; + var px= w4-w4*Math.cos(ang); + var py= w4*Math.sin(ang); + + this.tail[0]= px; + this.tail[1]= h2+ py; + + + var inc= -3*(Math.sin(time*.005)+Math.cos(time*.001))/2; + + this.tail1[0]= w4; + this.tail1[1]= h2+inc; + this.tail1[2]= w2; + this.tail1[3]= inc; + + + ///// curva de cabeza. + /* + this.tail1[5]= -inc; + this.head1[1]= -inc; + this.head1[3]= h2-inc; + this.head2[1]= h-inc; + this.head2[3]= h-inc; + */ + + this.tail2[0]= w2; + this.tail2[1]= h+inc; + this.tail2[2]= w4; + this.tail2[3]= h2+inc; + + + ctx.beginPath(); + ctx.fillStyle='orange'; + + //////////////////////////////////////////////// START ALETAS + aletaSize= h2; // ancho + var aletaHeight= 7; // alto aleta + var aletaWidth= 5; + var aletaPos= w*2/3 + aletaWidth; + + ctx.beginPath(); + ctx.moveTo( aletaPos, 2 ); + ctx.quadraticCurveTo( + aletaPos, -aletaHeight, + aletaPos-aletaSize, -aletaHeight-3*Math.sin(time*.002) ); + ctx.lineTo( aletaPos-aletaWidth, 2); + ctx.closePath(); + ctx.fill(); + ctx.beginPath(); + ctx.moveTo( aletaPos, h-2 ); + ctx.quadraticCurveTo( + aletaPos, h+aletaHeight, + aletaPos-aletaSize, h+aletaHeight-3*Math.cos(time*.002) ); + ctx.lineTo( aletaPos-aletaWidth, h-2 ); + ctx.closePath(); + ctx.fill(); + //////////////////////////////////////////////// END ALETAS + + //////////////////////////////////////////////// START BODY +/* + this.head1[3]= h2-inc ; + + // subir bajar cuerpo + this.tail1[5]= inc; + this.head2[3]= h+inc; +*/ + ctx.beginPath(); + ctx.moveTo( this.tail[0], this.tail[1] + this.tailSize ); + ctx.bezierCurveTo( + this.tail1[0], this.tail1[1], + this.tail1[2], this.tail1[3], + this.tail1[4], this.tail1[5] ); + ctx.quadraticCurveTo( + this.head1[0], this.head1[1], + this.head1[2], this.head1[3] + ); + ctx.quadraticCurveTo( + this.head2[0], this.head2[1], + this.head2[2], this.head2[3] + ); + ctx.bezierCurveTo( + this.tail2[0], this.tail2[1], + this.tail2[2], this.tail2[3], + this.tail[0], this.tail[1] - this.tailSize ); + ctx.closePath(); + ctx.fillStyle=this.bodyColor; + ctx.fill(); + ctx.strokeStyle=this.bodyColor; + ctx.stroke(); + //////////////////////////////////////////////// END BODY + + //////////////////////////////////////////////// START EYES + ctx.beginPath(); + ctx.fillStyle='black'; + var eyeradius= h2/6; + + if ( this.antihead ) { + ctx.arc(this.headpos-eyeradius*2, h2-h2/3, eyeradius, 0, 2*Math.PI, false ); + ctx.arc(this.headpos-eyeradius*2, h2+h2/3, eyeradius, 0, 2*Math.PI, false ); + + } else { + ctx.arc(w-w2/4, h2-h2/3, eyeradius, 0, 2*Math.PI, false ); + ctx.arc(w-w2/4, h2+h2/3, eyeradius, 0, 2*Math.PI, false ); + } + ctx.fill(); + //////////////////////////////////////////////// END EYES + } + } + +}); diff --git a/CAAT/documentation/demos/demo2/fishpond_org.html b/CAAT/documentation/demos/demo2/fishpond_org.html new file mode 100644 index 0000000..5c6decb --- /dev/null +++ b/CAAT/documentation/demos/demo2/fishpond_org.html @@ -0,0 +1,209 @@ + + + + + CAAT example: Procedural Actors, The Fishpond + + + + + + +
    + + +
    + +
    +
    +

    Procedural Fish Pond

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Path Behaviors.
    • +
    • Path Behavior lifecycle.
    • +
    • Gradient optimization by caching it as bitmap.
    • +
    • Generating procedural Actors
    • +
    • Avoid erasing the background since it's going to be overwritten by the background.
    • +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo20/Board.js b/CAAT/documentation/demos/demo20/Board.js new file mode 100644 index 0000000..eb45698 --- /dev/null +++ b/CAAT/documentation/demos/demo20/Board.js @@ -0,0 +1,197 @@ +CAAT.Module({ + + defines : "CAAT.FC.Board", + depends : [ + "CAAT.Foundation.Actor", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.UI.PathActor", + "CAAT.Behavior.PathBehavior", + "CAAT.PathUtil.Path", + "CAAT.Math.Point", + + "CAAT.FC.Ship" + ], + extendsClass : "CAAT.Foundation.ActorContainer", + extendsWith : { + + points : null, + inPlane : false, + currentPlane : null, + pathActor : null, + lx : null, + ly : null, + tl : null, + MT : 50, + DT : 20, + __index : 0, + + + create : function( director, scene ) { + + var me= this; + + this.setBounds(0,0,director.width,director.height); + scene.addChild( this ); + + this.pathActor= new CAAT.Foundation.UI.PathActor(). + setBounds(0,0,director.width,director.height). + enableEvents(false). + setInteractive(false); + + this.pathActor.paint= function( director, time ) { + CAAT.Foundation.UI.PathActor.prototype.paint.call(this,director,time); + + for( i=0; i>1; + this.addFlight( + Math.random() * director.width, + i + + + + + CAAT example: Path flattening and traversal + + + + + + +
    + + +
    + +
    +
    +

    Path flattening and traversal

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Drag moving rectangles and create a traversal path.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Advanced path techniques: flattening, and optimizing.
    • +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo21/tiles.png b/CAAT/documentation/demos/demo21/tiles.png new file mode 100644 index 0000000..d0c760b Binary files /dev/null and b/CAAT/documentation/demos/demo21/tiles.png differ diff --git a/CAAT/documentation/demos/demo21/vvv.html b/CAAT/documentation/demos/demo21/vvv.html new file mode 100644 index 0000000..850f0ad --- /dev/null +++ b/CAAT/documentation/demos/demo21/vvv.html @@ -0,0 +1,1315 @@ + + + + + + CAAT example: Tile maps + + + + +
    + + +
    + +
    +
    + +
    +
    + +
    +
    +
    +
    + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo22/multitouch.html b/CAAT/documentation/demos/demo22/multitouch.html new file mode 100644 index 0000000..4807daf --- /dev/null +++ b/CAAT/documentation/demos/demo22/multitouch.html @@ -0,0 +1,180 @@ + + + + + + CAAT example: Multitouch + + + + + + +
    + + +
    + +
    +
    +

    Multitouch

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Your fingers on a touch screen.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Enabling multitouch.
    • +
    • Managing multitouch events.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo23/actionTo.html b/CAAT/documentation/demos/demo23/actionTo.html new file mode 100644 index 0000000..73eafb3 --- /dev/null +++ b/CAAT/documentation/demos/demo23/actionTo.html @@ -0,0 +1,185 @@ + + + + + + CAAT example: Multitouch + + + + + + +
    + + +
    + +
    +
    +

    Action To : moveTo, rotateTo, scaleTo, scaleXTo, scaleYTo

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click on screen
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Calculate valid pointTo angle.
    • +
    • Define incremental affine transformations with moveTo and rotateTo.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/lion.js b/CAAT/documentation/demos/demo24/lion.js new file mode 100644 index 0000000..100c96b --- /dev/null +++ b/CAAT/documentation/demos/demo24/lion.js @@ -0,0 +1,3002 @@ +function lion(ctx) { +ctx.fillStyle='#f2cc99'; +ctx.beginPath(); +ctx.moveTo(69.000000,18.000000); + ctx.lineTo(82.000000,8.000000); + ctx.lineTo(99.000000,3.000000); + ctx.lineTo(118.000000,5.000000); + ctx.lineTo(135.000000,12.000000); + ctx.lineTo(149.000000,21.000000); + ctx.lineTo(156.000000,13.000000); + ctx.lineTo(165.000000,9.000000); + ctx.lineTo(177.000000,13.000000); + ctx.lineTo(183.000000,28.000000); + ctx.lineTo(180.000000,50.000000); + ctx.lineTo(164.000000,91.000000); + ctx.lineTo(155.000000,107.000000); + ctx.lineTo(154.000000,114.000000); + ctx.lineTo(151.000000,121.000000); + ctx.lineTo(141.000000,127.000000); + ctx.lineTo(139.000000,136.000000); + ctx.lineTo(155.000000,206.000000); + ctx.lineTo(157.000000,251.000000); + ctx.lineTo(126.000000,342.000000); + ctx.lineTo(133.000000,357.000000); + ctx.lineTo(128.000000,376.000000); + ctx.lineTo(83.000000,376.000000); + ctx.lineTo(75.000000,368.000000); + ctx.lineTo(67.000000,350.000000); + ctx.lineTo(61.000000,350.000000); + ctx.lineTo(53.000000,369.000000); + ctx.lineTo(4.000000,369.000000); + ctx.lineTo(2.000000,361.000000); + ctx.lineTo(5.000000,354.000000); + ctx.lineTo(12.000000,342.000000); + ctx.lineTo(16.000000,321.000000); + ctx.lineTo(4.000000,257.000000); + ctx.lineTo(4.000000,244.000000); + ctx.lineTo(7.000000,218.000000); + ctx.lineTo(9.000000,179.000000); + ctx.lineTo(26.000000,127.000000); + ctx.lineTo(43.000000,93.000000); + ctx.lineTo(32.000000,77.000000); + ctx.lineTo(30.000000,70.000000); + ctx.lineTo(24.000000,67.000000); + ctx.lineTo(16.000000,49.000000); + ctx.lineTo(17.000000,35.000000); + ctx.lineTo(18.000000,23.000000); + ctx.lineTo(30.000000,12.000000); + ctx.lineTo(40.000000,7.000000); + ctx.lineTo(53.000000,7.000000); + ctx.lineTo(62.000000,12.000000); + ctx.lineTo(69.000000,18.000000); +ctx.fill(); + + + + +ctx.fillStyle='#e5b27f'; +ctx.beginPath(); +ctx.moveTo(142.000000,79.000000); + ctx.lineTo(136.000000,74.000000); + ctx.lineTo(138.000000,82.000000); + ctx.lineTo(133.000000,78.000000); + ctx.lineTo(133.000000,84.000000); + ctx.lineTo(127.000000,78.000000); + ctx.lineTo(128.000000,85.000000); + ctx.lineTo(124.000000,80.000000); + ctx.lineTo(125.000000,87.000000); + ctx.lineTo(119.000000,82.000000); + ctx.lineTo(119.000000,90.000000); + ctx.lineTo(125.000000,99.000000); + ctx.lineTo(125.000000,96.000000); + ctx.lineTo(128.000000,100.000000); + ctx.lineTo(128.000000,94.000000); + ctx.lineTo(131.000000,98.000000); + ctx.lineTo(132.000000,93.000000); + ctx.lineTo(135.000000,97.000000); + ctx.lineTo(136.000000,93.000000); + ctx.lineTo(138.000000,97.000000); + ctx.lineTo(139.000000,94.000000); + ctx.lineTo(141.000000,98.000000); + ctx.lineTo(143.000000,94.000000); + ctx.lineTo(144.000000,85.000000); + ctx.lineTo(142.000000,79.000000); +ctx.fill(); + + + + +ctx.fillStyle='#eb8080'; +ctx.beginPath(); +ctx.moveTo(127.000000,101.000000); + ctx.lineTo(132.000000,100.000000); + ctx.lineTo(137.000000,99.000000); + ctx.lineTo(144.000000,101.000000); + ctx.lineTo(143.000000,105.000000); + ctx.lineTo(135.000000,110.000000); + ctx.lineTo(127.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#f2cc99'; +ctx.beginPath(); +ctx.moveTo(178.000000,229.000000); + ctx.lineTo(157.000000,248.000000); + ctx.lineTo(139.000000,296.000000); + ctx.lineTo(126.000000,349.000000); + ctx.lineTo(137.000000,356.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(183.000000,342.000000); + ctx.lineTo(212.000000,332.000000); + ctx.lineTo(235.000000,288.000000); + ctx.lineTo(235.000000,261.000000); + ctx.lineTo(228.000000,252.000000); + ctx.lineTo(212.000000,250.000000); + ctx.lineTo(188.000000,251.000000); + ctx.lineTo(178.000000,229.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(56.000000,229.000000); + ctx.lineTo(48.000000,241.000000); + ctx.lineTo(48.000000,250.000000); + ctx.lineTo(57.000000,281.000000); + ctx.lineTo(63.000000,325.000000); + ctx.lineTo(71.000000,338.000000); + ctx.lineTo(81.000000,315.000000); + ctx.lineTo(76.000000,321.000000); + ctx.lineTo(79.000000,311.000000); + ctx.lineTo(83.000000,301.000000); + ctx.lineTo(75.000000,308.000000); + ctx.lineTo(80.000000,298.000000); + ctx.lineTo(73.000000,303.000000); + ctx.lineTo(76.000000,296.000000); + ctx.lineTo(71.000000,298.000000); + ctx.lineTo(74.000000,292.000000); + ctx.lineTo(69.000000,293.000000); + ctx.lineTo(74.000000,284.000000); + ctx.lineTo(78.000000,278.000000); + ctx.lineTo(71.000000,278.000000); + ctx.lineTo(74.000000,274.000000); + ctx.lineTo(68.000000,273.000000); + ctx.lineTo(70.000000,268.000000); + ctx.lineTo(66.000000,267.000000); + ctx.lineTo(68.000000,261.000000); + ctx.lineTo(60.000000,266.000000); + ctx.lineTo(62.000000,259.000000); + ctx.lineTo(65.000000,253.000000); + ctx.lineTo(57.000000,258.000000); + ctx.lineTo(59.000000,251.000000); + ctx.lineTo(55.000000,254.000000); + ctx.lineTo(55.000000,248.000000); + ctx.lineTo(60.000000,237.000000); + ctx.lineTo(54.000000,240.000000); + ctx.lineTo(58.000000,234.000000); + ctx.lineTo(54.000000,236.000000); + ctx.lineTo(56.000000,229.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(74.000000,363.000000); + ctx.lineTo(79.000000,368.000000); + ctx.lineTo(81.000000,368.000000); + ctx.lineTo(85.000000,362.000000); + ctx.lineTo(89.000000,363.000000); + ctx.lineTo(92.000000,370.000000); + ctx.lineTo(96.000000,373.000000); + ctx.lineTo(101.000000,372.000000); + ctx.lineTo(108.000000,361.000000); + ctx.lineTo(110.000000,371.000000); + ctx.lineTo(113.000000,373.000000); + ctx.lineTo(116.000000,371.000000); + ctx.lineTo(120.000000,358.000000); + ctx.lineTo(122.000000,363.000000); + ctx.lineTo(123.000000,371.000000); + ctx.lineTo(126.000000,371.000000); + ctx.lineTo(129.000000,367.000000); + ctx.lineTo(132.000000,357.000000); + ctx.lineTo(135.000000,361.000000); + ctx.lineTo(130.000000,376.000000); + ctx.lineTo(127.000000,377.000000); + ctx.lineTo(94.000000,378.000000); + ctx.lineTo(84.000000,376.000000); + ctx.lineTo(76.000000,371.000000); + ctx.lineTo(74.000000,363.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(212.000000,250.000000); + ctx.lineTo(219.000000,251.000000); + ctx.lineTo(228.000000,258.000000); + ctx.lineTo(236.000000,270.000000); + ctx.lineTo(235.000000,287.000000); + ctx.lineTo(225.000000,304.000000); + ctx.lineTo(205.000000,332.000000); + ctx.lineTo(177.000000,343.000000); + ctx.lineTo(171.000000,352.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(166.000000,352.000000); + ctx.lineTo(168.000000,346.000000); + ctx.lineTo(168.000000,339.000000); + ctx.lineTo(165.000000,333.000000); + ctx.lineTo(155.000000,327.000000); + ctx.lineTo(155.000000,323.000000); + ctx.lineTo(161.000000,320.000000); + ctx.lineTo(165.000000,316.000000); + ctx.lineTo(169.000000,316.000000); + ctx.lineTo(167.000000,312.000000); + ctx.lineTo(171.000000,313.000000); + ctx.lineTo(168.000000,308.000000); + ctx.lineTo(173.000000,309.000000); + ctx.lineTo(170.000000,306.000000); + ctx.lineTo(177.000000,306.000000); + ctx.lineTo(175.000000,308.000000); + ctx.lineTo(177.000000,311.000000); + ctx.lineTo(174.000000,311.000000); + ctx.lineTo(176.000000,316.000000); + ctx.lineTo(171.000000,315.000000); + ctx.lineTo(174.000000,319.000000); + ctx.lineTo(168.000000,320.000000); + ctx.lineTo(168.000000,323.000000); + ctx.lineTo(175.000000,327.000000); + ctx.lineTo(179.000000,332.000000); + ctx.lineTo(183.000000,326.000000); + ctx.lineTo(184.000000,332.000000); + ctx.lineTo(189.000000,323.000000); + ctx.lineTo(190.000000,328.000000); + ctx.lineTo(194.000000,320.000000); + ctx.lineTo(194.000000,325.000000); + ctx.lineTo(199.000000,316.000000); + ctx.lineTo(201.000000,320.000000); + ctx.lineTo(204.000000,313.000000); + ctx.lineTo(206.000000,316.000000); + ctx.lineTo(208.000000,310.000000); + ctx.lineTo(211.000000,305.000000); + ctx.lineTo(219.000000,298.000000); + ctx.lineTo(226.000000,288.000000); + ctx.lineTo(229.000000,279.000000); + ctx.lineTo(228.000000,266.000000); + ctx.lineTo(224.000000,259.000000); + ctx.lineTo(217.000000,253.000000); + ctx.lineTo(212.000000,250.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(151.000000,205.000000); + ctx.lineTo(151.000000,238.000000); + ctx.lineTo(149.000000,252.000000); + ctx.lineTo(141.000000,268.000000); + ctx.lineTo(128.000000,282.000000); + ctx.lineTo(121.000000,301.000000); + ctx.lineTo(130.000000,300.000000); + ctx.lineTo(126.000000,313.000000); + ctx.lineTo(118.000000,324.000000); + ctx.lineTo(116.000000,337.000000); + ctx.lineTo(120.000000,346.000000); + ctx.lineTo(133.000000,352.000000); + ctx.lineTo(133.000000,340.000000); + ctx.lineTo(137.000000,333.000000); + ctx.lineTo(145.000000,329.000000); + ctx.lineTo(156.000000,327.000000); + ctx.lineTo(153.000000,319.000000); + ctx.lineTo(153.000000,291.000000); + ctx.lineTo(157.000000,271.000000); + ctx.lineTo(170.000000,259.000000); + ctx.lineTo(178.000000,277.000000); + ctx.lineTo(193.000000,250.000000); + ctx.lineTo(174.000000,216.000000); + ctx.lineTo(151.000000,205.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,127.000000); + ctx.lineTo(90.000000,142.000000); + ctx.lineTo(95.000000,155.000000); + ctx.lineTo(108.000000,164.000000); + ctx.lineTo(125.000000,167.000000); + ctx.lineTo(139.000000,175.000000); + ctx.lineTo(150.000000,206.000000); + ctx.lineTo(152.000000,191.000000); + ctx.lineTo(141.000000,140.000000); + ctx.lineTo(121.000000,148.000000); + ctx.lineTo(100.000000,136.000000); + ctx.lineTo(78.000000,127.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(21.000000,58.000000); + ctx.lineTo(35.000000,63.000000); + ctx.lineTo(38.000000,68.000000); + ctx.lineTo(32.000000,69.000000); + ctx.lineTo(42.000000,74.000000); + ctx.lineTo(40.000000,79.000000); + ctx.lineTo(47.000000,80.000000); + ctx.lineTo(54.000000,83.000000); + ctx.lineTo(45.000000,94.000000); + ctx.lineTo(34.000000,81.000000); + ctx.lineTo(32.000000,73.000000); + ctx.lineTo(24.000000,66.000000); + ctx.lineTo(21.000000,58.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(71.000000,34.000000); + ctx.lineTo(67.000000,34.000000); + ctx.lineTo(66.000000,27.000000); + ctx.lineTo(59.000000,24.000000); + ctx.lineTo(54.000000,17.000000); + ctx.lineTo(48.000000,17.000000); + ctx.lineTo(39.000000,22.000000); + ctx.lineTo(30.000000,26.000000); + ctx.lineTo(28.000000,31.000000); + ctx.lineTo(31.000000,39.000000); + ctx.lineTo(38.000000,46.000000); + ctx.lineTo(29.000000,45.000000); + ctx.lineTo(36.000000,54.000000); + ctx.lineTo(41.000000,61.000000); + ctx.lineTo(41.000000,70.000000); + ctx.lineTo(50.000000,69.000000); + ctx.lineTo(54.000000,71.000000); + ctx.lineTo(55.000000,58.000000); + ctx.lineTo(67.000000,52.000000); + ctx.lineTo(76.000000,43.000000); + ctx.lineTo(76.000000,39.000000); + ctx.lineTo(68.000000,44.000000); + ctx.lineTo(71.000000,34.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(139.000000,74.000000); + ctx.lineTo(141.000000,83.000000); + ctx.lineTo(143.000000,89.000000); + ctx.lineTo(144.000000,104.000000); + ctx.lineTo(148.000000,104.000000); + ctx.lineTo(155.000000,106.000000); + ctx.lineTo(154.000000,86.000000); + ctx.lineTo(157.000000,77.000000); + ctx.lineTo(155.000000,72.000000); + ctx.lineTo(150.000000,77.000000); + ctx.lineTo(144.000000,77.000000); + ctx.lineTo(139.000000,74.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(105.000000,44.000000); + ctx.lineTo(102.000000,53.000000); + ctx.lineTo(108.000000,58.000000); + ctx.lineTo(111.000000,62.000000); + ctx.lineTo(112.000000,55.000000); + ctx.lineTo(105.000000,44.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(141.000000,48.000000); + ctx.lineTo(141.000000,54.000000); + ctx.lineTo(144.000000,58.000000); + ctx.lineTo(139.000000,62.000000); + ctx.lineTo(137.000000,66.000000); + ctx.lineTo(136.000000,59.000000); + ctx.lineTo(137.000000,52.000000); + ctx.lineTo(141.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(98.000000,135.000000); + ctx.lineTo(104.000000,130.000000); + ctx.lineTo(105.000000,134.000000); + ctx.lineTo(108.000000,132.000000); + ctx.lineTo(108.000000,135.000000); + ctx.lineTo(112.000000,134.000000); + ctx.lineTo(113.000000,137.000000); + ctx.lineTo(116.000000,136.000000); + ctx.lineTo(116.000000,139.000000); + ctx.lineTo(119.000000,139.000000); + ctx.lineTo(124.000000,141.000000); + ctx.lineTo(128.000000,140.000000); + ctx.lineTo(133.000000,138.000000); + ctx.lineTo(140.000000,133.000000); + ctx.lineTo(139.000000,140.000000); + ctx.lineTo(126.000000,146.000000); + ctx.lineTo(104.000000,144.000000); + ctx.lineTo(98.000000,135.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(97.000000,116.000000); + ctx.lineTo(103.000000,119.000000); + ctx.lineTo(103.000000,116.000000); + ctx.lineTo(111.000000,118.000000); + ctx.lineTo(116.000000,117.000000); + ctx.lineTo(122.000000,114.000000); + ctx.lineTo(127.000000,107.000000); + ctx.lineTo(135.000000,111.000000); + ctx.lineTo(142.000000,107.000000); + ctx.lineTo(141.000000,114.000000); + ctx.lineTo(145.000000,118.000000); + ctx.lineTo(149.000000,121.000000); + ctx.lineTo(145.000000,125.000000); + ctx.lineTo(140.000000,124.000000); + ctx.lineTo(127.000000,121.000000); + ctx.lineTo(113.000000,125.000000); + ctx.lineTo(100.000000,124.000000); + ctx.lineTo(97.000000,116.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(147.000000,33.000000); + ctx.lineTo(152.000000,35.000000); + ctx.lineTo(157.000000,34.000000); + ctx.lineTo(153.000000,31.000000); + ctx.lineTo(160.000000,31.000000); + ctx.lineTo(156.000000,28.000000); + ctx.lineTo(161.000000,28.000000); + ctx.lineTo(159.000000,24.000000); + ctx.lineTo(163.000000,25.000000); + ctx.lineTo(163.000000,21.000000); + ctx.lineTo(165.000000,22.000000); + ctx.lineTo(170.000000,23.000000); + ctx.lineTo(167.000000,17.000000); + ctx.lineTo(172.000000,21.000000); + ctx.lineTo(174.000000,18.000000); + ctx.lineTo(175.000000,23.000000); + ctx.lineTo(176.000000,22.000000); + ctx.lineTo(177.000000,28.000000); + ctx.lineTo(177.000000,33.000000); + ctx.lineTo(174.000000,37.000000); + ctx.lineTo(176.000000,39.000000); + ctx.lineTo(174.000000,44.000000); + ctx.lineTo(171.000000,49.000000); + ctx.lineTo(168.000000,53.000000); + ctx.lineTo(164.000000,57.000000); + ctx.lineTo(159.000000,68.000000); + ctx.lineTo(156.000000,70.000000); + ctx.lineTo(154.000000,60.000000); + ctx.lineTo(150.000000,51.000000); + ctx.lineTo(146.000000,43.000000); + ctx.lineTo(144.000000,35.000000); + ctx.lineTo(147.000000,33.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(85.000000,72.000000); + ctx.lineTo(89.000000,74.000000); + ctx.lineTo(93.000000,75.000000); + ctx.lineTo(100.000000,76.000000); + ctx.lineTo(105.000000,75.000000); + ctx.lineTo(102.000000,79.000000); + ctx.lineTo(94.000000,79.000000); + ctx.lineTo(88.000000,76.000000); + ctx.lineTo(85.000000,72.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(86.000000,214.000000); + ctx.lineTo(79.000000,221.000000); + ctx.lineTo(76.000000,232.000000); + ctx.lineTo(82.000000,225.000000); + ctx.lineTo(78.000000,239.000000); + ctx.lineTo(82.000000,234.000000); + ctx.lineTo(78.000000,245.000000); + ctx.lineTo(81.000000,243.000000); + ctx.lineTo(79.000000,255.000000); + ctx.lineTo(84.000000,250.000000); + ctx.lineTo(84.000000,267.000000); + ctx.lineTo(87.000000,254.000000); + ctx.lineTo(90.000000,271.000000); + ctx.lineTo(90.000000,257.000000); + ctx.lineTo(95.000000,271.000000); + ctx.lineTo(93.000000,256.000000); + ctx.lineTo(95.000000,249.000000); + ctx.lineTo(92.000000,252.000000); + ctx.lineTo(93.000000,243.000000); + ctx.lineTo(89.000000,253.000000); + ctx.lineTo(89.000000,241.000000); + ctx.lineTo(86.000000,250.000000); + ctx.lineTo(87.000000,236.000000); + ctx.lineTo(83.000000,245.000000); + ctx.lineTo(87.000000,231.000000); + ctx.lineTo(82.000000,231.000000); + ctx.lineTo(90.000000,219.000000); + ctx.lineTo(84.000000,221.000000); + ctx.lineTo(86.000000,214.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffcc7f'; +ctx.beginPath(); +ctx.moveTo(93.000000,68.000000); + ctx.lineTo(96.000000,72.000000); + ctx.lineTo(100.000000,73.000000); + ctx.lineTo(106.000000,72.000000); + ctx.lineTo(108.000000,66.000000); + ctx.lineTo(105.000000,63.000000); + ctx.lineTo(100.000000,62.000000); + ctx.lineTo(93.000000,68.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffcc7f'; +ctx.beginPath(); +ctx.moveTo(144.000000,64.000000); + ctx.lineTo(142.000000,68.000000); + ctx.lineTo(142.000000,73.000000); + ctx.lineTo(146.000000,74.000000); + ctx.lineTo(150.000000,73.000000); + ctx.lineTo(154.000000,64.000000); + ctx.lineTo(149.000000,62.000000); + ctx.lineTo(144.000000,64.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(57.000000,91.000000); + ctx.lineTo(42.000000,111.000000); + ctx.lineTo(52.000000,105.000000); + ctx.lineTo(41.000000,117.000000); + ctx.lineTo(53.000000,112.000000); + ctx.lineTo(46.000000,120.000000); + ctx.lineTo(53.000000,116.000000); + ctx.lineTo(50.000000,124.000000); + ctx.lineTo(57.000000,119.000000); + ctx.lineTo(55.000000,127.000000); + ctx.lineTo(61.000000,122.000000); + ctx.lineTo(60.000000,130.000000); + ctx.lineTo(67.000000,126.000000); + ctx.lineTo(66.000000,134.000000); + ctx.lineTo(71.000000,129.000000); + ctx.lineTo(72.000000,136.000000); + ctx.lineTo(77.000000,130.000000); + ctx.lineTo(76.000000,137.000000); + ctx.lineTo(80.000000,133.000000); + ctx.lineTo(82.000000,138.000000); + ctx.lineTo(86.000000,135.000000); + ctx.lineTo(96.000000,135.000000); + ctx.lineTo(94.000000,129.000000); + ctx.lineTo(86.000000,124.000000); + ctx.lineTo(83.000000,117.000000); + ctx.lineTo(77.000000,123.000000); + ctx.lineTo(79.000000,117.000000); + ctx.lineTo(73.000000,120.000000); + ctx.lineTo(75.000000,112.000000); + ctx.lineTo(68.000000,116.000000); + ctx.lineTo(71.000000,111.000000); + ctx.lineTo(65.000000,114.000000); + ctx.lineTo(69.000000,107.000000); + ctx.lineTo(63.000000,110.000000); + ctx.lineTo(68.000000,102.000000); + ctx.lineTo(61.000000,107.000000); + ctx.lineTo(66.000000,98.000000); + ctx.lineTo(61.000000,103.000000); + ctx.lineTo(63.000000,97.000000); + ctx.lineTo(57.000000,99.000000); + ctx.lineTo(57.000000,91.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(83.000000,79.000000); + ctx.lineTo(76.000000,79.000000); + ctx.lineTo(67.000000,82.000000); + ctx.lineTo(75.000000,83.000000); + ctx.lineTo(65.000000,88.000000); + ctx.lineTo(76.000000,87.000000); + ctx.lineTo(65.000000,92.000000); + ctx.lineTo(76.000000,91.000000); + ctx.lineTo(68.000000,96.000000); + ctx.lineTo(77.000000,95.000000); + ctx.lineTo(70.000000,99.000000); + ctx.lineTo(80.000000,98.000000); + ctx.lineTo(72.000000,104.000000); + ctx.lineTo(80.000000,102.000000); + ctx.lineTo(76.000000,108.000000); + ctx.lineTo(85.000000,103.000000); + ctx.lineTo(92.000000,101.000000); + ctx.lineTo(87.000000,98.000000); + ctx.lineTo(93.000000,96.000000); + ctx.lineTo(86.000000,94.000000); + ctx.lineTo(91.000000,93.000000); + ctx.lineTo(85.000000,91.000000); + ctx.lineTo(93.000000,89.000000); + ctx.lineTo(99.000000,89.000000); + ctx.lineTo(105.000000,93.000000); + ctx.lineTo(107.000000,85.000000); + ctx.lineTo(102.000000,82.000000); + ctx.lineTo(92.000000,80.000000); + ctx.lineTo(83.000000,79.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(109.000000,77.000000); + ctx.lineTo(111.000000,83.000000); + ctx.lineTo(109.000000,89.000000); + ctx.lineTo(113.000000,94.000000); + ctx.lineTo(117.000000,90.000000); + ctx.lineTo(117.000000,81.000000); + ctx.lineTo(114.000000,78.000000); + ctx.lineTo(109.000000,77.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(122.000000,128.000000); + ctx.lineTo(127.000000,126.000000); + ctx.lineTo(134.000000,127.000000); + ctx.lineTo(136.000000,129.000000); + ctx.lineTo(134.000000,130.000000); + ctx.lineTo(130.000000,128.000000); + ctx.lineTo(124.000000,129.000000); + ctx.lineTo(122.000000,128.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,27.000000); + ctx.lineTo(82.000000,32.000000); + ctx.lineTo(80.000000,33.000000); + ctx.lineTo(82.000000,36.000000); + ctx.lineTo(78.000000,37.000000); + ctx.lineTo(82.000000,40.000000); + ctx.lineTo(78.000000,42.000000); + ctx.lineTo(81.000000,46.000000); + ctx.lineTo(76.000000,47.000000); + ctx.lineTo(78.000000,49.000000); + ctx.lineTo(74.000000,50.000000); + ctx.lineTo(82.000000,52.000000); + ctx.lineTo(87.000000,50.000000); + ctx.lineTo(83.000000,48.000000); + ctx.lineTo(91.000000,46.000000); + ctx.lineTo(86.000000,45.000000); + ctx.lineTo(91.000000,42.000000); + ctx.lineTo(88.000000,40.000000); + ctx.lineTo(92.000000,37.000000); + ctx.lineTo(86.000000,34.000000); + ctx.lineTo(90.000000,31.000000); + ctx.lineTo(86.000000,29.000000); + ctx.lineTo(89.000000,26.000000); + ctx.lineTo(78.000000,27.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(82.000000,17.000000); + ctx.lineTo(92.000000,20.000000); + ctx.lineTo(79.000000,21.000000); + ctx.lineTo(90.000000,25.000000); + ctx.lineTo(81.000000,25.000000); + ctx.lineTo(94.000000,28.000000); + ctx.lineTo(93.000000,26.000000); + ctx.lineTo(101.000000,30.000000); + ctx.lineTo(101.000000,26.000000); + ctx.lineTo(107.000000,33.000000); + ctx.lineTo(108.000000,28.000000); + ctx.lineTo(111.000000,40.000000); + ctx.lineTo(113.000000,34.000000); + ctx.lineTo(115.000000,45.000000); + ctx.lineTo(117.000000,39.000000); + ctx.lineTo(119.000000,54.000000); + ctx.lineTo(121.000000,46.000000); + ctx.lineTo(124.000000,58.000000); + ctx.lineTo(126.000000,47.000000); + ctx.lineTo(129.000000,59.000000); + ctx.lineTo(130.000000,49.000000); + ctx.lineTo(134.000000,58.000000); + ctx.lineTo(133.000000,44.000000); + ctx.lineTo(137.000000,48.000000); + ctx.lineTo(133.000000,37.000000); + ctx.lineTo(137.000000,40.000000); + ctx.lineTo(133.000000,32.000000); + ctx.lineTo(126.000000,20.000000); + ctx.lineTo(135.000000,26.000000); + ctx.lineTo(132.000000,19.000000); + ctx.lineTo(138.000000,23.000000); + ctx.lineTo(135.000000,17.000000); + ctx.lineTo(142.000000,18.000000); + ctx.lineTo(132.000000,11.000000); + ctx.lineTo(116.000000,6.000000); + ctx.lineTo(94.000000,6.000000); + ctx.lineTo(78.000000,11.000000); + ctx.lineTo(92.000000,12.000000); + ctx.lineTo(80.000000,14.000000); + ctx.lineTo(90.000000,16.000000); + ctx.lineTo(82.000000,17.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(142.000000,234.000000); + ctx.lineTo(132.000000,227.000000); + ctx.lineTo(124.000000,223.000000); + ctx.lineTo(115.000000,220.000000); + ctx.lineTo(110.000000,225.000000); + ctx.lineTo(118.000000,224.000000); + ctx.lineTo(127.000000,229.000000); + ctx.lineTo(135.000000,236.000000); + ctx.lineTo(122.000000,234.000000); + ctx.lineTo(115.000000,237.000000); + ctx.lineTo(113.000000,242.000000); + ctx.lineTo(121.000000,238.000000); + ctx.lineTo(139.000000,243.000000); + ctx.lineTo(121.000000,245.000000); + ctx.lineTo(111.000000,254.000000); + ctx.lineTo(95.000000,254.000000); + ctx.lineTo(102.000000,244.000000); + ctx.lineTo(104.000000,235.000000); + ctx.lineTo(110.000000,229.000000); + ctx.lineTo(100.000000,231.000000); + ctx.lineTo(104.000000,224.000000); + ctx.lineTo(113.000000,216.000000); + ctx.lineTo(122.000000,215.000000); + ctx.lineTo(132.000000,217.000000); + ctx.lineTo(141.000000,224.000000); + ctx.lineTo(145.000000,230.000000); + ctx.lineTo(149.000000,240.000000); + ctx.lineTo(142.000000,234.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(115.000000,252.000000); + ctx.lineTo(125.000000,248.000000); + ctx.lineTo(137.000000,249.000000); + ctx.lineTo(143.000000,258.000000); + ctx.lineTo(134.000000,255.000000); + ctx.lineTo(125.000000,254.000000); + ctx.lineTo(115.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(114.000000,212.000000); + ctx.lineTo(130.000000,213.000000); + ctx.lineTo(140.000000,219.000000); + ctx.lineTo(147.000000,225.000000); + ctx.lineTo(144.000000,214.000000); + ctx.lineTo(137.000000,209.000000); + ctx.lineTo(128.000000,207.000000); + ctx.lineTo(114.000000,212.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(102.000000,263.000000); + ctx.lineTo(108.000000,258.000000); + ctx.lineTo(117.000000,257.000000); + ctx.lineTo(131.000000,258.000000); + ctx.lineTo(116.000000,260.000000); + ctx.lineTo(109.000000,265.000000); + ctx.lineTo(102.000000,263.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(51.000000,241.000000); + ctx.lineTo(35.000000,224.000000); + ctx.lineTo(40.000000,238.000000); + ctx.lineTo(23.000000,224.000000); + ctx.lineTo(31.000000,242.000000); + ctx.lineTo(19.000000,239.000000); + ctx.lineTo(28.000000,247.000000); + ctx.lineTo(17.000000,246.000000); + ctx.lineTo(25.000000,250.000000); + ctx.lineTo(37.000000,254.000000); + ctx.lineTo(39.000000,263.000000); + ctx.lineTo(44.000000,271.000000); + ctx.lineTo(47.000000,294.000000); + ctx.lineTo(48.000000,317.000000); + ctx.lineTo(51.000000,328.000000); + ctx.lineTo(60.000000,351.000000); + ctx.lineTo(60.000000,323.000000); + ctx.lineTo(53.000000,262.000000); + ctx.lineTo(47.000000,246.000000); + ctx.lineTo(51.000000,241.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(2.000000,364.000000); + ctx.lineTo(9.000000,367.000000); + ctx.lineTo(14.000000,366.000000); + ctx.lineTo(18.000000,355.000000); + ctx.lineTo(20.000000,364.000000); + ctx.lineTo(26.000000,366.000000); + ctx.lineTo(31.000000,357.000000); + ctx.lineTo(35.000000,364.000000); + ctx.lineTo(39.000000,364.000000); + ctx.lineTo(42.000000,357.000000); + ctx.lineTo(47.000000,363.000000); + ctx.lineTo(53.000000,360.000000); + ctx.lineTo(59.000000,357.000000); + ctx.lineTo(54.000000,369.000000); + ctx.lineTo(7.000000,373.000000); + ctx.lineTo(2.000000,364.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(7.000000,349.000000); + ctx.lineTo(19.000000,345.000000); + ctx.lineTo(25.000000,339.000000); + ctx.lineTo(18.000000,341.000000); + ctx.lineTo(23.000000,333.000000); + ctx.lineTo(28.000000,326.000000); + ctx.lineTo(23.000000,326.000000); + ctx.lineTo(27.000000,320.000000); + ctx.lineTo(23.000000,316.000000); + ctx.lineTo(25.000000,311.000000); + ctx.lineTo(20.000000,298.000000); + ctx.lineTo(15.000000,277.000000); + ctx.lineTo(12.000000,264.000000); + ctx.lineTo(9.000000,249.000000); + ctx.lineTo(10.000000,223.000000); + ctx.lineTo(3.000000,248.000000); + ctx.lineTo(5.000000,261.000000); + ctx.lineTo(15.000000,307.000000); + ctx.lineTo(17.000000,326.000000); + ctx.lineTo(11.000000,343.000000); + ctx.lineTo(7.000000,349.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(11.000000,226.000000); + ctx.lineTo(15.000000,231.000000); + ctx.lineTo(25.000000,236.000000); + ctx.lineTo(18.000000,227.000000); + ctx.lineTo(11.000000,226.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(13.000000,214.000000); + ctx.lineTo(19.000000,217.000000); + ctx.lineTo(32.000000,227.000000); + ctx.lineTo(23.000000,214.000000); + ctx.lineTo(16.000000,208.000000); + ctx.lineTo(15.000000,190.000000); + ctx.lineTo(24.000000,148.000000); + ctx.lineTo(31.000000,121.000000); + ctx.lineTo(24.000000,137.000000); + ctx.lineTo(14.000000,170.000000); + ctx.lineTo(8.000000,189.000000); + ctx.lineTo(13.000000,214.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(202.000000,254.000000); + ctx.lineTo(195.000000,258.000000); + ctx.lineTo(199.000000,260.000000); + ctx.lineTo(193.000000,263.000000); + ctx.lineTo(197.000000,263.000000); + ctx.lineTo(190.000000,268.000000); + ctx.lineTo(196.000000,268.000000); + ctx.lineTo(191.000000,273.000000); + ctx.lineTo(188.000000,282.000000); + ctx.lineTo(200.000000,272.000000); + ctx.lineTo(194.000000,272.000000); + ctx.lineTo(201.000000,266.000000); + ctx.lineTo(197.000000,265.000000); + ctx.lineTo(204.000000,262.000000); + ctx.lineTo(200.000000,258.000000); + ctx.lineTo(204.000000,256.000000); + ctx.lineTo(202.000000,254.000000); +ctx.fill(); + + + + +ctx.fillStyle='#845433'; +ctx.beginPath(); +ctx.moveTo(151.000000,213.000000); + ctx.lineTo(165.000000,212.000000); + ctx.lineTo(179.000000,225.000000); + ctx.lineTo(189.000000,246.000000); + ctx.lineTo(187.000000,262.000000); + ctx.lineTo(179.000000,275.000000); + ctx.lineTo(176.000000,263.000000); + ctx.lineTo(177.000000,247.000000); + ctx.lineTo(171.000000,233.000000); + ctx.lineTo(163.000000,230.000000); + ctx.lineTo(165.000000,251.000000); + ctx.lineTo(157.000000,264.000000); + ctx.lineTo(146.000000,298.000000); + ctx.lineTo(145.000000,321.000000); + ctx.lineTo(133.000000,326.000000); + ctx.lineTo(143.000000,285.000000); + ctx.lineTo(154.000000,260.000000); + ctx.lineTo(153.000000,240.000000); + ctx.lineTo(151.000000,213.000000); +ctx.fill(); + + + + +ctx.fillStyle='#845433'; +ctx.beginPath(); +ctx.moveTo(91.000000,132.000000); + ctx.lineTo(95.000000,145.000000); + ctx.lineTo(97.000000,154.000000); + ctx.lineTo(104.000000,148.000000); + ctx.lineTo(107.000000,155.000000); + ctx.lineTo(109.000000,150.000000); + ctx.lineTo(111.000000,158.000000); + ctx.lineTo(115.000000,152.000000); + ctx.lineTo(118.000000,159.000000); + ctx.lineTo(120.000000,153.000000); + ctx.lineTo(125.000000,161.000000); + ctx.lineTo(126.000000,155.000000); + ctx.lineTo(133.000000,164.000000); + ctx.lineTo(132.000000,154.000000); + ctx.lineTo(137.000000,163.000000); + ctx.lineTo(137.000000,152.000000); + ctx.lineTo(142.000000,163.000000); + ctx.lineTo(147.000000,186.000000); + ctx.lineTo(152.000000,192.000000); + ctx.lineTo(148.000000,167.000000); + ctx.lineTo(141.000000,143.000000); + ctx.lineTo(124.000000,145.000000); + ctx.lineTo(105.000000,143.000000); + ctx.lineTo(91.000000,132.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(31.000000,57.000000); + ctx.lineTo(23.000000,52.000000); + ctx.lineTo(26.000000,51.000000); + ctx.lineTo(20.000000,44.000000); + ctx.lineTo(23.000000,42.000000); + ctx.lineTo(21.000000,36.000000); + ctx.lineTo(22.000000,29.000000); + ctx.lineTo(25.000000,23.000000); + ctx.lineTo(24.000000,32.000000); + ctx.lineTo(30.000000,43.000000); + ctx.lineTo(26.000000,41.000000); + ctx.lineTo(30.000000,50.000000); + ctx.lineTo(26.000000,48.000000); + ctx.lineTo(31.000000,57.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(147.000000,21.000000); + ctx.lineTo(149.000000,28.000000); + ctx.lineTo(155.000000,21.000000); + ctx.lineTo(161.000000,16.000000); + ctx.lineTo(167.000000,14.000000); + ctx.lineTo(175.000000,15.000000); + ctx.lineTo(173.000000,11.000000); + ctx.lineTo(161.000000,9.000000); + ctx.lineTo(147.000000,21.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(181.000000,39.000000); + ctx.lineTo(175.000000,51.000000); + ctx.lineTo(169.000000,57.000000); + ctx.lineTo(171.000000,65.000000); + ctx.lineTo(165.000000,68.000000); + ctx.lineTo(165.000000,75.000000); + ctx.lineTo(160.000000,76.000000); + ctx.lineTo(162.000000,91.000000); + ctx.lineTo(171.000000,71.000000); + ctx.lineTo(180.000000,51.000000); + ctx.lineTo(181.000000,39.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(132.000000,346.000000); + ctx.lineTo(139.000000,348.000000); + ctx.lineTo(141.000000,346.000000); + ctx.lineTo(142.000000,341.000000); + ctx.lineTo(147.000000,342.000000); + ctx.lineTo(143.000000,355.000000); + ctx.lineTo(133.000000,350.000000); + ctx.lineTo(132.000000,346.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(146.000000,355.000000); + ctx.lineTo(151.000000,352.000000); + ctx.lineTo(155.000000,348.000000); + ctx.lineTo(157.000000,343.000000); + ctx.lineTo(160.000000,349.000000); + ctx.lineTo(151.000000,356.000000); + ctx.lineTo(147.000000,357.000000); + ctx.lineTo(146.000000,355.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(99.000000,266.000000); + ctx.lineTo(100.000000,281.000000); + ctx.lineTo(94.000000,305.000000); + ctx.lineTo(86.000000,322.000000); + ctx.lineTo(78.000000,332.000000); + ctx.lineTo(72.000000,346.000000); + ctx.lineTo(73.000000,331.000000); + ctx.lineTo(91.000000,291.000000); + ctx.lineTo(99.000000,266.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(20.000000,347.000000); + ctx.lineTo(32.000000,342.000000); + ctx.lineTo(45.000000,340.000000); + ctx.lineTo(54.000000,345.000000); + ctx.lineTo(45.000000,350.000000); + ctx.lineTo(42.000000,353.000000); + ctx.lineTo(38.000000,350.000000); + ctx.lineTo(31.000000,353.000000); + ctx.lineTo(29.000000,356.000000); + ctx.lineTo(23.000000,350.000000); + ctx.lineTo(19.000000,353.000000); + ctx.lineTo(15.000000,349.000000); + ctx.lineTo(20.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,344.000000); + ctx.lineTo(86.000000,344.000000); + ctx.lineTo(92.000000,349.000000); + ctx.lineTo(88.000000,358.000000); + ctx.lineTo(84.000000,352.000000); + ctx.lineTo(78.000000,344.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(93.000000,347.000000); + ctx.lineTo(104.000000,344.000000); + ctx.lineTo(117.000000,345.000000); + ctx.lineTo(124.000000,354.000000); + ctx.lineTo(121.000000,357.000000); + ctx.lineTo(116.000000,351.000000); + ctx.lineTo(112.000000,351.000000); + ctx.lineTo(108.000000,355.000000); + ctx.lineTo(102.000000,351.000000); + ctx.lineTo(93.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(105.000000,12.000000); + ctx.lineTo(111.000000,18.000000); + ctx.lineTo(113.000000,24.000000); + ctx.lineTo(113.000000,29.000000); + ctx.lineTo(119.000000,34.000000); + ctx.lineTo(116.000000,23.000000); + ctx.lineTo(112.000000,16.000000); + ctx.lineTo(105.000000,12.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(122.000000,27.000000); + ctx.lineTo(125.000000,34.000000); + ctx.lineTo(127.000000,43.000000); + ctx.lineTo(128.000000,34.000000); + ctx.lineTo(125.000000,29.000000); + ctx.lineTo(122.000000,27.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(115.000000,13.000000); + ctx.lineTo(122.000000,19.000000); + ctx.lineTo(122.000000,15.000000); + ctx.lineTo(113.000000,10.000000); + ctx.lineTo(115.000000,13.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(116.000000,172.000000); + ctx.lineTo(107.000000,182.000000); + ctx.lineTo(98.000000,193.000000); + ctx.lineTo(98.000000,183.000000); + ctx.lineTo(90.000000,199.000000); + ctx.lineTo(89.000000,189.000000); + ctx.lineTo(84.000000,207.000000); + ctx.lineTo(88.000000,206.000000); + ctx.lineTo(87.000000,215.000000); + ctx.lineTo(95.000000,206.000000); + ctx.lineTo(93.000000,219.000000); + ctx.lineTo(91.000000,230.000000); + ctx.lineTo(98.000000,216.000000); + ctx.lineTo(97.000000,226.000000); + ctx.lineTo(104.000000,214.000000); + ctx.lineTo(112.000000,209.000000); + ctx.lineTo(104.000000,208.000000); + ctx.lineTo(113.000000,202.000000); + ctx.lineTo(126.000000,200.000000); + ctx.lineTo(139.000000,207.000000); + ctx.lineTo(132.000000,198.000000); + ctx.lineTo(142.000000,203.000000); + ctx.lineTo(134.000000,192.000000); + ctx.lineTo(142.000000,195.000000); + ctx.lineTo(134.000000,187.000000); + ctx.lineTo(140.000000,185.000000); + ctx.lineTo(130.000000,181.000000); + ctx.lineTo(136.000000,177.000000); + ctx.lineTo(126.000000,177.000000); + ctx.lineTo(125.000000,171.000000); + ctx.lineTo(116.000000,180.000000); + ctx.lineTo(116.000000,172.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(74.000000,220.000000); + ctx.lineTo(67.000000,230.000000); + ctx.lineTo(67.000000,221.000000); + ctx.lineTo(59.000000,235.000000); + ctx.lineTo(63.000000,233.000000); + ctx.lineTo(60.000000,248.000000); + ctx.lineTo(70.000000,232.000000); + ctx.lineTo(65.000000,249.000000); + ctx.lineTo(71.000000,243.000000); + ctx.lineTo(67.000000,256.000000); + ctx.lineTo(73.000000,250.000000); + ctx.lineTo(69.000000,262.000000); + ctx.lineTo(73.000000,259.000000); + ctx.lineTo(71.000000,267.000000); + ctx.lineTo(76.000000,262.000000); + ctx.lineTo(72.000000,271.000000); + ctx.lineTo(78.000000,270.000000); + ctx.lineTo(76.000000,275.000000); + ctx.lineTo(82.000000,274.000000); + ctx.lineTo(78.000000,290.000000); + ctx.lineTo(86.000000,279.000000); + ctx.lineTo(86.000000,289.000000); + ctx.lineTo(92.000000,274.000000); + ctx.lineTo(88.000000,275.000000); + ctx.lineTo(87.000000,264.000000); + ctx.lineTo(82.000000,270.000000); + ctx.lineTo(82.000000,258.000000); + ctx.lineTo(77.000000,257.000000); + ctx.lineTo(78.000000,247.000000); + ctx.lineTo(73.000000,246.000000); + ctx.lineTo(77.000000,233.000000); + ctx.lineTo(72.000000,236.000000); + ctx.lineTo(74.000000,220.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(133.000000,230.000000); + ctx.lineTo(147.000000,242.000000); + ctx.lineTo(148.000000,250.000000); + ctx.lineTo(145.000000,254.000000); + ctx.lineTo(138.000000,247.000000); + ctx.lineTo(129.000000,246.000000); + ctx.lineTo(142.000000,245.000000); + ctx.lineTo(138.000000,241.000000); + ctx.lineTo(128.000000,237.000000); + ctx.lineTo(137.000000,238.000000); + ctx.lineTo(133.000000,230.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(133.000000,261.000000); + ctx.lineTo(125.000000,261.000000); + ctx.lineTo(116.000000,263.000000); + ctx.lineTo(111.000000,267.000000); + ctx.lineTo(125.000000,265.000000); + ctx.lineTo(133.000000,261.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(121.000000,271.000000); + ctx.lineTo(109.000000,273.000000); + ctx.lineTo(103.000000,279.000000); + ctx.lineTo(99.000000,305.000000); + ctx.lineTo(92.000000,316.000000); + ctx.lineTo(85.000000,327.000000); + ctx.lineTo(83.000000,335.000000); + ctx.lineTo(89.000000,340.000000); + ctx.lineTo(97.000000,341.000000); + ctx.lineTo(94.000000,336.000000); + ctx.lineTo(101.000000,336.000000); + ctx.lineTo(96.000000,331.000000); + ctx.lineTo(103.000000,330.000000); + ctx.lineTo(97.000000,327.000000); + ctx.lineTo(108.000000,325.000000); + ctx.lineTo(99.000000,322.000000); + ctx.lineTo(109.000000,321.000000); + ctx.lineTo(100.000000,318.000000); + ctx.lineTo(110.000000,317.000000); + ctx.lineTo(105.000000,314.000000); + ctx.lineTo(110.000000,312.000000); + ctx.lineTo(107.000000,310.000000); + ctx.lineTo(113.000000,308.000000); + ctx.lineTo(105.000000,306.000000); + ctx.lineTo(114.000000,303.000000); + ctx.lineTo(105.000000,301.000000); + ctx.lineTo(115.000000,298.000000); + ctx.lineTo(107.000000,295.000000); + ctx.lineTo(115.000000,294.000000); + ctx.lineTo(108.000000,293.000000); + ctx.lineTo(117.000000,291.000000); + ctx.lineTo(109.000000,289.000000); + ctx.lineTo(117.000000,286.000000); + ctx.lineTo(109.000000,286.000000); + ctx.lineTo(118.000000,283.000000); + ctx.lineTo(112.000000,281.000000); + ctx.lineTo(118.000000,279.000000); + ctx.lineTo(114.000000,278.000000); + ctx.lineTo(119.000000,276.000000); + ctx.lineTo(115.000000,274.000000); + ctx.lineTo(121.000000,271.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(79.000000,364.000000); + ctx.lineTo(74.000000,359.000000); + ctx.lineTo(74.000000,353.000000); + ctx.lineTo(76.000000,347.000000); + ctx.lineTo(80.000000,351.000000); + ctx.lineTo(83.000000,356.000000); + ctx.lineTo(82.000000,360.000000); + ctx.lineTo(79.000000,364.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(91.000000,363.000000); + ctx.lineTo(93.000000,356.000000); + ctx.lineTo(97.000000,353.000000); + ctx.lineTo(103.000000,355.000000); + ctx.lineTo(105.000000,360.000000); + ctx.lineTo(103.000000,366.000000); + ctx.lineTo(99.000000,371.000000); + ctx.lineTo(94.000000,368.000000); + ctx.lineTo(91.000000,363.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(110.000000,355.000000); + ctx.lineTo(114.000000,353.000000); + ctx.lineTo(118.000000,357.000000); + ctx.lineTo(117.000000,363.000000); + ctx.lineTo(113.000000,369.000000); + ctx.lineTo(111.000000,362.000000); + ctx.lineTo(110.000000,355.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(126.000000,354.000000); + ctx.lineTo(123.000000,358.000000); + ctx.lineTo(124.000000,367.000000); + ctx.lineTo(126.000000,369.000000); + ctx.lineTo(129.000000,361.000000); + ctx.lineTo(129.000000,357.000000); + ctx.lineTo(126.000000,354.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(30.000000,154.000000); + ctx.lineTo(24.000000,166.000000); + ctx.lineTo(20.000000,182.000000); + ctx.lineTo(23.000000,194.000000); + ctx.lineTo(29.000000,208.000000); + ctx.lineTo(37.000000,218.000000); + ctx.lineTo(41.000000,210.000000); + ctx.lineTo(41.000000,223.000000); + ctx.lineTo(46.000000,214.000000); + ctx.lineTo(46.000000,227.000000); + ctx.lineTo(52.000000,216.000000); + ctx.lineTo(52.000000,227.000000); + ctx.lineTo(61.000000,216.000000); + ctx.lineTo(59.000000,225.000000); + ctx.lineTo(68.000000,213.000000); + ctx.lineTo(73.000000,219.000000); + ctx.lineTo(70.000000,207.000000); + ctx.lineTo(77.000000,212.000000); + ctx.lineTo(69.000000,200.000000); + ctx.lineTo(77.000000,202.000000); + ctx.lineTo(70.000000,194.000000); + ctx.lineTo(78.000000,197.000000); + ctx.lineTo(68.000000,187.000000); + ctx.lineTo(76.000000,182.000000); + ctx.lineTo(64.000000,182.000000); + ctx.lineTo(58.000000,175.000000); + ctx.lineTo(58.000000,185.000000); + ctx.lineTo(53.000000,177.000000); + ctx.lineTo(50.000000,186.000000); + ctx.lineTo(46.000000,171.000000); + ctx.lineTo(44.000000,182.000000); + ctx.lineTo(39.000000,167.000000); + ctx.lineTo(36.000000,172.000000); + ctx.lineTo(36.000000,162.000000); + ctx.lineTo(30.000000,166.000000); + ctx.lineTo(30.000000,154.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(44.000000,130.000000); + ctx.lineTo(41.000000,137.000000); + ctx.lineTo(45.000000,136.000000); + ctx.lineTo(43.000000,150.000000); + ctx.lineTo(48.000000,142.000000); + ctx.lineTo(48.000000,157.000000); + ctx.lineTo(53.000000,150.000000); + ctx.lineTo(52.000000,164.000000); + ctx.lineTo(60.000000,156.000000); + ctx.lineTo(61.000000,169.000000); + ctx.lineTo(64.000000,165.000000); + ctx.lineTo(66.000000,175.000000); + ctx.lineTo(70.000000,167.000000); + ctx.lineTo(74.000000,176.000000); + ctx.lineTo(77.000000,168.000000); + ctx.lineTo(80.000000,183.000000); + ctx.lineTo(85.000000,172.000000); + ctx.lineTo(90.000000,182.000000); + ctx.lineTo(93.000000,174.000000); + ctx.lineTo(98.000000,181.000000); + ctx.lineTo(99.000000,173.000000); + ctx.lineTo(104.000000,175.000000); + ctx.lineTo(105.000000,169.000000); + ctx.lineTo(114.000000,168.000000); + ctx.lineTo(102.000000,163.000000); + ctx.lineTo(95.000000,157.000000); + ctx.lineTo(94.000000,166.000000); + ctx.lineTo(90.000000,154.000000); + ctx.lineTo(87.000000,162.000000); + ctx.lineTo(82.000000,149.000000); + ctx.lineTo(75.000000,159.000000); + ctx.lineTo(72.000000,148.000000); + ctx.lineTo(68.000000,155.000000); + ctx.lineTo(67.000000,143.000000); + ctx.lineTo(62.000000,148.000000); + ctx.lineTo(62.000000,138.000000); + ctx.lineTo(58.000000,145.000000); + ctx.lineTo(56.000000,133.000000); + ctx.lineTo(52.000000,142.000000); + ctx.lineTo(52.000000,128.000000); + ctx.lineTo(49.000000,134.000000); + ctx.lineTo(47.000000,125.000000); + ctx.lineTo(44.000000,130.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(13.000000,216.000000); + ctx.lineTo(19.000000,219.000000); + ctx.lineTo(36.000000,231.000000); + ctx.lineTo(22.000000,223.000000); + ctx.lineTo(16.000000,222.000000); + ctx.lineTo(22.000000,227.000000); + ctx.lineTo(12.000000,224.000000); + ctx.lineTo(13.000000,220.000000); + ctx.lineTo(16.000000,220.000000); + ctx.lineTo(13.000000,216.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(10.000000,231.000000); + ctx.lineTo(14.000000,236.000000); + ctx.lineTo(25.000000,239.000000); + ctx.lineTo(27.000000,237.000000); + ctx.lineTo(19.000000,234.000000); + ctx.lineTo(10.000000,231.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(9.000000,245.000000); + ctx.lineTo(14.000000,242.000000); + ctx.lineTo(25.000000,245.000000); + ctx.lineTo(13.000000,245.000000); + ctx.lineTo(9.000000,245.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(33.000000,255.000000); + ctx.lineTo(26.000000,253.000000); + ctx.lineTo(18.000000,254.000000); + ctx.lineTo(25.000000,256.000000); + ctx.lineTo(18.000000,258.000000); + ctx.lineTo(27.000000,260.000000); + ctx.lineTo(18.000000,263.000000); + ctx.lineTo(27.000000,265.000000); + ctx.lineTo(19.000000,267.000000); + ctx.lineTo(29.000000,270.000000); + ctx.lineTo(21.000000,272.000000); + ctx.lineTo(29.000000,276.000000); + ctx.lineTo(21.000000,278.000000); + ctx.lineTo(30.000000,281.000000); + ctx.lineTo(22.000000,283.000000); + ctx.lineTo(31.000000,287.000000); + ctx.lineTo(24.000000,288.000000); + ctx.lineTo(32.000000,292.000000); + ctx.lineTo(23.000000,293.000000); + ctx.lineTo(34.000000,298.000000); + ctx.lineTo(26.000000,299.000000); + ctx.lineTo(37.000000,303.000000); + ctx.lineTo(32.000000,305.000000); + ctx.lineTo(39.000000,309.000000); + ctx.lineTo(33.000000,309.000000); + ctx.lineTo(39.000000,314.000000); + ctx.lineTo(34.000000,314.000000); + ctx.lineTo(40.000000,318.000000); + ctx.lineTo(34.000000,317.000000); + ctx.lineTo(40.000000,321.000000); + ctx.lineTo(34.000000,321.000000); + ctx.lineTo(41.000000,326.000000); + ctx.lineTo(33.000000,326.000000); + ctx.lineTo(40.000000,330.000000); + ctx.lineTo(33.000000,332.000000); + ctx.lineTo(39.000000,333.000000); + ctx.lineTo(33.000000,337.000000); + ctx.lineTo(42.000000,337.000000); + ctx.lineTo(54.000000,341.000000); + ctx.lineTo(49.000000,337.000000); + ctx.lineTo(52.000000,335.000000); + ctx.lineTo(47.000000,330.000000); + ctx.lineTo(50.000000,330.000000); + ctx.lineTo(45.000000,325.000000); + ctx.lineTo(49.000000,325.000000); + ctx.lineTo(45.000000,321.000000); + ctx.lineTo(48.000000,321.000000); + ctx.lineTo(45.000000,316.000000); + ctx.lineTo(46.000000,306.000000); + ctx.lineTo(45.000000,286.000000); + ctx.lineTo(43.000000,274.000000); + ctx.lineTo(36.000000,261.000000); + ctx.lineTo(33.000000,255.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(7.000000,358.000000); + ctx.lineTo(9.000000,351.000000); + ctx.lineTo(14.000000,351.000000); + ctx.lineTo(17.000000,359.000000); + ctx.lineTo(11.000000,364.000000); + ctx.lineTo(7.000000,358.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(44.000000,354.000000); + ctx.lineTo(49.000000,351.000000); + ctx.lineTo(52.000000,355.000000); + ctx.lineTo(49.000000,361.000000); + ctx.lineTo(44.000000,354.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(32.000000,357.000000); + ctx.lineTo(37.000000,353.000000); + ctx.lineTo(40.000000,358.000000); + ctx.lineTo(36.000000,361.000000); + ctx.lineTo(32.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(139.000000,334.000000); + ctx.lineTo(145.000000,330.000000); + ctx.lineTo(154.000000,330.000000); + ctx.lineTo(158.000000,334.000000); + ctx.lineTo(154.000000,341.000000); + ctx.lineTo(152.000000,348.000000); + ctx.lineTo(145.000000,350.000000); + ctx.lineTo(149.000000,340.000000); + ctx.lineTo(147.000000,336.000000); + ctx.lineTo(141.000000,339.000000); + ctx.lineTo(139.000000,345.000000); + ctx.lineTo(136.000000,342.000000); + ctx.lineTo(136.000000,339.000000); + ctx.lineTo(139.000000,334.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(208.000000,259.000000); + ctx.lineTo(215.000000,259.000000); + ctx.lineTo(212.000000,255.000000); + ctx.lineTo(220.000000,259.000000); + ctx.lineTo(224.000000,263.000000); + ctx.lineTo(225.000000,274.000000); + ctx.lineTo(224.000000,283.000000); + ctx.lineTo(220.000000,292.000000); + ctx.lineTo(208.000000,300.000000); + ctx.lineTo(206.000000,308.000000); + ctx.lineTo(203.000000,304.000000); + ctx.lineTo(199.000000,315.000000); + ctx.lineTo(197.000000,309.000000); + ctx.lineTo(195.000000,318.000000); + ctx.lineTo(193.000000,313.000000); + ctx.lineTo(190.000000,322.000000); + ctx.lineTo(190.000000,316.000000); + ctx.lineTo(185.000000,325.000000); + ctx.lineTo(182.000000,318.000000); + ctx.lineTo(180.000000,325.000000); + ctx.lineTo(172.000000,321.000000); + ctx.lineTo(178.000000,320.000000); + ctx.lineTo(176.000000,313.000000); + ctx.lineTo(186.000000,312.000000); + ctx.lineTo(180.000000,307.000000); + ctx.lineTo(188.000000,307.000000); + ctx.lineTo(184.000000,303.000000); + ctx.lineTo(191.000000,302.000000); + ctx.lineTo(186.000000,299.000000); + ctx.lineTo(195.000000,294.000000); + ctx.lineTo(187.000000,290.000000); + ctx.lineTo(197.000000,288.000000); + ctx.lineTo(192.000000,286.000000); + ctx.lineTo(201.000000,283.000000); + ctx.lineTo(194.000000,280.000000); + ctx.lineTo(203.000000,277.000000); + ctx.lineTo(198.000000,275.000000); + ctx.lineTo(207.000000,271.000000); + ctx.lineTo(200.000000,269.000000); + ctx.lineTo(209.000000,265.000000); + ctx.lineTo(204.000000,265.000000); + ctx.lineTo(212.000000,262.000000); + ctx.lineTo(208.000000,259.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(106.000000,126.000000); + ctx.lineTo(106.000000,131.000000); + ctx.lineTo(109.000000,132.000000); + ctx.lineTo(111.000000,134.000000); + ctx.lineTo(115.000000,132.000000); + ctx.lineTo(115.000000,135.000000); + ctx.lineTo(119.000000,133.000000); + ctx.lineTo(118.000000,137.000000); + ctx.lineTo(123.000000,137.000000); + ctx.lineTo(128.000000,137.000000); + ctx.lineTo(133.000000,134.000000); + ctx.lineTo(136.000000,130.000000); + ctx.lineTo(136.000000,127.000000); + ctx.lineTo(132.000000,124.000000); + ctx.lineTo(118.000000,128.000000); + ctx.lineTo(112.000000,128.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(107.000000,114.000000); + ctx.lineTo(101.000000,110.000000); + ctx.lineTo(98.000000,102.000000); + ctx.lineTo(105.000000,97.000000); + ctx.lineTo(111.000000,98.000000); + ctx.lineTo(119.000000,102.000000); + ctx.lineTo(121.000000,108.000000); + ctx.lineTo(118.000000,112.000000); + ctx.lineTo(113.000000,115.000000); + ctx.lineTo(107.000000,114.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(148.000000,106.000000); + ctx.lineTo(145.000000,110.000000); + ctx.lineTo(146.000000,116.000000); + ctx.lineTo(150.000000,118.000000); + ctx.lineTo(152.000000,111.000000); + ctx.lineTo(151.000000,107.000000); + ctx.lineTo(148.000000,106.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(80.000000,55.000000); + ctx.lineTo(70.000000,52.000000); + ctx.lineTo(75.000000,58.000000); + ctx.lineTo(63.000000,57.000000); + ctx.lineTo(72.000000,61.000000); + ctx.lineTo(57.000000,61.000000); + ctx.lineTo(67.000000,66.000000); + ctx.lineTo(57.000000,67.000000); + ctx.lineTo(62.000000,69.000000); + ctx.lineTo(54.000000,71.000000); + ctx.lineTo(61.000000,73.000000); + ctx.lineTo(54.000000,77.000000); + ctx.lineTo(63.000000,78.000000); + ctx.lineTo(53.000000,85.000000); + ctx.lineTo(60.000000,84.000000); + ctx.lineTo(56.000000,90.000000); + ctx.lineTo(69.000000,84.000000); + ctx.lineTo(63.000000,82.000000); + ctx.lineTo(75.000000,76.000000); + ctx.lineTo(70.000000,75.000000); + ctx.lineTo(77.000000,72.000000); + ctx.lineTo(72.000000,71.000000); + ctx.lineTo(78.000000,69.000000); + ctx.lineTo(72.000000,66.000000); + ctx.lineTo(81.000000,67.000000); + ctx.lineTo(78.000000,64.000000); + ctx.lineTo(82.000000,63.000000); + ctx.lineTo(80.000000,60.000000); + ctx.lineTo(86.000000,62.000000); + ctx.lineTo(80.000000,55.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(87.000000,56.000000); + ctx.lineTo(91.000000,52.000000); + ctx.lineTo(96.000000,50.000000); + ctx.lineTo(102.000000,56.000000); + ctx.lineTo(98.000000,56.000000); + ctx.lineTo(92.000000,60.000000); + ctx.lineTo(87.000000,56.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(85.000000,68.000000); + ctx.lineTo(89.000000,73.000000); + ctx.lineTo(98.000000,76.000000); + ctx.lineTo(106.000000,74.000000); + ctx.lineTo(96.000000,73.000000); + ctx.lineTo(91.000000,70.000000); + ctx.lineTo(85.000000,68.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(115.000000,57.000000); + ctx.lineTo(114.000000,64.000000); + ctx.lineTo(111.000000,64.000000); + ctx.lineTo(115.000000,75.000000); + ctx.lineTo(122.000000,81.000000); + ctx.lineTo(122.000000,74.000000); + ctx.lineTo(126.000000,79.000000); + ctx.lineTo(126.000000,74.000000); + ctx.lineTo(131.000000,78.000000); + ctx.lineTo(130.000000,72.000000); + ctx.lineTo(133.000000,77.000000); + ctx.lineTo(131.000000,68.000000); + ctx.lineTo(126.000000,61.000000); + ctx.lineTo(119.000000,57.000000); + ctx.lineTo(115.000000,57.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(145.000000,48.000000); + ctx.lineTo(143.000000,53.000000); + ctx.lineTo(147.000000,59.000000); + ctx.lineTo(151.000000,59.000000); + ctx.lineTo(150.000000,55.000000); + ctx.lineTo(145.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(26.000000,22.000000); + ctx.lineTo(34.000000,15.000000); + ctx.lineTo(43.000000,10.000000); + ctx.lineTo(52.000000,10.000000); + ctx.lineTo(59.000000,16.000000); + ctx.lineTo(47.000000,15.000000); + ctx.lineTo(32.000000,22.000000); + ctx.lineTo(26.000000,22.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(160.000000,19.000000); + ctx.lineTo(152.000000,26.000000); + ctx.lineTo(149.000000,34.000000); + ctx.lineTo(154.000000,33.000000); + ctx.lineTo(152.000000,30.000000); + ctx.lineTo(157.000000,30.000000); + ctx.lineTo(155.000000,26.000000); + ctx.lineTo(158.000000,27.000000); + ctx.lineTo(157.000000,23.000000); + ctx.lineTo(161.000000,23.000000); + ctx.lineTo(160.000000,19.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(98.000000,117.000000); + ctx.lineTo(105.000000,122.000000); + ctx.lineTo(109.000000,122.000000); + ctx.lineTo(105.000000,117.000000); + ctx.lineTo(113.000000,120.000000); + ctx.lineTo(121.000000,120.000000); + ctx.lineTo(130.000000,112.000000); + ctx.lineTo(128.000000,108.000000); + ctx.lineTo(123.000000,103.000000); + ctx.lineTo(123.000000,99.000000); + ctx.lineTo(128.000000,101.000000); + ctx.lineTo(132.000000,106.000000); + ctx.lineTo(135.000000,109.000000); + ctx.lineTo(142.000000,105.000000); + ctx.lineTo(142.000000,101.000000); + ctx.lineTo(145.000000,101.000000); + ctx.lineTo(145.000000,91.000000); + ctx.lineTo(148.000000,101.000000); + ctx.lineTo(145.000000,105.000000); + ctx.lineTo(136.000000,112.000000); + ctx.lineTo(135.000000,116.000000); + ctx.lineTo(143.000000,124.000000); + ctx.lineTo(148.000000,120.000000); + ctx.lineTo(150.000000,122.000000); + ctx.lineTo(142.000000,128.000000); + ctx.lineTo(133.000000,122.000000); + ctx.lineTo(121.000000,125.000000); + ctx.lineTo(112.000000,126.000000); + ctx.lineTo(103.000000,125.000000); + ctx.lineTo(100.000000,129.000000); + ctx.lineTo(96.000000,124.000000); + ctx.lineTo(98.000000,117.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(146.000000,118.000000); + ctx.lineTo(152.000000,118.000000); + ctx.lineTo(152.000000,115.000000); + ctx.lineTo(149.000000,115.000000); + ctx.lineTo(146.000000,118.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(148.000000,112.000000); + ctx.lineTo(154.000000,111.000000); + ctx.lineTo(154.000000,109.000000); + ctx.lineTo(149.000000,109.000000); + ctx.lineTo(148.000000,112.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,112.000000); + ctx.lineTo(108.000000,115.000000); + ctx.lineTo(114.000000,116.000000); + ctx.lineTo(118.000000,114.000000); + ctx.lineTo(106.000000,112.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(108.000000,108.000000); + ctx.lineTo(111.000000,110.000000); + ctx.lineTo(116.000000,110.000000); + ctx.lineTo(119.000000,108.000000); + ctx.lineTo(108.000000,108.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,104.000000); + ctx.lineTo(109.000000,105.000000); + ctx.lineTo(117.000000,106.000000); + ctx.lineTo(115.000000,104.000000); + ctx.lineTo(106.000000,104.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(50.000000,25.000000); + ctx.lineTo(41.000000,26.000000); + ctx.lineTo(34.000000,33.000000); + ctx.lineTo(39.000000,43.000000); + ctx.lineTo(49.000000,58.000000); + ctx.lineTo(36.000000,51.000000); + ctx.lineTo(47.000000,68.000000); + ctx.lineTo(55.000000,69.000000); + ctx.lineTo(54.000000,59.000000); + ctx.lineTo(61.000000,57.000000); + ctx.lineTo(74.000000,46.000000); + ctx.lineTo(60.000000,52.000000); + ctx.lineTo(67.000000,42.000000); + ctx.lineTo(57.000000,48.000000); + ctx.lineTo(61.000000,40.000000); + ctx.lineTo(54.000000,45.000000); + ctx.lineTo(60.000000,36.000000); + ctx.lineTo(59.000000,29.000000); + ctx.lineTo(48.000000,38.000000); + ctx.lineTo(52.000000,30.000000); + ctx.lineTo(47.000000,32.000000); + ctx.lineTo(50.000000,25.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(147.000000,34.000000); + ctx.lineTo(152.000000,41.000000); + ctx.lineTo(155.000000,49.000000); + ctx.lineTo(161.000000,53.000000); + ctx.lineTo(157.000000,47.000000); + ctx.lineTo(164.000000,47.000000); + ctx.lineTo(158.000000,43.000000); + ctx.lineTo(168.000000,44.000000); + ctx.lineTo(159.000000,40.000000); + ctx.lineTo(164.000000,37.000000); + ctx.lineTo(169.000000,37.000000); + ctx.lineTo(164.000000,33.000000); + ctx.lineTo(169.000000,34.000000); + ctx.lineTo(165.000000,28.000000); + ctx.lineTo(170.000000,30.000000); + ctx.lineTo(170.000000,25.000000); + ctx.lineTo(173.000000,29.000000); + ctx.lineTo(175.000000,27.000000); + ctx.lineTo(176.000000,32.000000); + ctx.lineTo(173.000000,36.000000); + ctx.lineTo(175.000000,39.000000); + ctx.lineTo(172.000000,42.000000); + ctx.lineTo(172.000000,46.000000); + ctx.lineTo(168.000000,49.000000); + ctx.lineTo(170.000000,55.000000); + ctx.lineTo(162.000000,57.000000); + ctx.lineTo(158.000000,63.000000); + ctx.lineTo(155.000000,58.000000); + ctx.lineTo(153.000000,50.000000); + ctx.lineTo(149.000000,46.000000); + ctx.lineTo(147.000000,34.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(155.000000,71.000000); + ctx.lineTo(159.000000,80.000000); + ctx.lineTo(157.000000,93.000000); + ctx.lineTo(157.000000,102.000000); + ctx.lineTo(155.000000,108.000000); + ctx.lineTo(150.000000,101.000000); + ctx.lineTo(149.000000,93.000000); + ctx.lineTo(154.000000,101.000000); + ctx.lineTo(152.000000,91.000000); + ctx.lineTo(151.000000,83.000000); + ctx.lineTo(155.000000,79.000000); + ctx.lineTo(155.000000,71.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(112.000000,78.000000); + ctx.lineTo(115.000000,81.000000); + ctx.lineTo(114.000000,91.000000); + ctx.lineTo(112.000000,87.000000); + ctx.lineTo(113.000000,82.000000); + ctx.lineTo(112.000000,78.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(78.000000,28.000000); + ctx.lineTo(64.000000,17.000000); + ctx.lineTo(58.000000,11.000000); + ctx.lineTo(47.000000,9.000000); + ctx.lineTo(36.000000,10.000000); + ctx.lineTo(28.000000,16.000000); + ctx.lineTo(21.000000,26.000000); + ctx.lineTo(18.000000,41.000000); + ctx.lineTo(20.000000,51.000000); + ctx.lineTo(23.000000,61.000000); + ctx.lineTo(33.000000,65.000000); + ctx.lineTo(28.000000,68.000000); + ctx.lineTo(37.000000,74.000000); + ctx.lineTo(36.000000,81.000000); + ctx.lineTo(43.000000,87.000000); + ctx.lineTo(48.000000,90.000000); + ctx.lineTo(43.000000,100.000000); + ctx.lineTo(40.000000,98.000000); + ctx.lineTo(39.000000,90.000000); + ctx.lineTo(31.000000,80.000000); + ctx.lineTo(30.000000,72.000000); + ctx.lineTo(22.000000,71.000000); + ctx.lineTo(17.000000,61.000000); + ctx.lineTo(14.000000,46.000000); + ctx.lineTo(16.000000,28.000000); + ctx.lineTo(23.000000,17.000000); + ctx.lineTo(33.000000,9.000000); + ctx.lineTo(45.000000,6.000000); + ctx.lineTo(54.000000,6.000000); + ctx.lineTo(65.000000,12.000000); + ctx.lineTo(78.000000,28.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(67.000000,18.000000); + ctx.lineTo(76.000000,9.000000); + ctx.lineTo(87.000000,5.000000); + ctx.lineTo(101.000000,2.000000); + ctx.lineTo(118.000000,3.000000); + ctx.lineTo(135.000000,8.000000); + ctx.lineTo(149.000000,20.000000); + ctx.lineTo(149.000000,26.000000); + ctx.lineTo(144.000000,19.000000); + ctx.lineTo(132.000000,12.000000); + ctx.lineTo(121.000000,9.000000); + ctx.lineTo(105.000000,7.000000); + ctx.lineTo(89.000000,8.000000); + ctx.lineTo(76.000000,14.000000); + ctx.lineTo(70.000000,20.000000); + ctx.lineTo(67.000000,18.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(56.000000,98.000000); + ctx.lineTo(48.000000,106.000000); + ctx.lineTo(56.000000,103.000000); + ctx.lineTo(47.000000,112.000000); + ctx.lineTo(56.000000,110.000000); + ctx.lineTo(52.000000,115.000000); + ctx.lineTo(57.000000,113.000000); + ctx.lineTo(52.000000,121.000000); + ctx.lineTo(62.000000,115.000000); + ctx.lineTo(58.000000,123.000000); + ctx.lineTo(65.000000,119.000000); + ctx.lineTo(63.000000,125.000000); + ctx.lineTo(69.000000,121.000000); + ctx.lineTo(68.000000,127.000000); + ctx.lineTo(74.000000,125.000000); + ctx.lineTo(74.000000,129.000000); + ctx.lineTo(79.000000,128.000000); + ctx.lineTo(83.000000,132.000000); + ctx.lineTo(94.000000,135.000000); + ctx.lineTo(93.000000,129.000000); + ctx.lineTo(85.000000,127.000000); + ctx.lineTo(81.000000,122.000000); + ctx.lineTo(76.000000,126.000000); + ctx.lineTo(75.000000,121.000000); + ctx.lineTo(71.000000,124.000000); + ctx.lineTo(71.000000,117.000000); + ctx.lineTo(66.000000,121.000000); + ctx.lineTo(66.000000,117.000000); + ctx.lineTo(62.000000,117.000000); + ctx.lineTo(64.000000,112.000000); + ctx.lineTo(60.000000,113.000000); + ctx.lineTo(60.000000,110.000000); + ctx.lineTo(57.000000,111.000000); + ctx.lineTo(61.000000,105.000000); + ctx.lineTo(57.000000,107.000000); + ctx.lineTo(60.000000,101.000000); + ctx.lineTo(55.000000,102.000000); + ctx.lineTo(56.000000,98.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(101.000000,132.000000); + ctx.lineTo(103.000000,138.000000); + ctx.lineTo(106.000000,134.000000); + ctx.lineTo(106.000000,139.000000); + ctx.lineTo(112.000000,136.000000); + ctx.lineTo(111.000000,142.000000); + ctx.lineTo(115.000000,139.000000); + ctx.lineTo(114.000000,143.000000); + ctx.lineTo(119.000000,142.000000); + ctx.lineTo(125.000000,145.000000); + ctx.lineTo(131.000000,142.000000); + ctx.lineTo(135.000000,138.000000); + ctx.lineTo(140.000000,134.000000); + ctx.lineTo(140.000000,129.000000); + ctx.lineTo(143.000000,135.000000); + ctx.lineTo(145.000000,149.000000); + ctx.lineTo(150.000000,171.000000); + ctx.lineTo(149.000000,184.000000); + ctx.lineTo(145.000000,165.000000); + ctx.lineTo(141.000000,150.000000); + ctx.lineTo(136.000000,147.000000); + ctx.lineTo(132.000000,151.000000); + ctx.lineTo(131.000000,149.000000); + ctx.lineTo(126.000000,152.000000); + ctx.lineTo(125.000000,150.000000); + ctx.lineTo(121.000000,152.000000); + ctx.lineTo(117.000000,148.000000); + ctx.lineTo(111.000000,152.000000); + ctx.lineTo(110.000000,148.000000); + ctx.lineTo(105.000000,149.000000); + ctx.lineTo(104.000000,145.000000); + ctx.lineTo(98.000000,150.000000); + ctx.lineTo(96.000000,138.000000); + ctx.lineTo(94.000000,132.000000); + ctx.lineTo(94.000000,130.000000); + ctx.lineTo(98.000000,132.000000); + ctx.lineTo(101.000000,132.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(41.000000,94.000000); + ctx.lineTo(32.000000,110.000000); + ctx.lineTo(23.000000,132.000000); + ctx.lineTo(12.000000,163.000000); + ctx.lineTo(6.000000,190.000000); + ctx.lineTo(7.000000,217.000000); + ctx.lineTo(5.000000,236.000000); + ctx.lineTo(3.000000,247.000000); + ctx.lineTo(9.000000,230.000000); + ctx.lineTo(12.000000,211.000000); + ctx.lineTo(12.000000,185.000000); + ctx.lineTo(18.000000,160.000000); + ctx.lineTo(26.000000,134.000000); + ctx.lineTo(35.000000,110.000000); + ctx.lineTo(43.000000,99.000000); + ctx.lineTo(41.000000,94.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(32.000000,246.000000); + ctx.lineTo(41.000000,250.000000); + ctx.lineTo(50.000000,257.000000); + ctx.lineTo(52.000000,267.000000); + ctx.lineTo(53.000000,295.000000); + ctx.lineTo(53.000000,323.000000); + ctx.lineTo(59.000000,350.000000); + ctx.lineTo(54.000000,363.000000); + ctx.lineTo(51.000000,365.000000); + ctx.lineTo(44.000000,366.000000); + ctx.lineTo(42.000000,360.000000); + ctx.lineTo(40.000000,372.000000); + ctx.lineTo(54.000000,372.000000); + ctx.lineTo(59.000000,366.000000); + ctx.lineTo(62.000000,353.000000); + ctx.lineTo(71.000000,352.000000); + ctx.lineTo(75.000000,335.000000); + ctx.lineTo(73.000000,330.000000); + ctx.lineTo(66.000000,318.000000); + ctx.lineTo(68.000000,302.000000); + ctx.lineTo(64.000000,294.000000); + ctx.lineTo(67.000000,288.000000); + ctx.lineTo(63.000000,286.000000); + ctx.lineTo(63.000000,279.000000); + ctx.lineTo(59.000000,275.000000); + ctx.lineTo(58.000000,267.000000); + ctx.lineTo(56.000000,262.000000); + ctx.lineTo(50.000000,247.000000); + ctx.lineTo(42.000000,235.000000); + ctx.lineTo(44.000000,246.000000); + ctx.lineTo(32.000000,236.000000); + ctx.lineTo(35.000000,244.000000); + ctx.lineTo(32.000000,246.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(134.000000,324.000000); + ctx.lineTo(146.000000,320.000000); + ctx.lineTo(159.000000,322.000000); + ctx.lineTo(173.000000,327.000000); + ctx.lineTo(179.000000,337.000000); + ctx.lineTo(179.000000,349.000000); + ctx.lineTo(172.000000,355.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(170.000000,350.000000); + ctx.lineTo(174.000000,343.000000); + ctx.lineTo(170.000000,333.000000); + ctx.lineTo(163.000000,328.000000); + ctx.lineTo(152.000000,326.000000); + ctx.lineTo(134.000000,329.000000); + ctx.lineTo(134.000000,324.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(173.000000,339.000000); + ctx.lineTo(183.000000,334.000000); + ctx.lineTo(184.000000,338.000000); + ctx.lineTo(191.000000,329.000000); + ctx.lineTo(194.000000,332.000000); + ctx.lineTo(199.000000,323.000000); + ctx.lineTo(202.000000,325.000000); + ctx.lineTo(206.000000,318.000000); + ctx.lineTo(209.000000,320.000000); + ctx.lineTo(213.000000,309.000000); + ctx.lineTo(221.000000,303.000000); + ctx.lineTo(228.000000,296.000000); + ctx.lineTo(232.000000,289.000000); + ctx.lineTo(234.000000,279.000000); + ctx.lineTo(233.000000,269.000000); + ctx.lineTo(230.000000,262.000000); + ctx.lineTo(225.000000,256.000000); + ctx.lineTo(219.000000,253.000000); + ctx.lineTo(208.000000,252.000000); + ctx.lineTo(198.000000,252.000000); + ctx.lineTo(210.000000,249.000000); + ctx.lineTo(223.000000,250.000000); + ctx.lineTo(232.000000,257.000000); + ctx.lineTo(237.000000,265.000000); + ctx.lineTo(238.000000,277.000000); + ctx.lineTo(238.000000,291.000000); + ctx.lineTo(232.000000,305.000000); + ctx.lineTo(221.000000,323.000000); + ctx.lineTo(218.000000,335.000000); + ctx.lineTo(212.000000,342.000000); + ctx.lineTo(200.000000,349.000000); + ctx.lineTo(178.000000,348.000000); + ctx.lineTo(173.000000,339.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(165.000000,296.000000); + ctx.lineTo(158.000000,301.000000); + ctx.lineTo(156.000000,310.000000); + ctx.lineTo(156.000000,323.000000); + ctx.lineTo(162.000000,324.000000); + ctx.lineTo(159.000000,318.000000); + ctx.lineTo(162.000000,308.000000); + ctx.lineTo(162.000000,304.000000); + ctx.lineTo(165.000000,296.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(99.000000,252.000000); + ctx.lineTo(105.000000,244.000000); + ctx.lineTo(107.000000,234.000000); + ctx.lineTo(115.000000,228.000000); + ctx.lineTo(121.000000,228.000000); + ctx.lineTo(131.000000,235.000000); + ctx.lineTo(122.000000,233.000000); + ctx.lineTo(113.000000,235.000000); + ctx.lineTo(109.000000,246.000000); + ctx.lineTo(121.000000,239.000000); + ctx.lineTo(133.000000,243.000000); + ctx.lineTo(121.000000,243.000000); + ctx.lineTo(110.000000,251.000000); + ctx.lineTo(99.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(117.000000,252.000000); + ctx.lineTo(124.000000,247.000000); + ctx.lineTo(134.000000,249.000000); + ctx.lineTo(136.000000,253.000000); + ctx.lineTo(126.000000,252.000000); + ctx.lineTo(117.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(117.000000,218.000000); + ctx.lineTo(132.000000,224.000000); + ctx.lineTo(144.000000,233.000000); + ctx.lineTo(140.000000,225.000000); + ctx.lineTo(132.000000,219.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(122.000000,212.000000); + ctx.lineTo(134.000000,214.000000); + ctx.lineTo(143.000000,221.000000); + ctx.lineTo(141.000000,213.000000); + ctx.lineTo(132.000000,210.000000); + ctx.lineTo(122.000000,212.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(69.000000,352.000000); + ctx.lineTo(70.000000,363.000000); + ctx.lineTo(76.000000,373.000000); + ctx.lineTo(86.000000,378.000000); + ctx.lineTo(97.000000,379.000000); + ctx.lineTo(108.000000,379.000000); + ctx.lineTo(120.000000,377.000000); + ctx.lineTo(128.000000,378.000000); + ctx.lineTo(132.000000,373.000000); + ctx.lineTo(135.000000,361.000000); + ctx.lineTo(133.000000,358.000000); + ctx.lineTo(132.000000,366.000000); + ctx.lineTo(127.000000,375.000000); + ctx.lineTo(121.000000,374.000000); + ctx.lineTo(121.000000,362.000000); + ctx.lineTo(119.000000,367.000000); + ctx.lineTo(117.000000,374.000000); + ctx.lineTo(110.000000,376.000000); + ctx.lineTo(110.000000,362.000000); + ctx.lineTo(107.000000,357.000000); + ctx.lineTo(106.000000,371.000000); + ctx.lineTo(104.000000,375.000000); + ctx.lineTo(97.000000,376.000000); + ctx.lineTo(90.000000,375.000000); + ctx.lineTo(90.000000,368.000000); + ctx.lineTo(86.000000,362.000000); + ctx.lineTo(83.000000,364.000000); + ctx.lineTo(86.000000,369.000000); + ctx.lineTo(85.000000,373.000000); + ctx.lineTo(78.000000,370.000000); + ctx.lineTo(73.000000,362.000000); + ctx.lineTo(71.000000,351.000000); + ctx.lineTo(69.000000,352.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(100.000000,360.000000); + ctx.lineTo(96.000000,363.000000); + ctx.lineTo(99.000000,369.000000); + ctx.lineTo(102.000000,364.000000); + ctx.lineTo(100.000000,360.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(115.000000,360.000000); + ctx.lineTo(112.000000,363.000000); + ctx.lineTo(114.000000,369.000000); + ctx.lineTo(117.000000,364.000000); + ctx.lineTo(115.000000,360.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(127.000000,362.000000); + ctx.lineTo(125.000000,364.000000); + ctx.lineTo(126.000000,369.000000); + ctx.lineTo(128.000000,365.000000); + ctx.lineTo(127.000000,362.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(5.000000,255.000000); + ctx.lineTo(7.000000,276.000000); + ctx.lineTo(11.000000,304.000000); + ctx.lineTo(15.000000,320.000000); + ctx.lineTo(13.000000,334.000000); + ctx.lineTo(6.000000,348.000000); + ctx.lineTo(2.000000,353.000000); + ctx.lineTo(0.000000,363.000000); + ctx.lineTo(5.000000,372.000000); + ctx.lineTo(12.000000,374.000000); + ctx.lineTo(25.000000,372.000000); + ctx.lineTo(38.000000,372.000000); + ctx.lineTo(44.000000,369.000000); + ctx.lineTo(42.000000,367.000000); + ctx.lineTo(36.000000,368.000000); + ctx.lineTo(31.000000,369.000000); + ctx.lineTo(30.000000,360.000000); + ctx.lineTo(27.000000,368.000000); + ctx.lineTo(20.000000,370.000000); + ctx.lineTo(16.000000,361.000000); + ctx.lineTo(15.000000,368.000000); + ctx.lineTo(10.000000,369.000000); + ctx.lineTo(3.000000,366.000000); + ctx.lineTo(3.000000,359.000000); + ctx.lineTo(6.000000,352.000000); + ctx.lineTo(11.000000,348.000000); + ctx.lineTo(17.000000,331.000000); + ctx.lineTo(19.000000,316.000000); + ctx.lineTo(12.000000,291.000000); + ctx.lineTo(9.000000,274.000000); + ctx.lineTo(5.000000,255.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(10.000000,358.000000); + ctx.lineTo(7.000000,362.000000); + ctx.lineTo(10.000000,366.000000); + ctx.lineTo(11.000000,362.000000); + ctx.lineTo(10.000000,358.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(25.000000,357.000000); + ctx.lineTo(22.000000,360.000000); + ctx.lineTo(24.000000,366.000000); + ctx.lineTo(27.000000,360.000000); + ctx.lineTo(25.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(37.000000,357.000000); + ctx.lineTo(34.000000,361.000000); + ctx.lineTo(36.000000,365.000000); + ctx.lineTo(38.000000,361.000000); + ctx.lineTo(37.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(49.000000,356.000000); + ctx.lineTo(46.000000,359.000000); + ctx.lineTo(47.000000,364.000000); + ctx.lineTo(50.000000,360.000000); + ctx.lineTo(49.000000,356.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(130.000000,101.000000); + ctx.lineTo(132.000000,102.000000); + ctx.lineTo(135.000000,101.000000); + ctx.lineTo(139.000000,102.000000); + ctx.lineTo(143.000000,103.000000); + ctx.lineTo(142.000000,101.000000); + ctx.lineTo(137.000000,100.000000); + ctx.lineTo(133.000000,100.000000); + ctx.lineTo(130.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,48.000000); + ctx.lineTo(105.000000,52.000000); + ctx.lineTo(108.000000,56.000000); + ctx.lineTo(109.000000,52.000000); + ctx.lineTo(106.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(139.000000,52.000000); + ctx.lineTo(139.000000,56.000000); + ctx.lineTo(140.000000,60.000000); + ctx.lineTo(142.000000,58.000000); + ctx.lineTo(141.000000,56.000000); + ctx.lineTo(139.000000,52.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(25.000000,349.000000); + ctx.lineTo(29.000000,351.000000); + ctx.lineTo(30.000000,355.000000); + ctx.lineTo(33.000000,350.000000); + ctx.lineTo(37.000000,348.000000); + ctx.lineTo(42.000000,351.000000); + ctx.lineTo(45.000000,347.000000); + ctx.lineTo(49.000000,345.000000); + ctx.lineTo(44.000000,343.000000); + ctx.lineTo(36.000000,345.000000); + ctx.lineTo(25.000000,349.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(98.000000,347.000000); + ctx.lineTo(105.000000,351.000000); + ctx.lineTo(107.000000,354.000000); + ctx.lineTo(109.000000,349.000000); + ctx.lineTo(115.000000,349.000000); + ctx.lineTo(120.000000,353.000000); + ctx.lineTo(118.000000,349.000000); + ctx.lineTo(113.000000,346.000000); + ctx.lineTo(104.000000,346.000000); + ctx.lineTo(98.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(83.000000,348.000000); + ctx.lineTo(87.000000,352.000000); + ctx.lineTo(87.000000,357.000000); + ctx.lineTo(89.000000,351.000000); + ctx.lineTo(87.000000,348.000000); + ctx.lineTo(83.000000,348.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(155.000000,107.000000); + ctx.lineTo(163.000000,107.000000); + ctx.lineTo(170.000000,107.000000); + ctx.lineTo(186.000000,108.000000); + ctx.lineTo(175.000000,109.000000); + ctx.lineTo(155.000000,109.000000); + ctx.lineTo(155.000000,107.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(153.000000,114.000000); + ctx.lineTo(162.000000,113.000000); + ctx.lineTo(175.000000,112.000000); + ctx.lineTo(192.000000,114.000000); + ctx.lineTo(173.000000,114.000000); + ctx.lineTo(154.000000,115.000000); + ctx.lineTo(153.000000,114.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(152.000000,118.000000); + ctx.lineTo(164.000000,120.000000); + ctx.lineTo(180.000000,123.000000); + ctx.lineTo(197.000000,129.000000); + ctx.lineTo(169.000000,123.000000); + ctx.lineTo(151.000000,120.000000); + ctx.lineTo(152.000000,118.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(68.000000,109.000000); + ctx.lineTo(87.000000,106.000000); + ctx.lineTo(107.000000,106.000000); + ctx.lineTo(106.000000,108.000000); + ctx.lineTo(88.000000,108.000000); + ctx.lineTo(68.000000,109.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(105.000000,111.000000); + ctx.lineTo(95.000000,112.000000); + ctx.lineTo(79.000000,114.000000); + ctx.lineTo(71.000000,116.000000); + ctx.lineTo(85.000000,115.000000); + ctx.lineTo(102.000000,113.000000); + ctx.lineTo(105.000000,111.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(108.000000,101.000000); + ctx.lineTo(98.000000,99.000000); + ctx.lineTo(87.000000,99.000000); + ctx.lineTo(78.000000,99.000000); + ctx.lineTo(93.000000,100.000000); + ctx.lineTo(105.000000,102.000000); + ctx.lineTo(108.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(85.000000,63.000000); + ctx.lineTo(91.000000,63.000000); + ctx.lineTo(97.000000,60.000000); + ctx.lineTo(104.000000,60.000000); + ctx.lineTo(108.000000,62.000000); + ctx.lineTo(111.000000,69.000000); + ctx.lineTo(112.000000,75.000000); + ctx.lineTo(110.000000,74.000000); + ctx.lineTo(108.000000,71.000000); + ctx.lineTo(103.000000,73.000000); + ctx.lineTo(106.000000,69.000000); + ctx.lineTo(105.000000,65.000000); + ctx.lineTo(103.000000,64.000000); + ctx.lineTo(103.000000,67.000000); + ctx.lineTo(102.000000,70.000000); + ctx.lineTo(99.000000,70.000000); + ctx.lineTo(97.000000,66.000000); + ctx.lineTo(94.000000,67.000000); + ctx.lineTo(97.000000,72.000000); + ctx.lineTo(88.000000,67.000000); + ctx.lineTo(84.000000,66.000000); + ctx.lineTo(85.000000,63.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(140.000000,74.000000); + ctx.lineTo(141.000000,66.000000); + ctx.lineTo(144.000000,61.000000); + ctx.lineTo(150.000000,61.000000); + ctx.lineTo(156.000000,62.000000); + ctx.lineTo(153.000000,70.000000); + ctx.lineTo(150.000000,73.000000); + ctx.lineTo(152.000000,65.000000); + ctx.lineTo(150.000000,65.000000); + ctx.lineTo(151.000000,68.000000); + ctx.lineTo(149.000000,71.000000); + ctx.lineTo(146.000000,71.000000); + ctx.lineTo(144.000000,66.000000); + ctx.lineTo(143.000000,70.000000); + ctx.lineTo(143.000000,74.000000); + ctx.lineTo(140.000000,74.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(146.000000,20.000000); + ctx.lineTo(156.000000,11.000000); + ctx.lineTo(163.000000,9.000000); + ctx.lineTo(172.000000,9.000000); + ctx.lineTo(178.000000,14.000000); + ctx.lineTo(182.000000,18.000000); + ctx.lineTo(184.000000,32.000000); + ctx.lineTo(182.000000,42.000000); + ctx.lineTo(182.000000,52.000000); + ctx.lineTo(177.000000,58.000000); + ctx.lineTo(176.000000,67.000000); + ctx.lineTo(171.000000,76.000000); + ctx.lineTo(165.000000,90.000000); + ctx.lineTo(157.000000,105.000000); + ctx.lineTo(160.000000,92.000000); + ctx.lineTo(164.000000,85.000000); + ctx.lineTo(168.000000,78.000000); + ctx.lineTo(167.000000,73.000000); + ctx.lineTo(173.000000,66.000000); + ctx.lineTo(172.000000,62.000000); + ctx.lineTo(175.000000,59.000000); + ctx.lineTo(174.000000,55.000000); + ctx.lineTo(177.000000,53.000000); + ctx.lineTo(180.000000,46.000000); + ctx.lineTo(181.000000,29.000000); + ctx.lineTo(179.000000,21.000000); + ctx.lineTo(173.000000,13.000000); + ctx.lineTo(166.000000,11.000000); + ctx.lineTo(159.000000,13.000000); + ctx.lineTo(153.000000,18.000000); + ctx.lineTo(148.000000,23.000000); + ctx.lineTo(146.000000,20.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(150.000000,187.000000); + ctx.lineTo(148.000000,211.000000); + ctx.lineTo(150.000000,233.000000); + ctx.lineTo(153.000000,247.000000); + ctx.lineTo(148.000000,267.000000); + ctx.lineTo(135.000000,283.000000); + ctx.lineTo(125.000000,299.000000); + ctx.lineTo(136.000000,292.000000); + ctx.lineTo(131.000000,313.000000); + ctx.lineTo(122.000000,328.000000); + ctx.lineTo(122.000000,345.000000); + ctx.lineTo(129.000000,352.000000); + ctx.lineTo(133.000000,359.000000); + ctx.lineTo(133.000000,367.000000); + ctx.lineTo(137.000000,359.000000); + ctx.lineTo(148.000000,356.000000); + ctx.lineTo(140.000000,350.000000); + ctx.lineTo(131.000000,347.000000); + ctx.lineTo(129.000000,340.000000); + ctx.lineTo(132.000000,332.000000); + ctx.lineTo(140.000000,328.000000); + ctx.lineTo(137.000000,322.000000); + ctx.lineTo(140.000000,304.000000); + ctx.lineTo(154.000000,265.000000); + ctx.lineTo(157.000000,244.000000); + ctx.lineTo(155.000000,223.000000); + ctx.lineTo(161.000000,220.000000); + ctx.lineTo(175.000000,229.000000); + ctx.lineTo(186.000000,247.000000); + ctx.lineTo(185.000000,260.000000); + ctx.lineTo(176.000000,275.000000); + ctx.lineTo(178.000000,287.000000); + ctx.lineTo(185.000000,277.000000); + ctx.lineTo(188.000000,261.000000); + ctx.lineTo(196.000000,253.000000); + ctx.lineTo(189.000000,236.000000); + ctx.lineTo(174.000000,213.000000); + ctx.lineTo(150.000000,187.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(147.000000,338.000000); + ctx.lineTo(142.000000,341.000000); + ctx.lineTo(143.000000,345.000000); + ctx.lineTo(141.000000,354.000000); + ctx.lineTo(147.000000,343.000000); + ctx.lineTo(147.000000,338.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(157.000000,342.000000); + ctx.lineTo(156.000000,349.000000); + ctx.lineTo(150.000000,356.000000); + ctx.lineTo(157.000000,353.000000); + ctx.lineTo(163.000000,346.000000); + ctx.lineTo(162.000000,342.000000); + ctx.lineTo(157.000000,342.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(99.000000,265.000000); + ctx.lineTo(96.000000,284.000000); + ctx.lineTo(92.000000,299.000000); + ctx.lineTo(73.000000,339.000000); + ctx.lineTo(73.000000,333.000000); + ctx.lineTo(87.000000,300.000000); + ctx.lineTo(99.000000,265.000000); +ctx.fill(); +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/p1.js b/CAAT/documentation/demos/demo24/p1.js new file mode 100644 index 0000000..46fdc03 --- /dev/null +++ b/CAAT/documentation/demos/demo24/p1.js @@ -0,0 +1,4421 @@ +function ff( ctx ) { + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-122.304001,84.285004); + ctx.bezierCurveTo(-122.304001,84.285004,-122.203003,86.179001,-123.027000,86.160004); + ctx.bezierCurveTo(-123.850998,86.140999,-140.304993,38.066002,-160.832993,40.308998); + ctx.bezierCurveTo(-160.832993,40.308998,-143.050003,32.956001,-122.304001,84.285004); + ctx.lineTo(-122.304001,84.285004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-118.774002,81.262001); + ctx.bezierCurveTo(-118.774002,81.262001,-119.322998,83.078003,-120.092003,82.778999); + ctx.bezierCurveTo(-120.860001,82.481003,-119.976997,31.674999,-140.042999,26.801001); + ctx.bezierCurveTo(-140.042999,26.801001,-120.820000,25.937000,-118.774002,81.262001); + ctx.lineTo(-118.774002,81.262001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-91.283997,123.589996); + ctx.bezierCurveTo(-91.283997,123.589996,-89.648003,124.550003,-90.117996,125.226997); + ctx.bezierCurveTo(-90.588997,125.903999,-139.763000,113.101997,-149.218002,131.459000); + ctx.bezierCurveTo(-149.218002,131.459000,-145.539001,112.571999,-91.283997,123.589996); + ctx.lineTo(-91.283997,123.589996); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-94.093002,133.800995); + ctx.bezierCurveTo(-94.093002,133.800995,-92.237000,134.197006,-92.471001,134.988007); + ctx.bezierCurveTo(-92.704002,135.779007,-143.406998,139.121002,-146.597000,159.522003); + ctx.bezierCurveTo(-146.597000,159.522003,-149.054993,140.436996,-94.093002,133.800995); + ctx.lineTo(-94.093002,133.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-98.304001,128.276001); + ctx.bezierCurveTo(-98.304001,128.276001,-96.526001,128.938995,-96.872002,129.686996); + ctx.bezierCurveTo(-97.218002,130.434998,-147.865997,126.346001,-153.998001,146.063995); + ctx.bezierCurveTo(-153.998001,146.063995,-153.645996,126.824997,-98.304001,128.276001); + ctx.lineTo(-98.304001,128.276001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-109.009003,110.071999); + ctx.bezierCurveTo(-109.009003,110.071999,-107.700996,111.445999,-108.339996,111.967003); + ctx.bezierCurveTo(-108.978996,112.487999,-152.722000,86.634003,-166.869003,101.676003); + ctx.bezierCurveTo(-166.869003,101.676003,-158.128006,84.532997,-109.009003,110.071999); + ctx.lineTo(-109.009003,110.071999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-116.554001,114.263000); + ctx.bezierCurveTo(-116.554001,114.263000,-115.098000,115.480003,-115.674004,116.070999); + ctx.bezierCurveTo(-116.250000,116.661003,-162.638000,95.921997,-174.992004,112.469002); + ctx.bezierCurveTo(-174.992004,112.469002,-168.246994,94.446999,-116.554001,114.263000); + ctx.lineTo(-116.554001,114.263000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-119.153999,118.334999); + ctx.bezierCurveTo(-119.153999,118.334999,-117.545998,119.343002,-118.036003,120.005997); + ctx.bezierCurveTo(-118.526001,120.668999,-167.307999,106.445999,-177.291000,124.522003); + ctx.bezierCurveTo(-177.291000,124.522003,-173.065994,105.749001,-119.153999,118.334999); + ctx.lineTo(-119.153999,118.334999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-108.419998,118.948997); + ctx.bezierCurveTo(-108.419998,118.948997,-107.297997,120.480003,-107.999001,120.915001); + ctx.bezierCurveTo(-108.699997,121.349998,-148.768997,90.101997,-164.727005,103.207001); + ctx.bezierCurveTo(-164.727005,103.207001,-153.862000,87.325996,-108.419998,118.948997); + ctx.lineTo(-108.419998,118.948997); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-128.199997,90.000000); + ctx.bezierCurveTo(-128.199997,90.000000,-127.599998,91.800003,-128.399994,92.000000); + ctx.bezierCurveTo(-129.199997,92.199997,-157.800003,50.200001,-177.001007,57.799999); + ctx.bezierCurveTo(-177.001007,57.799999,-161.800003,46.000000,-128.199997,90.000000); + ctx.lineTo(-128.199997,90.000000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-127.504997,96.978996); + ctx.bezierCurveTo(-127.504997,96.978996,-126.529999,98.608002,-127.268997,98.974998); + ctx.bezierCurveTo(-128.007004,99.343002,-164.992004,64.499001,-182.100998,76.060997); + ctx.bezierCurveTo(-182.100998,76.060997,-169.804001,61.261002,-127.504997,96.978996); + ctx.lineTo(-127.504997,96.978996); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.172'; +ctx.beginPath(); +ctx.moveTo(-127.620003,101.348999); + ctx.bezierCurveTo(-127.620003,101.348999,-126.498001,102.879997,-127.198997,103.315002); + ctx.bezierCurveTo(-127.900002,103.749001,-167.968994,72.501999,-183.927002,85.607002); + ctx.bezierCurveTo(-183.927002,85.607002,-173.061996,69.725998,-127.620003,101.348999); + ctx.lineTo(-127.620003,101.348999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-129.830002,103.065002); + ctx.bezierCurveTo(-129.326996,109.112999,-128.339005,115.681999,-126.599998,118.801003); + ctx.bezierCurveTo(-126.599998,118.801003,-130.199997,131.201004,-121.400002,144.401001); + ctx.bezierCurveTo(-121.400002,144.401001,-121.800003,151.600998,-120.199997,154.800995); + ctx.bezierCurveTo(-120.199997,154.800995,-116.199997,163.201004,-111.400002,164.001007); + ctx.bezierCurveTo(-107.515999,164.647995,-98.792999,167.716995,-88.931999,169.121002); + ctx.bezierCurveTo(-88.931999,169.121002,-71.800003,183.201004,-75.000000,196.001007); + ctx.bezierCurveTo(-75.000000,196.001007,-75.400002,212.401001,-79.000000,214.001007); + ctx.bezierCurveTo(-79.000000,214.001007,-67.400002,202.800995,-77.000000,219.600998); + ctx.lineTo(-81.400002,238.401001); + ctx.bezierCurveTo(-81.400002,238.401001,-55.799999,216.800995,-71.400002,235.201004); + ctx.lineTo(-81.400002,261.200989); + ctx.bezierCurveTo(-81.400002,261.200989,-61.799999,242.800995,-69.000000,251.201004); + ctx.lineTo(-72.199997,260.001007); + ctx.bezierCurveTo(-72.199997,260.001007,-29.000000,232.800995,-59.799999,262.401001); + ctx.bezierCurveTo(-59.799999,262.401001,-51.799999,258.800995,-47.400002,261.601013); + ctx.bezierCurveTo(-47.400002,261.601013,-40.599998,260.401001,-41.400002,262.001007); + ctx.bezierCurveTo(-41.400002,262.001007,-62.200001,272.401001,-65.800003,290.800995); + ctx.bezierCurveTo(-65.800003,290.800995,-57.400002,280.800995,-60.599998,291.601013); + ctx.lineTo(-60.200001,303.200989); + ctx.bezierCurveTo(-60.200001,303.200989,-56.200001,281.601013,-56.599998,319.200989); + ctx.bezierCurveTo(-56.599998,319.200989,-37.400002,301.200989,-49.000000,322.001007); + ctx.lineTo(-49.000000,338.800995); + ctx.bezierCurveTo(-49.000000,338.800995,-33.799999,322.401001,-40.200001,335.200989); + ctx.bezierCurveTo(-40.200001,335.200989,-30.200001,326.401001,-34.200001,341.601013); + ctx.bezierCurveTo(-34.200001,341.601013,-35.000000,352.001007,-30.600000,340.800995); + ctx.bezierCurveTo(-30.600000,340.800995,-14.600000,310.200989,-20.600000,336.401001); + ctx.bezierCurveTo(-20.600000,336.401001,-21.400000,355.601013,-16.600000,340.800995); + ctx.bezierCurveTo(-16.600000,340.800995,-16.200001,351.200989,-7.000000,358.401001); + ctx.bezierCurveTo(-7.000000,358.401001,-8.200000,307.601013,4.600000,343.601013); + ctx.lineTo(8.600000,360.001007); + ctx.bezierCurveTo(8.600000,360.001007,11.400000,350.800995,11.000000,345.601013); + ctx.bezierCurveTo(11.000000,345.601013,25.799999,329.200989,19.000000,353.601013); + ctx.bezierCurveTo(19.000000,353.601013,34.200001,330.800995,31.000000,344.001007); + ctx.bezierCurveTo(31.000000,344.001007,23.400000,360.001007,25.000000,364.800995); + ctx.bezierCurveTo(25.000000,364.800995,41.799999,330.001007,43.000000,328.401001); + ctx.bezierCurveTo(43.000000,328.401001,41.000000,370.802002,51.799999,334.800995); + ctx.bezierCurveTo(51.799999,334.800995,57.400002,346.800995,54.599998,351.200989); + ctx.bezierCurveTo(54.599998,351.200989,62.599998,343.200989,61.799999,340.001007); + ctx.bezierCurveTo(61.799999,340.001007,66.400002,331.800995,69.199997,345.401001); + ctx.bezierCurveTo(69.199997,345.401001,71.000000,354.800995,72.599998,351.601013); + ctx.bezierCurveTo(72.599998,351.601013,76.599998,375.601990,77.800003,352.800995); + ctx.bezierCurveTo(77.800003,352.800995,79.400002,339.200989,72.199997,327.601013); + ctx.bezierCurveTo(72.199997,327.601013,73.000000,324.401001,70.199997,320.401001); + ctx.bezierCurveTo(70.199997,320.401001,83.800003,342.001007,76.599998,313.200989); + ctx.bezierCurveTo(76.599998,313.200989,87.801003,321.200989,89.000999,321.200989); + ctx.bezierCurveTo(89.000999,321.200989,75.400002,298.001007,84.199997,302.800995); + ctx.bezierCurveTo(84.199997,302.800995,79.000000,292.401001,97.000999,304.401001); + ctx.bezierCurveTo(97.000999,304.401001,81.000000,288.401001,98.600998,298.001007); + ctx.bezierCurveTo(98.600998,298.001007,106.600998,304.401001,99.000999,294.401001); + ctx.bezierCurveTo(99.000999,294.401001,84.599998,278.401001,106.600998,296.401001); + ctx.bezierCurveTo(106.600998,296.401001,118.200996,312.800995,119.000999,315.601013); + ctx.bezierCurveTo(119.000999,315.601013,109.000999,286.401001,104.600998,283.601013); + ctx.bezierCurveTo(104.600998,283.601013,113.000999,247.201004,154.201004,262.800995); + ctx.bezierCurveTo(154.201004,262.800995,161.001007,280.001007,165.401001,261.601013); + ctx.bezierCurveTo(165.401001,261.601013,178.201004,255.201004,189.401001,282.800995); + ctx.bezierCurveTo(189.401001,282.800995,193.401001,269.200989,192.600998,266.401001); + ctx.bezierCurveTo(192.600998,266.401001,199.401001,267.601013,198.600998,266.401001); + ctx.bezierCurveTo(198.600998,266.401001,211.800995,270.800995,213.001007,270.001007); + ctx.bezierCurveTo(213.001007,270.001007,219.800995,276.800995,220.201004,273.200989); + ctx.bezierCurveTo(220.201004,273.200989,229.401001,276.001007,227.401001,272.401001); + ctx.bezierCurveTo(227.401001,272.401001,236.201004,288.001007,236.600998,291.601013); + ctx.lineTo(239.001007,277.601013); + ctx.lineTo(241.001007,280.401001); + ctx.bezierCurveTo(241.001007,280.401001,242.600998,272.800995,241.800995,271.601013); + ctx.bezierCurveTo(241.001007,270.401001,261.800995,278.401001,266.601013,299.200989); + ctx.lineTo(268.601013,307.601013); + ctx.bezierCurveTo(268.601013,307.601013,274.601013,292.800995,273.001007,288.800995); + ctx.bezierCurveTo(273.001007,288.800995,278.200989,289.601013,278.601013,294.001007); + ctx.bezierCurveTo(278.601013,294.001007,282.601013,270.800995,277.800995,264.800995); + ctx.bezierCurveTo(277.800995,264.800995,282.200989,264.001007,283.401001,267.601013); + ctx.lineTo(283.401001,260.401001); + ctx.bezierCurveTo(283.401001,260.401001,290.601013,261.200989,290.601013,258.800995); + ctx.bezierCurveTo(290.601013,258.800995,295.001007,254.800995,297.001007,259.601013); + ctx.bezierCurveTo(297.001007,259.601013,284.601013,224.401001,303.001007,243.600998); + ctx.bezierCurveTo(303.001007,243.600998,310.200989,254.401001,306.601013,235.600998); + ctx.bezierCurveTo(303.001007,216.800995,299.001007,215.201004,303.800995,214.800995); + ctx.bezierCurveTo(303.800995,214.800995,304.601013,211.201004,302.601013,209.600998); + ctx.bezierCurveTo(300.601013,208.001007,303.800995,209.600998,303.800995,209.600998); + ctx.bezierCurveTo(303.800995,209.600998,308.601013,213.600998,303.401001,191.600998); + ctx.bezierCurveTo(303.401001,191.600998,309.800995,193.201004,297.800995,164.001007); + ctx.bezierCurveTo(297.800995,164.001007,300.601013,161.600998,296.601013,153.201004); + ctx.bezierCurveTo(296.601013,153.201004,304.601013,157.600998,307.401001,156.001007); + ctx.bezierCurveTo(307.401001,156.001007,307.001007,154.401001,303.800995,150.401001); + ctx.bezierCurveTo(303.800995,150.401001,282.200989,95.599998,302.601013,117.600998); + ctx.bezierCurveTo(302.601013,117.600998,314.450989,131.151001,308.050995,108.350998); + ctx.bezierCurveTo(308.050995,108.350998,298.940002,84.341003,299.717010,80.044998); + ctx.lineTo(-129.830002,103.065002); + ctx.lineTo(-129.830002,103.065002); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#cc7226'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(299.717010,80.245003); + ctx.bezierCurveTo(300.345001,80.426003,302.550995,81.550003,303.800995,83.199997); + ctx.bezierCurveTo(303.800995,83.199997,310.601013,94.000000,305.401001,75.599998); + ctx.bezierCurveTo(305.401001,75.599998,296.200989,46.799999,305.001007,58.000000); + ctx.bezierCurveTo(305.001007,58.000000,311.001007,65.199997,307.800995,51.599998); + ctx.bezierCurveTo(303.936005,35.173000,301.401001,28.799999,301.401001,28.799999); + ctx.bezierCurveTo(301.401001,28.799999,313.001007,33.599998,286.200989,-6.000000); + ctx.lineTo(295.001007,-2.400000); + ctx.bezierCurveTo(295.001007,-2.400000,275.401001,-42.000000,253.800995,-47.200001); + ctx.lineTo(245.800995,-53.200001); + ctx.bezierCurveTo(245.800995,-53.200001,284.200989,-91.199997,271.401001,-128.000000); + ctx.bezierCurveTo(271.401001,-128.000000,264.601013,-133.199997,255.001007,-124.000000); + ctx.bezierCurveTo(255.001007,-124.000000,248.600998,-119.199997,242.600998,-120.800003); + ctx.bezierCurveTo(242.600998,-120.800003,211.800995,-119.599998,209.800995,-119.599998); + ctx.bezierCurveTo(207.800995,-119.599998,173.001007,-156.800003,107.401001,-139.199997); + ctx.bezierCurveTo(107.401001,-139.199997,102.200996,-137.199997,97.801003,-138.399994); + ctx.bezierCurveTo(97.801003,-138.399994,79.400002,-154.399994,30.600000,-131.600006); + ctx.bezierCurveTo(30.600000,-131.600006,20.600000,-129.600006,19.000000,-129.600006); + ctx.bezierCurveTo(17.400000,-129.600006,14.600000,-129.600006,6.600000,-123.199997); + ctx.bezierCurveTo(-1.400000,-116.800003,-1.800000,-116.000000,-3.800000,-114.400002); + ctx.bezierCurveTo(-3.800000,-114.400002,-20.200001,-103.199997,-25.000000,-102.400002); + ctx.bezierCurveTo(-25.000000,-102.400002,-36.599998,-96.000000,-41.000000,-86.000000); + ctx.lineTo(-44.599998,-84.800003); + ctx.bezierCurveTo(-44.599998,-84.800003,-46.200001,-77.599998,-46.599998,-76.400002); + ctx.bezierCurveTo(-46.599998,-76.400002,-51.400002,-72.800003,-52.200001,-67.199997); + ctx.bezierCurveTo(-52.200001,-67.199997,-61.000000,-61.200001,-60.599998,-56.799999); + ctx.bezierCurveTo(-60.599998,-56.799999,-62.200001,-51.599998,-63.000000,-46.799999); + ctx.bezierCurveTo(-63.000000,-46.799999,-70.199997,-42.000000,-69.400002,-39.200001); + ctx.bezierCurveTo(-69.400002,-39.200001,-77.000000,-25.200001,-75.800003,-18.400000); + ctx.bezierCurveTo(-75.800003,-18.400000,-82.199997,-18.799999,-85.000000,-16.400000); + ctx.bezierCurveTo(-85.000000,-16.400000,-85.800003,-11.600000,-87.400002,-11.200000); + ctx.bezierCurveTo(-87.400002,-11.200000,-90.199997,-10.000000,-87.800003,-6.000000); + ctx.bezierCurveTo(-87.800003,-6.000000,-89.400002,-3.200000,-89.800003,-1.600000); + ctx.bezierCurveTo(-89.800003,-1.600000,-89.000000,1.200000,-93.400002,6.800000); + ctx.bezierCurveTo(-93.400002,6.800000,-99.800003,25.600000,-97.800003,30.799999); + ctx.bezierCurveTo(-97.800003,30.799999,-97.400002,35.599998,-100.199997,37.200001); + ctx.bezierCurveTo(-100.199997,37.200001,-103.800003,36.799999,-95.400002,48.799999); + ctx.bezierCurveTo(-95.400002,48.799999,-94.599998,50.000000,-97.800003,52.400002); + ctx.bezierCurveTo(-97.800003,52.400002,-115.000000,56.000000,-117.400002,72.400002); + ctx.bezierCurveTo(-117.400002,72.400002,-131.000000,87.199997,-131.000000,92.400002); + ctx.bezierCurveTo(-131.000000,94.705002,-130.729004,97.851997,-130.029999,102.464996); + ctx.bezierCurveTo(-130.029999,102.464996,-130.600006,110.801003,-103.000000,111.600998); + ctx.bezierCurveTo(-75.400002,112.401001,299.717010,80.245003,299.717010,80.245003); + ctx.lineTo(299.717010,80.245003); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(-115.599998,102.599998); + ctx.bezierCurveTo(-140.600006,63.200001,-126.199997,119.600998,-126.199997,119.600998); + ctx.bezierCurveTo(-117.400002,154.001007,12.200000,116.401001,12.200000,116.401001); + ctx.bezierCurveTo(12.200000,116.401001,181.001007,86.000000,192.201004,82.000000); + ctx.bezierCurveTo(203.401001,78.000000,298.601013,84.400002,298.601013,84.400002); + ctx.lineTo(293.001007,67.599998); + ctx.bezierCurveTo(228.201004,21.200001,209.001007,44.400002,195.401001,40.400002); + ctx.bezierCurveTo(181.800995,36.400002,184.201004,46.000000,181.001007,46.799999); + ctx.bezierCurveTo(177.800995,47.599998,138.600998,22.799999,132.201004,23.600000); + ctx.bezierCurveTo(125.801003,24.400000,100.459000,0.649000,115.401001,32.400002); + ctx.bezierCurveTo(131.401001,66.400002,57.000000,71.599998,40.200001,60.400002); + ctx.bezierCurveTo(23.400000,49.200001,47.400002,78.800003,47.400002,78.800003); + ctx.bezierCurveTo(65.800003,98.800003,31.400000,82.000000,31.400000,82.000000); + ctx.bezierCurveTo(-3.000000,69.199997,-27.000000,94.800003,-30.200001,95.599998); + ctx.bezierCurveTo(-33.400002,96.400002,-38.200001,99.599998,-39.000000,93.199997); + ctx.bezierCurveTo(-39.799999,86.800003,-47.310001,70.098999,-79.000000,96.400002); + ctx.bezierCurveTo(-99.000000,113.000999,-112.800003,91.000000,-112.800003,91.000000); + ctx.lineTo(-115.599998,102.599998); + ctx.lineTo(-115.599998,102.599998); +ctx.fill(); + + + + +ctx.fillStyle='#e87f3a'; +ctx.beginPath(); +ctx.moveTo(133.509995,25.346001); + ctx.bezierCurveTo(127.110001,26.146000,101.742996,2.407000,116.709999,34.146000); + ctx.bezierCurveTo(133.309998,69.346001,58.310001,73.346001,41.509998,62.146000); + ctx.bezierCurveTo(24.709000,50.945999,48.709999,80.545998,48.709999,80.545998); + ctx.bezierCurveTo(67.110001,100.545998,32.709000,83.746002,32.709000,83.746002); + ctx.bezierCurveTo(-1.691000,70.945999,-25.691000,96.545998,-28.891001,97.346001); + ctx.bezierCurveTo(-32.091000,98.146004,-36.890999,101.346001,-37.691002,94.945999); + ctx.bezierCurveTo(-38.491001,88.545998,-45.869999,72.012001,-77.691002,98.146004); + ctx.bezierCurveTo(-98.927002,115.491997,-112.417999,94.037003,-112.417999,94.037003); + ctx.lineTo(-115.617996,104.146004); + ctx.bezierCurveTo(-140.617996,64.346001,-125.545998,122.654999,-125.545998,122.654999); + ctx.bezierCurveTo(-116.745003,157.056000,13.509000,118.146004,13.509000,118.146004); + ctx.bezierCurveTo(13.509000,118.146004,182.309998,87.746002,193.509995,83.746002); + ctx.bezierCurveTo(204.710007,79.746002,299.037994,86.072998,299.037994,86.072998); + ctx.lineTo(293.510010,68.764000); + ctx.bezierCurveTo(228.710007,22.364000,210.309998,46.146000,196.710007,42.146000); + ctx.bezierCurveTo(183.110001,38.146000,185.509995,47.745998,182.309998,48.546001); + ctx.bezierCurveTo(179.110001,49.346001,139.910004,24.546000,133.509995,25.346001); + ctx.lineTo(133.509995,25.346001); +ctx.fill(); + + + + +ctx.fillStyle='#ea8c4d'; +ctx.beginPath(); +ctx.moveTo(134.819000,27.091000); + ctx.bezierCurveTo(128.419006,27.891001,103.684998,3.862000,118.018997,35.890999); + ctx.bezierCurveTo(134.218994,72.092003,59.618999,75.092003,42.819000,63.891998); + ctx.bezierCurveTo(26.018999,52.692001,50.019001,82.292000,50.019001,82.292000); + ctx.bezierCurveTo(68.418999,102.292000,34.019001,85.491997,34.019001,85.491997); + ctx.bezierCurveTo(-0.381000,72.692001,-24.382000,98.292000,-27.582001,99.092003); + ctx.bezierCurveTo(-30.782000,99.891998,-35.582001,103.092003,-36.382000,96.692001); + ctx.bezierCurveTo(-37.181999,90.292000,-44.430000,73.925003,-76.382004,99.891998); + ctx.bezierCurveTo(-98.855003,117.983002,-112.036003,97.073997,-112.036003,97.073997); + ctx.lineTo(-115.636002,105.692001); + ctx.bezierCurveTo(-139.436005,66.692001,-124.890999,125.709999,-124.890999,125.709999); + ctx.bezierCurveTo(-116.091003,160.110001,14.819000,119.891998,14.819000,119.891998); + ctx.bezierCurveTo(14.819000,119.891998,183.619003,89.491997,194.819000,85.491997); + ctx.bezierCurveTo(206.018997,81.491997,299.473999,87.746002,299.473999,87.746002); + ctx.lineTo(294.019989,69.928001); + ctx.bezierCurveTo(229.218994,23.528000,211.619003,47.890999,198.018997,43.890999); + ctx.bezierCurveTo(184.419006,39.890999,186.819000,49.491001,183.619003,50.292000); + ctx.bezierCurveTo(180.419006,51.091999,141.218994,26.291000,134.819000,27.091000); + ctx.lineTo(134.819000,27.091000); +ctx.fill(); + + + + +ctx.fillStyle='#ec9961'; +ctx.beginPath(); +ctx.moveTo(136.128006,28.837000); + ctx.bezierCurveTo(129.727997,29.636999,104.999001,5.605000,119.328003,37.637001); + ctx.bezierCurveTo(136.128006,75.193001,60.394001,76.482002,44.127998,65.637001); + ctx.bezierCurveTo(27.327999,54.437000,51.327999,84.037003,51.327999,84.037003); + ctx.bezierCurveTo(69.727997,104.037003,35.327999,87.237000,35.327999,87.237000); + ctx.bezierCurveTo(0.928000,74.436996,-23.072001,100.037003,-26.271999,100.836998); + ctx.bezierCurveTo(-29.472000,101.637001,-34.271999,104.836998,-35.071999,98.436996); + ctx.bezierCurveTo(-35.872002,92.037003,-42.988998,75.838997,-75.072998,101.637001); + ctx.bezierCurveTo(-98.781998,120.473999,-111.654999,100.110001,-111.654999,100.110001); + ctx.lineTo(-115.654999,107.237000); + ctx.bezierCurveTo(-137.455002,70.436996,-124.236000,128.764999,-124.236000,128.764999); + ctx.bezierCurveTo(-115.435997,163.164993,16.128000,121.637001,16.128000,121.637001); + ctx.bezierCurveTo(16.128000,121.637001,184.927994,91.237000,196.128998,87.237000); + ctx.bezierCurveTo(207.328995,83.237000,299.911011,89.418999,299.911011,89.418999); + ctx.lineTo(294.528992,71.092003); + ctx.bezierCurveTo(229.729004,24.691000,212.929001,49.637001,199.328995,45.637001); + ctx.bezierCurveTo(185.727997,41.637001,188.128006,51.237000,184.927994,52.036999); + ctx.bezierCurveTo(181.727997,52.837002,142.528000,28.037001,136.128006,28.837000); + ctx.lineTo(136.128006,28.837000); +ctx.fill(); + + + + +ctx.fillStyle='#eea575'; +ctx.beginPath(); +ctx.moveTo(137.438004,30.583000); + ctx.bezierCurveTo(131.037003,31.382999,106.814003,7.129000,120.637001,39.382999); + ctx.bezierCurveTo(137.438004,78.583000,62.237000,78.583000,45.437000,67.383003); + ctx.bezierCurveTo(28.636999,56.182999,52.637001,85.782997,52.637001,85.782997); + ctx.bezierCurveTo(71.037003,105.782997,36.637001,88.983002,36.637001,88.983002); + ctx.bezierCurveTo(2.237000,76.182999,-21.763000,101.782997,-24.962999,102.583000); + ctx.bezierCurveTo(-28.163000,103.383003,-32.963001,106.583000,-33.763000,100.182999); + ctx.bezierCurveTo(-34.563000,93.782997,-41.548000,77.751999,-73.763000,103.383003); + ctx.bezierCurveTo(-98.709000,122.964996,-111.273003,103.146004,-111.273003,103.146004); + ctx.lineTo(-115.672997,108.782997); + ctx.bezierCurveTo(-135.473007,73.982002,-123.582001,131.819000,-123.582001,131.819000); + ctx.bezierCurveTo(-114.781998,166.220001,17.437000,123.383003,17.437000,123.383003); + ctx.bezierCurveTo(17.437000,123.383003,186.238007,92.983002,197.438004,88.983002); + ctx.bezierCurveTo(208.638000,84.983002,300.346985,91.092003,300.346985,91.092003); + ctx.lineTo(295.037994,72.254997); + ctx.bezierCurveTo(230.238007,25.855000,214.238007,51.382999,200.638000,47.382999); + ctx.bezierCurveTo(187.037994,43.382999,189.438004,52.983002,186.238007,53.783001); + ctx.bezierCurveTo(183.037994,54.583000,143.837997,29.783001,137.438004,30.583000); + ctx.lineTo(137.438004,30.583000); +ctx.fill(); + + + + +ctx.fillStyle='#f1b288'; +ctx.beginPath(); +ctx.moveTo(138.746994,32.327999); + ctx.bezierCurveTo(132.347000,33.127998,106.383003,9.677000,121.946999,41.127998); + ctx.bezierCurveTo(141.147003,79.928001,63.546001,80.328003,46.745998,69.127998); + ctx.bezierCurveTo(29.945999,57.928001,53.945999,87.528000,53.945999,87.528000); + ctx.bezierCurveTo(72.346001,107.528000,37.945999,90.727997,37.945999,90.727997); + ctx.bezierCurveTo(3.546000,77.928001,-20.454000,103.528000,-23.653999,104.328003); + ctx.bezierCurveTo(-26.854000,105.127998,-31.653999,108.328003,-32.453999,101.928001); + ctx.bezierCurveTo(-33.254002,95.528000,-40.108002,79.665001,-72.454002,105.127998); + ctx.bezierCurveTo(-98.636002,125.456001,-110.890999,106.182999,-110.890999,106.182999); + ctx.lineTo(-115.691002,110.328003); + ctx.bezierCurveTo(-133.690994,77.127998,-122.927002,134.873993,-122.927002,134.873993); + ctx.bezierCurveTo(-114.126999,169.274002,18.746000,125.127998,18.746000,125.127998); + ctx.bezierCurveTo(18.746000,125.127998,187.546997,94.727997,198.746994,90.727997); + ctx.bezierCurveTo(209.947006,86.727997,300.782990,92.764000,300.782990,92.764000); + ctx.lineTo(295.546997,73.418999); + ctx.bezierCurveTo(230.746994,27.018999,215.546997,53.127998,201.947006,49.127998); + ctx.bezierCurveTo(188.347000,45.127998,190.746994,54.728001,187.546997,55.528000); + ctx.bezierCurveTo(184.347000,56.327999,145.147003,31.528000,138.746994,32.327999); + ctx.lineTo(138.746994,32.327999); +ctx.fill(); + + + + +ctx.fillStyle='#f3bf9c'; +ctx.beginPath(); +ctx.moveTo(140.056000,34.073002); + ctx.bezierCurveTo(133.654999,34.873001,107.313004,11.613000,123.254997,42.873001); + ctx.bezierCurveTo(143.656006,82.874001,64.855003,82.073997,48.055000,70.874001); + ctx.bezierCurveTo(31.254999,59.674000,55.255001,89.274002,55.255001,89.274002); + ctx.bezierCurveTo(73.654999,109.274002,39.255001,92.473999,39.255001,92.473999); + ctx.bezierCurveTo(4.855000,79.674004,-19.145000,105.274002,-22.344999,106.073997); + ctx.bezierCurveTo(-25.545000,106.874001,-30.344999,110.073997,-31.145000,103.674004); + ctx.bezierCurveTo(-31.945000,97.274002,-38.667999,81.578003,-71.144997,106.874001); + ctx.bezierCurveTo(-98.564003,127.946999,-110.509003,109.219002,-110.509003,109.219002); + ctx.lineTo(-115.709000,111.874001); + ctx.bezierCurveTo(-131.709000,81.674004,-122.273003,137.929001,-122.273003,137.929001); + ctx.bezierCurveTo(-113.473000,172.328995,20.055000,126.874001,20.055000,126.874001); + ctx.bezierCurveTo(20.055000,126.874001,188.856003,96.473999,200.056000,92.473999); + ctx.bezierCurveTo(211.255997,88.473999,301.220001,94.436996,301.220001,94.436996); + ctx.lineTo(296.056000,74.583000); + ctx.bezierCurveTo(231.255997,28.183001,216.856003,54.874001,203.255997,50.874001); + ctx.bezierCurveTo(189.656006,46.873001,192.056000,56.473999,188.856003,57.273998); + ctx.bezierCurveTo(185.656006,58.074001,146.455994,33.272999,140.056000,34.073002); + ctx.lineTo(140.056000,34.073002); +ctx.fill(); + + + + +ctx.fillStyle='#f5ccb0'; +ctx.beginPath(); +ctx.moveTo(141.365005,35.819000); + ctx.bezierCurveTo(134.964996,36.618999,107.523003,13.944000,124.565002,44.618999); + ctx.bezierCurveTo(146.565002,84.219002,66.164001,83.819000,49.363998,72.619003); + ctx.bezierCurveTo(32.563999,61.418999,56.563999,91.018997,56.563999,91.018997); + ctx.bezierCurveTo(74.963997,111.018997,40.563999,94.219002,40.563999,94.219002); + ctx.bezierCurveTo(6.164000,81.418999,-17.836000,107.018997,-21.035999,107.819000); + ctx.bezierCurveTo(-24.236000,108.619003,-29.035999,111.819000,-29.836000,105.418999); + ctx.bezierCurveTo(-30.636000,99.018997,-37.227001,83.491997,-69.835999,108.619003); + ctx.bezierCurveTo(-98.490997,130.438004,-110.126999,112.255997,-110.126999,112.255997); + ctx.lineTo(-115.726997,113.418999); + ctx.bezierCurveTo(-130.128006,85.018997,-121.617996,140.983002,-121.617996,140.983002); + ctx.bezierCurveTo(-112.818001,175.384003,21.364000,128.619003,21.364000,128.619003); + ctx.bezierCurveTo(21.364000,128.619003,190.164993,98.219002,201.365005,94.219002); + ctx.bezierCurveTo(212.565002,90.219002,301.656006,96.110001,301.656006,96.110001); + ctx.lineTo(296.565002,75.746002); + ctx.bezierCurveTo(231.764999,29.346001,218.164993,56.618999,204.565002,52.618999); + ctx.bezierCurveTo(190.964996,48.618999,193.365005,58.219002,190.164993,59.019001); + ctx.bezierCurveTo(186.964996,59.819000,147.764999,35.019001,141.365005,35.819000); + ctx.lineTo(141.365005,35.819000); +ctx.fill(); + + + + +ctx.fillStyle='#f8d8c4'; +ctx.beginPath(); +ctx.moveTo(142.673996,37.564999); + ctx.bezierCurveTo(136.274002,38.365002,108.832001,15.689000,125.874001,46.365002); + ctx.bezierCurveTo(147.873993,85.964996,67.473999,85.565002,50.674000,74.364998); + ctx.bezierCurveTo(33.874001,63.165001,57.874001,92.764999,57.874001,92.764999); + ctx.bezierCurveTo(76.274002,112.764999,41.874001,95.964996,41.874001,95.964996); + ctx.bezierCurveTo(7.473000,83.165001,-16.527000,108.764999,-19.726999,109.565002); + ctx.bezierCurveTo(-22.927000,110.364998,-27.726999,113.565002,-28.527000,107.165001); + ctx.bezierCurveTo(-29.327000,100.764999,-35.785999,85.404999,-68.527000,110.364998); + ctx.bezierCurveTo(-98.417999,132.929001,-109.745003,115.292999,-109.745003,115.292999); + ctx.lineTo(-115.745003,114.964996); + ctx.bezierCurveTo(-129.345993,88.564003,-120.962997,144.037994,-120.962997,144.037994); + ctx.bezierCurveTo(-112.163002,178.438004,22.673000,130.365005,22.673000,130.365005); + ctx.bezierCurveTo(22.673000,130.365005,191.473999,99.964996,202.673996,95.964996); + ctx.bezierCurveTo(213.873993,91.964996,302.092987,97.782997,302.092987,97.782997); + ctx.lineTo(297.075012,76.910004); + ctx.bezierCurveTo(232.274002,30.510000,219.473999,58.365002,205.873993,54.365002); + ctx.bezierCurveTo(192.274002,50.365002,194.673996,59.965000,191.473999,60.764999); + ctx.bezierCurveTo(188.274002,61.564999,149.074005,36.764999,142.673996,37.564999); + ctx.lineTo(142.673996,37.564999); +ctx.fill(); + + + + +ctx.fillStyle='#fae5d7'; +ctx.beginPath(); +ctx.moveTo(143.983002,39.310001); + ctx.bezierCurveTo(137.582993,40.110001,110.528999,17.223000,127.182999,48.110001); + ctx.bezierCurveTo(149.182999,88.910004,68.782997,87.309998,51.983002,76.110001); + ctx.bezierCurveTo(35.182999,64.910004,59.182999,94.510002,59.182999,94.510002); + ctx.bezierCurveTo(77.583000,114.510002,43.182999,97.709999,43.182999,97.709999); + ctx.bezierCurveTo(8.783000,84.910004,-15.217000,110.510002,-18.417000,111.309998); + ctx.bezierCurveTo(-21.618000,112.110001,-26.417999,115.309998,-27.218000,108.910004); + ctx.bezierCurveTo(-28.018000,102.510002,-34.346001,87.318001,-67.218002,112.110001); + ctx.bezierCurveTo(-98.345001,135.419998,-109.362999,118.329002,-109.362999,118.329002); + ctx.lineTo(-115.764000,116.510002); + ctx.bezierCurveTo(-128.764008,92.510002,-120.308998,147.093002,-120.308998,147.093002); + ctx.bezierCurveTo(-111.509003,181.492996,23.983000,132.110001,23.983000,132.110001); + ctx.bezierCurveTo(23.983000,132.110001,192.783005,101.709999,203.983002,97.709999); + ctx.bezierCurveTo(215.182999,93.709999,302.528992,99.456001,302.528992,99.456001); + ctx.lineTo(297.583008,78.073997); + ctx.bezierCurveTo(232.783005,31.673000,220.783005,60.110001,207.182999,56.110001); + ctx.bezierCurveTo(193.582993,52.110001,195.983002,61.709999,192.783005,62.509998); + ctx.bezierCurveTo(189.582993,63.310001,150.382996,38.509998,143.983002,39.310001); + ctx.lineTo(143.983002,39.310001); +ctx.fill(); + + + + +ctx.fillStyle='#fcf2eb'; +ctx.beginPath(); +ctx.moveTo(145.292007,41.055000); + ctx.bezierCurveTo(138.891998,41.855000,112.917000,18.410999,128.492004,49.855000); + ctx.bezierCurveTo(149.692001,92.655998,70.092003,89.056000,53.292000,77.856003); + ctx.bezierCurveTo(36.492001,66.655998,60.492001,96.255997,60.492001,96.255997); + ctx.bezierCurveTo(78.891998,116.255997,44.492001,99.456001,44.492001,99.456001); + ctx.bezierCurveTo(10.092000,86.655998,-13.908000,112.255997,-17.108000,113.056000); + ctx.bezierCurveTo(-20.308001,113.856003,-25.108000,117.056000,-25.908001,110.655998); + ctx.bezierCurveTo(-26.708000,104.255997,-32.904999,89.232002,-65.907997,113.856003); + ctx.bezierCurveTo(-98.273003,137.910995,-108.982002,121.364998,-108.982002,121.364998); + ctx.lineTo(-115.781998,118.056000); + ctx.bezierCurveTo(-128.582001,94.856003,-119.653999,150.147003,-119.653999,150.147003); + ctx.bezierCurveTo(-110.853996,184.546997,25.292000,133.856003,25.292000,133.856003); + ctx.bezierCurveTo(25.292000,133.856003,194.093002,103.456001,205.292999,99.456001); + ctx.bezierCurveTo(216.492996,95.456001,302.964996,101.127998,302.964996,101.127998); + ctx.lineTo(298.092987,79.237000); + ctx.bezierCurveTo(233.292007,32.837002,222.093002,61.855999,208.492996,57.855999); + ctx.bezierCurveTo(194.893005,53.855000,197.292999,63.456001,194.093002,64.255997); + ctx.bezierCurveTo(190.891998,65.056000,151.692001,40.255001,145.292007,41.055000); + ctx.lineTo(145.292007,41.055000); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(-115.800003,119.600998); + ctx.bezierCurveTo(-128.600006,97.599998,-119.000000,153.201004,-119.000000,153.201004); + ctx.bezierCurveTo(-110.199997,187.600998,26.600000,135.600998,26.600000,135.600998); + ctx.bezierCurveTo(26.600000,135.600998,195.401001,105.199997,206.600998,101.199997); + ctx.bezierCurveTo(217.800995,97.199997,303.401001,102.800003,303.401001,102.800003); + ctx.lineTo(298.601013,80.400002); + ctx.bezierCurveTo(233.800995,34.000000,223.401001,63.599998,209.800995,59.599998); + ctx.bezierCurveTo(196.201004,55.599998,198.600998,65.199997,195.401001,66.000000); + ctx.bezierCurveTo(192.201004,66.800003,153.001007,42.000000,146.600998,42.799999); + ctx.bezierCurveTo(140.201004,43.599998,114.981003,19.792999,129.800995,51.599998); + ctx.bezierCurveTo(152.028000,99.306999,69.041000,89.226997,54.599998,79.599998); + ctx.bezierCurveTo(37.799999,68.400002,61.799999,98.000000,61.799999,98.000000); + ctx.bezierCurveTo(80.199997,118.000999,45.799999,101.199997,45.799999,101.199997); + ctx.bezierCurveTo(11.400000,88.400002,-12.600000,114.000999,-15.800000,114.801003); + ctx.bezierCurveTo(-19.000000,115.600998,-23.799999,118.801003,-24.600000,112.401001); + ctx.bezierCurveTo(-25.400000,106.000000,-31.465000,91.143997,-64.599998,115.600998); + ctx.bezierCurveTo(-98.199997,140.401001,-108.599998,124.401001,-108.599998,124.401001); + ctx.lineTo(-115.800003,119.600998); + ctx.lineTo(-115.800003,119.600998); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-74.199997,149.600998); + ctx.bezierCurveTo(-74.199997,149.600998,-81.400002,161.201004,-60.599998,174.401001); + ctx.bezierCurveTo(-60.599998,174.401001,-59.200001,175.800995,-77.199997,171.600998); + ctx.bezierCurveTo(-77.199997,171.600998,-83.400002,169.600998,-85.000000,159.201004); + ctx.bezierCurveTo(-85.000000,159.201004,-89.800003,154.800995,-94.599998,149.201004); + ctx.bezierCurveTo(-99.400002,143.600998,-74.199997,149.600998,-74.199997,149.600998); + ctx.lineTo(-74.199997,149.600998); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(65.800003,102.000000); + ctx.bezierCurveTo(65.800003,102.000000,83.498001,128.820999,82.900002,133.600998); + ctx.bezierCurveTo(81.599998,144.001007,81.400002,153.600998,84.599998,157.600998); + ctx.bezierCurveTo(87.801003,161.600998,96.600998,194.800995,96.600998,194.800995); + ctx.bezierCurveTo(96.600998,194.800995,96.200996,196.001007,108.600998,158.001007); + ctx.bezierCurveTo(108.600998,158.001007,120.200996,142.001007,100.200996,123.600998); + ctx.bezierCurveTo(100.200996,123.600998,65.000000,94.800003,65.800003,102.000000); + ctx.lineTo(65.800003,102.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-54.200001,176.401001); + ctx.bezierCurveTo(-54.200001,176.401001,-43.000000,183.600998,-57.400002,214.800995); + ctx.lineTo(-51.000000,212.401001); + ctx.bezierCurveTo(-51.000000,212.401001,-51.799999,223.600998,-55.000000,226.001007); + ctx.lineTo(-47.799999,222.800995); + ctx.bezierCurveTo(-47.799999,222.800995,-43.000000,230.800995,-47.000000,235.600998); + ctx.bezierCurveTo(-47.000000,235.600998,-30.200001,243.600998,-31.000000,250.001007); + ctx.bezierCurveTo(-31.000000,250.001007,-24.600000,242.001007,-28.600000,235.600998); + ctx.bezierCurveTo(-32.599998,229.201004,-39.799999,233.201004,-39.000000,214.800995); + ctx.lineTo(-47.799999,218.001007); + ctx.bezierCurveTo(-47.799999,218.001007,-42.200001,209.201004,-42.200001,202.800995); + ctx.lineTo(-50.200001,205.201004); + ctx.bezierCurveTo(-50.200001,205.201004,-34.730999,178.623001,-45.400002,177.201004); + ctx.bezierCurveTo(-51.400002,176.401001,-54.200001,176.401001,-54.200001,176.401001); + ctx.lineTo(-54.200001,176.401001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-21.799999,193.201004); + ctx.bezierCurveTo(-21.799999,193.201004,-19.000000,188.800995,-21.799999,189.600998); + ctx.bezierCurveTo(-24.600000,190.401001,-55.799999,205.201004,-61.799999,214.800995); + ctx.bezierCurveTo(-61.799999,214.800995,-27.400000,190.401001,-21.799999,193.201004); + ctx.lineTo(-21.799999,193.201004); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-11.400000,201.201004); + ctx.bezierCurveTo(-11.400000,201.201004,-8.600000,196.800995,-11.400000,197.600998); + ctx.bezierCurveTo(-14.200000,198.401001,-45.400002,213.201004,-51.400002,222.800995); + ctx.bezierCurveTo(-51.400002,222.800995,-17.000000,198.401001,-11.400000,201.201004); + ctx.lineTo(-11.400000,201.201004); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(1.800000,186.001007); + ctx.bezierCurveTo(1.800000,186.001007,4.600000,181.600998,1.800000,182.401001); + ctx.bezierCurveTo(-1.000000,183.201004,-32.200001,198.001007,-38.200001,207.600998); + ctx.bezierCurveTo(-38.200001,207.600998,-3.800000,183.201004,1.800000,186.001007); + ctx.lineTo(1.800000,186.001007); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-21.400000,229.600998); + ctx.bezierCurveTo(-21.400000,229.600998,-21.400000,223.600998,-24.200001,224.401001); + ctx.bezierCurveTo(-27.000000,225.201004,-63.000000,242.800995,-69.000000,252.401001); + ctx.bezierCurveTo(-69.000000,252.401001,-27.000000,226.800995,-21.400000,229.600998); + ctx.lineTo(-21.400000,229.600998); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-20.200001,218.800995); + ctx.bezierCurveTo(-20.200001,218.800995,-19.000000,214.001007,-21.799999,214.800995); + ctx.bezierCurveTo(-23.799999,214.800995,-50.200001,226.401001,-56.200001,236.001007); + ctx.bezierCurveTo(-56.200001,236.001007,-26.600000,214.401001,-20.200001,218.800995); + ctx.lineTo(-20.200001,218.800995); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-34.599998,266.401001); + ctx.lineTo(-44.599998,274.001007); + ctx.bezierCurveTo(-44.599998,274.001007,-34.200001,266.401001,-30.600000,267.601013); + ctx.bezierCurveTo(-30.600000,267.601013,-37.400002,278.800995,-38.200001,284.001007); + ctx.bezierCurveTo(-38.200001,284.001007,-27.799999,271.200989,-22.200001,271.601013); + ctx.bezierCurveTo(-22.200001,271.601013,-14.600000,272.001007,-14.600000,282.800995); + ctx.bezierCurveTo(-14.600000,282.800995,-9.000000,272.401001,-5.800000,272.800995); + ctx.bezierCurveTo(-5.800000,272.800995,-4.600000,279.200989,-5.800000,286.001007); + ctx.bezierCurveTo(-5.800000,286.001007,-1.800000,278.401001,2.200000,280.001007); + ctx.bezierCurveTo(2.200000,280.001007,8.600000,278.001007,7.800000,289.601013); + ctx.bezierCurveTo(7.800000,289.601013,7.800000,300.001007,7.000000,302.800995); + ctx.bezierCurveTo(7.000000,302.800995,12.600000,276.401001,15.000000,276.001007); + ctx.bezierCurveTo(15.000000,276.001007,23.000000,274.800995,27.799999,283.601013); + ctx.bezierCurveTo(27.799999,283.601013,23.799999,276.001007,28.600000,278.001007); + ctx.bezierCurveTo(28.600000,278.001007,39.400002,279.601013,42.599998,286.401001); + ctx.bezierCurveTo(42.599998,286.401001,35.799999,274.401001,41.400002,277.601013); + ctx.bezierCurveTo(41.400002,277.601013,48.200001,277.601013,49.400002,284.001007); + ctx.bezierCurveTo(49.400002,284.001007,57.799999,305.200989,59.799999,306.800995); + ctx.bezierCurveTo(59.799999,306.800995,52.200001,285.200989,53.799999,285.200989); + ctx.bezierCurveTo(53.799999,285.200989,51.799999,273.200989,57.000000,288.001007); + ctx.bezierCurveTo(57.000000,288.001007,53.799999,274.001007,59.400002,274.800995); + ctx.bezierCurveTo(65.000000,275.601013,69.400002,285.601013,77.800003,283.200989); + ctx.bezierCurveTo(77.800003,283.200989,87.401001,288.800995,89.401001,219.600998); + ctx.lineTo(-34.599998,266.401001); + ctx.lineTo(-34.599998,266.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-29.799999,173.600998); + ctx.bezierCurveTo(-29.799999,173.600998,-15.000000,167.600998,25.000000,173.600998); + ctx.bezierCurveTo(25.000000,173.600998,32.200001,174.001007,39.000000,165.201004); + ctx.bezierCurveTo(45.799999,156.401001,72.599998,149.201004,79.000000,151.201004); + ctx.lineTo(88.600998,157.600998); + ctx.lineTo(89.401001,158.800995); + ctx.bezierCurveTo(89.401001,158.800995,101.801003,169.201004,102.200996,176.800995); + ctx.bezierCurveTo(102.600998,184.401001,87.801003,232.401001,78.199997,248.401001); + ctx.bezierCurveTo(68.599998,264.401001,59.000000,276.800995,39.799999,274.401001); + ctx.bezierCurveTo(39.799999,274.401001,19.000000,270.401001,-6.600000,274.401001); + ctx.bezierCurveTo(-6.600000,274.401001,-35.799999,272.800995,-38.599998,264.800995); + ctx.bezierCurveTo(-41.400002,256.800995,-27.400000,241.600998,-27.400000,241.600998); + ctx.bezierCurveTo(-27.400000,241.600998,-23.000000,233.201004,-24.200001,218.800995); + ctx.bezierCurveTo(-25.400000,204.401001,-25.000000,176.401001,-29.799999,173.600998); + ctx.lineTo(-29.799999,173.600998); +ctx.fill(); + + + + +ctx.fillStyle='#e5668c'; +ctx.beginPath(); +ctx.moveTo(-7.800000,175.600998); + ctx.bezierCurveTo(0.600000,194.001007,-29.000000,259.200989,-29.000000,259.200989); + ctx.bezierCurveTo(-31.000000,260.800995,-16.340000,266.846008,-6.200000,264.401001); + ctx.bezierCurveTo(4.746000,261.763000,45.000000,266.001007,45.000000,266.001007); + ctx.bezierCurveTo(68.599998,250.401001,81.400002,206.001007,81.400002,206.001007); + ctx.bezierCurveTo(81.400002,206.001007,91.801003,182.001007,74.199997,178.800995); + ctx.bezierCurveTo(56.599998,175.600998,-7.800000,175.600998,-7.800000,175.600998); + ctx.lineTo(-7.800000,175.600998); +ctx.fill(); + + + + +ctx.fillStyle='#b23259'; +ctx.beginPath(); +ctx.moveTo(-9.831000,206.496994); + ctx.bezierCurveTo(-6.505000,193.707001,-4.921000,181.906006,-7.800000,175.600998); + ctx.bezierCurveTo(-7.800000,175.600998,54.599998,182.001007,65.800003,161.201004); + ctx.bezierCurveTo(70.041000,153.326004,84.801003,184.001007,84.400002,193.600998); + ctx.bezierCurveTo(84.400002,193.600998,21.400000,208.001007,6.600000,196.800995); + ctx.lineTo(-9.831000,206.496994); + ctx.lineTo(-9.831000,206.496994); +ctx.fill(); + + + + +ctx.fillStyle='#a5264c'; +ctx.beginPath(); +ctx.moveTo(-5.400000,222.800995); + ctx.bezierCurveTo(-5.400000,222.800995,-3.400000,230.001007,-5.800000,234.001007); + ctx.bezierCurveTo(-5.800000,234.001007,-7.400000,234.800995,-8.600000,235.201004); + ctx.bezierCurveTo(-8.600000,235.201004,-7.400000,238.800995,-1.400000,240.401001); + ctx.bezierCurveTo(-1.400000,240.401001,0.600000,244.800995,3.000000,245.201004); + ctx.bezierCurveTo(5.400000,245.600998,10.200000,251.201004,14.200000,250.001007); + ctx.bezierCurveTo(18.200001,248.800995,29.400000,244.800995,29.400000,244.800995); + ctx.bezierCurveTo(29.400000,244.800995,35.000000,241.600998,43.799999,245.201004); + ctx.bezierCurveTo(43.799999,245.201004,46.174999,244.399002,46.599998,240.401001); + ctx.bezierCurveTo(47.099998,235.701004,50.200001,232.001007,52.200001,230.001007); + ctx.bezierCurveTo(54.200001,228.001007,63.799999,215.201004,62.599998,214.800995); + ctx.bezierCurveTo(61.400002,214.401001,-5.400000,222.800995,-5.400000,222.800995); + ctx.lineTo(-5.400000,222.800995); +ctx.fill(); + + + + +ctx.fillStyle='#ff727f'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-9.800000,174.401001); + ctx.bezierCurveTo(-9.800000,174.401001,-12.600000,196.800995,-9.400000,205.201004); + ctx.bezierCurveTo(-6.200000,213.600998,-7.000000,215.600998,-7.800000,219.600998); + ctx.bezierCurveTo(-8.600000,223.600998,-4.200000,233.600998,1.400000,239.600998); + ctx.lineTo(13.400000,241.201004); + ctx.bezierCurveTo(13.400000,241.201004,28.600000,237.600998,37.799999,240.401001); + ctx.bezierCurveTo(37.799999,240.401001,46.793999,241.744003,50.200001,226.800995); + ctx.bezierCurveTo(50.200001,226.800995,55.000000,220.401001,62.200001,217.600998); + ctx.bezierCurveTo(69.400002,214.800995,76.599998,173.201004,72.599998,165.201004); + ctx.bezierCurveTo(68.599998,157.201004,54.200001,152.800995,38.200001,168.401001); + ctx.bezierCurveTo(22.200001,184.001007,20.200001,167.201004,-9.800000,174.401001); + ctx.lineTo(-9.800000,174.401001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-8.200000,249.201004); + ctx.bezierCurveTo(-8.200000,249.201004,-9.000000,247.201004,-13.400000,246.800995); + ctx.bezierCurveTo(-13.400000,246.800995,-35.799999,243.201004,-44.200001,230.800995); + ctx.bezierCurveTo(-44.200001,230.800995,-51.000000,225.201004,-46.599998,236.800995); + ctx.bezierCurveTo(-46.599998,236.800995,-36.200001,257.200989,-29.400000,260.001007); + ctx.bezierCurveTo(-29.400000,260.001007,-13.000000,264.001007,-8.200000,249.201004); + ctx.lineTo(-8.200000,249.201004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#cc3f4c'; +ctx.beginPath(); +ctx.moveTo(71.741997,185.229004); + ctx.bezierCurveTo(72.401001,177.322998,74.353996,168.709000,72.599998,165.201004); + ctx.bezierCurveTo(66.153999,152.307007,49.181000,157.695007,38.200001,168.401001); + ctx.bezierCurveTo(22.200001,184.001007,20.200001,167.201004,-9.800000,174.401001); + ctx.bezierCurveTo(-9.800000,174.401001,-11.545000,188.363998,-10.705000,198.376007); + ctx.bezierCurveTo(-10.705000,198.376007,26.600000,186.800995,27.400000,192.401001); + ctx.bezierCurveTo(27.400000,192.401001,29.000000,189.201004,38.200001,189.201004); + ctx.bezierCurveTo(47.400002,189.201004,70.141998,188.029007,71.741997,185.229004); + ctx.lineTo(71.741997,185.229004); +ctx.fill(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#a51926'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(28.600000,175.201004); + ctx.bezierCurveTo(28.600000,175.201004,33.400002,180.001007,29.799999,189.600998); + ctx.bezierCurveTo(29.799999,189.600998,15.400000,205.600998,17.400000,219.600998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-19.400000,260.001007); + ctx.bezierCurveTo(-19.400000,260.001007,-23.799999,247.201004,-15.000000,254.001007); + ctx.bezierCurveTo(-15.000000,254.001007,-10.200000,256.001007,-11.400000,257.601013); + ctx.bezierCurveTo(-12.600000,259.200989,-18.200001,263.200989,-19.400000,260.001007); + ctx.lineTo(-19.400000,260.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-14.360000,261.200989); + ctx.bezierCurveTo(-14.360000,261.200989,-17.879999,250.960999,-10.840000,256.401001); + ctx.bezierCurveTo(-10.840000,256.401001,-6.419000,258.848999,-7.960000,259.281006); + ctx.bezierCurveTo(-12.520000,260.561005,-7.960000,263.121002,-14.360000,261.200989); + ctx.lineTo(-14.360000,261.200989); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-9.560000,261.200989); + ctx.bezierCurveTo(-9.560000,261.200989,-13.080000,250.960999,-6.040000,256.401001); + ctx.bezierCurveTo(-6.040000,256.401001,-1.665000,258.710999,-3.160000,259.281006); + ctx.bezierCurveTo(-6.520000,260.561005,-3.160000,263.121002,-9.560000,261.200989); + ctx.lineTo(-9.560000,261.200989); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-2.960000,261.401001); + ctx.bezierCurveTo(-2.960000,261.401001,-6.480000,251.160995,0.560000,256.601013); + ctx.bezierCurveTo(0.560000,256.601013,4.943000,258.933014,3.441000,259.480988); + ctx.bezierCurveTo(0.480000,260.561005,3.441000,263.321014,-2.960000,261.401001); + ctx.lineTo(-2.960000,261.401001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(3.520000,261.321014); + ctx.bezierCurveTo(3.520000,261.321014,0.000000,251.080994,7.041000,256.520996); + ctx.bezierCurveTo(7.041000,256.520996,10.881000,258.121002,9.921000,259.401001); + ctx.bezierCurveTo(8.961000,260.681000,9.921000,263.240997,3.520000,261.321014); + ctx.lineTo(3.520000,261.321014); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(10.200000,262.001007); + ctx.bezierCurveTo(10.200000,262.001007,5.400000,249.600998,14.600000,256.001007); + ctx.bezierCurveTo(14.600000,256.001007,19.400000,258.001007,18.200001,259.601013); + ctx.bezierCurveTo(17.000000,261.200989,18.200001,264.401001,10.200000,262.001007); + ctx.lineTo(10.200000,262.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#a5264c'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(-18.200001,244.800995); + ctx.bezierCurveTo(-18.200001,244.800995,-5.000000,242.001007,1.000000,245.201004); + ctx.bezierCurveTo(1.000000,245.201004,7.000000,246.401001,8.200000,246.001007); + ctx.bezierCurveTo(9.400000,245.600998,12.600000,245.201004,12.600000,245.201004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#a5264c'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(15.800000,253.600998); + ctx.bezierCurveTo(15.800000,253.600998,27.799999,240.001007,39.799999,244.401001); + ctx.bezierCurveTo(46.816002,246.973999,45.799999,243.600998,46.599998,240.800995); + ctx.bezierCurveTo(47.400002,238.001007,47.599998,233.800995,52.599998,230.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(33.000000,237.600998); + ctx.bezierCurveTo(33.000000,237.600998,29.000000,226.800995,26.200001,239.600998); + ctx.bezierCurveTo(23.400000,252.401001,20.200001,256.001007,18.600000,258.800995); + ctx.bezierCurveTo(18.600000,258.800995,18.600000,264.001007,27.000000,263.601013); + ctx.bezierCurveTo(27.000000,263.601013,37.799999,263.200989,38.200001,260.401001); + ctx.bezierCurveTo(38.599998,257.601013,37.000000,246.001007,33.000000,237.600998); + ctx.lineTo(33.000000,237.600998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#a5264c'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(47.000000,244.800995); + ctx.bezierCurveTo(47.000000,244.800995,50.599998,242.401001,53.000000,243.600998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#a5264c'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(53.500000,228.401001); + ctx.bezierCurveTo(53.500000,228.401001,56.400002,223.501007,61.200001,222.701004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#b2b2b2'; +ctx.beginPath(); +ctx.moveTo(-25.799999,265.200989); + ctx.bezierCurveTo(-25.799999,265.200989,-7.800000,268.401001,-3.400000,266.800995); + ctx.bezierCurveTo(-3.400000,266.800995,5.400000,266.800995,-3.000000,268.800995); + ctx.bezierCurveTo(-3.000000,268.800995,-15.800000,268.800995,-23.799999,267.601013); + ctx.bezierCurveTo(-23.799999,267.601013,-35.400002,262.001007,-25.799999,265.200989); + ctx.lineTo(-25.799999,265.200989); +ctx.fill(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-11.800000,172.001007); + ctx.bezierCurveTo(-11.800000,172.001007,5.800000,172.001007,7.800000,172.800995); + ctx.bezierCurveTo(7.800000,172.800995,15.000000,203.600998,11.400000,211.201004); + ctx.bezierCurveTo(11.400000,211.201004,10.200000,214.001007,7.400000,208.401001); + ctx.bezierCurveTo(7.400000,208.401001,-11.000000,175.600998,-14.200000,173.600998); + ctx.bezierCurveTo(-17.400000,171.600998,-13.000000,172.001007,-11.800000,172.001007); + ctx.lineTo(-11.800000,172.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-88.900002,169.300995); + ctx.bezierCurveTo(-88.900002,169.300995,-80.000000,171.001007,-67.400002,173.600998); + ctx.bezierCurveTo(-67.400002,173.600998,-62.599998,196.001007,-59.400002,200.800995); + ctx.bezierCurveTo(-56.200001,205.600998,-59.799999,205.600998,-63.400002,202.800995); + ctx.bezierCurveTo(-67.000000,200.001007,-81.800003,186.001007,-83.800003,181.600998); + ctx.bezierCurveTo(-85.800003,177.201004,-88.900002,169.300995,-88.900002,169.300995); + ctx.lineTo(-88.900002,169.300995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-67.039001,173.817993); + ctx.bezierCurveTo(-67.039001,173.817993,-61.238998,175.365997,-60.230000,177.580994); + ctx.bezierCurveTo(-59.222000,179.794998,-61.431999,183.091995,-61.431999,183.091995); + ctx.bezierCurveTo(-61.431999,183.091995,-62.431999,186.397003,-63.633999,184.235001); + ctx.bezierCurveTo(-64.835999,182.072006,-67.708000,174.412003,-67.039001,173.817993); + ctx.lineTo(-67.039001,173.817993); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-67.000000,173.600998); + ctx.bezierCurveTo(-67.000000,173.600998,-63.400002,178.800995,-59.799999,178.800995); + ctx.bezierCurveTo(-56.200001,178.800995,-55.818001,178.388000,-53.000000,179.001007); + ctx.bezierCurveTo(-48.400002,180.001007,-48.799999,178.001007,-42.200001,179.201004); + ctx.bezierCurveTo(-39.560001,179.681000,-37.000000,178.800995,-34.200001,180.001007); + ctx.bezierCurveTo(-31.400000,181.201004,-28.200001,180.401001,-27.000000,178.401001); + ctx.bezierCurveTo(-25.799999,176.401001,-21.000000,172.201004,-21.000000,172.201004); + ctx.bezierCurveTo(-21.000000,172.201004,-33.799999,174.001007,-36.599998,174.800995); + ctx.bezierCurveTo(-36.599998,174.800995,-59.000000,176.001007,-67.000000,173.600998); + ctx.lineTo(-67.000000,173.600998); +ctx.fill(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-22.400000,173.800995); + ctx.bezierCurveTo(-22.400000,173.800995,-28.850000,177.300995,-29.250000,179.701004); + ctx.bezierCurveTo(-29.650000,182.100998,-24.000000,185.800995,-24.000000,185.800995); + ctx.bezierCurveTo(-24.000000,185.800995,-21.250000,190.401001,-20.650000,188.001007); + ctx.bezierCurveTo(-20.049999,185.600998,-21.600000,174.201004,-22.400000,173.800995); + ctx.lineTo(-22.400000,173.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-59.884998,179.264999); + ctx.bezierCurveTo(-59.884998,179.264999,-52.877998,190.453003,-52.660999,179.242004); + ctx.bezierCurveTo(-52.660999,179.242004,-52.104000,177.983994,-53.863998,177.962006); + ctx.bezierCurveTo(-59.938999,177.886002,-58.417999,173.783997,-59.884998,179.264999); + ctx.lineTo(-59.884998,179.264999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-52.707001,179.514008); + ctx.bezierCurveTo(-52.707001,179.514008,-44.785999,190.701004,-45.422001,179.421005); + ctx.bezierCurveTo(-45.422001,179.421005,-45.415001,179.089005,-47.167999,178.936005); + ctx.bezierCurveTo(-51.915001,178.522003,-51.570000,174.003998,-52.707001,179.514008); + ctx.lineTo(-52.707001,179.514008); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-45.493999,179.522003); + ctx.bezierCurveTo(-45.493999,179.522003,-37.534000,190.149994,-38.202999,180.483994); + ctx.bezierCurveTo(-38.202999,180.483994,-38.084000,179.251007,-39.737999,178.949997); + ctx.bezierCurveTo(-43.630001,178.244003,-43.841000,174.994995,-45.493999,179.522003); + ctx.lineTo(-45.493999,179.522003); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffcc'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.5'; +ctx.beginPath(); +ctx.moveTo(-38.618000,179.602005); + ctx.bezierCurveTo(-38.618000,179.602005,-30.718000,191.162994,-30.370001,181.382004); + ctx.bezierCurveTo(-30.370001,181.382004,-28.726000,180.003998,-30.472000,179.781998); + ctx.bezierCurveTo(-36.290001,179.042007,-35.492001,174.587997,-38.618000,179.602005); + ctx.lineTo(-38.618000,179.602005); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#e5e5b2'; +ctx.beginPath(); +ctx.moveTo(-74.792000,183.132004); + ctx.lineTo(-82.449997,181.600998); + ctx.bezierCurveTo(-85.050003,176.600998,-87.150002,170.451004,-87.150002,170.451004); + ctx.bezierCurveTo(-87.150002,170.451004,-80.800003,171.451004,-68.300003,174.251007); + ctx.bezierCurveTo(-68.300003,174.251007,-67.424004,177.569000,-65.952003,183.363998); + ctx.lineTo(-74.792000,183.132004); + ctx.lineTo(-74.792000,183.132004); +ctx.fill(); + + + + +ctx.fillStyle='#e5e5b2'; +ctx.beginPath(); +ctx.moveTo(-9.724000,178.470001); + ctx.bezierCurveTo(-11.390000,175.964005,-12.707000,174.205994,-13.357000,173.800003); + ctx.bezierCurveTo(-16.370001,171.917007,-12.227000,172.294006,-11.098000,172.294006); + ctx.bezierCurveTo(-11.098000,172.294006,5.473000,172.294006,7.356000,173.046997); + ctx.bezierCurveTo(7.356000,173.046997,7.880000,175.289001,8.564000,178.679993); + ctx.bezierCurveTo(8.564000,178.679993,-1.524000,176.669998,-9.724000,178.470001); + ctx.lineTo(-9.724000,178.470001); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(43.880001,40.320999); + ctx.bezierCurveTo(71.600998,44.280998,97.121002,8.641000,98.880997,-1.040000); + ctx.bezierCurveTo(100.640999,-10.720000,90.521004,-22.600000,90.521004,-22.600000); + ctx.bezierCurveTo(91.841003,-25.680000,87.000999,-39.759998,81.721001,-49.000000); + ctx.bezierCurveTo(76.441002,-58.240002,60.540001,-57.265999,43.000000,-58.240002); + ctx.bezierCurveTo(27.160000,-59.119999,8.680000,-35.799999,7.360000,-34.040001); + ctx.bezierCurveTo(6.040000,-32.279999,12.200000,6.001000,13.520000,11.721000); + ctx.bezierCurveTo(14.840000,17.441000,12.200000,43.841000,12.200000,43.841000); + ctx.bezierCurveTo(46.439999,34.741001,16.160000,36.361000,43.880001,40.320999); + ctx.lineTo(43.880001,40.320999); +ctx.fill(); + + + + +ctx.fillStyle='#ea8e51'; +ctx.beginPath(); +ctx.moveTo(8.088000,-33.391998); + ctx.bezierCurveTo(6.792000,-31.664000,12.840000,5.921000,14.136000,11.537000); + ctx.bezierCurveTo(15.432000,17.153000,12.840000,43.073002,12.840000,43.073002); + ctx.bezierCurveTo(45.512001,34.193001,16.728001,35.729000,43.944000,39.617001); + ctx.bezierCurveTo(71.161003,43.505001,96.217003,8.513000,97.945000,-0.992000); + ctx.bezierCurveTo(99.672997,-10.496000,89.737000,-22.160000,89.737000,-22.160000); + ctx.bezierCurveTo(91.032997,-25.184000,86.280998,-39.007999,81.097000,-48.080002); + ctx.bezierCurveTo(75.913002,-57.152000,60.301998,-56.195000,43.080002,-57.152000); + ctx.bezierCurveTo(27.528000,-58.015999,9.384000,-35.119999,8.088000,-33.391998); + ctx.lineTo(8.088000,-33.391998); +ctx.fill(); + + + + +ctx.fillStyle='#efaa7c'; +ctx.beginPath(); +ctx.moveTo(8.816000,-32.743999); + ctx.bezierCurveTo(7.544000,-31.048000,13.480000,5.841000,14.752000,11.353000); + ctx.bezierCurveTo(16.024000,16.865000,13.480000,42.305000,13.480000,42.305000); + ctx.bezierCurveTo(44.883999,33.145000,17.296000,35.097000,44.007999,38.912998); + ctx.bezierCurveTo(70.721001,42.729000,95.313004,8.385000,97.009003,-0.944000); + ctx.bezierCurveTo(98.705002,-10.272000,88.953003,-21.719999,88.953003,-21.719999); + ctx.bezierCurveTo(90.224998,-24.688000,85.560997,-38.256001,80.473000,-47.160000); + ctx.bezierCurveTo(75.385002,-56.063999,60.063000,-55.125000,43.160000,-56.063999); + ctx.bezierCurveTo(27.896000,-56.911999,10.088000,-34.439999,8.816000,-32.743999); + ctx.lineTo(8.816000,-32.743999); +ctx.fill(); + + + + +ctx.fillStyle='#f4c6a8'; +ctx.beginPath(); +ctx.moveTo(9.544000,-32.096001); + ctx.bezierCurveTo(8.296000,-30.431999,14.120000,5.761000,15.368000,11.169000); + ctx.bezierCurveTo(16.615999,16.577000,14.120000,41.536999,14.120000,41.536999); + ctx.bezierCurveTo(43.556000,32.497002,17.864000,34.465000,44.071999,38.209000); + ctx.bezierCurveTo(70.280998,41.952999,94.408997,8.257000,96.072998,-0.895000); + ctx.bezierCurveTo(97.737000,-10.048000,88.168999,-21.280001,88.168999,-21.280001); + ctx.bezierCurveTo(89.417000,-24.191999,84.841003,-37.504002,79.848999,-46.240002); + ctx.bezierCurveTo(74.857002,-54.976002,59.824001,-54.055000,43.240002,-54.976002); + ctx.bezierCurveTo(28.264000,-55.807999,10.792000,-33.759998,9.544000,-32.096001); + ctx.lineTo(9.544000,-32.096001); +ctx.fill(); + + + + +ctx.fillStyle='#f9e2d3'; +ctx.beginPath(); +ctx.moveTo(10.272000,-31.448000); + ctx.bezierCurveTo(9.048000,-29.816000,14.760000,5.681000,15.984000,10.985000); + ctx.bezierCurveTo(17.208000,16.289000,14.760000,40.769001,14.760000,40.769001); + ctx.bezierCurveTo(42.627998,31.849001,18.431999,33.833000,44.136002,37.505001); + ctx.bezierCurveTo(69.841003,41.176998,93.504997,8.129000,95.137001,-0.848000); + ctx.bezierCurveTo(96.768997,-9.824000,87.385002,-20.840000,87.385002,-20.840000); + ctx.bezierCurveTo(88.609001,-23.695999,84.121002,-36.751999,79.224998,-45.320000); + ctx.bezierCurveTo(74.329002,-53.888000,59.584999,-52.985001,43.320000,-53.888000); + ctx.bezierCurveTo(28.632000,-54.703999,11.496000,-33.080002,10.272000,-31.448000); + ctx.lineTo(10.272000,-31.448000); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(44.200001,36.799999); + ctx.bezierCurveTo(69.400002,40.400002,92.600998,8.000000,94.200996,-0.800000); + ctx.bezierCurveTo(95.801003,-9.600000,86.600998,-20.400000,86.600998,-20.400000); + ctx.bezierCurveTo(87.801003,-23.200001,83.400002,-36.000000,78.599998,-44.400002); + ctx.bezierCurveTo(73.800003,-52.799999,59.346001,-51.914001,43.400002,-52.799999); + ctx.bezierCurveTo(29.000000,-53.599998,12.200000,-32.400002,11.000000,-30.799999); + ctx.bezierCurveTo(9.800000,-29.200001,15.400000,5.600000,16.600000,10.800000); + ctx.bezierCurveTo(17.799999,16.000000,15.400000,40.000000,15.400000,40.000000); + ctx.bezierCurveTo(40.900002,31.400000,19.000000,33.200001,44.200001,36.799999); + ctx.lineTo(44.200001,36.799999); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(90.600998,2.800000); + ctx.bezierCurveTo(90.600998,2.800000,62.799999,10.400000,51.200001,8.800000); + ctx.bezierCurveTo(51.200001,8.800000,35.400002,2.200000,26.600000,24.000000); + ctx.bezierCurveTo(26.600000,24.000000,23.000000,31.200001,21.000000,33.200001); + ctx.bezierCurveTo(19.000000,35.200001,90.600998,2.800000,90.600998,2.800000); + ctx.lineTo(90.600998,2.800000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(94.401001,0.600000); + ctx.bezierCurveTo(94.401001,0.600000,65.400002,12.800000,55.400002,12.400000); + ctx.bezierCurveTo(55.400002,12.400000,39.000000,7.800000,30.600000,22.400000); + ctx.bezierCurveTo(30.600000,22.400000,22.200001,31.600000,19.000000,33.200001); + ctx.bezierCurveTo(19.000000,33.200001,18.600000,34.799999,25.000000,30.799999); + ctx.lineTo(35.400002,36.000000); + ctx.bezierCurveTo(35.400002,36.000000,50.200001,45.599998,59.799999,29.600000); + ctx.bezierCurveTo(59.799999,29.600000,63.799999,18.400000,63.799999,16.400000); + ctx.bezierCurveTo(63.799999,14.400000,85.000000,8.800000,86.600998,8.400000); + ctx.bezierCurveTo(88.200996,8.000000,94.801003,3.800000,94.401001,0.600000); + ctx.lineTo(94.401001,0.600000); +ctx.fill(); + + + + +ctx.fillStyle='#99cc32'; +ctx.beginPath(); +ctx.moveTo(47.000000,36.514000); + ctx.bezierCurveTo(40.127998,36.514000,31.754999,32.648998,31.754999,26.400000); + ctx.bezierCurveTo(31.754999,20.152000,40.127998,13.887000,47.000000,13.887000); + ctx.bezierCurveTo(53.874001,13.887000,59.445999,18.952000,59.445999,25.200001); + ctx.bezierCurveTo(59.445999,31.448999,53.874001,36.514000,47.000000,36.514000); + ctx.lineTo(47.000000,36.514000); +ctx.fill(); + + + + +ctx.fillStyle='#659900'; +ctx.beginPath(); +ctx.moveTo(43.376999,19.830000); + ctx.bezierCurveTo(38.530998,20.552000,33.442001,22.055000,33.514000,21.839001); + ctx.bezierCurveTo(35.054001,17.219999,41.415001,13.887000,47.000000,13.887000); + ctx.bezierCurveTo(51.296001,13.887000,55.084000,15.865000,57.320000,18.875000); + ctx.bezierCurveTo(57.320000,18.875000,52.004002,18.545000,43.376999,19.830000); + ctx.lineTo(43.376999,19.830000); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(55.400002,19.600000); + ctx.bezierCurveTo(55.400002,19.600000,51.000000,16.400000,51.000000,18.600000); + ctx.bezierCurveTo(51.000000,18.600000,54.599998,23.000000,55.400002,19.600000); + ctx.lineTo(55.400002,19.600000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(45.400002,27.726000); + ctx.bezierCurveTo(42.901001,27.726000,40.875000,25.700001,40.875000,23.200001); + ctx.bezierCurveTo(40.875000,20.701000,42.901001,18.674999,45.400002,18.674999); + ctx.bezierCurveTo(47.900002,18.674999,49.925999,20.701000,49.925999,23.200001); + ctx.bezierCurveTo(49.925999,25.700001,47.900002,27.726000,45.400002,27.726000); + ctx.lineTo(45.400002,27.726000); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(-58.599998,14.400000); + ctx.bezierCurveTo(-58.599998,14.400000,-61.799999,-6.800000,-59.400002,-11.200000); + ctx.bezierCurveTo(-59.400002,-11.200000,-48.599998,-21.200001,-49.000000,-24.799999); + ctx.bezierCurveTo(-49.000000,-24.799999,-49.400002,-42.799999,-50.599998,-43.599998); + ctx.bezierCurveTo(-51.799999,-44.400002,-59.400002,-50.400002,-65.400002,-44.000000); + ctx.bezierCurveTo(-65.400002,-44.000000,-75.800003,-26.000000,-75.000000,-19.600000); + ctx.lineTo(-75.000000,-17.600000); + ctx.bezierCurveTo(-75.000000,-17.600000,-82.599998,-18.000000,-84.199997,-16.000000); + ctx.bezierCurveTo(-84.199997,-16.000000,-85.400002,-10.800000,-86.599998,-10.400000); + ctx.bezierCurveTo(-86.599998,-10.400000,-89.400002,-8.000000,-87.400002,-5.200000); + ctx.bezierCurveTo(-87.400002,-5.200000,-89.400002,-2.800000,-89.000000,1.200000); + ctx.lineTo(-81.400002,5.200000); + ctx.bezierCurveTo(-81.400002,5.200000,-79.400002,19.600000,-68.599998,24.799999); + ctx.bezierCurveTo(-63.764000,27.129000,-60.599998,20.400000,-58.599998,14.400000); + ctx.lineTo(-58.599998,14.400000); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(-59.599998,12.560000); + ctx.bezierCurveTo(-59.599998,12.560000,-62.480000,-6.520000,-60.320000,-10.480000); + ctx.bezierCurveTo(-60.320000,-10.480000,-50.599998,-19.480000,-50.959999,-22.719999); + ctx.bezierCurveTo(-50.959999,-22.719999,-51.320000,-38.919998,-52.400002,-39.639999); + ctx.bezierCurveTo(-53.480000,-40.360001,-60.320000,-45.759998,-65.720001,-40.000000); + ctx.bezierCurveTo(-65.720001,-40.000000,-75.080002,-23.799999,-74.360001,-18.040001); + ctx.lineTo(-74.360001,-16.240000); + ctx.bezierCurveTo(-74.360001,-16.240000,-81.199997,-16.600000,-82.639999,-14.800000); + ctx.bezierCurveTo(-82.639999,-14.800000,-83.720001,-10.120000,-84.800003,-9.760000); + ctx.bezierCurveTo(-84.800003,-9.760000,-87.320000,-7.600000,-85.519997,-5.080000); + ctx.bezierCurveTo(-85.519997,-5.080000,-87.320000,-2.920000,-86.959999,0.680000); + ctx.lineTo(-80.120003,4.280000); + ctx.bezierCurveTo(-80.120003,4.280000,-78.320000,17.240000,-68.599998,21.920000); + ctx.bezierCurveTo(-64.248001,24.014999,-61.400002,17.959999,-59.599998,12.560000); + ctx.lineTo(-59.599998,12.560000); +ctx.fill(); + + + + +ctx.fillStyle='#eb955c'; +ctx.beginPath(); +ctx.moveTo(-51.049999,-42.610001); + ctx.bezierCurveTo(-52.139999,-43.470001,-59.630001,-49.240002,-65.480003,-43.000000); + ctx.bezierCurveTo(-65.480003,-43.000000,-75.620003,-25.450001,-74.839996,-19.209999); + ctx.lineTo(-74.839996,-17.260000); + ctx.bezierCurveTo(-74.839996,-17.260000,-82.250000,-17.650000,-83.809998,-15.700000); + ctx.bezierCurveTo(-83.809998,-15.700000,-84.980003,-10.630000,-86.150002,-10.240000); + ctx.bezierCurveTo(-86.150002,-10.240000,-88.879997,-7.900000,-86.930000,-5.170000); + ctx.bezierCurveTo(-86.930000,-5.170000,-88.879997,-2.830000,-88.489998,1.070000); + ctx.lineTo(-81.080002,4.970000); + ctx.bezierCurveTo(-81.080002,4.970000,-79.129997,19.010000,-68.599998,24.080000); + ctx.bezierCurveTo(-63.886002,26.350000,-60.799999,19.790001,-58.849998,13.940000); + ctx.bezierCurveTo(-58.849998,13.940000,-61.970001,-6.730000,-59.630001,-11.020000); + ctx.bezierCurveTo(-59.630001,-11.020000,-49.099998,-20.770000,-49.490002,-24.280001); + ctx.bezierCurveTo(-49.490002,-24.280001,-49.880001,-41.830002,-51.049999,-42.610001); + ctx.lineTo(-51.049999,-42.610001); +ctx.fill(); + + + + +ctx.fillStyle='#f2b892'; +ctx.beginPath(); +ctx.moveTo(-51.500000,-41.619999); + ctx.bezierCurveTo(-52.480000,-42.540001,-59.860001,-48.080002,-65.559998,-42.000000); + ctx.bezierCurveTo(-65.559998,-42.000000,-75.440002,-24.900000,-74.680000,-18.820000); + ctx.lineTo(-74.680000,-16.920000); + ctx.bezierCurveTo(-74.680000,-16.920000,-81.900002,-17.299999,-83.419998,-15.400000); + ctx.bezierCurveTo(-83.419998,-15.400000,-84.559998,-10.460000,-85.699997,-10.080000); + ctx.bezierCurveTo(-85.699997,-10.080000,-88.360001,-7.800000,-86.459999,-5.140000); + ctx.bezierCurveTo(-86.459999,-5.140000,-88.360001,-2.860000,-87.980003,0.940000); + ctx.lineTo(-80.760002,4.740000); + ctx.bezierCurveTo(-80.760002,4.740000,-78.860001,18.420000,-68.599998,23.360001); + ctx.bezierCurveTo(-64.005997,25.572001,-61.000000,19.180000,-59.099998,13.480000); + ctx.bezierCurveTo(-59.099998,13.480000,-62.139999,-6.660000,-59.860001,-10.840000); + ctx.bezierCurveTo(-59.860001,-10.840000,-49.599998,-20.340000,-49.980000,-23.760000); + ctx.bezierCurveTo(-49.980000,-23.760000,-50.360001,-40.860001,-51.500000,-41.619999); + ctx.lineTo(-51.500000,-41.619999); +ctx.fill(); + + + + +ctx.fillStyle='#f8dcc8'; +ctx.beginPath(); +ctx.moveTo(-51.950001,-40.630001); + ctx.bezierCurveTo(-52.820000,-41.610001,-60.090000,-46.919998,-65.639999,-41.000000); + ctx.bezierCurveTo(-65.639999,-41.000000,-75.260002,-24.350000,-74.519997,-18.430000); + ctx.lineTo(-74.519997,-16.580000); + ctx.bezierCurveTo(-74.519997,-16.580000,-81.550003,-16.950001,-83.029999,-15.100000); + ctx.bezierCurveTo(-83.029999,-15.100000,-84.139999,-10.290000,-85.250000,-9.920000); + ctx.bezierCurveTo(-85.250000,-9.920000,-87.839996,-7.700000,-85.989998,-5.110000); + ctx.bezierCurveTo(-85.989998,-5.110000,-87.839996,-2.890000,-87.470001,0.810000); + ctx.lineTo(-80.440002,4.510000); + ctx.bezierCurveTo(-80.440002,4.510000,-78.589996,17.830000,-68.599998,22.639999); + ctx.bezierCurveTo(-64.126999,24.794001,-61.200001,18.570000,-59.349998,13.020000); + ctx.bezierCurveTo(-59.349998,13.020000,-62.310001,-6.590000,-60.090000,-10.660000); + ctx.bezierCurveTo(-60.090000,-10.660000,-50.099998,-19.910000,-50.470001,-23.240000); + ctx.bezierCurveTo(-50.470001,-23.240000,-50.840000,-39.889999,-51.950001,-40.630001); + ctx.lineTo(-51.950001,-40.630001); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(-59.599998,12.460000); + ctx.bezierCurveTo(-59.599998,12.460000,-62.480000,-6.520000,-60.320000,-10.480000); + ctx.bezierCurveTo(-60.320000,-10.480000,-50.599998,-19.480000,-50.959999,-22.719999); + ctx.bezierCurveTo(-50.959999,-22.719999,-51.320000,-38.919998,-52.400002,-39.639999); + ctx.bezierCurveTo(-53.160000,-40.680000,-60.320000,-45.759998,-65.720001,-40.000000); + ctx.bezierCurveTo(-65.720001,-40.000000,-75.080002,-23.799999,-74.360001,-18.040001); + ctx.lineTo(-74.360001,-16.240000); + ctx.bezierCurveTo(-74.360001,-16.240000,-81.199997,-16.600000,-82.639999,-14.800000); + ctx.bezierCurveTo(-82.639999,-14.800000,-83.720001,-10.120000,-84.800003,-9.760000); + ctx.bezierCurveTo(-84.800003,-9.760000,-87.320000,-7.600000,-85.519997,-5.080000); + ctx.bezierCurveTo(-85.519997,-5.080000,-87.320000,-2.920000,-86.959999,0.680000); + ctx.lineTo(-80.120003,4.280000); + ctx.bezierCurveTo(-80.120003,4.280000,-78.320000,17.240000,-68.599998,21.920000); + ctx.bezierCurveTo(-64.248001,24.014999,-61.400002,17.860001,-59.599998,12.460000); + ctx.lineTo(-59.599998,12.460000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-62.700001,6.200000); + ctx.bezierCurveTo(-62.700001,6.200000,-84.300003,-4.000000,-85.199997,-4.800000); + ctx.bezierCurveTo(-85.199997,-4.800000,-76.099998,3.400000,-75.300003,3.400000); + ctx.bezierCurveTo(-74.500000,3.400000,-62.700001,6.200000,-62.700001,6.200000); + ctx.lineTo(-62.700001,6.200000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-79.800003,0.000000); + ctx.bezierCurveTo(-79.800003,0.000000,-61.400002,3.600000,-61.400002,8.000000); + ctx.bezierCurveTo(-61.400002,10.912000,-61.643002,24.330999,-67.000000,22.799999); + ctx.bezierCurveTo(-75.400002,20.400000,-71.800003,6.000000,-79.800003,0.000000); + ctx.lineTo(-79.800003,0.000000); +ctx.fill(); + + + + +ctx.fillStyle='#99cc32'; +ctx.beginPath(); +ctx.moveTo(-71.400002,3.800000); + ctx.bezierCurveTo(-71.400002,3.800000,-62.422001,5.274000,-61.400002,8.000000); + ctx.bezierCurveTo(-60.799999,9.600000,-60.137001,17.908001,-65.599998,19.000000); + ctx.bezierCurveTo(-70.152000,19.910999,-72.382004,9.690000,-71.400002,3.800000); + ctx.lineTo(-71.400002,3.800000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(14.595000,46.348999); + ctx.bezierCurveTo(14.098000,44.606998,15.409000,44.737999,17.200001,44.200001); + ctx.bezierCurveTo(19.200001,43.599998,31.400000,39.799999,32.200001,37.200001); + ctx.bezierCurveTo(33.000000,34.599998,46.200001,39.000000,46.200001,39.000000); + ctx.bezierCurveTo(48.000000,39.799999,52.400002,42.400002,52.400002,42.400002); + ctx.bezierCurveTo(57.200001,43.599998,63.799999,44.000000,63.799999,44.000000); + ctx.bezierCurveTo(66.199997,45.000000,69.599998,47.799999,69.599998,47.799999); + ctx.bezierCurveTo(84.199997,58.000000,96.600998,50.799999,96.600998,50.799999); + ctx.bezierCurveTo(116.600998,44.200001,110.600998,27.000000,110.600998,27.000000); + ctx.bezierCurveTo(107.600998,18.000000,110.801003,14.600000,110.801003,14.600000); + ctx.bezierCurveTo(111.000999,10.800000,118.200996,17.200001,118.200996,17.200001); + ctx.bezierCurveTo(120.801003,21.400000,121.600998,26.400000,121.600998,26.400000); + ctx.bezierCurveTo(129.600998,37.599998,126.200996,19.799999,126.200996,19.799999); + ctx.bezierCurveTo(126.401001,18.799999,123.600998,15.200000,123.600998,14.000000); + ctx.bezierCurveTo(123.600998,12.800000,121.801003,9.400000,121.801003,9.400000); + ctx.bezierCurveTo(118.801003,6.000000,121.200996,-1.000000,121.200996,-1.000000); + ctx.bezierCurveTo(123.000999,-14.800000,120.801003,-13.000000,120.801003,-13.000000); + ctx.bezierCurveTo(119.600998,-14.800000,110.401001,-4.800000,110.401001,-4.800000); + ctx.bezierCurveTo(108.200996,-1.400000,102.200996,0.200000,102.200996,0.200000); + ctx.bezierCurveTo(99.401001,2.000000,96.000999,0.600000,96.000999,0.600000); + ctx.bezierCurveTo(93.401001,0.200000,87.801003,7.200000,87.801003,7.200000); + ctx.bezierCurveTo(90.600998,7.000000,93.000999,11.400000,95.401001,11.600000); + ctx.bezierCurveTo(97.801003,11.800000,99.600998,9.200000,101.200996,8.600000); + ctx.bezierCurveTo(102.801003,8.000000,105.600998,13.800000,105.600998,13.800000); + ctx.bezierCurveTo(106.000999,16.400000,100.401001,21.200001,100.401001,21.200001); + ctx.bezierCurveTo(100.000999,25.799999,98.401001,24.200001,98.401001,24.200001); + ctx.bezierCurveTo(95.401001,23.600000,94.200996,27.400000,93.200996,32.000000); + ctx.bezierCurveTo(92.200996,36.599998,88.000999,37.000000,88.000999,37.000000); + ctx.bezierCurveTo(86.401001,44.400002,85.199997,41.400002,85.199997,41.400002); + ctx.bezierCurveTo(85.000000,35.799999,79.000000,41.599998,79.000000,41.599998); + ctx.bezierCurveTo(77.800003,43.599998,73.199997,41.400002,73.199997,41.400002); + ctx.bezierCurveTo(66.400002,39.400002,68.800003,37.400002,68.800003,37.400002); + ctx.bezierCurveTo(70.599998,35.200001,81.800003,37.400002,81.800003,37.400002); + ctx.bezierCurveTo(84.000000,35.799999,76.000000,31.799999,76.000000,31.799999); + ctx.bezierCurveTo(75.400002,30.000000,76.400002,25.600000,76.400002,25.600000); + ctx.bezierCurveTo(77.599998,22.400000,84.400002,16.799999,84.400002,16.799999); + ctx.bezierCurveTo(93.801003,15.600000,91.000999,14.000000,91.000999,14.000000); + ctx.bezierCurveTo(84.801003,8.800000,79.000000,16.400000,79.000000,16.400000); + ctx.bezierCurveTo(76.800003,22.600000,59.400002,37.599998,59.400002,37.599998); + ctx.bezierCurveTo(54.599998,41.000000,57.200001,34.200001,53.200001,37.599998); + ctx.bezierCurveTo(49.200001,41.000000,28.600000,32.000000,28.600000,32.000000); + ctx.bezierCurveTo(17.038000,30.806999,14.306000,46.549000,10.777000,43.429001); + ctx.bezierCurveTo(10.777000,43.429001,16.195000,51.949001,14.595000,46.348999); + ctx.lineTo(14.595000,46.348999); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(209.401001,-120.000000); + ctx.bezierCurveTo(209.401001,-120.000000,183.800995,-112.000000,181.001007,-93.199997); + ctx.bezierCurveTo(181.001007,-93.199997,178.600998,-70.400002,199.001007,-52.799999); + ctx.bezierCurveTo(199.001007,-52.799999,199.401001,-46.400002,201.401001,-43.200001); + ctx.bezierCurveTo(201.401001,-43.200001,199.800995,-38.400002,218.600998,-46.000000); + ctx.lineTo(245.800995,-54.400002); + ctx.bezierCurveTo(245.800995,-54.400002,252.201004,-56.799999,257.401001,-65.599998); + ctx.bezierCurveTo(262.601013,-74.400002,277.800995,-93.199997,274.200989,-118.400002); + ctx.bezierCurveTo(274.200989,-118.400002,275.401001,-129.600006,269.401001,-130.000000); + ctx.bezierCurveTo(269.401001,-130.000000,261.001007,-131.600006,253.800995,-124.000000); + ctx.bezierCurveTo(253.800995,-124.000000,247.001007,-120.800003,244.600998,-121.199997); + ctx.lineTo(209.401001,-120.000000); + ctx.lineTo(209.401001,-120.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(264.022003,-120.989998); + ctx.bezierCurveTo(264.022003,-120.989998,266.122009,-129.919998,261.282013,-125.080002); + ctx.bezierCurveTo(261.282013,-125.080002,254.242004,-119.360001,246.761002,-119.360001); + ctx.bezierCurveTo(246.761002,-119.360001,232.240997,-117.160004,227.841003,-103.959999); + ctx.bezierCurveTo(227.841003,-103.959999,223.880997,-77.120003,231.800995,-71.400002); + ctx.bezierCurveTo(231.800995,-71.400002,236.641006,-63.919998,243.681000,-70.519997); + ctx.bezierCurveTo(250.722000,-77.120003,266.221985,-107.349998,264.022003,-120.989998); + ctx.lineTo(264.022003,-120.989998); +ctx.fill(); + + + + +ctx.fillStyle='#323232'; +ctx.beginPath(); +ctx.moveTo(263.648010,-120.632004); + ctx.bezierCurveTo(263.648010,-120.632004,265.738007,-129.376007,260.985992,-124.624001); + ctx.bezierCurveTo(260.985992,-124.624001,254.074005,-119.008003,246.729004,-119.008003); + ctx.bezierCurveTo(246.729004,-119.008003,232.473007,-116.848000,228.153000,-103.888000); + ctx.bezierCurveTo(228.153000,-103.888000,224.264999,-77.536003,232.041000,-71.919998); + ctx.bezierCurveTo(232.041000,-71.919998,236.792999,-64.575996,243.705002,-71.056000); + ctx.bezierCurveTo(250.617996,-77.536003,265.808014,-107.239998,263.648010,-120.632004); + ctx.lineTo(263.648010,-120.632004); +ctx.fill(); + + + + +ctx.fillStyle='#666666'; +ctx.beginPath(); +ctx.moveTo(263.273987,-120.274002); + ctx.bezierCurveTo(263.273987,-120.274002,265.354004,-128.832001,260.690002,-124.167999); + ctx.bezierCurveTo(260.690002,-124.167999,253.906006,-118.655998,246.697006,-118.655998); + ctx.bezierCurveTo(246.697006,-118.655998,232.705002,-116.536003,228.464996,-103.816002); + ctx.bezierCurveTo(228.464996,-103.816002,224.649002,-77.952003,232.281006,-72.440002); + ctx.bezierCurveTo(232.281006,-72.440002,236.945007,-65.232002,243.729004,-71.592003); + ctx.bezierCurveTo(250.514008,-77.952003,265.394012,-107.129997,263.273987,-120.274002); + ctx.lineTo(263.273987,-120.274002); +ctx.fill(); + + + + +ctx.fillStyle='#999999'; +ctx.beginPath(); +ctx.moveTo(262.899994,-119.916000); + ctx.bezierCurveTo(262.899994,-119.916000,264.970001,-128.287994,260.394012,-123.711998); + ctx.bezierCurveTo(260.394012,-123.711998,253.738007,-118.304001,246.664993,-118.304001); + ctx.bezierCurveTo(246.664993,-118.304001,232.936996,-116.223999,228.776993,-103.744003); + ctx.bezierCurveTo(228.776993,-103.744003,225.033005,-78.367996,232.520996,-72.959999); + ctx.bezierCurveTo(232.520996,-72.959999,237.097000,-65.888000,243.753006,-72.127998); + ctx.bezierCurveTo(250.410004,-78.367996,264.980011,-107.019997,262.899994,-119.916000); + ctx.lineTo(262.899994,-119.916000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(262.526001,-119.557999); + ctx.bezierCurveTo(262.526001,-119.557999,264.585999,-127.744003,260.097992,-123.255997); + ctx.bezierCurveTo(260.097992,-123.255997,253.569000,-117.952003,246.632996,-117.952003); + ctx.bezierCurveTo(246.632996,-117.952003,233.169006,-115.912003,229.089005,-103.671997); + ctx.bezierCurveTo(229.089005,-103.671997,225.417007,-78.783997,232.761002,-73.480003); + ctx.bezierCurveTo(232.761002,-73.480003,237.248993,-66.543999,243.776993,-72.664001); + ctx.bezierCurveTo(250.304993,-78.783997,264.566010,-106.910004,262.526001,-119.557999); + ctx.lineTo(262.526001,-119.557999); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(262.151001,-119.199997); + ctx.bezierCurveTo(262.151001,-119.199997,264.200989,-127.199997,259.800995,-122.800003); + ctx.bezierCurveTo(259.800995,-122.800003,253.401001,-117.599998,246.600998,-117.599998); + ctx.bezierCurveTo(246.600998,-117.599998,233.401001,-115.599998,229.401001,-103.599998); + ctx.bezierCurveTo(229.401001,-103.599998,225.800995,-79.199997,233.001007,-74.000000); + ctx.bezierCurveTo(233.001007,-74.000000,237.401001,-67.199997,243.800995,-73.199997); + ctx.bezierCurveTo(250.201004,-79.199997,264.151001,-106.800003,262.151001,-119.199997); + ctx.lineTo(262.151001,-119.199997); +ctx.fill(); + + + + +ctx.fillStyle='#992600'; +ctx.beginPath(); +ctx.moveTo(50.599998,84.000000); + ctx.bezierCurveTo(50.599998,84.000000,30.200001,64.800003,22.200001,64.000000); + ctx.bezierCurveTo(22.200001,64.000000,-12.200000,60.000000,-27.000000,78.000000); + ctx.bezierCurveTo(-27.000000,78.000000,-9.400000,57.599998,18.200001,63.200001); + ctx.bezierCurveTo(18.200001,63.200001,-3.400000,58.799999,-15.800000,62.000000); + ctx.bezierCurveTo(-15.800000,62.000000,-32.599998,62.000000,-42.200001,76.000000); + ctx.lineTo(-45.000000,80.800003); + ctx.bezierCurveTo(-45.000000,80.800003,-41.000000,66.000000,-22.600000,60.000000); + ctx.bezierCurveTo(-22.600000,60.000000,0.200000,55.200001,11.000000,60.000000); + ctx.bezierCurveTo(11.000000,60.000000,-10.600000,53.200001,-20.600000,55.200001); + ctx.bezierCurveTo(-20.600000,55.200001,-51.000000,52.799999,-63.799999,79.199997); + ctx.bezierCurveTo(-63.799999,79.199997,-59.799999,64.800003,-45.000000,57.599998); + ctx.bezierCurveTo(-45.000000,57.599998,-31.400000,48.799999,-11.000000,51.599998); + ctx.bezierCurveTo(-11.000000,51.599998,3.400000,54.799999,8.600000,57.200001); + ctx.bezierCurveTo(13.800000,59.599998,12.600000,56.799999,4.200000,52.000000); + ctx.bezierCurveTo(4.200000,52.000000,-1.400000,42.000000,-15.400000,42.400002); + ctx.bezierCurveTo(-15.400000,42.400002,-58.200001,46.000000,-68.599998,58.000000); + ctx.bezierCurveTo(-68.599998,58.000000,-55.000000,46.799999,-44.599998,44.000000); + ctx.bezierCurveTo(-44.599998,44.000000,-22.200001,36.000000,-13.800000,36.799999); + ctx.bezierCurveTo(-13.800000,36.799999,11.000000,37.799999,18.600000,33.799999); + ctx.bezierCurveTo(18.600000,33.799999,7.400000,38.799999,10.600000,42.000000); + ctx.bezierCurveTo(13.800000,45.200001,20.600000,52.799999,20.600000,54.000000); + ctx.bezierCurveTo(20.600000,55.200001,44.799999,77.300003,48.400002,81.699997); + ctx.lineTo(50.599998,84.000000); + ctx.lineTo(50.599998,84.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(189.000000,278.000000); + ctx.bezierCurveTo(189.000000,278.000000,173.500000,241.500000,161.000000,232.000000); + ctx.bezierCurveTo(161.000000,232.000000,187.000000,248.000000,190.500000,266.000000); + ctx.bezierCurveTo(190.500000,266.000000,190.500000,276.000000,189.000000,278.000000); + ctx.lineTo(189.000000,278.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(236.000000,285.500000); + ctx.bezierCurveTo(236.000000,285.500000,209.500000,230.500000,191.000000,206.500000); + ctx.bezierCurveTo(191.000000,206.500000,234.500000,244.000000,239.500000,270.500000); + ctx.lineTo(240.000000,276.000000); + ctx.lineTo(237.000000,273.500000); + ctx.bezierCurveTo(237.000000,273.500000,236.500000,282.500000,236.000000,285.500000); + ctx.lineTo(236.000000,285.500000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(292.500000,237.000000); + ctx.bezierCurveTo(292.500000,237.000000,230.000000,177.500000,228.500000,175.000000); + ctx.bezierCurveTo(228.500000,175.000000,289.000000,241.000000,292.000000,248.500000); + ctx.bezierCurveTo(292.000000,248.500000,290.000000,239.500000,292.500000,237.000000); + ctx.lineTo(292.500000,237.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(104.000000,280.500000); + ctx.bezierCurveTo(104.000000,280.500000,123.500000,228.500000,142.500000,251.000000); + ctx.bezierCurveTo(142.500000,251.000000,157.500000,261.000000,157.000000,264.000000); + ctx.bezierCurveTo(157.000000,264.000000,153.000000,257.500000,135.000000,258.000000); + ctx.bezierCurveTo(135.000000,258.000000,116.000000,255.000000,104.000000,280.500000); + ctx.lineTo(104.000000,280.500000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(294.500000,153.000000); + ctx.bezierCurveTo(294.500000,153.000000,249.500000,124.500000,242.000000,123.000000); + ctx.bezierCurveTo(230.192993,120.639000,291.500000,152.000000,296.500000,162.500000); + ctx.bezierCurveTo(296.500000,162.500000,298.500000,160.000000,294.500000,153.000000); + ctx.lineTo(294.500000,153.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(143.800995,259.601013); + ctx.bezierCurveTo(143.800995,259.601013,164.201004,257.601013,171.001007,250.800995); + ctx.lineTo(175.401001,254.401001); + ctx.lineTo(193.001007,216.001007); + ctx.lineTo(196.600998,221.201004); + ctx.bezierCurveTo(196.600998,221.201004,211.001007,206.401001,210.201004,198.401001); + ctx.bezierCurveTo(209.401001,190.401001,223.001007,204.401001,223.001007,204.401001); + ctx.bezierCurveTo(223.001007,204.401001,222.201004,192.800995,229.401001,199.600998); + ctx.bezierCurveTo(229.401001,199.600998,227.001007,184.001007,235.401001,192.001007); + ctx.bezierCurveTo(235.401001,192.001007,224.863998,161.843994,247.401001,187.600998); + ctx.bezierCurveTo(253.001007,194.001007,248.600998,187.201004,248.600998,187.201004); + ctx.bezierCurveTo(248.600998,187.201004,222.600998,139.201004,244.201004,153.600998); + ctx.bezierCurveTo(244.201004,153.600998,246.201004,130.800995,245.001007,126.401001); + ctx.bezierCurveTo(243.800995,122.000999,241.800995,99.599998,237.001007,94.400002); + ctx.bezierCurveTo(232.201004,89.199997,237.401001,87.599998,243.001007,92.800003); + ctx.bezierCurveTo(243.001007,92.800003,231.800995,68.800003,245.001007,80.800003); + ctx.bezierCurveTo(245.001007,80.800003,241.401001,65.599998,237.001007,62.799999); + ctx.bezierCurveTo(237.001007,62.799999,231.401001,45.599998,246.600998,56.400002); + ctx.bezierCurveTo(246.600998,56.400002,242.201004,44.000000,239.001007,40.799999); + ctx.bezierCurveTo(239.001007,40.799999,227.401001,13.200000,234.600998,18.000000); + ctx.lineTo(239.001007,21.600000); + ctx.bezierCurveTo(239.001007,21.600000,232.201004,7.600000,238.600998,12.000000); + ctx.bezierCurveTo(245.001007,16.400000,245.001007,16.000000,245.001007,16.000000); + ctx.bezierCurveTo(245.001007,16.000000,223.800995,-17.200001,244.201004,0.400000); + ctx.bezierCurveTo(244.201004,0.400000,236.042007,-13.518000,232.600998,-20.400000); + ctx.bezierCurveTo(232.600998,-20.400000,213.800995,-40.799999,228.201004,-34.400002); + ctx.lineTo(233.001007,-32.799999); + ctx.bezierCurveTo(233.001007,-32.799999,224.201004,-42.799999,216.201004,-44.400002); + ctx.bezierCurveTo(208.201004,-46.000000,218.600998,-52.400002,225.001007,-50.400002); + ctx.bezierCurveTo(231.401001,-48.400002,247.001007,-40.799999,247.001007,-40.799999); + ctx.bezierCurveTo(247.001007,-40.799999,259.800995,-22.000000,263.800995,-21.600000); + ctx.bezierCurveTo(263.800995,-21.600000,243.800995,-29.200001,249.800995,-21.200001); + ctx.bezierCurveTo(249.800995,-21.200001,264.200989,-7.200000,257.001007,-7.600000); + ctx.bezierCurveTo(257.001007,-7.600000,251.001007,-0.400000,255.800995,8.400000); + ctx.bezierCurveTo(255.800995,8.400000,237.341995,-9.991000,252.201004,15.600000); + ctx.lineTo(259.001007,32.000000); + ctx.bezierCurveTo(259.001007,32.000000,234.600998,7.200000,245.800995,29.200001); + ctx.bezierCurveTo(245.800995,29.200001,263.001007,52.799999,265.001007,53.200001); + ctx.bezierCurveTo(267.001007,53.599998,271.401001,62.400002,271.401001,62.400002); + ctx.lineTo(267.001007,60.400002); + ctx.lineTo(272.200989,69.199997); + ctx.bezierCurveTo(272.200989,69.199997,261.001007,57.200001,267.001007,70.400002); + ctx.lineTo(272.601013,84.800003); + ctx.bezierCurveTo(272.601013,84.800003,252.201004,62.799999,265.800995,92.400002); + ctx.bezierCurveTo(265.800995,92.400002,249.401001,87.199997,258.200989,104.400002); + ctx.bezierCurveTo(258.200989,104.400002,256.601013,120.401001,257.001007,125.600998); + ctx.bezierCurveTo(257.401001,130.800995,258.601013,159.201004,254.201004,167.201004); + ctx.bezierCurveTo(249.800995,175.201004,260.200989,194.401001,262.200989,198.401001); + ctx.bezierCurveTo(264.200989,202.401001,267.800995,213.201004,259.001007,204.001007); + ctx.bezierCurveTo(250.201004,194.800995,254.600998,200.401001,256.601013,209.201004); + ctx.bezierCurveTo(258.601013,218.001007,264.601013,233.600998,263.800995,239.201004); + ctx.bezierCurveTo(263.800995,239.201004,262.601013,240.401001,259.401001,236.800995); + ctx.bezierCurveTo(259.401001,236.800995,244.600998,214.001007,246.201004,228.401001); + ctx.bezierCurveTo(246.201004,228.401001,245.001007,236.401001,241.800995,245.201004); + ctx.bezierCurveTo(241.800995,245.201004,238.600998,256.001007,238.600998,247.201004); + ctx.bezierCurveTo(238.600998,247.201004,235.401001,230.401001,232.600998,238.001007); + ctx.bezierCurveTo(229.800995,245.600998,226.201004,251.600998,223.401001,254.001007); + ctx.bezierCurveTo(220.600998,256.401001,215.401001,233.600998,214.201004,244.001007); + ctx.bezierCurveTo(214.201004,244.001007,202.201004,231.600998,197.401001,248.001007); + ctx.lineTo(185.800995,264.401001); + ctx.bezierCurveTo(185.800995,264.401001,185.401001,252.001007,184.201004,258.001007); + ctx.bezierCurveTo(184.201004,258.001007,154.201004,264.001007,143.800995,259.601013); + ctx.lineTo(143.800995,259.601013); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(109.401001,-97.199997); + ctx.bezierCurveTo(109.401001,-97.199997,97.801003,-105.199997,93.801003,-104.800003); + ctx.bezierCurveTo(89.801003,-104.400002,121.401001,-113.599998,162.600998,-86.000000); + ctx.bezierCurveTo(162.600998,-86.000000,167.401001,-83.199997,171.001007,-83.599998); + ctx.bezierCurveTo(171.001007,-83.599998,174.201004,-81.199997,171.401001,-77.599998); + ctx.bezierCurveTo(171.401001,-77.599998,162.600998,-68.000000,173.800995,-56.799999); + ctx.bezierCurveTo(173.800995,-56.799999,192.201004,-50.000000,186.600998,-58.799999); + ctx.bezierCurveTo(186.600998,-58.799999,197.401001,-54.799999,199.800995,-50.799999); + ctx.bezierCurveTo(202.201004,-46.799999,201.001007,-50.799999,201.001007,-50.799999); + ctx.bezierCurveTo(201.001007,-50.799999,194.600998,-58.000000,188.600998,-63.200001); + ctx.bezierCurveTo(188.600998,-63.200001,183.401001,-65.199997,180.600998,-73.599998); + ctx.bezierCurveTo(177.800995,-82.000000,175.401001,-92.000000,179.800995,-95.199997); + ctx.bezierCurveTo(179.800995,-95.199997,175.800995,-90.800003,176.600998,-94.800003); + ctx.bezierCurveTo(177.401001,-98.800003,181.001007,-102.400002,182.600998,-102.800003); + ctx.bezierCurveTo(184.201004,-103.199997,200.600998,-119.000000,207.401001,-119.400002); + ctx.bezierCurveTo(207.401001,-119.400002,198.201004,-118.000000,195.201004,-119.000000); + ctx.bezierCurveTo(192.201004,-120.000000,165.600998,-131.399994,159.600998,-132.600006); + ctx.bezierCurveTo(159.600998,-132.600006,142.800995,-139.199997,154.800995,-137.199997); + ctx.bezierCurveTo(154.800995,-137.199997,190.600998,-133.399994,208.800995,-120.199997); + ctx.bezierCurveTo(208.800995,-120.199997,201.600998,-128.600006,183.201004,-135.600006); + ctx.bezierCurveTo(183.201004,-135.600006,161.001007,-148.199997,125.801003,-143.199997); + ctx.bezierCurveTo(125.801003,-143.199997,108.000999,-140.000000,100.200996,-138.199997); + ctx.bezierCurveTo(100.200996,-138.199997,97.600998,-138.800003,97.000999,-139.199997); + ctx.bezierCurveTo(96.401001,-139.600006,84.599998,-148.600006,57.000000,-141.600006); + ctx.bezierCurveTo(57.000000,-141.600006,40.000000,-137.000000,31.400000,-132.199997); + ctx.bezierCurveTo(31.400000,-132.199997,16.200001,-131.000000,12.600000,-127.800003); + ctx.bezierCurveTo(12.600000,-127.800003,-6.000000,-113.199997,-8.000000,-112.400002); + ctx.bezierCurveTo(-10.000000,-111.599998,-21.400000,-104.000000,-22.200001,-103.599998); + ctx.bezierCurveTo(-22.200001,-103.599998,2.400000,-110.199997,4.800000,-112.599998); + ctx.bezierCurveTo(7.200000,-115.000000,24.600000,-117.599998,27.000000,-116.199997); + ctx.bezierCurveTo(29.400000,-114.800003,37.799999,-115.400002,28.200001,-114.800003); + ctx.bezierCurveTo(28.200001,-114.800003,103.801003,-100.000000,104.600998,-98.000000); + ctx.bezierCurveTo(105.401001,-96.000000,109.401001,-97.199997,109.401001,-97.199997); + ctx.lineTo(109.401001,-97.199997); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(180.800995,-106.400002); + ctx.bezierCurveTo(180.800995,-106.400002,170.600998,-113.800003,168.600998,-113.800003); + ctx.bezierCurveTo(166.600998,-113.800003,154.201004,-124.000000,150.001007,-123.599998); + ctx.bezierCurveTo(145.800995,-123.199997,133.600998,-133.199997,106.200996,-125.000000); + ctx.bezierCurveTo(106.200996,-125.000000,105.600998,-127.000000,109.200996,-127.800003); + ctx.bezierCurveTo(109.200996,-127.800003,115.600998,-130.000000,116.000999,-130.600006); + ctx.bezierCurveTo(116.000999,-130.600006,136.201004,-134.800003,143.401001,-131.199997); + ctx.bezierCurveTo(143.401001,-131.199997,152.600998,-128.600006,158.800995,-122.400002); + ctx.bezierCurveTo(158.800995,-122.400002,170.001007,-119.199997,173.201004,-120.199997); + ctx.bezierCurveTo(173.201004,-120.199997,182.001007,-118.000000,182.401001,-116.199997); + ctx.bezierCurveTo(182.401001,-116.199997,188.201004,-113.199997,186.401001,-110.599998); + ctx.bezierCurveTo(186.401001,-110.599998,186.800995,-109.000000,180.800995,-106.400002); + ctx.lineTo(180.800995,-106.400002); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(168.330002,-108.509003); + ctx.bezierCurveTo(169.136993,-107.876999,170.156006,-107.778999,170.761002,-106.970001); + ctx.bezierCurveTo(170.994995,-106.655998,170.705994,-106.330002,170.391006,-106.233002); + ctx.bezierCurveTo(169.348007,-105.916000,168.292007,-106.486000,167.149994,-105.898003); + ctx.bezierCurveTo(166.748001,-105.691002,166.106003,-105.873001,165.552994,-106.022003); + ctx.bezierCurveTo(163.921005,-106.462997,162.091995,-106.487999,160.401001,-105.800003); + ctx.bezierCurveTo(158.416000,-106.929001,156.056000,-106.345001,153.975006,-107.346001); + ctx.bezierCurveTo(153.917007,-107.373001,153.695007,-107.027000,153.621002,-107.054001); + ctx.bezierCurveTo(150.574997,-108.198997,146.832001,-107.916000,144.401001,-110.199997); + ctx.bezierCurveTo(141.973007,-110.612000,139.615997,-111.073997,137.188004,-111.753998); + ctx.bezierCurveTo(135.369995,-112.263000,133.960999,-113.251999,132.341003,-114.084000); + ctx.bezierCurveTo(130.964005,-114.792000,129.507004,-115.314003,127.973000,-115.685997); + ctx.bezierCurveTo(126.110001,-116.138000,124.278999,-116.026001,122.386002,-116.545998); + ctx.bezierCurveTo(122.292999,-116.570999,122.100998,-116.226997,122.018997,-116.253998); + ctx.bezierCurveTo(121.695000,-116.362000,121.404999,-116.945000,121.234001,-116.891998); + ctx.bezierCurveTo(119.553001,-116.370003,118.065002,-117.342003,116.401001,-117.000000); + ctx.bezierCurveTo(115.223000,-118.223999,113.495003,-117.978996,111.948997,-118.420998); + ctx.bezierCurveTo(108.985001,-119.268997,105.831001,-117.999001,102.801003,-119.000000); + ctx.bezierCurveTo(106.914001,-120.842003,111.600998,-119.610001,115.663002,-121.679001); + ctx.bezierCurveTo(117.990997,-122.864998,120.653000,-121.763000,123.223000,-122.523003); + ctx.bezierCurveTo(123.709999,-122.667000,124.401001,-122.869003,124.801003,-122.199997); + ctx.bezierCurveTo(124.934998,-122.334999,125.116997,-122.573997,125.175003,-122.545998); + ctx.bezierCurveTo(127.625000,-121.389000,129.940002,-120.114998,132.421997,-119.049004); + ctx.bezierCurveTo(132.763000,-118.903000,133.294998,-119.135002,133.546997,-118.932999); + ctx.bezierCurveTo(135.067001,-117.717003,137.009995,-117.820000,138.401001,-116.599998); + ctx.bezierCurveTo(140.098999,-117.101997,141.891998,-116.722000,143.621002,-117.346001); + ctx.bezierCurveTo(143.697998,-117.373001,143.932007,-117.031998,143.964996,-117.054001); + ctx.bezierCurveTo(145.095001,-117.802002,146.250000,-117.530998,147.141998,-117.226997); + ctx.bezierCurveTo(147.479996,-117.112000,148.143005,-116.864998,148.447998,-116.791000); + ctx.bezierCurveTo(149.574005,-116.514999,150.429993,-116.035004,151.608994,-115.851997); + ctx.bezierCurveTo(151.723007,-115.834000,151.908005,-116.174004,151.979996,-116.146004); + ctx.bezierCurveTo(153.102997,-115.708000,154.145004,-115.764000,154.800995,-114.599998); + ctx.bezierCurveTo(154.936005,-114.735001,155.100998,-114.973000,155.182999,-114.945999); + ctx.bezierCurveTo(156.210007,-114.608002,156.858994,-113.852997,157.960007,-113.612000); + ctx.bezierCurveTo(158.445007,-113.505997,159.057007,-112.879997,159.632996,-112.704002); + ctx.bezierCurveTo(162.024994,-111.973000,163.867996,-110.444000,166.061996,-109.549004); + ctx.bezierCurveTo(166.820999,-109.238998,167.697006,-109.004997,168.330002,-108.509003); + ctx.lineTo(168.330002,-108.509003); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(91.695999,-122.738998); + ctx.bezierCurveTo(89.178001,-124.463997,86.809998,-125.570000,84.367996,-127.356003); + ctx.bezierCurveTo(84.186996,-127.488998,83.827003,-127.319000,83.625000,-127.441002); + ctx.bezierCurveTo(82.617996,-128.050003,81.730003,-128.630997,80.748001,-129.326996); + ctx.bezierCurveTo(80.209000,-129.709000,79.388000,-129.697998,78.879997,-129.955994); + ctx.bezierCurveTo(76.335999,-131.248001,73.707001,-131.806000,71.199997,-133.000000); + ctx.bezierCurveTo(71.882004,-133.638000,73.003998,-133.393997,73.599998,-134.199997); + ctx.bezierCurveTo(73.794998,-133.919998,74.032997,-133.636002,74.386002,-133.826996); + ctx.bezierCurveTo(76.064003,-134.731003,77.914001,-134.884003,79.589996,-134.794006); + ctx.bezierCurveTo(81.293999,-134.701996,83.014000,-134.397003,84.789001,-134.125000); + ctx.bezierCurveTo(85.096001,-134.078003,85.294998,-133.554993,85.617996,-133.457993); + ctx.bezierCurveTo(87.846001,-132.794998,90.235001,-133.320007,92.353996,-132.481995); + ctx.bezierCurveTo(93.945000,-131.852997,95.514999,-131.029999,96.753998,-129.755005); + ctx.bezierCurveTo(97.005997,-129.494995,96.681000,-129.194000,96.401001,-129.000000); + ctx.bezierCurveTo(96.789001,-129.108994,97.061996,-128.903000,97.172997,-128.589996); + ctx.bezierCurveTo(97.257004,-128.350998,97.257004,-128.048996,97.172997,-127.809998); + ctx.bezierCurveTo(97.060997,-127.498001,96.781998,-127.397003,96.407997,-127.346001); + ctx.bezierCurveTo(95.000999,-127.155998,96.773003,-128.535995,96.072998,-128.087997); + ctx.bezierCurveTo(94.800003,-127.274002,95.545998,-125.867996,94.801003,-124.599998); + ctx.bezierCurveTo(94.521004,-124.793999,94.291000,-125.012001,94.401001,-125.400002); + ctx.bezierCurveTo(94.635002,-124.877998,94.032997,-124.587997,93.864998,-124.272003); + ctx.bezierCurveTo(93.480003,-123.546997,92.581001,-122.132004,91.695999,-122.738998); + ctx.lineTo(91.695999,-122.738998); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(59.198002,-115.390999); + ctx.bezierCurveTo(56.043999,-116.184998,52.993999,-116.070000,49.978001,-117.346001); + ctx.bezierCurveTo(49.910999,-117.374001,49.688000,-117.027000,49.624001,-117.054001); + ctx.bezierCurveTo(48.257999,-117.648003,47.340000,-118.613998,46.264000,-119.660004); + ctx.bezierCurveTo(45.351002,-120.547997,43.693001,-120.161003,42.418999,-120.648003); + ctx.bezierCurveTo(42.095001,-120.772003,41.891998,-121.283997,41.591000,-121.322998); + ctx.bezierCurveTo(40.372002,-121.480003,39.445000,-122.429001,38.400002,-123.000000); + ctx.bezierCurveTo(40.736000,-123.794998,43.146999,-123.764000,45.609001,-124.148003); + ctx.bezierCurveTo(45.722000,-124.166000,45.867001,-123.845001,46.000000,-123.845001); + ctx.bezierCurveTo(46.136002,-123.845001,46.265999,-124.066002,46.400002,-124.199997); + ctx.bezierCurveTo(46.595001,-123.919998,46.896999,-123.594002,47.153999,-123.848000); + ctx.bezierCurveTo(47.702000,-124.388000,48.257999,-124.197998,48.798000,-124.157997); + ctx.bezierCurveTo(48.942001,-124.148003,49.067001,-123.845001,49.200001,-123.845001); + ctx.bezierCurveTo(49.335999,-123.845001,49.466999,-124.155998,49.599998,-124.155998); + ctx.bezierCurveTo(49.736000,-124.154999,49.867001,-123.845001,50.000000,-123.845001); + ctx.bezierCurveTo(50.136002,-123.845001,50.265999,-124.066002,50.400002,-124.199997); + ctx.bezierCurveTo(51.091999,-123.417999,51.977001,-123.972000,52.799000,-123.792999); + ctx.bezierCurveTo(53.837002,-123.566002,54.104000,-122.417999,55.178001,-122.120003); + ctx.bezierCurveTo(59.893002,-120.816002,64.029999,-118.670998,68.392998,-116.584000); + ctx.bezierCurveTo(68.699997,-116.436996,68.910004,-116.189003,68.800003,-115.800003); + ctx.bezierCurveTo(69.067001,-115.800003,69.379997,-115.888000,69.570000,-115.755997); + ctx.bezierCurveTo(70.627998,-115.024002,71.668999,-114.475998,72.365997,-113.377998); + ctx.bezierCurveTo(72.582001,-113.039001,72.252998,-112.632004,72.019997,-112.683998); + ctx.bezierCurveTo(67.591003,-113.679001,63.584999,-114.287003,59.198002,-115.390999); + ctx.lineTo(59.198002,-115.390999); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(45.338001,-71.179001); + ctx.bezierCurveTo(43.745998,-72.398003,43.161999,-74.429001,42.034000,-76.221001); + ctx.bezierCurveTo(41.820000,-76.560997,42.094002,-76.875000,42.410999,-76.963997); + ctx.bezierCurveTo(42.971001,-77.123001,43.514000,-76.644997,43.923000,-76.443001); + ctx.bezierCurveTo(45.667999,-75.581001,47.202999,-74.338997,49.200001,-74.199997); + ctx.bezierCurveTo(51.189999,-71.966003,55.450001,-71.581001,55.457001,-68.199997); + ctx.bezierCurveTo(55.458000,-67.341003,54.029999,-68.259003,53.599998,-67.400002); + ctx.bezierCurveTo(51.148998,-68.403000,48.759998,-68.300003,46.380001,-69.766998); + ctx.bezierCurveTo(45.763000,-70.148003,46.092999,-70.600998,45.338001,-71.179001); + ctx.lineTo(45.338001,-71.179001); +ctx.fill(); + + + + +ctx.fillStyle='#cc7226'; +ctx.beginPath(); +ctx.moveTo(17.799999,-123.755997); + ctx.bezierCurveTo(17.934999,-123.754997,24.966000,-123.522003,24.948999,-123.407997); + ctx.bezierCurveTo(24.903999,-123.098999,17.174000,-122.050003,16.809999,-122.220001); + ctx.bezierCurveTo(16.646000,-122.295998,9.134000,-119.865997,9.000000,-120.000000); + ctx.bezierCurveTo(9.268000,-120.135002,17.534000,-123.755997,17.799999,-123.755997); + ctx.lineTo(17.799999,-123.755997); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(33.200001,-114.000000); + ctx.bezierCurveTo(33.200001,-114.000000,18.400000,-112.199997,14.000000,-111.000000); + ctx.bezierCurveTo(9.600000,-109.800003,-9.000000,-102.199997,-12.000000,-100.199997); + ctx.bezierCurveTo(-12.000000,-100.199997,-25.400000,-94.800003,-42.400002,-74.800003); + ctx.bezierCurveTo(-42.400002,-74.800003,-34.799999,-78.199997,-32.599998,-81.000000); + ctx.bezierCurveTo(-32.599998,-81.000000,-19.000000,-93.599998,-19.200001,-91.000000); + ctx.bezierCurveTo(-19.200001,-91.000000,-7.000000,-99.599998,-7.600000,-97.400002); + ctx.bezierCurveTo(-7.600000,-97.400002,16.799999,-108.599998,14.800000,-105.400002); + ctx.bezierCurveTo(14.800000,-105.400002,36.400002,-110.000000,35.400002,-108.000000); + ctx.bezierCurveTo(35.400002,-108.000000,54.200001,-103.599998,51.400002,-103.400002); + ctx.bezierCurveTo(51.400002,-103.400002,45.599998,-102.199997,52.000000,-98.599998); + ctx.bezierCurveTo(52.000000,-98.599998,48.599998,-94.199997,43.200001,-98.199997); + ctx.bezierCurveTo(37.799999,-102.199997,40.799999,-100.000000,35.799999,-99.000000); + ctx.bezierCurveTo(35.799999,-99.000000,33.200001,-98.199997,28.600000,-102.199997); + ctx.bezierCurveTo(28.600000,-102.199997,23.000000,-106.800003,14.200000,-103.199997); + ctx.bezierCurveTo(14.200000,-103.199997,-16.400000,-90.599998,-18.400000,-90.000000); + ctx.bezierCurveTo(-18.400000,-90.000000,-22.000000,-87.199997,-24.400000,-83.599998); + ctx.bezierCurveTo(-24.400000,-83.599998,-30.200001,-79.199997,-33.200001,-77.800003); + ctx.bezierCurveTo(-33.200001,-77.800003,-46.000000,-66.199997,-47.200001,-64.800003); + ctx.bezierCurveTo(-47.200001,-64.800003,-50.599998,-59.599998,-51.400002,-59.200001); + ctx.bezierCurveTo(-51.400002,-59.200001,-45.000000,-63.000000,-43.000000,-65.000000); + ctx.bezierCurveTo(-43.000000,-65.000000,-29.000000,-75.000000,-23.600000,-75.800003); + ctx.bezierCurveTo(-23.600000,-75.800003,-19.200001,-78.800003,-18.400000,-80.199997); + ctx.bezierCurveTo(-18.400000,-80.199997,-4.000000,-89.400002,0.200000,-89.400002); + ctx.bezierCurveTo(0.200000,-89.400002,9.400000,-84.199997,11.800000,-91.199997); + ctx.bezierCurveTo(11.800000,-91.199997,17.600000,-93.000000,23.200001,-91.800003); + ctx.bezierCurveTo(23.200001,-91.800003,26.400000,-94.400002,25.600000,-96.599998); + ctx.bezierCurveTo(25.600000,-96.599998,27.200001,-98.400002,28.200001,-94.599998); + ctx.bezierCurveTo(28.200001,-94.599998,31.600000,-91.000000,36.400002,-93.000000); + ctx.bezierCurveTo(36.400002,-93.000000,40.400002,-93.199997,38.400002,-90.800003); + ctx.bezierCurveTo(38.400002,-90.800003,34.000000,-87.000000,22.200001,-86.800003); + ctx.bezierCurveTo(22.200001,-86.800003,9.800000,-86.199997,-6.600000,-78.599998); + ctx.bezierCurveTo(-6.600000,-78.599998,-36.400002,-68.199997,-45.599998,-57.799999); + ctx.bezierCurveTo(-45.599998,-57.799999,-52.000000,-49.000000,-57.400002,-47.799999); + ctx.bezierCurveTo(-57.400002,-47.799999,-63.200001,-47.000000,-69.199997,-39.599998); + ctx.bezierCurveTo(-69.199997,-39.599998,-59.400002,-45.400002,-50.400002,-45.400002); + ctx.bezierCurveTo(-50.400002,-45.400002,-46.400002,-47.799999,-50.200001,-44.200001); + ctx.bezierCurveTo(-50.200001,-44.200001,-53.799999,-36.599998,-52.200001,-31.200001); + ctx.bezierCurveTo(-52.200001,-31.200001,-52.799999,-26.000000,-53.599998,-24.400000); + ctx.bezierCurveTo(-53.599998,-24.400000,-61.400002,-11.600000,-61.400002,-9.200000); + ctx.bezierCurveTo(-61.400002,-6.800000,-60.200001,3.000000,-59.799999,3.600000); + ctx.bezierCurveTo(-59.400002,4.200000,-60.799999,2.000000,-57.000000,4.400000); + ctx.bezierCurveTo(-53.200001,6.800000,-50.400002,8.400000,-49.599998,11.200000); + ctx.bezierCurveTo(-48.799999,14.000000,-51.599998,5.800000,-51.799999,4.000000); + ctx.bezierCurveTo(-52.000000,2.200000,-56.200001,-5.000000,-55.400002,-7.400000); + ctx.bezierCurveTo(-55.400002,-7.400000,-54.400002,-6.400000,-53.599998,-5.000000); + ctx.bezierCurveTo(-53.599998,-5.000000,-54.200001,-5.600000,-53.599998,-9.200000); + ctx.bezierCurveTo(-53.599998,-9.200000,-52.799999,-14.400000,-51.400002,-17.600000); + ctx.bezierCurveTo(-50.000000,-20.799999,-48.000000,-24.600000,-47.599998,-25.400000); + ctx.bezierCurveTo(-47.200001,-26.200001,-47.200001,-32.000000,-45.799999,-29.400000); + ctx.lineTo(-42.400002,-26.799999); + ctx.bezierCurveTo(-42.400002,-26.799999,-45.200001,-29.400000,-43.000000,-31.600000); + ctx.bezierCurveTo(-43.000000,-31.600000,-44.000000,-37.200001,-42.200001,-39.799999); + ctx.bezierCurveTo(-42.200001,-39.799999,-35.200001,-48.200001,-33.599998,-49.200001); + ctx.bezierCurveTo(-32.000000,-50.200001,-33.400002,-49.799999,-33.400002,-49.799999); + ctx.bezierCurveTo(-33.400002,-49.799999,-27.400000,-54.000000,-33.200001,-52.400002); + ctx.bezierCurveTo(-33.200001,-52.400002,-37.200001,-50.799999,-40.200001,-50.799999); + ctx.bezierCurveTo(-40.200001,-50.799999,-47.799999,-48.799999,-43.799999,-53.000000); + ctx.bezierCurveTo(-39.799999,-57.200001,-29.799999,-62.599998,-26.000000,-62.400002); + ctx.lineTo(-25.200001,-60.799999); + ctx.lineTo(-14.000000,-63.200001); + ctx.lineTo(-15.200000,-62.400002); + ctx.bezierCurveTo(-15.200000,-62.400002,-15.400000,-62.599998,-11.200000,-63.000000); + ctx.bezierCurveTo(-7.000000,-63.400002,-1.200000,-62.000000,0.200000,-63.799999); + ctx.bezierCurveTo(1.600000,-65.599998,5.000000,-66.599998,4.600000,-65.199997); + ctx.bezierCurveTo(4.200000,-63.799999,4.000000,-61.799999,4.000000,-61.799999); + ctx.bezierCurveTo(4.000000,-61.799999,9.000000,-67.599998,8.400000,-65.400002); + ctx.bezierCurveTo(7.800000,-63.200001,-0.400000,-58.000000,-1.800000,-51.799999); + ctx.lineTo(8.600000,-60.000000); + ctx.lineTo(12.200000,-63.000000); + ctx.bezierCurveTo(12.200000,-63.000000,15.800000,-60.799999,16.000000,-62.400002); + ctx.bezierCurveTo(16.200001,-64.000000,20.799999,-69.800003,22.000000,-69.599998); + ctx.bezierCurveTo(23.200001,-69.400002,25.200001,-72.199997,25.000000,-69.599998); + ctx.bezierCurveTo(24.799999,-67.000000,32.400002,-61.599998,32.400002,-61.599998); + ctx.bezierCurveTo(32.400002,-61.599998,35.599998,-63.400002,37.000000,-62.000000); + ctx.bezierCurveTo(38.400002,-60.599998,42.599998,-81.800003,42.599998,-81.800003); + ctx.lineTo(67.599998,-92.400002); + ctx.lineTo(111.200996,-95.800003); + ctx.lineTo(94.200996,-102.599998); + ctx.lineTo(33.200001,-114.000000); + ctx.lineTo(33.200001,-114.000000); +ctx.fill(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#4c0000'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(51.400002,85.000000); + ctx.bezierCurveTo(51.400002,85.000000,36.400002,68.199997,28.000000,65.599998); + ctx.bezierCurveTo(28.000000,65.599998,14.600000,58.799999,-10.000000,66.599998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#4c0000'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(24.799999,64.199997); + ctx.bezierCurveTo(24.799999,64.199997,-0.400000,56.200001,-15.800000,60.400002); + ctx.bezierCurveTo(-15.800000,60.400002,-34.200001,62.400002,-42.599998,76.199997); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#4c0000'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(21.200001,63.000000); + ctx.bezierCurveTo(21.200001,63.000000,4.200000,55.799999,-10.600000,53.599998); + ctx.bezierCurveTo(-10.600000,53.599998,-27.200001,51.000000,-43.799999,58.200001); + ctx.bezierCurveTo(-43.799999,58.200001,-56.000000,64.199997,-61.400002,74.400002); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#4c0000'; +ctx.lineWidth='2'; +ctx.beginPath(); +ctx.moveTo(22.200001,63.400002); + ctx.bezierCurveTo(22.200001,63.400002,6.800000,52.400002,5.800000,51.000000); + ctx.bezierCurveTo(5.800000,51.000000,-1.200000,40.000000,-14.200000,39.599998); + ctx.bezierCurveTo(-14.200000,39.599998,-35.599998,40.400002,-52.799999,48.400002); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(20.895000,54.407001); + ctx.bezierCurveTo(22.437000,55.869999,49.400002,84.800003,49.400002,84.800003); + ctx.bezierCurveTo(84.599998,121.401001,56.599998,87.199997,56.599998,87.199997); + ctx.bezierCurveTo(49.000000,82.400002,39.799999,63.599998,39.799999,63.599998); + ctx.bezierCurveTo(38.599998,60.799999,53.799999,70.800003,53.799999,70.800003); + ctx.bezierCurveTo(57.799999,71.599998,71.400002,90.800003,71.400002,90.800003); + ctx.bezierCurveTo(64.599998,88.400002,69.400002,95.599998,69.400002,95.599998); + ctx.bezierCurveTo(72.199997,97.599998,92.600998,113.200996,92.600998,113.200996); + ctx.bezierCurveTo(96.200996,117.200996,100.200996,118.801003,100.200996,118.801003); + ctx.bezierCurveTo(114.200996,113.600998,107.801003,126.801003,107.801003,126.801003); + ctx.bezierCurveTo(110.200996,133.600998,115.801003,122.000999,115.801003,122.000999); + ctx.bezierCurveTo(127.000999,105.199997,110.600998,107.600998,110.600998,107.600998); + ctx.bezierCurveTo(80.599998,110.401001,73.800003,94.400002,73.800003,94.400002); + ctx.bezierCurveTo(71.400002,92.000000,80.199997,94.400002,80.199997,94.400002); + ctx.bezierCurveTo(88.600998,96.400002,73.000000,82.000000,73.000000,82.000000); + ctx.bezierCurveTo(75.400002,82.000000,84.599998,88.800003,84.599998,88.800003); + ctx.bezierCurveTo(95.000999,98.000000,97.000999,96.000000,97.000999,96.000000); + ctx.bezierCurveTo(115.000999,87.199997,125.401001,94.800003,125.401001,94.800003); + ctx.bezierCurveTo(127.401001,96.400002,121.801003,103.199997,123.401001,108.401001); + ctx.bezierCurveTo(125.000999,113.600998,129.800995,126.000999,129.800995,126.000999); + ctx.bezierCurveTo(127.401001,127.600998,127.801003,138.401001,127.801003,138.401001); + ctx.bezierCurveTo(144.600998,161.600998,135.001007,159.600998,135.001007,159.600998); + ctx.bezierCurveTo(119.401001,159.201004,134.201004,166.800995,134.201004,166.800995); + ctx.bezierCurveTo(137.401001,168.800995,146.201004,176.001007,146.201004,176.001007); + ctx.bezierCurveTo(143.401001,174.800995,141.800995,180.001007,141.800995,180.001007); + ctx.bezierCurveTo(146.600998,184.001007,143.800995,188.800995,143.800995,188.800995); + ctx.bezierCurveTo(137.800995,190.001007,136.600998,194.001007,136.600998,194.001007); + ctx.bezierCurveTo(143.401001,202.001007,133.401001,202.401001,133.401001,202.401001); + ctx.bezierCurveTo(137.001007,206.800995,132.201004,218.800995,132.201004,218.800995); + ctx.bezierCurveTo(127.401001,218.800995,121.000999,224.401001,121.000999,224.401001); + ctx.bezierCurveTo(123.401001,229.201004,113.000999,234.800995,113.000999,234.800995); + ctx.bezierCurveTo(104.600998,236.401001,107.401001,243.201004,107.401001,243.201004); + ctx.bezierCurveTo(99.401001,249.201004,97.000999,265.200989,97.000999,265.200989); + ctx.bezierCurveTo(96.200996,275.601013,93.801003,278.800995,99.000999,276.800995); + ctx.bezierCurveTo(104.200996,274.800995,103.401001,262.401001,103.401001,262.401001); + ctx.bezierCurveTo(98.600998,246.800995,141.401001,230.800995,141.401001,230.800995); + ctx.bezierCurveTo(145.401001,229.201004,146.201004,224.001007,146.201004,224.001007); + ctx.bezierCurveTo(148.201004,224.401001,157.001007,232.001007,157.001007,232.001007); + ctx.bezierCurveTo(164.600998,243.201004,165.001007,234.001007,165.001007,234.001007); + ctx.bezierCurveTo(166.201004,230.401001,164.600998,224.401001,164.600998,224.401001); + ctx.bezierCurveTo(170.600998,202.800995,156.600998,196.401001,156.600998,196.401001); + ctx.bezierCurveTo(146.600998,162.800995,160.600998,171.201004,160.600998,171.201004); + ctx.bezierCurveTo(163.401001,176.800995,174.201004,182.001007,174.201004,182.001007); + ctx.lineTo(177.800995,179.600998); + ctx.bezierCurveTo(176.201004,174.800995,184.600998,168.800995,184.600998,168.800995); + ctx.bezierCurveTo(187.401001,175.201004,193.401001,167.201004,193.401001,167.201004); + ctx.bezierCurveTo(197.001007,142.800995,209.401001,157.201004,209.401001,157.201004); + ctx.bezierCurveTo(213.401001,158.401001,214.600998,151.600998,214.600998,151.600998); + ctx.bezierCurveTo(218.201004,141.201004,214.600998,127.600998,214.600998,127.600998); + ctx.bezierCurveTo(218.201004,127.200996,227.800995,133.201004,227.800995,133.201004); + ctx.bezierCurveTo(230.600998,129.600998,221.401001,112.801003,225.401001,115.200996); + ctx.bezierCurveTo(229.401001,117.600998,233.800995,119.200996,233.800995,119.200996); + ctx.bezierCurveTo(234.600998,117.200996,224.600998,104.801003,224.600998,104.801003); + ctx.bezierCurveTo(220.201004,102.000000,215.001007,81.599998,215.001007,81.599998); + ctx.bezierCurveTo(222.201004,85.199997,212.201004,70.000000,212.201004,70.000000); + ctx.bezierCurveTo(212.201004,66.800003,218.201004,55.599998,218.201004,55.599998); + ctx.bezierCurveTo(217.401001,48.799999,218.201004,49.200001,218.201004,49.200001); + ctx.bezierCurveTo(221.001007,50.400002,229.001007,52.000000,222.201004,45.599998); + ctx.bezierCurveTo(215.401001,39.200001,223.001007,34.400002,223.001007,34.400002); + ctx.bezierCurveTo(227.401001,31.600000,213.800995,32.000000,213.800995,32.000000); + ctx.bezierCurveTo(208.600998,27.600000,209.001007,23.600000,209.001007,23.600000); + ctx.bezierCurveTo(217.001007,25.600000,202.600998,11.200000,200.201004,7.600000); + ctx.bezierCurveTo(197.800995,4.000000,207.401001,-1.200000,207.401001,-1.200000); + ctx.bezierCurveTo(220.600998,-4.800000,209.001007,-8.000000,209.001007,-8.000000); + ctx.bezierCurveTo(189.401001,-7.600000,200.201004,-18.400000,200.201004,-18.400000); + ctx.bezierCurveTo(206.201004,-18.000000,204.600998,-20.400000,204.600998,-20.400000); + ctx.bezierCurveTo(199.401001,-21.600000,189.800995,-28.000000,189.800995,-28.000000); + ctx.bezierCurveTo(185.800995,-31.600000,189.401001,-30.799999,189.401001,-30.799999); + ctx.bezierCurveTo(206.201004,-29.600000,177.401001,-40.799999,177.401001,-40.799999); + ctx.bezierCurveTo(185.401001,-40.799999,167.401001,-51.200001,167.401001,-51.200001); + ctx.bezierCurveTo(165.401001,-52.799999,162.201004,-60.400002,162.201004,-60.400002); + ctx.bezierCurveTo(156.201004,-65.599998,151.401001,-72.400002,151.401001,-72.400002); + ctx.bezierCurveTo(151.001007,-76.800003,146.201004,-81.599998,146.201004,-81.599998); + ctx.bezierCurveTo(134.600998,-95.199997,129.001007,-94.800003,129.001007,-94.800003); + ctx.bezierCurveTo(114.200996,-98.400002,109.000999,-97.599998,109.000999,-97.599998); + ctx.lineTo(56.200001,-93.199997); + ctx.bezierCurveTo(29.799999,-80.400002,37.599998,-59.400002,37.599998,-59.400002); + ctx.bezierCurveTo(44.000000,-51.000000,53.200001,-54.799999,53.200001,-54.799999); + ctx.bezierCurveTo(57.799999,-61.000000,69.400002,-58.799999,69.400002,-58.799999); + ctx.bezierCurveTo(89.801003,-55.599998,87.200996,-59.200001,87.200996,-59.200001); + ctx.bezierCurveTo(84.801003,-63.799999,68.599998,-70.000000,68.400002,-70.599998); + ctx.bezierCurveTo(68.199997,-71.199997,59.400002,-74.599998,59.400002,-74.599998); + ctx.bezierCurveTo(56.400002,-75.800003,52.000000,-85.000000,52.000000,-85.000000); + ctx.bezierCurveTo(48.799999,-88.400002,64.599998,-82.599998,64.599998,-82.599998); + ctx.bezierCurveTo(63.400002,-81.599998,70.800003,-77.599998,70.800003,-77.599998); + ctx.bezierCurveTo(88.200996,-78.599998,98.801003,-67.800003,98.801003,-67.800003); + ctx.bezierCurveTo(109.600998,-51.200001,109.801003,-59.400002,109.801003,-59.400002); + ctx.bezierCurveTo(112.600998,-68.800003,100.801003,-90.000000,100.801003,-90.000000); + ctx.bezierCurveTo(101.200996,-92.000000,109.401001,-85.400002,109.401001,-85.400002); + ctx.bezierCurveTo(110.801003,-87.400002,111.600998,-81.599998,111.600998,-81.599998); + ctx.bezierCurveTo(111.801003,-79.199997,115.600998,-71.199997,115.600998,-71.199997); + ctx.bezierCurveTo(118.401001,-58.200001,122.000999,-65.599998,122.000999,-65.599998); + ctx.lineTo(126.600998,-56.200001); + ctx.bezierCurveTo(128.001007,-53.599998,122.000999,-46.000000,122.000999,-46.000000); + ctx.bezierCurveTo(121.801003,-43.200001,122.600998,-43.400002,117.000999,-35.799999); + ctx.bezierCurveTo(111.401001,-28.200001,114.801003,-23.799999,114.801003,-23.799999); + ctx.bezierCurveTo(113.401001,-17.200001,122.200996,-17.600000,122.200996,-17.600000); + ctx.bezierCurveTo(124.801003,-15.400000,128.201004,-15.400000,128.201004,-15.400000); + ctx.bezierCurveTo(130.001007,-13.400000,132.401001,-14.000000,132.401001,-14.000000); + ctx.bezierCurveTo(134.001007,-17.799999,140.201004,-15.800000,140.201004,-15.800000); + ctx.bezierCurveTo(141.600998,-18.200001,149.800995,-18.600000,149.800995,-18.600000); + ctx.bezierCurveTo(150.800995,-21.200001,151.201004,-22.799999,154.600998,-23.400000); + ctx.bezierCurveTo(158.001007,-24.000000,133.401001,-67.000000,133.401001,-67.000000); + ctx.bezierCurveTo(139.800995,-67.800003,131.600998,-80.199997,131.600998,-80.199997); + ctx.bezierCurveTo(129.401001,-86.800003,140.800995,-72.199997,143.001007,-70.800003); + ctx.bezierCurveTo(145.201004,-69.400002,146.201004,-67.199997,144.600998,-67.400002); + ctx.bezierCurveTo(143.001007,-67.599998,141.201004,-65.400002,142.600998,-65.199997); + ctx.bezierCurveTo(144.001007,-65.000000,157.001007,-50.000000,160.401001,-39.799999); + ctx.bezierCurveTo(163.800995,-29.600000,169.800995,-25.600000,176.001007,-19.600000); + ctx.bezierCurveTo(182.201004,-13.600000,181.401001,10.600000,181.401001,10.600000); + ctx.bezierCurveTo(181.001007,19.400000,187.001007,30.000000,187.001007,30.000000); + ctx.bezierCurveTo(189.001007,33.799999,184.800995,52.000000,184.800995,52.000000); + ctx.bezierCurveTo(182.800995,54.200001,184.201004,55.000000,184.201004,55.000000); + ctx.bezierCurveTo(185.201004,56.200001,192.001007,69.400002,192.001007,69.400002); + ctx.bezierCurveTo(190.201004,69.199997,193.800995,72.800003,193.800995,72.800003); + ctx.bezierCurveTo(199.001007,78.800003,192.600998,75.800003,192.600998,75.800003); + ctx.bezierCurveTo(186.600998,74.199997,193.600998,84.000000,193.600998,84.000000); + ctx.bezierCurveTo(194.800995,85.800003,185.800995,81.199997,185.800995,81.199997); + ctx.bezierCurveTo(176.600998,80.599998,188.201004,87.800003,188.201004,87.800003); + ctx.bezierCurveTo(196.800995,95.000000,185.401001,90.599998,185.401001,90.599998); + ctx.bezierCurveTo(180.800995,88.800003,184.001007,95.599998,184.001007,95.599998); + ctx.bezierCurveTo(187.201004,97.199997,204.401001,104.199997,204.401001,104.199997); + ctx.bezierCurveTo(204.800995,108.000999,201.800995,113.000999,201.800995,113.000999); + ctx.bezierCurveTo(202.201004,117.000999,200.001007,120.401001,200.001007,120.401001); + ctx.bezierCurveTo(198.800995,128.600998,198.201004,129.401001,198.201004,129.401001); + ctx.bezierCurveTo(194.001007,129.600998,186.600998,143.401001,186.600998,143.401001); + ctx.bezierCurveTo(184.800995,146.001007,174.600998,158.001007,174.600998,158.001007); + ctx.bezierCurveTo(172.600998,165.001007,154.600998,157.800995,154.600998,157.800995); + ctx.bezierCurveTo(148.001007,161.201004,150.001007,157.800995,150.001007,157.800995); + ctx.bezierCurveTo(149.600998,155.600998,154.401001,149.600998,154.401001,149.600998); + ctx.bezierCurveTo(161.401001,147.001007,158.800995,136.201004,158.800995,136.201004); + ctx.bezierCurveTo(162.800995,134.800995,151.600998,132.001007,151.800995,130.800995); + ctx.bezierCurveTo(152.001007,129.600998,157.800995,128.201004,157.800995,128.201004); + ctx.bezierCurveTo(165.800995,126.200996,161.401001,123.801003,161.401001,123.801003); + ctx.bezierCurveTo(160.800995,119.801003,163.800995,114.200996,163.800995,114.200996); + ctx.bezierCurveTo(175.401001,113.401001,163.800995,97.199997,163.800995,97.199997); + ctx.bezierCurveTo(153.001007,89.599998,152.001007,83.800003,152.001007,83.800003); + ctx.bezierCurveTo(164.600998,75.599998,156.401001,63.200001,156.600998,59.599998); + ctx.bezierCurveTo(156.800995,56.000000,158.001007,34.400002,158.001007,34.400002); + ctx.bezierCurveTo(156.001007,28.200001,153.001007,14.600000,153.001007,14.600000); + ctx.bezierCurveTo(155.201004,9.400000,162.600998,-3.200000,162.600998,-3.200000); + ctx.bezierCurveTo(165.401001,-7.400000,174.201004,-12.200000,172.001007,-15.200000); + ctx.bezierCurveTo(169.800995,-18.200001,162.001007,-16.400000,162.001007,-16.400000); + ctx.bezierCurveTo(154.201004,-17.799999,154.800995,-12.600000,154.800995,-12.600000); + ctx.bezierCurveTo(153.201004,-11.600000,152.401001,-6.600000,152.401001,-6.600000); + ctx.bezierCurveTo(151.679993,1.333000,142.800995,7.600000,142.800995,7.600000); + ctx.bezierCurveTo(131.600998,13.800000,140.800995,17.799999,140.800995,17.799999); + ctx.bezierCurveTo(146.800995,24.400000,137.001007,24.600000,137.001007,24.600000); + ctx.bezierCurveTo(126.000999,22.799999,134.201004,33.000000,134.201004,33.000000); + ctx.bezierCurveTo(145.001007,45.799999,142.001007,48.599998,142.001007,48.599998); + ctx.bezierCurveTo(131.800995,49.599998,144.401001,58.799999,144.401001,58.799999); + ctx.bezierCurveTo(144.401001,58.799999,143.600998,56.799999,143.800995,58.599998); + ctx.bezierCurveTo(144.001007,60.400002,147.001007,64.599998,147.800995,66.599998); + ctx.bezierCurveTo(148.600998,68.599998,144.600998,68.800003,144.600998,68.800003); + ctx.bezierCurveTo(145.201004,78.400002,129.800995,74.199997,129.800995,74.199997); + ctx.bezierCurveTo(129.800995,74.199997,129.800995,74.199997,128.201004,74.400002); + ctx.bezierCurveTo(126.600998,74.599998,115.401001,73.800003,109.600998,71.599998); + ctx.bezierCurveTo(103.801003,69.400002,97.000999,69.400002,97.000999,69.400002); + ctx.bezierCurveTo(97.000999,69.400002,93.000999,71.199997,85.400002,71.000000); + ctx.bezierCurveTo(77.800003,70.800003,69.800003,73.599998,69.800003,73.599998); + ctx.bezierCurveTo(65.400002,73.199997,74.000000,68.800003,74.199997,69.000000); + ctx.bezierCurveTo(74.400002,69.199997,80.000000,63.599998,72.000000,64.199997); + ctx.bezierCurveTo(50.202999,65.834999,39.400002,55.599998,39.400002,55.599998); + ctx.bezierCurveTo(37.400002,54.200001,34.799999,51.400002,34.799999,51.400002); + ctx.bezierCurveTo(24.799999,49.400002,36.200001,63.799999,36.200001,63.799999); + ctx.bezierCurveTo(37.400002,65.199997,36.000000,66.199997,36.000000,66.199997); + ctx.bezierCurveTo(35.200001,64.599998,27.400000,59.200001,27.400000,59.200001); + ctx.bezierCurveTo(24.589001,58.227001,23.226000,56.893002,20.895000,54.407001); + ctx.lineTo(20.895000,54.407001); +ctx.fill(); + + + + +ctx.fillStyle='#4c0000'; +ctx.beginPath(); +ctx.moveTo(-3.000000,42.799999); + ctx.bezierCurveTo(-3.000000,42.799999,8.600000,48.400002,11.200000,51.200001); + ctx.bezierCurveTo(13.800000,54.000000,27.799999,65.400002,27.799999,65.400002); + ctx.bezierCurveTo(27.799999,65.400002,22.400000,63.400002,19.799999,61.599998); + ctx.bezierCurveTo(17.200001,59.799999,6.400000,51.599998,6.400000,51.599998); + ctx.bezierCurveTo(6.400000,51.599998,2.600000,45.599998,-3.000000,42.799999); + ctx.lineTo(-3.000000,42.799999); +ctx.fill(); + + + + +ctx.fillStyle='#99cc32'; +ctx.beginPath(); +ctx.moveTo(-61.008999,11.603000); + ctx.bezierCurveTo(-60.672001,11.455000,-61.195999,8.743000,-61.400002,8.200000); + ctx.bezierCurveTo(-62.422001,5.474000,-71.400002,4.000000,-71.400002,4.000000); + ctx.bezierCurveTo(-71.626999,5.365000,-71.681999,6.961000,-71.575996,8.599000); + ctx.bezierCurveTo(-71.575996,8.599000,-66.708000,14.118000,-61.008999,11.603000); + ctx.lineTo(-61.008999,11.603000); +ctx.fill(); + + + + +ctx.fillStyle='#659900'; +ctx.beginPath(); +ctx.moveTo(-61.008999,11.403000); + ctx.bezierCurveTo(-61.458000,11.561000,-61.023998,8.669000,-61.200001,8.200000); + ctx.bezierCurveTo(-62.222000,5.474000,-71.400002,3.900000,-71.400002,3.900000); + ctx.bezierCurveTo(-71.626999,5.265000,-71.681999,6.861000,-71.575996,8.499000); + ctx.bezierCurveTo(-71.575996,8.499000,-67.307999,13.618000,-61.008999,11.403000); + ctx.lineTo(-61.008999,11.403000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-65.400002,11.546000); + ctx.bezierCurveTo(-66.025002,11.546000,-66.530998,10.406000,-66.530998,9.000000); + ctx.bezierCurveTo(-66.530998,7.595000,-66.025002,6.455000,-65.400002,6.455000); + ctx.bezierCurveTo(-64.775002,6.455000,-64.267998,7.595000,-64.267998,9.000000); + ctx.bezierCurveTo(-64.267998,10.406000,-64.775002,11.546000,-65.400002,11.546000); + ctx.lineTo(-65.400002,11.546000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-111.000000,109.600998); + ctx.bezierCurveTo(-111.000000,109.600998,-116.599998,119.600998,-91.800003,113.600998); + ctx.bezierCurveTo(-91.800003,113.600998,-77.800003,112.401001,-75.400002,110.000999); + ctx.bezierCurveTo(-74.199997,110.801003,-65.834000,113.734001,-63.000000,114.401001); + ctx.bezierCurveTo(-56.200001,116.000999,-47.799999,106.000000,-47.799999,106.000000); + ctx.bezierCurveTo(-47.799999,106.000000,-43.200001,95.500000,-40.400002,95.500000); + ctx.bezierCurveTo(-37.599998,95.500000,-40.799999,97.099998,-40.799999,97.099998); + ctx.bezierCurveTo(-40.799999,97.099998,-47.400002,107.200996,-47.000000,108.801003); + ctx.bezierCurveTo(-47.000000,108.801003,-52.200001,128.800995,-68.199997,129.600998); + ctx.bezierCurveTo(-68.199997,129.600998,-84.349998,130.550995,-83.000000,136.401001); + ctx.bezierCurveTo(-83.000000,136.401001,-74.199997,134.001007,-71.800003,136.401001); + ctx.bezierCurveTo(-71.800003,136.401001,-61.000000,136.001007,-69.000000,142.401001); + ctx.lineTo(-75.800003,154.001007); + ctx.bezierCurveTo(-75.800003,154.001007,-75.660004,157.919006,-85.800003,154.401001); + ctx.bezierCurveTo(-95.599998,151.001007,-105.900002,138.100998,-105.900002,138.100998); + ctx.bezierCurveTo(-105.900002,138.100998,-121.849998,123.551003,-111.000000,109.600998); + ctx.lineTo(-111.000000,109.600998); +ctx.fill(); + + + + +ctx.fillStyle='#e59999'; +ctx.beginPath(); +ctx.moveTo(-112.199997,113.600998); + ctx.bezierCurveTo(-112.199997,113.600998,-114.199997,123.200996,-77.400002,112.801003); + ctx.bezierCurveTo(-77.400002,112.801003,-73.000000,112.801003,-70.599998,113.600998); + ctx.bezierCurveTo(-68.199997,114.401001,-56.200001,117.200996,-54.200001,116.000999); + ctx.bezierCurveTo(-54.200001,116.000999,-61.400002,129.600998,-73.000000,128.001007); + ctx.bezierCurveTo(-73.000000,128.001007,-86.199997,129.600998,-85.800003,134.401001); + ctx.bezierCurveTo(-85.800003,134.401001,-81.800003,141.600998,-77.000000,144.001007); + ctx.bezierCurveTo(-77.000000,144.001007,-74.199997,146.401001,-74.599998,149.600998); + ctx.bezierCurveTo(-75.000000,152.800995,-77.800003,154.401001,-79.800003,155.201004); + ctx.bezierCurveTo(-81.800003,156.001007,-85.000000,152.800995,-86.599998,152.800995); + ctx.bezierCurveTo(-88.199997,152.800995,-96.599998,146.401001,-101.000000,141.600998); + ctx.bezierCurveTo(-105.400002,136.800995,-113.800003,124.801003,-113.400002,122.000999); + ctx.bezierCurveTo(-113.000000,119.200996,-112.199997,113.600998,-112.199997,113.600998); + ctx.lineTo(-112.199997,113.600998); +ctx.fill(); + + + + +ctx.fillStyle='#b26565'; +ctx.beginPath(); +ctx.moveTo(-109.000000,131.050995); + ctx.bezierCurveTo(-106.400002,135.001007,-103.199997,139.201004,-101.000000,141.600998); + ctx.bezierCurveTo(-96.599998,146.401001,-88.199997,152.800995,-86.599998,152.800995); + ctx.bezierCurveTo(-85.000000,152.800995,-81.800003,156.001007,-79.800003,155.201004); + ctx.bezierCurveTo(-77.800003,154.401001,-75.000000,152.800995,-74.599998,149.600998); + ctx.bezierCurveTo(-74.199997,146.401001,-77.000000,144.001007,-77.000000,144.001007); + ctx.bezierCurveTo(-80.066002,142.468002,-82.806000,138.975998,-84.385002,136.653000); + ctx.bezierCurveTo(-84.385002,136.653000,-84.199997,139.201004,-89.400002,138.401001); + ctx.bezierCurveTo(-94.599998,137.600998,-99.800003,134.800995,-101.400002,131.600998); + ctx.bezierCurveTo(-103.000000,128.401001,-105.400002,126.000999,-103.800003,129.600998); + ctx.bezierCurveTo(-102.199997,133.201004,-99.800003,136.800995,-98.199997,137.201004); + ctx.bezierCurveTo(-96.599998,137.600998,-97.000000,138.800995,-99.400002,138.401001); + ctx.bezierCurveTo(-101.800003,138.001007,-104.599998,137.600998,-109.000000,132.401001); + ctx.lineTo(-109.000000,131.050995); +ctx.fill(); + + + + +ctx.fillStyle='#992600'; +ctx.beginPath(); +ctx.moveTo(-111.599998,110.000999); + ctx.bezierCurveTo(-111.599998,110.000999,-109.800003,96.400002,-108.599998,92.400002); + ctx.bezierCurveTo(-108.599998,92.400002,-109.400002,85.599998,-107.000000,81.400002); + ctx.bezierCurveTo(-104.599998,77.199997,-102.599998,71.000000,-99.599998,65.599998); + ctx.bezierCurveTo(-96.599998,60.200001,-96.400002,56.200001,-92.400002,54.599998); + ctx.bezierCurveTo(-88.400002,53.000000,-82.400002,44.400002,-79.599998,43.400002); + ctx.bezierCurveTo(-76.800003,42.400002,-77.000000,43.200001,-77.000000,43.200001); + ctx.bezierCurveTo(-77.000000,43.200001,-70.199997,28.400000,-56.599998,32.400002); + ctx.bezierCurveTo(-56.599998,32.400002,-72.800003,29.600000,-57.000000,20.200001); + ctx.bezierCurveTo(-57.000000,20.200001,-61.799999,21.299999,-58.500000,14.300000); + ctx.bezierCurveTo(-56.299000,9.632000,-56.799999,16.400000,-67.800003,28.200001); + ctx.bezierCurveTo(-67.800003,28.200001,-72.800003,36.799999,-78.000000,39.799999); + ctx.bezierCurveTo(-83.199997,42.799999,-95.199997,49.799999,-96.400002,53.599998); + ctx.bezierCurveTo(-97.599998,57.400002,-100.800003,63.200001,-102.800003,64.800003); + ctx.bezierCurveTo(-104.800003,66.400002,-107.599998,70.599998,-108.000000,74.000000); + ctx.bezierCurveTo(-108.000000,74.000000,-109.199997,78.000000,-110.599998,79.199997); + ctx.bezierCurveTo(-112.000000,80.400002,-112.199997,83.599998,-112.199997,85.599998); + ctx.bezierCurveTo(-112.199997,87.599998,-114.199997,90.400002,-114.000000,92.800003); + ctx.bezierCurveTo(-114.000000,92.800003,-113.199997,111.801003,-113.599998,113.801003); + ctx.lineTo(-111.599998,110.000999); + ctx.lineTo(-111.599998,110.000999); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(-120.199997,114.600998); + ctx.bezierCurveTo(-120.199997,114.600998,-122.199997,113.200996,-126.599998,119.200996); + ctx.bezierCurveTo(-126.599998,119.200996,-119.300003,152.201004,-119.300003,153.600998); + ctx.bezierCurveTo(-119.300003,153.600998,-118.199997,151.501007,-119.500000,144.300995); + ctx.bezierCurveTo(-120.800003,137.100998,-121.699997,124.401001,-121.699997,124.401001); + ctx.lineTo(-120.199997,114.600998); + ctx.lineTo(-120.199997,114.600998); +ctx.fill(); + + + + +ctx.fillStyle='#992600'; +ctx.beginPath(); +ctx.moveTo(-98.599998,54.000000); + ctx.bezierCurveTo(-98.599998,54.000000,-116.199997,57.200001,-115.800003,86.400002); + ctx.lineTo(-116.599998,111.200996); + ctx.bezierCurveTo(-116.599998,111.200996,-117.800003,85.599998,-119.000000,84.000000); + ctx.bezierCurveTo(-120.199997,82.400002,-116.199997,71.199997,-119.400002,77.199997); + ctx.bezierCurveTo(-119.400002,77.199997,-133.399994,91.199997,-125.400002,112.401001); + ctx.bezierCurveTo(-125.400002,112.401001,-123.900002,115.700996,-126.900002,111.100998); + ctx.bezierCurveTo(-126.900002,111.100998,-131.500000,98.500000,-130.399994,92.099998); + ctx.bezierCurveTo(-130.399994,92.099998,-130.199997,89.900002,-128.300003,87.099998); + ctx.bezierCurveTo(-128.300003,87.099998,-119.699997,75.400002,-117.000000,73.099998); + ctx.bezierCurveTo(-117.000000,73.099998,-115.199997,58.700001,-99.800003,53.500000); + ctx.bezierCurveTo(-99.800003,53.500000,-94.099998,51.200001,-98.599998,54.000000); + ctx.lineTo(-98.599998,54.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(40.799999,-12.200000); + ctx.bezierCurveTo(41.459999,-12.554000,41.451000,-13.524000,42.030998,-13.697000); + ctx.bezierCurveTo(43.180000,-14.041000,43.344002,-15.108000,43.862000,-15.892000); + ctx.bezierCurveTo(44.735001,-17.211000,44.928001,-18.743999,45.509998,-20.235001); + ctx.bezierCurveTo(45.782001,-20.934999,45.808998,-21.889999,45.495998,-22.549999); + ctx.bezierCurveTo(44.321999,-25.031000,43.619999,-27.480000,42.178001,-29.906000); + ctx.bezierCurveTo(41.910000,-30.356001,41.647999,-31.150000,41.446999,-31.747999); + ctx.bezierCurveTo(40.984001,-33.132000,39.727001,-34.123001,38.867001,-35.443001); + ctx.bezierCurveTo(38.578999,-35.883999,39.104000,-36.808998,38.388000,-36.893002); + ctx.bezierCurveTo(37.491001,-36.998001,36.042000,-37.577999,35.808998,-36.551998); + ctx.bezierCurveTo(35.221001,-33.965000,36.231998,-31.441999,37.200001,-29.000000); + ctx.bezierCurveTo(36.417999,-28.308001,36.751999,-27.386999,36.903999,-26.620001); + ctx.bezierCurveTo(37.613998,-23.014000,36.416000,-19.662001,35.654999,-16.188000); + ctx.bezierCurveTo(35.632000,-16.084000,35.973999,-15.886000,35.945999,-15.824000); + ctx.bezierCurveTo(34.723999,-13.138000,33.271999,-10.693000,31.452999,-8.312000); + ctx.bezierCurveTo(30.695000,-7.320000,29.823000,-6.404000,29.326000,-5.341000); + ctx.bezierCurveTo(28.958000,-4.554000,28.549999,-3.588000,28.799999,-2.600000); + ctx.bezierCurveTo(25.365000,0.180000,23.115000,4.025000,20.504000,7.871000); + ctx.bezierCurveTo(20.042000,8.551000,20.333000,9.760000,20.884001,10.029000); + ctx.bezierCurveTo(21.697001,10.427000,22.653000,9.403000,23.122999,8.557000); + ctx.bezierCurveTo(23.511999,7.859000,23.865000,7.209000,24.356001,6.566000); + ctx.bezierCurveTo(24.489000,6.391000,24.309999,5.972000,24.445000,5.851000); + ctx.bezierCurveTo(27.077999,3.504000,28.747000,0.568000,31.200001,-1.800000); + ctx.bezierCurveTo(33.150002,-2.129000,34.687000,-3.127000,36.435001,-4.140000); + ctx.bezierCurveTo(36.743000,-4.319000,37.266998,-4.070000,37.556999,-4.265000); + ctx.bezierCurveTo(39.310001,-5.442000,39.307999,-7.478000,39.414001,-9.388000); + ctx.bezierCurveTo(39.464001,-10.272000,39.660000,-11.589000,40.799999,-12.200000); + ctx.lineTo(40.799999,-12.200000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(31.959000,-16.666000); + ctx.bezierCurveTo(32.083000,-16.743000,31.927999,-17.166000,32.036999,-17.382000); + ctx.bezierCurveTo(32.199001,-17.705999,32.602001,-17.893999,32.764000,-18.218000); + ctx.bezierCurveTo(32.873001,-18.434000,32.709999,-18.813999,32.846001,-18.955999); + ctx.bezierCurveTo(35.179001,-21.403000,35.436001,-24.427000,34.400002,-27.400000); + ctx.bezierCurveTo(35.424000,-28.020000,35.485001,-29.282000,35.060001,-30.129000); + ctx.bezierCurveTo(34.207001,-31.829000,34.014000,-33.755001,33.039001,-35.298000); + ctx.bezierCurveTo(32.237000,-36.567001,30.659000,-37.811001,29.288000,-36.507999); + ctx.bezierCurveTo(28.867001,-36.108002,28.546000,-35.320999,28.823999,-34.609001); + ctx.bezierCurveTo(28.888000,-34.445999,29.173000,-34.299999,29.146000,-34.217999); + ctx.bezierCurveTo(29.039000,-33.894001,28.493000,-33.669998,28.487000,-33.397999); + ctx.bezierCurveTo(28.457001,-31.902000,27.503000,-30.391001,28.132999,-29.062000); + ctx.bezierCurveTo(28.905001,-27.433001,29.724001,-25.576000,30.400000,-23.799999); + ctx.bezierCurveTo(29.166000,-21.684000,30.198999,-19.235001,28.445999,-17.358000); + ctx.bezierCurveTo(28.309999,-17.212000,28.319000,-16.826000,28.441000,-16.624001); + ctx.bezierCurveTo(28.733000,-16.138000,29.139000,-15.732000,29.625000,-15.440000); + ctx.bezierCurveTo(29.827000,-15.319000,30.174999,-15.317000,30.375000,-15.441000); + ctx.bezierCurveTo(30.952999,-15.803000,31.351000,-16.290001,31.959000,-16.666000); + ctx.lineTo(31.959000,-16.666000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(94.771004,-26.976999); + ctx.bezierCurveTo(96.160004,-25.184999,96.449997,-22.389999,94.401001,-21.000000); + ctx.bezierCurveTo(94.950996,-17.691000,98.302002,-19.670000,100.401001,-20.200001); + ctx.bezierCurveTo(100.292000,-20.587999,100.518997,-20.931999,100.802002,-20.937000); + ctx.bezierCurveTo(101.859001,-20.952000,102.539001,-21.983999,103.600998,-21.799999); + ctx.bezierCurveTo(104.035004,-23.357000,105.672997,-24.059000,106.317001,-25.438999); + ctx.bezierCurveTo(108.042999,-29.134001,107.452003,-33.407001,104.867996,-36.653000); + ctx.bezierCurveTo(104.666000,-36.907001,104.883003,-37.424000,104.759003,-37.785999); + ctx.bezierCurveTo(104.002998,-39.997002,101.934998,-40.312000,100.000999,-41.000000); + ctx.bezierCurveTo(98.823997,-44.875000,98.163002,-48.905998,96.401001,-52.599998); + ctx.bezierCurveTo(94.787003,-52.849998,94.088997,-54.589001,92.751999,-55.308998); + ctx.bezierCurveTo(91.418999,-56.028000,90.850998,-54.449001,90.891998,-53.403000); + ctx.bezierCurveTo(90.899002,-53.198002,91.350998,-52.973999,91.181000,-52.609001); + ctx.bezierCurveTo(91.105003,-52.445000,90.845001,-52.334000,90.845001,-52.200001); + ctx.bezierCurveTo(90.846001,-52.064999,91.067001,-51.933998,91.200996,-51.799999); + ctx.bezierCurveTo(90.282997,-50.980000,88.860001,-50.502998,88.565002,-49.358002); + ctx.bezierCurveTo(87.611000,-45.647999,90.183998,-42.522999,91.851997,-39.321999); + ctx.bezierCurveTo(92.443001,-38.187000,91.707001,-36.916000,90.946999,-35.708000); + ctx.bezierCurveTo(90.509003,-35.013000,90.616997,-33.886002,90.892998,-33.029999); + ctx.bezierCurveTo(91.644997,-30.698999,93.236000,-28.959999,94.771004,-26.976999); + ctx.lineTo(94.771004,-26.976999); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(57.611000,-8.591000); + ctx.bezierCurveTo(56.124001,-6.740000,52.712002,-4.171000,55.629002,-2.243000); + ctx.bezierCurveTo(55.823002,-2.114000,56.193001,-2.110000,56.366001,-2.244000); + ctx.bezierCurveTo(58.387001,-3.809000,60.389999,-4.712000,62.826000,-5.294000); + ctx.bezierCurveTo(62.950001,-5.323000,63.223999,-4.856000,63.592999,-5.017000); + ctx.bezierCurveTo(65.206001,-5.720000,67.216003,-5.662000,68.400002,-7.000000); + ctx.bezierCurveTo(72.167000,-6.776000,75.732002,-7.892000,79.123001,-9.200000); + ctx.bezierCurveTo(80.283997,-9.648000,81.554001,-10.207000,82.754997,-10.709000); + ctx.bezierCurveTo(84.130997,-11.285000,85.334999,-12.213000,86.446999,-13.354000); + ctx.bezierCurveTo(86.580002,-13.490000,86.933998,-13.400000,87.200996,-13.400000); + ctx.bezierCurveTo(87.161003,-14.263000,88.123001,-14.390000,88.370003,-15.012000); + ctx.bezierCurveTo(88.461998,-15.244000,88.311996,-15.640000,88.445000,-15.742000); + ctx.bezierCurveTo(90.583000,-17.372000,91.502998,-19.389999,90.334000,-21.767000); + ctx.bezierCurveTo(90.049004,-22.344999,89.800003,-22.962999,89.234001,-23.438999); + ctx.bezierCurveTo(88.149002,-24.350000,87.046997,-23.496000,86.000000,-23.799999); + ctx.bezierCurveTo(85.841003,-23.172001,85.112000,-23.344000,84.725998,-23.146000); + ctx.bezierCurveTo(83.866997,-22.707001,82.533997,-23.292000,81.675003,-22.854000); + ctx.bezierCurveTo(80.313004,-22.159000,79.071999,-21.990000,77.650002,-21.613001); + ctx.bezierCurveTo(77.337997,-21.531000,76.559998,-21.627001,76.400002,-21.000000); + ctx.bezierCurveTo(76.265999,-21.134001,76.117996,-21.368000,76.012001,-21.346001); + ctx.bezierCurveTo(74.103996,-20.950001,72.844002,-20.736000,71.542999,-19.044001); + ctx.bezierCurveTo(71.440002,-18.910999,70.998001,-19.090000,70.838997,-18.955000); + ctx.bezierCurveTo(69.882004,-18.146999,69.476997,-16.913000,68.375999,-16.240999); + ctx.bezierCurveTo(68.175003,-16.118000,67.822998,-16.285999,67.628998,-16.157000); + ctx.bezierCurveTo(66.983002,-15.726000,66.615997,-15.085000,65.973999,-14.638000); + ctx.bezierCurveTo(65.644997,-14.409000,65.245003,-14.734000,65.277000,-14.990000); + ctx.bezierCurveTo(65.522003,-16.937000,66.175003,-18.724001,65.599998,-20.600000); + ctx.bezierCurveTo(67.677002,-23.120001,70.194000,-25.069000,72.000000,-27.799999); + ctx.bezierCurveTo(72.014999,-29.966000,72.707001,-32.112000,72.594002,-34.188999); + ctx.bezierCurveTo(72.584000,-34.382000,72.295998,-35.115002,72.169998,-35.462002); + ctx.bezierCurveTo(71.858002,-36.316002,72.764000,-37.382000,71.919998,-38.105999); + ctx.bezierCurveTo(70.515999,-39.308998,69.223999,-38.432999,68.400002,-37.000000); + ctx.bezierCurveTo(66.561996,-36.610001,64.496002,-35.917000,62.917999,-37.151001); + ctx.bezierCurveTo(61.910999,-37.938000,61.333000,-38.844002,60.534000,-39.900002); + ctx.bezierCurveTo(59.549000,-41.202000,59.883999,-42.638000,59.953999,-44.202000); + ctx.bezierCurveTo(59.959999,-44.330002,59.645000,-44.466000,59.645000,-44.599998); + ctx.bezierCurveTo(59.646000,-44.735001,59.866001,-44.866001,60.000000,-45.000000); + ctx.bezierCurveTo(59.293999,-45.625999,59.019001,-46.683998,58.000000,-47.000000); + ctx.bezierCurveTo(58.305000,-48.091999,57.629002,-48.976002,56.757999,-49.278000); + ctx.bezierCurveTo(54.763000,-49.969002,53.085999,-48.056999,51.194000,-47.984001); + ctx.bezierCurveTo(50.680000,-47.965000,50.213001,-49.002998,49.563999,-49.327999); + ctx.bezierCurveTo(49.132000,-49.543999,48.428001,-49.577000,48.066002,-49.311001); + ctx.bezierCurveTo(47.377998,-48.806999,46.789001,-48.693001,46.030998,-48.487999); + ctx.bezierCurveTo(44.414001,-48.051998,43.136002,-46.958000,41.655998,-46.103001); + ctx.bezierCurveTo(40.171001,-45.245998,39.216000,-43.808998,38.136002,-42.488998); + ctx.bezierCurveTo(37.195000,-41.337002,37.058998,-38.923000,38.479000,-38.423000); + ctx.bezierCurveTo(40.321999,-37.772999,41.625999,-40.476002,43.591999,-40.150002); + ctx.bezierCurveTo(43.903999,-40.098999,44.110001,-39.787998,44.000000,-39.400002); + ctx.bezierCurveTo(44.389000,-39.291000,44.606998,-39.520000,44.799999,-39.799999); + ctx.bezierCurveTo(45.658001,-38.780998,46.821999,-38.444000,47.759998,-37.570999); + ctx.bezierCurveTo(48.730000,-36.667000,50.476002,-37.084999,51.491001,-36.088001); + ctx.bezierCurveTo(53.020000,-34.585999,52.460999,-31.905001,54.400002,-30.600000); + ctx.bezierCurveTo(53.813999,-29.287001,53.207001,-28.010000,52.872002,-26.583000); + ctx.bezierCurveTo(52.590000,-25.377001,53.584000,-24.180000,54.794998,-24.271000); + ctx.bezierCurveTo(56.053001,-24.365000,56.314999,-25.124001,56.799999,-26.200001); + ctx.bezierCurveTo(57.067001,-25.933001,57.535999,-25.636000,57.494999,-25.420000); + ctx.bezierCurveTo(57.037998,-23.033001,56.011002,-21.040001,55.553001,-18.608999); + ctx.bezierCurveTo(55.493999,-18.292000,55.188999,-18.090000,54.799999,-18.200001); + ctx.bezierCurveTo(54.332001,-14.051000,50.279999,-11.657000,47.735001,-8.492000); + ctx.bezierCurveTo(47.332001,-7.990000,47.327999,-6.741000,47.737000,-6.338000); + ctx.bezierCurveTo(49.139999,-4.951000,51.099998,-6.497000,52.799999,-7.000000); + ctx.bezierCurveTo(53.013000,-8.206000,53.872002,-9.148000,55.203999,-9.092000); + ctx.bezierCurveTo(55.459999,-9.082000,55.695000,-9.624000,56.019001,-9.754000); + ctx.bezierCurveTo(56.367001,-9.892000,56.868999,-9.668000,57.154999,-9.866000); + ctx.bezierCurveTo(58.883999,-11.061000,60.292000,-12.167000,62.029999,-13.356000); + ctx.bezierCurveTo(62.222000,-13.487000,62.566002,-13.328000,62.782001,-13.436000); + ctx.bezierCurveTo(63.106998,-13.598000,63.293999,-13.985000,63.617001,-14.170000); + ctx.bezierCurveTo(63.965000,-14.370000,64.207001,-14.080000,64.400002,-13.800000); + ctx.bezierCurveTo(63.754002,-13.451000,63.750000,-12.494000,63.167999,-12.292000); + ctx.bezierCurveTo(62.393002,-12.024000,61.832001,-11.511000,61.158001,-11.064000); + ctx.bezierCurveTo(60.866001,-10.871000,60.207001,-11.119000,60.103001,-10.940000); + ctx.bezierCurveTo(59.505001,-9.912000,58.320999,-9.474000,57.611000,-8.591000); + ctx.lineTo(57.611000,-8.591000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(2.200000,-58.000000); + ctx.bezierCurveTo(2.200000,-58.000000,-7.038000,-60.872002,-18.200001,-35.200001); + ctx.bezierCurveTo(-18.200001,-35.200001,-20.600000,-30.000000,-23.000000,-28.000000); + ctx.bezierCurveTo(-25.400000,-26.000000,-36.599998,-22.400000,-38.599998,-18.400000); + ctx.lineTo(-49.000000,-2.400000); + ctx.bezierCurveTo(-49.000000,-2.400000,-34.200001,-18.400000,-31.000000,-20.799999); + ctx.bezierCurveTo(-31.000000,-20.799999,-23.000000,-29.200001,-26.200001,-22.400000); + ctx.bezierCurveTo(-26.200001,-22.400000,-40.200001,-11.600000,-39.000000,-2.400000); + ctx.bezierCurveTo(-39.000000,-2.400000,-44.599998,12.000000,-45.400002,14.000000); + ctx.bezierCurveTo(-45.400002,14.000000,-29.400000,-18.000000,-27.000000,-19.200001); + ctx.bezierCurveTo(-24.600000,-20.400000,-23.400000,-20.400000,-24.600000,-16.799999); + ctx.bezierCurveTo(-25.799999,-13.200000,-26.200001,3.200000,-29.000000,5.200000); + ctx.bezierCurveTo(-29.000000,5.200000,-21.000000,-15.200000,-21.799999,-18.400000); + ctx.bezierCurveTo(-21.799999,-18.400000,-18.600000,-22.000000,-16.200001,-16.799999); + ctx.lineTo(-17.400000,-0.800000); + ctx.lineTo(-13.000000,11.200000); + ctx.bezierCurveTo(-13.000000,11.200000,-15.400000,0.000000,-13.800000,-15.600000); + ctx.bezierCurveTo(-13.800000,-15.600000,-15.800000,-26.000000,-11.800000,-20.400000); + ctx.bezierCurveTo(-7.800000,-14.800000,1.800000,-8.800000,1.800000,-4.000000); + ctx.bezierCurveTo(1.800000,-4.000000,-3.400000,-21.600000,-12.600000,-26.400000); + ctx.lineTo(-16.600000,-20.400000); + ctx.lineTo(-17.799999,-22.400000); + ctx.bezierCurveTo(-17.799999,-22.400000,-21.400000,-23.200001,-17.000000,-30.000000); + ctx.bezierCurveTo(-12.600000,-36.799999,-13.000000,-37.599998,-13.000000,-37.599998); + ctx.bezierCurveTo(-13.000000,-37.599998,-6.600000,-30.400000,-5.000000,-30.400000); + ctx.bezierCurveTo(-5.000000,-30.400000,8.200000,-38.000000,9.400000,-13.600000); + ctx.bezierCurveTo(9.400000,-13.600000,16.200001,-28.000000,7.000000,-34.799999); + ctx.bezierCurveTo(7.000000,-34.799999,-7.800000,-36.799999,-6.600000,-42.000000); + ctx.lineTo(0.600000,-54.400002); + ctx.bezierCurveTo(4.200000,-59.599998,2.600000,-56.799999,2.600000,-56.799999); + ctx.lineTo(2.200000,-58.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-17.799999,-41.599998); + ctx.bezierCurveTo(-17.799999,-41.599998,-30.600000,-41.599998,-33.799999,-36.400002); + ctx.lineTo(-41.000000,-26.799999); + ctx.bezierCurveTo(-41.000000,-26.799999,-23.799999,-36.799999,-19.799999,-38.000000); + ctx.bezierCurveTo(-15.800000,-39.200001,-17.799999,-41.599998,-17.799999,-41.599998); + ctx.lineTo(-17.799999,-41.599998); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-57.799999,-35.200001); + ctx.bezierCurveTo(-57.799999,-35.200001,-59.799999,-34.000000,-60.200001,-31.200001); + ctx.bezierCurveTo(-60.599998,-28.400000,-63.000000,-28.000000,-62.200001,-25.200001); + ctx.bezierCurveTo(-61.400002,-22.400000,-59.400002,-20.000000,-59.400002,-24.000000); + ctx.bezierCurveTo(-59.400002,-28.000000,-57.799999,-30.000000,-57.000000,-31.200001); + ctx.bezierCurveTo(-56.200001,-32.400002,-54.599998,-36.799999,-57.799999,-35.200001); + ctx.lineTo(-57.799999,-35.200001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-66.599998,26.000000); + ctx.bezierCurveTo(-66.599998,26.000000,-75.000000,22.000000,-78.199997,18.400000); + ctx.bezierCurveTo(-81.400002,14.800000,-80.947998,19.966000,-85.800003,19.600000); + ctx.bezierCurveTo(-91.647003,19.159000,-90.599998,3.200000,-90.599998,3.200000); + ctx.lineTo(-94.599998,10.800000); + ctx.bezierCurveTo(-94.599998,10.800000,-95.800003,25.200001,-87.800003,22.799999); + ctx.bezierCurveTo(-83.892998,21.628000,-82.599998,23.200001,-84.199997,24.000000); + ctx.bezierCurveTo(-85.800003,24.799999,-78.599998,25.200001,-81.400002,26.799999); + ctx.bezierCurveTo(-84.199997,28.400000,-69.800003,23.200001,-72.199997,33.599998); + ctx.lineTo(-66.599998,26.000000); + ctx.lineTo(-66.599998,26.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-79.199997,40.400002); + ctx.bezierCurveTo(-79.199997,40.400002,-94.599998,44.799999,-98.199997,35.200001); + ctx.bezierCurveTo(-98.199997,35.200001,-103.000000,37.599998,-100.800003,40.599998); + ctx.bezierCurveTo(-98.599998,43.599998,-97.400002,44.000000,-97.400002,44.000000); + ctx.bezierCurveTo(-97.400002,44.000000,-92.000000,45.200001,-92.599998,46.000000); + ctx.bezierCurveTo(-93.199997,46.799999,-95.599998,50.200001,-95.599998,50.200001); + ctx.bezierCurveTo(-95.599998,50.200001,-85.400002,44.200001,-79.199997,40.400002); + ctx.lineTo(-79.199997,40.400002); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(149.201004,118.600998); + ctx.bezierCurveTo(148.774002,120.735001,147.102997,121.536003,145.201004,122.200996); + ctx.bezierCurveTo(143.283997,121.242996,140.686005,118.137001,138.800995,120.200996); + ctx.bezierCurveTo(138.326996,119.721001,137.548004,119.661003,137.203995,118.999001); + ctx.bezierCurveTo(136.738998,118.100998,137.011002,117.055000,136.669006,116.257004); + ctx.bezierCurveTo(136.123993,114.985001,135.414993,113.619003,135.600998,112.200996); + ctx.bezierCurveTo(137.406998,111.488998,138.001999,109.583000,137.528000,107.820000); + ctx.bezierCurveTo(137.459000,107.563004,137.029999,107.365997,137.229996,107.016998); + ctx.bezierCurveTo(137.416000,106.694000,137.733994,106.467003,138.001007,106.199997); + ctx.bezierCurveTo(137.865997,106.334999,137.720993,106.568001,137.610001,106.547997); + ctx.bezierCurveTo(137.000000,106.442001,137.123993,105.805000,137.253998,105.417999); + ctx.bezierCurveTo(137.839005,103.671997,139.852997,103.407997,141.201004,104.599998); + ctx.bezierCurveTo(141.457001,104.035004,141.966003,104.228996,142.401001,104.199997); + ctx.bezierCurveTo(142.350998,103.621002,142.759003,103.094002,142.957001,102.674004); + ctx.bezierCurveTo(143.475006,101.575996,145.104004,102.681999,145.901001,102.070000); + ctx.bezierCurveTo(146.977005,101.245003,148.039993,100.545998,149.117996,101.149002); + ctx.bezierCurveTo(150.927002,102.162003,152.636002,103.374001,153.835007,105.114998); + ctx.bezierCurveTo(154.410004,105.948997,154.649994,107.230003,154.591995,108.188004); + ctx.bezierCurveTo(154.554001,108.834999,153.173004,108.483002,152.830002,109.412003); + ctx.bezierCurveTo(152.184998,111.160004,154.016006,111.679001,154.772003,113.016998); + ctx.bezierCurveTo(154.970001,113.365997,154.705994,113.669998,154.391006,113.767998); + ctx.bezierCurveTo(153.979996,113.896004,153.195999,113.707001,153.334000,114.160004); + ctx.bezierCurveTo(154.306000,117.352997,151.550003,118.030998,149.201004,118.600998); + ctx.lineTo(149.201004,118.600998); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.beginPath(); +ctx.moveTo(139.600006,138.201004); + ctx.bezierCurveTo(139.593002,136.462997,137.992004,134.707001,139.201004,133.001007); + ctx.bezierCurveTo(139.335999,133.134995,139.466995,133.356003,139.600998,133.356003); + ctx.bezierCurveTo(139.735992,133.356003,139.867004,133.134995,140.001007,133.001007); + ctx.bezierCurveTo(141.496002,135.216995,145.147995,136.145004,145.005997,138.990997); + ctx.bezierCurveTo(144.983994,139.438004,143.897003,140.356003,144.800995,141.001007); + ctx.bezierCurveTo(142.988007,142.348999,142.932999,144.718994,142.001007,146.600998); + ctx.bezierCurveTo(140.763000,146.315002,139.550995,145.951996,138.401001,145.401001); + ctx.bezierCurveTo(138.753006,143.914993,138.636002,142.231003,139.455994,140.910995); + ctx.bezierCurveTo(139.889999,140.212997,139.602997,139.134003,139.600006,138.201004); + ctx.lineTo(139.600006,138.201004); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-26.600000,129.201004); + ctx.bezierCurveTo(-26.600000,129.201004,-43.458000,139.337006,-29.400000,124.000999); + ctx.bezierCurveTo(-20.600000,114.401001,-10.600000,108.801003,-10.600000,108.801003); + ctx.bezierCurveTo(-10.600000,108.801003,-0.200000,104.400002,3.400000,103.199997); + ctx.bezierCurveTo(7.000000,102.000000,22.200001,96.800003,25.400000,96.400002); + ctx.bezierCurveTo(28.600000,96.000000,38.200001,92.000000,45.000000,96.000000); + ctx.bezierCurveTo(51.799999,100.000000,59.799999,104.400002,59.799999,104.400002); + ctx.bezierCurveTo(59.799999,104.400002,43.400002,96.000000,39.799999,98.400002); + ctx.bezierCurveTo(36.200001,100.800003,29.000000,100.400002,23.000000,103.599998); + ctx.bezierCurveTo(23.000000,103.599998,8.200000,108.000999,5.000000,110.000999); + ctx.bezierCurveTo(1.800000,112.000999,-8.600000,123.600998,-10.200000,122.801003); + ctx.bezierCurveTo(-11.800000,122.000999,-9.800000,121.600998,-8.600000,118.801003); + ctx.bezierCurveTo(-7.400000,116.000999,-9.400000,114.401001,-17.400000,120.801003); + ctx.bezierCurveTo(-25.400000,127.200996,-26.600000,129.201004,-26.600000,129.201004); + ctx.lineTo(-26.600000,129.201004); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-19.195000,123.234001); + ctx.bezierCurveTo(-19.195000,123.234001,-17.785000,110.194000,-9.307000,111.859001); + ctx.bezierCurveTo(-9.307000,111.859001,-1.081000,107.689003,1.641000,105.721001); + ctx.bezierCurveTo(1.641000,105.721001,9.780000,104.018997,11.090000,103.402000); + ctx.bezierCurveTo(29.569000,94.702003,44.287998,99.221001,44.834999,98.100998); + ctx.bezierCurveTo(45.381001,96.982002,65.005997,104.098999,68.614998,108.184998); + ctx.bezierCurveTo(69.005997,108.627998,58.383999,102.587997,48.686001,100.696999); + ctx.bezierCurveTo(40.412998,99.083000,18.811001,100.944000,7.905000,106.480003); + ctx.bezierCurveTo(4.932000,107.988998,-4.013000,113.773003,-6.544000,113.662003); + ctx.bezierCurveTo(-9.075000,113.550003,-19.195000,123.234001,-19.195000,123.234001); + ctx.lineTo(-19.195000,123.234001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-23.000000,148.800995); + ctx.bezierCurveTo(-23.000000,148.800995,-38.200001,146.401001,-21.400000,144.800995); + ctx.bezierCurveTo(-21.400000,144.800995,-3.400000,142.800995,0.600000,137.600998); + ctx.bezierCurveTo(0.600000,137.600998,14.200000,128.401001,17.000000,128.001007); + ctx.bezierCurveTo(19.799999,127.600998,49.799999,120.401001,50.200001,118.000999); + ctx.bezierCurveTo(50.599998,115.600998,56.200001,115.600998,57.799999,116.401001); + ctx.bezierCurveTo(59.400002,117.200996,58.599998,118.401001,55.799999,119.200996); + ctx.bezierCurveTo(53.000000,120.000999,21.799999,136.401001,15.400000,137.600998); + ctx.bezierCurveTo(9.000000,138.800995,-2.600000,146.401001,-7.400000,147.600998); + ctx.bezierCurveTo(-12.200000,148.800995,-23.000000,148.800995,-23.000000,148.800995); + ctx.lineTo(-23.000000,148.800995); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-3.480000,141.403000); + ctx.bezierCurveTo(-3.480000,141.403000,-12.062000,140.574005,-3.461000,139.755005); + ctx.bezierCurveTo(-3.461000,139.755005,5.355000,136.330994,7.403000,133.667999); + ctx.bezierCurveTo(7.403000,133.667999,14.367000,128.957001,15.800000,128.753006); + ctx.bezierCurveTo(17.233999,128.548004,31.194000,124.861000,31.399000,123.633003); + ctx.bezierCurveTo(31.604000,122.403999,65.669998,109.822998,70.089996,113.013000); + ctx.bezierCurveTo(73.000999,115.113998,63.099998,113.436996,53.466000,117.847000); + ctx.bezierCurveTo(52.111000,118.467003,18.257999,133.054001,14.981000,133.667999); + ctx.bezierCurveTo(11.704000,134.283005,5.765000,138.173996,3.307000,138.787994); + ctx.bezierCurveTo(0.850000,139.403000,-3.480000,141.403000,-3.480000,141.403000); + ctx.lineTo(-3.480000,141.403000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-11.400000,143.600998); + ctx.bezierCurveTo(-11.400000,143.600998,-6.200000,143.201004,-7.400000,144.800995); + ctx.bezierCurveTo(-8.600000,146.401001,-11.000000,145.600998,-11.000000,145.600998); + ctx.lineTo(-11.400000,143.600998); + ctx.lineTo(-11.400000,143.600998); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-18.600000,145.201004); + ctx.bezierCurveTo(-18.600000,145.201004,-13.400000,144.800995,-14.600000,146.401001); + ctx.bezierCurveTo(-15.800000,148.001007,-18.200001,147.201004,-18.200001,147.201004); + ctx.lineTo(-18.600000,145.201004); + ctx.lineTo(-18.600000,145.201004); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-29.000000,146.800995); + ctx.bezierCurveTo(-29.000000,146.800995,-23.799999,146.401001,-25.000000,148.001007); + ctx.bezierCurveTo(-26.200001,149.600998,-28.600000,148.800995,-28.600000,148.800995); + ctx.lineTo(-29.000000,146.800995); + ctx.lineTo(-29.000000,146.800995); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-36.599998,147.600998); + ctx.bezierCurveTo(-36.599998,147.600998,-31.400000,147.201004,-32.599998,148.800995); + ctx.bezierCurveTo(-33.799999,150.401001,-36.200001,149.600998,-36.200001,149.600998); + ctx.lineTo(-36.599998,147.600998); + ctx.lineTo(-36.599998,147.600998); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(1.800000,108.000999); + ctx.bezierCurveTo(1.800000,108.000999,6.200000,108.000999,5.000000,109.600998); + ctx.bezierCurveTo(3.800000,111.200996,0.600000,110.801003,0.600000,110.801003); + ctx.lineTo(1.800000,108.000999); + ctx.lineTo(1.800000,108.000999); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-8.200000,113.600998); + ctx.bezierCurveTo(-8.200000,113.600998,-1.694000,111.459999,-4.200000,114.801003); + ctx.bezierCurveTo(-5.400000,116.401001,-7.800000,115.600998,-7.800000,115.600998); + ctx.lineTo(-8.200000,113.600998); + ctx.lineTo(-8.200000,113.600998); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-19.400000,118.401001); + ctx.bezierCurveTo(-19.400000,118.401001,-14.200000,118.000999,-15.400000,119.600998); + ctx.bezierCurveTo(-16.600000,121.200996,-19.000000,120.401001,-19.000000,120.401001); + ctx.lineTo(-19.400000,118.401001); + ctx.lineTo(-19.400000,118.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-27.000000,124.401001); + ctx.bezierCurveTo(-27.000000,124.401001,-21.799999,124.000999,-23.000000,125.600998); + ctx.bezierCurveTo(-24.200001,127.200996,-26.600000,126.401001,-26.600000,126.401001); + ctx.lineTo(-27.000000,124.401001); + ctx.lineTo(-27.000000,124.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-33.799999,129.201004); + ctx.bezierCurveTo(-33.799999,129.201004,-28.600000,128.800995,-29.799999,130.401001); + ctx.bezierCurveTo(-31.000000,132.001007,-33.400002,131.201004,-33.400002,131.201004); + ctx.lineTo(-33.799999,129.201004); + ctx.lineTo(-33.799999,129.201004); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(5.282000,135.598007); + ctx.bezierCurveTo(5.282000,135.598007,12.203000,135.065994,10.606000,137.195007); + ctx.bezierCurveTo(9.009000,139.324997,5.814000,138.259995,5.814000,138.259995); + ctx.lineTo(5.282000,135.598007); + ctx.lineTo(5.282000,135.598007); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(15.682000,130.798004); + ctx.bezierCurveTo(15.682000,130.798004,22.603001,130.266006,21.006001,132.395004); + ctx.bezierCurveTo(19.409000,134.524994,16.214001,133.460007,16.214001,133.460007); + ctx.lineTo(15.682000,130.798004); + ctx.lineTo(15.682000,130.798004); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(26.482000,126.398003); + ctx.bezierCurveTo(26.482000,126.398003,33.403000,125.865997,31.806000,127.995003); + ctx.bezierCurveTo(30.209000,130.125000,27.014000,129.059998,27.014000,129.059998); + ctx.lineTo(26.482000,126.398003); + ctx.lineTo(26.482000,126.398003); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(36.882000,121.598000); + ctx.bezierCurveTo(36.882000,121.598000,43.803001,121.066002,42.206001,123.195000); + ctx.bezierCurveTo(40.609001,125.324997,37.414001,124.260002,37.414001,124.260002); + ctx.lineTo(36.882000,121.598000); + ctx.lineTo(36.882000,121.598000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(9.282000,103.598000); + ctx.bezierCurveTo(9.282000,103.598000,16.202999,103.066002,14.606000,105.195000); + ctx.bezierCurveTo(13.009000,107.324997,9.014000,107.059998,9.014000,107.059998); + ctx.lineTo(9.282000,103.598000); + ctx.lineTo(9.282000,103.598000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(19.282000,100.398003); + ctx.bezierCurveTo(19.282000,100.398003,26.202999,99.865997,24.606001,101.995003); + ctx.bezierCurveTo(23.009001,104.125000,18.614000,103.860001,18.614000,103.860001); + ctx.lineTo(19.282000,100.398003); + ctx.lineTo(19.282000,100.398003); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-3.400000,140.401001); + ctx.bezierCurveTo(-3.400000,140.401001,1.800000,140.001007,0.600000,141.600998); + ctx.bezierCurveTo(-0.600000,143.201004,-3.000000,142.401001,-3.000000,142.401001); + ctx.lineTo(-3.400000,140.401001); + ctx.lineTo(-3.400000,140.401001); +ctx.fill(); + + + + +ctx.fillStyle='#992600'; +ctx.beginPath(); +ctx.moveTo(-76.599998,41.200001); + ctx.bezierCurveTo(-76.599998,41.200001,-81.000000,50.000000,-81.400002,53.200001); + ctx.bezierCurveTo(-81.400002,53.200001,-80.599998,44.400002,-79.400002,42.400002); + ctx.bezierCurveTo(-78.199997,40.400002,-76.599998,41.200001,-76.599998,41.200001); + ctx.lineTo(-76.599998,41.200001); +ctx.fill(); + + + + +ctx.fillStyle='#992600'; +ctx.beginPath(); +ctx.moveTo(-95.000000,55.200001); + ctx.bezierCurveTo(-95.000000,55.200001,-98.199997,69.599998,-97.800003,72.400002); + ctx.bezierCurveTo(-97.800003,72.400002,-99.000000,60.799999,-98.599998,59.599998); + ctx.bezierCurveTo(-98.199997,58.400002,-95.000000,55.200001,-95.000000,55.200001); + ctx.lineTo(-95.000000,55.200001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-74.199997,-19.400000); + ctx.lineTo(-74.400002,-16.200001); + ctx.lineTo(-76.599998,-16.000000); + ctx.bezierCurveTo(-76.599998,-16.000000,-62.400002,-3.400000,-61.799999,4.200000); + ctx.bezierCurveTo(-61.799999,4.200000,-61.000000,-4.000000,-74.199997,-19.400000); + ctx.lineTo(-74.199997,-19.400000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-70.216003,-18.135000); + ctx.bezierCurveTo(-70.647003,-18.551001,-70.428001,-19.296000,-70.835999,-19.556000); + ctx.bezierCurveTo(-71.644997,-20.072001,-69.538002,-20.129000,-69.765999,-20.844999); + ctx.bezierCurveTo(-70.149002,-22.051001,-69.961998,-22.072001,-70.084000,-23.348000); + ctx.bezierCurveTo(-70.140999,-23.945999,-69.553001,-25.486000,-69.167999,-25.926001); + ctx.bezierCurveTo(-67.722000,-27.577999,-69.045998,-30.510000,-67.405998,-32.061001); + ctx.bezierCurveTo(-67.101997,-32.349998,-66.725998,-32.902000,-66.441002,-33.320000); + ctx.bezierCurveTo(-65.781998,-34.283001,-64.598000,-34.771000,-63.647999,-35.598999); + ctx.bezierCurveTo(-63.330002,-35.875000,-63.530998,-36.702000,-62.962002,-36.610001); + ctx.bezierCurveTo(-62.248001,-36.494999,-61.007000,-36.625000,-61.051998,-35.784000); + ctx.bezierCurveTo(-61.165001,-33.664001,-62.493999,-31.944000,-63.773998,-30.275999); + ctx.bezierCurveTo(-63.323002,-29.572001,-63.780998,-28.937000,-64.065002,-28.379999); + ctx.bezierCurveTo(-65.400002,-25.760000,-65.210999,-22.919001,-65.385002,-20.079000); + ctx.bezierCurveTo(-65.389999,-19.993999,-65.696999,-19.916000,-65.689003,-19.863001); + ctx.bezierCurveTo(-65.335999,-17.528000,-64.751999,-15.329000,-63.873001,-13.100000); + ctx.bezierCurveTo(-63.507000,-12.170000,-63.035999,-11.275000,-62.886002,-10.348000); + ctx.bezierCurveTo(-62.775002,-9.662000,-62.672001,-8.829000,-63.080002,-8.124000); + ctx.bezierCurveTo(-61.044998,-5.234000,-62.354000,-2.583000,-61.185001,0.948000); + ctx.bezierCurveTo(-60.978001,1.573000,-59.285999,3.487000,-59.749001,3.326000); + ctx.bezierCurveTo(-62.262001,2.455000,-62.374001,2.057000,-62.550999,1.304000); + ctx.bezierCurveTo(-62.696999,0.681000,-63.027000,-0.696000,-63.264000,-1.298000); + ctx.bezierCurveTo(-63.327999,-1.462000,-63.499001,-3.346000,-63.577000,-3.468000); + ctx.bezierCurveTo(-65.089996,-5.850000,-63.731998,-5.674000,-65.101997,-8.032000); + ctx.bezierCurveTo(-66.529999,-8.712000,-67.496002,-9.816000,-68.619003,-10.978000); + ctx.bezierCurveTo(-68.817001,-11.182000,-67.674004,-11.906000,-67.855003,-12.119000); + ctx.bezierCurveTo(-68.946999,-13.408000,-70.099998,-14.175000,-69.764000,-15.668000); + ctx.bezierCurveTo(-69.609001,-16.358000,-69.472000,-17.415001,-70.216003,-18.135000); + ctx.lineTo(-70.216003,-18.135000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-73.800003,-16.400000); + ctx.bezierCurveTo(-73.800003,-16.400000,-73.400002,-9.600000,-71.000000,-8.000000); + ctx.bezierCurveTo(-68.599998,-6.400000,-69.800003,-7.200000,-73.000000,-8.400000); + ctx.bezierCurveTo(-76.199997,-9.600000,-75.000000,-10.400000,-75.000000,-10.400000); + ctx.bezierCurveTo(-75.000000,-10.400000,-77.800003,-10.000000,-75.400002,-8.000000); + ctx.bezierCurveTo(-73.000000,-6.000000,-69.400002,-3.600000,-71.000000,-3.600000); + ctx.bezierCurveTo(-72.599998,-3.600000,-80.199997,-7.600000,-80.199997,-10.400000); + ctx.bezierCurveTo(-80.199997,-13.200000,-81.199997,-17.299999,-81.199997,-17.299999); + ctx.bezierCurveTo(-81.199997,-17.299999,-80.099998,-18.100000,-75.300003,-18.000000); + ctx.bezierCurveTo(-75.300003,-18.000000,-73.900002,-17.299999,-73.800003,-16.400000); + ctx.lineTo(-73.800003,-16.400000); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-74.599998,2.200000); + ctx.bezierCurveTo(-74.599998,2.200000,-83.120003,-0.591000,-101.599998,2.800000); + ctx.bezierCurveTo(-101.599998,2.800000,-92.569000,0.722000,-73.800003,3.000000); + ctx.bezierCurveTo(-63.500000,4.250000,-74.599998,2.200000,-74.599998,2.200000); + ctx.lineTo(-74.599998,2.200000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-72.501999,2.129000); + ctx.bezierCurveTo(-72.501999,2.129000,-80.748001,-1.389000,-99.453003,0.392000); + ctx.bezierCurveTo(-99.453003,0.392000,-90.275002,-0.897000,-71.774002,2.995000); + ctx.bezierCurveTo(-61.619999,5.131000,-72.501999,2.129000,-72.501999,2.129000); + ctx.lineTo(-72.501999,2.129000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-70.713997,2.222000); + ctx.bezierCurveTo(-70.713997,2.222000,-78.676003,-1.899000,-97.460999,-1.514000); + ctx.bezierCurveTo(-97.460999,-1.514000,-88.212997,-2.118000,-70.052002,3.140000); + ctx.bezierCurveTo(-60.085999,6.025000,-70.713997,2.222000,-70.713997,2.222000); + ctx.lineTo(-70.713997,2.222000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-69.444000,2.445000); + ctx.bezierCurveTo(-69.444000,2.445000,-76.267998,-1.862000,-93.141998,-2.960000); + ctx.bezierCurveTo(-93.141998,-2.960000,-84.803001,-2.790000,-68.921997,3.319000); + ctx.bezierCurveTo(-60.206001,6.672000,-69.444000,2.445000,-69.444000,2.445000); + ctx.lineTo(-69.444000,2.445000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(45.840000,12.961000); + ctx.bezierCurveTo(45.840000,12.961000,44.910000,13.605000,45.124001,12.424000); + ctx.bezierCurveTo(45.339001,11.243000,73.546997,-1.927000,77.161003,-1.677000); + ctx.bezierCurveTo(77.161003,-1.677000,46.912998,11.529000,45.840000,12.961000); + ctx.lineTo(45.840000,12.961000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(42.445999,13.600000); + ctx.bezierCurveTo(42.445999,13.600000,41.570000,14.315000,41.691002,13.121000); + ctx.bezierCurveTo(41.812000,11.927000,68.899002,-3.418000,72.521004,-3.452000); + ctx.bezierCurveTo(72.521004,-3.452000,43.403999,12.089000,42.445999,13.600000); + ctx.lineTo(42.445999,13.600000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(39.160000,14.975000); + ctx.bezierCurveTo(39.160000,14.975000,38.332001,15.747000,38.374001,14.547000); + ctx.bezierCurveTo(38.416000,13.348000,58.233002,-2.149000,68.044998,-4.023000); + ctx.bezierCurveTo(68.044998,-4.023000,50.014999,4.104000,39.160000,14.975000); + ctx.lineTo(39.160000,14.975000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(36.284000,16.837999); + ctx.bezierCurveTo(36.284000,16.837999,35.539001,17.532000,35.577000,16.452999); + ctx.bezierCurveTo(35.615002,15.373000,53.449001,1.426000,62.279999,-0.260000); + ctx.bezierCurveTo(62.279999,-0.260000,46.054001,7.054000,36.284000,16.837999); + ctx.lineTo(36.284000,16.837999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(4.600000,164.800995); + ctx.bezierCurveTo(4.600000,164.800995,-10.600000,162.401001,6.200000,160.800995); + ctx.bezierCurveTo(6.200000,160.800995,24.200001,158.800995,28.200001,153.600998); + ctx.bezierCurveTo(28.200001,153.600998,41.799999,144.401001,44.599998,144.001007); + ctx.bezierCurveTo(47.400002,143.600998,63.799999,140.001007,64.199997,137.600998); + ctx.bezierCurveTo(64.599998,135.201004,70.599998,132.800995,72.199997,133.600998); + ctx.bezierCurveTo(73.800003,134.401001,73.800003,143.600998,71.000000,144.401001); + ctx.bezierCurveTo(68.199997,145.201004,49.400002,152.401001,43.000000,153.600998); + ctx.bezierCurveTo(36.599998,154.800995,25.000000,162.401001,20.200001,163.600998); + ctx.bezierCurveTo(15.400000,164.800995,4.600000,164.800995,4.600000,164.800995); + ctx.lineTo(4.600000,164.800995); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(77.599998,127.401001); + ctx.bezierCurveTo(77.599998,127.401001,74.599998,129.001007,73.400002,131.600998); + ctx.bezierCurveTo(73.400002,131.600998,67.000000,142.201004,52.799999,145.401001); + ctx.bezierCurveTo(52.799999,145.401001,29.799999,154.401001,22.000000,156.401001); + ctx.bezierCurveTo(22.000000,156.401001,8.600000,161.401001,1.200000,160.600998); + ctx.bezierCurveTo(1.200000,160.600998,-5.800000,160.800995,0.400000,162.401001); + ctx.bezierCurveTo(0.400000,162.401001,20.600000,160.401001,24.000000,158.600998); + ctx.bezierCurveTo(24.000000,158.600998,39.599998,153.401001,42.599998,150.800995); + ctx.bezierCurveTo(45.599998,148.201004,63.799999,143.201004,66.000000,141.201004); + ctx.bezierCurveTo(68.199997,139.201004,78.000000,130.800995,77.599998,127.401001); + ctx.lineTo(77.599998,127.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(18.882000,158.910995); + ctx.bezierCurveTo(18.882000,158.910995,24.111000,158.684998,22.958000,160.233994); + ctx.bezierCurveTo(21.805000,161.783997,19.357000,160.910004,19.357000,160.910004); + ctx.lineTo(18.882000,158.910995); + ctx.lineTo(18.882000,158.910995); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(11.680000,160.263000); + ctx.bezierCurveTo(11.680000,160.263000,16.908001,160.037003,15.756000,161.585999); + ctx.bezierCurveTo(14.603000,163.136002,12.155000,162.263000,12.155000,162.263000); + ctx.lineTo(11.680000,160.263000); + ctx.lineTo(11.680000,160.263000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(1.251000,161.511002); + ctx.bezierCurveTo(1.251000,161.511002,6.480000,161.283997,5.327000,162.834000); + ctx.bezierCurveTo(4.174000,164.382996,1.726000,163.509995,1.726000,163.509995); + ctx.lineTo(1.251000,161.511002); + ctx.lineTo(1.251000,161.511002); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-6.383000,162.054993); + ctx.bezierCurveTo(-6.383000,162.054993,-1.154000,161.828995,-2.307000,163.378006); + ctx.bezierCurveTo(-3.460000,164.927994,-5.908000,164.054001,-5.908000,164.054001); + ctx.lineTo(-6.383000,162.054993); + ctx.lineTo(-6.383000,162.054993); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(35.415001,151.513000); + ctx.bezierCurveTo(35.415001,151.513000,42.375000,151.212006,40.840000,153.274002); + ctx.bezierCurveTo(39.306000,155.335999,36.047001,154.173996,36.047001,154.173996); + ctx.lineTo(35.415001,151.513000); + ctx.lineTo(35.415001,151.513000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(45.730000,147.087997); + ctx.bezierCurveTo(45.730000,147.087997,51.688999,143.787003,51.154999,148.848999); + ctx.bezierCurveTo(50.884998,151.404999,46.362000,149.748993,46.362000,149.748993); + ctx.lineTo(45.730000,147.087997); + ctx.lineTo(45.730000,147.087997); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(54.862000,144.274002); + ctx.bezierCurveTo(54.862000,144.274002,62.021000,140.572998,60.286999,146.035004); + ctx.bezierCurveTo(59.508999,148.485001,55.493000,146.934998,55.493000,146.934998); + ctx.lineTo(54.862000,144.274002); + ctx.lineTo(54.862000,144.274002); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(64.375999,139.449005); + ctx.bezierCurveTo(64.375999,139.449005,68.735001,134.548004,69.801003,141.210007); + ctx.bezierCurveTo(70.207001,143.748001,65.008003,142.110001,65.008003,142.110001); + ctx.lineTo(64.375999,139.449005); + ctx.lineTo(64.375999,139.449005); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(26.834000,155.996994); + ctx.bezierCurveTo(26.834000,155.996994,32.062000,155.770004,30.910000,157.320007); + ctx.bezierCurveTo(29.757000,158.869003,27.308001,157.996002,27.308001,157.996002); + ctx.lineTo(26.834000,155.996994); + ctx.lineTo(26.834000,155.996994); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(62.433998,34.603001); + ctx.bezierCurveTo(62.433998,34.603001,61.708000,35.268002,61.707001,34.196999); + ctx.bezierCurveTo(61.707001,33.126999,79.191002,19.863001,88.033997,18.479000); + ctx.bezierCurveTo(88.033997,18.479000,71.934998,25.208000,62.433998,34.603001); + ctx.lineTo(62.433998,34.603001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(65.400002,98.400002); + ctx.bezierCurveTo(65.400002,98.400002,87.401001,120.801003,96.600998,124.401001); + ctx.bezierCurveTo(96.600998,124.401001,105.801003,135.600998,101.801003,161.600998); + ctx.bezierCurveTo(101.801003,161.600998,98.600998,169.201004,95.401001,148.401001); + ctx.bezierCurveTo(95.401001,148.401001,98.600998,123.200996,87.401001,139.201004); + ctx.bezierCurveTo(87.401001,139.201004,79.000000,129.300995,85.400002,129.600998); + ctx.bezierCurveTo(85.400002,129.600998,88.600998,131.600998,89.000999,130.001007); + ctx.bezierCurveTo(89.401001,128.401001,81.400002,114.801003,64.199997,100.400002); + ctx.bezierCurveTo(47.000000,86.000000,65.400002,98.400002,65.400002,98.400002); + ctx.lineTo(65.400002,98.400002); +ctx.fill(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(7.000000,137.201004); + ctx.bezierCurveTo(7.000000,137.201004,6.800000,135.401001,8.600000,136.201004); + ctx.bezierCurveTo(10.400000,137.001007,104.600998,143.201004,136.201004,167.201004); + ctx.bezierCurveTo(136.201004,167.201004,91.000999,144.001007,7.000000,137.201004); + ctx.lineTo(7.000000,137.201004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(17.400000,132.800995); + ctx.bezierCurveTo(17.400000,132.800995,17.200001,131.001007,19.000000,131.800995); + ctx.bezierCurveTo(20.799999,132.600998,157.401001,131.600998,181.001007,164.001007); + ctx.bezierCurveTo(181.001007,164.001007,159.001007,138.800995,17.400000,132.800995); + ctx.lineTo(17.400000,132.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(29.000000,128.800995); + ctx.bezierCurveTo(29.000000,128.800995,28.799999,127.000999,30.600000,127.801003); + ctx.bezierCurveTo(32.400002,128.600998,205.800995,115.600998,229.401001,148.001007); + ctx.bezierCurveTo(229.401001,148.001007,219.800995,122.401001,29.000000,128.800995); + ctx.lineTo(29.000000,128.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(39.000000,124.000999); + ctx.bezierCurveTo(39.000000,124.000999,38.799999,122.200996,40.599998,123.000999); + ctx.bezierCurveTo(42.400002,123.801003,164.600998,85.199997,188.201004,117.600998); + ctx.bezierCurveTo(188.201004,117.600998,174.800995,93.000000,39.000000,124.000999); + ctx.lineTo(39.000000,124.000999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-19.000000,146.800995); + ctx.bezierCurveTo(-19.000000,146.800995,-19.200001,145.001007,-17.400000,145.800995); + ctx.bezierCurveTo(-15.600000,146.600998,2.200000,148.800995,4.200000,187.600998); + ctx.bezierCurveTo(4.200000,187.600998,-3.000000,145.600998,-19.000000,146.800995); + ctx.lineTo(-19.000000,146.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-27.799999,148.401001); + ctx.bezierCurveTo(-27.799999,148.401001,-28.000000,146.600998,-26.200001,147.401001); + ctx.bezierCurveTo(-24.400000,148.201004,-10.200000,143.600998,-13.000000,182.401001); + ctx.bezierCurveTo(-13.000000,182.401001,-11.800000,147.201004,-27.799999,148.401001); + ctx.lineTo(-27.799999,148.401001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-35.799999,148.800995); + ctx.bezierCurveTo(-35.799999,148.800995,-36.000000,147.001007,-34.200001,147.800995); + ctx.bezierCurveTo(-32.400002,148.600998,-17.000000,149.201004,-29.400000,171.600998); + ctx.bezierCurveTo(-29.400000,171.600998,-19.799999,147.600998,-35.799999,148.800995); + ctx.lineTo(-35.799999,148.800995); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(11.526000,104.464996); + ctx.bezierCurveTo(11.526000,104.464996,11.082000,106.463997,12.631000,105.247002); + ctx.bezierCurveTo(28.698999,92.622002,61.140999,33.720001,116.825996,28.086000); + ctx.bezierCurveTo(116.825996,28.086000,78.517998,15.976000,11.526000,104.464996); + ctx.lineTo(11.526000,104.464996); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(22.726000,102.665001); + ctx.bezierCurveTo(22.726000,102.665001,21.363001,101.472000,23.231001,100.847000); + ctx.bezierCurveTo(25.099001,100.222000,137.541000,27.719999,176.826004,35.686001); + ctx.bezierCurveTo(176.826004,35.686001,149.718994,28.176001,22.726000,102.665001); + ctx.lineTo(22.726000,102.665001); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(1.885000,108.766998); + ctx.bezierCurveTo(1.885000,108.766998,1.376000,110.365997,3.087000,109.389999); + ctx.bezierCurveTo(12.062000,104.269997,15.677000,47.058998,59.254002,45.804001); + ctx.bezierCurveTo(59.254002,45.804001,26.843000,31.090000,1.885000,108.766998); + ctx.lineTo(1.885000,108.766998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-18.038000,119.792999); + ctx.bezierCurveTo(-18.038000,119.792999,-19.115000,121.079002,-17.162001,120.824997); + ctx.bezierCurveTo(-6.916000,119.492996,14.489000,78.222000,58.928001,83.301003); + ctx.bezierCurveTo(58.928001,83.301003,26.962000,68.955002,-18.038000,119.792999); + ctx.lineTo(-18.038000,119.792999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-6.800000,113.667000); + ctx.bezierCurveTo(-6.800000,113.667000,-7.611000,115.136002,-5.742000,114.511002); + ctx.bezierCurveTo(4.057000,111.237000,17.141001,66.625000,61.729000,63.077999); + ctx.bezierCurveTo(61.729000,63.077999,27.603001,55.134998,-6.800000,113.667000); + ctx.lineTo(-6.800000,113.667000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-25.077999,124.912003); + ctx.bezierCurveTo(-25.077999,124.912003,-25.951000,125.954002,-24.368999,125.748001); + ctx.bezierCurveTo(-16.070000,124.668999,1.268000,91.239998,37.264000,95.353996); + ctx.bezierCurveTo(37.264000,95.353996,11.371000,83.734001,-25.077999,124.912003); + ctx.lineTo(-25.077999,124.912003); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-32.676998,130.820999); + ctx.bezierCurveTo(-32.676998,130.820999,-33.681999,131.865997,-32.091000,131.748001); + ctx.bezierCurveTo(-27.923000,131.438995,2.715000,98.360001,21.183001,113.862000); + ctx.bezierCurveTo(21.183001,113.862000,9.168000,95.139000,-32.676998,130.820999); + ctx.lineTo(-32.676998,130.820999); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(36.855000,98.898003); + ctx.bezierCurveTo(36.855000,98.898003,35.653999,97.542999,37.585999,97.157997); + ctx.bezierCurveTo(39.518002,96.774002,160.220993,39.061001,198.184006,51.926998); + ctx.bezierCurveTo(198.184006,51.926998,172.242996,41.053001,36.855000,98.898003); + ctx.lineTo(36.855000,98.898003); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(3.400000,163.201004); + ctx.bezierCurveTo(3.400000,163.201004,3.200000,161.401001,5.000000,162.201004); + ctx.bezierCurveTo(6.800000,163.001007,22.200001,163.600998,9.800000,186.001007); + ctx.bezierCurveTo(9.800000,186.001007,19.400000,162.001007,3.400000,163.201004); + ctx.lineTo(3.400000,163.201004); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(13.800000,161.600998); + ctx.bezierCurveTo(13.800000,161.600998,13.600000,159.800995,15.400000,160.600998); + ctx.bezierCurveTo(17.200001,161.401001,35.000000,163.600998,37.000000,202.401001); + ctx.bezierCurveTo(37.000000,202.401001,29.799999,160.401001,13.800000,161.600998); + ctx.lineTo(13.800000,161.600998); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(20.600000,160.001007); + ctx.bezierCurveTo(20.600000,160.001007,20.400000,158.201004,22.200001,159.001007); + ctx.bezierCurveTo(24.000000,159.800995,48.599998,163.201004,72.199997,195.600998); + ctx.bezierCurveTo(72.199997,195.600998,36.599998,158.800995,20.600000,160.001007); + ctx.lineTo(20.600000,160.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(28.225000,157.972000); + ctx.bezierCurveTo(28.225000,157.972000,27.788000,156.214005,29.677999,156.768005); + ctx.bezierCurveTo(31.568001,157.322006,52.001999,155.423004,90.098999,189.598999); + ctx.bezierCurveTo(90.098999,189.598999,43.924000,154.656006,28.225000,157.972000); + ctx.lineTo(28.225000,157.972000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(38.625000,153.572006); + ctx.bezierCurveTo(38.625000,153.572006,38.188000,151.813995,40.077999,152.367996); + ctx.bezierCurveTo(41.967999,152.921997,76.802002,157.423004,128.498993,192.399002); + ctx.bezierCurveTo(128.498993,192.399002,54.324001,150.255997,38.625000,153.572006); + ctx.lineTo(38.625000,153.572006); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-1.800000,142.001007); + ctx.bezierCurveTo(-1.800000,142.001007,-2.000000,140.201004,-0.200000,141.001007); + ctx.bezierCurveTo(1.600000,141.800995,55.000000,144.401001,85.400002,171.201004); + ctx.bezierCurveTo(85.400002,171.201004,50.499001,146.425995,-1.800000,142.001007); + ctx.lineTo(-1.800000,142.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(-11.800000,146.001007); + ctx.bezierCurveTo(-11.800000,146.001007,-12.000000,144.201004,-10.200000,145.001007); + ctx.bezierCurveTo(-8.400000,145.800995,16.200001,149.201004,39.799999,181.600998); + ctx.bezierCurveTo(39.799999,181.600998,4.200000,144.800995,-11.800000,146.001007); + ctx.lineTo(-11.800000,146.001007); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(49.502998,148.962006); + ctx.bezierCurveTo(49.502998,148.962006,48.938000,147.240997,50.863998,147.654999); + ctx.bezierCurveTo(52.790001,148.067993,87.860001,150.003998,141.981003,181.098007); + ctx.bezierCurveTo(141.981003,181.098007,64.317001,146.703995,49.502998,148.962006); + ctx.lineTo(49.502998,148.962006); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(57.903000,146.561996); + ctx.bezierCurveTo(57.903000,146.561996,57.338001,144.841003,59.264000,145.255005); + ctx.bezierCurveTo(61.189999,145.667999,96.260002,147.604004,150.380997,178.697998); + ctx.bezierCurveTo(150.380997,178.697998,73.317001,143.904007,57.903000,146.561996); + ctx.lineTo(57.903000,146.561996); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#ffffff'; +ctx.strokeStyle='#000000'; +ctx.lineWidth='0.1'; +ctx.beginPath(); +ctx.moveTo(67.502998,141.561996); + ctx.bezierCurveTo(67.502998,141.561996,66.938004,139.841003,68.863998,140.255005); + ctx.bezierCurveTo(70.790001,140.667999,113.860001,145.003998,203.582001,179.298004); + ctx.bezierCurveTo(203.582001,179.298004,82.917000,138.904007,67.502998,141.561996); + ctx.lineTo(67.502998,141.561996); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-43.799999,148.401001); + ctx.bezierCurveTo(-43.799999,148.401001,-38.599998,148.001007,-39.799999,149.600998); + ctx.bezierCurveTo(-41.000000,151.201004,-43.400002,150.401001,-43.400002,150.401001); + ctx.lineTo(-43.799999,148.401001); + ctx.lineTo(-43.799999,148.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-13.000000,162.401001); + ctx.bezierCurveTo(-13.000000,162.401001,-7.800000,162.001007,-9.000000,163.600998); + ctx.bezierCurveTo(-10.200000,165.201004,-12.600000,164.401001,-12.600000,164.401001); + ctx.lineTo(-13.000000,162.401001); + ctx.lineTo(-13.000000,162.401001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-21.799999,162.001007); + ctx.bezierCurveTo(-21.799999,162.001007,-16.600000,161.600998,-17.799999,163.201004); + ctx.bezierCurveTo(-19.000000,164.800995,-21.400000,164.001007,-21.400000,164.001007); + ctx.lineTo(-21.799999,162.001007); + ctx.lineTo(-21.799999,162.001007); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-117.168999,150.182007); + ctx.bezierCurveTo(-117.168999,150.182007,-112.124001,151.505005,-113.781998,152.623993); + ctx.bezierCurveTo(-115.439003,153.744003,-117.445999,152.201996,-117.445999,152.201996); + ctx.lineTo(-117.168999,150.182007); + ctx.lineTo(-117.168999,150.182007); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-115.168999,140.582001); + ctx.bezierCurveTo(-115.168999,140.582001,-110.124001,141.904999,-111.781998,143.024002); + ctx.bezierCurveTo(-113.439003,144.143997,-115.445999,142.602005,-115.445999,142.602005); + ctx.lineTo(-115.168999,140.582001); + ctx.lineTo(-115.168999,140.582001); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-122.369003,136.182007); + ctx.bezierCurveTo(-122.369003,136.182007,-117.323997,137.505005,-118.982002,138.623993); + ctx.bezierCurveTo(-120.639000,139.744003,-122.646004,138.201996,-122.646004,138.201996); + ctx.lineTo(-122.369003,136.182007); + ctx.lineTo(-122.369003,136.182007); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-42.599998,211.201004); + ctx.bezierCurveTo(-42.599998,211.201004,-44.200001,211.201004,-48.200001,213.201004); + ctx.bezierCurveTo(-50.200001,213.201004,-61.400002,216.800995,-67.000000,226.800995); + ctx.bezierCurveTo(-67.000000,226.800995,-54.599998,217.201004,-42.599998,211.201004); + ctx.lineTo(-42.599998,211.201004); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(45.116001,303.846985); + ctx.bezierCurveTo(45.257000,304.105011,45.312000,304.524994,45.604000,304.541992); + ctx.bezierCurveTo(46.262001,304.582001,47.494999,304.882996,47.369999,304.247009); + ctx.bezierCurveTo(46.521999,299.941010,45.647999,295.003998,41.514999,293.196991); + ctx.bezierCurveTo(40.875999,292.917999,39.433998,293.330994,39.360001,294.214996); + ctx.bezierCurveTo(39.233002,295.739014,39.116001,297.088013,39.424999,298.553986); + ctx.bezierCurveTo(39.724998,299.975006,41.882999,299.984985,42.799999,298.601013); + ctx.bezierCurveTo(43.736000,300.273010,44.167999,302.115997,45.116001,303.846985); + ctx.lineTo(45.116001,303.846985); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(34.037998,308.580994); + ctx.bezierCurveTo(34.785999,309.993988,34.659000,311.852997,36.074001,312.415985); + ctx.bezierCurveTo(36.813999,312.709991,38.664001,311.734985,38.245998,310.661011); + ctx.bezierCurveTo(37.444000,308.600006,37.056000,306.360992,35.667000,304.549988); + ctx.bezierCurveTo(35.466999,304.287994,35.707001,303.755005,35.547001,303.427002); + ctx.bezierCurveTo(34.952999,302.207001,33.807999,301.471985,32.400002,301.800995); + ctx.bezierCurveTo(31.285000,304.003998,32.432999,306.132996,33.955002,307.842010); + ctx.bezierCurveTo(34.091000,307.993988,33.924999,308.369995,34.037998,308.580994); + ctx.lineTo(34.037998,308.580994); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-5.564000,303.390991); + ctx.bezierCurveTo(-5.672000,303.014008,-5.710000,302.550995,-5.545000,302.230011); + ctx.bezierCurveTo(-5.014000,301.196991,-4.221000,300.075012,-4.558000,299.053009); + ctx.bezierCurveTo(-4.906000,297.997009,-6.022000,298.178986,-6.672000,298.747986); + ctx.bezierCurveTo(-7.807000,299.742004,-7.856000,301.567993,-8.547000,302.927002); + ctx.bezierCurveTo(-8.743000,303.312988,-8.692000,303.885986,-9.133000,304.277008); + ctx.bezierCurveTo(-9.607000,304.697998,-10.047000,306.221985,-9.951000,306.792999); + ctx.bezierCurveTo(-9.898000,307.105988,-10.081000,317.014008,-9.859000,316.751007); + ctx.bezierCurveTo(-9.240000,316.018005,-6.190000,306.283997,-6.121000,305.391998); + ctx.bezierCurveTo(-6.064000,304.661011,-5.332000,304.196014,-5.564000,303.390991); + ctx.lineTo(-5.564000,303.390991); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-31.202000,296.598999); + ctx.bezierCurveTo(-28.568001,294.100006,-25.778000,291.139008,-26.219999,287.427002); + ctx.bezierCurveTo(-26.336000,286.450989,-28.111000,286.977997,-28.298000,287.824005); + ctx.bezierCurveTo(-29.100000,291.449005,-31.139000,294.109985,-33.707001,296.502014); + ctx.bezierCurveTo(-35.903000,298.549011,-37.764999,304.893005,-38.000000,305.401001); + ctx.bezierCurveTo(-34.303001,300.144989,-32.046001,297.398987,-31.202000,296.598999); + ctx.lineTo(-31.202000,296.598999); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-44.776001,290.635010); + ctx.bezierCurveTo(-44.252998,290.265015,-44.555000,289.773987,-44.338001,289.441986); + ctx.bezierCurveTo(-43.384998,287.984009,-42.084000,286.738007,-42.066002,285.000000); + ctx.bezierCurveTo(-42.063000,284.722992,-42.441002,284.414001,-42.776001,284.638000); + ctx.bezierCurveTo(-43.053001,284.821991,-43.395000,284.951996,-43.502998,285.082001); + ctx.bezierCurveTo(-45.533001,287.531006,-46.932999,290.201996,-48.375999,293.014008); + ctx.bezierCurveTo(-48.558998,293.371002,-49.702999,297.862000,-49.389999,297.972992); + ctx.bezierCurveTo(-49.151001,298.058014,-47.431000,293.877014,-47.221001,293.763000); + ctx.bezierCurveTo(-45.958000,293.076996,-45.945999,291.462006,-44.776001,290.635010); + ctx.lineTo(-44.776001,290.635010); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-28.042999,310.178986); + ctx.bezierCurveTo(-27.599001,309.309998,-26.023001,308.108002,-26.136000,307.218994); + ctx.bezierCurveTo(-26.254000,306.290985,-25.785999,304.847992,-26.698000,305.536011); + ctx.bezierCurveTo(-27.955000,306.484009,-31.403999,307.833008,-31.674000,313.640991); + ctx.bezierCurveTo(-31.700001,314.212006,-28.726000,311.519012,-28.042999,310.178986); + ctx.lineTo(-28.042999,310.178986); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-13.600000,293.001007); + ctx.bezierCurveTo(-13.200000,292.333008,-12.492000,292.806000,-12.033000,292.542999); + ctx.bezierCurveTo(-11.385000,292.170990,-10.774000,291.613007,-10.482000,290.963989); + ctx.bezierCurveTo(-9.512000,288.815002,-7.743000,286.994995,-7.600000,284.601013); + ctx.bezierCurveTo(-9.091000,283.196014,-9.770000,285.235992,-10.400000,286.200989); + ctx.bezierCurveTo(-11.723000,284.553986,-12.722000,286.428009,-14.022000,286.946991); + ctx.bezierCurveTo(-14.092000,286.975006,-14.305000,286.627991,-14.380000,286.654999); + ctx.bezierCurveTo(-15.557000,287.095001,-16.237000,288.175995,-17.235001,288.957001); + ctx.bezierCurveTo(-17.406000,289.091003,-17.811001,288.911011,-17.958000,289.046997); + ctx.bezierCurveTo(-18.610001,289.649994,-19.583000,289.975006,-19.863001,290.657013); + ctx.bezierCurveTo(-20.973000,293.364014,-24.113001,295.459015,-26.000000,303.001007); + ctx.bezierCurveTo(-25.618999,303.910004,-21.488001,296.359009,-21.000999,295.661011); + ctx.bezierCurveTo(-20.165001,294.464996,-20.047001,297.321991,-18.771000,296.656006); + ctx.bezierCurveTo(-18.719999,296.628998,-18.534000,296.867004,-18.400000,297.001007); + ctx.bezierCurveTo(-18.205999,296.721008,-17.988001,296.492004,-17.600000,296.601013); + ctx.bezierCurveTo(-17.600000,296.200989,-17.733999,295.644989,-17.533001,295.485992); + ctx.bezierCurveTo(-16.296000,294.509003,-16.379999,293.441010,-15.600000,292.200989); + ctx.bezierCurveTo(-15.142000,292.989990,-14.081000,292.270996,-13.600000,293.001007); + ctx.lineTo(-13.600000,293.001007); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(46.200001,347.401001); + ctx.bezierCurveTo(46.200001,347.401001,53.599998,327.001007,49.200001,315.800995); + ctx.bezierCurveTo(49.200001,315.800995,60.599998,337.401001,56.000000,348.601013); + ctx.bezierCurveTo(56.000000,348.601013,55.599998,338.200989,51.599998,333.200989); + ctx.bezierCurveTo(51.599998,333.200989,47.599998,346.001007,46.200001,347.401001); + ctx.lineTo(46.200001,347.401001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(31.400000,344.800995); + ctx.bezierCurveTo(31.400000,344.800995,36.799999,336.001007,28.799999,317.601013); + ctx.bezierCurveTo(28.799999,317.601013,28.000000,338.001007,21.200001,349.001007); + ctx.bezierCurveTo(21.200001,349.001007,35.400002,328.800995,31.400000,344.800995); + ctx.lineTo(31.400000,344.800995); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(21.400000,342.800995); + ctx.bezierCurveTo(21.400000,342.800995,21.200001,322.800995,21.600000,319.800995); + ctx.bezierCurveTo(21.600000,319.800995,17.799999,336.401001,7.600000,346.001007); + ctx.bezierCurveTo(7.600000,346.001007,22.000000,334.001007,21.400000,342.800995); + ctx.lineTo(21.400000,342.800995); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(11.800000,310.800995); + ctx.bezierCurveTo(11.800000,310.800995,17.799999,324.401001,7.800000,342.800995); + ctx.bezierCurveTo(7.800000,342.800995,14.200000,330.601013,9.400000,323.601013); + ctx.bezierCurveTo(9.400000,323.601013,12.000000,320.200989,11.800000,310.800995); + ctx.lineTo(11.800000,310.800995); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-7.400000,342.401001); + ctx.bezierCurveTo(-7.400000,342.401001,-8.400000,326.800995,-6.600000,324.601013); + ctx.bezierCurveTo(-6.600000,324.601013,-6.400000,318.200989,-6.800000,317.200989); + ctx.bezierCurveTo(-6.800000,317.200989,-2.800000,311.001007,-2.600000,318.401001); + ctx.bezierCurveTo(-2.600000,318.401001,-1.200000,326.200989,1.600000,330.800995); + ctx.bezierCurveTo(1.600000,330.800995,5.200000,336.200989,5.000000,342.601013); + ctx.bezierCurveTo(5.000000,342.601013,-5.000000,312.401001,-7.400000,342.401001); + ctx.lineTo(-7.400000,342.401001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-11.000000,314.800995); + ctx.bezierCurveTo(-11.000000,314.800995,-17.600000,325.601013,-19.400000,344.601013); + ctx.bezierCurveTo(-19.400000,344.601013,-20.799999,338.401001,-17.000000,324.001007); + ctx.bezierCurveTo(-17.000000,324.001007,-12.800000,308.601013,-11.000000,314.800995); + ctx.lineTo(-11.000000,314.800995); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-32.799999,334.601013); + ctx.bezierCurveTo(-32.799999,334.601013,-27.799999,329.200989,-26.400000,324.200989); + ctx.bezierCurveTo(-26.400000,324.200989,-22.799999,308.401001,-29.200001,317.001007); + ctx.bezierCurveTo(-29.200001,317.001007,-29.000000,325.001007,-37.200001,332.401001); + ctx.bezierCurveTo(-37.200001,332.401001,-32.400002,330.001007,-32.799999,334.601013); + ctx.lineTo(-32.799999,334.601013); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-38.599998,329.601013); + ctx.bezierCurveTo(-38.599998,329.601013,-35.200001,312.200989,-34.400002,311.401001); + ctx.bezierCurveTo(-34.400002,311.401001,-32.599998,308.001007,-35.400002,311.200989); + ctx.bezierCurveTo(-35.400002,311.200989,-44.200001,330.401001,-48.200001,337.001007); + ctx.bezierCurveTo(-48.200001,337.001007,-40.200001,327.800995,-38.599998,329.601013); + ctx.lineTo(-38.599998,329.601013); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-44.400002,313.001007); + ctx.bezierCurveTo(-44.400002,313.001007,-32.799999,290.601013,-54.599998,316.401001); + ctx.bezierCurveTo(-54.599998,316.401001,-43.599998,306.601013,-44.400002,313.001007); + ctx.lineTo(-44.400002,313.001007); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(-59.799999,298.401001); + ctx.bezierCurveTo(-59.799999,298.401001,-55.000000,279.601013,-52.400002,279.800995); + ctx.bezierCurveTo(-52.400002,279.800995,-44.200001,270.800995,-50.799999,281.401001); + ctx.bezierCurveTo(-50.799999,281.401001,-56.799999,291.001007,-56.200001,300.800995); + ctx.bezierCurveTo(-56.200001,300.800995,-56.799999,291.200989,-59.799999,298.401001); + ctx.lineTo(-59.799999,298.401001); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(270.500000,287.000000); + ctx.bezierCurveTo(270.500000,287.000000,258.500000,277.000000,256.000000,273.500000); + ctx.bezierCurveTo(256.000000,273.500000,269.500000,292.000000,269.500000,299.000000); + ctx.bezierCurveTo(269.500000,299.000000,272.000000,291.500000,270.500000,287.000000); + ctx.lineTo(270.500000,287.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(276.000000,265.000000); + ctx.bezierCurveTo(276.000000,265.000000,255.000000,250.000000,251.500000,242.500000); + ctx.bezierCurveTo(251.500000,242.500000,278.000000,272.000000,278.000000,276.500000); + ctx.bezierCurveTo(278.000000,276.500000,278.500000,267.500000,276.000000,265.000000); + ctx.lineTo(276.000000,265.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(293.000000,111.000000); + ctx.bezierCurveTo(293.000000,111.000000,281.000000,103.000000,279.500000,105.000000); + ctx.bezierCurveTo(279.500000,105.000000,290.000000,111.500000,292.500000,120.000000); + ctx.bezierCurveTo(292.500000,120.000000,291.000000,111.000000,293.000000,111.000000); + ctx.lineTo(293.000000,111.000000); +ctx.fill(); + + + + +ctx.fillStyle='#cccccc'; +ctx.beginPath(); +ctx.moveTo(301.500000,191.500000); + ctx.lineTo(284.000000,179.500000); + ctx.bezierCurveTo(284.000000,179.500000,303.000000,196.500000,303.500000,200.500000); + ctx.lineTo(301.500000,191.500000); + ctx.lineTo(301.500000,191.500000); +ctx.fill(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-89.250000,169.000000); + ctx.lineTo(-67.250000,173.750000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-39.000000,331.000000); + ctx.bezierCurveTo(-39.000000,331.000000,-39.500000,327.500000,-48.500000,338.000000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(-33.500000,336.000000); + ctx.bezierCurveTo(-33.500000,336.000000,-31.500000,329.500000,-38.000000,334.000000); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='none'; +ctx.strokeStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(20.500000,344.500000); + ctx.bezierCurveTo(20.500000,344.500000,22.000000,333.500000,10.500000,346.500000); +ctx.fill(); +ctx.stroke(); + + + + +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/p2.js b/CAAT/documentation/demos/demo24/p2.js new file mode 100644 index 0000000..14a6c51 --- /dev/null +++ b/CAAT/documentation/demos/demo24/p2.js @@ -0,0 +1,3007 @@ +function ff1(ctx) { + + +ctx.fillStyle='#f2cc99'; +ctx.beginPath(); +ctx.moveTo(69.000000,18.000000); + ctx.lineTo(82.000000,8.000000); + ctx.lineTo(99.000000,3.000000); + ctx.lineTo(118.000000,5.000000); + ctx.lineTo(135.000000,12.000000); + ctx.lineTo(149.000000,21.000000); + ctx.lineTo(156.000000,13.000000); + ctx.lineTo(165.000000,9.000000); + ctx.lineTo(177.000000,13.000000); + ctx.lineTo(183.000000,28.000000); + ctx.lineTo(180.000000,50.000000); + ctx.lineTo(164.000000,91.000000); + ctx.lineTo(155.000000,107.000000); + ctx.lineTo(154.000000,114.000000); + ctx.lineTo(151.000000,121.000000); + ctx.lineTo(141.000000,127.000000); + ctx.lineTo(139.000000,136.000000); + ctx.lineTo(155.000000,206.000000); + ctx.lineTo(157.000000,251.000000); + ctx.lineTo(126.000000,342.000000); + ctx.lineTo(133.000000,357.000000); + ctx.lineTo(128.000000,376.000000); + ctx.lineTo(83.000000,376.000000); + ctx.lineTo(75.000000,368.000000); + ctx.lineTo(67.000000,350.000000); + ctx.lineTo(61.000000,350.000000); + ctx.lineTo(53.000000,369.000000); + ctx.lineTo(4.000000,369.000000); + ctx.lineTo(2.000000,361.000000); + ctx.lineTo(5.000000,354.000000); + ctx.lineTo(12.000000,342.000000); + ctx.lineTo(16.000000,321.000000); + ctx.lineTo(4.000000,257.000000); + ctx.lineTo(4.000000,244.000000); + ctx.lineTo(7.000000,218.000000); + ctx.lineTo(9.000000,179.000000); + ctx.lineTo(26.000000,127.000000); + ctx.lineTo(43.000000,93.000000); + ctx.lineTo(32.000000,77.000000); + ctx.lineTo(30.000000,70.000000); + ctx.lineTo(24.000000,67.000000); + ctx.lineTo(16.000000,49.000000); + ctx.lineTo(17.000000,35.000000); + ctx.lineTo(18.000000,23.000000); + ctx.lineTo(30.000000,12.000000); + ctx.lineTo(40.000000,7.000000); + ctx.lineTo(53.000000,7.000000); + ctx.lineTo(62.000000,12.000000); + ctx.lineTo(69.000000,18.000000); +ctx.fill(); + + + + +ctx.fillStyle='#e5b27f'; +ctx.beginPath(); +ctx.moveTo(142.000000,79.000000); + ctx.lineTo(136.000000,74.000000); + ctx.lineTo(138.000000,82.000000); + ctx.lineTo(133.000000,78.000000); + ctx.lineTo(133.000000,84.000000); + ctx.lineTo(127.000000,78.000000); + ctx.lineTo(128.000000,85.000000); + ctx.lineTo(124.000000,80.000000); + ctx.lineTo(125.000000,87.000000); + ctx.lineTo(119.000000,82.000000); + ctx.lineTo(119.000000,90.000000); + ctx.lineTo(125.000000,99.000000); + ctx.lineTo(125.000000,96.000000); + ctx.lineTo(128.000000,100.000000); + ctx.lineTo(128.000000,94.000000); + ctx.lineTo(131.000000,98.000000); + ctx.lineTo(132.000000,93.000000); + ctx.lineTo(135.000000,97.000000); + ctx.lineTo(136.000000,93.000000); + ctx.lineTo(138.000000,97.000000); + ctx.lineTo(139.000000,94.000000); + ctx.lineTo(141.000000,98.000000); + ctx.lineTo(143.000000,94.000000); + ctx.lineTo(144.000000,85.000000); + ctx.lineTo(142.000000,79.000000); +ctx.fill(); + + + + +ctx.fillStyle='#eb8080'; +ctx.beginPath(); +ctx.moveTo(127.000000,101.000000); + ctx.lineTo(132.000000,100.000000); + ctx.lineTo(137.000000,99.000000); + ctx.lineTo(144.000000,101.000000); + ctx.lineTo(143.000000,105.000000); + ctx.lineTo(135.000000,110.000000); + ctx.lineTo(127.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#f2cc99'; +ctx.beginPath(); +ctx.moveTo(178.000000,229.000000); + ctx.lineTo(157.000000,248.000000); + ctx.lineTo(139.000000,296.000000); + ctx.lineTo(126.000000,349.000000); + ctx.lineTo(137.000000,356.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(183.000000,342.000000); + ctx.lineTo(212.000000,332.000000); + ctx.lineTo(235.000000,288.000000); + ctx.lineTo(235.000000,261.000000); + ctx.lineTo(228.000000,252.000000); + ctx.lineTo(212.000000,250.000000); + ctx.lineTo(188.000000,251.000000); + ctx.lineTo(178.000000,229.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(56.000000,229.000000); + ctx.lineTo(48.000000,241.000000); + ctx.lineTo(48.000000,250.000000); + ctx.lineTo(57.000000,281.000000); + ctx.lineTo(63.000000,325.000000); + ctx.lineTo(71.000000,338.000000); + ctx.lineTo(81.000000,315.000000); + ctx.lineTo(76.000000,321.000000); + ctx.lineTo(79.000000,311.000000); + ctx.lineTo(83.000000,301.000000); + ctx.lineTo(75.000000,308.000000); + ctx.lineTo(80.000000,298.000000); + ctx.lineTo(73.000000,303.000000); + ctx.lineTo(76.000000,296.000000); + ctx.lineTo(71.000000,298.000000); + ctx.lineTo(74.000000,292.000000); + ctx.lineTo(69.000000,293.000000); + ctx.lineTo(74.000000,284.000000); + ctx.lineTo(78.000000,278.000000); + ctx.lineTo(71.000000,278.000000); + ctx.lineTo(74.000000,274.000000); + ctx.lineTo(68.000000,273.000000); + ctx.lineTo(70.000000,268.000000); + ctx.lineTo(66.000000,267.000000); + ctx.lineTo(68.000000,261.000000); + ctx.lineTo(60.000000,266.000000); + ctx.lineTo(62.000000,259.000000); + ctx.lineTo(65.000000,253.000000); + ctx.lineTo(57.000000,258.000000); + ctx.lineTo(59.000000,251.000000); + ctx.lineTo(55.000000,254.000000); + ctx.lineTo(55.000000,248.000000); + ctx.lineTo(60.000000,237.000000); + ctx.lineTo(54.000000,240.000000); + ctx.lineTo(58.000000,234.000000); + ctx.lineTo(54.000000,236.000000); + ctx.lineTo(56.000000,229.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(74.000000,363.000000); + ctx.lineTo(79.000000,368.000000); + ctx.lineTo(81.000000,368.000000); + ctx.lineTo(85.000000,362.000000); + ctx.lineTo(89.000000,363.000000); + ctx.lineTo(92.000000,370.000000); + ctx.lineTo(96.000000,373.000000); + ctx.lineTo(101.000000,372.000000); + ctx.lineTo(108.000000,361.000000); + ctx.lineTo(110.000000,371.000000); + ctx.lineTo(113.000000,373.000000); + ctx.lineTo(116.000000,371.000000); + ctx.lineTo(120.000000,358.000000); + ctx.lineTo(122.000000,363.000000); + ctx.lineTo(123.000000,371.000000); + ctx.lineTo(126.000000,371.000000); + ctx.lineTo(129.000000,367.000000); + ctx.lineTo(132.000000,357.000000); + ctx.lineTo(135.000000,361.000000); + ctx.lineTo(130.000000,376.000000); + ctx.lineTo(127.000000,377.000000); + ctx.lineTo(94.000000,378.000000); + ctx.lineTo(84.000000,376.000000); + ctx.lineTo(76.000000,371.000000); + ctx.lineTo(74.000000,363.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(212.000000,250.000000); + ctx.lineTo(219.000000,251.000000); + ctx.lineTo(228.000000,258.000000); + ctx.lineTo(236.000000,270.000000); + ctx.lineTo(235.000000,287.000000); + ctx.lineTo(225.000000,304.000000); + ctx.lineTo(205.000000,332.000000); + ctx.lineTo(177.000000,343.000000); + ctx.lineTo(171.000000,352.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(166.000000,352.000000); + ctx.lineTo(168.000000,346.000000); + ctx.lineTo(168.000000,339.000000); + ctx.lineTo(165.000000,333.000000); + ctx.lineTo(155.000000,327.000000); + ctx.lineTo(155.000000,323.000000); + ctx.lineTo(161.000000,320.000000); + ctx.lineTo(165.000000,316.000000); + ctx.lineTo(169.000000,316.000000); + ctx.lineTo(167.000000,312.000000); + ctx.lineTo(171.000000,313.000000); + ctx.lineTo(168.000000,308.000000); + ctx.lineTo(173.000000,309.000000); + ctx.lineTo(170.000000,306.000000); + ctx.lineTo(177.000000,306.000000); + ctx.lineTo(175.000000,308.000000); + ctx.lineTo(177.000000,311.000000); + ctx.lineTo(174.000000,311.000000); + ctx.lineTo(176.000000,316.000000); + ctx.lineTo(171.000000,315.000000); + ctx.lineTo(174.000000,319.000000); + ctx.lineTo(168.000000,320.000000); + ctx.lineTo(168.000000,323.000000); + ctx.lineTo(175.000000,327.000000); + ctx.lineTo(179.000000,332.000000); + ctx.lineTo(183.000000,326.000000); + ctx.lineTo(184.000000,332.000000); + ctx.lineTo(189.000000,323.000000); + ctx.lineTo(190.000000,328.000000); + ctx.lineTo(194.000000,320.000000); + ctx.lineTo(194.000000,325.000000); + ctx.lineTo(199.000000,316.000000); + ctx.lineTo(201.000000,320.000000); + ctx.lineTo(204.000000,313.000000); + ctx.lineTo(206.000000,316.000000); + ctx.lineTo(208.000000,310.000000); + ctx.lineTo(211.000000,305.000000); + ctx.lineTo(219.000000,298.000000); + ctx.lineTo(226.000000,288.000000); + ctx.lineTo(229.000000,279.000000); + ctx.lineTo(228.000000,266.000000); + ctx.lineTo(224.000000,259.000000); + ctx.lineTo(217.000000,253.000000); + ctx.lineTo(212.000000,250.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(151.000000,205.000000); + ctx.lineTo(151.000000,238.000000); + ctx.lineTo(149.000000,252.000000); + ctx.lineTo(141.000000,268.000000); + ctx.lineTo(128.000000,282.000000); + ctx.lineTo(121.000000,301.000000); + ctx.lineTo(130.000000,300.000000); + ctx.lineTo(126.000000,313.000000); + ctx.lineTo(118.000000,324.000000); + ctx.lineTo(116.000000,337.000000); + ctx.lineTo(120.000000,346.000000); + ctx.lineTo(133.000000,352.000000); + ctx.lineTo(133.000000,340.000000); + ctx.lineTo(137.000000,333.000000); + ctx.lineTo(145.000000,329.000000); + ctx.lineTo(156.000000,327.000000); + ctx.lineTo(153.000000,319.000000); + ctx.lineTo(153.000000,291.000000); + ctx.lineTo(157.000000,271.000000); + ctx.lineTo(170.000000,259.000000); + ctx.lineTo(178.000000,277.000000); + ctx.lineTo(193.000000,250.000000); + ctx.lineTo(174.000000,216.000000); + ctx.lineTo(151.000000,205.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,127.000000); + ctx.lineTo(90.000000,142.000000); + ctx.lineTo(95.000000,155.000000); + ctx.lineTo(108.000000,164.000000); + ctx.lineTo(125.000000,167.000000); + ctx.lineTo(139.000000,175.000000); + ctx.lineTo(150.000000,206.000000); + ctx.lineTo(152.000000,191.000000); + ctx.lineTo(141.000000,140.000000); + ctx.lineTo(121.000000,148.000000); + ctx.lineTo(100.000000,136.000000); + ctx.lineTo(78.000000,127.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(21.000000,58.000000); + ctx.lineTo(35.000000,63.000000); + ctx.lineTo(38.000000,68.000000); + ctx.lineTo(32.000000,69.000000); + ctx.lineTo(42.000000,74.000000); + ctx.lineTo(40.000000,79.000000); + ctx.lineTo(47.000000,80.000000); + ctx.lineTo(54.000000,83.000000); + ctx.lineTo(45.000000,94.000000); + ctx.lineTo(34.000000,81.000000); + ctx.lineTo(32.000000,73.000000); + ctx.lineTo(24.000000,66.000000); + ctx.lineTo(21.000000,58.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(71.000000,34.000000); + ctx.lineTo(67.000000,34.000000); + ctx.lineTo(66.000000,27.000000); + ctx.lineTo(59.000000,24.000000); + ctx.lineTo(54.000000,17.000000); + ctx.lineTo(48.000000,17.000000); + ctx.lineTo(39.000000,22.000000); + ctx.lineTo(30.000000,26.000000); + ctx.lineTo(28.000000,31.000000); + ctx.lineTo(31.000000,39.000000); + ctx.lineTo(38.000000,46.000000); + ctx.lineTo(29.000000,45.000000); + ctx.lineTo(36.000000,54.000000); + ctx.lineTo(41.000000,61.000000); + ctx.lineTo(41.000000,70.000000); + ctx.lineTo(50.000000,69.000000); + ctx.lineTo(54.000000,71.000000); + ctx.lineTo(55.000000,58.000000); + ctx.lineTo(67.000000,52.000000); + ctx.lineTo(76.000000,43.000000); + ctx.lineTo(76.000000,39.000000); + ctx.lineTo(68.000000,44.000000); + ctx.lineTo(71.000000,34.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(139.000000,74.000000); + ctx.lineTo(141.000000,83.000000); + ctx.lineTo(143.000000,89.000000); + ctx.lineTo(144.000000,104.000000); + ctx.lineTo(148.000000,104.000000); + ctx.lineTo(155.000000,106.000000); + ctx.lineTo(154.000000,86.000000); + ctx.lineTo(157.000000,77.000000); + ctx.lineTo(155.000000,72.000000); + ctx.lineTo(150.000000,77.000000); + ctx.lineTo(144.000000,77.000000); + ctx.lineTo(139.000000,74.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(105.000000,44.000000); + ctx.lineTo(102.000000,53.000000); + ctx.lineTo(108.000000,58.000000); + ctx.lineTo(111.000000,62.000000); + ctx.lineTo(112.000000,55.000000); + ctx.lineTo(105.000000,44.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(141.000000,48.000000); + ctx.lineTo(141.000000,54.000000); + ctx.lineTo(144.000000,58.000000); + ctx.lineTo(139.000000,62.000000); + ctx.lineTo(137.000000,66.000000); + ctx.lineTo(136.000000,59.000000); + ctx.lineTo(137.000000,52.000000); + ctx.lineTo(141.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(98.000000,135.000000); + ctx.lineTo(104.000000,130.000000); + ctx.lineTo(105.000000,134.000000); + ctx.lineTo(108.000000,132.000000); + ctx.lineTo(108.000000,135.000000); + ctx.lineTo(112.000000,134.000000); + ctx.lineTo(113.000000,137.000000); + ctx.lineTo(116.000000,136.000000); + ctx.lineTo(116.000000,139.000000); + ctx.lineTo(119.000000,139.000000); + ctx.lineTo(124.000000,141.000000); + ctx.lineTo(128.000000,140.000000); + ctx.lineTo(133.000000,138.000000); + ctx.lineTo(140.000000,133.000000); + ctx.lineTo(139.000000,140.000000); + ctx.lineTo(126.000000,146.000000); + ctx.lineTo(104.000000,144.000000); + ctx.lineTo(98.000000,135.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(97.000000,116.000000); + ctx.lineTo(103.000000,119.000000); + ctx.lineTo(103.000000,116.000000); + ctx.lineTo(111.000000,118.000000); + ctx.lineTo(116.000000,117.000000); + ctx.lineTo(122.000000,114.000000); + ctx.lineTo(127.000000,107.000000); + ctx.lineTo(135.000000,111.000000); + ctx.lineTo(142.000000,107.000000); + ctx.lineTo(141.000000,114.000000); + ctx.lineTo(145.000000,118.000000); + ctx.lineTo(149.000000,121.000000); + ctx.lineTo(145.000000,125.000000); + ctx.lineTo(140.000000,124.000000); + ctx.lineTo(127.000000,121.000000); + ctx.lineTo(113.000000,125.000000); + ctx.lineTo(100.000000,124.000000); + ctx.lineTo(97.000000,116.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(147.000000,33.000000); + ctx.lineTo(152.000000,35.000000); + ctx.lineTo(157.000000,34.000000); + ctx.lineTo(153.000000,31.000000); + ctx.lineTo(160.000000,31.000000); + ctx.lineTo(156.000000,28.000000); + ctx.lineTo(161.000000,28.000000); + ctx.lineTo(159.000000,24.000000); + ctx.lineTo(163.000000,25.000000); + ctx.lineTo(163.000000,21.000000); + ctx.lineTo(165.000000,22.000000); + ctx.lineTo(170.000000,23.000000); + ctx.lineTo(167.000000,17.000000); + ctx.lineTo(172.000000,21.000000); + ctx.lineTo(174.000000,18.000000); + ctx.lineTo(175.000000,23.000000); + ctx.lineTo(176.000000,22.000000); + ctx.lineTo(177.000000,28.000000); + ctx.lineTo(177.000000,33.000000); + ctx.lineTo(174.000000,37.000000); + ctx.lineTo(176.000000,39.000000); + ctx.lineTo(174.000000,44.000000); + ctx.lineTo(171.000000,49.000000); + ctx.lineTo(168.000000,53.000000); + ctx.lineTo(164.000000,57.000000); + ctx.lineTo(159.000000,68.000000); + ctx.lineTo(156.000000,70.000000); + ctx.lineTo(154.000000,60.000000); + ctx.lineTo(150.000000,51.000000); + ctx.lineTo(146.000000,43.000000); + ctx.lineTo(144.000000,35.000000); + ctx.lineTo(147.000000,33.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(85.000000,72.000000); + ctx.lineTo(89.000000,74.000000); + ctx.lineTo(93.000000,75.000000); + ctx.lineTo(100.000000,76.000000); + ctx.lineTo(105.000000,75.000000); + ctx.lineTo(102.000000,79.000000); + ctx.lineTo(94.000000,79.000000); + ctx.lineTo(88.000000,76.000000); + ctx.lineTo(85.000000,72.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(86.000000,214.000000); + ctx.lineTo(79.000000,221.000000); + ctx.lineTo(76.000000,232.000000); + ctx.lineTo(82.000000,225.000000); + ctx.lineTo(78.000000,239.000000); + ctx.lineTo(82.000000,234.000000); + ctx.lineTo(78.000000,245.000000); + ctx.lineTo(81.000000,243.000000); + ctx.lineTo(79.000000,255.000000); + ctx.lineTo(84.000000,250.000000); + ctx.lineTo(84.000000,267.000000); + ctx.lineTo(87.000000,254.000000); + ctx.lineTo(90.000000,271.000000); + ctx.lineTo(90.000000,257.000000); + ctx.lineTo(95.000000,271.000000); + ctx.lineTo(93.000000,256.000000); + ctx.lineTo(95.000000,249.000000); + ctx.lineTo(92.000000,252.000000); + ctx.lineTo(93.000000,243.000000); + ctx.lineTo(89.000000,253.000000); + ctx.lineTo(89.000000,241.000000); + ctx.lineTo(86.000000,250.000000); + ctx.lineTo(87.000000,236.000000); + ctx.lineTo(83.000000,245.000000); + ctx.lineTo(87.000000,231.000000); + ctx.lineTo(82.000000,231.000000); + ctx.lineTo(90.000000,219.000000); + ctx.lineTo(84.000000,221.000000); + ctx.lineTo(86.000000,214.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffcc7f'; +ctx.beginPath(); +ctx.moveTo(93.000000,68.000000); + ctx.lineTo(96.000000,72.000000); + ctx.lineTo(100.000000,73.000000); + ctx.lineTo(106.000000,72.000000); + ctx.lineTo(108.000000,66.000000); + ctx.lineTo(105.000000,63.000000); + ctx.lineTo(100.000000,62.000000); + ctx.lineTo(93.000000,68.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffcc7f'; +ctx.beginPath(); +ctx.moveTo(144.000000,64.000000); + ctx.lineTo(142.000000,68.000000); + ctx.lineTo(142.000000,73.000000); + ctx.lineTo(146.000000,74.000000); + ctx.lineTo(150.000000,73.000000); + ctx.lineTo(154.000000,64.000000); + ctx.lineTo(149.000000,62.000000); + ctx.lineTo(144.000000,64.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(57.000000,91.000000); + ctx.lineTo(42.000000,111.000000); + ctx.lineTo(52.000000,105.000000); + ctx.lineTo(41.000000,117.000000); + ctx.lineTo(53.000000,112.000000); + ctx.lineTo(46.000000,120.000000); + ctx.lineTo(53.000000,116.000000); + ctx.lineTo(50.000000,124.000000); + ctx.lineTo(57.000000,119.000000); + ctx.lineTo(55.000000,127.000000); + ctx.lineTo(61.000000,122.000000); + ctx.lineTo(60.000000,130.000000); + ctx.lineTo(67.000000,126.000000); + ctx.lineTo(66.000000,134.000000); + ctx.lineTo(71.000000,129.000000); + ctx.lineTo(72.000000,136.000000); + ctx.lineTo(77.000000,130.000000); + ctx.lineTo(76.000000,137.000000); + ctx.lineTo(80.000000,133.000000); + ctx.lineTo(82.000000,138.000000); + ctx.lineTo(86.000000,135.000000); + ctx.lineTo(96.000000,135.000000); + ctx.lineTo(94.000000,129.000000); + ctx.lineTo(86.000000,124.000000); + ctx.lineTo(83.000000,117.000000); + ctx.lineTo(77.000000,123.000000); + ctx.lineTo(79.000000,117.000000); + ctx.lineTo(73.000000,120.000000); + ctx.lineTo(75.000000,112.000000); + ctx.lineTo(68.000000,116.000000); + ctx.lineTo(71.000000,111.000000); + ctx.lineTo(65.000000,114.000000); + ctx.lineTo(69.000000,107.000000); + ctx.lineTo(63.000000,110.000000); + ctx.lineTo(68.000000,102.000000); + ctx.lineTo(61.000000,107.000000); + ctx.lineTo(66.000000,98.000000); + ctx.lineTo(61.000000,103.000000); + ctx.lineTo(63.000000,97.000000); + ctx.lineTo(57.000000,99.000000); + ctx.lineTo(57.000000,91.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(83.000000,79.000000); + ctx.lineTo(76.000000,79.000000); + ctx.lineTo(67.000000,82.000000); + ctx.lineTo(75.000000,83.000000); + ctx.lineTo(65.000000,88.000000); + ctx.lineTo(76.000000,87.000000); + ctx.lineTo(65.000000,92.000000); + ctx.lineTo(76.000000,91.000000); + ctx.lineTo(68.000000,96.000000); + ctx.lineTo(77.000000,95.000000); + ctx.lineTo(70.000000,99.000000); + ctx.lineTo(80.000000,98.000000); + ctx.lineTo(72.000000,104.000000); + ctx.lineTo(80.000000,102.000000); + ctx.lineTo(76.000000,108.000000); + ctx.lineTo(85.000000,103.000000); + ctx.lineTo(92.000000,101.000000); + ctx.lineTo(87.000000,98.000000); + ctx.lineTo(93.000000,96.000000); + ctx.lineTo(86.000000,94.000000); + ctx.lineTo(91.000000,93.000000); + ctx.lineTo(85.000000,91.000000); + ctx.lineTo(93.000000,89.000000); + ctx.lineTo(99.000000,89.000000); + ctx.lineTo(105.000000,93.000000); + ctx.lineTo(107.000000,85.000000); + ctx.lineTo(102.000000,82.000000); + ctx.lineTo(92.000000,80.000000); + ctx.lineTo(83.000000,79.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(109.000000,77.000000); + ctx.lineTo(111.000000,83.000000); + ctx.lineTo(109.000000,89.000000); + ctx.lineTo(113.000000,94.000000); + ctx.lineTo(117.000000,90.000000); + ctx.lineTo(117.000000,81.000000); + ctx.lineTo(114.000000,78.000000); + ctx.lineTo(109.000000,77.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(122.000000,128.000000); + ctx.lineTo(127.000000,126.000000); + ctx.lineTo(134.000000,127.000000); + ctx.lineTo(136.000000,129.000000); + ctx.lineTo(134.000000,130.000000); + ctx.lineTo(130.000000,128.000000); + ctx.lineTo(124.000000,129.000000); + ctx.lineTo(122.000000,128.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,27.000000); + ctx.lineTo(82.000000,32.000000); + ctx.lineTo(80.000000,33.000000); + ctx.lineTo(82.000000,36.000000); + ctx.lineTo(78.000000,37.000000); + ctx.lineTo(82.000000,40.000000); + ctx.lineTo(78.000000,42.000000); + ctx.lineTo(81.000000,46.000000); + ctx.lineTo(76.000000,47.000000); + ctx.lineTo(78.000000,49.000000); + ctx.lineTo(74.000000,50.000000); + ctx.lineTo(82.000000,52.000000); + ctx.lineTo(87.000000,50.000000); + ctx.lineTo(83.000000,48.000000); + ctx.lineTo(91.000000,46.000000); + ctx.lineTo(86.000000,45.000000); + ctx.lineTo(91.000000,42.000000); + ctx.lineTo(88.000000,40.000000); + ctx.lineTo(92.000000,37.000000); + ctx.lineTo(86.000000,34.000000); + ctx.lineTo(90.000000,31.000000); + ctx.lineTo(86.000000,29.000000); + ctx.lineTo(89.000000,26.000000); + ctx.lineTo(78.000000,27.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(82.000000,17.000000); + ctx.lineTo(92.000000,20.000000); + ctx.lineTo(79.000000,21.000000); + ctx.lineTo(90.000000,25.000000); + ctx.lineTo(81.000000,25.000000); + ctx.lineTo(94.000000,28.000000); + ctx.lineTo(93.000000,26.000000); + ctx.lineTo(101.000000,30.000000); + ctx.lineTo(101.000000,26.000000); + ctx.lineTo(107.000000,33.000000); + ctx.lineTo(108.000000,28.000000); + ctx.lineTo(111.000000,40.000000); + ctx.lineTo(113.000000,34.000000); + ctx.lineTo(115.000000,45.000000); + ctx.lineTo(117.000000,39.000000); + ctx.lineTo(119.000000,54.000000); + ctx.lineTo(121.000000,46.000000); + ctx.lineTo(124.000000,58.000000); + ctx.lineTo(126.000000,47.000000); + ctx.lineTo(129.000000,59.000000); + ctx.lineTo(130.000000,49.000000); + ctx.lineTo(134.000000,58.000000); + ctx.lineTo(133.000000,44.000000); + ctx.lineTo(137.000000,48.000000); + ctx.lineTo(133.000000,37.000000); + ctx.lineTo(137.000000,40.000000); + ctx.lineTo(133.000000,32.000000); + ctx.lineTo(126.000000,20.000000); + ctx.lineTo(135.000000,26.000000); + ctx.lineTo(132.000000,19.000000); + ctx.lineTo(138.000000,23.000000); + ctx.lineTo(135.000000,17.000000); + ctx.lineTo(142.000000,18.000000); + ctx.lineTo(132.000000,11.000000); + ctx.lineTo(116.000000,6.000000); + ctx.lineTo(94.000000,6.000000); + ctx.lineTo(78.000000,11.000000); + ctx.lineTo(92.000000,12.000000); + ctx.lineTo(80.000000,14.000000); + ctx.lineTo(90.000000,16.000000); + ctx.lineTo(82.000000,17.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(142.000000,234.000000); + ctx.lineTo(132.000000,227.000000); + ctx.lineTo(124.000000,223.000000); + ctx.lineTo(115.000000,220.000000); + ctx.lineTo(110.000000,225.000000); + ctx.lineTo(118.000000,224.000000); + ctx.lineTo(127.000000,229.000000); + ctx.lineTo(135.000000,236.000000); + ctx.lineTo(122.000000,234.000000); + ctx.lineTo(115.000000,237.000000); + ctx.lineTo(113.000000,242.000000); + ctx.lineTo(121.000000,238.000000); + ctx.lineTo(139.000000,243.000000); + ctx.lineTo(121.000000,245.000000); + ctx.lineTo(111.000000,254.000000); + ctx.lineTo(95.000000,254.000000); + ctx.lineTo(102.000000,244.000000); + ctx.lineTo(104.000000,235.000000); + ctx.lineTo(110.000000,229.000000); + ctx.lineTo(100.000000,231.000000); + ctx.lineTo(104.000000,224.000000); + ctx.lineTo(113.000000,216.000000); + ctx.lineTo(122.000000,215.000000); + ctx.lineTo(132.000000,217.000000); + ctx.lineTo(141.000000,224.000000); + ctx.lineTo(145.000000,230.000000); + ctx.lineTo(149.000000,240.000000); + ctx.lineTo(142.000000,234.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(115.000000,252.000000); + ctx.lineTo(125.000000,248.000000); + ctx.lineTo(137.000000,249.000000); + ctx.lineTo(143.000000,258.000000); + ctx.lineTo(134.000000,255.000000); + ctx.lineTo(125.000000,254.000000); + ctx.lineTo(115.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(114.000000,212.000000); + ctx.lineTo(130.000000,213.000000); + ctx.lineTo(140.000000,219.000000); + ctx.lineTo(147.000000,225.000000); + ctx.lineTo(144.000000,214.000000); + ctx.lineTo(137.000000,209.000000); + ctx.lineTo(128.000000,207.000000); + ctx.lineTo(114.000000,212.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(102.000000,263.000000); + ctx.lineTo(108.000000,258.000000); + ctx.lineTo(117.000000,257.000000); + ctx.lineTo(131.000000,258.000000); + ctx.lineTo(116.000000,260.000000); + ctx.lineTo(109.000000,265.000000); + ctx.lineTo(102.000000,263.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(51.000000,241.000000); + ctx.lineTo(35.000000,224.000000); + ctx.lineTo(40.000000,238.000000); + ctx.lineTo(23.000000,224.000000); + ctx.lineTo(31.000000,242.000000); + ctx.lineTo(19.000000,239.000000); + ctx.lineTo(28.000000,247.000000); + ctx.lineTo(17.000000,246.000000); + ctx.lineTo(25.000000,250.000000); + ctx.lineTo(37.000000,254.000000); + ctx.lineTo(39.000000,263.000000); + ctx.lineTo(44.000000,271.000000); + ctx.lineTo(47.000000,294.000000); + ctx.lineTo(48.000000,317.000000); + ctx.lineTo(51.000000,328.000000); + ctx.lineTo(60.000000,351.000000); + ctx.lineTo(60.000000,323.000000); + ctx.lineTo(53.000000,262.000000); + ctx.lineTo(47.000000,246.000000); + ctx.lineTo(51.000000,241.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(2.000000,364.000000); + ctx.lineTo(9.000000,367.000000); + ctx.lineTo(14.000000,366.000000); + ctx.lineTo(18.000000,355.000000); + ctx.lineTo(20.000000,364.000000); + ctx.lineTo(26.000000,366.000000); + ctx.lineTo(31.000000,357.000000); + ctx.lineTo(35.000000,364.000000); + ctx.lineTo(39.000000,364.000000); + ctx.lineTo(42.000000,357.000000); + ctx.lineTo(47.000000,363.000000); + ctx.lineTo(53.000000,360.000000); + ctx.lineTo(59.000000,357.000000); + ctx.lineTo(54.000000,369.000000); + ctx.lineTo(7.000000,373.000000); + ctx.lineTo(2.000000,364.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(7.000000,349.000000); + ctx.lineTo(19.000000,345.000000); + ctx.lineTo(25.000000,339.000000); + ctx.lineTo(18.000000,341.000000); + ctx.lineTo(23.000000,333.000000); + ctx.lineTo(28.000000,326.000000); + ctx.lineTo(23.000000,326.000000); + ctx.lineTo(27.000000,320.000000); + ctx.lineTo(23.000000,316.000000); + ctx.lineTo(25.000000,311.000000); + ctx.lineTo(20.000000,298.000000); + ctx.lineTo(15.000000,277.000000); + ctx.lineTo(12.000000,264.000000); + ctx.lineTo(9.000000,249.000000); + ctx.lineTo(10.000000,223.000000); + ctx.lineTo(3.000000,248.000000); + ctx.lineTo(5.000000,261.000000); + ctx.lineTo(15.000000,307.000000); + ctx.lineTo(17.000000,326.000000); + ctx.lineTo(11.000000,343.000000); + ctx.lineTo(7.000000,349.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(11.000000,226.000000); + ctx.lineTo(15.000000,231.000000); + ctx.lineTo(25.000000,236.000000); + ctx.lineTo(18.000000,227.000000); + ctx.lineTo(11.000000,226.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(13.000000,214.000000); + ctx.lineTo(19.000000,217.000000); + ctx.lineTo(32.000000,227.000000); + ctx.lineTo(23.000000,214.000000); + ctx.lineTo(16.000000,208.000000); + ctx.lineTo(15.000000,190.000000); + ctx.lineTo(24.000000,148.000000); + ctx.lineTo(31.000000,121.000000); + ctx.lineTo(24.000000,137.000000); + ctx.lineTo(14.000000,170.000000); + ctx.lineTo(8.000000,189.000000); + ctx.lineTo(13.000000,214.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(202.000000,254.000000); + ctx.lineTo(195.000000,258.000000); + ctx.lineTo(199.000000,260.000000); + ctx.lineTo(193.000000,263.000000); + ctx.lineTo(197.000000,263.000000); + ctx.lineTo(190.000000,268.000000); + ctx.lineTo(196.000000,268.000000); + ctx.lineTo(191.000000,273.000000); + ctx.lineTo(188.000000,282.000000); + ctx.lineTo(200.000000,272.000000); + ctx.lineTo(194.000000,272.000000); + ctx.lineTo(201.000000,266.000000); + ctx.lineTo(197.000000,265.000000); + ctx.lineTo(204.000000,262.000000); + ctx.lineTo(200.000000,258.000000); + ctx.lineTo(204.000000,256.000000); + ctx.lineTo(202.000000,254.000000); +ctx.fill(); + + + + +ctx.fillStyle='#845433'; +ctx.beginPath(); +ctx.moveTo(151.000000,213.000000); + ctx.lineTo(165.000000,212.000000); + ctx.lineTo(179.000000,225.000000); + ctx.lineTo(189.000000,246.000000); + ctx.lineTo(187.000000,262.000000); + ctx.lineTo(179.000000,275.000000); + ctx.lineTo(176.000000,263.000000); + ctx.lineTo(177.000000,247.000000); + ctx.lineTo(171.000000,233.000000); + ctx.lineTo(163.000000,230.000000); + ctx.lineTo(165.000000,251.000000); + ctx.lineTo(157.000000,264.000000); + ctx.lineTo(146.000000,298.000000); + ctx.lineTo(145.000000,321.000000); + ctx.lineTo(133.000000,326.000000); + ctx.lineTo(143.000000,285.000000); + ctx.lineTo(154.000000,260.000000); + ctx.lineTo(153.000000,240.000000); + ctx.lineTo(151.000000,213.000000); +ctx.fill(); + + + + +ctx.fillStyle='#845433'; +ctx.beginPath(); +ctx.moveTo(91.000000,132.000000); + ctx.lineTo(95.000000,145.000000); + ctx.lineTo(97.000000,154.000000); + ctx.lineTo(104.000000,148.000000); + ctx.lineTo(107.000000,155.000000); + ctx.lineTo(109.000000,150.000000); + ctx.lineTo(111.000000,158.000000); + ctx.lineTo(115.000000,152.000000); + ctx.lineTo(118.000000,159.000000); + ctx.lineTo(120.000000,153.000000); + ctx.lineTo(125.000000,161.000000); + ctx.lineTo(126.000000,155.000000); + ctx.lineTo(133.000000,164.000000); + ctx.lineTo(132.000000,154.000000); + ctx.lineTo(137.000000,163.000000); + ctx.lineTo(137.000000,152.000000); + ctx.lineTo(142.000000,163.000000); + ctx.lineTo(147.000000,186.000000); + ctx.lineTo(152.000000,192.000000); + ctx.lineTo(148.000000,167.000000); + ctx.lineTo(141.000000,143.000000); + ctx.lineTo(124.000000,145.000000); + ctx.lineTo(105.000000,143.000000); + ctx.lineTo(91.000000,132.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(31.000000,57.000000); + ctx.lineTo(23.000000,52.000000); + ctx.lineTo(26.000000,51.000000); + ctx.lineTo(20.000000,44.000000); + ctx.lineTo(23.000000,42.000000); + ctx.lineTo(21.000000,36.000000); + ctx.lineTo(22.000000,29.000000); + ctx.lineTo(25.000000,23.000000); + ctx.lineTo(24.000000,32.000000); + ctx.lineTo(30.000000,43.000000); + ctx.lineTo(26.000000,41.000000); + ctx.lineTo(30.000000,50.000000); + ctx.lineTo(26.000000,48.000000); + ctx.lineTo(31.000000,57.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(147.000000,21.000000); + ctx.lineTo(149.000000,28.000000); + ctx.lineTo(155.000000,21.000000); + ctx.lineTo(161.000000,16.000000); + ctx.lineTo(167.000000,14.000000); + ctx.lineTo(175.000000,15.000000); + ctx.lineTo(173.000000,11.000000); + ctx.lineTo(161.000000,9.000000); + ctx.lineTo(147.000000,21.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(181.000000,39.000000); + ctx.lineTo(175.000000,51.000000); + ctx.lineTo(169.000000,57.000000); + ctx.lineTo(171.000000,65.000000); + ctx.lineTo(165.000000,68.000000); + ctx.lineTo(165.000000,75.000000); + ctx.lineTo(160.000000,76.000000); + ctx.lineTo(162.000000,91.000000); + ctx.lineTo(171.000000,71.000000); + ctx.lineTo(180.000000,51.000000); + ctx.lineTo(181.000000,39.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(132.000000,346.000000); + ctx.lineTo(139.000000,348.000000); + ctx.lineTo(141.000000,346.000000); + ctx.lineTo(142.000000,341.000000); + ctx.lineTo(147.000000,342.000000); + ctx.lineTo(143.000000,355.000000); + ctx.lineTo(133.000000,350.000000); + ctx.lineTo(132.000000,346.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(146.000000,355.000000); + ctx.lineTo(151.000000,352.000000); + ctx.lineTo(155.000000,348.000000); + ctx.lineTo(157.000000,343.000000); + ctx.lineTo(160.000000,349.000000); + ctx.lineTo(151.000000,356.000000); + ctx.lineTo(147.000000,357.000000); + ctx.lineTo(146.000000,355.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(99.000000,266.000000); + ctx.lineTo(100.000000,281.000000); + ctx.lineTo(94.000000,305.000000); + ctx.lineTo(86.000000,322.000000); + ctx.lineTo(78.000000,332.000000); + ctx.lineTo(72.000000,346.000000); + ctx.lineTo(73.000000,331.000000); + ctx.lineTo(91.000000,291.000000); + ctx.lineTo(99.000000,266.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(20.000000,347.000000); + ctx.lineTo(32.000000,342.000000); + ctx.lineTo(45.000000,340.000000); + ctx.lineTo(54.000000,345.000000); + ctx.lineTo(45.000000,350.000000); + ctx.lineTo(42.000000,353.000000); + ctx.lineTo(38.000000,350.000000); + ctx.lineTo(31.000000,353.000000); + ctx.lineTo(29.000000,356.000000); + ctx.lineTo(23.000000,350.000000); + ctx.lineTo(19.000000,353.000000); + ctx.lineTo(15.000000,349.000000); + ctx.lineTo(20.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(78.000000,344.000000); + ctx.lineTo(86.000000,344.000000); + ctx.lineTo(92.000000,349.000000); + ctx.lineTo(88.000000,358.000000); + ctx.lineTo(84.000000,352.000000); + ctx.lineTo(78.000000,344.000000); +ctx.fill(); + + + + +ctx.fillStyle='#9c826b'; +ctx.beginPath(); +ctx.moveTo(93.000000,347.000000); + ctx.lineTo(104.000000,344.000000); + ctx.lineTo(117.000000,345.000000); + ctx.lineTo(124.000000,354.000000); + ctx.lineTo(121.000000,357.000000); + ctx.lineTo(116.000000,351.000000); + ctx.lineTo(112.000000,351.000000); + ctx.lineTo(108.000000,355.000000); + ctx.lineTo(102.000000,351.000000); + ctx.lineTo(93.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(105.000000,12.000000); + ctx.lineTo(111.000000,18.000000); + ctx.lineTo(113.000000,24.000000); + ctx.lineTo(113.000000,29.000000); + ctx.lineTo(119.000000,34.000000); + ctx.lineTo(116.000000,23.000000); + ctx.lineTo(112.000000,16.000000); + ctx.lineTo(105.000000,12.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(122.000000,27.000000); + ctx.lineTo(125.000000,34.000000); + ctx.lineTo(127.000000,43.000000); + ctx.lineTo(128.000000,34.000000); + ctx.lineTo(125.000000,29.000000); + ctx.lineTo(122.000000,27.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(115.000000,13.000000); + ctx.lineTo(122.000000,19.000000); + ctx.lineTo(122.000000,15.000000); + ctx.lineTo(113.000000,10.000000); + ctx.lineTo(115.000000,13.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(116.000000,172.000000); + ctx.lineTo(107.000000,182.000000); + ctx.lineTo(98.000000,193.000000); + ctx.lineTo(98.000000,183.000000); + ctx.lineTo(90.000000,199.000000); + ctx.lineTo(89.000000,189.000000); + ctx.lineTo(84.000000,207.000000); + ctx.lineTo(88.000000,206.000000); + ctx.lineTo(87.000000,215.000000); + ctx.lineTo(95.000000,206.000000); + ctx.lineTo(93.000000,219.000000); + ctx.lineTo(91.000000,230.000000); + ctx.lineTo(98.000000,216.000000); + ctx.lineTo(97.000000,226.000000); + ctx.lineTo(104.000000,214.000000); + ctx.lineTo(112.000000,209.000000); + ctx.lineTo(104.000000,208.000000); + ctx.lineTo(113.000000,202.000000); + ctx.lineTo(126.000000,200.000000); + ctx.lineTo(139.000000,207.000000); + ctx.lineTo(132.000000,198.000000); + ctx.lineTo(142.000000,203.000000); + ctx.lineTo(134.000000,192.000000); + ctx.lineTo(142.000000,195.000000); + ctx.lineTo(134.000000,187.000000); + ctx.lineTo(140.000000,185.000000); + ctx.lineTo(130.000000,181.000000); + ctx.lineTo(136.000000,177.000000); + ctx.lineTo(126.000000,177.000000); + ctx.lineTo(125.000000,171.000000); + ctx.lineTo(116.000000,180.000000); + ctx.lineTo(116.000000,172.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(74.000000,220.000000); + ctx.lineTo(67.000000,230.000000); + ctx.lineTo(67.000000,221.000000); + ctx.lineTo(59.000000,235.000000); + ctx.lineTo(63.000000,233.000000); + ctx.lineTo(60.000000,248.000000); + ctx.lineTo(70.000000,232.000000); + ctx.lineTo(65.000000,249.000000); + ctx.lineTo(71.000000,243.000000); + ctx.lineTo(67.000000,256.000000); + ctx.lineTo(73.000000,250.000000); + ctx.lineTo(69.000000,262.000000); + ctx.lineTo(73.000000,259.000000); + ctx.lineTo(71.000000,267.000000); + ctx.lineTo(76.000000,262.000000); + ctx.lineTo(72.000000,271.000000); + ctx.lineTo(78.000000,270.000000); + ctx.lineTo(76.000000,275.000000); + ctx.lineTo(82.000000,274.000000); + ctx.lineTo(78.000000,290.000000); + ctx.lineTo(86.000000,279.000000); + ctx.lineTo(86.000000,289.000000); + ctx.lineTo(92.000000,274.000000); + ctx.lineTo(88.000000,275.000000); + ctx.lineTo(87.000000,264.000000); + ctx.lineTo(82.000000,270.000000); + ctx.lineTo(82.000000,258.000000); + ctx.lineTo(77.000000,257.000000); + ctx.lineTo(78.000000,247.000000); + ctx.lineTo(73.000000,246.000000); + ctx.lineTo(77.000000,233.000000); + ctx.lineTo(72.000000,236.000000); + ctx.lineTo(74.000000,220.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(133.000000,230.000000); + ctx.lineTo(147.000000,242.000000); + ctx.lineTo(148.000000,250.000000); + ctx.lineTo(145.000000,254.000000); + ctx.lineTo(138.000000,247.000000); + ctx.lineTo(129.000000,246.000000); + ctx.lineTo(142.000000,245.000000); + ctx.lineTo(138.000000,241.000000); + ctx.lineTo(128.000000,237.000000); + ctx.lineTo(137.000000,238.000000); + ctx.lineTo(133.000000,230.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(133.000000,261.000000); + ctx.lineTo(125.000000,261.000000); + ctx.lineTo(116.000000,263.000000); + ctx.lineTo(111.000000,267.000000); + ctx.lineTo(125.000000,265.000000); + ctx.lineTo(133.000000,261.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(121.000000,271.000000); + ctx.lineTo(109.000000,273.000000); + ctx.lineTo(103.000000,279.000000); + ctx.lineTo(99.000000,305.000000); + ctx.lineTo(92.000000,316.000000); + ctx.lineTo(85.000000,327.000000); + ctx.lineTo(83.000000,335.000000); + ctx.lineTo(89.000000,340.000000); + ctx.lineTo(97.000000,341.000000); + ctx.lineTo(94.000000,336.000000); + ctx.lineTo(101.000000,336.000000); + ctx.lineTo(96.000000,331.000000); + ctx.lineTo(103.000000,330.000000); + ctx.lineTo(97.000000,327.000000); + ctx.lineTo(108.000000,325.000000); + ctx.lineTo(99.000000,322.000000); + ctx.lineTo(109.000000,321.000000); + ctx.lineTo(100.000000,318.000000); + ctx.lineTo(110.000000,317.000000); + ctx.lineTo(105.000000,314.000000); + ctx.lineTo(110.000000,312.000000); + ctx.lineTo(107.000000,310.000000); + ctx.lineTo(113.000000,308.000000); + ctx.lineTo(105.000000,306.000000); + ctx.lineTo(114.000000,303.000000); + ctx.lineTo(105.000000,301.000000); + ctx.lineTo(115.000000,298.000000); + ctx.lineTo(107.000000,295.000000); + ctx.lineTo(115.000000,294.000000); + ctx.lineTo(108.000000,293.000000); + ctx.lineTo(117.000000,291.000000); + ctx.lineTo(109.000000,289.000000); + ctx.lineTo(117.000000,286.000000); + ctx.lineTo(109.000000,286.000000); + ctx.lineTo(118.000000,283.000000); + ctx.lineTo(112.000000,281.000000); + ctx.lineTo(118.000000,279.000000); + ctx.lineTo(114.000000,278.000000); + ctx.lineTo(119.000000,276.000000); + ctx.lineTo(115.000000,274.000000); + ctx.lineTo(121.000000,271.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(79.000000,364.000000); + ctx.lineTo(74.000000,359.000000); + ctx.lineTo(74.000000,353.000000); + ctx.lineTo(76.000000,347.000000); + ctx.lineTo(80.000000,351.000000); + ctx.lineTo(83.000000,356.000000); + ctx.lineTo(82.000000,360.000000); + ctx.lineTo(79.000000,364.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(91.000000,363.000000); + ctx.lineTo(93.000000,356.000000); + ctx.lineTo(97.000000,353.000000); + ctx.lineTo(103.000000,355.000000); + ctx.lineTo(105.000000,360.000000); + ctx.lineTo(103.000000,366.000000); + ctx.lineTo(99.000000,371.000000); + ctx.lineTo(94.000000,368.000000); + ctx.lineTo(91.000000,363.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(110.000000,355.000000); + ctx.lineTo(114.000000,353.000000); + ctx.lineTo(118.000000,357.000000); + ctx.lineTo(117.000000,363.000000); + ctx.lineTo(113.000000,369.000000); + ctx.lineTo(111.000000,362.000000); + ctx.lineTo(110.000000,355.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(126.000000,354.000000); + ctx.lineTo(123.000000,358.000000); + ctx.lineTo(124.000000,367.000000); + ctx.lineTo(126.000000,369.000000); + ctx.lineTo(129.000000,361.000000); + ctx.lineTo(129.000000,357.000000); + ctx.lineTo(126.000000,354.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(30.000000,154.000000); + ctx.lineTo(24.000000,166.000000); + ctx.lineTo(20.000000,182.000000); + ctx.lineTo(23.000000,194.000000); + ctx.lineTo(29.000000,208.000000); + ctx.lineTo(37.000000,218.000000); + ctx.lineTo(41.000000,210.000000); + ctx.lineTo(41.000000,223.000000); + ctx.lineTo(46.000000,214.000000); + ctx.lineTo(46.000000,227.000000); + ctx.lineTo(52.000000,216.000000); + ctx.lineTo(52.000000,227.000000); + ctx.lineTo(61.000000,216.000000); + ctx.lineTo(59.000000,225.000000); + ctx.lineTo(68.000000,213.000000); + ctx.lineTo(73.000000,219.000000); + ctx.lineTo(70.000000,207.000000); + ctx.lineTo(77.000000,212.000000); + ctx.lineTo(69.000000,200.000000); + ctx.lineTo(77.000000,202.000000); + ctx.lineTo(70.000000,194.000000); + ctx.lineTo(78.000000,197.000000); + ctx.lineTo(68.000000,187.000000); + ctx.lineTo(76.000000,182.000000); + ctx.lineTo(64.000000,182.000000); + ctx.lineTo(58.000000,175.000000); + ctx.lineTo(58.000000,185.000000); + ctx.lineTo(53.000000,177.000000); + ctx.lineTo(50.000000,186.000000); + ctx.lineTo(46.000000,171.000000); + ctx.lineTo(44.000000,182.000000); + ctx.lineTo(39.000000,167.000000); + ctx.lineTo(36.000000,172.000000); + ctx.lineTo(36.000000,162.000000); + ctx.lineTo(30.000000,166.000000); + ctx.lineTo(30.000000,154.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(44.000000,130.000000); + ctx.lineTo(41.000000,137.000000); + ctx.lineTo(45.000000,136.000000); + ctx.lineTo(43.000000,150.000000); + ctx.lineTo(48.000000,142.000000); + ctx.lineTo(48.000000,157.000000); + ctx.lineTo(53.000000,150.000000); + ctx.lineTo(52.000000,164.000000); + ctx.lineTo(60.000000,156.000000); + ctx.lineTo(61.000000,169.000000); + ctx.lineTo(64.000000,165.000000); + ctx.lineTo(66.000000,175.000000); + ctx.lineTo(70.000000,167.000000); + ctx.lineTo(74.000000,176.000000); + ctx.lineTo(77.000000,168.000000); + ctx.lineTo(80.000000,183.000000); + ctx.lineTo(85.000000,172.000000); + ctx.lineTo(90.000000,182.000000); + ctx.lineTo(93.000000,174.000000); + ctx.lineTo(98.000000,181.000000); + ctx.lineTo(99.000000,173.000000); + ctx.lineTo(104.000000,175.000000); + ctx.lineTo(105.000000,169.000000); + ctx.lineTo(114.000000,168.000000); + ctx.lineTo(102.000000,163.000000); + ctx.lineTo(95.000000,157.000000); + ctx.lineTo(94.000000,166.000000); + ctx.lineTo(90.000000,154.000000); + ctx.lineTo(87.000000,162.000000); + ctx.lineTo(82.000000,149.000000); + ctx.lineTo(75.000000,159.000000); + ctx.lineTo(72.000000,148.000000); + ctx.lineTo(68.000000,155.000000); + ctx.lineTo(67.000000,143.000000); + ctx.lineTo(62.000000,148.000000); + ctx.lineTo(62.000000,138.000000); + ctx.lineTo(58.000000,145.000000); + ctx.lineTo(56.000000,133.000000); + ctx.lineTo(52.000000,142.000000); + ctx.lineTo(52.000000,128.000000); + ctx.lineTo(49.000000,134.000000); + ctx.lineTo(47.000000,125.000000); + ctx.lineTo(44.000000,130.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(13.000000,216.000000); + ctx.lineTo(19.000000,219.000000); + ctx.lineTo(36.000000,231.000000); + ctx.lineTo(22.000000,223.000000); + ctx.lineTo(16.000000,222.000000); + ctx.lineTo(22.000000,227.000000); + ctx.lineTo(12.000000,224.000000); + ctx.lineTo(13.000000,220.000000); + ctx.lineTo(16.000000,220.000000); + ctx.lineTo(13.000000,216.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(10.000000,231.000000); + ctx.lineTo(14.000000,236.000000); + ctx.lineTo(25.000000,239.000000); + ctx.lineTo(27.000000,237.000000); + ctx.lineTo(19.000000,234.000000); + ctx.lineTo(10.000000,231.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(9.000000,245.000000); + ctx.lineTo(14.000000,242.000000); + ctx.lineTo(25.000000,245.000000); + ctx.lineTo(13.000000,245.000000); + ctx.lineTo(9.000000,245.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(33.000000,255.000000); + ctx.lineTo(26.000000,253.000000); + ctx.lineTo(18.000000,254.000000); + ctx.lineTo(25.000000,256.000000); + ctx.lineTo(18.000000,258.000000); + ctx.lineTo(27.000000,260.000000); + ctx.lineTo(18.000000,263.000000); + ctx.lineTo(27.000000,265.000000); + ctx.lineTo(19.000000,267.000000); + ctx.lineTo(29.000000,270.000000); + ctx.lineTo(21.000000,272.000000); + ctx.lineTo(29.000000,276.000000); + ctx.lineTo(21.000000,278.000000); + ctx.lineTo(30.000000,281.000000); + ctx.lineTo(22.000000,283.000000); + ctx.lineTo(31.000000,287.000000); + ctx.lineTo(24.000000,288.000000); + ctx.lineTo(32.000000,292.000000); + ctx.lineTo(23.000000,293.000000); + ctx.lineTo(34.000000,298.000000); + ctx.lineTo(26.000000,299.000000); + ctx.lineTo(37.000000,303.000000); + ctx.lineTo(32.000000,305.000000); + ctx.lineTo(39.000000,309.000000); + ctx.lineTo(33.000000,309.000000); + ctx.lineTo(39.000000,314.000000); + ctx.lineTo(34.000000,314.000000); + ctx.lineTo(40.000000,318.000000); + ctx.lineTo(34.000000,317.000000); + ctx.lineTo(40.000000,321.000000); + ctx.lineTo(34.000000,321.000000); + ctx.lineTo(41.000000,326.000000); + ctx.lineTo(33.000000,326.000000); + ctx.lineTo(40.000000,330.000000); + ctx.lineTo(33.000000,332.000000); + ctx.lineTo(39.000000,333.000000); + ctx.lineTo(33.000000,337.000000); + ctx.lineTo(42.000000,337.000000); + ctx.lineTo(54.000000,341.000000); + ctx.lineTo(49.000000,337.000000); + ctx.lineTo(52.000000,335.000000); + ctx.lineTo(47.000000,330.000000); + ctx.lineTo(50.000000,330.000000); + ctx.lineTo(45.000000,325.000000); + ctx.lineTo(49.000000,325.000000); + ctx.lineTo(45.000000,321.000000); + ctx.lineTo(48.000000,321.000000); + ctx.lineTo(45.000000,316.000000); + ctx.lineTo(46.000000,306.000000); + ctx.lineTo(45.000000,286.000000); + ctx.lineTo(43.000000,274.000000); + ctx.lineTo(36.000000,261.000000); + ctx.lineTo(33.000000,255.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(7.000000,358.000000); + ctx.lineTo(9.000000,351.000000); + ctx.lineTo(14.000000,351.000000); + ctx.lineTo(17.000000,359.000000); + ctx.lineTo(11.000000,364.000000); + ctx.lineTo(7.000000,358.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(44.000000,354.000000); + ctx.lineTo(49.000000,351.000000); + ctx.lineTo(52.000000,355.000000); + ctx.lineTo(49.000000,361.000000); + ctx.lineTo(44.000000,354.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(32.000000,357.000000); + ctx.lineTo(37.000000,353.000000); + ctx.lineTo(40.000000,358.000000); + ctx.lineTo(36.000000,361.000000); + ctx.lineTo(32.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(139.000000,334.000000); + ctx.lineTo(145.000000,330.000000); + ctx.lineTo(154.000000,330.000000); + ctx.lineTo(158.000000,334.000000); + ctx.lineTo(154.000000,341.000000); + ctx.lineTo(152.000000,348.000000); + ctx.lineTo(145.000000,350.000000); + ctx.lineTo(149.000000,340.000000); + ctx.lineTo(147.000000,336.000000); + ctx.lineTo(141.000000,339.000000); + ctx.lineTo(139.000000,345.000000); + ctx.lineTo(136.000000,342.000000); + ctx.lineTo(136.000000,339.000000); + ctx.lineTo(139.000000,334.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(208.000000,259.000000); + ctx.lineTo(215.000000,259.000000); + ctx.lineTo(212.000000,255.000000); + ctx.lineTo(220.000000,259.000000); + ctx.lineTo(224.000000,263.000000); + ctx.lineTo(225.000000,274.000000); + ctx.lineTo(224.000000,283.000000); + ctx.lineTo(220.000000,292.000000); + ctx.lineTo(208.000000,300.000000); + ctx.lineTo(206.000000,308.000000); + ctx.lineTo(203.000000,304.000000); + ctx.lineTo(199.000000,315.000000); + ctx.lineTo(197.000000,309.000000); + ctx.lineTo(195.000000,318.000000); + ctx.lineTo(193.000000,313.000000); + ctx.lineTo(190.000000,322.000000); + ctx.lineTo(190.000000,316.000000); + ctx.lineTo(185.000000,325.000000); + ctx.lineTo(182.000000,318.000000); + ctx.lineTo(180.000000,325.000000); + ctx.lineTo(172.000000,321.000000); + ctx.lineTo(178.000000,320.000000); + ctx.lineTo(176.000000,313.000000); + ctx.lineTo(186.000000,312.000000); + ctx.lineTo(180.000000,307.000000); + ctx.lineTo(188.000000,307.000000); + ctx.lineTo(184.000000,303.000000); + ctx.lineTo(191.000000,302.000000); + ctx.lineTo(186.000000,299.000000); + ctx.lineTo(195.000000,294.000000); + ctx.lineTo(187.000000,290.000000); + ctx.lineTo(197.000000,288.000000); + ctx.lineTo(192.000000,286.000000); + ctx.lineTo(201.000000,283.000000); + ctx.lineTo(194.000000,280.000000); + ctx.lineTo(203.000000,277.000000); + ctx.lineTo(198.000000,275.000000); + ctx.lineTo(207.000000,271.000000); + ctx.lineTo(200.000000,269.000000); + ctx.lineTo(209.000000,265.000000); + ctx.lineTo(204.000000,265.000000); + ctx.lineTo(212.000000,262.000000); + ctx.lineTo(208.000000,259.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(106.000000,126.000000); + ctx.lineTo(106.000000,131.000000); + ctx.lineTo(109.000000,132.000000); + ctx.lineTo(111.000000,134.000000); + ctx.lineTo(115.000000,132.000000); + ctx.lineTo(115.000000,135.000000); + ctx.lineTo(119.000000,133.000000); + ctx.lineTo(118.000000,137.000000); + ctx.lineTo(123.000000,137.000000); + ctx.lineTo(128.000000,137.000000); + ctx.lineTo(133.000000,134.000000); + ctx.lineTo(136.000000,130.000000); + ctx.lineTo(136.000000,127.000000); + ctx.lineTo(132.000000,124.000000); + ctx.lineTo(118.000000,128.000000); + ctx.lineTo(112.000000,128.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); + ctx.lineTo(106.000000,126.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(107.000000,114.000000); + ctx.lineTo(101.000000,110.000000); + ctx.lineTo(98.000000,102.000000); + ctx.lineTo(105.000000,97.000000); + ctx.lineTo(111.000000,98.000000); + ctx.lineTo(119.000000,102.000000); + ctx.lineTo(121.000000,108.000000); + ctx.lineTo(118.000000,112.000000); + ctx.lineTo(113.000000,115.000000); + ctx.lineTo(107.000000,114.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(148.000000,106.000000); + ctx.lineTo(145.000000,110.000000); + ctx.lineTo(146.000000,116.000000); + ctx.lineTo(150.000000,118.000000); + ctx.lineTo(152.000000,111.000000); + ctx.lineTo(151.000000,107.000000); + ctx.lineTo(148.000000,106.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(80.000000,55.000000); + ctx.lineTo(70.000000,52.000000); + ctx.lineTo(75.000000,58.000000); + ctx.lineTo(63.000000,57.000000); + ctx.lineTo(72.000000,61.000000); + ctx.lineTo(57.000000,61.000000); + ctx.lineTo(67.000000,66.000000); + ctx.lineTo(57.000000,67.000000); + ctx.lineTo(62.000000,69.000000); + ctx.lineTo(54.000000,71.000000); + ctx.lineTo(61.000000,73.000000); + ctx.lineTo(54.000000,77.000000); + ctx.lineTo(63.000000,78.000000); + ctx.lineTo(53.000000,85.000000); + ctx.lineTo(60.000000,84.000000); + ctx.lineTo(56.000000,90.000000); + ctx.lineTo(69.000000,84.000000); + ctx.lineTo(63.000000,82.000000); + ctx.lineTo(75.000000,76.000000); + ctx.lineTo(70.000000,75.000000); + ctx.lineTo(77.000000,72.000000); + ctx.lineTo(72.000000,71.000000); + ctx.lineTo(78.000000,69.000000); + ctx.lineTo(72.000000,66.000000); + ctx.lineTo(81.000000,67.000000); + ctx.lineTo(78.000000,64.000000); + ctx.lineTo(82.000000,63.000000); + ctx.lineTo(80.000000,60.000000); + ctx.lineTo(86.000000,62.000000); + ctx.lineTo(80.000000,55.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(87.000000,56.000000); + ctx.lineTo(91.000000,52.000000); + ctx.lineTo(96.000000,50.000000); + ctx.lineTo(102.000000,56.000000); + ctx.lineTo(98.000000,56.000000); + ctx.lineTo(92.000000,60.000000); + ctx.lineTo(87.000000,56.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(85.000000,68.000000); + ctx.lineTo(89.000000,73.000000); + ctx.lineTo(98.000000,76.000000); + ctx.lineTo(106.000000,74.000000); + ctx.lineTo(96.000000,73.000000); + ctx.lineTo(91.000000,70.000000); + ctx.lineTo(85.000000,68.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(115.000000,57.000000); + ctx.lineTo(114.000000,64.000000); + ctx.lineTo(111.000000,64.000000); + ctx.lineTo(115.000000,75.000000); + ctx.lineTo(122.000000,81.000000); + ctx.lineTo(122.000000,74.000000); + ctx.lineTo(126.000000,79.000000); + ctx.lineTo(126.000000,74.000000); + ctx.lineTo(131.000000,78.000000); + ctx.lineTo(130.000000,72.000000); + ctx.lineTo(133.000000,77.000000); + ctx.lineTo(131.000000,68.000000); + ctx.lineTo(126.000000,61.000000); + ctx.lineTo(119.000000,57.000000); + ctx.lineTo(115.000000,57.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(145.000000,48.000000); + ctx.lineTo(143.000000,53.000000); + ctx.lineTo(147.000000,59.000000); + ctx.lineTo(151.000000,59.000000); + ctx.lineTo(150.000000,55.000000); + ctx.lineTo(145.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(26.000000,22.000000); + ctx.lineTo(34.000000,15.000000); + ctx.lineTo(43.000000,10.000000); + ctx.lineTo(52.000000,10.000000); + ctx.lineTo(59.000000,16.000000); + ctx.lineTo(47.000000,15.000000); + ctx.lineTo(32.000000,22.000000); + ctx.lineTo(26.000000,22.000000); +ctx.fill(); + + + + +ctx.fillStyle='#ffe5b2'; +ctx.beginPath(); +ctx.moveTo(160.000000,19.000000); + ctx.lineTo(152.000000,26.000000); + ctx.lineTo(149.000000,34.000000); + ctx.lineTo(154.000000,33.000000); + ctx.lineTo(152.000000,30.000000); + ctx.lineTo(157.000000,30.000000); + ctx.lineTo(155.000000,26.000000); + ctx.lineTo(158.000000,27.000000); + ctx.lineTo(157.000000,23.000000); + ctx.lineTo(161.000000,23.000000); + ctx.lineTo(160.000000,19.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(98.000000,117.000000); + ctx.lineTo(105.000000,122.000000); + ctx.lineTo(109.000000,122.000000); + ctx.lineTo(105.000000,117.000000); + ctx.lineTo(113.000000,120.000000); + ctx.lineTo(121.000000,120.000000); + ctx.lineTo(130.000000,112.000000); + ctx.lineTo(128.000000,108.000000); + ctx.lineTo(123.000000,103.000000); + ctx.lineTo(123.000000,99.000000); + ctx.lineTo(128.000000,101.000000); + ctx.lineTo(132.000000,106.000000); + ctx.lineTo(135.000000,109.000000); + ctx.lineTo(142.000000,105.000000); + ctx.lineTo(142.000000,101.000000); + ctx.lineTo(145.000000,101.000000); + ctx.lineTo(145.000000,91.000000); + ctx.lineTo(148.000000,101.000000); + ctx.lineTo(145.000000,105.000000); + ctx.lineTo(136.000000,112.000000); + ctx.lineTo(135.000000,116.000000); + ctx.lineTo(143.000000,124.000000); + ctx.lineTo(148.000000,120.000000); + ctx.lineTo(150.000000,122.000000); + ctx.lineTo(142.000000,128.000000); + ctx.lineTo(133.000000,122.000000); + ctx.lineTo(121.000000,125.000000); + ctx.lineTo(112.000000,126.000000); + ctx.lineTo(103.000000,125.000000); + ctx.lineTo(100.000000,129.000000); + ctx.lineTo(96.000000,124.000000); + ctx.lineTo(98.000000,117.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(146.000000,118.000000); + ctx.lineTo(152.000000,118.000000); + ctx.lineTo(152.000000,115.000000); + ctx.lineTo(149.000000,115.000000); + ctx.lineTo(146.000000,118.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(148.000000,112.000000); + ctx.lineTo(154.000000,111.000000); + ctx.lineTo(154.000000,109.000000); + ctx.lineTo(149.000000,109.000000); + ctx.lineTo(148.000000,112.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,112.000000); + ctx.lineTo(108.000000,115.000000); + ctx.lineTo(114.000000,116.000000); + ctx.lineTo(118.000000,114.000000); + ctx.lineTo(106.000000,112.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(108.000000,108.000000); + ctx.lineTo(111.000000,110.000000); + ctx.lineTo(116.000000,110.000000); + ctx.lineTo(119.000000,108.000000); + ctx.lineTo(108.000000,108.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,104.000000); + ctx.lineTo(109.000000,105.000000); + ctx.lineTo(117.000000,106.000000); + ctx.lineTo(115.000000,104.000000); + ctx.lineTo(106.000000,104.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(50.000000,25.000000); + ctx.lineTo(41.000000,26.000000); + ctx.lineTo(34.000000,33.000000); + ctx.lineTo(39.000000,43.000000); + ctx.lineTo(49.000000,58.000000); + ctx.lineTo(36.000000,51.000000); + ctx.lineTo(47.000000,68.000000); + ctx.lineTo(55.000000,69.000000); + ctx.lineTo(54.000000,59.000000); + ctx.lineTo(61.000000,57.000000); + ctx.lineTo(74.000000,46.000000); + ctx.lineTo(60.000000,52.000000); + ctx.lineTo(67.000000,42.000000); + ctx.lineTo(57.000000,48.000000); + ctx.lineTo(61.000000,40.000000); + ctx.lineTo(54.000000,45.000000); + ctx.lineTo(60.000000,36.000000); + ctx.lineTo(59.000000,29.000000); + ctx.lineTo(48.000000,38.000000); + ctx.lineTo(52.000000,30.000000); + ctx.lineTo(47.000000,32.000000); + ctx.lineTo(50.000000,25.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(147.000000,34.000000); + ctx.lineTo(152.000000,41.000000); + ctx.lineTo(155.000000,49.000000); + ctx.lineTo(161.000000,53.000000); + ctx.lineTo(157.000000,47.000000); + ctx.lineTo(164.000000,47.000000); + ctx.lineTo(158.000000,43.000000); + ctx.lineTo(168.000000,44.000000); + ctx.lineTo(159.000000,40.000000); + ctx.lineTo(164.000000,37.000000); + ctx.lineTo(169.000000,37.000000); + ctx.lineTo(164.000000,33.000000); + ctx.lineTo(169.000000,34.000000); + ctx.lineTo(165.000000,28.000000); + ctx.lineTo(170.000000,30.000000); + ctx.lineTo(170.000000,25.000000); + ctx.lineTo(173.000000,29.000000); + ctx.lineTo(175.000000,27.000000); + ctx.lineTo(176.000000,32.000000); + ctx.lineTo(173.000000,36.000000); + ctx.lineTo(175.000000,39.000000); + ctx.lineTo(172.000000,42.000000); + ctx.lineTo(172.000000,46.000000); + ctx.lineTo(168.000000,49.000000); + ctx.lineTo(170.000000,55.000000); + ctx.lineTo(162.000000,57.000000); + ctx.lineTo(158.000000,63.000000); + ctx.lineTo(155.000000,58.000000); + ctx.lineTo(153.000000,50.000000); + ctx.lineTo(149.000000,46.000000); + ctx.lineTo(147.000000,34.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(155.000000,71.000000); + ctx.lineTo(159.000000,80.000000); + ctx.lineTo(157.000000,93.000000); + ctx.lineTo(157.000000,102.000000); + ctx.lineTo(155.000000,108.000000); + ctx.lineTo(150.000000,101.000000); + ctx.lineTo(149.000000,93.000000); + ctx.lineTo(154.000000,101.000000); + ctx.lineTo(152.000000,91.000000); + ctx.lineTo(151.000000,83.000000); + ctx.lineTo(155.000000,79.000000); + ctx.lineTo(155.000000,71.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(112.000000,78.000000); + ctx.lineTo(115.000000,81.000000); + ctx.lineTo(114.000000,91.000000); + ctx.lineTo(112.000000,87.000000); + ctx.lineTo(113.000000,82.000000); + ctx.lineTo(112.000000,78.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(78.000000,28.000000); + ctx.lineTo(64.000000,17.000000); + ctx.lineTo(58.000000,11.000000); + ctx.lineTo(47.000000,9.000000); + ctx.lineTo(36.000000,10.000000); + ctx.lineTo(28.000000,16.000000); + ctx.lineTo(21.000000,26.000000); + ctx.lineTo(18.000000,41.000000); + ctx.lineTo(20.000000,51.000000); + ctx.lineTo(23.000000,61.000000); + ctx.lineTo(33.000000,65.000000); + ctx.lineTo(28.000000,68.000000); + ctx.lineTo(37.000000,74.000000); + ctx.lineTo(36.000000,81.000000); + ctx.lineTo(43.000000,87.000000); + ctx.lineTo(48.000000,90.000000); + ctx.lineTo(43.000000,100.000000); + ctx.lineTo(40.000000,98.000000); + ctx.lineTo(39.000000,90.000000); + ctx.lineTo(31.000000,80.000000); + ctx.lineTo(30.000000,72.000000); + ctx.lineTo(22.000000,71.000000); + ctx.lineTo(17.000000,61.000000); + ctx.lineTo(14.000000,46.000000); + ctx.lineTo(16.000000,28.000000); + ctx.lineTo(23.000000,17.000000); + ctx.lineTo(33.000000,9.000000); + ctx.lineTo(45.000000,6.000000); + ctx.lineTo(54.000000,6.000000); + ctx.lineTo(65.000000,12.000000); + ctx.lineTo(78.000000,28.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(67.000000,18.000000); + ctx.lineTo(76.000000,9.000000); + ctx.lineTo(87.000000,5.000000); + ctx.lineTo(101.000000,2.000000); + ctx.lineTo(118.000000,3.000000); + ctx.lineTo(135.000000,8.000000); + ctx.lineTo(149.000000,20.000000); + ctx.lineTo(149.000000,26.000000); + ctx.lineTo(144.000000,19.000000); + ctx.lineTo(132.000000,12.000000); + ctx.lineTo(121.000000,9.000000); + ctx.lineTo(105.000000,7.000000); + ctx.lineTo(89.000000,8.000000); + ctx.lineTo(76.000000,14.000000); + ctx.lineTo(70.000000,20.000000); + ctx.lineTo(67.000000,18.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(56.000000,98.000000); + ctx.lineTo(48.000000,106.000000); + ctx.lineTo(56.000000,103.000000); + ctx.lineTo(47.000000,112.000000); + ctx.lineTo(56.000000,110.000000); + ctx.lineTo(52.000000,115.000000); + ctx.lineTo(57.000000,113.000000); + ctx.lineTo(52.000000,121.000000); + ctx.lineTo(62.000000,115.000000); + ctx.lineTo(58.000000,123.000000); + ctx.lineTo(65.000000,119.000000); + ctx.lineTo(63.000000,125.000000); + ctx.lineTo(69.000000,121.000000); + ctx.lineTo(68.000000,127.000000); + ctx.lineTo(74.000000,125.000000); + ctx.lineTo(74.000000,129.000000); + ctx.lineTo(79.000000,128.000000); + ctx.lineTo(83.000000,132.000000); + ctx.lineTo(94.000000,135.000000); + ctx.lineTo(93.000000,129.000000); + ctx.lineTo(85.000000,127.000000); + ctx.lineTo(81.000000,122.000000); + ctx.lineTo(76.000000,126.000000); + ctx.lineTo(75.000000,121.000000); + ctx.lineTo(71.000000,124.000000); + ctx.lineTo(71.000000,117.000000); + ctx.lineTo(66.000000,121.000000); + ctx.lineTo(66.000000,117.000000); + ctx.lineTo(62.000000,117.000000); + ctx.lineTo(64.000000,112.000000); + ctx.lineTo(60.000000,113.000000); + ctx.lineTo(60.000000,110.000000); + ctx.lineTo(57.000000,111.000000); + ctx.lineTo(61.000000,105.000000); + ctx.lineTo(57.000000,107.000000); + ctx.lineTo(60.000000,101.000000); + ctx.lineTo(55.000000,102.000000); + ctx.lineTo(56.000000,98.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(101.000000,132.000000); + ctx.lineTo(103.000000,138.000000); + ctx.lineTo(106.000000,134.000000); + ctx.lineTo(106.000000,139.000000); + ctx.lineTo(112.000000,136.000000); + ctx.lineTo(111.000000,142.000000); + ctx.lineTo(115.000000,139.000000); + ctx.lineTo(114.000000,143.000000); + ctx.lineTo(119.000000,142.000000); + ctx.lineTo(125.000000,145.000000); + ctx.lineTo(131.000000,142.000000); + ctx.lineTo(135.000000,138.000000); + ctx.lineTo(140.000000,134.000000); + ctx.lineTo(140.000000,129.000000); + ctx.lineTo(143.000000,135.000000); + ctx.lineTo(145.000000,149.000000); + ctx.lineTo(150.000000,171.000000); + ctx.lineTo(149.000000,184.000000); + ctx.lineTo(145.000000,165.000000); + ctx.lineTo(141.000000,150.000000); + ctx.lineTo(136.000000,147.000000); + ctx.lineTo(132.000000,151.000000); + ctx.lineTo(131.000000,149.000000); + ctx.lineTo(126.000000,152.000000); + ctx.lineTo(125.000000,150.000000); + ctx.lineTo(121.000000,152.000000); + ctx.lineTo(117.000000,148.000000); + ctx.lineTo(111.000000,152.000000); + ctx.lineTo(110.000000,148.000000); + ctx.lineTo(105.000000,149.000000); + ctx.lineTo(104.000000,145.000000); + ctx.lineTo(98.000000,150.000000); + ctx.lineTo(96.000000,138.000000); + ctx.lineTo(94.000000,132.000000); + ctx.lineTo(94.000000,130.000000); + ctx.lineTo(98.000000,132.000000); + ctx.lineTo(101.000000,132.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(41.000000,94.000000); + ctx.lineTo(32.000000,110.000000); + ctx.lineTo(23.000000,132.000000); + ctx.lineTo(12.000000,163.000000); + ctx.lineTo(6.000000,190.000000); + ctx.lineTo(7.000000,217.000000); + ctx.lineTo(5.000000,236.000000); + ctx.lineTo(3.000000,247.000000); + ctx.lineTo(9.000000,230.000000); + ctx.lineTo(12.000000,211.000000); + ctx.lineTo(12.000000,185.000000); + ctx.lineTo(18.000000,160.000000); + ctx.lineTo(26.000000,134.000000); + ctx.lineTo(35.000000,110.000000); + ctx.lineTo(43.000000,99.000000); + ctx.lineTo(41.000000,94.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(32.000000,246.000000); + ctx.lineTo(41.000000,250.000000); + ctx.lineTo(50.000000,257.000000); + ctx.lineTo(52.000000,267.000000); + ctx.lineTo(53.000000,295.000000); + ctx.lineTo(53.000000,323.000000); + ctx.lineTo(59.000000,350.000000); + ctx.lineTo(54.000000,363.000000); + ctx.lineTo(51.000000,365.000000); + ctx.lineTo(44.000000,366.000000); + ctx.lineTo(42.000000,360.000000); + ctx.lineTo(40.000000,372.000000); + ctx.lineTo(54.000000,372.000000); + ctx.lineTo(59.000000,366.000000); + ctx.lineTo(62.000000,353.000000); + ctx.lineTo(71.000000,352.000000); + ctx.lineTo(75.000000,335.000000); + ctx.lineTo(73.000000,330.000000); + ctx.lineTo(66.000000,318.000000); + ctx.lineTo(68.000000,302.000000); + ctx.lineTo(64.000000,294.000000); + ctx.lineTo(67.000000,288.000000); + ctx.lineTo(63.000000,286.000000); + ctx.lineTo(63.000000,279.000000); + ctx.lineTo(59.000000,275.000000); + ctx.lineTo(58.000000,267.000000); + ctx.lineTo(56.000000,262.000000); + ctx.lineTo(50.000000,247.000000); + ctx.lineTo(42.000000,235.000000); + ctx.lineTo(44.000000,246.000000); + ctx.lineTo(32.000000,236.000000); + ctx.lineTo(35.000000,244.000000); + ctx.lineTo(32.000000,246.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(134.000000,324.000000); + ctx.lineTo(146.000000,320.000000); + ctx.lineTo(159.000000,322.000000); + ctx.lineTo(173.000000,327.000000); + ctx.lineTo(179.000000,337.000000); + ctx.lineTo(179.000000,349.000000); + ctx.lineTo(172.000000,355.000000); + ctx.lineTo(158.000000,357.000000); + ctx.lineTo(170.000000,350.000000); + ctx.lineTo(174.000000,343.000000); + ctx.lineTo(170.000000,333.000000); + ctx.lineTo(163.000000,328.000000); + ctx.lineTo(152.000000,326.000000); + ctx.lineTo(134.000000,329.000000); + ctx.lineTo(134.000000,324.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(173.000000,339.000000); + ctx.lineTo(183.000000,334.000000); + ctx.lineTo(184.000000,338.000000); + ctx.lineTo(191.000000,329.000000); + ctx.lineTo(194.000000,332.000000); + ctx.lineTo(199.000000,323.000000); + ctx.lineTo(202.000000,325.000000); + ctx.lineTo(206.000000,318.000000); + ctx.lineTo(209.000000,320.000000); + ctx.lineTo(213.000000,309.000000); + ctx.lineTo(221.000000,303.000000); + ctx.lineTo(228.000000,296.000000); + ctx.lineTo(232.000000,289.000000); + ctx.lineTo(234.000000,279.000000); + ctx.lineTo(233.000000,269.000000); + ctx.lineTo(230.000000,262.000000); + ctx.lineTo(225.000000,256.000000); + ctx.lineTo(219.000000,253.000000); + ctx.lineTo(208.000000,252.000000); + ctx.lineTo(198.000000,252.000000); + ctx.lineTo(210.000000,249.000000); + ctx.lineTo(223.000000,250.000000); + ctx.lineTo(232.000000,257.000000); + ctx.lineTo(237.000000,265.000000); + ctx.lineTo(238.000000,277.000000); + ctx.lineTo(238.000000,291.000000); + ctx.lineTo(232.000000,305.000000); + ctx.lineTo(221.000000,323.000000); + ctx.lineTo(218.000000,335.000000); + ctx.lineTo(212.000000,342.000000); + ctx.lineTo(200.000000,349.000000); + ctx.lineTo(178.000000,348.000000); + ctx.lineTo(173.000000,339.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(165.000000,296.000000); + ctx.lineTo(158.000000,301.000000); + ctx.lineTo(156.000000,310.000000); + ctx.lineTo(156.000000,323.000000); + ctx.lineTo(162.000000,324.000000); + ctx.lineTo(159.000000,318.000000); + ctx.lineTo(162.000000,308.000000); + ctx.lineTo(162.000000,304.000000); + ctx.lineTo(165.000000,296.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(99.000000,252.000000); + ctx.lineTo(105.000000,244.000000); + ctx.lineTo(107.000000,234.000000); + ctx.lineTo(115.000000,228.000000); + ctx.lineTo(121.000000,228.000000); + ctx.lineTo(131.000000,235.000000); + ctx.lineTo(122.000000,233.000000); + ctx.lineTo(113.000000,235.000000); + ctx.lineTo(109.000000,246.000000); + ctx.lineTo(121.000000,239.000000); + ctx.lineTo(133.000000,243.000000); + ctx.lineTo(121.000000,243.000000); + ctx.lineTo(110.000000,251.000000); + ctx.lineTo(99.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(117.000000,252.000000); + ctx.lineTo(124.000000,247.000000); + ctx.lineTo(134.000000,249.000000); + ctx.lineTo(136.000000,253.000000); + ctx.lineTo(126.000000,252.000000); + ctx.lineTo(117.000000,252.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(117.000000,218.000000); + ctx.lineTo(132.000000,224.000000); + ctx.lineTo(144.000000,233.000000); + ctx.lineTo(140.000000,225.000000); + ctx.lineTo(132.000000,219.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); + ctx.lineTo(117.000000,218.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(122.000000,212.000000); + ctx.lineTo(134.000000,214.000000); + ctx.lineTo(143.000000,221.000000); + ctx.lineTo(141.000000,213.000000); + ctx.lineTo(132.000000,210.000000); + ctx.lineTo(122.000000,212.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(69.000000,352.000000); + ctx.lineTo(70.000000,363.000000); + ctx.lineTo(76.000000,373.000000); + ctx.lineTo(86.000000,378.000000); + ctx.lineTo(97.000000,379.000000); + ctx.lineTo(108.000000,379.000000); + ctx.lineTo(120.000000,377.000000); + ctx.lineTo(128.000000,378.000000); + ctx.lineTo(132.000000,373.000000); + ctx.lineTo(135.000000,361.000000); + ctx.lineTo(133.000000,358.000000); + ctx.lineTo(132.000000,366.000000); + ctx.lineTo(127.000000,375.000000); + ctx.lineTo(121.000000,374.000000); + ctx.lineTo(121.000000,362.000000); + ctx.lineTo(119.000000,367.000000); + ctx.lineTo(117.000000,374.000000); + ctx.lineTo(110.000000,376.000000); + ctx.lineTo(110.000000,362.000000); + ctx.lineTo(107.000000,357.000000); + ctx.lineTo(106.000000,371.000000); + ctx.lineTo(104.000000,375.000000); + ctx.lineTo(97.000000,376.000000); + ctx.lineTo(90.000000,375.000000); + ctx.lineTo(90.000000,368.000000); + ctx.lineTo(86.000000,362.000000); + ctx.lineTo(83.000000,364.000000); + ctx.lineTo(86.000000,369.000000); + ctx.lineTo(85.000000,373.000000); + ctx.lineTo(78.000000,370.000000); + ctx.lineTo(73.000000,362.000000); + ctx.lineTo(71.000000,351.000000); + ctx.lineTo(69.000000,352.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(100.000000,360.000000); + ctx.lineTo(96.000000,363.000000); + ctx.lineTo(99.000000,369.000000); + ctx.lineTo(102.000000,364.000000); + ctx.lineTo(100.000000,360.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(115.000000,360.000000); + ctx.lineTo(112.000000,363.000000); + ctx.lineTo(114.000000,369.000000); + ctx.lineTo(117.000000,364.000000); + ctx.lineTo(115.000000,360.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(127.000000,362.000000); + ctx.lineTo(125.000000,364.000000); + ctx.lineTo(126.000000,369.000000); + ctx.lineTo(128.000000,365.000000); + ctx.lineTo(127.000000,362.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(5.000000,255.000000); + ctx.lineTo(7.000000,276.000000); + ctx.lineTo(11.000000,304.000000); + ctx.lineTo(15.000000,320.000000); + ctx.lineTo(13.000000,334.000000); + ctx.lineTo(6.000000,348.000000); + ctx.lineTo(2.000000,353.000000); + ctx.lineTo(0.000000,363.000000); + ctx.lineTo(5.000000,372.000000); + ctx.lineTo(12.000000,374.000000); + ctx.lineTo(25.000000,372.000000); + ctx.lineTo(38.000000,372.000000); + ctx.lineTo(44.000000,369.000000); + ctx.lineTo(42.000000,367.000000); + ctx.lineTo(36.000000,368.000000); + ctx.lineTo(31.000000,369.000000); + ctx.lineTo(30.000000,360.000000); + ctx.lineTo(27.000000,368.000000); + ctx.lineTo(20.000000,370.000000); + ctx.lineTo(16.000000,361.000000); + ctx.lineTo(15.000000,368.000000); + ctx.lineTo(10.000000,369.000000); + ctx.lineTo(3.000000,366.000000); + ctx.lineTo(3.000000,359.000000); + ctx.lineTo(6.000000,352.000000); + ctx.lineTo(11.000000,348.000000); + ctx.lineTo(17.000000,331.000000); + ctx.lineTo(19.000000,316.000000); + ctx.lineTo(12.000000,291.000000); + ctx.lineTo(9.000000,274.000000); + ctx.lineTo(5.000000,255.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(10.000000,358.000000); + ctx.lineTo(7.000000,362.000000); + ctx.lineTo(10.000000,366.000000); + ctx.lineTo(11.000000,362.000000); + ctx.lineTo(10.000000,358.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(25.000000,357.000000); + ctx.lineTo(22.000000,360.000000); + ctx.lineTo(24.000000,366.000000); + ctx.lineTo(27.000000,360.000000); + ctx.lineTo(25.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(37.000000,357.000000); + ctx.lineTo(34.000000,361.000000); + ctx.lineTo(36.000000,365.000000); + ctx.lineTo(38.000000,361.000000); + ctx.lineTo(37.000000,357.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(49.000000,356.000000); + ctx.lineTo(46.000000,359.000000); + ctx.lineTo(47.000000,364.000000); + ctx.lineTo(50.000000,360.000000); + ctx.lineTo(49.000000,356.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(130.000000,101.000000); + ctx.lineTo(132.000000,102.000000); + ctx.lineTo(135.000000,101.000000); + ctx.lineTo(139.000000,102.000000); + ctx.lineTo(143.000000,103.000000); + ctx.lineTo(142.000000,101.000000); + ctx.lineTo(137.000000,100.000000); + ctx.lineTo(133.000000,100.000000); + ctx.lineTo(130.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(106.000000,48.000000); + ctx.lineTo(105.000000,52.000000); + ctx.lineTo(108.000000,56.000000); + ctx.lineTo(109.000000,52.000000); + ctx.lineTo(106.000000,48.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(139.000000,52.000000); + ctx.lineTo(139.000000,56.000000); + ctx.lineTo(140.000000,60.000000); + ctx.lineTo(142.000000,58.000000); + ctx.lineTo(141.000000,56.000000); + ctx.lineTo(139.000000,52.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(25.000000,349.000000); + ctx.lineTo(29.000000,351.000000); + ctx.lineTo(30.000000,355.000000); + ctx.lineTo(33.000000,350.000000); + ctx.lineTo(37.000000,348.000000); + ctx.lineTo(42.000000,351.000000); + ctx.lineTo(45.000000,347.000000); + ctx.lineTo(49.000000,345.000000); + ctx.lineTo(44.000000,343.000000); + ctx.lineTo(36.000000,345.000000); + ctx.lineTo(25.000000,349.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(98.000000,347.000000); + ctx.lineTo(105.000000,351.000000); + ctx.lineTo(107.000000,354.000000); + ctx.lineTo(109.000000,349.000000); + ctx.lineTo(115.000000,349.000000); + ctx.lineTo(120.000000,353.000000); + ctx.lineTo(118.000000,349.000000); + ctx.lineTo(113.000000,346.000000); + ctx.lineTo(104.000000,346.000000); + ctx.lineTo(98.000000,347.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(83.000000,348.000000); + ctx.lineTo(87.000000,352.000000); + ctx.lineTo(87.000000,357.000000); + ctx.lineTo(89.000000,351.000000); + ctx.lineTo(87.000000,348.000000); + ctx.lineTo(83.000000,348.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(155.000000,107.000000); + ctx.lineTo(163.000000,107.000000); + ctx.lineTo(170.000000,107.000000); + ctx.lineTo(186.000000,108.000000); + ctx.lineTo(175.000000,109.000000); + ctx.lineTo(155.000000,109.000000); + ctx.lineTo(155.000000,107.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(153.000000,114.000000); + ctx.lineTo(162.000000,113.000000); + ctx.lineTo(175.000000,112.000000); + ctx.lineTo(192.000000,114.000000); + ctx.lineTo(173.000000,114.000000); + ctx.lineTo(154.000000,115.000000); + ctx.lineTo(153.000000,114.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(152.000000,118.000000); + ctx.lineTo(164.000000,120.000000); + ctx.lineTo(180.000000,123.000000); + ctx.lineTo(197.000000,129.000000); + ctx.lineTo(169.000000,123.000000); + ctx.lineTo(151.000000,120.000000); + ctx.lineTo(152.000000,118.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(68.000000,109.000000); + ctx.lineTo(87.000000,106.000000); + ctx.lineTo(107.000000,106.000000); + ctx.lineTo(106.000000,108.000000); + ctx.lineTo(88.000000,108.000000); + ctx.lineTo(68.000000,109.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(105.000000,111.000000); + ctx.lineTo(95.000000,112.000000); + ctx.lineTo(79.000000,114.000000); + ctx.lineTo(71.000000,116.000000); + ctx.lineTo(85.000000,115.000000); + ctx.lineTo(102.000000,113.000000); + ctx.lineTo(105.000000,111.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(108.000000,101.000000); + ctx.lineTo(98.000000,99.000000); + ctx.lineTo(87.000000,99.000000); + ctx.lineTo(78.000000,99.000000); + ctx.lineTo(93.000000,100.000000); + ctx.lineTo(105.000000,102.000000); + ctx.lineTo(108.000000,101.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(85.000000,63.000000); + ctx.lineTo(91.000000,63.000000); + ctx.lineTo(97.000000,60.000000); + ctx.lineTo(104.000000,60.000000); + ctx.lineTo(108.000000,62.000000); + ctx.lineTo(111.000000,69.000000); + ctx.lineTo(112.000000,75.000000); + ctx.lineTo(110.000000,74.000000); + ctx.lineTo(108.000000,71.000000); + ctx.lineTo(103.000000,73.000000); + ctx.lineTo(106.000000,69.000000); + ctx.lineTo(105.000000,65.000000); + ctx.lineTo(103.000000,64.000000); + ctx.lineTo(103.000000,67.000000); + ctx.lineTo(102.000000,70.000000); + ctx.lineTo(99.000000,70.000000); + ctx.lineTo(97.000000,66.000000); + ctx.lineTo(94.000000,67.000000); + ctx.lineTo(97.000000,72.000000); + ctx.lineTo(88.000000,67.000000); + ctx.lineTo(84.000000,66.000000); + ctx.lineTo(85.000000,63.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(140.000000,74.000000); + ctx.lineTo(141.000000,66.000000); + ctx.lineTo(144.000000,61.000000); + ctx.lineTo(150.000000,61.000000); + ctx.lineTo(156.000000,62.000000); + ctx.lineTo(153.000000,70.000000); + ctx.lineTo(150.000000,73.000000); + ctx.lineTo(152.000000,65.000000); + ctx.lineTo(150.000000,65.000000); + ctx.lineTo(151.000000,68.000000); + ctx.lineTo(149.000000,71.000000); + ctx.lineTo(146.000000,71.000000); + ctx.lineTo(144.000000,66.000000); + ctx.lineTo(143.000000,70.000000); + ctx.lineTo(143.000000,74.000000); + ctx.lineTo(140.000000,74.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(146.000000,20.000000); + ctx.lineTo(156.000000,11.000000); + ctx.lineTo(163.000000,9.000000); + ctx.lineTo(172.000000,9.000000); + ctx.lineTo(178.000000,14.000000); + ctx.lineTo(182.000000,18.000000); + ctx.lineTo(184.000000,32.000000); + ctx.lineTo(182.000000,42.000000); + ctx.lineTo(182.000000,52.000000); + ctx.lineTo(177.000000,58.000000); + ctx.lineTo(176.000000,67.000000); + ctx.lineTo(171.000000,76.000000); + ctx.lineTo(165.000000,90.000000); + ctx.lineTo(157.000000,105.000000); + ctx.lineTo(160.000000,92.000000); + ctx.lineTo(164.000000,85.000000); + ctx.lineTo(168.000000,78.000000); + ctx.lineTo(167.000000,73.000000); + ctx.lineTo(173.000000,66.000000); + ctx.lineTo(172.000000,62.000000); + ctx.lineTo(175.000000,59.000000); + ctx.lineTo(174.000000,55.000000); + ctx.lineTo(177.000000,53.000000); + ctx.lineTo(180.000000,46.000000); + ctx.lineTo(181.000000,29.000000); + ctx.lineTo(179.000000,21.000000); + ctx.lineTo(173.000000,13.000000); + ctx.lineTo(166.000000,11.000000); + ctx.lineTo(159.000000,13.000000); + ctx.lineTo(153.000000,18.000000); + ctx.lineTo(148.000000,23.000000); + ctx.lineTo(146.000000,20.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(150.000000,187.000000); + ctx.lineTo(148.000000,211.000000); + ctx.lineTo(150.000000,233.000000); + ctx.lineTo(153.000000,247.000000); + ctx.lineTo(148.000000,267.000000); + ctx.lineTo(135.000000,283.000000); + ctx.lineTo(125.000000,299.000000); + ctx.lineTo(136.000000,292.000000); + ctx.lineTo(131.000000,313.000000); + ctx.lineTo(122.000000,328.000000); + ctx.lineTo(122.000000,345.000000); + ctx.lineTo(129.000000,352.000000); + ctx.lineTo(133.000000,359.000000); + ctx.lineTo(133.000000,367.000000); + ctx.lineTo(137.000000,359.000000); + ctx.lineTo(148.000000,356.000000); + ctx.lineTo(140.000000,350.000000); + ctx.lineTo(131.000000,347.000000); + ctx.lineTo(129.000000,340.000000); + ctx.lineTo(132.000000,332.000000); + ctx.lineTo(140.000000,328.000000); + ctx.lineTo(137.000000,322.000000); + ctx.lineTo(140.000000,304.000000); + ctx.lineTo(154.000000,265.000000); + ctx.lineTo(157.000000,244.000000); + ctx.lineTo(155.000000,223.000000); + ctx.lineTo(161.000000,220.000000); + ctx.lineTo(175.000000,229.000000); + ctx.lineTo(186.000000,247.000000); + ctx.lineTo(185.000000,260.000000); + ctx.lineTo(176.000000,275.000000); + ctx.lineTo(178.000000,287.000000); + ctx.lineTo(185.000000,277.000000); + ctx.lineTo(188.000000,261.000000); + ctx.lineTo(196.000000,253.000000); + ctx.lineTo(189.000000,236.000000); + ctx.lineTo(174.000000,213.000000); + ctx.lineTo(150.000000,187.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(147.000000,338.000000); + ctx.lineTo(142.000000,341.000000); + ctx.lineTo(143.000000,345.000000); + ctx.lineTo(141.000000,354.000000); + ctx.lineTo(147.000000,343.000000); + ctx.lineTo(147.000000,338.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(157.000000,342.000000); + ctx.lineTo(156.000000,349.000000); + ctx.lineTo(150.000000,356.000000); + ctx.lineTo(157.000000,353.000000); + ctx.lineTo(163.000000,346.000000); + ctx.lineTo(162.000000,342.000000); + ctx.lineTo(157.000000,342.000000); +ctx.fill(); + + + + +ctx.fillStyle='#000000'; +ctx.beginPath(); +ctx.moveTo(99.000000,265.000000); + ctx.lineTo(96.000000,284.000000); + ctx.lineTo(92.000000,299.000000); + ctx.lineTo(73.000000,339.000000); + ctx.lineTo(73.000000,333.000000); + ctx.lineTo(87.000000,300.000000); + ctx.lineTo(99.000000,265.000000); +ctx.fill(); + + + +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/p3.js b/CAAT/documentation/demos/demo24/p3.js new file mode 100644 index 0000000..ad1b912 --- /dev/null +++ b/CAAT/documentation/demos/demo24/p3.js @@ -0,0 +1,892 @@ +function ff3(ctx) { + + +ctx.fillStyle='rgb(246,127,0)'; +ctx.strokeStyle='none'; +ctx.lineWidth='1'; +ctx.beginPath(); +ctx.moveTo(204.330002,139.830002); + ctx.bezierCurveTo(196.330002,133.330002,206.679993,132.820007,206.580002,132.580002); + ctx.bezierCurveTo(192.330002,97.080002,169.350006,81.410004,167.580002,80.580002); + ctx.bezierCurveTo(162.119995,78.019997,159.479996,78.260002,160.449997,76.970001); + ctx.bezierCurveTo(161.410004,75.680000,167.720001,79.720001,168.580002,80.330002); + ctx.bezierCurveTo(193.830002,98.330002,207.580002,132.330002,207.580002,132.330002); + ctx.bezierCurveTo(207.580002,132.330002,209.330002,133.330002,209.580002,132.580002); + ctx.bezierCurveTo(219.580002,103.080002,239.580002,87.580002,246.330002,81.330002); + ctx.bezierCurveTo(253.080002,75.080002,256.630005,74.470001,247.330002,81.580002); + ctx.bezierCurveTo(218.580002,103.580002,210.339996,132.229996,210.830002,132.330002); + ctx.bezierCurveTo(222.330002,134.830002,211.330002,140.330002,211.830002,139.830002); + ctx.bezierCurveTo(214.850006,136.809998,214.830002,145.830002,214.830002,145.830002); + ctx.bezierCurveTo(214.830002,145.830002,231.830002,110.830002,298.329987,66.330002); + ctx.bezierCurveTo(302.429993,63.590000,445.829987,-14.670000,395.829987,80.830002); + ctx.bezierCurveTo(393.239990,85.790001,375.829987,105.830002,375.829987,105.830002); + ctx.bezierCurveTo(375.829987,105.830002,377.329987,114.330002,371.329987,121.330002); + ctx.bezierCurveTo(370.299988,122.529999,367.829987,134.330002,361.829987,140.830002); + ctx.bezierCurveTo(360.140015,142.669998,361.809998,139.250000,361.829987,140.830002); + ctx.bezierCurveTo(362.329987,170.830002,337.760010,170.169998,339.329987,170.330002); + ctx.bezierCurveTo(348.829987,171.330002,350.190002,183.660004,350.329987,183.830002); + ctx.bezierCurveTo(355.829987,190.330002,353.829987,191.830002,355.829987,194.830002); + ctx.bezierCurveTo(366.630005,211.020004,355.239990,210.050003,356.829987,212.830002); + ctx.bezierCurveTo(360.829987,219.830002,355.989990,222.720001,357.329987,224.830002); + ctx.bezierCurveTo(360.829987,230.330002,354.750000,233.839996,354.829987,235.330002); + ctx.bezierCurveTo(355.329987,243.830002,349.670013,240.729996,349.829987,244.330002); + ctx.bezierCurveTo(350.329987,255.330002,346.329987,250.830002,343.829987,254.830002); + ctx.bezierCurveTo(336.329987,266.829987,333.459991,262.380005,332.829987,263.829987); + ctx.bezierCurveTo(329.829987,270.829987,325.809998,269.149994,324.329987,270.829987); + ctx.bezierCurveTo(320.829987,274.829987,317.329987,274.829987,315.829987,276.329987); + ctx.bezierCurveTo(308.829987,283.329987,304.859985,278.390015,303.829987,278.829987); + ctx.bezierCurveTo(287.829987,285.829987,280.329987,280.170013,277.829987,280.329987); + ctx.bezierCurveTo(270.329987,280.829987,271.480011,279.670013,269.329987,277.829987); + ctx.bezierCurveTo(237.830002,250.830002,219.330002,211.830002,215.830002,206.830002); + ctx.bezierCurveTo(214.399994,204.789993,211.350006,193.119995,212.330002,195.830002); + ctx.bezierCurveTo(214.330002,201.330002,213.330002,250.330002,207.830002,250.330002); + ctx.bezierCurveTo(202.330002,250.330002,201.830002,204.330002,205.330002,195.830002); + ctx.bezierCurveTo(206.429993,193.160004,204.399994,203.720001,201.789993,206.830002); + ctx.bezierCurveTo(196.330002,213.330002,179.500000,250.830002,147.589996,277.829987); + ctx.bezierCurveTo(145.419998,279.670013,146.580002,280.829987,138.979996,280.329987); + ctx.bezierCurveTo(136.460007,280.170013,128.850006,285.829987,112.650002,278.829987); + ctx.bezierCurveTo(111.610001,278.390015,107.580002,283.329987,100.489998,276.329987); + ctx.bezierCurveTo(98.970001,274.829987,95.430000,274.829987,91.879997,270.829987); + ctx.bezierCurveTo(90.389999,269.149994,86.309998,270.829987,83.269997,263.829987); + ctx.bezierCurveTo(82.639999,262.380005,79.730003,266.829987,72.129997,254.830002); + ctx.bezierCurveTo(69.599998,250.830002,65.540001,255.330002,66.050003,244.330002); + ctx.bezierCurveTo(66.220001,240.729996,60.480000,243.830002,60.990002,235.330002); + ctx.bezierCurveTo(61.080002,233.839996,54.910000,230.330002,58.450001,224.830002); + ctx.bezierCurveTo(59.810001,222.720001,54.910000,219.830002,58.959999,212.830002); + ctx.bezierCurveTo(60.570000,210.050003,49.040001,211.020004,59.970001,194.830002); + ctx.bezierCurveTo(62.000000,191.830002,59.970001,190.330002,65.540001,183.830002); + ctx.bezierCurveTo(65.690002,183.660004,67.059998,171.330002,76.690002,170.330002); + ctx.bezierCurveTo(78.279999,170.169998,53.389999,170.830002,53.900002,140.830002); + ctx.bezierCurveTo(53.919998,139.250000,55.610001,142.669998,53.900002,140.830002); + ctx.bezierCurveTo(47.820000,134.330002,45.320000,122.529999,44.270000,121.330002); + ctx.bezierCurveTo(38.189999,114.330002,39.709999,105.830002,39.709999,105.830002); + ctx.bezierCurveTo(39.709999,105.830002,22.080000,85.790001,19.459999,80.830002); + ctx.bezierCurveTo(-31.190001,-14.670000,114.070000,63.590000,118.220001,66.330002); + ctx.bezierCurveTo(185.580002,110.830002,202.000000,145.830002,202.000000,145.830002); + ctx.bezierCurveTo(202.000000,145.830002,202.360001,143.279999,203.000000,141.830002); + ctx.bezierCurveTo(203.639999,140.389999,204.559998,140.020004,204.330002,139.830002); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='rgb(0,0,0)'; +ctx.strokeStyle='none'; +ctx.lineWidth='1'; +ctx.beginPath(); +ctx.moveTo(203.619995,139.619995); + ctx.bezierCurveTo(195.619995,133.119995,205.960007,132.600006,205.869995,132.369995); + ctx.bezierCurveTo(191.619995,96.870003,168.639999,81.199997,166.869995,80.370003); + ctx.bezierCurveTo(161.410004,77.809998,158.770004,78.050003,159.729996,76.760002); + ctx.bezierCurveTo(160.690002,75.470001,167.009995,79.510002,167.869995,80.120003); + ctx.bezierCurveTo(193.119995,98.120003,206.869995,132.119995,206.869995,132.119995); + ctx.bezierCurveTo(206.869995,132.119995,208.619995,133.119995,208.869995,132.369995); + ctx.bezierCurveTo(218.869995,102.870003,238.869995,87.370003,245.619995,81.120003); + ctx.bezierCurveTo(252.369995,74.870003,255.919998,74.260002,246.619995,81.370003); + ctx.bezierCurveTo(217.869995,103.370003,209.630005,132.009995,210.119995,132.119995); + ctx.bezierCurveTo(221.619995,134.619995,210.619995,140.119995,211.119995,139.619995); + ctx.bezierCurveTo(214.139999,136.600006,214.119995,145.619995,214.119995,145.619995); + ctx.bezierCurveTo(214.119995,145.619995,231.119995,110.620003,297.619995,66.120003); + ctx.bezierCurveTo(301.709991,63.380001,445.119995,-14.880000,395.119995,80.620003); + ctx.bezierCurveTo(392.529999,85.570000,375.119995,105.620003,375.119995,105.620003); + ctx.bezierCurveTo(375.119995,105.620003,376.619995,114.120003,370.619995,121.120003); + ctx.bezierCurveTo(369.589996,122.320000,367.119995,134.119995,361.119995,140.619995); + ctx.bezierCurveTo(359.429993,142.460007,361.089996,139.039993,361.119995,140.619995); + ctx.bezierCurveTo(361.619995,170.619995,337.049988,169.960007,338.619995,170.119995); + ctx.bezierCurveTo(348.119995,171.119995,349.470001,183.449997,349.619995,183.619995); + ctx.bezierCurveTo(355.119995,190.119995,353.119995,191.619995,355.119995,194.619995); + ctx.bezierCurveTo(365.910004,210.809998,354.529999,209.839996,356.119995,212.619995); + ctx.bezierCurveTo(360.119995,219.619995,355.279999,222.509995,356.619995,224.619995); + ctx.bezierCurveTo(360.119995,230.119995,354.029999,233.619995,354.119995,235.119995); + ctx.bezierCurveTo(354.619995,243.619995,348.959991,240.520004,349.119995,244.119995); + ctx.bezierCurveTo(349.619995,255.119995,345.619995,250.619995,343.119995,254.619995); + ctx.bezierCurveTo(335.619995,266.619995,332.739990,262.170013,332.119995,263.619995); + ctx.bezierCurveTo(329.119995,270.619995,325.089996,268.940002,323.619995,270.619995); + ctx.bezierCurveTo(320.119995,274.619995,316.619995,274.619995,315.119995,276.119995); + ctx.bezierCurveTo(308.119995,283.119995,304.149994,278.170013,303.119995,278.619995); + ctx.bezierCurveTo(287.119995,285.619995,279.619995,279.950012,277.119995,280.119995); + ctx.bezierCurveTo(269.619995,280.619995,270.769989,279.459991,268.619995,277.619995); + ctx.bezierCurveTo(237.119995,250.619995,218.619995,211.619995,215.119995,206.619995); + ctx.bezierCurveTo(213.690002,204.570007,210.630005,192.910004,211.619995,195.619995); + ctx.bezierCurveTo(213.619995,201.119995,212.619995,250.119995,207.119995,250.119995); + ctx.bezierCurveTo(201.619995,250.119995,201.119995,204.119995,204.619995,195.619995); + ctx.bezierCurveTo(205.720001,192.949997,203.690002,203.500000,201.080002,206.619995); + ctx.bezierCurveTo(195.619995,213.119995,178.789993,250.619995,146.880005,277.619995); + ctx.bezierCurveTo(144.710007,279.459991,145.869995,280.619995,138.270004,280.119995); + ctx.bezierCurveTo(135.750000,279.950012,128.139999,285.619995,111.940002,278.619995); + ctx.bezierCurveTo(110.900002,278.170013,106.870003,283.119995,99.779999,276.119995); + ctx.bezierCurveTo(98.260002,274.619995,94.720001,274.619995,91.169998,270.619995); + ctx.bezierCurveTo(89.680000,268.940002,85.599998,270.619995,82.559998,263.619995); + ctx.bezierCurveTo(81.930000,262.170013,79.010002,266.619995,71.419998,254.619995); + ctx.bezierCurveTo(68.879997,250.619995,64.830002,255.119995,65.339996,244.119995); + ctx.bezierCurveTo(65.510002,240.520004,59.770000,243.619995,60.270000,235.119995); + ctx.bezierCurveTo(60.360001,233.619995,54.200001,230.119995,57.740002,224.619995); + ctx.bezierCurveTo(59.099998,222.509995,54.200001,219.619995,58.250000,212.619995); + ctx.bezierCurveTo(59.860001,209.839996,48.330002,210.809998,59.259998,194.619995); + ctx.bezierCurveTo(61.290001,191.619995,59.259998,190.119995,64.830002,183.619995); + ctx.bezierCurveTo(64.980003,183.449997,66.349998,171.119995,75.980003,170.119995); + ctx.bezierCurveTo(77.570000,169.960007,52.680000,170.619995,53.180000,140.619995); + ctx.bezierCurveTo(53.209999,139.039993,54.900002,142.460007,53.180000,140.619995); + ctx.bezierCurveTo(47.110001,134.119995,44.599998,122.320000,43.560001,121.120003); + ctx.bezierCurveTo(37.480000,114.120003,39.000000,105.620003,39.000000,105.620003); + ctx.bezierCurveTo(39.000000,105.620003,21.370001,85.570000,18.740000,80.620003); + ctx.bezierCurveTo(-31.900000,-14.880000,113.360001,63.380001,117.510002,66.120003); + ctx.bezierCurveTo(184.869995,110.620003,201.289993,145.619995,201.289993,145.619995); + ctx.bezierCurveTo(201.289993,145.619995,201.649994,143.070007,202.289993,141.619995); + ctx.bezierCurveTo(202.929993,140.179993,203.850006,139.809998,203.619995,139.619995); +ctx.moveTo(242.119995,153.119995); + ctx.bezierCurveTo(245.160004,153.020004,251.350006,156.169998,255.119995,155.119995); + ctx.bezierCurveTo(280.549988,148.059998,328.440002,154.559998,331.619995,155.619995); + ctx.bezierCurveTo(343.619995,159.619995,351.619995,131.119995,326.119995,131.119995); + ctx.bezierCurveTo(294.589996,131.119995,301.119995,129.119995,280.119995,126.120003); + ctx.bezierCurveTo(278.339996,125.870003,252.600006,135.419998,228.619995,149.119995); + ctx.bezierCurveTo(225.119995,151.119995,227.119995,153.619995,242.119995,153.119995); +ctx.moveTo(223.119995,148.119995); + ctx.bezierCurveTo(225.660004,148.399994,238.119995,139.619995,277.119995,124.120003); + ctx.bezierCurveTo(279.489990,123.180000,279.619995,118.120003,300.619995,108.620003); + ctx.bezierCurveTo(301.989990,108.000000,300.119995,104.620003,314.619995,92.620003); + ctx.bezierCurveTo(321.790009,86.690002,297.119995,87.620003,291.619995,88.620003); + ctx.bezierCurveTo(286.119995,89.620003,272.619995,100.620003,272.619995,100.620003); + ctx.bezierCurveTo(272.619995,100.620003,287.799988,88.550003,282.619995,90.120003); + ctx.bezierCurveTo(271.119995,93.620003,241.119995,126.620003,231.119995,140.619995); + ctx.bezierCurveTo(221.119995,154.619995,247.619995,116.620003,254.119995,110.620003); + ctx.bezierCurveTo(260.619995,104.620003,204.619995,146.119995,223.119995,148.119995); +ctx.moveTo(335.619995,128.619995); + ctx.bezierCurveTo(350.140015,131.529999,348.619995,110.120003,341.119995,109.120003); + ctx.bezierCurveTo(329.549988,107.580002,307.510010,108.300003,301.119995,110.620003); + ctx.bezierCurveTo(284.619995,116.620003,280.290009,122.650002,281.619995,123.120003); + ctx.bezierCurveTo(310.119995,133.119995,330.619995,127.620003,335.619995,128.619995); +ctx.moveTo(335.119995,106.620003); + ctx.bezierCurveTo(341.040009,107.360001,351.119995,109.620003,351.619995,101.620003); + ctx.bezierCurveTo(351.869995,97.599998,365.619995,104.620003,368.619995,105.120003); + ctx.bezierCurveTo(371.100006,105.529999,358.119995,100.330002,353.619995,97.120003); + ctx.bezierCurveTo(350.119995,94.620003,349.510010,91.760002,349.119995,91.620003); + ctx.bezierCurveTo(317.119995,80.120003,303.619995,107.120003,303.619995,107.120003); + ctx.bezierCurveTo(303.619995,107.120003,331.119995,106.120003,335.119995,106.620003); +ctx.moveTo(400.619995,62.619999); + ctx.bezierCurveTo(395.619995,54.619999,386.660004,57.080002,383.619995,53.619999); + ctx.bezierCurveTo(369.119995,37.119999,335.540009,58.279999,363.119995,56.119999); + ctx.bezierCurveTo(395.119995,53.619999,401.209991,63.570000,400.619995,62.619999); +ctx.moveTo(376.619995,66.620003); + ctx.bezierCurveTo(390.130005,66.620003,396.119995,72.620003,395.119995,71.620003); + ctx.bezierCurveTo(388.119995,64.620003,382.119995,66.120003,380.619995,64.120003); + ctx.bezierCurveTo(371.700012,52.230000,345.119995,64.620003,347.119995,67.620003); + ctx.bezierCurveTo(349.119995,70.620003,373.119995,66.620003,376.619995,66.620003); +ctx.moveTo(330.119995,76.120003); + ctx.bezierCurveTo(309.119995,81.120003,318.119995,88.620003,320.619995,88.120003); + ctx.bezierCurveTo(340.049988,84.239998,334.500000,75.080002,330.119995,76.120003); +ctx.moveTo(340.619995,52.119999); + ctx.bezierCurveTo(331.119995,53.119999,330.480011,70.430000,335.119995,67.120003); + ctx.bezierCurveTo(342.119995,62.119999,350.119995,51.119999,340.619995,52.119999); +ctx.moveTo(315.619995,75.620003); + ctx.bezierCurveTo(329.619995,70.120003,319.119995,67.620003,314.619995,68.120003); + ctx.bezierCurveTo(310.119995,68.620003,306.790009,75.449997,308.119995,78.120003); + ctx.bezierCurveTo(311.119995,84.120003,312.910004,76.690002,315.619995,75.620003); +ctx.moveTo(359.619995,121.120003); + ctx.bezierCurveTo(364.119995,118.620003,358.619995,112.620003,354.619995,115.120003); + ctx.bezierCurveTo(350.619995,117.620003,355.119995,123.620003,359.619995,121.120003); +ctx.moveTo(350.119995,78.620003); + ctx.bezierCurveTo(361.890015,90.389999,366.619995,84.120003,369.119995,83.120003); + ctx.bezierCurveTo(377.239990,79.870003,386.119995,88.620003,384.619995,87.120003); + ctx.bezierCurveTo(377.339996,79.839996,372.619995,81.120003,371.619995,79.620003); + ctx.bezierCurveTo(364.010010,68.199997,352.660004,75.440002,350.119995,75.620003); + ctx.bezierCurveTo(343.119995,76.120003,334.429993,81.029999,337.619995,80.120003); + ctx.bezierCurveTo(341.119995,79.120003,348.619995,77.120003,350.119995,78.620003); +ctx.moveTo(383.619995,44.119999); + ctx.bezierCurveTo(390.619995,39.119999,381.399994,37.849998,379.619995,38.119999); + ctx.bezierCurveTo(373.119995,39.119999,376.619995,49.119999,383.619995,44.119999); +ctx.moveTo(224.619995,181.119995); + ctx.bezierCurveTo(230.119995,187.619995,291.619995,285.119995,282.119995,252.619995); + ctx.bezierCurveTo(280.829987,248.199997,285.619995,266.119995,291.119995,256.119995); + ctx.bezierCurveTo(292.660004,253.320007,301.269989,253.029999,274.619995,208.619995); + ctx.bezierCurveTo(273.119995,206.119995,252.619995,198.119995,232.119995,175.619995); + ctx.bezierCurveTo(229.020004,172.210007,220.050003,175.720001,224.619995,181.119995); +ctx.moveTo(280.119995,215.619995); + ctx.bezierCurveTo(284.619995,222.619995,295.809998,246.070007,296.619995,249.619995); + ctx.bezierCurveTo(299.119995,260.619995,306.119995,248.119995,307.619995,248.619995); + ctx.bezierCurveTo(320.779999,253.009995,311.119995,241.119995,310.119995,238.119995); + ctx.bezierCurveTo(300.950012,210.619995,279.619995,213.119995,279.619995,213.119995); + ctx.bezierCurveTo(279.619995,213.119995,275.619995,208.619995,280.119995,215.619995); +ctx.moveTo(253.619995,256.119995); + ctx.bezierCurveTo(266.260010,274.089996,271.119995,267.119995,273.619995,265.119995); + ctx.bezierCurveTo(281.320007,258.959991,232.339996,196.139999,229.119995,192.119995); + ctx.bezierCurveTo(225.119995,187.119995,225.119995,215.619995,253.619995,256.119995); +ctx.moveTo(300.119995,219.119995); + ctx.bezierCurveTo(306.619995,224.119995,313.859985,245.190002,317.619995,244.619995); + ctx.bezierCurveTo(327.619995,243.119995,321.619995,234.619995,324.119995,236.119995); + ctx.bezierCurveTo(326.619995,237.619995,331.619995,234.949997,330.119995,232.119995); + ctx.bezierCurveTo(317.619995,208.619995,298.119995,216.119995,298.119995,216.119995); + ctx.bezierCurveTo(298.119995,216.119995,293.619995,214.119995,300.119995,219.119995); +ctx.moveTo(235.619995,168.619995); + ctx.bezierCurveTo(216.119995,168.619995,282.119995,222.619995,301.119995,212.119995); + ctx.bezierCurveTo(305.059998,209.940002,296.119995,208.619995,297.619995,197.119995); + ctx.bezierCurveTo(297.899994,195.020004,284.119995,191.119995,284.119995,178.119995); + ctx.bezierCurveTo(284.119995,173.880005,276.200012,172.119995,251.119995,172.119995); + ctx.bezierCurveTo(246.619995,172.119995,256.029999,168.619995,235.619995,168.619995); +ctx.moveTo(307.619995,213.619995); + ctx.bezierCurveTo(325.890015,215.649994,330.230011,229.800003,332.619995,228.119995); + ctx.bezierCurveTo(361.119995,208.119995,309.890015,199.960007,300.619995,201.119995); + ctx.bezierCurveTo(296.619995,201.619995,303.119995,213.119995,307.619995,213.619995); +ctx.moveTo(238.619995,164.119995); + ctx.bezierCurveTo(242.119995,166.619995,254.119995,176.619995,292.619995,168.119995); + ctx.bezierCurveTo(294.089996,167.800003,263.619995,167.619995,259.619995,166.619995); + ctx.bezierCurveTo(255.619995,165.619995,236.250000,162.429993,238.619995,164.119995); +ctx.moveTo(305.119995,198.619995); + ctx.bezierCurveTo(342.619995,207.619995,332.720001,201.360001,334.119995,200.619995); + ctx.bezierCurveTo(342.619995,196.119995,333.329987,195.229996,334.619995,193.619995); + ctx.bezierCurveTo(338.829987,188.360001,327.619995,185.119995,304.119995,182.619995); + ctx.bezierCurveTo(298.559998,182.029999,287.540009,179.270004,287.119995,180.119995); + ctx.bezierCurveTo(283.619995,187.119995,300.329987,197.470001,305.119995,198.619995); +ctx.moveTo(311.119995,182.119995); + ctx.bezierCurveTo(343.619995,187.619995,323.230011,177.429993,323.619995,177.119995); + ctx.bezierCurveTo(335.119995,168.119995,297.119995,168.119995,297.119995,168.119995); + ctx.bezierCurveTo(297.119995,168.119995,280.790009,172.000000,281.119995,172.619995); + ctx.bezierCurveTo(285.619995,181.119995,307.149994,181.449997,311.119995,182.119995); +ctx.moveTo(249.619995,253.619995); + ctx.bezierCurveTo(249.619995,253.619995,220.619995,207.119995,226.619995,188.119995); + ctx.bezierCurveTo(227.830002,184.309998,213.619995,165.619995,220.119995,197.119995); + ctx.bezierCurveTo(220.220001,197.610001,218.889999,190.429993,216.619995,187.119995); + ctx.bezierCurveTo(214.350006,183.809998,211.179993,184.899994,213.119995,194.619995); + ctx.bezierCurveTo(218.009995,219.050003,249.619995,253.619995,249.619995,253.619995); +ctx.moveTo(289.119995,83.620003); + ctx.bezierCurveTo(296.619995,81.620003,293.119995,79.120003,288.619995,78.120003); + ctx.bezierCurveTo(284.119995,77.120003,281.619995,85.620003,289.119995,83.620003); +ctx.moveTo(187.399994,149.119995); + ctx.bezierCurveTo(163.119995,135.419998,137.039993,125.870003,135.229996,126.120003); + ctx.bezierCurveTo(113.959999,129.119995,120.580002,131.119995,88.639999,131.119995); + ctx.bezierCurveTo(62.810001,131.119995,70.910004,159.619995,83.070000,155.619995); + ctx.bezierCurveTo(86.290001,154.559998,134.800003,148.059998,160.559998,155.119995); + ctx.bezierCurveTo(164.369995,156.169998,170.649994,153.020004,173.729996,153.119995); + ctx.bezierCurveTo(188.919998,153.619995,190.949997,151.119995,187.399994,149.119995); +ctx.moveTo(161.570007,110.620003); + ctx.bezierCurveTo(168.149994,116.620003,195.000000,154.619995,184.869995,140.619995); + ctx.bezierCurveTo(174.740005,126.620003,144.350006,93.620003,132.699997,90.120003); + ctx.bezierCurveTo(127.459999,88.550003,142.830002,100.620003,142.830002,100.620003); + ctx.bezierCurveTo(142.830002,100.620003,129.160004,89.620003,123.580002,88.620003); + ctx.bezierCurveTo(118.010002,87.620003,93.029999,86.690002,100.290001,92.620003); + ctx.bezierCurveTo(114.970001,104.620003,113.080002,108.000000,114.470001,108.620003); + ctx.bezierCurveTo(135.740005,118.120003,135.869995,123.180000,138.270004,124.120003); + ctx.bezierCurveTo(177.779999,139.619995,190.399994,148.399994,192.970001,148.119995); + ctx.bezierCurveTo(211.710007,146.119995,154.990005,104.620003,161.570007,110.620003); +ctx.moveTo(133.710007,123.120003); + ctx.bezierCurveTo(135.070007,122.650002,130.679993,116.620003,113.959999,110.620003); + ctx.bezierCurveTo(107.489998,108.300003,85.160004,107.580002,73.440002,109.120003); + ctx.bezierCurveTo(65.849998,110.120003,64.309998,131.529999,79.010002,128.619995); + ctx.bezierCurveTo(84.080002,127.620003,104.839996,133.119995,133.710007,123.120003); +ctx.moveTo(111.430000,107.120003); + ctx.bezierCurveTo(111.430000,107.120003,97.750000,80.120003,65.339996,91.620003); + ctx.bezierCurveTo(64.949997,91.760002,64.330002,94.620003,60.779999,97.120003); + ctx.bezierCurveTo(56.230000,100.330002,43.080002,105.529999,45.590000,105.120003); + ctx.bezierCurveTo(48.630001,104.620003,62.549999,97.599998,62.810001,101.620003); + ctx.bezierCurveTo(63.310001,109.620003,73.529999,107.360001,79.519997,106.620003); + ctx.bezierCurveTo(83.570000,106.120003,111.430000,107.120003,111.430000,107.120003); +ctx.moveTo(51.160000,56.119999); + ctx.bezierCurveTo(79.089996,58.279999,45.080002,37.119999,30.389999,53.619999); + ctx.bezierCurveTo(27.309999,57.080002,18.240000,54.619999,13.170000,62.619999); + ctx.bezierCurveTo(12.570000,63.570000,18.740000,53.619999,51.160000,56.119999); +ctx.moveTo(67.370003,67.620003); + ctx.bezierCurveTo(69.389999,64.620003,42.470001,52.230000,33.430000,64.120003); + ctx.bezierCurveTo(31.910000,66.120003,25.830000,64.620003,18.740000,71.620003); + ctx.bezierCurveTo(17.730000,72.620003,23.799999,66.620003,37.480000,66.620003); + ctx.bezierCurveTo(41.029999,66.620003,65.339996,70.620003,67.370003,67.620003); +ctx.moveTo(84.589996,76.120003); + ctx.bezierCurveTo(105.860001,81.120003,96.739998,88.620003,94.209999,88.120003); + ctx.bezierCurveTo(74.529999,84.239998,80.150002,75.080002,84.589996,76.120003); +ctx.moveTo(79.519997,67.120003); + ctx.bezierCurveTo(84.220001,70.430000,83.570000,53.119999,73.949997,52.119999); + ctx.bezierCurveTo(64.330002,51.119999,72.430000,62.119999,79.519997,67.120003); +ctx.moveTo(106.870003,78.120003); + ctx.bezierCurveTo(108.220001,75.449997,104.839996,68.620003,100.290001,68.120003); + ctx.bezierCurveTo(95.730003,67.620003,85.089996,70.120003,99.269997,75.620003); + ctx.bezierCurveTo(102.019997,76.690002,103.830002,84.120003,106.870003,78.120003); +ctx.moveTo(59.770000,115.120003); + ctx.bezierCurveTo(55.720001,112.620003,50.139999,118.620003,54.700001,121.120003); + ctx.bezierCurveTo(59.259998,123.620003,63.820000,117.620003,59.770000,115.120003); +ctx.moveTo(76.989998,80.120003); + ctx.bezierCurveTo(80.220001,81.029999,71.419998,76.120003,64.330002,75.620003); + ctx.bezierCurveTo(61.750000,75.440002,50.259998,68.199997,42.549999,79.620003); + ctx.bezierCurveTo(41.529999,81.120003,36.750000,79.839996,29.379999,87.120003); + ctx.bezierCurveTo(27.860001,88.620003,36.849998,79.870003,45.080002,83.120003); + ctx.bezierCurveTo(47.610001,84.120003,52.410000,90.389999,64.330002,78.620003); + ctx.bezierCurveTo(65.849998,77.120003,73.440002,79.120003,76.989998,80.120003); +ctx.moveTo(34.439999,38.119999); + ctx.bezierCurveTo(32.639999,37.849998,23.299999,39.119999,30.389999,44.119999); + ctx.bezierCurveTo(37.480000,49.119999,41.029999,39.119999,34.439999,38.119999); +ctx.moveTo(183.860001,175.619995); + ctx.bezierCurveTo(163.089996,198.119995,142.320007,206.119995,140.800003,208.619995); + ctx.bezierCurveTo(113.809998,253.029999,122.529999,253.320007,124.089996,256.119995); + ctx.bezierCurveTo(129.660004,266.119995,134.520004,248.199997,133.210007,252.619995); + ctx.bezierCurveTo(123.580002,285.119995,185.880005,187.619995,191.449997,181.119995); + ctx.bezierCurveTo(196.080002,175.720001,187.000000,172.210007,183.860001,175.619995); +ctx.moveTo(135.740005,213.119995); + ctx.bezierCurveTo(135.740005,213.119995,114.129997,210.619995,104.839996,238.119995); + ctx.bezierCurveTo(103.830002,241.119995,94.050003,253.009995,107.379997,248.619995); + ctx.bezierCurveTo(108.900002,248.119995,115.989998,260.619995,118.519997,249.619995); + ctx.bezierCurveTo(119.339996,246.070007,130.679993,222.619995,135.229996,215.619995); + ctx.bezierCurveTo(139.789993,208.619995,135.740005,213.119995,135.740005,213.119995); +ctx.moveTo(186.889999,192.119995); + ctx.bezierCurveTo(183.639999,196.139999,134.020004,258.959991,141.820007,265.119995); + ctx.bezierCurveTo(144.350006,267.119995,149.270004,274.089996,162.080002,256.119995); + ctx.bezierCurveTo(190.949997,215.619995,190.949997,187.119995,186.889999,192.119995); +ctx.moveTo(117.000000,216.119995); + ctx.bezierCurveTo(117.000000,216.119995,97.250000,208.619995,84.589996,232.119995); + ctx.bezierCurveTo(83.059998,234.949997,88.129997,237.619995,90.660004,236.119995); + ctx.bezierCurveTo(93.199997,234.619995,87.120003,243.119995,97.250000,244.619995); + ctx.bezierCurveTo(101.059998,245.190002,108.389999,224.119995,114.970001,219.119995); + ctx.bezierCurveTo(121.559998,214.119995,117.000000,216.119995,117.000000,216.119995); +ctx.moveTo(164.610001,172.119995); + ctx.bezierCurveTo(139.199997,172.119995,131.179993,173.880005,131.179993,178.119995); + ctx.bezierCurveTo(131.179993,191.119995,117.230003,195.020004,117.510002,197.119995); + ctx.bezierCurveTo(119.029999,208.619995,109.970001,209.940002,113.959999,212.119995); + ctx.bezierCurveTo(133.210007,222.619995,200.059998,168.619995,180.309998,168.619995); + ctx.bezierCurveTo(159.639999,168.619995,169.169998,172.119995,164.610001,172.119995); +ctx.moveTo(114.470001,201.119995); + ctx.bezierCurveTo(105.080002,199.960007,53.180000,208.119995,82.050003,228.119995); + ctx.bezierCurveTo(84.470001,229.800003,88.870003,215.649994,107.379997,213.619995); + ctx.bezierCurveTo(111.940002,213.119995,118.519997,201.619995,114.470001,201.119995); +ctx.moveTo(156.000000,166.619995); + ctx.bezierCurveTo(151.949997,167.619995,121.089996,167.800003,122.570000,168.119995); + ctx.bezierCurveTo(161.570007,176.619995,173.729996,166.619995,177.270004,164.119995); + ctx.bezierCurveTo(179.669998,162.429993,160.050003,165.619995,156.000000,166.619995); +ctx.moveTo(128.139999,180.119995); + ctx.bezierCurveTo(127.709999,179.270004,116.550003,182.029999,110.919998,182.619995); + ctx.bezierCurveTo(87.120003,185.119995,75.760002,188.360001,80.029999,193.619995); + ctx.bezierCurveTo(81.330002,195.229996,71.919998,196.119995,80.529999,200.619995); + ctx.bezierCurveTo(81.949997,201.360001,71.919998,207.619995,109.910004,198.619995); + ctx.bezierCurveTo(114.760002,197.470001,131.690002,187.119995,128.139999,180.119995); +ctx.moveTo(134.220001,172.619995); + ctx.bezierCurveTo(134.559998,172.000000,118.010002,168.119995,118.010002,168.119995); + ctx.bezierCurveTo(118.010002,168.119995,79.519997,168.119995,91.169998,177.119995); + ctx.bezierCurveTo(91.570000,177.429993,70.910004,187.619995,103.830002,182.119995); + ctx.bezierCurveTo(107.860001,181.449997,129.660004,181.119995,134.220001,172.619995); +ctx.moveTo(203.100006,194.619995); + ctx.bezierCurveTo(205.070007,184.899994,201.850006,183.809998,199.559998,187.119995); + ctx.bezierCurveTo(197.259995,190.429993,195.910004,197.610001,196.009995,197.119995); + ctx.bezierCurveTo(202.600006,165.619995,188.210007,184.309998,189.429993,188.119995); + ctx.bezierCurveTo(195.500000,207.119995,166.130005,253.619995,166.130005,253.619995); + ctx.bezierCurveTo(166.130005,253.619995,198.149994,219.050003,203.100006,194.619995); +ctx.moveTo(126.620003,78.120003); + ctx.bezierCurveTo(122.059998,79.120003,118.519997,81.620003,126.120003,83.620003); + ctx.bezierCurveTo(133.710007,85.620003,131.179993,77.120003,126.620003,78.120003); +ctx.fill(); +ctx.stroke(); + + + + +ctx.fillStyle='rgb(255,246,227)'; +ctx.strokeStyle='none'; +ctx.lineWidth='1'; +ctx.beginPath(); +ctx.moveTo(363.730011,85.730003); + ctx.bezierCurveTo(359.269989,86.290001,355.230011,86.730003,354.230011,81.230003); + ctx.bezierCurveTo(353.230011,75.730003,355.730011,73.730003,363.230011,75.730003); + ctx.bezierCurveTo(370.730011,77.730003,375.730011,84.230003,363.730011,85.730003); +ctx.moveTo(327.230011,89.230003); + ctx.bezierCurveTo(327.230011,89.230003,308.510010,93.650002,325.730011,80.730003); + ctx.bezierCurveTo(333.730011,74.730003,334.230011,79.730003,334.730011,82.730003); + ctx.bezierCurveTo(335.480011,87.199997,327.230011,89.230003,327.230011,89.230003); +ctx.moveTo(384.230011,48.730000); + ctx.bezierCurveTo(375.880005,47.060001,376.230011,42.230000,385.230011,40.230000); + ctx.bezierCurveTo(386.700012,39.910000,389.230011,49.730000,384.230011,48.730000); +ctx.moveTo(389.230011,48.730000); + ctx.bezierCurveTo(391.730011,48.230000,395.730011,49.230000,396.230011,52.730000); + ctx.bezierCurveTo(396.730011,56.230000,392.730011,58.230000,390.230011,56.230000); + ctx.bezierCurveTo(387.730011,54.230000,386.730011,49.230000,389.230011,48.730000); +ctx.moveTo(383.230011,59.730000); + ctx.bezierCurveTo(385.730011,58.730000,393.230011,60.230000,392.730011,63.230000); + ctx.bezierCurveTo(392.230011,66.230003,386.230011,66.730003,383.730011,65.230003); + ctx.bezierCurveTo(381.230011,63.730000,380.730011,60.730000,383.230011,59.730000); +ctx.moveTo(384.230011,77.230003); + ctx.bezierCurveTo(387.230011,74.730003,390.730011,77.230003,391.730011,78.730003); + ctx.bezierCurveTo(392.730011,80.230003,387.730011,82.230003,386.230011,82.730003); + ctx.bezierCurveTo(384.730011,83.230003,381.230011,79.730003,384.230011,77.230003); +ctx.moveTo(395.730011,40.230000); + ctx.bezierCurveTo(395.730011,40.230000,399.730011,40.230000,398.730011,41.730000); + ctx.bezierCurveTo(397.730011,43.230000,394.730011,43.230000,394.730011,43.230000); +ctx.moveTo(401.730011,49.230000); + ctx.bezierCurveTo(401.730011,49.230000,405.730011,49.230000,404.730011,50.730000); + ctx.bezierCurveTo(403.730011,52.230000,400.730011,52.230000,400.730011,52.230000); +ctx.moveTo(369.230011,97.230003); + ctx.bezierCurveTo(369.230011,97.230003,374.230011,99.230003,373.230011,100.730003); + ctx.bezierCurveTo(372.230011,102.230003,370.730011,104.730003,367.230011,101.230003); + ctx.bezierCurveTo(363.730011,97.730003,369.230011,97.230003,369.230011,97.230003); +ctx.moveTo(355.730011,116.730003); + ctx.bezierCurveTo(358.730011,114.230003,362.230011,116.730003,363.230011,118.230003); + ctx.bezierCurveTo(364.230011,119.730003,359.230011,121.730003,357.730011,122.230003); + ctx.bezierCurveTo(356.230011,122.730003,352.730011,119.230003,355.730011,116.730003); +ctx.moveTo(357.730011,106.730003); + ctx.bezierCurveTo(360.730011,104.230003,363.230011,107.730003,364.230011,109.230003); + ctx.bezierCurveTo(365.230011,110.730003,361.230011,111.730003,359.730011,112.230003); + ctx.bezierCurveTo(358.230011,112.730003,354.730011,109.230003,357.730011,106.730003); +ctx.moveTo(340.730011,73.230003); + ctx.bezierCurveTo(337.160004,73.430000,331.230011,71.730003,340.230011,65.730003); + ctx.bezierCurveTo(348.549988,60.189999,348.230011,61.730000,348.730011,64.730003); + ctx.bezierCurveTo(349.480011,69.199997,344.299988,73.040001,340.730011,73.230003); +ctx.moveTo(310.230011,82.230003); + ctx.bezierCurveTo(310.230011,82.230003,306.730011,79.230003,313.730011,73.230003); + ctx.bezierCurveTo(321.329987,66.730003,320.230011,69.230003,320.730011,72.230003); + ctx.bezierCurveTo(321.480011,76.699997,310.230011,82.230003,310.230011,82.230003); +ctx.moveTo(341.230011,55.730000); + ctx.bezierCurveTo(341.230011,55.730000,347.230011,54.730000,346.230011,56.230000); + ctx.bezierCurveTo(345.230011,57.730000,342.730011,63.230000,339.230011,59.730000); + ctx.bezierCurveTo(335.730011,56.230000,341.230011,55.730000,341.230011,55.730000); +ctx.moveTo(374.730011,86.230003); + ctx.bezierCurveTo(376.109985,86.230003,377.230011,87.360001,377.230011,88.730003); + ctx.bezierCurveTo(377.230011,90.110001,376.109985,91.230003,374.730011,91.230003); + ctx.bezierCurveTo(373.359985,91.230003,372.230011,90.110001,372.230011,88.730003); + ctx.bezierCurveTo(372.230011,87.360001,373.359985,86.230003,374.730011,86.230003); +ctx.moveTo(369.730011,110.730003); + ctx.bezierCurveTo(371.109985,110.730003,372.230011,111.860001,372.230011,113.230003); + ctx.bezierCurveTo(372.230011,114.610001,371.109985,115.730003,369.730011,115.730003); + ctx.bezierCurveTo(368.359985,115.730003,367.230011,114.610001,367.230011,113.230003); + ctx.bezierCurveTo(367.230011,111.860001,368.359985,110.730003,369.730011,110.730003); +ctx.moveTo(365.730011,120.730003); + ctx.bezierCurveTo(367.109985,120.730003,368.230011,121.860001,368.230011,123.230003); + ctx.bezierCurveTo(368.230011,124.610001,367.109985,125.730003,365.730011,125.730003); + ctx.bezierCurveTo(364.359985,125.730003,363.230011,124.610001,363.230011,123.230003); + ctx.bezierCurveTo(363.230011,121.860001,364.359985,120.730003,365.730011,120.730003); +ctx.moveTo(349.730011,127.230003); + ctx.bezierCurveTo(351.109985,127.230003,352.230011,128.360001,352.230011,129.729996); + ctx.bezierCurveTo(352.230011,131.110001,351.109985,132.229996,349.730011,132.229996); + ctx.bezierCurveTo(348.359985,132.229996,347.230011,131.110001,347.230011,129.729996); + ctx.bezierCurveTo(347.230011,128.360001,348.359985,127.230003,349.730011,127.230003); +ctx.moveTo(358.230011,128.729996); + ctx.bezierCurveTo(359.609985,128.729996,362.230011,130.860001,362.230011,132.229996); + ctx.bezierCurveTo(362.230011,133.610001,359.609985,133.729996,358.230011,133.729996); + ctx.bezierCurveTo(356.859985,133.729996,355.730011,132.610001,355.730011,131.229996); + ctx.bezierCurveTo(355.730011,129.860001,356.859985,128.729996,358.230011,128.729996); +ctx.moveTo(382.230011,89.730003); + ctx.bezierCurveTo(383.609985,89.730003,384.730011,90.860001,384.730011,92.230003); + ctx.bezierCurveTo(384.730011,93.610001,383.609985,94.730003,382.230011,94.730003); + ctx.bezierCurveTo(380.859985,94.730003,379.730011,93.610001,379.730011,92.230003); + ctx.bezierCurveTo(379.730011,90.860001,380.859985,89.730003,382.230011,89.730003); +ctx.moveTo(395.730011,66.230003); + ctx.bezierCurveTo(397.109985,66.230003,398.230011,67.360001,398.230011,68.730003); + ctx.bezierCurveTo(398.230011,70.110001,397.109985,71.230003,395.730011,71.230003); + ctx.bezierCurveTo(394.359985,71.230003,393.230011,70.110001,393.230011,68.730003); + ctx.bezierCurveTo(393.230011,67.360001,394.359985,66.230003,395.730011,66.230003); +ctx.moveTo(300.730011,74.230003); + ctx.bezierCurveTo(303.049988,75.160004,314.230011,67.730003,310.730011,66.730003); + ctx.bezierCurveTo(307.230011,65.730003,298.230011,73.230003,300.730011,74.230003); +ctx.moveTo(319.730011,61.230000); + ctx.bezierCurveTo(322.230011,61.730000,329.730011,58.730000,326.230011,57.730000); + ctx.bezierCurveTo(322.730011,56.730000,317.089996,60.709999,319.730011,61.230000); +ctx.moveTo(271.730011,91.730003); + ctx.bezierCurveTo(277.230011,88.730003,292.730011,81.230003,285.230011,82.230003); + ctx.bezierCurveTo(277.730011,83.230003,267.010010,94.309998,271.730011,91.730003); +ctx.moveTo(364.230011,42.230000); + ctx.bezierCurveTo(366.730011,42.730000,374.230011,39.730000,370.730011,38.730000); + ctx.bezierCurveTo(367.230011,37.730000,361.589996,41.709999,364.230011,42.230000); +ctx.moveTo(292.230011,78.730003); + ctx.bezierCurveTo(294.730011,79.230003,299.730011,76.730003,296.230011,75.730003); + ctx.bezierCurveTo(292.730011,74.730003,289.589996,78.209999,292.230011,78.730003); +ctx.moveTo(355.230011,141.229996); + ctx.bezierCurveTo(356.609985,141.229996,357.730011,142.860001,357.730011,144.229996); + ctx.bezierCurveTo(357.730011,145.610001,357.109985,145.729996,355.730011,145.729996); + ctx.bezierCurveTo(354.359985,145.729996,353.230011,144.610001,353.230011,143.229996); + ctx.bezierCurveTo(353.230011,141.860001,353.859985,141.229996,355.230011,141.229996); +ctx.moveTo(347.730011,140.729996); + ctx.bezierCurveTo(349.109985,140.729996,351.230011,141.360001,351.230011,142.729996); + ctx.bezierCurveTo(351.230011,144.110001,348.609985,143.729996,347.230011,143.729996); + ctx.bezierCurveTo(345.859985,143.729996,344.730011,142.610001,344.730011,141.229996); + ctx.bezierCurveTo(344.730011,139.860001,346.359985,140.729996,347.730011,140.729996); +ctx.moveTo(349.730011,155.229996); + ctx.bezierCurveTo(351.109985,155.229996,353.730011,157.360001,353.730011,158.729996); + ctx.bezierCurveTo(353.730011,160.110001,351.109985,160.229996,349.730011,160.229996); + ctx.bezierCurveTo(348.359985,160.229996,347.230011,159.110001,347.230011,157.729996); + ctx.bezierCurveTo(347.230011,156.360001,348.359985,155.229996,349.730011,155.229996); +ctx.moveTo(337.730011,175.729996); + ctx.bezierCurveTo(341.730011,174.729996,341.730011,176.729996,342.730011,180.229996); + ctx.bezierCurveTo(343.730011,183.729996,350.799988,195.110001,339.230011,181.229996); + ctx.bezierCurveTo(336.730011,178.229996,333.730011,176.729996,337.730011,175.729996); +ctx.moveTo(349.730011,187.729996); + ctx.bezierCurveTo(351.109985,187.729996,352.230011,188.860001,352.230011,190.229996); + ctx.bezierCurveTo(352.230011,191.610001,351.109985,192.729996,349.730011,192.729996); + ctx.bezierCurveTo(348.359985,192.729996,347.230011,191.610001,347.230011,190.229996); + ctx.bezierCurveTo(347.230011,188.860001,348.359985,187.729996,349.730011,187.729996); +ctx.moveTo(352.230011,196.729996); + ctx.bezierCurveTo(353.609985,196.729996,354.730011,197.860001,354.730011,199.229996); + ctx.bezierCurveTo(354.730011,200.610001,353.609985,201.729996,352.230011,201.729996); + ctx.bezierCurveTo(350.859985,201.729996,349.730011,200.610001,349.730011,199.229996); + ctx.bezierCurveTo(349.730011,197.860001,350.859985,196.729996,352.230011,196.729996); +ctx.moveTo(352.399994,205.729996); + ctx.bezierCurveTo(353.769989,205.729996,355.730011,208.860001,355.730011,210.229996); + ctx.bezierCurveTo(355.730011,211.610001,354.609985,212.729996,353.230011,212.729996); + ctx.bezierCurveTo(351.859985,212.729996,349.070007,211.110001,349.070007,209.729996); + ctx.bezierCurveTo(349.070007,208.360001,351.019989,205.729996,352.399994,205.729996); +ctx.moveTo(353.730011,221.729996); + ctx.bezierCurveTo(355.109985,221.729996,354.730011,221.860001,354.730011,223.229996); + ctx.bezierCurveTo(354.730011,224.610001,354.609985,223.729996,353.230011,223.729996); + ctx.bezierCurveTo(351.859985,223.729996,352.230011,224.610001,352.230011,223.229996); + ctx.bezierCurveTo(352.230011,221.860001,352.359985,221.729996,353.730011,221.729996); +ctx.moveTo(340.230011,188.729996); + ctx.bezierCurveTo(341.609985,188.729996,341.230011,188.860001,341.230011,190.229996); + ctx.bezierCurveTo(341.230011,191.610001,341.109985,190.729996,339.730011,190.729996); + ctx.bezierCurveTo(338.359985,190.729996,338.730011,191.610001,338.730011,190.229996); + ctx.bezierCurveTo(338.730011,188.860001,338.859985,188.729996,340.230011,188.729996); +ctx.moveTo(343.230011,201.229996); + ctx.bezierCurveTo(344.609985,201.229996,344.230011,201.360001,344.230011,202.729996); + ctx.bezierCurveTo(344.230011,204.110001,344.440002,207.729996,343.070007,207.729996); + ctx.bezierCurveTo(341.690002,207.729996,341.730011,204.110001,341.730011,202.729996); + ctx.bezierCurveTo(341.730011,201.360001,341.859985,201.229996,343.230011,201.229996); +ctx.moveTo(346.730011,215.229996); + ctx.bezierCurveTo(348.109985,215.229996,347.730011,215.360001,347.730011,216.729996); + ctx.bezierCurveTo(347.730011,218.110001,347.609985,217.229996,346.230011,217.229996); + ctx.bezierCurveTo(344.859985,217.229996,345.230011,218.110001,345.230011,216.729996); + ctx.bezierCurveTo(345.230011,215.360001,345.359985,215.229996,346.730011,215.229996); +ctx.moveTo(340.570007,228.729996); + ctx.bezierCurveTo(341.940002,228.729996,341.730011,228.860001,341.730011,230.229996); + ctx.bezierCurveTo(341.730011,231.610001,341.440002,230.729996,340.070007,230.729996); + ctx.bezierCurveTo(338.690002,230.729996,339.230011,231.610001,339.230011,230.229996); + ctx.bezierCurveTo(339.230011,228.860001,339.190002,228.729996,340.570007,228.729996); +ctx.moveTo(349.399994,232.070007); + ctx.bezierCurveTo(350.769989,232.070007,352.070007,234.020004,352.070007,235.399994); + ctx.bezierCurveTo(352.070007,236.770004,349.109985,239.229996,347.730011,239.229996); + ctx.bezierCurveTo(346.359985,239.229996,346.730011,240.110001,346.730011,238.729996); + ctx.bezierCurveTo(346.730011,237.360001,348.019989,232.070007,349.399994,232.070007); +ctx.moveTo(343.730011,246.399994); + ctx.bezierCurveTo(345.109985,246.399994,347.399994,246.020004,347.399994,247.399994); + ctx.bezierCurveTo(347.399994,248.770004,344.109985,251.229996,342.730011,251.229996); + ctx.bezierCurveTo(341.359985,251.229996,341.730011,252.110001,341.730011,250.729996); + ctx.bezierCurveTo(341.730011,249.360001,342.359985,246.399994,343.730011,246.399994); +ctx.moveTo(335.230011,239.229996); + ctx.bezierCurveTo(336.609985,239.229996,336.230011,239.360001,336.230011,240.729996); + ctx.bezierCurveTo(336.230011,242.110001,336.109985,241.229996,334.730011,241.229996); + ctx.bezierCurveTo(333.359985,241.229996,333.730011,242.110001,333.730011,240.729996); + ctx.bezierCurveTo(333.730011,239.360001,333.859985,239.229996,335.230011,239.229996); +ctx.moveTo(332.730011,258.399994); + ctx.bezierCurveTo(334.109985,258.399994,335.399994,260.019989,335.399994,261.399994); + ctx.bezierCurveTo(335.399994,262.769989,333.109985,262.230011,331.730011,262.230011); + ctx.bezierCurveTo(330.359985,262.230011,330.730011,263.109985,330.730011,261.730011); + ctx.bezierCurveTo(330.730011,260.359985,331.359985,258.399994,332.730011,258.399994); +ctx.moveTo(324.399994,263.730011); + ctx.bezierCurveTo(325.769989,263.730011,325.070007,265.359985,325.070007,266.730011); + ctx.bezierCurveTo(325.070007,268.109985,320.109985,271.230011,318.730011,271.230011); + ctx.bezierCurveTo(317.359985,271.230011,317.730011,272.109985,317.730011,270.730011); + ctx.bezierCurveTo(317.730011,269.359985,323.019989,263.730011,324.399994,263.730011); +ctx.moveTo(325.230011,247.729996); + ctx.bezierCurveTo(326.609985,247.729996,326.230011,247.860001,326.230011,249.229996); + ctx.bezierCurveTo(326.230011,250.610001,326.109985,249.729996,324.730011,249.729996); + ctx.bezierCurveTo(323.359985,249.729996,323.730011,250.610001,323.730011,249.229996); + ctx.bezierCurveTo(323.730011,247.860001,323.859985,247.729996,325.230011,247.729996); +ctx.moveTo(313.230011,256.230011); + ctx.bezierCurveTo(314.609985,256.230011,319.070007,258.019989,319.070007,259.399994); + ctx.bezierCurveTo(319.070007,260.769989,313.440002,263.070007,312.070007,263.070007); + ctx.bezierCurveTo(310.690002,263.070007,309.730011,260.769989,309.730011,259.399994); + ctx.bezierCurveTo(309.730011,258.019989,311.859985,256.230011,313.230011,256.230011); +ctx.moveTo(300.230011,260.730011); + ctx.bezierCurveTo(301.609985,260.730011,301.230011,260.859985,301.230011,262.230011); + ctx.bezierCurveTo(301.230011,263.609985,301.109985,262.730011,299.730011,262.730011); + ctx.bezierCurveTo(298.359985,262.730011,298.730011,263.609985,298.730011,262.230011); + ctx.bezierCurveTo(298.730011,260.859985,298.859985,260.730011,300.230011,260.730011); +ctx.moveTo(308.230011,272.730011); + ctx.bezierCurveTo(309.609985,272.730011,309.230011,272.859985,309.230011,274.230011); + ctx.bezierCurveTo(309.230011,275.609985,309.109985,274.730011,307.730011,274.730011); + ctx.bezierCurveTo(306.359985,274.730011,306.730011,275.609985,306.730011,274.230011); + ctx.bezierCurveTo(306.730011,272.859985,306.859985,272.730011,308.230011,272.730011); +ctx.moveTo(305.230011,273.730011); + ctx.bezierCurveTo(306.609985,273.730011,306.230011,273.859985,306.230011,275.230011); + ctx.bezierCurveTo(306.230011,276.609985,306.109985,275.730011,304.730011,275.730011); + ctx.bezierCurveTo(303.359985,275.730011,303.730011,276.609985,303.730011,275.230011); + ctx.bezierCurveTo(303.730011,273.859985,303.859985,273.730011,305.230011,273.730011); +ctx.moveTo(293.730011,274.070007); + ctx.bezierCurveTo(294.649994,274.070007,295.730011,275.480011,295.730011,276.399994); + ctx.bezierCurveTo(295.730011,277.320007,295.649994,276.730011,294.730011,276.730011); + ctx.bezierCurveTo(293.820007,276.730011,291.399994,277.980011,291.399994,277.070007); + ctx.bezierCurveTo(291.399994,276.149994,292.820007,274.070007,293.730011,274.070007); +ctx.moveTo(296.730011,276.730011); + ctx.bezierCurveTo(297.649994,276.730011,297.399994,276.820007,297.399994,277.730011); + ctx.bezierCurveTo(297.399994,278.649994,297.320007,278.070007,296.399994,278.070007); + ctx.bezierCurveTo(295.480011,278.070007,295.730011,278.649994,295.730011,277.730011); + ctx.bezierCurveTo(295.730011,276.820007,295.820007,276.730011,296.730011,276.730011); +ctx.moveTo(291.399994,263.730011); + ctx.bezierCurveTo(292.320007,263.730011,293.730011,267.149994,293.730011,268.070007); + ctx.bezierCurveTo(293.730011,268.980011,290.649994,268.730011,289.730011,268.730011); + ctx.bezierCurveTo(288.820007,268.730011,287.399994,265.980011,287.399994,265.070007); + ctx.bezierCurveTo(287.399994,264.149994,290.480011,263.730011,291.399994,263.730011); +ctx.moveTo(280.070007,274.730011); + ctx.bezierCurveTo(281.440002,274.730011,281.230011,274.859985,281.230011,276.230011); + ctx.bezierCurveTo(281.230011,277.609985,280.940002,276.730011,279.570007,276.730011); + ctx.bezierCurveTo(278.190002,276.730011,278.730011,277.609985,278.730011,276.230011); + ctx.bezierCurveTo(278.730011,274.859985,278.690002,274.730011,280.070007,274.730011); +ctx.moveTo(277.070007,267.730011); + ctx.bezierCurveTo(278.440002,267.730011,276.399994,271.019989,276.399994,272.399994); + ctx.bezierCurveTo(276.399994,273.769989,271.940002,274.230011,270.570007,274.230011); + ctx.bezierCurveTo(269.190002,274.230011,271.730011,272.440002,271.730011,271.070007); + ctx.bezierCurveTo(271.730011,269.690002,275.690002,267.730011,277.070007,267.730011); +ctx.moveTo(52.230000,84.900002); + ctx.bezierCurveTo(56.700001,85.459999,60.730000,85.900002,61.730000,80.400002); + ctx.bezierCurveTo(62.730000,74.900002,60.230000,72.900002,52.730000,74.900002); + ctx.bezierCurveTo(45.230000,76.900002,40.230000,83.400002,52.230000,84.900002); +ctx.moveTo(88.730003,88.400002); + ctx.bezierCurveTo(88.730003,88.400002,107.449997,92.809998,90.230003,79.900002); + ctx.bezierCurveTo(82.230003,73.900002,81.730003,78.900002,81.230003,81.900002); + ctx.bezierCurveTo(80.489998,86.370003,88.730003,88.400002,88.730003,88.400002); +ctx.moveTo(31.730000,47.900002); + ctx.bezierCurveTo(40.080002,46.230000,39.730000,41.400002,30.730000,39.400002); + ctx.bezierCurveTo(29.270000,39.070000,26.730000,48.900002,31.730000,47.900002); +ctx.moveTo(26.730000,47.900002); + ctx.bezierCurveTo(24.230000,47.400002,20.230000,48.400002,19.730000,51.900002); + ctx.bezierCurveTo(19.230000,55.400002,23.230000,57.400002,25.730000,55.400002); + ctx.bezierCurveTo(28.230000,53.400002,29.230000,48.400002,26.730000,47.900002); +ctx.moveTo(32.730000,58.900002); + ctx.bezierCurveTo(30.230000,57.900002,22.730000,59.400002,23.230000,62.400002); + ctx.bezierCurveTo(23.730000,65.400002,29.730000,65.900002,32.230000,64.400002); + ctx.bezierCurveTo(34.730000,62.900002,35.230000,59.900002,32.730000,58.900002); +ctx.moveTo(31.730000,76.400002); + ctx.bezierCurveTo(28.730000,73.900002,25.230000,76.400002,24.230000,77.900002); + ctx.bezierCurveTo(23.230000,79.400002,28.230000,81.400002,29.730000,81.900002); + ctx.bezierCurveTo(31.230000,82.400002,34.730000,78.900002,31.730000,76.400002); +ctx.moveTo(20.230000,39.400002); + ctx.bezierCurveTo(20.230000,39.400002,16.230000,39.400002,17.230000,40.900002); + ctx.bezierCurveTo(18.230000,42.400002,21.230000,42.400002,21.230000,42.400002); +ctx.moveTo(14.230000,48.400002); + ctx.bezierCurveTo(14.230000,48.400002,10.230000,48.400002,11.230000,49.900002); + ctx.bezierCurveTo(12.230000,51.400002,15.230000,51.400002,15.230000,51.400002); +ctx.moveTo(46.730000,96.400002); + ctx.bezierCurveTo(46.730000,96.400002,41.730000,98.400002,42.730000,99.900002); + ctx.bezierCurveTo(43.730000,101.400002,45.230000,103.900002,48.730000,100.400002); + ctx.bezierCurveTo(52.230000,96.900002,46.730000,96.400002,46.730000,96.400002); +ctx.moveTo(60.230000,115.900002); + ctx.bezierCurveTo(57.230000,113.400002,53.730000,115.900002,52.730000,117.400002); + ctx.bezierCurveTo(51.730000,118.900002,56.730000,120.900002,58.230000,121.400002); + ctx.bezierCurveTo(59.730000,121.900002,63.230000,118.400002,60.230000,115.900002); +ctx.moveTo(58.230000,105.900002); + ctx.bezierCurveTo(55.230000,103.400002,52.730000,106.900002,51.730000,108.400002); + ctx.bezierCurveTo(50.730000,109.900002,54.730000,110.900002,56.230000,111.400002); + ctx.bezierCurveTo(57.730000,111.900002,61.230000,108.400002,58.230000,105.900002); +ctx.moveTo(75.230003,72.400002); + ctx.bezierCurveTo(78.800003,72.599998,84.730003,70.900002,75.730003,64.900002); + ctx.bezierCurveTo(67.410004,59.349998,67.730003,60.900002,67.230003,63.900002); + ctx.bezierCurveTo(66.489998,68.370003,71.660004,72.199997,75.230003,72.400002); +ctx.moveTo(105.730003,81.400002); + ctx.bezierCurveTo(105.730003,81.400002,109.230003,78.400002,102.230003,72.400002); + ctx.bezierCurveTo(94.639999,65.889999,95.730003,68.400002,95.230003,71.400002); + ctx.bezierCurveTo(94.489998,75.870003,105.730003,81.400002,105.730003,81.400002); +ctx.moveTo(74.730003,54.900002); + ctx.bezierCurveTo(74.730003,54.900002,68.730003,53.900002,69.730003,55.400002); + ctx.bezierCurveTo(70.730003,56.900002,73.230003,62.400002,76.730003,58.900002); + ctx.bezierCurveTo(80.230003,55.400002,74.730003,54.900002,74.730003,54.900002); +ctx.moveTo(41.230000,85.400002); + ctx.bezierCurveTo(39.860001,85.400002,38.730000,86.529999,38.730000,87.900002); + ctx.bezierCurveTo(38.730000,89.279999,39.860001,90.400002,41.230000,90.400002); + ctx.bezierCurveTo(42.610001,90.400002,43.730000,89.279999,43.730000,87.900002); + ctx.bezierCurveTo(43.730000,86.529999,42.610001,85.400002,41.230000,85.400002); +ctx.moveTo(46.230000,109.900002); + ctx.bezierCurveTo(44.860001,109.900002,43.730000,111.029999,43.730000,112.400002); + ctx.bezierCurveTo(43.730000,113.779999,44.860001,114.900002,46.230000,114.900002); + ctx.bezierCurveTo(47.610001,114.900002,48.730000,113.779999,48.730000,112.400002); + ctx.bezierCurveTo(48.730000,111.029999,47.610001,109.900002,46.230000,109.900002); +ctx.moveTo(50.230000,119.900002); + ctx.bezierCurveTo(48.860001,119.900002,47.730000,121.029999,47.730000,122.400002); + ctx.bezierCurveTo(47.730000,123.779999,48.860001,124.900002,50.230000,124.900002); + ctx.bezierCurveTo(51.610001,124.900002,52.730000,123.779999,52.730000,122.400002); + ctx.bezierCurveTo(52.730000,121.029999,51.610001,119.900002,50.230000,119.900002); +ctx.moveTo(66.230003,126.400002); + ctx.bezierCurveTo(64.860001,126.400002,63.730000,127.529999,63.730000,128.899994); + ctx.bezierCurveTo(63.730000,130.279999,64.860001,131.399994,66.230003,131.399994); + ctx.bezierCurveTo(67.610001,131.399994,68.730003,130.279999,68.730003,128.899994); + ctx.bezierCurveTo(68.730003,127.529999,67.610001,126.400002,66.230003,126.400002); +ctx.moveTo(57.730000,127.900002); + ctx.bezierCurveTo(56.360001,127.900002,53.730000,130.029999,53.730000,131.399994); + ctx.bezierCurveTo(53.730000,132.779999,56.360001,132.899994,57.730000,132.899994); + ctx.bezierCurveTo(59.110001,132.899994,60.230000,131.779999,60.230000,130.399994); + ctx.bezierCurveTo(60.230000,129.029999,59.110001,127.900002,57.730000,127.900002); +ctx.moveTo(33.730000,88.900002); + ctx.bezierCurveTo(32.360001,88.900002,31.230000,90.029999,31.230000,91.400002); + ctx.bezierCurveTo(31.230000,92.779999,32.360001,93.900002,33.730000,93.900002); + ctx.bezierCurveTo(35.110001,93.900002,36.230000,92.779999,36.230000,91.400002); + ctx.bezierCurveTo(36.230000,90.029999,35.110001,88.900002,33.730000,88.900002); +ctx.moveTo(20.230000,65.400002); + ctx.bezierCurveTo(18.860001,65.400002,17.730000,66.529999,17.730000,67.900002); + ctx.bezierCurveTo(17.730000,69.279999,18.860001,70.400002,20.230000,70.400002); + ctx.bezierCurveTo(21.610001,70.400002,22.730000,69.279999,22.730000,67.900002); + ctx.bezierCurveTo(22.730000,66.529999,21.610001,65.400002,20.230000,65.400002); +ctx.moveTo(115.230003,73.400002); + ctx.bezierCurveTo(112.910004,74.330002,101.730003,66.900002,105.230003,65.900002); + ctx.bezierCurveTo(108.730003,64.900002,117.730003,72.400002,115.230003,73.400002); +ctx.moveTo(96.230003,60.400002); + ctx.bezierCurveTo(93.730003,60.900002,86.230003,57.900002,89.730003,56.900002); + ctx.bezierCurveTo(93.230003,55.900002,98.870003,59.869999,96.230003,60.400002); +ctx.moveTo(144.229996,90.900002); + ctx.bezierCurveTo(138.729996,87.900002,123.230003,80.400002,130.729996,81.400002); + ctx.bezierCurveTo(138.229996,82.400002,148.960007,93.480003,144.229996,90.900002); +ctx.moveTo(51.730000,41.400002); + ctx.bezierCurveTo(49.230000,41.900002,41.730000,38.900002,45.230000,37.900002); + ctx.bezierCurveTo(48.730000,36.900002,54.369999,40.869999,51.730000,41.400002); +ctx.moveTo(123.730003,77.900002); + ctx.bezierCurveTo(121.230003,78.400002,116.230003,75.900002,119.730003,74.900002); + ctx.bezierCurveTo(123.230003,73.900002,126.370003,77.370003,123.730003,77.900002); +ctx.moveTo(60.730000,140.399994); + ctx.bezierCurveTo(59.360001,140.399994,58.230000,142.029999,58.230000,143.399994); + ctx.bezierCurveTo(58.230000,144.779999,58.860001,144.899994,60.230000,144.899994); + ctx.bezierCurveTo(61.610001,144.899994,62.730000,143.779999,62.730000,142.399994); + ctx.bezierCurveTo(62.730000,141.029999,62.110001,140.399994,60.730000,140.399994); +ctx.moveTo(68.230003,139.899994); + ctx.bezierCurveTo(66.860001,139.899994,64.730003,140.529999,64.730003,141.899994); + ctx.bezierCurveTo(64.730003,143.279999,67.360001,142.899994,68.730003,142.899994); + ctx.bezierCurveTo(70.110001,142.899994,71.230003,141.779999,71.230003,140.399994); + ctx.bezierCurveTo(71.230003,139.029999,69.610001,139.899994,68.230003,139.899994); +ctx.moveTo(66.230003,154.399994); + ctx.bezierCurveTo(64.860001,154.399994,62.230000,156.529999,62.230000,157.899994); + ctx.bezierCurveTo(62.230000,159.279999,64.860001,159.399994,66.230003,159.399994); + ctx.bezierCurveTo(67.610001,159.399994,68.730003,158.279999,68.730003,156.899994); + ctx.bezierCurveTo(68.730003,155.529999,67.610001,154.399994,66.230003,154.399994); +ctx.moveTo(78.230003,174.899994); + ctx.bezierCurveTo(74.230003,173.899994,74.230003,175.899994,73.230003,179.399994); + ctx.bezierCurveTo(72.230003,182.899994,65.169998,194.279999,76.730003,180.399994); + ctx.bezierCurveTo(79.230003,177.399994,82.230003,175.899994,78.230003,174.899994); +ctx.moveTo(66.230003,186.899994); + ctx.bezierCurveTo(64.860001,186.899994,63.730000,188.020004,63.730000,189.399994); + ctx.bezierCurveTo(63.730000,190.770004,64.860001,191.899994,66.230003,191.899994); + ctx.bezierCurveTo(67.610001,191.899994,68.730003,190.770004,68.730003,189.399994); + ctx.bezierCurveTo(68.730003,188.020004,67.610001,186.899994,66.230003,186.899994); +ctx.moveTo(63.730000,195.899994); + ctx.bezierCurveTo(62.360001,195.899994,61.230000,197.020004,61.230000,198.399994); + ctx.bezierCurveTo(61.230000,199.770004,62.360001,200.899994,63.730000,200.899994); + ctx.bezierCurveTo(65.110001,200.899994,66.230003,199.770004,66.230003,198.399994); + ctx.bezierCurveTo(66.230003,197.020004,65.110001,195.899994,63.730000,195.899994); +ctx.moveTo(63.570000,204.899994); + ctx.bezierCurveTo(62.189999,204.899994,60.230000,208.020004,60.230000,209.399994); + ctx.bezierCurveTo(60.230000,210.770004,61.360001,211.899994,62.730000,211.899994); + ctx.bezierCurveTo(64.110001,211.899994,66.900002,210.270004,66.900002,208.899994); + ctx.bezierCurveTo(66.900002,207.520004,64.940002,204.899994,63.570000,204.899994); +ctx.moveTo(62.230000,220.899994); + ctx.bezierCurveTo(60.860001,220.899994,61.230000,221.020004,61.230000,222.399994); + ctx.bezierCurveTo(61.230000,223.770004,61.360001,222.899994,62.730000,222.899994); + ctx.bezierCurveTo(64.110001,222.899994,63.730000,223.770004,63.730000,222.399994); + ctx.bezierCurveTo(63.730000,221.020004,63.610001,220.899994,62.230000,220.899994); +ctx.moveTo(75.730003,187.899994); + ctx.bezierCurveTo(74.360001,187.899994,74.730003,188.020004,74.730003,189.399994); + ctx.bezierCurveTo(74.730003,190.770004,74.860001,189.899994,76.230003,189.899994); + ctx.bezierCurveTo(77.610001,189.899994,77.230003,190.770004,77.230003,189.399994); + ctx.bezierCurveTo(77.230003,188.020004,77.110001,187.899994,75.730003,187.899994); +ctx.moveTo(72.730003,200.399994); + ctx.bezierCurveTo(71.360001,200.399994,71.730003,200.520004,71.730003,201.899994); + ctx.bezierCurveTo(71.730003,203.270004,71.529999,206.899994,72.900002,206.899994); + ctx.bezierCurveTo(74.279999,206.899994,74.230003,203.270004,74.230003,201.899994); + ctx.bezierCurveTo(74.230003,200.520004,74.110001,200.399994,72.730003,200.399994); +ctx.moveTo(69.230003,214.399994); + ctx.bezierCurveTo(67.860001,214.399994,68.230003,214.520004,68.230003,215.899994); + ctx.bezierCurveTo(68.230003,217.270004,68.360001,216.399994,69.730003,216.399994); + ctx.bezierCurveTo(71.110001,216.399994,70.730003,217.270004,70.730003,215.899994); + ctx.bezierCurveTo(70.730003,214.520004,70.610001,214.399994,69.230003,214.399994); +ctx.moveTo(75.400002,227.899994); + ctx.bezierCurveTo(74.029999,227.899994,74.230003,228.020004,74.230003,229.399994); + ctx.bezierCurveTo(74.230003,230.770004,74.529999,229.899994,75.900002,229.899994); + ctx.bezierCurveTo(77.279999,229.899994,76.730003,230.770004,76.730003,229.399994); + ctx.bezierCurveTo(76.730003,228.020004,76.779999,227.899994,75.400002,227.899994); +ctx.moveTo(66.570000,231.229996); + ctx.bezierCurveTo(65.190002,231.229996,63.900002,233.190002,63.900002,234.570007); + ctx.bezierCurveTo(63.900002,235.940002,66.860001,238.399994,68.230003,238.399994); + ctx.bezierCurveTo(69.610001,238.399994,69.230003,239.270004,69.230003,237.899994); + ctx.bezierCurveTo(69.230003,236.520004,67.940002,231.229996,66.570000,231.229996); +ctx.moveTo(72.230003,245.570007); + ctx.bezierCurveTo(70.860001,245.570007,68.570000,245.190002,68.570000,246.570007); + ctx.bezierCurveTo(68.570000,247.940002,71.860001,250.399994,73.230003,250.399994); + ctx.bezierCurveTo(74.610001,250.399994,74.230003,251.270004,74.230003,249.899994); + ctx.bezierCurveTo(74.230003,248.520004,73.610001,245.570007,72.230003,245.570007); +ctx.moveTo(80.730003,238.399994); + ctx.bezierCurveTo(79.360001,238.399994,79.730003,238.520004,79.730003,239.899994); + ctx.bezierCurveTo(79.730003,241.270004,79.860001,240.399994,81.230003,240.399994); + ctx.bezierCurveTo(82.610001,240.399994,82.230003,241.270004,82.230003,239.899994); + ctx.bezierCurveTo(82.230003,238.520004,82.110001,238.399994,80.730003,238.399994); +ctx.moveTo(83.230003,257.570007); + ctx.bezierCurveTo(81.860001,257.570007,80.570000,259.190002,80.570000,260.570007); + ctx.bezierCurveTo(80.570000,261.940002,82.860001,261.399994,84.230003,261.399994); + ctx.bezierCurveTo(85.610001,261.399994,85.230003,262.269989,85.230003,260.899994); + ctx.bezierCurveTo(85.230003,259.519989,84.610001,257.570007,83.230003,257.570007); +ctx.moveTo(91.570000,262.899994); + ctx.bezierCurveTo(90.190002,262.899994,90.900002,264.519989,90.900002,265.899994); + ctx.bezierCurveTo(90.900002,267.269989,95.860001,270.399994,97.230003,270.399994); + ctx.bezierCurveTo(98.610001,270.399994,98.230003,271.269989,98.230003,269.899994); + ctx.bezierCurveTo(98.230003,268.519989,92.940002,262.899994,91.570000,262.899994); +ctx.moveTo(90.730003,246.899994); + ctx.bezierCurveTo(89.360001,246.899994,89.730003,247.020004,89.730003,248.399994); + ctx.bezierCurveTo(89.730003,249.770004,89.860001,248.899994,91.230003,248.899994); + ctx.bezierCurveTo(92.610001,248.899994,92.230003,249.770004,92.230003,248.399994); + ctx.bezierCurveTo(92.230003,247.020004,92.110001,246.899994,90.730003,246.899994); +ctx.moveTo(102.730003,255.399994); + ctx.bezierCurveTo(101.360001,255.399994,96.900002,257.190002,96.900002,258.570007); + ctx.bezierCurveTo(96.900002,259.940002,102.529999,262.230011,103.900002,262.230011); + ctx.bezierCurveTo(105.279999,262.230011,106.230003,259.940002,106.230003,258.570007); + ctx.bezierCurveTo(106.230003,257.190002,104.110001,255.399994,102.730003,255.399994); +ctx.moveTo(115.730003,259.899994); + ctx.bezierCurveTo(114.360001,259.899994,114.730003,260.019989,114.730003,261.399994); + ctx.bezierCurveTo(114.730003,262.769989,114.860001,261.899994,116.230003,261.899994); + ctx.bezierCurveTo(117.610001,261.899994,117.230003,262.769989,117.230003,261.399994); + ctx.bezierCurveTo(117.230003,260.019989,117.110001,259.899994,115.730003,259.899994); +ctx.moveTo(107.730003,271.899994); + ctx.bezierCurveTo(106.360001,271.899994,106.730003,272.019989,106.730003,273.399994); + ctx.bezierCurveTo(106.730003,274.769989,106.860001,273.899994,108.230003,273.899994); + ctx.bezierCurveTo(109.610001,273.899994,109.230003,274.769989,109.230003,273.399994); + ctx.bezierCurveTo(109.230003,272.019989,109.110001,271.899994,107.730003,271.899994); +ctx.moveTo(110.730003,272.899994); + ctx.bezierCurveTo(109.360001,272.899994,109.730003,273.019989,109.730003,274.399994); + ctx.bezierCurveTo(109.730003,275.769989,109.860001,274.899994,111.230003,274.899994); + ctx.bezierCurveTo(112.610001,274.899994,112.230003,275.769989,112.230003,274.399994); + ctx.bezierCurveTo(112.230003,273.019989,112.110001,272.899994,110.730003,272.899994); +ctx.moveTo(122.230003,273.230011); + ctx.bezierCurveTo(121.320000,273.230011,120.230003,274.649994,120.230003,275.570007); + ctx.bezierCurveTo(120.230003,276.480011,120.320000,275.899994,121.230003,275.899994); + ctx.bezierCurveTo(122.150002,275.899994,124.570000,277.149994,124.570000,276.230011); + ctx.bezierCurveTo(124.570000,275.320007,123.150002,273.230011,122.230003,273.230011); +ctx.moveTo(119.230003,275.899994); + ctx.bezierCurveTo(118.320000,275.899994,118.570000,275.980011,118.570000,276.899994); + ctx.bezierCurveTo(118.570000,277.820007,118.650002,277.230011,119.570000,277.230011); + ctx.bezierCurveTo(120.480003,277.230011,120.230003,277.820007,120.230003,276.899994); + ctx.bezierCurveTo(120.230003,275.980011,120.150002,275.899994,119.230003,275.899994); +ctx.moveTo(124.570000,262.899994); + ctx.bezierCurveTo(123.650002,262.899994,122.230003,266.320007,122.230003,267.230011); + ctx.bezierCurveTo(122.230003,268.149994,125.320000,267.899994,126.230003,267.899994); + ctx.bezierCurveTo(127.150002,267.899994,128.570007,265.149994,128.570007,264.230011); + ctx.bezierCurveTo(128.570007,263.320007,125.480003,262.899994,124.570000,262.899994); +ctx.moveTo(135.899994,273.899994); + ctx.bezierCurveTo(134.529999,273.899994,134.729996,274.019989,134.729996,275.399994); + ctx.bezierCurveTo(134.729996,276.769989,135.029999,275.899994,136.399994,275.899994); + ctx.bezierCurveTo(137.779999,275.899994,137.229996,276.769989,137.229996,275.399994); + ctx.bezierCurveTo(137.229996,274.019989,137.279999,273.899994,135.899994,273.899994); +ctx.moveTo(138.899994,266.899994); + ctx.bezierCurveTo(137.529999,266.899994,139.570007,270.190002,139.570007,271.570007); + ctx.bezierCurveTo(139.570007,272.940002,144.029999,273.399994,145.399994,273.399994); + ctx.bezierCurveTo(146.779999,273.399994,144.229996,271.609985,144.229996,270.230011); + ctx.bezierCurveTo(144.229996,268.859985,140.279999,266.899994,138.899994,266.899994); +ctx.moveTo(211.000000,134.800003); + ctx.bezierCurveTo(209.630005,134.800003,209.830002,134.929993,209.830002,136.300003); + ctx.bezierCurveTo(209.830002,137.679993,210.130005,136.800003,211.500000,136.800003); + ctx.bezierCurveTo(212.880005,136.800003,212.330002,137.679993,212.330002,136.300003); + ctx.bezierCurveTo(212.330002,134.929993,212.380005,134.800003,211.000000,134.800003); +ctx.moveTo(205.500000,134.800003); + ctx.bezierCurveTo(204.130005,134.800003,204.330002,134.929993,204.330002,136.300003); + ctx.bezierCurveTo(204.330002,137.679993,204.630005,136.800003,206.000000,136.800003); + ctx.bezierCurveTo(207.380005,136.800003,206.830002,137.679993,206.830002,136.300003); + ctx.bezierCurveTo(206.830002,134.929993,206.880005,134.800003,205.500000,134.800003); +ctx.moveTo(211.000000,143.800003); + ctx.bezierCurveTo(209.630005,143.800003,209.830002,143.929993,209.830002,145.300003); + ctx.bezierCurveTo(209.830002,146.679993,210.130005,145.800003,211.500000,145.800003); + ctx.bezierCurveTo(212.880005,145.800003,212.330002,146.679993,212.330002,145.300003); + ctx.bezierCurveTo(212.330002,143.929993,212.380005,143.800003,211.000000,143.800003); +ctx.moveTo(204.899994,143.699997); + ctx.bezierCurveTo(203.529999,143.699997,203.729996,143.830002,203.729996,145.199997); + ctx.bezierCurveTo(203.729996,146.580002,204.029999,145.699997,205.399994,145.699997); + ctx.bezierCurveTo(206.779999,145.699997,206.229996,146.580002,206.229996,145.199997); + ctx.bezierCurveTo(206.229996,143.830002,206.279999,143.699997,204.899994,143.699997); +ctx.moveTo(213.000000,154.300003); + ctx.bezierCurveTo(211.630005,154.300003,212.000000,155.429993,212.000000,156.800003); + ctx.bezierCurveTo(212.000000,158.179993,212.419998,161.300003,213.800003,161.300003); + ctx.bezierCurveTo(215.169998,161.300003,214.330002,157.179993,214.330002,155.800003); + ctx.bezierCurveTo(214.330002,154.429993,214.380005,154.300003,213.000000,154.300003); +ctx.moveTo(204.000000,154.300003); + ctx.bezierCurveTo(202.630005,154.300003,202.600006,155.529999,202.600006,156.899994); + ctx.bezierCurveTo(202.600006,158.279999,201.630005,161.500000,203.000000,161.500000); + ctx.bezierCurveTo(204.380005,161.500000,204.800003,157.679993,204.800003,156.300003); + ctx.bezierCurveTo(204.800003,154.929993,205.380005,154.300003,204.000000,154.300003); +ctx.fill(); +ctx.stroke(); + + + + +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/path.html b/CAAT/documentation/demos/demo24/path.html new file mode 100644 index 0000000..cda9687 --- /dev/null +++ b/CAAT/documentation/demos/demo24/path.html @@ -0,0 +1,226 @@ + + + + + + CAAT example: Compund Path + + + + + + +
    + + +
    + +
    +
    +

    Path Segments

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click on screen
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Build paths out of base primitives.
    • +
    • Combine paths to build a more complex one.
    • +
    • Set an actor to traverse a path in a given amount of time.
    • +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo24/pathtest.html b/CAAT/documentation/demos/demo24/pathtest.html new file mode 100644 index 0000000..d650f21 --- /dev/null +++ b/CAAT/documentation/demos/demo24/pathtest.html @@ -0,0 +1,132 @@ + + + + + + CAAT example: Multitouch + + + + + + +
    + + +
    + +
    +
    +

    Path Segments

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click on screen
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Build paths out of base primitives.
    • +
    • Combine paths to build a more complex one.
    • +
    • Set an actor to traverse a path in a given amount of time.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo25/dirtyrects.html b/CAAT/documentation/demos/demo25/dirtyrects.html new file mode 100644 index 0000000..9e7303e --- /dev/null +++ b/CAAT/documentation/demos/demo25/dirtyrects.html @@ -0,0 +1,259 @@ + + + + + + CAAT example: Compund Path + + + + + + +
     
    +
    + + +
    + +
    +
    +

    Path Segments

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click on screen
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Build paths out of base primitives.
    • +
    • Combine paths to build a more complex one.
    • +
    • Set an actor to traverse a path in a given amount of time.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo25/flipcards.html b/CAAT/documentation/demos/demo25/flipcards.html new file mode 100644 index 0000000..ea26846 --- /dev/null +++ b/CAAT/documentation/demos/demo25/flipcards.html @@ -0,0 +1,246 @@ + + + + + + CAAT example: Flip cards effect. + + + + + + +
    + + +
    + +
    +
    +

    Flip Card example.

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click cards to start the flip effect.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Manage compound behaviors.
    • +
    • Set correct behavior lifecycle listener.
    • +
    • Respond to mouse.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo26/hierarchy2.html b/CAAT/documentation/demos/demo26/hierarchy2.html new file mode 100644 index 0000000..8cbd526 --- /dev/null +++ b/CAAT/documentation/demos/demo26/hierarchy2.html @@ -0,0 +1,279 @@ + + + + + + CAAT example: Hierarchical affine transforms + + + + + + +
    + + +
    + +
    +
    +

    Hierarchy II

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • None.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Define child/parent relationship.
    • +
    • Convert coordinates between spaces, ie., from arm to screen.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo27/font.html b/CAAT/documentation/demos/demo27/font.html new file mode 100644 index 0000000..d3deaaa --- /dev/null +++ b/CAAT/documentation/demos/demo27/font.html @@ -0,0 +1,194 @@ + + + + + + CAAT example: CAAT.Font + CAAT.TextActor + + + + + + +
     
    +
     
    +
     
    +
     
    + + +
    + + +
    + +
    +
    +

    CAAT.Font

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Drag path handles.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Creating a CAAT.Font object. +
    • Make google fonts load and usable in a canvas +
    • Use CAAT.Font with CAAT.TextActor
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo28/paint.html b/CAAT/documentation/demos/demo28/paint.html new file mode 100644 index 0000000..a53b9be --- /dev/null +++ b/CAAT/documentation/demos/demo28/paint.html @@ -0,0 +1,174 @@ + + + + + + CAAT example: Paint + + + + + + +
    + + +
    + +
    +
    +

    Minimal Paint program

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Drag or touch events.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo29/layout2.html b/CAAT/documentation/demos/demo29/layout2.html new file mode 100644 index 0000000..ff70e90 --- /dev/null +++ b/CAAT/documentation/demos/demo29/layout2.html @@ -0,0 +1,391 @@ + + + + + CAAT example: Auto Layout + + + + + + + + + + + + +
    +
    +

    Automatic layout capabilities

    +
    +
    +

    This demo shows CAAT container's auto layout capabilities. Which are the foundation for CAAT's UI capabilities. +

    This demo features nested Containers with different layouts applied. Also a layd-out container's children + vertical and horizontal alignment are set randomly. +

    Current implementations include:

    +
      +
    • BorderLayout
    • +
    • GridLayout
    • +
    • BoxLayout
    • +
    +
    +
    +

    Controls:

    +
      +
    • Resize browser window to see animated auto layout.
    • +
    • Press +/- to add/remove new actors to the scene.
    • +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo3/sprites_org.html b/CAAT/documentation/demos/demo3/sprites_org.html new file mode 100644 index 0000000..827feab --- /dev/null +++ b/CAAT/documentation/demos/demo3/sprites_org.html @@ -0,0 +1,236 @@ + + + + + CAAT example: Sprites across a path + + + + + + +
    + + +
    + +
    +
    +

    Sprites on Path

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Click on screen to add more sprites.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Path Behaviors.
    • +
    • Path Behavior lifecycle.
    • +
    • CompoundImage management.
    • +
    • SpriteActor definition.
    • +
    • Dynamic sprite addition to the scene.
    • +
    • Gradient optimization by caching it as bitmap.
    • +
    • Avoid erasing the background since it's going to be overwritten by the background.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo30/fonts.html b/CAAT/documentation/demos/demo30/fonts.html new file mode 100644 index 0000000..b6f972f --- /dev/null +++ b/CAAT/documentation/demos/demo30/fonts.html @@ -0,0 +1,297 @@ + + + + + + CAAT example: Google Fonts + + + + + + +
     
    + +
    + + +
    + +
    +
    +

    CAAT.Foundation.UI.TextActor vs ctx.drawString

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • CAAT.Foundation.UI.TextActor mimics perfectly text drawn with drawString
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo31/dude.png b/CAAT/documentation/demos/demo31/dude.png new file mode 100644 index 0000000..af72820 Binary files /dev/null and b/CAAT/documentation/demos/demo31/dude.png differ diff --git a/CAAT/documentation/demos/demo31/sprites.html b/CAAT/documentation/demos/demo31/sprites.html new file mode 100644 index 0000000..7a77e60 --- /dev/null +++ b/CAAT/documentation/demos/demo31/sprites.html @@ -0,0 +1,282 @@ + + + + + + CAAT example: Sprite Animation Management + + + + + +
    + + +
    + +
    +
    +

    Sprite Animation Management

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Click on a character to select it.
    • +
    • Click on buttons to play different sprite animations.
    • +
    • Use cursors to trigger animations. +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Defining Sprite Animations. +
    • Setting up Sprite Animation callbacks. +
    • Keyboard bindings. +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo32/svgpath.html b/CAAT/documentation/demos/demo32/svgpath.html new file mode 100644 index 0000000..5baed55 --- /dev/null +++ b/CAAT/documentation/demos/demo32/svgpath.html @@ -0,0 +1,111 @@ + + + + + + CAAT example: SVG Path parser + + + + + + +
    + + +
    + +
    +
    +

    SVG Parser

    +
    +
    + +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Build paths from SVG representation.
    • +
    +
    +
    +
    +
    +
    + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo33/keyframing.html b/CAAT/documentation/demos/demo33/keyframing.html new file mode 100644 index 0000000..a5b2b6d --- /dev/null +++ b/CAAT/documentation/demos/demo33/keyframing.html @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + +
    + + +
    + +
    +
    +

    On-the-fly CSS3 Keyframing

    +
    +
    +
    ABCD
    +
    ABCD
    +
    ABCD
    +
    ABCD
    +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Click on screen
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Build paths from SVG representation.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/dragon/L_front_leg.png b/CAAT/documentation/demos/demo34/dragon/L_front_leg.png new file mode 100755 index 0000000..4a8b204 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_front_leg.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_front_thigh.png b/CAAT/documentation/demos/demo34/dragon/L_front_thigh.png new file mode 100755 index 0000000..5b691a8 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_front_thigh.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_rear_leg.png b/CAAT/documentation/demos/demo34/dragon/L_rear_leg.png new file mode 100755 index 0000000..fc00ab6 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_rear_leg.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_rear_thigh.png b/CAAT/documentation/demos/demo34/dragon/L_rear_thigh.png new file mode 100755 index 0000000..4c363aa Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_rear_thigh.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing01.png b/CAAT/documentation/demos/demo34/dragon/L_wing01.png new file mode 100755 index 0000000..3a12127 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing01.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing02.png b/CAAT/documentation/demos/demo34/dragon/L_wing02.png new file mode 100755 index 0000000..831d7ca Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing02.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing03.png b/CAAT/documentation/demos/demo34/dragon/L_wing03.png new file mode 100755 index 0000000..702c43f Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing03.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing04.png b/CAAT/documentation/demos/demo34/dragon/L_wing04.png new file mode 100755 index 0000000..5cba467 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing04.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing05.png b/CAAT/documentation/demos/demo34/dragon/L_wing05.png new file mode 100755 index 0000000..d8d18c2 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing05.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing06.png b/CAAT/documentation/demos/demo34/dragon/L_wing06.png new file mode 100755 index 0000000..788c70b Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing06.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing07.png b/CAAT/documentation/demos/demo34/dragon/L_wing07.png new file mode 100755 index 0000000..c055793 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing07.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing08.png b/CAAT/documentation/demos/demo34/dragon/L_wing08.png new file mode 100755 index 0000000..dc16d00 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing08.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/L_wing09.png b/CAAT/documentation/demos/demo34/dragon/L_wing09.png new file mode 100755 index 0000000..97e9158 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/L_wing09.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_front_leg.png b/CAAT/documentation/demos/demo34/dragon/R_front_leg.png new file mode 100755 index 0000000..bcc28ee Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_front_leg.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_front_thigh.png b/CAAT/documentation/demos/demo34/dragon/R_front_thigh.png new file mode 100755 index 0000000..fbf13cf Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_front_thigh.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_rear_leg.png b/CAAT/documentation/demos/demo34/dragon/R_rear_leg.png new file mode 100755 index 0000000..c2cc5e7 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_rear_leg.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_rear_thigh.png b/CAAT/documentation/demos/demo34/dragon/R_rear_thigh.png new file mode 100755 index 0000000..ade9cde Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_rear_thigh.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing01.png b/CAAT/documentation/demos/demo34/dragon/R_wing01.png new file mode 100755 index 0000000..873bf07 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing01.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing02.png b/CAAT/documentation/demos/demo34/dragon/R_wing02.png new file mode 100755 index 0000000..60dd189 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing02.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing03.png b/CAAT/documentation/demos/demo34/dragon/R_wing03.png new file mode 100755 index 0000000..1cf2e1c Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing03.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing04.png b/CAAT/documentation/demos/demo34/dragon/R_wing04.png new file mode 100755 index 0000000..316aa4e Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing04.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing05.png b/CAAT/documentation/demos/demo34/dragon/R_wing05.png new file mode 100755 index 0000000..73fdb42 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing05.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing06.png b/CAAT/documentation/demos/demo34/dragon/R_wing06.png new file mode 100755 index 0000000..931ca65 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing06.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing07.png b/CAAT/documentation/demos/demo34/dragon/R_wing07.png new file mode 100755 index 0000000..3d7af82 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing07.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing08.png b/CAAT/documentation/demos/demo34/dragon/R_wing08.png new file mode 100755 index 0000000..f6d28d3 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing08.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/R_wing09.png b/CAAT/documentation/demos/demo34/dragon/R_wing09.png new file mode 100755 index 0000000..f97a876 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/R_wing09.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/back.png b/CAAT/documentation/demos/demo34/dragon/back.png new file mode 100755 index 0000000..05531bc Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/back.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/chest.png b/CAAT/documentation/demos/demo34/dragon/chest.png new file mode 100755 index 0000000..6e3ba44 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/chest.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/chin.png b/CAAT/documentation/demos/demo34/dragon/chin.png new file mode 100755 index 0000000..68c7648 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/chin.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/dragon-flying.json b/CAAT/documentation/demos/demo34/dragon/dragon-flying.json new file mode 100644 index 0000000..68aff27 --- /dev/null +++ b/CAAT/documentation/demos/demo34/dragon/dragon-flying.json @@ -0,0 +1,1833 @@ +{ + "bones": { + "back": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 17.39 + }, + { + "time": 0.5, + "angle": 0 + }, + { + "time": 0.8333, + "angle": 7 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "neck": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -8.18 + }, + { + "time": 0.3333, + "angle": -23.16 + }, + { + "time": 0.5, + "angle": -18.01 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "chest": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail1": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -2.42 + }, + { + "time": 0.3333, + "angle": -26.2 + }, + { + "time": 0.5, + "angle": -29.65 + }, + { + "time": 0.6666, + "angle": -23.15 + }, + { + "time": 0.8333, + "angle": -55.46 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_rear_thigh": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail2": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -1.12 + }, + { + "time": 0.3333, + "angle": 10.48 + }, + { + "time": 0.5, + "angle": 7.89 + }, + { + "time": 0.8333, + "angle": -10.38 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail3": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 8.24 + }, + { + "time": 0.3333, + "angle": 15.21 + }, + { + "time": 0.5, + "angle": 14.84 + }, + { + "time": 0.8333, + "angle": -18.9 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail4": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 17.46 + }, + { + "time": 0.3333, + "angle": 22.15 + }, + { + "time": 0.5, + "angle": 22.76 + }, + { + "time": 0.8333, + "angle": -4.37 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail5": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 7.4 + }, + { + "time": 0.3333, + "angle": 28.5 + }, + { + "time": 0.5, + "angle": 21.33 + }, + { + "time": 0.8333, + "angle": -1.27 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "tail6": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 45.99 + }, + { + "time": 0.4, + "angle": 43.53 + }, + { + "time": 0.5, + "angle": 61.79 + }, + { + "time": 0.8333, + "angle": 13.28 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_rear_leg": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -14.21 + }, + { + "time": 0.5, + "angle": 47.17 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_rear_toe3": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.5, + "angle": -36.06 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_rear_toe2": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.5, + "angle": -20.32 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_rear_toe1": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.5, + "angle": -18.71 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "head": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": [0.408, 1.36, 0.675, 1.43] + }, + { + "time": 0.5, + "angle": 1.03 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "chin": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": [0.416, 1.15, 0.494, 1.27] + }, + { + "time": 0.3333, + "angle": -5.15 + }, + { + "time": 0.5, + "angle": 9.79 + }, + { + "time": 0.6666, + "angle": 18.94 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_thigh": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -19.18 + }, + { + "time": 0.3333, + "angle": -32.02 + }, + { + "time": 0.5, + "angle": -19.62 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_front_thigh": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -12.96 + }, + { + "time": 0.5, + "angle": 16.2 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_leg": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 37.77 + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_toe1": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": -16.08 + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_toe2": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.33, + "y": 1.029 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_toe4": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.5, + "angle": 26.51 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.239, + "y": 0.993 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_front_toe3": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.5, + "angle": 16.99 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.402, + "y": 1.007 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_front_leg": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 26.07 + }, + { + "time": 0.5, + "angle": -21.6 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 1, + "y": 1, + "curve": "stepped" + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_front_toe1": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 29.23 + }, + { + "time": 0.5, + "angle": 34.83 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.412, + "y": 1 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_front_toe2": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 24.89 + }, + { + "time": 0.5, + "angle": 23.16 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.407, + "y": 1.057 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "R_front_toe3": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.1666, + "angle": 11.01 + }, + { + "time": 0.5, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 0.5, + "x": 0, + "y": 0, + "curve": "stepped" + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + }, + { + "time": 0.5, + "x": 1.329, + "y": 1.181 + }, + { + "time": 1, + "x": 1, + "y": 1 + } + ] + }, + "L_rear_leg": { + "rotate": [ + { + "time": 0, + "angle": 0 + }, + { + "time": 0.3666, + "angle": 25.19 + }, + { + "time": 0.6666, + "angle": -15.65 + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0 + } + ], + "scale": [ + { + "time": 0, + "x": 1, + "y": 1 + } + ] + }, + "COG": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": [0.456, 0.2, 0.422, 1.06] + }, + { + "time": 0.3333, + "angle": 23.93 + }, + { + "time": 0.6666, + "angle": 337.8, + "curve": [0.41, 0, 0.887, 0.75] + }, + { + "time": 1, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0, + "curve": [0.33, 1, 0.816, 1.33] + }, + { + "time": 0.5, + "x": 0, + "y": 113.01, + "curve": [0.396, 0, 0.709, 2.03] + }, + { + "time": 1, + "x": 0, + "y": 0 + } + ] + } +}, + "slots": { + "R_wing": { + "attachment": [ + { + "time": 0, + "name": "R_wing01" + }, + { + "time": 0.0666, + "name": "R_wing02" + }, + { + "time": 0.1333, + "name": "R_wing03" + }, + { + "time": 0.2, + "name": "R_wing04" + }, + { + "time": 0.2666, + "name": "R_wing05" + }, + { + "time": 0.3333, + "name": "R_wing06" + }, + { + "time": 0.4, + "name": "R_wing07" + }, + { + "time": 0.4666, + "name": "R_wing08" + }, + { + "time": 0.5333, + "name": "R_wing09" + }, + { + "time": 0.6, + "name": "R_wing01" + }, + { + "time": 0.7333, + "name": "R_wing02" + }, + { + "time": 0.7666, + "name": "R_wing02" + }, + { + "time": 0.8, + "name": "R_wing03" + }, + { + "time": 0.8333, + "name": "R_wing04" + }, + { + "time": 0.8666, + "name": "R_wing05" + }, + { + "time": 0.9, + "name": "R_wing06" + }, + { + "time": 0.9333, + "name": "R_wing07" + }, + { + "time": 0.9666, + "name": "R_wing08" + }, + { + "time": 1, + "name": "R_wing09" + } + ] + }, + "L_wing": { + "attachment": [ + { + "time": 0, + "name": "L_wing01" + }, + { + "time": 0.0666, + "name": "L_wing02" + }, + { + "time": 0.1333, + "name": "L_wing03" + }, + { + "time": 0.2, + "name": "L_wing04" + }, + { + "time": 0.2666, + "name": "L_wing05" + }, + { + "time": 0.3333, + "name": "L_wing06" + }, + { + "time": 0.4, + "name": "L_wing07" + }, + { + "time": 0.4666, + "name": "L_wing08" + }, + { + "time": 0.5333, + "name": "L_wing09" + }, + { + "time": 0.6, + "name": "L_wing01" + }, + { + "time": 0.7333, + "name": "L_wing02" + }, + { + "time": 0.8, + "name": "L_wing03" + }, + { + "time": 0.8333, + "name": "L_wing04" + }, + { + "time": 0.8666, + "name": "L_wing05" + }, + { + "time": 0.9, + "name": "L_wing06" + }, + { + "time": 0.9333, + "name": "L_wing07" + }, + { + "time": 0.9666, + "name": "L_wing08" + }, + { + "time": 1, + "name": "L_wing09" + } + ] + } +}} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/dragon/dragon-skeleton.json b/CAAT/documentation/demos/demo34/dragon/dragon-skeleton.json new file mode 100644 index 0000000..0d3adfb --- /dev/null +++ b/CAAT/documentation/demos/demo34/dragon/dragon-skeleton.json @@ -0,0 +1,813 @@ +{"bones": [ + { + "name": "root", + "y": -176.12 + }, + { + "name": "COG", + "parent": "root", + "y": 176.12 + }, + { + "name": "neck", + "parent": "COG", + "length": 41.36, + "x": 64.75, + "y": 11.98, + "rotation": 39.05 + }, + { + "name": "back", + "parent": "COG", + "length": 115.37, + "x": 16.03, + "y": 27.94, + "rotation": 151.83 + }, + { + "name": "chest", + "parent": "COG", + "length": 31.24, + "x": 52.52, + "y": 15.34, + "rotation": 161.7 + }, + { + "name": "head", + "parent": "neck", + "length": 188.83, + "x": 69.96, + "y": 2.49, + "rotation": 8.06 + }, + { + "name": "chin", + "parent": "neck", + "length": 153.15, + "x": 64.62, + "y": -6.99, + "rotation": -69.07 + }, + { + "name": "R_wing", + "parent": "head", + "length": 359.5, + "x": -74.68, + "y": 20.9, + "rotation": 83.21 + }, + { + "name": "tail1", + "parent": "back", + "length": 65.65, + "x": 115.37, + "y": -0.19, + "rotation": 44.31 + }, + { + "name": "R_rear_thigh", + "parent": "back", + "length": 123.46, + "x": 65.31, + "y": 59.89, + "rotation": 104.87 + }, + { + "name": "tail2", + "parent": "tail1", + "length": 54.5, + "x": 65.65, + "y": 0.22, + "rotation": 12 + }, + { + "name": "tail3", + "parent": "tail2", + "length": 41.78, + "x": 54.5, + "y": 0.37, + "rotation": 1.8 + }, + { + "name": "tail4", + "parent": "tail3", + "length": 34.19, + "x": 41.78, + "y": 0.16, + "rotation": -1.8 + }, + { + "name": "tail5", + "parent": "tail4", + "length": 32.32, + "x": 34.19, + "y": -0.19, + "rotation": -3.15 + }, + { + "name": "tail6", + "parent": "tail5", + "length": 80.08, + "x": 32.32, + "y": -0.23, + "rotation": -29.55 + }, + { + "name": "L_rear_thigh", + "parent": "R_rear_thigh", + "length": 88.05, + "x": -8.59, + "y": 30.18, + "rotation": 28.35 + }, + { + "name": "R_rear_leg", + "parent": "R_rear_thigh", + "length": 91.06, + "x": 123.46, + "y": -0.26, + "rotation": -129.04 + }, + { + "name": "L_rear_leg", + "parent": "L_rear_thigh", + "length": 103.74, + "x": 96.04, + "y": -0.97, + "rotation": -122.41 + }, + { + "name": "R_rear_toe3", + "parent": "R_rear_leg", + "length": 103.45, + "x": 91.06, + "y": -0.35, + "rotation": 112.26 + }, + { + "name": "R_rear_toe2", + "parent": "R_rear_leg", + "length": 99.29, + "x": 89.6, + "y": 1.52, + "rotation": 125.32 + }, + { + "name": "R_rear_toe1", + "parent": "R_rear_leg", + "length": 94.99, + "x": 90.06, + "y": 2.12, + "rotation": 141.98 + }, + { + "name": "L_wing", + "parent": "chest", + "length": 301.12, + "x": -7.24, + "y": -24.65, + "rotation": -75.51 + }, + { + "name": "L_front_thigh", + "parent": "chest", + "length": 67.42, + "x": -45.58, + "y": 7.92, + "rotation": 138.94 + }, + { + "name": "R_front_thigh", + "parent": "chest", + "length": 81.63, + "x": -10.89, + "y": 28.25, + "rotation": 67.96 + }, + { + "name": "L_front_leg", + "parent": "L_front_thigh", + "length": 51.57, + "x": 67.42, + "y": 0.02, + "rotation": 43.36 + }, + { + "name": "L_front_toe1", + "parent": "L_front_leg", + "length": 51.44, + "x": 45.53, + "y": 2.43, + "rotation": -98 + }, + { + "name": "L_front_toe2", + "parent": "L_front_leg", + "length": 61.97, + "x": 51.57, + "y": -0.12, + "rotation": -55.26 + }, + { + "name": "L_front_toe4", + "parent": "L_front_leg", + "length": 53.47, + "x": 50.6, + "y": 7.08, + "scaleX": 1.134, + "rotation": 19.42 + }, + { + "name": "L_front_toe3", + "parent": "L_front_leg", + "length": 45.65, + "x": 54.19, + "y": 0.6, + "scaleX": 1.134, + "rotation": -11.13 + }, + { + "name": "R_front_leg", + "parent": "R_front_thigh", + "length": 66.52, + "x": 83.04, + "y": -0.3, + "rotation": 92.7 + }, + { + "name": "R_front_toe1", + "parent": "R_front_leg", + "length": 46.65, + "x": 70.03, + "y": 5.31, + "rotation": 8.59 + }, + { + "name": "R_front_toe2", + "parent": "R_front_leg", + "length": 53.66, + "x": 66.52, + "y": 0.33, + "rotation": -35.02 + }, + { + "name": "R_front_toe3", + "parent": "R_front_leg", + "length": 58.38, + "x": 62.1, + "y": -0.79, + "rotation": -74.67 + } +], + "slots": [ + { + "name": "L_rear_leg", + "bone": "L_rear_leg", + "attachment": "L_rear_leg" + }, + { + "name": "L_rear_thigh", + "bone": "L_rear_thigh", + "attachment": "L_rear_thigh" + }, + { + "name": "L_wing", + "bone": "L_wing", + "attachment": "L_wing01" + }, + { + "name": "tail6", + "bone": "tail6", + "attachment": "tail06" + }, + { + "name": "tail5", + "bone": "tail5", + "attachment": "tail05" + }, + { + "name": "tail4", + "bone": "tail4", + "attachment": "tail04" + }, + { + "name": "tail3", + "bone": "tail3", + "attachment": "tail03" + }, + { + "name": "tail2", + "bone": "tail2", + "attachment": "tail02" + }, + { + "name": "tail1", + "bone": "tail1", + "attachment": "tail01" + }, + { + "name": "back", + "bone": "back", + "attachment": "back" + }, + { + "name": "L_front_thigh", + "bone": "L_front_thigh", + "attachment": "L_front_thigh" + }, + { + "name": "L_front_leg", + "bone": "L_front_leg", + "attachment": "L_front_leg" + }, + { + "name": "L_front_toe1", + "bone": "L_front_toe1", + "attachment": "front_toeA" + }, + { + "name": "L_front_toe4", + "bone": "L_front_toe4", + "attachment": "front_toeB" + }, + { + "name": "L_front_toe3", + "bone": "L_front_toe3", + "attachment": "front_toeB" + }, + { + "name": "L_front_toe2", + "bone": "L_front_toe2", + "attachment": "front_toeB" + }, + { + "name": "chest", + "bone": "chest", + "attachment": "chest" + }, + { + "name": "R_rear_toe1", + "bone": "R_rear_toe1", + "attachment": "rear-toe" + }, + { + "name": "R_rear_toe2", + "bone": "R_rear_toe2", + "attachment": "rear-toe" + }, + { + "name": "R_rear_toe3", + "bone": "R_rear_toe3", + "attachment": "rear-toe" + }, + { + "name": "R_rear_leg", + "bone": "R_rear_leg", + "attachment": "R_rear_leg" + }, + { + "name": "R_rear_thigh", + "bone": "R_rear_thigh", + "attachment": "R_rear_thigh" + }, + { + "name": "R_front_toe1", + "bone": "R_front_toe1", + "attachment": "front_toeB" + }, + { + "name": "R_front_thigh", + "bone": "R_front_thigh", + "attachment": "R_front_thigh" + }, + { + "name": "R_front_leg", + "bone": "R_front_leg", + "attachment": "R_front_leg" + }, + { + "name": "R_front_toe2", + "bone": "R_front_toe2", + "attachment": "front_toeB" + }, + { + "name": "R_front_toe3", + "bone": "R_front_toe3", + "attachment": "front_toeB" + }, + { + "name": "chin", + "bone": "chin", + "attachment": "chin" + }, + { + "name": "R_wing", + "bone": "R_wing", + "attachment": "R_wing01" + }, + { + "name": "head", + "bone": "head", + "attachment": "head" + }, + { + "name": "logo", + "bone": "root", + "attachment": "logo" + } +], "skins": { + "default": { + "L_rear_leg": { + "L_rear_leg": { + "x": 67.29, + "y": 12.62, + "rotation": -162.65, + "width": 206, + "height": 177 + } + }, + "L_rear_thigh": { + "L_rear_thigh": { + "x": 56.03, + "y": 27.38, + "rotation": 74.93, + "width": 91, + "height": 149 + } + }, + "L_wing": { + "L_wing01": { + "x": 129.21, + "y": -45.49, + "rotation": -83.7, + "width": 191, + "height": 256 + }, + "L_wing02": { + "x": 126.37, + "y": -31.69, + "rotation": -86.18, + "width": 179, + "height": 269 + }, + "L_wing03": { + "x": 110.26, + "y": -90.89, + "rotation": -86.18, + "width": 186, + "height": 207 + }, + "L_wing04": { + "x": -61.61, + "y": -83.26, + "rotation": -86.18, + "width": 188, + "height": 135 + }, + "L_wing05": { + "x": -90.01, + "y": -78.14, + "rotation": -86.18, + "width": 218, + "height": 213 + }, + "L_wing06": { + "x": -143.76, + "y": -83.71, + "rotation": -86.18, + "width": 192, + "height": 331 + }, + "L_wing07": { + "x": -133.04, + "y": -33.89, + "rotation": -86.18, + "width": 159, + "height": 255 + }, + "L_wing08": { + "x": 50.15, + "y": -15.71, + "rotation": -86.18, + "width": 164, + "height": 181 + }, + "L_wing09": { + "x": 85.94, + "y": -11.32, + "rotation": -86.18, + "width": 204, + "height": 167 + } + }, + "tail6": { + "tail06": { + "x": 28.02, + "y": -16.83, + "rotation": -175.44, + "width": 95, + "height": 68 + } + }, + "tail5": { + "tail05": { + "x": 15.05, + "y": -3.57, + "rotation": 155, + "width": 52, + "height": 59 + } + }, + "tail4": { + "tail04": { + "x": 15.34, + "y": -2.17, + "rotation": 151.84, + "width": 56, + "height": 71 + } + }, + "tail3": { + "tail03": { + "x": 16.94, + "y": -2, + "rotation": 150.04, + "width": 73, + "height": 92 + } + }, + "tail2": { + "tail02": { + "x": 18.11, + "y": -1.75, + "rotation": 151.84, + "width": 95, + "height": 120 + } + }, + "tail1": { + "tail01": { + "x": 22.59, + "y": -4.5, + "rotation": 163.85, + "width": 120, + "height": 153 + } + }, + "back": { + "back": { + "x": 35.84, + "y": 19.99, + "rotation": -151.83, + "width": 190, + "height": 185 + } + }, + "L_front_thigh": { + "L_front_thigh": { + "x": 27.66, + "y": -11.58, + "rotation": 58.66, + "width": 84, + "height": 72 + } + }, + "L_front_leg": { + "L_front_leg": { + "x": 14.68, + "y": 0.48, + "rotation": 15.99, + "width": 84, + "height": 57 + } + }, + "L_front_toe1": { + "front_toeA": { + "x": 31.92, + "y": 0.61, + "rotation": 109.55, + "width": 29, + "height": 50 + } + }, + "L_front_toe4": { + "front_toeB": { + "x": 23.21, + "y": -11.68, + "scaleX": 0.881, + "rotation": 79.89, + "width": 56, + "height": 57 + } + }, + "L_front_toe3": { + "front_toeB": { + "x": 18.21, + "y": -7.21, + "scaleX": 0.881, + "scaleY": 0.94, + "rotation": 99.71, + "width": 56, + "height": 57 + } + }, + "L_front_toe2": { + "front_toeB": { + "x": 26.83, + "y": -4.94, + "rotation": 109.51, + "width": 56, + "height": 57 + } + }, + "chest": { + "chest": { + "x": -14.6, + "y": 24.78, + "rotation": -161.7, + "width": 136, + "height": 122 + } + }, + "R_rear_toe1": { + "rear-toe": { + "x": 54.75, + "y": -5.72, + "rotation": 134.79, + "width": 109, + "height": 77 + } + }, + "R_rear_toe2": { + "rear-toe": { + "x": 57.02, + "y": -7.22, + "rotation": 134.42, + "width": 109, + "height": 77 + } + }, + "R_rear_toe3": { + "rear-toe": { + "x": 47.46, + "y": -7.64, + "rotation": 134.34, + "width": 109, + "height": 77 + } + }, + "R_rear_leg": { + "R_rear_leg": { + "x": 60.87, + "y": -5.72, + "rotation": -127.66, + "width": 116, + "height": 100 + } + }, + "R_rear_thigh": { + "R_rear_thigh": { + "x": 53.25, + "y": 12.58, + "rotation": 103.29, + "width": 91, + "height": 149 + } + }, + "R_front_toe1": { + "front_toeB": { + "x": 24.49, + "y": -2.61, + "rotation": 104.18, + "width": 56, + "height": 57 + } + }, + "R_front_thigh": { + "R_front_thigh": { + "x": 35.28, + "y": 2.11, + "rotation": 130.33, + "width": 108, + "height": 108 + } + }, + "R_front_leg": { + "R_front_leg": { + "x": 17.79, + "y": 4.22, + "rotation": 37.62, + "width": 101, + "height": 89 + } + }, + "R_front_toe2": { + "front_toeB": { + "x": 26.39, + "y": 1.16, + "rotation": 104.57, + "width": 56, + "height": 57 + } + }, + "R_front_toe3": { + "front_toeB": { + "x": 30.66, + "y": -0.06, + "rotation": 112.29, + "width": 56, + "height": 57 + } + }, + "chin": { + "chin": { + "x": 66.55, + "y": 7.32, + "rotation": 30.01, + "width": 214, + "height": 146 + } + }, + "R_wing": { + "R_wing01": { + "x": 170.08, + "y": -23.67, + "rotation": -130.33, + "width": 219, + "height": 310 + }, + "R_wing02": { + "x": 171.14, + "y": -19.33, + "rotation": -130.33, + "width": 203, + "height": 305 + }, + "R_wing03": { + "x": 166.46, + "y": 29.23, + "rotation": -130.33, + "width": 272, + "height": 247 + }, + "R_wing04": { + "x": 42.94, + "y": 134.05, + "rotation": -130.33, + "width": 279, + "height": 144 + }, + "R_wing05": { + "x": -8.83, + "y": 142.59, + "rotation": -130.33, + "width": 251, + "height": 229 + }, + "R_wing06": { + "x": -123.33, + "y": 111.22, + "rotation": -130.33, + "width": 200, + "height": 366 + }, + "R_wing07": { + "x": -40.17, + "y": 118.03, + "rotation": -130.33, + "width": 200, + "height": 263 + }, + "R_wing08": { + "x": 48.01, + "y": 28.76, + "rotation": -130.33, + "width": 234, + "height": 254 + }, + "R_wing09": { + "x": 128.1, + "y": 21.12, + "rotation": -130.33, + "width": 248, + "height": 204 + } + }, + "head": { + "head": { + "x": 76.68, + "y": 32.21, + "rotation": -47.12, + "width": 296, + "height": 260 + } + }, + "logo": { + "logo": { + "y": -176.72, + "width": 897, + "height": 92 + } + } + } +}} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/dragon/front_toeA.png b/CAAT/documentation/demos/demo34/dragon/front_toeA.png new file mode 100755 index 0000000..f021032 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/front_toeA.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/front_toeB.png b/CAAT/documentation/demos/demo34/dragon/front_toeB.png new file mode 100755 index 0000000..0b48c23 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/front_toeB.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/head.png b/CAAT/documentation/demos/demo34/dragon/head.png new file mode 100755 index 0000000..5e4e436 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/head.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/license.txt b/CAAT/documentation/demos/demo34/dragon/license.txt new file mode 100755 index 0000000..41ebddd --- /dev/null +++ b/CAAT/documentation/demos/demo34/dragon/license.txt @@ -0,0 +1,5 @@ +Copyright (c) 2013, ODI EntertainmenT + +The project file and images in this "dragon" project are provided for +demonstration purposes only and may not be redistributed for any reason nor +used as the basis for derivative work. \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/dragon/logo.png b/CAAT/documentation/demos/demo34/dragon/logo.png new file mode 100755 index 0000000..cf43dad Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/logo.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/rear-toe.png b/CAAT/documentation/demos/demo34/dragon/rear-toe.png new file mode 100755 index 0000000..e4c7fa8 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/rear-toe.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail01.png b/CAAT/documentation/demos/demo34/dragon/tail01.png new file mode 100755 index 0000000..e9bcef7 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail01.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail02.png b/CAAT/documentation/demos/demo34/dragon/tail02.png new file mode 100755 index 0000000..8b31a93 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail02.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail03.png b/CAAT/documentation/demos/demo34/dragon/tail03.png new file mode 100755 index 0000000..aa09539 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail03.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail04.png b/CAAT/documentation/demos/demo34/dragon/tail04.png new file mode 100755 index 0000000..2aeeed4 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail04.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail05.png b/CAAT/documentation/demos/demo34/dragon/tail05.png new file mode 100755 index 0000000..f41005c Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail05.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/tail06.png b/CAAT/documentation/demos/demo34/dragon/tail06.png new file mode 100755 index 0000000..31f68a4 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/tail06.png differ diff --git a/CAAT/documentation/demos/demo34/dragon/template.png b/CAAT/documentation/demos/demo34/dragon/template.png new file mode 100755 index 0000000..3f2ef65 Binary files /dev/null and b/CAAT/documentation/demos/demo34/dragon/template.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/dagger.png b/CAAT/documentation/demos/demo34/goblins/dagger.png new file mode 100755 index 0000000..9a666d6 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/dagger.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/eyes-closed.png b/CAAT/documentation/demos/demo34/goblins/goblin/eyes-closed.png new file mode 100755 index 0000000..e306dd4 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/eyes-closed.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/head.png b/CAAT/documentation/demos/demo34/goblins/goblin/head.png new file mode 100755 index 0000000..82b49f7 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/head.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-arm.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-arm.png new file mode 100755 index 0000000..42f60e0 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-arm.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-foot.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-foot.png new file mode 100755 index 0000000..89c142b Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-foot.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-hand.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-hand.png new file mode 100755 index 0000000..39700f0 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-hand.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-lower-leg.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-lower-leg.png new file mode 100755 index 0000000..dd3e83b Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-shoulder.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-shoulder.png new file mode 100755 index 0000000..220b09c Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/left-upper-leg.png b/CAAT/documentation/demos/demo34/goblins/goblin/left-upper-leg.png new file mode 100755 index 0000000..a031cf6 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/left-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/neck.png b/CAAT/documentation/demos/demo34/goblins/goblin/neck.png new file mode 100755 index 0000000..f4f3f04 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/neck.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/pelvis.png b/CAAT/documentation/demos/demo34/goblins/goblin/pelvis.png new file mode 100755 index 0000000..a8fc15c Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/pelvis.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-arm.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-arm.png new file mode 100755 index 0000000..c7b752b Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-arm.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-foot.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-foot.png new file mode 100755 index 0000000..ce982d3 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-foot.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-hand.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-hand.png new file mode 100755 index 0000000..2363fba Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-hand.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-lower-leg.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-lower-leg.png new file mode 100755 index 0000000..b9bb496 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-shoulder.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-shoulder.png new file mode 100755 index 0000000..48baa26 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/right-upper-leg.png b/CAAT/documentation/demos/demo34/goblins/goblin/right-upper-leg.png new file mode 100755 index 0000000..d5fac44 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/right-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/torso.png b/CAAT/documentation/demos/demo34/goblins/goblin/torso.png new file mode 100755 index 0000000..f9b4314 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/torso.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/undie-straps.png b/CAAT/documentation/demos/demo34/goblins/goblin/undie-straps.png new file mode 100755 index 0000000..6088d35 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/undie-straps.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblin/undies.png b/CAAT/documentation/demos/demo34/goblins/goblin/undies.png new file mode 100755 index 0000000..95016ba Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblin/undies.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/eyes-closed.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/eyes-closed.png new file mode 100755 index 0000000..d682684 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/eyes-closed.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/head.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/head.png new file mode 100755 index 0000000..5434995 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/head.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-arm.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-arm.png new file mode 100755 index 0000000..00c5bbc Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-arm.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-foot.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-foot.png new file mode 100755 index 0000000..e1adb40 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-foot.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-hand.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-hand.png new file mode 100755 index 0000000..e070bf2 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-hand.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-lower-leg.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-lower-leg.png new file mode 100755 index 0000000..346866f Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-shoulder.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-shoulder.png new file mode 100755 index 0000000..0cb53d4 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/left-upper-leg.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-upper-leg.png new file mode 100755 index 0000000..be09a93 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/left-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/neck.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/neck.png new file mode 100755 index 0000000..14b62b3 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/neck.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/pelvis.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/pelvis.png new file mode 100755 index 0000000..f24c2a7 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/pelvis.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-arm.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-arm.png new file mode 100755 index 0000000..5818fc6 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-arm.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-foot.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-foot.png new file mode 100755 index 0000000..716f4f0 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-foot.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-hand.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-hand.png new file mode 100755 index 0000000..cd5eadc Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-hand.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-lower-leg.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-lower-leg.png new file mode 100755 index 0000000..f135720 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-shoulder.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-shoulder.png new file mode 100755 index 0000000..297a5fc Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/right-upper-leg.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-upper-leg.png new file mode 100755 index 0000000..d6dae75 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/right-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/torso.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/torso.png new file mode 100755 index 0000000..2a92320 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/torso.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/undie-straps.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/undie-straps.png new file mode 100755 index 0000000..36913d5 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/undie-straps.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblingirl/undies.png b/CAAT/documentation/demos/demo34/goblins/goblingirl/undies.png new file mode 100755 index 0000000..ac3ac2e Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/goblingirl/undies.png differ diff --git a/CAAT/documentation/demos/demo34/goblins/goblins-skeleton.json b/CAAT/documentation/demos/demo34/goblins/goblins-skeleton.json new file mode 100644 index 0000000..043c9dc --- /dev/null +++ b/CAAT/documentation/demos/demo34/goblins/goblins-skeleton.json @@ -0,0 +1,201 @@ +{ +"bones": [ + { "name": "root" }, + { "name": "hip", "parent": "root", "x": 0.64, "y": 114.41 }, + { "name": "left upper leg", "parent": "hip", "length": 50.39, "x": 14.45, "y": 2.81, "rotation": -89.09 }, + { "name": "left lower leg", "parent": "left upper leg", "length": 49.89, "x": 56.34, "y": 0.98, "rotation": -16.65 }, + { "name": "left foot", "parent": "left lower leg", "length": 46.5, "x": 58.94, "y": -7.61, "rotation": 102.43 }, + { "name": "right upper leg", "parent": "hip", "length": 42.45, "x": -20.07, "y": -6.83, "rotation": -97.49 }, + { "name": "right lower leg", "parent": "right upper leg", "length": 58.52, "x": 42.99, "y": -0.61, "rotation": -14.34 }, + { "name": "right foot", "parent": "right lower leg", "length": 45.45, "x": 64.88, "y": 0.04, "rotation": 110.3 }, + { "name": "torso", "parent": "hip", "length": 85.82, "x": -6.42, "y": 1.97, "rotation": 93.92 }, + { "name": "neck", "parent": "torso", "length": 18.38, "x": 81.67, "y": -6.34, "rotation": -1.51 }, + { "name": "head", "parent": "neck", "length": 68.28, "x": 20.93, "y": 11.59, "rotation": -13.92 }, + { "name": "right shoulder", "parent": "torso", "length": 37.24, "x": 76.02, "y": 18.14, "rotation": 133.88 }, + { "name": "right arm", "parent": "right shoulder", "length": 36.74, "x": 37.6, "y": 0.31, "rotation": 36.32 }, + { "name": "right hand", "parent": "right arm", "length": 15.32, "x": 36.9, "y": 0.34, "rotation": 2.35 }, + { "name": "left shoulder", "parent": "torso", "length": 35.43, "x": 74.04, "y": -20.38, "rotation": -156.96 }, + { "name": "left arm", "parent": "left shoulder", "length": 35.62, "x": 37.85, "y": -2.34, "rotation": 28.16 }, + { "name": "left hand", "parent": "left arm", "length": 11.52, "x": 35.62, "y": 0.07, "rotation": 2.7 }, + { "name": "pelvis", "parent": "hip", "x": 1.41, "y": -6.57 } +], +"slots": [ + { "name": "left shoulder", "bone": "left shoulder", "attachment": "left shoulder" }, + { "name": "left arm", "bone": "left arm", "attachment": "left arm" }, + { "name": "left hand item", "bone": "left hand", "attachment": "spear" }, + { "name": "left hand", "bone": "left hand", "attachment": "left hand" }, + { "name": "left foot", "bone": "left foot", "attachment": "left foot" }, + { "name": "left lower leg", "bone": "left lower leg", "attachment": "left lower leg" }, + { "name": "left upper leg", "bone": "left upper leg", "attachment": "left upper leg" }, + { "name": "neck", "bone": "neck", "attachment": "neck" }, + { "name": "torso", "bone": "torso", "attachment": "torso" }, + { "name": "pelvis", "bone": "pelvis", "attachment": "pelvis" }, + { "name": "right foot", "bone": "right foot", "attachment": "right foot" }, + { "name": "right lower leg", "bone": "right lower leg", "attachment": "right lower leg" }, + { "name": "undie straps", "bone": "pelvis", "attachment": "undie straps" }, + { "name": "undies", "bone": "pelvis", "attachment": "undies" }, + { "name": "right upper leg", "bone": "right upper leg", "attachment": "right upper leg" }, + { "name": "head", "bone": "head", "attachment": "head" }, + { "name": "eyes", "bone": "head" }, + { "name": "right shoulder", "bone": "right shoulder", "attachment": "right shoulder" }, + { "name": "right arm", "bone": "right arm", "attachment": "right arm" }, + { "name": "right hand item", "bone": "right hand", "attachment": "dagger" }, + { "name": "right hand", "bone": "right hand", "attachment": "right hand" } +], +"skins": { + "default": { + "left hand item": { + "dagger": { "x": 7.88, "y": -23.45, "rotation": 10.47, "width": 26, "height": 108 }, + "spear": { "x": -4.55, "y": 39.2, "rotation": 13.04, "width": 22, "height": 368 } + }, + "right hand item": { + "dagger": { "x": 7.17, "y": -22.38, "rotation": -5.27, "width": 26, "height": 108 } + } + }, + "goblin": { + "neck": { + "neck": { "name": "goblin/neck", "x": 10.1, "y": 0.42, "rotation": -93.69, "width": 36, "height": 41 } + }, + "undies": { + "undies": { "name": "goblin/undies", "x": 6.3, "y": 0.12, "rotation": 0.91, "width": 36, "height": 29 } + }, + "right hand": { + "right hand": { "name": "goblin/right-hand", "x": 7.88, "y": 2.78, "rotation": 91.96, "width": 36, "height": 37 } + }, + "right arm": { + "right arm": { "name": "goblin/right-arm", "x": 16.44, "y": -1.04, "rotation": 94.32, "width": 23, "height": 50 } + }, + "head": { + "head": { "name": "goblin/head", "x": 25.73, "y": 2.33, "rotation": -92.29, "width": 103, "height": 66 } + }, + "left shoulder": { + "left shoulder": { "name": "goblin/left-shoulder", "x": 15.56, "y": -2.26, "rotation": 62.01, "width": 29, "height": 44 } + }, + "left arm": { + "left arm": { + "name": "goblin/left-arm", + "x": 16.7, + "y": -1.69, + "scaleX": 1.057, + "scaleY": 1.057, + "rotation": 33.84, + "width": 37, + "height": 35 + } + }, + "left hand": { + "left hand": { + "name": "goblin/left-hand", + "x": 3.47, + "y": 3.41, + "scaleX": 0.892, + "scaleY": 0.892, + "rotation": 31.14, + "width": 36, + "height": 41 + } + }, + "right lower leg": { + "right lower leg": { "name": "goblin/right-lower-leg", "x": 25.68, "y": -3.15, "rotation": 111.83, "width": 36, "height": 76 } + }, + "right upper leg": { + "right upper leg": { "name": "goblin/right-upper-leg", "x": 20.35, "y": 1.47, "rotation": 97.49, "width": 34, "height": 63 } + }, + "pelvis": { + "pelvis": { "name": "goblin/pelvis", "x": -5.61, "y": 0.76, "width": 62, "height": 43 } + }, + "left lower leg": { + "left lower leg": { "name": "goblin/left-lower-leg", "x": 23.58, "y": -2.06, "rotation": 105.75, "width": 33, "height": 70 } + }, + "left upper leg": { + "left upper leg": { "name": "goblin/left-upper-leg", "x": 29.68, "y": -3.87, "rotation": 89.09, "width": 33, "height": 73 } + }, + "torso": { + "torso": { "name": "goblin/torso", "x": 38.09, "y": -3.87, "rotation": -94.95, "width": 68, "height": 96 } + }, + "right shoulder": { + "right shoulder": { "name": "goblin/right-shoulder", "x": 15.68, "y": -1.03, "rotation": 130.65, "width": 39, "height": 45 } + }, + "right foot": { + "right foot": { "name": "goblin/right-foot", "x": 23.56, "y": 9.8, "rotation": 1.52, "width": 63, "height": 33 } + }, + "left foot": { + "left foot": { "name": "goblin/left-foot", "x": 24.85, "y": 8.74, "rotation": 3.32, "width": 65, "height": 31 } + }, + "undie straps": { + "undie straps": { "name": "goblin/undie-straps", "x": -3.87, "y": 13.1, "scaleX": 1.089, "width": 55, "height": 19 } + }, + "eyes": { + "eyes closed": { "name": "goblin/eyes-closed", "x": 32.21, "y": -21.27, "rotation": -88.92, "width": 34, "height": 12 } + } + }, + "goblingirl": { + "left upper leg": { + "left upper leg": { "name": "goblingirl/left-upper-leg", "x": 30.21, "y": -2.95, "rotation": 89.09, "width": 33, "height": 70 } + }, + "left lower leg": { + "left lower leg": { "name": "goblingirl/left-lower-leg", "x": 25.02, "y": -0.6, "rotation": 105.75, "width": 33, "height": 70 } + }, + "left foot": { + "left foot": { "name": "goblingirl/left-foot", "x": 25.17, "y": 7.92, "rotation": 3.32, "width": 65, "height": 31 } + }, + "right upper leg": { + "right upper leg": { "name": "goblingirl/right-upper-leg", "x": 19.69, "y": 2.13, "rotation": 97.49, "width": 34, "height": 63 } + }, + "right lower leg": { + "right lower leg": { "name": "goblingirl/right-lower-leg", "x": 26.15, "y": -3.27, "rotation": 111.83, "width": 36, "height": 76 } + }, + "right foot": { + "right foot": { "name": "goblingirl/right-foot", "x": 23.46, "y": 9.66, "rotation": 1.52, "width": 63, "height": 33 } + }, + "torso": { + "torso": { "name": "goblingirl/torso", "x": 36.28, "y": -5.14, "rotation": -95.74, "width": 68, "height": 96 } + }, + "left shoulder": { + "left shoulder": { "name": "goblingirl/left-shoulder", "x": 19.8, "y": -0.42, "rotation": 61.21, "width": 28, "height": 46 } + }, + "left arm": { + "left arm": { "name": "goblingirl/left-arm", "x": 19.64, "y": -2.42, "rotation": 33.05, "width": 37, "height": 35 } + }, + "left hand": { + "left hand": { + "name": "goblingirl/left-hand", + "x": 4.34, + "y": 2.39, + "scaleX": 0.896, + "scaleY": 0.896, + "rotation": 30.34, + "width": 35, + "height": 40 + } + }, + "neck": { + "neck": { "name": "goblingirl/neck", "x": 6.16, "y": -3.14, "rotation": -98.86, "width": 35, "height": 41 } + }, + "head": { + "head": { "name": "goblingirl/head", "x": 27.71, "y": -4.32, "rotation": -85.58, "width": 103, "height": 81 } + }, + "right shoulder": { + "right shoulder": { "name": "goblingirl/right-shoulder", "x": 14.46, "y": 0.45, "rotation": 129.85, "width": 39, "height": 45 } + }, + "right arm": { + "right arm": { "name": "goblingirl/right-arm", "x": 16.85, "y": -0.66, "rotation": 93.52, "width": 28, "height": 50 } + }, + "right hand": { + "right hand": { "name": "goblingirl/right-hand", "x": 7.21, "y": 3.43, "rotation": 91.16, "width": 36, "height": 37 } + }, + "pelvis": { + "pelvis": { "name": "goblingirl/pelvis", "x": -3.87, "y": 3.18, "width": 62, "height": 43 } + }, + "undie straps": { + "undie straps": { "name": "goblingirl/undie-straps", "x": -1.51, "y": 14.18, "width": 55, "height": 19 } + }, + "undies": { + "undies": { "name": "goblingirl/undies", "x": 5.4, "y": 1.7, "width": 36, "height": 29 } + }, + "eyes": { + "eyes closed": { "name": "goblingirl/eyes-closed", "x": 28, "y": -25.54, "rotation": -87.04, "width": 37, "height": 21 } + } + } +} +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/goblins/goblins-walk.json b/CAAT/documentation/demos/demo34/goblins/goblins-walk.json new file mode 100644 index 0000000..468b8ec --- /dev/null +++ b/CAAT/documentation/demos/demo34/goblins/goblins-walk.json @@ -0,0 +1,296 @@ +{ +"bones": { + "left upper leg": { + "rotate": [ + { "time": 0, "angle": -26.55 }, + { "time": 0.1333, "angle": -8.78 }, + { "time": 0.2333, "angle": 9.51 }, + { "time": 0.3666, "angle": 30.74 }, + { "time": 0.5, "angle": 25.33 }, + { "time": 0.6333, "angle": 26.11 }, + { "time": 0.7333, "angle": -7.7 }, + { "time": 0.8666, "angle": -21.19 }, + { "time": 1, "angle": -26.55 } + ], + "translate": [ + { "time": 0, "x": -1.32, "y": 1.7 }, + { "time": 0.3666, "x": -0.06, "y": 2.42 }, + { "time": 1, "x": -1.32, "y": 1.7 } + ] + }, + "right upper leg": { + "rotate": [ + { "time": 0, "angle": 42.45 }, + { "time": 0.1333, "angle": 52.1 }, + { "time": 0.2333, "angle": 8.53 }, + { "time": 0.5, "angle": -16.93 }, + { "time": 0.6333, "angle": 1.89 }, + { + "time": 0.7333, + "angle": 28.06, + "curve": [ 0.462, 0.11, 1, 1 ] + }, + { + "time": 0.8666, + "angle": 58.68, + "curve": [ 0.5, 0.02, 1, 1 ] + }, + { "time": 1, "angle": 42.45 } + ], + "translate": [ + { "time": 0, "x": 6.23, "y": 0 }, + { "time": 0.2333, "x": 2.14, "y": 2.4 }, + { "time": 0.5, "x": 2.44, "y": 4.8 }, + { "time": 1, "x": 6.23, "y": 0 } + ] + }, + "left lower leg": { + "rotate": [ + { "time": 0, "angle": -22.98 }, + { "time": 0.1333, "angle": -63.5 }, + { "time": 0.2333, "angle": -73.76 }, + { "time": 0.5, "angle": 5.11 }, + { "time": 0.6333, "angle": -28.29 }, + { "time": 0.7333, "angle": 4.08 }, + { "time": 0.8666, "angle": 3.53 }, + { "time": 1, "angle": -22.98 } + ], + "translate": [ + { "time": 0, "x": 0, "y": 0 }, + { "time": 0.2333, "x": 2.55, "y": -0.47 }, + { "time": 0.5, "x": 0, "y": 0, "curve": "stepped" }, + { "time": 1, "x": 0, "y": 0 } + ] + }, + "left foot": { + "rotate": [ + { "time": 0, "angle": -3.69 }, + { "time": 0.1333, "angle": -10.42 }, + { "time": 0.2333, "angle": -5.01 }, + { "time": 0.3666, "angle": 3.87 }, + { "time": 0.5, "angle": -3.87 }, + { "time": 0.6333, "angle": 2.78 }, + { "time": 0.7333, "angle": 1.68 }, + { "time": 0.8666, "angle": -8.54 }, + { "time": 1, "angle": -3.69 } + ] + }, + "right shoulder": { + "rotate": [ + { + "time": 0, + "angle": 5.29, + "curve": [ 0.264, 0, 0.75, 1 ] + }, + { "time": 0.6333, "angle": 6.65 }, + { "time": 1, "angle": 5.29 } + ] + }, + "right arm": { + "rotate": [ + { + "time": 0, + "angle": -4.02, + "curve": [ 0.267, 0, 0.804, 0.99 ] + }, + { + "time": 0.6333, + "angle": 19.78, + "curve": [ 0.307, 0, 0.787, 0.99 ] + }, + { "time": 1, "angle": -4.02 } + ] + }, + "right hand": { + "rotate": [ + { "time": 0, "angle": 8.98 }, + { "time": 0.6333, "angle": 0.51 }, + { "time": 1, "angle": 8.98 } + ] + }, + "left shoulder": { + "rotate": [ + { + "time": 0, + "angle": 6.25, + "curve": [ 0.339, 0, 0.683, 1 ] + }, + { + "time": 0.5, + "angle": -11.78, + "curve": [ 0.281, 0, 0.686, 0.99 ] + }, + { "time": 1, "angle": 6.25 } + ], + "translate": [ + { "time": 0, "x": 1.15, "y": 0.23 } + ] + }, + "left hand": { + "rotate": [ + { + "time": 0, + "angle": -21.23, + "curve": [ 0.295, 0, 0.755, 0.98 ] + }, + { + "time": 0.5, + "angle": -27.28, + "curve": [ 0.241, 0, 0.75, 0.97 ] + }, + { "time": 1, "angle": -21.23 } + ] + }, + "left arm": { + "rotate": [ + { + "time": 0, + "angle": 28.37, + "curve": [ 0.339, 0, 0.683, 1 ] + }, + { + "time": 0.5, + "angle": 60.09, + "curve": [ 0.281, 0, 0.686, 0.99 ] + }, + { "time": 1, "angle": 28.37 } + ] + }, + "torso": { + "rotate": [ + { "time": 0, "angle": -10.28 }, + { + "time": 0.1333, + "angle": -15.38, + "curve": [ 0.545, 0, 0.818, 1 ] + }, + { + "time": 0.3666, + "angle": -9.78, + "curve": [ 0.58, 0.17, 0.669, 0.99 ] + }, + { + "time": 0.6333, + "angle": -15.75, + "curve": [ 0.235, 0.01, 0.795, 1 ] + }, + { + "time": 0.8666, + "angle": -7.06, + "curve": [ 0.209, 0, 0.816, 0.98 ] + }, + { "time": 1, "angle": -10.28 } + ], + "translate": [ + { "time": 0, "x": -1.29, "y": 1.68 } + ] + }, + "right foot": { + "rotate": [ + { "time": 0, "angle": -5.25 }, + { "time": 0.2333, "angle": -1.91 }, + { "time": 0.3666, "angle": -6.45 }, + { "time": 0.5, "angle": -5.39 }, + { "time": 0.7333, "angle": -11.68 }, + { "time": 0.8666, "angle": 0.46 }, + { "time": 1, "angle": -5.25 } + ] + }, + "right lower leg": { + "rotate": [ + { + "time": 0, + "angle": -3.39, + "curve": [ 0.316, 0.01, 0.741, 0.98 ] + }, + { + "time": 0.1333, + "angle": -45.53, + "curve": [ 0.229, 0, 0.738, 0.97 ] + }, + { "time": 0.2333, "angle": -4.83 }, + { "time": 0.5, "angle": -19.53 }, + { "time": 0.6333, "angle": -64.8 }, + { + "time": 0.7333, + "angle": -82.56, + "curve": [ 0.557, 0.18, 1, 1 ] + }, + { "time": 1, "angle": -3.39 } + ], + "translate": [ + { "time": 0, "x": 0, "y": 0, "curve": "stepped" }, + { "time": 0.5, "x": 0, "y": 0 }, + { "time": 0.6333, "x": 2.18, "y": 0.21 }, + { "time": 1, "x": 0, "y": 0 } + ] + }, + "hip": { + "rotate": [ + { "time": 0, "angle": 0, "curve": "stepped" }, + { "time": 1, "angle": 0 } + ], + "translate": [ + { "time": 0, "x": 0, "y": -4.16 }, + { + "time": 0.1333, + "x": 0, + "y": -7.05, + "curve": [ 0.359, 0.47, 0.646, 0.74 ] + }, + { "time": 0.3666, "x": 0, "y": 6.78 }, + { "time": 0.5, "x": 0, "y": -6.13 }, + { + "time": 0.6333, + "x": 0, + "y": -7.05, + "curve": [ 0.359, 0.47, 0.646, 0.74 ] + }, + { "time": 0.8666, "x": 0, "y": 6.78 }, + { "time": 1, "x": 0, "y": -4.16 } + ] + }, + "neck": { + "rotate": [ + { "time": 0, "angle": 3.6 }, + { "time": 0.1333, "angle": 17.49 }, + { "time": 0.2333, "angle": 6.1 }, + { "time": 0.3666, "angle": 3.45 }, + { "time": 0.5, "angle": 5.17 }, + { "time": 0.6333, "angle": 18.36 }, + { "time": 0.7333, "angle": 6.09 }, + { "time": 0.8666, "angle": 2.28 }, + { "time": 1, "angle": 3.6 } + ] + }, + "head": { + "rotate": [ + { + "time": 0, + "angle": 3.6, + "curve": [ 0, 0, 0.704, 1.17 ] + }, + { "time": 0.1333, "angle": -0.2 }, + { "time": 0.2333, "angle": 6.1 }, + { "time": 0.3666, "angle": 3.45 }, + { + "time": 0.5, + "angle": 5.17, + "curve": [ 0, 0, 0.704, 1.61 ] + }, + { "time": 0.6666, "angle": 1.1 }, + { "time": 0.7333, "angle": 6.09 }, + { "time": 0.8666, "angle": 2.28 }, + { "time": 1, "angle": 3.6 } + ] + } +}, +"slots": { + "eyes": { + "attachment": [ + { "time": 0.7, "name": "eyes closed" }, + { "time": 0.8, "name": null } + ] + } +} +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/goblins/spear.png b/CAAT/documentation/demos/demo34/goblins/spear.png new file mode 100755 index 0000000..0704dc3 Binary files /dev/null and b/CAAT/documentation/demos/demo34/goblins/spear.png differ diff --git a/CAAT/documentation/demos/demo34/index.html b/CAAT/documentation/demos/demo34/index.html new file mode 100755 index 0000000..194cba8 --- /dev/null +++ b/CAAT/documentation/demos/demo34/index.html @@ -0,0 +1,369 @@ + + + + + + + + + + + + + + +
    + + +
    + +
    +
    +

    Skeletal animation

    +
    +
    + +
    +
    +
    +

    + First attemp at support Spine from @EsotericSoft format. +

    +
    +
    + Show bones +
    +
    +
    +
    +
    + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/spineboy/animation.json b/CAAT/documentation/demos/demo34/spineboy/animation.json new file mode 100755 index 0000000..dc371c6 --- /dev/null +++ b/CAAT/documentation/demos/demo34/spineboy/animation.json @@ -0,0 +1,639 @@ +{ + "bones": { + "left upper leg": { + "rotate": [ + { + "time": 0, + "angle": -26.55 + }, + { + "time": 0.1333, + "angle": -8.78 + }, + { + "time": 0.2666, + "angle": 9.51 + }, + { + "time": 0.4, + "angle": 30.74 + }, + { + "time": 0.5333, + "angle": 25.33 + }, + { + "time": 0.6666, + "angle": 26.11 + }, + { + "time": 0.8, + "angle": -7.7 + }, + { + "time": 0.9333, + "angle": -21.19 + }, + { + "time": 1.0666, + "angle": -26.55 + } + ], + "translate": [ + { + "time": 0, + "x": -3, + "y": -2.25 + }, + { + "time": 0.4, + "x": -2.18, + "y": -2.25 + }, + { + "time": 1.0666, + "x": -3, + "y": -2.25 + } + ] + }, + "right upper leg": { + "rotate": [ + { + "time": 0, + "angle": 42.45 + }, + { + "time": 0.1333, + "angle": 52.1 + }, + { + "time": 0.2666, + "angle": 5.96 + }, + { + "time": 0.5333, + "angle": -16.93 + }, + { + "time": 0.6666, + "angle": 1.89 + }, + { + "time": 0.8, + "angle": 28.06, + "curve": [ 0.462, 0.11, 1, 1 ] + }, + { + "time": 0.9333, + "angle": 58.68, + "curve": [ 0.5, 0.02, 1, 1 ] + }, + { + "time": 1.0666, + "angle": 42.45 + } + ], + "translate": [ + { + "time": 0, + "x": 8.11, + "y": -2.36 + }, + { + "time": 0.1333, + "x": 10.03, + "y": -2.56 + }, + { + "time": 0.4, + "x": 2.76, + "y": -2.97 + }, + { + "time": 0.5333, + "x": 2.76, + "y": -2.81 + }, + { + "time": 0.9333, + "x": 8.67, + "y": -2.54 + }, + { + "time": 1.0666, + "x": 8.11, + "y": -2.36 + } + ] + }, + "left lower leg": { + "rotate": [ + { + "time": 0, + "angle": -10.21 + }, + { + "time": 0.1333, + "angle": -55.64 + }, + { + "time": 0.2666, + "angle": -68.12 + }, + { + "time": 0.5333, + "angle": 5.11 + }, + { + "time": 0.6666, + "angle": -28.29 + }, + { + "time": 0.8, + "angle": 4.08 + }, + { + "time": 0.9333, + "angle": 3.53 + }, + { + "time": 1.0666, + "angle": -10.21 + } + ] + }, + "left foot": { + "rotate": [ + { + "time": 0, + "angle": -3.69 + }, + { + "time": 0.1333, + "angle": -10.42 + }, + { + "time": 0.2666, + "angle": -17.14 + }, + { + "time": 0.4, + "angle": -2.83 + }, + { + "time": 0.5333, + "angle": -3.87 + }, + { + "time": 0.6666, + "angle": 2.78 + }, + { + "time": 0.8, + "angle": 1.68 + }, + { + "time": 0.9333, + "angle": -8.54 + }, + { + "time": 1.0666, + "angle": -3.69 + } + ] + }, + "right shoulder": { + "rotate": [ + { + "time": 0, + "angle": 20.89, + "curve": [ 0.264, 0, 0.75, 1 ] + }, + { + "time": 0.1333, + "angle": 3.72, + "curve": [ 0.272, 0, 0.841, 1 ] + }, + { + "time": 0.6666, + "angle": -278.28 + }, + { + "time": 1.0666, + "angle": 20.89 + } + ], + "translate": [ + { + "time": 0, + "x": -7.84, + "y": 7.19 + }, + { + "time": 0.1333, + "x": -6.36, + "y": 6.42 + }, + { + "time": 0.6666, + "x": -11.07, + "y": 5.25 + }, + { + "time": 1.0666, + "x": -7.84, + "y": 7.19 + } + ] + }, + "right arm": { + "rotate": [ + { + "time": 0, + "angle": -4.02, + "curve": [ 0.267, 0, 0.804, 0.99 ] + }, + { + "time": 0.1333, + "angle": -13.99, + "curve": [ 0.341, 0, 1, 1 ] + }, + { + "time": 0.6666, + "angle": 36.54, + "curve": [ 0.307, 0, 0.787, 0.99 ] + }, + { + "time": 1.0666, + "angle": -4.02 + } + ] + }, + "right hand": { + "rotate": [ + { + "time": 0, + "angle": 22.92 + }, + { + "time": 0.4, + "angle": -8.97 + }, + { + "time": 0.6666, + "angle": 0.51 + }, + { + "time": 1.0666, + "angle": 22.92 + } + ] + }, + "left shoulder": { + "rotate": [ + { + "time": 0, + "angle": -1.47 + }, + { + "time": 0.1333, + "angle": 13.6 + }, + { + "time": 0.6666, + "angle": -280.74 + }, + { + "time": 1.0666, + "angle": -1.47 + } + ], + "translate": [ + { + "time": 0, + "x": -1.76, + "y": 0.56 + }, + { + "time": 0.6666, + "x": -2.47, + "y": 8.14 + }, + { + "time": 1.0666, + "x": -1.76, + "y": 0.56 + } + ] + }, + "left hand": { + "rotate": [ + { + "time": 0, + "angle": 11.58, + "curve": [ 0.169, 0.37, 0.632, 1.55 ] + }, + { + "time": 0.1333, + "angle": 28.13, + "curve": [ 0.692, 0, 0.692, 0.99 ] + }, + { + "time": 0.6666, + "angle": -27.42, + "curve": [ 0.117, 0.41, 0.738, 1.76 ] + }, + { + "time": 0.8, + "angle": -36.32 + }, + { + "time": 1.0666, + "angle": 11.58 + } + ] + }, + "left arm": { + "rotate": [ + { + "time": 0, + "angle": -8.27 + }, + { + "time": 0.1333, + "angle": 18.43 + }, + { + "time": 0.6666, + "angle": 0.88 + }, + { + "time": 1.0666, + "angle": -8.27 + } + ] + }, + "torso": { + "rotate": [ + { + "time": 0, + "angle": -10.28 + }, + { + "time": 0.1333, + "angle": -15.38, + "curve": [ 0.545, 0, 1, 1 ] + }, + { + "time": 0.4, + "angle": -9.78, + "curve": [ 0.58, 0.17, 1, 1 ] + }, + { + "time": 0.6666, + "angle": -15.75 + }, + { + "time": 0.9333, + "angle": -7.06 + }, + { + "time": 1.0666, + "angle": -10.28 + } + ], + "translate": [ + { + "time": 0, + "x": -3.67, + "y": 1.68 + }, + { + "time": 0.1333, + "x": -3.67, + "y": 0.68 + }, + { + "time": 0.4, + "x": -3.67, + "y": 1.97 + }, + { + "time": 0.6666, + "x": -3.67, + "y": -0.14 + }, + { + "time": 1.0666, + "x": -3.67, + "y": 1.68 + } + ] + }, + "right foot": { + "rotate": [ + { + "time": 0, + "angle": -5.25 + }, + { + "time": 0.2666, + "angle": -4.08 + }, + { + "time": 0.4, + "angle": -6.45 + }, + { + "time": 0.5333, + "angle": -5.39 + }, + { + "time": 0.8, + "angle": -11.68 + }, + { + "time": 0.9333, + "angle": 0.46 + }, + { + "time": 1.0666, + "angle": -5.25 + } + ] + }, + "right lower leg": { + "rotate": [ + { + "time": 0, + "angle": -3.39 + }, + { + "time": 0.1333, + "angle": -45.53 + }, + { + "time": 0.2666, + "angle": -2.59 + }, + { + "time": 0.5333, + "angle": -19.53 + }, + { + "time": 0.6666, + "angle": -64.8 + }, + { + "time": 0.8, + "angle": -82.56, + "curve": [ 0.557, 0.18, 1, 1 ] + }, + { + "time": 1.0666, + "angle": -3.39 + } + ] + }, + "hip": { + "rotate": [ + { + "time": 0, + "angle": 0, + "curve": "stepped" + }, + { + "time": 1.0666, + "angle": 0 + } + ], + "translate": [ + { + "time": 0, + "x": 0, + "y": 0 + }, + { + "time": 0.1333, + "x": 0, + "y": -7.61, + "curve": [ 0.272, 0.86, 1, 1 ] + }, + { + "time": 0.4, + "x": 0, + "y": 8.7 + }, + { + "time": 0.5333, + "x": 0, + "y": -0.41 + }, + { + "time": 0.6666, + "x": 0, + "y": -7.05, + "curve": [ 0.235, 0.89, 1, 1 ] + }, + { + "time": 0.8, + "x": 0, + "y": 2.92 + }, + { + "time": 0.9333, + "x": 0, + "y": 6.78 + }, + { + "time": 1.0666, + "x": 0, + "y": 0 + } + ] + }, + "neck": { + "rotate": [ + { + "time": 0, + "angle": 3.6 + }, + { + "time": 0.1333, + "angle": 17.49 + }, + { + "time": 0.2666, + "angle": 6.1 + }, + { + "time": 0.4, + "angle": 3.45 + }, + { + "time": 0.5333, + "angle": 5.17 + }, + { + "time": 0.6666, + "angle": 18.36 + }, + { + "time": 0.8, + "angle": 6.09 + }, + { + "time": 0.9333, + "angle": 2.28 + }, + { + "time": 1.0666, + "angle": 3.6 + } + ] + }, + "head": { + "rotate": [ + { + "time": 0, + "angle": 3.6, + "curve": [ 0, 0, 0.704, 1.61 ] + }, + { + "time": 0.1666, + "angle": -0.2 + }, + { + "time": 0.2666, + "angle": 6.1 + }, + { + "time": 0.4, + "angle": 3.45 + }, + { + "time": 0.5333, + "angle": 5.17, + "curve": [ 0, 0, 0.704, 1.61 ] + }, + { + "time": 0.7, + "angle": 1.1 + }, + { + "time": 0.8, + "angle": 6.09 + }, + { + "time": 0.9333, + "angle": 2.28 + }, + { + "time": 1.0666, + "angle": 3.6 + } + ] + } + } +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/spineboy/eyes-closed.png b/CAAT/documentation/demos/demo34/spineboy/eyes-closed.png new file mode 100755 index 0000000..60718e1 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/eyes-closed.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/eyes.png b/CAAT/documentation/demos/demo34/spineboy/eyes.png new file mode 100755 index 0000000..707c91b Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/eyes.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/head.png b/CAAT/documentation/demos/demo34/spineboy/head.png new file mode 100755 index 0000000..5a98aa3 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/head.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-ankle.png b/CAAT/documentation/demos/demo34/spineboy/left-ankle.png new file mode 100755 index 0000000..fcf9a28 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-ankle.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-arm.png b/CAAT/documentation/demos/demo34/spineboy/left-arm.png new file mode 100755 index 0000000..4447dec Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-arm.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-foot.png b/CAAT/documentation/demos/demo34/spineboy/left-foot.png new file mode 100755 index 0000000..9b87682 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-foot.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-hand.png b/CAAT/documentation/demos/demo34/spineboy/left-hand.png new file mode 100755 index 0000000..b95a352 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-hand.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-lower-leg.png b/CAAT/documentation/demos/demo34/spineboy/left-lower-leg.png new file mode 100755 index 0000000..f316b65 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-pant-bottom.png b/CAAT/documentation/demos/demo34/spineboy/left-pant-bottom.png new file mode 100755 index 0000000..29a05bc Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-pant-bottom.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-shoulder.png b/CAAT/documentation/demos/demo34/spineboy/left-shoulder.png new file mode 100755 index 0000000..7fd429d Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/left-upper-leg.png b/CAAT/documentation/demos/demo34/spineboy/left-upper-leg.png new file mode 100755 index 0000000..f076d5c Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/left-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/license.txt b/CAAT/documentation/demos/demo34/spineboy/license.txt new file mode 100755 index 0000000..179fb62 --- /dev/null +++ b/CAAT/documentation/demos/demo34/spineboy/license.txt @@ -0,0 +1,8 @@ +Copyright (c) 2013, Esoteric Software + + The images in this project may be redistributed as long as they are accompanied + by this license file. The images may not be used for commercial use of any + kind. + + The project file is released into the public domain. It may be used as the basis + for derivative work. \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/spineboy/neck.png b/CAAT/documentation/demos/demo34/spineboy/neck.png new file mode 100755 index 0000000..c7b9388 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/neck.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/pelvis.png b/CAAT/documentation/demos/demo34/spineboy/pelvis.png new file mode 100755 index 0000000..f52c33c Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/pelvis.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-ankle.png b/CAAT/documentation/demos/demo34/spineboy/right-ankle.png new file mode 100755 index 0000000..92fc568 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-ankle.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-arm.png b/CAAT/documentation/demos/demo34/spineboy/right-arm.png new file mode 100755 index 0000000..cac970f Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-arm.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-foot-idle.png b/CAAT/documentation/demos/demo34/spineboy/right-foot-idle.png new file mode 100755 index 0000000..aaf609f Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-foot-idle.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-foot.png b/CAAT/documentation/demos/demo34/spineboy/right-foot.png new file mode 100755 index 0000000..7a06bf2 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-foot.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-hand.png b/CAAT/documentation/demos/demo34/spineboy/right-hand.png new file mode 100755 index 0000000..17c62bf Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-hand.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-lower-leg.png b/CAAT/documentation/demos/demo34/spineboy/right-lower-leg.png new file mode 100755 index 0000000..1f00e8e Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-lower-leg.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-pant-bottom.png b/CAAT/documentation/demos/demo34/spineboy/right-pant-bottom.png new file mode 100755 index 0000000..73309c0 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-pant-bottom.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-shoulder.png b/CAAT/documentation/demos/demo34/spineboy/right-shoulder.png new file mode 100755 index 0000000..23e9a2f Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-shoulder.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/right-upper-leg.png b/CAAT/documentation/demos/demo34/spineboy/right-upper-leg.png new file mode 100755 index 0000000..df0b116 Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/right-upper-leg.png differ diff --git a/CAAT/documentation/demos/demo34/spineboy/skeleton.json b/CAAT/documentation/demos/demo34/spineboy/skeleton.json new file mode 100755 index 0000000..49a4cef --- /dev/null +++ b/CAAT/documentation/demos/demo34/spineboy/skeleton.json @@ -0,0 +1,403 @@ +{ + "bones": [ + { + "name": "root", + "length": 0 + }, + { + "name": "hip", + "parent": "root", + "length": 0, + "x": 0.64, + "y": 114.41 + }, + { + "name": "left upper leg", + "parent": "hip", + "length": 50.39, + "x": 14.45, + "y": 2.81, + "rotation": -89.09 + }, + { + "name": "left lower leg", + "parent": "left upper leg", + "length": 56.45, + "x": 51.78, + "y": 3.46, + "rotation": -16.65 + }, + { + "name": "left foot", + "parent": "left lower leg", + "length": 46.5, + "x": 64.02, + "y": -8.67, + "rotation": 102.43 + }, + { + "name": "right upper leg", + "parent": "hip", + "length": 45.76, + "x": -18.27, + "rotation": -101.13 + }, + { + "name": "right lower leg", + "parent": "right upper leg", + "length": 58.52, + "x": 50.21, + "y": 0.6, + "rotation": -10.7 + }, + { + "name": "right foot", + "parent": "right lower leg", + "length": 45.45, + "x": 64.88, + "y": 0.04, + "rotation": 110.3 + }, + { + "name": "torso", + "parent": "hip", + "length": 85.82, + "x": -6.42, + "y": 1.97, + "rotation": 94.95 + }, + { + "name": "neck", + "parent": "torso", + "length": 18.38, + "x": 83.64, + "y": -1.78, + "rotation": 0.9 + }, + { + "name": "head", + "parent": "neck", + "length": 68.28, + "x": 19.09, + "y": 6.97, + "rotation": -8.94 + }, + { + "name": "right shoulder", + "parent": "torso", + "length": 49.95, + "x": 81.9, + "y": 6.79, + "rotation": 130.6 + }, + { + "name": "right arm", + "parent": "right shoulder", + "length": 36.74, + "x": 49.95, + "y": -0.12, + "rotation": 40.12 + }, + { + "name": "right hand", + "parent": "right arm", + "length": 15.32, + "x": 36.9, + "y": 0.34, + "rotation": 2.35 + }, + { + "name": "left shoulder", + "parent": "torso", + "length": 44.19, + "x": 78.96, + "y": -15.75, + "rotation": -156.96 + }, + { + "name": "left arm", + "parent": "left shoulder", + "length": 35.62, + "x": 44.19, + "y": -0.01, + "rotation": 28.16 + }, + { + "name": "left hand", + "parent": "left arm", + "length": 11.52, + "x": 35.62, + "y": 0.07, + "rotation": 2.7 + }, + { + "name": "pelvis", + "parent": "hip", + "length": 0, + "x": 1.41, + "y": -6.57 + } + ], + "slots": [ + { + "name": "template", + "bone": "root", + "color": "ff898c86" + }, + { + "name": "left shoulder", + "bone": "left shoulder", + "attachment": "left-shoulder" + }, + { + "name": "left arm", + "bone": "left arm", + "attachment": "left-arm" + }, + { + "name": "left hand", + "bone": "left hand", + "attachment": "left-hand" + }, + { + "name": "left foot", + "bone": "left foot", + "attachment": "left-foot" + }, + { + "name": "left lower leg", + "bone": "left lower leg", + "attachment": "left-lower-leg" + }, + { + "name": "left upper leg", + "bone": "left upper leg", + "attachment": "left-upper-leg" + }, + { + "name": "pelvis", + "bone": "pelvis", + "attachment": "pelvis" + }, + { + "name": "right foot", + "bone": "right foot", + "attachment": "right-foot" + }, + { + "name": "right lower leg", + "bone": "right lower leg", + "attachment": "right-lower-leg" + }, + { + "name": "right upper leg", + "bone": "right upper leg", + "attachment": "right-upper-leg" + }, + { + "name": "torso", + "bone": "torso", + "attachment": "torso" + }, + { + "name": "neck", + "bone": "neck", + "attachment": "neck" + }, + { + "name": "headboy", + "bone": "head", + "attachment": "headboy" + }, + { + "name": "eyes", + "bone": "head", + "attachment": "eyes" + }, + { + "name": "right shoulder", + "bone": "right shoulder", + "attachment": "right-shoulder" + }, + { + "name": "right arm", + "bone": "right arm", + "attachment": "right-arm" + }, + { + "name": "right hand", + "bone": "right hand", + "attachment": "right-hand" + } + ], + "skins": { + "default": { + "template": { + "spineboy": { + "y": 167.82, + "width": 145, + "height": 341 + } + }, + "left shoulder": { + "left-shoulder": { + "x": 23.74, + "y": 0.11, + "rotation": 62.01, + "width": 34, + "height": 53 + } + }, + "left arm": { + "left-arm": { + "x": 15.11, + "y": -0.44, + "rotation": 33.84, + "width": 35, + "height": 29 + } + }, + "left hand": { + "left-hand": { + "x": 0.75, + "y": 1.86, + "rotation": 31.14, + "width": 35, + "height": 38 + } + }, + "left foot": { + "left-foot": { + "x": 24.35, + "y": 8.88, + "rotation": 3.32, + "width": 65, + "height": 30 + } + }, + "left lower leg": { + "left-lower-leg": { + "x": 24.55, + "y": -1.92, + "rotation": 105.75, + "width": 49, + "height": 64 + } + }, + "left upper leg": { + "left-upper-leg": { + "x": 26.12, + "y": -1.85, + "rotation": 89.09, + "width": 33, + "height": 67 + } + }, + "pelvis": { + "pelvis": { + "x": -4.83, + "y": 10.62, + "width": 63, + "height": 47 + } + }, + "right foot": { + "right-foot": { + "x": 19.02, + "y": 8.47, + "rotation": 1.52, + "width": 67, + "height": 30 + } + }, + "right lower leg": { + "right-lower-leg": { + "x": 23.28, + "y": -2.59, + "rotation": 111.83, + "width": 51, + "height": 64 + } + }, + "right upper leg": { + "right-upper-leg": { + "x": 23.03, + "y": 0.25, + "rotation": 101.13, + "width": 44, + "height": 70 + } + }, + "torso": { + "torso": { + "x": 44.57, + "y": -7.08, + "rotation": -94.95, + "width": 68, + "height": 92 + } + }, + "neck": { + "neck": { + "x": 9.42, + "y": -3.66, + "rotation": -100.15, + "width": 34, + "height": 28 + } + }, + "headboy": { + "headboy": { + "x": 53.94, + "y": -5.75, + "rotation": -86.9, + "width": 121, + "height": 132 + } + }, + "eyes": { + "eyes-closed": { + "x": 28.77, + "y": -32.86, + "rotation": -86.9, + "width": 34, + "height": 27 + }, + "eyes": { + "x": 28.94, + "y": -32.92, + "rotation": -86.9, + "width": 34, + "height": 27 + } + }, + "right shoulder": { + "right-shoulder": { + "x": 25.86, + "y": 0.03, + "rotation": 134.44, + "width": 52, + "height": 51 + } + }, + "right arm": { + "right-arm": { + "x": 18.34, + "y": -2.64, + "rotation": 94.32, + "width": 21, + "height": 45 + } + }, + "right hand": { + "right-hand": { + "x": 6.82, + "y": 1.25, + "rotation": 91.96, + "width": 32, + "height": 32 + } + } + } + } +} \ No newline at end of file diff --git a/CAAT/documentation/demos/demo34/spineboy/torso.png b/CAAT/documentation/demos/demo34/spineboy/torso.png new file mode 100755 index 0000000..d5a318e Binary files /dev/null and b/CAAT/documentation/demos/demo34/spineboy/torso.png differ diff --git a/CAAT/documentation/demos/demo35/label.html b/CAAT/documentation/demos/demo35/label.html new file mode 100644 index 0000000..efb1cfc --- /dev/null +++ b/CAAT/documentation/demos/demo35/label.html @@ -0,0 +1,208 @@ + + + + + CAAT example: UI.Label + + + + + + + +
    + + +
    + +
    +
    +

    Label - Reload for new layouts

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • None.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • UI.Label object
    • +
    • Defining styles
    • +
    • Adding anchors
    • +
    • Mixing images and text
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo36/spritemap.html b/CAAT/documentation/demos/demo36/spritemap.html new file mode 100644 index 0000000..260f080 --- /dev/null +++ b/CAAT/documentation/demos/demo36/spritemap.html @@ -0,0 +1,261 @@ + + + + + CAAT example: Atlas Bitmaps + + + + + + + +
    + + +
    + +
    +
    +

    Atlas Bitmaps

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • None.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Create SpriteImage objects
    • +
    • Use Atlas bitmaps
    • +
    • Create fonts from sub-images contained in Atlas bitmaps
    • +
    +
    +
    +
    +
    +
    + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo4/coordinates_org.html b/CAAT/documentation/demos/demo4/coordinates_org.html new file mode 100644 index 0000000..cd99a59 --- /dev/null +++ b/CAAT/documentation/demos/demo4/coordinates_org.html @@ -0,0 +1,394 @@ + + + + + CAAT example: Coordinate system demo + + + + + + +
    + + +
    + +
    +
    +

    Homogeneous coordinates

    +
    +
    + +
    +
    +
    +

    + Use the following controls: +

    +
      +
    • Drag and Drop Actors on screen.
    • +
    • Shift+Drag to scale actors.
    • +
    • Control+Drag to rotate actors.
    • +
    • Shift+Alt to unevenly scale actors.
    • +
    • Pinch, rotate and drag on iOS with native gestures.
    • +
    • Priority input lists usage.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Built-in drag'n'drop and rotate/scale.
    • +
    • Homogeneous coordinate system. Despite Actor's scale, it is always of the + same size, and thus, always returns internal coordinates related to its original + size. When an Actor is rotated, local-reported coordinates honor an homogeneous + coordinate system as well. +
    • +
    • TextActor optimization by caching it as bitmap.
    • +
    • Manipulating Actors zorder.
    • +
    • How to set a priority input list. In this sample the blue actor will get input prioritized + to any other rectangles and its cointained children before the blue rectangle itself.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo5/numbers.png b/CAAT/documentation/demos/demo5/numbers.png new file mode 100644 index 0000000..912a466 Binary files /dev/null and b/CAAT/documentation/demos/demo5/numbers.png differ diff --git a/CAAT/documentation/demos/demo5/text-on-path_org.html b/CAAT/documentation/demos/demo5/text-on-path_org.html new file mode 100644 index 0000000..0eeb83c --- /dev/null +++ b/CAAT/documentation/demos/demo5/text-on-path_org.html @@ -0,0 +1,256 @@ + + + + + + CAAT example: Text on Path + + + + + +
    + + +
    + +
    +
    +

    Text on Path

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Drag path handles.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Constructing a Path and adding segments to it.
    • +
    • Showing a path by associating it to a PathActor.
    • +
    • Sprited fonts as text with TextActor.
    • +
    • Path management by calling setInteractive method.
    • +
    • Setting up a TextActor.
    • +
    • Setting a path for a TextActor
    • +
    • CAAT.Interpolator on path behavior.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo6/accelerometer_org.html b/CAAT/documentation/demos/demo6/accelerometer_org.html new file mode 100644 index 0000000..7fb8bf0 --- /dev/null +++ b/CAAT/documentation/demos/demo6/accelerometer_org.html @@ -0,0 +1,327 @@ + + + + + + + CAAT example: Accelerometer + + + + + +
    + + +
    + +
    +
    +

    Accelerometer

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Move your device. Working only on Firefox and Chrome.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Getting CAAT's accelerometer info.
    • +
    • Custom paint method for an Actor.
    • +
    • Hook on scene lifecycle (onRenderStart/onRenderEnd)
    • +
    +
    +
    +
    +
    +
    + + + + + +" + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo7/anchors_org.html b/CAAT/documentation/demos/demo7/anchors_org.html new file mode 100644 index 0000000..3536786 --- /dev/null +++ b/CAAT/documentation/demos/demo7/anchors_org.html @@ -0,0 +1,368 @@ + + + + + + CAAT example: Affine transformation anchors + + + + + + +
    + + +
    + +
    +
    +

    Affine transformation anchors

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Move mouse across experiment area.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Properly define Behaviors.
    • +
    • View different anchoring effects.
    • +
    • CompoundImage management.
    • +
    • SpriteActor definition.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo8/hierarchy_org.html b/CAAT/documentation/demos/demo8/hierarchy_org.html new file mode 100644 index 0000000..ca87952 --- /dev/null +++ b/CAAT/documentation/demos/demo8/hierarchy_org.html @@ -0,0 +1,308 @@ + + + + + + CAAT example: Hierarchical affine transforms + + + + + + +
    + + +
    + +
    +
    +

    Hierarchical affine transforms

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • None.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Properly define Behaviors with ANCHOR_CUSTOM as anchor point.
    • +
    • Properly define child/parent relationship.
    • +
    • Use of GenericBehavior to change Sun size.
    • +
    • Use of out-of-the-box StarActor.
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/demo9/behaviors_org.html b/CAAT/documentation/demos/demo9/behaviors_org.html new file mode 100644 index 0000000..af7e2f7 --- /dev/null +++ b/CAAT/documentation/demos/demo9/behaviors_org.html @@ -0,0 +1,274 @@ + + + + + CAAT example: Interactivity. Setting behaviors. + + + + + + +
    + + +
    + +
    +
    +

    Interactivity. Setting behaviors.

    +
    +
    + +
    +
    +
    +

    Controls:

    +
      +
    • Mouse Move over number Actors.
    • +
    • Mouse click on number Actors.
    • +
    +
    +
    +

    + This demo features the following elements: +

    +
      +
    • Respond to mouse events.
    • +
    • Generate a low-overhead Actor cache.
    • +
    • Manage layers of Actors (numbers and stars).
    • +
    +
    +
    +
    +
    +
    + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/index.html b/CAAT/documentation/demos/index.html new file mode 100644 index 0000000..9eec55c --- /dev/null +++ b/CAAT/documentation/demos/index.html @@ -0,0 +1,53 @@ + + + + + -- CAAT examples index -- + + + + + +

    Demos

    + +
    + Skeletal animation + Sprites control + Path management + Procedural fishpond + Sprites traversing a random path + Pixel perfect collistion detection with mouse + Sprites traversing a random path + accelerometer input + Actor anchors + Hierarchical rotations + Hierarchy II + Some actor behaviors + Procedural grass + Circles collision + Box2D integration + Scene transitions + Scene timers + SpriteImage demo + Masking + Video playback and manipullation + Keyboard demo + Quadtree based collision + Flightcontrol like demo + TileMap engine preview + Multitouch test + Action To + Path Creation + Flip cards + Fonts + Paint demo + Auto Layout + UI.TextActor vs drawString + SVG Parser + CSS3 @KeyFrames + +
    + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/menu/menu.html b/CAAT/documentation/demos/menu/menu.html new file mode 100644 index 0000000..8fd8774 --- /dev/null +++ b/CAAT/documentation/demos/menu/menu.html @@ -0,0 +1,57 @@ +

    Games

    + + +

    Demos

    + + + +

    Tutorial

    + \ No newline at end of file diff --git a/CAAT/documentation/demos/menu/menu.js b/CAAT/documentation/demos/menu/menu.js new file mode 100644 index 0000000..d4a5097 --- /dev/null +++ b/CAAT/documentation/demos/menu/menu.js @@ -0,0 +1,43 @@ +(function() { + var req; + + function loadXMLDoc() { + req = false; + if(window.XMLHttpRequest && !(window.ActiveXObject)) { + try { + req = new XMLHttpRequest(); + } catch(e) { + req = false; + } + } else if(window.ActiveXObject) { + try { + req = new ActiveXObject("Msxml2.XMLHTTP"); + } catch(e) { + try { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } catch(e) { + req = false; + } + } + } + if(req) { + req.onreadystatechange = processReqChange; + req.open("GET", '../menu/menu.html', true); + req.send(""); + } + } + + function processReqChange() { + if (req.readyState == 4) { + if (req.status == 200) { + var menu= document.getElementById('menu'); + menu.innerHTML= req.responseText; + } else { + document.getElementById('menu').innerHTML="Unable to load menu"; + } + } + } + + window.addEventListener('load',loadXMLDoc,false); + +})(); \ No newline at end of file diff --git a/CAAT/documentation/demos/style/demo.css b/CAAT/documentation/demos/style/demo.css new file mode 100644 index 0000000..a8b10ae --- /dev/null +++ b/CAAT/documentation/demos/style/demo.css @@ -0,0 +1,113 @@ +body { + margin: 0; + padding: 0; + background: #fff; + font-family: 'Lucida Grande', Geneva; + font-size: 12px; +} + +h1 { + border-bottom: 1px solid #888; + line-height: 1.5em; +} + +#page { + margin: 0 auto; + position: relative; + width: 950px; +} + +#page-tutorial { + margin: 0 auto; + position: relative; + width: 970px; +} + + +#header { + height: 10px; + width: 950px; +} + +#header-tutorial { + height: 10px; + width: 970px; +} + + +#experiment h1 { + font:normal 16pt Arial; + color:#FFFFFF; + text-shadow: + 0 1px 0 #ccc, + 0 2px 0 #c9c9c9, + 0 3px 0 #bbb, + 0 4px 0 #b9b9b9, + 0 5px 0 #aaa, + 0 6px 1px rgba(0,0,0,.1), + 0 0 5px rgba(0,0,0,.1), + 0 1px 3px rgba(0,0,0,.3), + 0 3px 5px rgba(0,0,0,.2), + 0 5px 10px rgba(0,0,0,.25), + 0 10px 10px rgba(0,0,0,.2); + + border: 0; +} + + +#content #menu { + float: left; + width: 130px; + padding-left: 10px; + padding-right: 10px; +} + +#content #menu-tutorial { + float: left; + width: 150px; + padding-left: 10px; + padding-right: 10px; +} + + +#content #experiment { + float: left; + width: 800px; +} + +#content #experiment #experiment-holder { + width: 800px; + margin: 0 auto; + padding: 0; + border: 1px solid #000; +} + +#content #tutorial { + float: left; + width: 800px; +} + +#menu ul { + padding: 4px 0 !important; + overflow: hidden; + margin: 0; +} + +#menu li { + text-indent: 0px; + margin-left: 0; +} + +a { + text-decoration: none; + color: #55f; +} + +a:hover { + background: #55f; + color: #fff; +} + +#menu .indented { + text-indent: 15px; !important; +} \ No newline at end of file diff --git a/CAAT/documentation/demos/templates/startup-with-splash/splash/lading.png b/CAAT/documentation/demos/templates/startup-with-splash/splash/lading.png new file mode 100644 index 0000000..82da8da Binary files /dev/null and b/CAAT/documentation/demos/templates/startup-with-splash/splash/lading.png differ diff --git a/CAAT/documentation/demos/templates/startup-with-splash/splash/rueda.png b/CAAT/documentation/demos/templates/startup-with-splash/splash/rueda.png new file mode 100644 index 0000000..e23dbc5 Binary files /dev/null and b/CAAT/documentation/demos/templates/startup-with-splash/splash/rueda.png differ diff --git a/CAAT/documentation/demos/templates/startup-with-splash/splash/splash.jpg b/CAAT/documentation/demos/templates/startup-with-splash/splash/splash.jpg new file mode 100644 index 0000000..2d5f2e4 Binary files /dev/null and b/CAAT/documentation/demos/templates/startup-with-splash/splash/splash.jpg differ diff --git a/CAAT/documentation/demos/templates/startup-with-splash/template-with-splash.html b/CAAT/documentation/demos/templates/startup-with-splash/template-with-splash.html new file mode 100644 index 0000000..2d25dc1 --- /dev/null +++ b/CAAT/documentation/demos/templates/startup-with-splash/template-with-splash.html @@ -0,0 +1,83 @@ + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/templates/startup-wo-splash/template.html b/CAAT/documentation/demos/templates/startup-wo-splash/template.html new file mode 100644 index 0000000..5438573 --- /dev/null +++ b/CAAT/documentation/demos/templates/startup-wo-splash/template.html @@ -0,0 +1,70 @@ + + + + + + + + + + \ No newline at end of file diff --git a/CAAT/documentation/demos/thumbs/demo1.png b/CAAT/documentation/demos/thumbs/demo1.png new file mode 100644 index 0000000..264e805 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo1.png differ diff --git a/CAAT/documentation/demos/thumbs/demo10.png b/CAAT/documentation/demos/thumbs/demo10.png new file mode 100644 index 0000000..35d3510 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo10.png differ diff --git a/CAAT/documentation/demos/thumbs/demo11.png b/CAAT/documentation/demos/thumbs/demo11.png new file mode 100644 index 0000000..b63f733 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo11.png differ diff --git a/CAAT/documentation/demos/thumbs/demo12.png b/CAAT/documentation/demos/thumbs/demo12.png new file mode 100644 index 0000000..e3206e0 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo12.png differ diff --git a/CAAT/documentation/demos/thumbs/demo13.png b/CAAT/documentation/demos/thumbs/demo13.png new file mode 100644 index 0000000..6d0a580 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo13.png differ diff --git a/CAAT/documentation/demos/thumbs/demo14.png b/CAAT/documentation/demos/thumbs/demo14.png new file mode 100644 index 0000000..4d4103c Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo14.png differ diff --git a/CAAT/documentation/demos/thumbs/demo15.png b/CAAT/documentation/demos/thumbs/demo15.png new file mode 100644 index 0000000..9ad9f5a Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo15.png differ diff --git a/CAAT/documentation/demos/thumbs/demo16.png b/CAAT/documentation/demos/thumbs/demo16.png new file mode 100644 index 0000000..e55869d Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo16.png differ diff --git a/CAAT/documentation/demos/thumbs/demo17.png b/CAAT/documentation/demos/thumbs/demo17.png new file mode 100644 index 0000000..2040f65 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo17.png differ diff --git a/CAAT/documentation/demos/thumbs/demo18.png b/CAAT/documentation/demos/thumbs/demo18.png new file mode 100644 index 0000000..32e2476 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo18.png differ diff --git a/CAAT/documentation/demos/thumbs/demo19.png b/CAAT/documentation/demos/thumbs/demo19.png new file mode 100644 index 0000000..8d25d41 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo19.png differ diff --git a/CAAT/documentation/demos/thumbs/demo2.png b/CAAT/documentation/demos/thumbs/demo2.png new file mode 100644 index 0000000..cc03f65 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo2.png differ diff --git a/CAAT/documentation/demos/thumbs/demo20.png b/CAAT/documentation/demos/thumbs/demo20.png new file mode 100644 index 0000000..7e3684c Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo20.png differ diff --git a/CAAT/documentation/demos/thumbs/demo21.png b/CAAT/documentation/demos/thumbs/demo21.png new file mode 100644 index 0000000..1cc229b Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo21.png differ diff --git a/CAAT/documentation/demos/thumbs/demo22.png b/CAAT/documentation/demos/thumbs/demo22.png new file mode 100644 index 0000000..ccc1ba9 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo22.png differ diff --git a/CAAT/documentation/demos/thumbs/demo23.png b/CAAT/documentation/demos/thumbs/demo23.png new file mode 100644 index 0000000..ac3850f Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo23.png differ diff --git a/CAAT/documentation/demos/thumbs/demo24.png b/CAAT/documentation/demos/thumbs/demo24.png new file mode 100644 index 0000000..95e2860 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo24.png differ diff --git a/CAAT/documentation/demos/thumbs/demo25.png b/CAAT/documentation/demos/thumbs/demo25.png new file mode 100644 index 0000000..78112ca Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo25.png differ diff --git a/CAAT/documentation/demos/thumbs/demo26.png b/CAAT/documentation/demos/thumbs/demo26.png new file mode 100644 index 0000000..6816c3d Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo26.png differ diff --git a/CAAT/documentation/demos/thumbs/demo27.png b/CAAT/documentation/demos/thumbs/demo27.png new file mode 100644 index 0000000..b2dbcf6 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo27.png differ diff --git a/CAAT/documentation/demos/thumbs/demo28.png b/CAAT/documentation/demos/thumbs/demo28.png new file mode 100644 index 0000000..c9b460b Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo28.png differ diff --git a/CAAT/documentation/demos/thumbs/demo29.png b/CAAT/documentation/demos/thumbs/demo29.png new file mode 100644 index 0000000..32f9bd2 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo29.png differ diff --git a/CAAT/documentation/demos/thumbs/demo3.png b/CAAT/documentation/demos/thumbs/demo3.png new file mode 100644 index 0000000..cedd52b Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo3.png differ diff --git a/CAAT/documentation/demos/thumbs/demo30.png b/CAAT/documentation/demos/thumbs/demo30.png new file mode 100644 index 0000000..9ef0299 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo30.png differ diff --git a/CAAT/documentation/demos/thumbs/demo31.png b/CAAT/documentation/demos/thumbs/demo31.png new file mode 100644 index 0000000..f607c01 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo31.png differ diff --git a/CAAT/documentation/demos/thumbs/demo32.png b/CAAT/documentation/demos/thumbs/demo32.png new file mode 100644 index 0000000..7d99019 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo32.png differ diff --git a/CAAT/documentation/demos/thumbs/demo33.png b/CAAT/documentation/demos/thumbs/demo33.png new file mode 100644 index 0000000..7a84d1b Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo33.png differ diff --git a/CAAT/documentation/demos/thumbs/demo34.png b/CAAT/documentation/demos/thumbs/demo34.png new file mode 100644 index 0000000..0525cef Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo34.png differ diff --git a/CAAT/documentation/demos/thumbs/demo4.png b/CAAT/documentation/demos/thumbs/demo4.png new file mode 100644 index 0000000..8b70f17 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo4.png differ diff --git a/CAAT/documentation/demos/thumbs/demo5.png b/CAAT/documentation/demos/thumbs/demo5.png new file mode 100644 index 0000000..f1eabb4 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo5.png differ diff --git a/CAAT/documentation/demos/thumbs/demo6.png b/CAAT/documentation/demos/thumbs/demo6.png new file mode 100644 index 0000000..1e1ff05 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo6.png differ diff --git a/CAAT/documentation/demos/thumbs/demo7.png b/CAAT/documentation/demos/thumbs/demo7.png new file mode 100644 index 0000000..56c960f Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo7.png differ diff --git a/CAAT/documentation/demos/thumbs/demo8.png b/CAAT/documentation/demos/thumbs/demo8.png new file mode 100644 index 0000000..f685a60 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo8.png differ diff --git a/CAAT/documentation/demos/thumbs/demo9.png b/CAAT/documentation/demos/thumbs/demo9.png new file mode 100644 index 0000000..50d77e3 Binary files /dev/null and b/CAAT/documentation/demos/thumbs/demo9.png differ diff --git a/CAAT/documentation/jsdoc/files.html b/CAAT/documentation/jsdoc/files.html new file mode 100644 index 0000000..bb93f83 --- /dev/null +++ b/CAAT/documentation/jsdoc/files.html @@ -0,0 +1,1562 @@ + + + + + + JsDoc Reference - File Index + + + + + + + + +
    + +
    +

    Classes

    + +
    +
    + +
    +

    File Index

    + + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
    + + \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/index.html b/CAAT/documentation/jsdoc/index.html new file mode 100644 index 0000000..3fec5a2 --- /dev/null +++ b/CAAT/documentation/jsdoc/index.html @@ -0,0 +1,1178 @@ + + + + + + JsDoc Reference - Index + + + + + + + + +
    + +
    +

    Classes

    + +
    +
    + +
    +

    Class Index

    + + +
    +

    _global_

    + +
    +
    + +
    +

    CAAT

    + +
    +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +
    +

    CAAT.Class

    + +
    +
    + +
    +

    CAAT.CSS

    + +
    +
    + +
    +

    CAAT.Event

    + +
    +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +
    +

    CAAT.KEYS

    + +
    +
    + +
    +

    CAAT.Math

    + +
    +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + + +
    + +
    +

    CAAT.WebGL

    + +
    +
    + + +
    + + +
    + + +
    + + +
    + +
    +

    String

    + +
    +
    + + +
    +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
    + + \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html new file mode 100644 index 0000000..9129fdb --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html @@ -0,0 +1,997 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.AlphaBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.AlphaBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: AlphaBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + endAlpha +
    +
    Ending alpha transparency value.
    +
    <private>   + +
    Starting alpha transparency value.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      + +
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize) +
    +
    +
      + +
    +
      + +
    +
      +
    parse(obj) +
    +
    +
      +
    setForTime(time, actor) +
    +
    Applies corresponding alpha transparency value for a given time.
    +
      +
    setValues(start, end) +
    +
    Set alpha transparency minimum and maximum value.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    __init, addListener, apply, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setRelativeValues, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.AlphaBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + endAlpha + +
    +
    + Ending alpha transparency value. Between 0 and 1. + + +
    + + + + + + + + +
    + + +
    <private> + + + startAlpha + +
    +
    + Starting alpha transparency value. Between 0 and 1. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + calculateKeyFrameData(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getKeyFrameDataValues(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPropertyName() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {number} + setForTime(time, actor) + +
    +
    + Applies corresponding alpha transparency value for a given time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    the time to apply the scale for.
    + +
    + actor + +
    +
    the target actor to set transparency for.
    + +
    + + + + + +
    +
    Returns:
    + +
    {number} the alpha value set. Normalized from 0 (total transparency) to 1 (total opacity)
    + +
    + + + + +
    + + +
    + + + setValues(start, end) + +
    +
    + Set alpha transparency minimum and maximum value. +This value can be coerced by Actor's property isGloblAlpha. + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    {number} a float indicating the starting alpha value.
    + +
    + end + +
    +
    {number} a float indicating the ending alpha value.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html new file mode 100644 index 0000000..69e3d57 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html @@ -0,0 +1,660 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.BaseBehavior.Status + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Behavior.BaseBehavior.Status +

    + + +

    + + + + + + +
    Defined in: BaseBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    Internal behavior status values.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Behavior.BaseBehavior.Status.EXPIRED +
    +
    +
    <static>   +
    + CAAT.Behavior.BaseBehavior.Status.NOT_STARTED +
    +
    +
    <static>   +
    + CAAT.Behavior.BaseBehavior.Status.STARTED +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Behavior.BaseBehavior.Status +
    + +
    + Internal behavior status values. Do not assign directly. + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Behavior.BaseBehavior.Status.EXPIRED + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.BaseBehavior.Status.NOT_STARTED + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.BaseBehavior.Status.STARTED + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html new file mode 100644 index 0000000..52d9d0e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html @@ -0,0 +1,2661 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.BaseBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.BaseBehavior +

    + + +

    + + + + + + +
    Defined in: BaseBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    The BaseBehavior is the base class of all Behavior modifiers: + +
  • AlphaBehabior +
  • RotateBehavior +
  • ScaleBehavior +
  • Scale1Behavior +
  • PathBehavior +
  • GenericBehavior +
  • ContainerBehavior + +Behavior base class.
  • +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + actor +
    +
    The actor this behavior will be applied to.
    +
    <private>   + +
    Behavior application duration time related to scene time.
    +
    <private>   + +
    Behavior application start time related to scene time.
    +
    <private>   + +
    Will this behavior apply for ever in a loop ?
    +
    <private>   + +
    if true, this behavior will be removed from the this.actor instance when it expires.
    +
      + +
    Apply the behavior, or just calculate the values ?
    +
      +
    + id +
    +
    An id to identify this behavior.
    +
    <private>   + +
    An interpolator object to apply behaviors using easing functions, etc.
    +
      + +
    does this behavior apply relative values ??
    +
    <private>   + +
    Behavior lifecycle observer list.
    +
    <private>   +
    + solved +
    +
    Is this behavior solved ? When called setDelayTime, this flag identifies whether the behavior +is in time relative to the scene.
    +
    <private>   +
    + status +
    +
    behavior status.
    +
    <private>   + +
    Initial offset to apply this behavior the first time.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    Constructor delegate function.
    +
      +
    addListener(behaviorListener) +
    +
    Adds an observer to this behavior.
    +
      +
    apply(time, actor) +
    +
    This method must no be called directly.
    +
      + +
    Calculate a CSS3 @key-frame for this behavior at the given time.
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize) +
    +
    Calculate a complete CSS3 @key-frame set for this behavior.
    +
      + +
    Remove all registered listeners to the behavior.
    +
    <private>   +
    fireBehaviorAppliedEvent(actor, time, normalizedTime, value) +
    +
    Notify observers about behavior being applied.
    +
    <private>   +
    fireBehaviorExpiredEvent(actor, time) +
    +
    Notify observers about expiration event.
    +
    <private>   +
    fireBehaviorStartedEvent(actor, time) +
    +
    Notify observers the first time the behavior is applied.
    +
      + +
    +
      + +
    Calculate a CSS3 @key-frame data values instead of building a CSS3 @key-frame value.
    +
      + +
    Get this behaviors CSS property name application.
    +
      + +
    +
      +
    initialize(overrides) +
    +
    +
      +
    isBehaviorInTime(time, actor) +
    +
    Chekcs whether the behaviour is in scene time.
    +
      +
    isCycle() +
    +
    +
    <private>   +
    normalizeTime(time) +
    +
    Convert scene time into something more manageable for the behavior.
    +
    <static>   +
    CAAT.Behavior.BaseBehavior.parse(obj) +
    +
    +
      +
    parse(obj) +
    +
    Parse a behavior of this type.
    +
      +
    setCycle(bool) +
    +
    Sets the behavior to cycle, ie apply forever.
    +
      + +
    Sets the default interpolator to a linear ramp, that is, behavior will be applied linearly.
    +
      +
    setDelayTime(delay, duration) +
    +
    Sets behavior start time and duration.
    +
    <private>   +
    setExpired(actor, time) +
    +
    Sets the behavior as expired.
    +
    <private>   +
    setForTime(actor, time) +
    +
    This method must be overriden for every Behavior breed.
    +
      +
    setFrameTime(startTime, duration) +
    +
    Sets behavior start time and duration.
    +
      +
    setId(id) +
    +
    Sets this behavior id.
    +
      +
    setInterpolator(interpolator) +
    +
    Changes behavior default interpolator to another instance of CAAT.Interpolator.
    +
      + +
    Make this behavior not applicable.
    +
      + +
    Sets default interpolator to be linear from 0.
    +
      +
    setRelative(bool) +
    +
    Set this behavior as relative value application to some other measures.
    +
      + +
    +
    <private>   +
    setStatus(st) +
    +
    Set this behavior status
    +
      +
    setTimeOffset(offset) +
    +
    Set this behavior offset time.
    +
      + +
    Set whether this behavior will apply behavior values to a reference Actor instance.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.BaseBehavior() +
    + +
    + The BaseBehavior is the base class of all Behavior modifiers: + +
  • AlphaBehabior +
  • RotateBehavior +
  • ScaleBehavior +
  • Scale1Behavior +
  • PathBehavior +
  • GenericBehavior +
  • ContainerBehavior + +Behavior base class. + +

    +A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator. +In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same +time interval. +

    +A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified +period. +

    +A behavior is guaranteed to notify (if any observer is registered) on behavior expiration. +

    +A behavior can keep an unlimited observers. Observers are objects of the form: +

    + +{ + behaviorExpired : function( behavior, time, actor); + behaviorApplied : function( behavior, time, normalizedTime, actor, value); +} + +

    +behaviorExpired: function( behavior, time, actor). This method will be called for any registered observer when +the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time +granurality. +

    +behaviorApplied : function( behavior, time, normalizedTime, actor, value). This method will be called once per +frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be +called multiple times. +

    +Every behavior is applied to a concrete Actor. +Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and +is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration. +

    +You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify +behaviorExpired to its registered observers. +

    +Other Behaviors simply must supply with the method setForTime(time, actor) overriden. + + + + + + + + + + + + + + + + + + + +

    + Field Detail +
    + + +
    <private> + + + actor + +
    +
    + The actor this behavior will be applied to. + + +
    + + + + + + + + +
    + + +
    <private> + + + behaviorDuration + +
    +
    + Behavior application duration time related to scene time. + + +
    + + + + + + + + +
    + + +
    <private> + + + behaviorStartTime + +
    +
    + Behavior application start time related to scene time. + + +
    + + + + + + + + +
    + + +
    <private> + + + cycleBehavior + +
    +
    + Will this behavior apply for ever in a loop ? + + +
    + + + + + + + + +
    + + +
    <private> + + + discardable + +
    +
    + if true, this behavior will be removed from the this.actor instance when it expires. + + +
    + + + + + + + + +
    + + +
    + + + doValueApplication + +
    +
    + Apply the behavior, or just calculate the values ? + + +
    + + + + + + + + +
    + + +
    + + + id + +
    +
    + An id to identify this behavior. + + +
    + + + + + + + + +
    + + +
    <private> + + + interpolator + +
    +
    + An interpolator object to apply behaviors using easing functions, etc. +Unless otherwise specified, it will be linearly applied. + + +
    + + + + + + + + +
    + + +
    + + + isRelative + +
    +
    + does this behavior apply relative values ?? + + +
    + + + + + + + + +
    + + +
    <private> + + + lifecycleListenerList + +
    +
    + Behavior lifecycle observer list. + + +
    + + + + + + + + +
    + + +
    <private> + + + solved + +
    +
    + Is this behavior solved ? When called setDelayTime, this flag identifies whether the behavior +is in time relative to the scene. + + +
    + + + + + + + + +
    + + +
    <private> + + + status + +
    +
    + behavior status. + + +
    + + + + + + + + +
    + + +
    <private> + + + timeOffset + +
    +
    + Initial offset to apply this behavior the first time. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + {this} + __init() + +
    +
    + Constructor delegate function. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {this}
    + +
    + + + + +
    + + +
    + + + addListener(behaviorListener) + +
    +
    + Adds an observer to this behavior. + + +
    + + + + +
    +
    Parameters:
    + +
    + behaviorListener + +
    +
    an observer instance.
    + +
    + + + + + + + + +
    + + +
    + + + apply(time, actor) + +
    +
    + This method must no be called directly. +The director loop will call this method in orther to apply actor behaviors. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    the scene time the behaviro is being applied at.
    + +
    + actor + +
    +
    a CAAT.Actor instance the behavior is being applied to.
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFrameData(time) + +
    +
    + Calculate a CSS3 @key-frame for this behavior at the given time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + Calculate a complete CSS3 @key-frame set for this behavior. + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    {string} browser vendor prefix
    + +
    + name + +
    +
    {string} keyframes animation name
    + +
    + keyframessize + +
    +
    {number} number of keyframes to generate
    + +
    + + + + + + + + +
    + + +
    + + + emptyListenerList() + +
    +
    + Remove all registered listeners to the behavior. + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + fireBehaviorAppliedEvent(actor, time, normalizedTime, value) + +
    +
    + Notify observers about behavior being applied. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    a CAAT.Actor instance the behavior is being applied to.
    + +
    + time + +
    +
    the scene time of behavior application.
    + +
    + normalizedTime + +
    +
    the normalized time (0..1) considering 0 behavior start time and 1 +behaviorStartTime+behaviorDuration.
    + +
    + value + +
    +
    the value being set for actor properties. each behavior will supply with its own value version.
    + +
    + + + + + + + + +
    + + +
    <private> + + + fireBehaviorExpiredEvent(actor, time) + +
    +
    + Notify observers about expiration event. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    a CAAT.Actor instance
    + +
    + time + +
    +
    an integer with the scene time the behavior was expired at.
    + +
    + + + + + + + + +
    + + +
    <private> + + + fireBehaviorStartedEvent(actor, time) + +
    +
    + Notify observers the first time the behavior is applied. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getDuration() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    an integer indicating the behavior duration time in ms.
    + +
    + + + + +
    + + +
    + + + getKeyFrameDataValues(time) + +
    +
    + Calculate a CSS3 @key-frame data values instead of building a CSS3 @key-frame value. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + {String} + getPropertyName() + +
    +
    + Get this behaviors CSS property name application. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {String}
    + +
    + + + + +
    + + +
    + + + getStartTime() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    an integer indicating the behavior start time in ms..
    + +
    + + + + +
    + + +
    + + + initialize(overrides) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + overrides + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isBehaviorInTime(time, actor) + +
    +
    + Chekcs whether the behaviour is in scene time. +In case it gets out of scene time, and has not been tagged as expired, the behavior is expired and observers +are notified about that fact. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    the scene time to check the behavior against.
    + +
    + actor + +
    +
    the actor the behavior is being applied to.
    + +
    + + + + + +
    +
    Returns:
    + +
    a boolean indicating whether the behavior is in scene time.
    + +
    + + + + +
    + + +
    + + + isCycle() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + normalizeTime(time) + +
    +
    + Convert scene time into something more manageable for the behavior. +behaviorStartTime will be 0 and behaviorStartTime+behaviorDuration will be 1. +the time parameter will be proportional to those values. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    the scene time to be normalized. an integer.
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.BaseBehavior.parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + Parse a behavior of this type. + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    {object} an object with a behavior definition.
    + +
    + + + + + + + + +
    + + +
    + + + setCycle(bool) + +
    +
    + Sets the behavior to cycle, ie apply forever. + + +
    + + + + +
    +
    Parameters:
    + +
    + bool + +
    +
    a boolean indicating whether the behavior is cycle.
    + +
    + + + + + + + + +
    + + +
    + + + setDefaultInterpolator() + +
    +
    + Sets the default interpolator to a linear ramp, that is, behavior will be applied linearly. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setDelayTime(delay, duration) + +
    +
    + Sets behavior start time and duration. Start time is relative to scene time. + +a call to + setFrameTime( scene.time, duration ) is equivalent to + setDelayTime( 0, duration ) + + +
    + + + + +
    +
    Parameters:
    + +
    + delay + +
    +
    {number}
    + +
    + duration + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    <private> + + + setExpired(actor, time) + +
    +
    + Sets the behavior as expired. +This method must not be called directly. It is an auxiliary method to isBehaviorInTime method. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    {CAAT.Actor}
    + +
    + time + +
    +
    {integer} the scene time.
    + +
    + + + + + + + + +
    + + +
    <private> + + + setForTime(actor, time) + +
    +
    + This method must be overriden for every Behavior breed. +Must not be called directly. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    {CAAT.Actor} a CAAT.Actor instance.
    + +
    + time + +
    +
    {number} an integer with the scene time.
    + +
    + + + + + + + + +
    + + +
    + + + setFrameTime(startTime, duration) + +
    +
    + Sets behavior start time and duration. Start time is set absolutely relative to scene time. + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    {number} an integer indicating behavior start time in scene time in ms..
    + +
    + duration + +
    +
    {number} an integer indicating behavior duration in ms.
    + +
    + + + + + + + + +
    + + +
    + + + setId(id) + +
    +
    + Sets this behavior id. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object}
    + +
    + + + + + + + + +
    + + +
    + + + setInterpolator(interpolator) + +
    +
    + Changes behavior default interpolator to another instance of CAAT.Interpolator. +If the behavior is not defined by CAAT.Interpolator factory methods, the interpolation function must return +its values in the range 0..1. The behavior will only apply for such value range. + + +
    + + + + +
    +
    Parameters:
    + +
    + interpolator + +
    +
    a CAAT.Interpolator instance.
    + +
    + + + + + + + + +
    + + +
    + + {*} + setOutOfFrameTime() + +
    +
    + Make this behavior not applicable. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setPingPong() + +
    +
    + Sets default interpolator to be linear from 0..1 and from 1..0. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {*} + setRelative(bool) + +
    +
    + Set this behavior as relative value application to some other measures. +Each Behavior will define its own. + + +
    + + + + +
    +
    Parameters:
    + +
    + bool + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setRelativeValues() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + {*} + setStatus(st) + +
    +
    + Set this behavior status + + +
    + + + + +
    +
    Parameters:
    + +
    + st + +
    +
    {CAAT.Behavior.BaseBehavior.Status}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + setTimeOffset(offset) + +
    +
    + Set this behavior offset time. +This method is intended to make a behavior start applying (the first) time from a different +start time. + + +
    + + + + +
    +
    Parameters:
    + +
    + offset + +
    +
    {number} between 0 and 1
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + setValueApplication(apply) + +
    +
    + Set whether this behavior will apply behavior values to a reference Actor instance. + + +
    + + + + +
    +
    Parameters:
    + +
    + apply + +
    +
    {boolean}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + + + + + + + + +
    + + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html new file mode 100644 index 0000000..c1c3003 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html @@ -0,0 +1,1469 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.ContainerBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.ContainerBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: ContainerBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + behaviors +
    +
    A collection of behaviors.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(conforming) +
    +
    +
      +
    addBehavior(behavior) +
    +
    Add a new behavior to the container.
    +
      +
    apply(time, actor) +
    +
    Applies every contained Behaviors.
    +
      +
    behaviorApplied(behavior, scenetime, time, actor, value) +
    +
    +
      +
    behaviorExpired(behavior, time, actor) +
    +
    This method is the observer implementation for every contained behavior.
    +
      +
    calculateKeyFrameData(referenceTime, prefix) +
    +
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize, anchorX, anchorY) +
    +
    +
      +
    conformToDuration(duration) +
    +
    Proportionally change this container duration to its children.
    +
      + +
    Get a behavior by mathing its id.
    +
      +
    getKeyFrameDataValues(referenceTime) +
    +
    +
      +
    parse(obj) +
    +
    +
      +
    setCycle(cycle, recurse) +
    +
    +
      +
    setDelayTime(start, duration) +
    +
    +
      +
    setExpired(actor, time) +
    +
    Expire this behavior and the children applied at the parameter time.
    +
      +
    setForTime(time{number}) +
    +
    Implementation method of the behavior.
    +
      +
    setFrameTime(start, duration) +
    +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    addListener, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getPropertyName, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setDefaultInterpolator, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setRelativeValues, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.ContainerBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + behaviors + +
    +
    + A collection of behaviors. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(conforming) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + conforming + +
    +
    {bool=} conform this behavior duration to that of its children.
    + +
    + + + + + + + + +
    + + +
    + + + addBehavior(behavior) + +
    +
    + Add a new behavior to the container. + + +
    + + + + +
    +
    Parameters:
    + +
    + behavior + +
    +
    {CAAT.Behavior.BaseBehavior}
    + +
    + + + + + + + + +
    + + +
    + + + apply(time, actor) + +
    +
    + Applies every contained Behaviors. +The application time the contained behaviors will receive will be ContainerBehavior related and not the +received time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    an integer indicating the time to apply the contained behaviors at.
    + +
    + actor + +
    +
    a CAAT.Foundation.Actor instance indicating the actor to apply the behaviors for.
    + +
    + + + + + + + + +
    + + +
    + + + behaviorApplied(behavior, scenetime, time, actor, value) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + behavior + +
    +
    + +
    + scenetime + +
    +
    + +
    + time + +
    +
    + +
    + actor + +
    +
    + +
    + value + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + behaviorExpired(behavior, time, actor) + +
    +
    + This method is the observer implementation for every contained behavior. +If a container is Cycle=true, won't allow its contained behaviors to be expired. + + +
    + + + + +
    +
    Parameters:
    + +
    + behavior + +
    +
    a CAAT.Behavior.BaseBehavior instance which has been expired.
    + +
    + time + +
    +
    an integer indicating the time at which has become expired.
    + +
    + actor + +
    +
    a CAAT.Foundation.Actor the expired behavior is being applied to.
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFrameData(referenceTime, prefix) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + referenceTime + +
    +
    + +
    + prefix + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize, anchorX, anchorY) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + anchorX + +
    +
    + +
    + anchorY + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + conformToDuration(duration) + +
    +
    + Proportionally change this container duration to its children. + + +
    + + + + +
    +
    Parameters:
    + +
    + duration + +
    +
    {number} new duration in ms.
    + +
    + + + + + +
    +
    Returns:
    + +
    this;
    + +
    + + + + +
    + + +
    + + + getBehaviorById(id) + +
    +
    + Get a behavior by mathing its id. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object}
    + +
    + + + + + + + + +
    + + +
    + + + getKeyFrameDataValues(referenceTime) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + referenceTime + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setCycle(cycle, recurse) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + cycle + +
    +
    + +
    + recurse + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setDelayTime(start, duration) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    + +
    + duration + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {*} + setExpired(actor, time) + +
    +
    + Expire this behavior and the children applied at the parameter time. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    {CAAT.Foundation.Actor}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setForTime(time{number}) + +
    +
    + Implementation method of the behavior. +Just call implementation method for its contained behaviors. + + +
    + + + + +
    +
    Parameters:
    + +
    + time{number} + +
    +
    an integer indicating the time the behavior is being applied at.
    + +
    + actor{CAAT.Foundation.Actor} + +
    +
    an actor the behavior is being applied to.
    + +
    + + + + + + + + +
    + + +
    + + + setFrameTime(start, duration) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    + +
    + duration + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html new file mode 100644 index 0000000..3d85442 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html @@ -0,0 +1,877 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.GenericBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.GenericBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: GenericBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + callback +
    +
    this callback will be invoked for every behavior application.
    +
      +
    + end +
    +
    ending value.
    +
      +
    + property +
    +
    property to apply values to.
    +
      +
    + start +
    +
    starting value.
    +
      +
    + target +
    +
    target to apply this generic behvior.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    setForTime(time, actor) +
    +
    +
      +
    setValues(start, end, target, property, callback) +
    +
    Defines the values to apply this behavior.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    __init, addListener, apply, calculateKeyFrameData, calculateKeyFramesData, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getKeyFrameDataValues, getPropertyName, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, parse, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setRelativeValues, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.GenericBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + callback + +
    +
    + this callback will be invoked for every behavior application. + + +
    + + + + + + + + +
    + + +
    + + + end + +
    +
    + ending value. + + +
    + + + + + + + + +
    + + +
    + + + property + +
    +
    + property to apply values to. + + +
    + + + + + + + + +
    + + +
    + + + start + +
    +
    + starting value. + + +
    + + + + + + + + +
    + + +
    + + + target + +
    +
    + target to apply this generic behvior. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + setForTime(time, actor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setValues(start, end, target, property, callback) + +
    +
    + Defines the values to apply this behavior. + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    {number} initial behavior value.
    + +
    + end + +
    +
    {number} final behavior value.
    + +
    + target + +
    +
    {object} an object. Usually a CAAT.Actor.
    + +
    + property + +
    +
    {string} target object's property to set value to.
    + +
    + callback + +
    +
    {function} a function of the form function( target, value ).
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html new file mode 100644 index 0000000..b76a40d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html @@ -0,0 +1,1557 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.Interpolator + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.Interpolator +

    + + +

    + + + + + + +
    Defined in: Interpolator.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
    <private>   +
    bounce(time) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    createCubicBezierInterpolator(p0, p1, p2, p3, bPingPong) +
    +
    Creates a Cubic bezier curbe as interpolator.
    +
      +
    createElasticInInterpolator(amplitude, p, bPingPong) +
    +
    +
      +
    createElasticInOutInterpolator(amplitude, p, bPingPong) +
    +
    +
      +
    createElasticOutInterpolator(amplitude, p, bPingPong) +
    +
    +
      +
    createExponentialInInterpolator(exponent, bPingPong) +
    +
    Set an exponential interpolator function.
    +
      +
    createExponentialInOutInterpolator(exponent, bPingPong) +
    +
    Set an exponential interpolator function.
    +
      +
    createExponentialOutInterpolator(exponent, bPingPong) +
    +
    Set an exponential interpolator function.
    +
      +
    createLinearInterpolator(bPingPong, bInverse) +
    +
    Set a linear interpolation function.
    +
      +
    createQuadricBezierInterpolator(p0, p1, p2, bPingPong) +
    +
    Creates a Quadric bezier curbe as interpolator.
    +
    <static>   +
    CAAT.Behavior.Interpolator.enumerateInterpolators() +
    +
    +
      +
    getContour(iSize) +
    +
    Gets an array of coordinates which define the polyline of the intepolator's curve contour.
    +
      +
    getPosition(time) +
    +
    Linear and inverse linear interpolation function.
    +
      +
    paint(ctx) +
    +
    Paints an interpolator on screen.
    +
    <static>   +
    CAAT.Behavior.Interpolator.parse(obj) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.Interpolator() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + bounce(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + createBackOutInterpolator(bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createBounceInInterpolator(bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createBounceInOutInterpolator(bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createBounceOutInterpolator(bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createCubicBezierInterpolator(p0, p1, p2, p3, bPingPong) + +
    +
    + Creates a Cubic bezier curbe as interpolator. + + +
    + + + + +
    +
    Parameters:
    + +
    + p0 + +
    +
    {CAAT.Math.Point}
    + +
    + p1 + +
    +
    {CAAT.Math.Point}
    + +
    + p2 + +
    +
    {CAAT.Math.Point}
    + +
    + p3 + +
    +
    {CAAT.Math.Point}
    + +
    + bPingPong + +
    +
    {boolean} a boolean indicating if the interpolator must ping-pong.
    + +
    + + + + + + + + +
    + + +
    + + + createElasticInInterpolator(amplitude, p, bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + amplitude + +
    +
    + +
    + p + +
    +
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createElasticInOutInterpolator(amplitude, p, bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + amplitude + +
    +
    + +
    + p + +
    +
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createElasticOutInterpolator(amplitude, p, bPingPong) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + amplitude + +
    +
    + +
    + p + +
    +
    + +
    + bPingPong + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createExponentialInInterpolator(exponent, bPingPong) + +
    +
    + Set an exponential interpolator function. The function to apply will be Math.pow(time,exponent). +This function starts with 0 and ends in values of 1. + + +
    + + + + +
    +
    Parameters:
    + +
    + exponent + +
    +
    {number} exponent of the function.
    + +
    + bPingPong + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    + + + createExponentialInOutInterpolator(exponent, bPingPong) + +
    +
    + Set an exponential interpolator function. Two functions will apply: +Math.pow(time*2,exponent)/2 for the first half of the function (t<0.5) and +1-Math.abs(Math.pow(time*2-2,exponent))/2 for the second half (t>=.5) +This function starts with 0 and goes to values of 1 and ends with values of 0. + + +
    + + + + +
    +
    Parameters:
    + +
    + exponent + +
    +
    {number} exponent of the function.
    + +
    + bPingPong + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    + + + createExponentialOutInterpolator(exponent, bPingPong) + +
    +
    + Set an exponential interpolator function. The function to apply will be 1-Math.pow(time,exponent). +This function starts with 1 and ends in values of 0. + + +
    + + + + +
    +
    Parameters:
    + +
    + exponent + +
    +
    {number} exponent of the function.
    + +
    + bPingPong + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    + + + createLinearInterpolator(bPingPong, bInverse) + +
    +
    + Set a linear interpolation function. + + +
    + + + + +
    +
    Parameters:
    + +
    + bPingPong + +
    +
    {boolean}
    + +
    + bInverse + +
    +
    {boolean} will values will be from 1 to 0 instead of 0 to 1 ?.
    + +
    + + + + + + + + +
    + + +
    + + + createQuadricBezierInterpolator(p0, p1, p2, bPingPong) + +
    +
    + Creates a Quadric bezier curbe as interpolator. + + +
    + + + + +
    +
    Parameters:
    + +
    + p0 + +
    +
    {CAAT.Math.Point}
    + +
    + p1 + +
    +
    {CAAT.Math.Point}
    + +
    + p2 + +
    +
    {CAAT.Math.Point}
    + +
    + bPingPong + +
    +
    {boolean} a boolean indicating if the interpolator must ping-pong.
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.Interpolator.enumerateInterpolators() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getContour(iSize) + +
    +
    + Gets an array of coordinates which define the polyline of the intepolator's curve contour. +Values for both coordinates range from 0 to 1. + + +
    + + + + +
    +
    Parameters:
    + +
    + iSize + +
    +
    {number} an integer indicating the number of contour segments.
    + +
    + + + + + +
    +
    Returns:
    + +
    Array. of object of the form {x:float, y:float}.
    + +
    + + + + +
    + + +
    + + + getPosition(time) + +
    +
    + Linear and inverse linear interpolation function. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + paint(ctx) + +
    +
    + Paints an interpolator on screen. + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    {CanvasRenderingContext}
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.Interpolator.parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html new file mode 100644 index 0000000..0cd3ba4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html @@ -0,0 +1,660 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.PathBehavior.AUTOROTATE + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Behavior.PathBehavior.AUTOROTATE +

    + + +

    + + + + + + +
    Defined in: PathBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    Internal PathBehavior rotation constants.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Behavior.PathBehavior.AUTOROTATE.FREE +
    +
    +
    <static>   +
    + CAAT.Behavior.PathBehavior.AUTOROTATE.LEFT_TO_RIGHT +
    +
    +
    <static>   +
    + CAAT.Behavior.PathBehavior.AUTOROTATE.RIGHT_TO_LEFT +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Behavior.PathBehavior.AUTOROTATE +
    + +
    + Internal PathBehavior rotation constants. + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Behavior.PathBehavior.AUTOROTATE.FREE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.PathBehavior.AUTOROTATE.LEFT_TO_RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.PathBehavior.AUTOROTATE.RIGHT_TO_LEFT + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.html new file mode 100644 index 0000000..5659843 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.html @@ -0,0 +1,1337 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.PathBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.PathBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: PathBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   + +
    Whether to set rotation angle while traversing the path.
    +
    <private>   + +
    Autorotation hint.
    +
    <private>   +
    + path +
    +
    A path to traverse.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      + +
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize) +
    +
    +
      + +
    +
      + +
    +
      +
    parse(obj) +
    +
    +
      + +
    Get a point on the path.
    +
      +
    setAutoRotate(autorotate, autorotateOp) +
    +
    Sets an actor rotation to be heading from past to current path's point.
    +
      +
    setForTime(time, actor) +
    +
    +
      + +
    +
      +
    setPath() +
    +
    Set the behavior path.
    +
      + +
    +
      +
    setTranslation(tx, ty) +
    +
    +
      + +
    Set the behavior path.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    __init, addListener, apply, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.PathBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + autoRotate + +
    +
    + Whether to set rotation angle while traversing the path. + + +
    + + + + + + + + +
    + + +
    <private> + + + autoRotateOp + +
    +
    + Autorotation hint. + + +
    + + + + + + + + +
    + + +
    <private> + + + path + +
    +
    + A path to traverse. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + calculateKeyFrameData(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getKeyFrameDataValues(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPropertyName() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {object} + positionOnTime(time) + +
    +
    + Get a point on the path. +If the time to get the point at is in behaviors frame time, a point on the path will be returned, otherwise +a default {x:-1, y:-1} point will be returned. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} the time at which the point will be taken from the path.
    + +
    + + + + + +
    +
    Returns:
    + +
    {object} an object of the form {x:float y:float}
    + +
    + + + + +
    + + +
    + + + setAutoRotate(autorotate, autorotateOp) + +
    +
    + Sets an actor rotation to be heading from past to current path's point. +Take into account that this will be incompatible with rotation Behaviors +since they will set their own rotation configuration. + + +
    + + + + +
    +
    Parameters:
    + +
    + autorotate + +
    +
    {boolean}
    + +
    + autorotateOp + +
    +
    {CAAT.PathBehavior.autorotate} whether the sprite is drawn heading to the right.
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + + setForTime(time, actor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setOpenContour(b) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + b + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPath() + +
    +
    + Set the behavior path. +The path can be any length, and will take behaviorDuration time to be traversed. + + +
    + + + + +
    +
    Parameters:
    + +
    + {CAAT.Path} + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRelativeValues(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTranslation(tx, ty) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + tx + +
    +
    a float with xoffset.
    + +
    + ty + +
    +
    a float with yoffset.
    + +
    + + + + + + + +
    +
    See:
    + +
    Actor.setPositionAnchor
    + +
    + + +
    + + +
    + + + setValues() + +
    +
    + Set the behavior path. +The path can be any length, and will take behaviorDuration time to be traversed. + + +
    + + + + +
    +
    Parameters:
    + +
    + {CAAT.Path} + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.RotateBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.RotateBehavior.html new file mode 100644 index 0000000..6cf5694 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.RotateBehavior.html @@ -0,0 +1,1275 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.RotateBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.RotateBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: RotateBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + anchorX +
    +
    Rotation X anchor.
    +
    <private>   +
    + anchorY +
    +
    Rotation Y anchor.
    +
    <private>   +
    + endAngle +
    +
    End rotation angle.
    +
    <private>   + +
    Start rotation angle.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      + +
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize) +
    +
    +
      + +
    +
      + +
    +
      +
    parse(obj) +
    +
    +
      +
    setAnchor(actor, rx, ry) +
    +
    Set the behavior rotation anchor.
    +
      +
    setAngles(start, end) +
    +
    +
      +
    setForTime(time, actor) +
    +
    +
      + +
    +
      +
    setValues(startAngle, endAngle, anchorx, anchory) +
    +
    Set behavior bound values.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    addListener, apply, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.RotateBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + anchorX + +
    +
    + Rotation X anchor. + + +
    + + + + + + + + +
    + + +
    <private> + + + anchorY + +
    +
    + Rotation Y anchor. + + +
    + + + + + + + + +
    + + +
    <private> + + + endAngle + +
    +
    + End rotation angle. + + +
    + + + + + + + + +
    + + +
    <private> + + + startAngle + +
    +
    + Start rotation angle. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + calculateKeyFrameData(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getKeyFrameDataValues(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPropertyName() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAnchor(actor, rx, ry) + +
    +
    + Set the behavior rotation anchor. Use this method when setting an exact percent +by calling setValues is complicated. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + rx + +
    +
    + +
    + ry + +
    +
    + +
    + + + + + + + +
    +
    See:
    + +
    CAAT.Actor + +These parameters are to set a custom rotation anchor point. if anchor==CAAT.Actor.ANCHOR_CUSTOM + the custom rotation point is set.
    + +
    + + +
    + + +
    + + + setAngles(start, end) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    + +
    + end + +
    +
    + +
    + + +
    +
    Deprecated:
    +
    + Use setValues instead +
    +
    + + + + + + + +
    + + +
    + + + setForTime(time, actor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRelativeValues(r) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + r + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setValues(startAngle, endAngle, anchorx, anchory) + +
    +
    + Set behavior bound values. +if no anchorx,anchory values are supplied, the behavior will assume +50% for both values, that is, the actor's center. + +Be aware the anchor values are supplied in RELATIVE PERCENT to +actor's size. + + +
    + + + + +
    +
    Parameters:
    + +
    + startAngle + +
    +
    {float} indicating the starting angle.
    + +
    + endAngle + +
    +
    {float} indicating the ending angle.
    + +
    + anchorx + +
    +
    {float} the percent position for anchorX
    + +
    + anchory + +
    +
    {float} the percent position for anchorY
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html new file mode 100644 index 0000000..fda029f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html @@ -0,0 +1,628 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.Scale1Behavior.AXIS + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Behavior.Scale1Behavior.AXIS +

    + + +

    + + + + + + +
    Defined in: Scale1Behavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Behavior.Scale1Behavior.AXIS.X +
    +
    +
    <static>   +
    + CAAT.Behavior.Scale1Behavior.AXIS.Y +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Behavior.Scale1Behavior.AXIS +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Behavior.Scale1Behavior.AXIS.X + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.Scale1Behavior.AXIS.Y + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.html new file mode 100644 index 0000000..ee88a9b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.html @@ -0,0 +1,1250 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.Scale1Behavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.Scale1Behavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: Scale1Behavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + anchorX +
    +
    Scale X anchor.
    +
    <private>   +
    + anchorY +
    +
    Scale Y anchor.
    +
      +
    + applyOnX +
    +
    Apply on Axis X or Y ?
    +
    <private>   +
    + endScale +
    +
    End scale value.
    +
    <private>   + +
    Start scale value.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    applyOnAxis(axis) +
    +
    +
      + +
    +
      +
    calculateKeyFramesData(prefix, name, keyframessize) +
    +
    +
      + +
    +
      + +
    +
      +
    parse(obj) +
    +
    +
      +
    setAnchor(actor, x, y) +
    +
    Set an exact position scale anchor.
    +
      +
    setForTime(time, actor) +
    +
    +
      +
    setValues(start, end, anchorx, anchory, anchory) +
    +
    Define this scale behaviors values.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    addListener, apply, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setRelativeValues, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.Scale1Behavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + anchorX + +
    +
    + Scale X anchor. + + +
    + + + + + + + + +
    + + +
    <private> + + + anchorY + +
    +
    + Scale Y anchor. + + +
    + + + + + + + + +
    + + +
    + + + applyOnX + +
    +
    + Apply on Axis X or Y ? + + +
    + + + + + + + + +
    + + +
    <private> + + + endScale + +
    +
    + End scale value. + + +
    + + + + + + + + +
    + + +
    <private> + + + startScale + +
    +
    + Start scale value. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + applyOnAxis(axis) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + axis + +
    +
    {CAAT.Behavior.Scale1Behavior.AXIS}
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFrameData(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getKeyFrameDataValues(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPropertyName() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAnchor(actor, x, y) + +
    +
    + Set an exact position scale anchor. Use this method when it is hard to +set a thorough anchor position expressed in percentage. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setForTime(time, actor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setValues(start, end, anchorx, anchory, anchory) + +
    +
    + Define this scale behaviors values. + +Be aware the anchor values are supplied in RELATIVE PERCENT to +actor's size. + + +
    + + + + +
    +
    Parameters:
    + +
    + start + +
    +
    {number} initial X axis scale value.
    + +
    + end + +
    +
    {number} final X axis scale value.
    + +
    + anchorx + +
    +
    {float} the percent position for anchorX
    + +
    + anchory + +
    +
    {float} the percent position for anchorY
    + +
    + anchory + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ScaleBehavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ScaleBehavior.html new file mode 100644 index 0000000..4d16138 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.ScaleBehavior.html @@ -0,0 +1,1250 @@ + + + + + + + JsDoc Reference - CAAT.Behavior.ScaleBehavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Behavior.ScaleBehavior +

    + + +

    + +
    Extends + CAAT.Behavior.BaseBehavior.
    + + + + + +
    Defined in: ScaleBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.anchorX +
    +
    Scale X anchor value.
    +
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.anchorY +
    +
    Scale Y anchor value.
    +
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.endScaleX +
    +
    End X scale value.
    +
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.endScaleY +
    +
    End Y scale value.
    +
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.startScaleX +
    +
    Start X scale value.
    +
    <private> <static>   +
    + CAAT.Behavior.ScaleBehavior.startScaleY +
    +
    Start Y scale value.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Behavior.BaseBehavior:
    actor, behaviorDuration, behaviorStartTime, cycleBehavior, discardable, doValueApplication, id, interpolator, isRelative, lifecycleListenerList, solved, status, timeOffset
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private> <static>   +
    CAAT.Behavior.ScaleBehavior.__init() +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.calculateKeyFrameData(time) +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.calculateKeyFramesData(prefix, name, keyframessize) +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.getKeyFrameDataValues(time) +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.getPropertyName() +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.parse(obj) +
    +
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.setAnchor(actor, x, y) +
    +
    Set an exact position scale anchor.
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.setForTime(time, actor) +
    +
    Applies corresponding scale values for a given time.
    +
    <static>   +
    CAAT.Behavior.ScaleBehavior.setValues(startX, endX, startY, endY, anchorx, anchory) +
    +
    Define this scale behaviors values.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Behavior.BaseBehavior:
    addListener, apply, emptyListenerList, fireBehaviorAppliedEvent, fireBehaviorExpiredEvent, fireBehaviorStartedEvent, getDuration, getStartTime, initialize, isBehaviorInTime, isCycle, normalizeTime, setCycle, setDefaultInterpolator, setDelayTime, setExpired, setFrameTime, setId, setInterpolator, setOutOfFrameTime, setPingPong, setRelative, setRelativeValues, setStatus, setTimeOffset, setValueApplication
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Behavior.ScaleBehavior() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.anchorX + +
    +
    + Scale X anchor value. + + +
    + + + + + + + + +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.anchorY + +
    +
    + Scale Y anchor value. + + +
    + + + + + + + + +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.endScaleX + +
    +
    + End X scale value. + + +
    + + + + + + + + +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.endScaleY + +
    +
    + End Y scale value. + + +
    + + + + + + + + +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.startScaleX + +
    +
    + Start X scale value. + + +
    + + + + + + + + +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.startScaleY + +
    +
    + Start Y scale value. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> <static> + + + CAAT.Behavior.ScaleBehavior.__init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.calculateKeyFrameData(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.calculateKeyFramesData(prefix, name, keyframessize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + name + +
    +
    + +
    + keyframessize + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.getKeyFrameDataValues(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.getPropertyName() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.parse(obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.setAnchor(actor, x, y) + +
    +
    + Set an exact position scale anchor. Use this method when it is hard to +set a thorough anchor position expressed in percentage. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + {object} + CAAT.Behavior.ScaleBehavior.setForTime(time, actor) + +
    +
    + Applies corresponding scale values for a given time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    the time to apply the scale for.
    + +
    + actor + +
    +
    the target actor to Scale.
    + +
    + + + + + +
    +
    Returns:
    + +
    {object} an object of the form { scaleX: {float}, scaleY: {float}�}
    + +
    + + + + +
    + + +
    <static> + + + CAAT.Behavior.ScaleBehavior.setValues(startX, endX, startY, endY, anchorx, anchory) + +
    +
    + Define this scale behaviors values. + +Be aware the anchor values are supplied in RELATIVE PERCENT to +actor's size. + + +
    + + + + +
    +
    Parameters:
    + +
    + startX + +
    +
    {number} initial X axis scale value.
    + +
    + endX + +
    +
    {number} final X axis scale value.
    + +
    + startY + +
    +
    {number} initial Y axis scale value.
    + +
    + endY + +
    +
    {number} final Y axis scale value.
    + +
    + anchorx + +
    +
    {float} the percent position for anchorX
    + +
    + anchory + +
    +
    {float} the percent position for anchorY
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.html b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.html new file mode 100644 index 0000000..55cd7f5 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Behavior.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Behavior + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Behavior +

    + + +

    + + + + + + +
    Defined in: BaseBehavior.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    Namespace for all behavior-based actor properties instrumenter objects.
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Behavior +
    + +
    + Namespace for all behavior-based actor properties instrumenter objects. + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.CSS.html b/CAAT/documentation/jsdoc/symbols/CAAT.CSS.html new file mode 100644 index 0000000..9abd259 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.CSS.html @@ -0,0 +1,875 @@ + + + + + + + JsDoc Reference - CAAT.CSS + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.CSS +

    + + +

    + + + + + + +
    Defined in: csskeyframehelper.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      +
    + CAAT.CSS +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.CSS.PREFIX +
    +
    Guess a browser custom prefix.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <static>   +
    CAAT.CSS.applyKeyframe(domElement, name, duration_millis, delay_millis, forever) +
    +
    Apply a given @key-frames animation to a DOM element.
    +
    <static>   +
    CAAT.CSS.getCSSKeyframes(name) +
    +
    +
    <static>   +
    CAAT.CSS.getCSSKeyframesIndex(name) +
    +
    +
    <static>   +
    CAAT.CSS.registerKeyframes(kfDescriptor) +
    +
    +
    <static>   +
    CAAT.CSS.unregisterKeyframes(name) +
    +
    Remove a @key-frames animation from the stylesheet.
    +
    + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.CSS +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.CSS.PREFIX + +
    +
    + Guess a browser custom prefix. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <static> + + + CAAT.CSS.applyKeyframe(domElement, name, duration_millis, delay_millis, forever) + +
    +
    + Apply a given @key-frames animation to a DOM element. + + +
    + + + + +
    +
    Parameters:
    + +
    + domElement + +
    +
    {DOMElement}
    + +
    + name + +
    +
    {string} animation name
    + +
    + duration_millis + +
    +
    {number}
    + +
    + delay_millis + +
    +
    {number}
    + +
    + forever + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.CSS.getCSSKeyframes(name) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.CSS.getCSSKeyframesIndex(name) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.CSS.registerKeyframes(kfDescriptor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + kfDescriptor + +
    +
    {object} + { + name{string}, + behavior{CAAT.Behavior}, + size{!number}, + overwrite{boolean} + } + }
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.CSS.unregisterKeyframes(name) + +
    +
    + Remove a @key-frames animation from the stylesheet. + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Class.html b/CAAT/documentation/jsdoc/symbols/CAAT.Class.html new file mode 100644 index 0000000..d2aaf54 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Class.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Class + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Class +

    + + +

    + + + + + + +
    Defined in: ModuleManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      +
    + CAAT.Class() +
    +
    +
    + + + + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Class() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Event.KeyEvent.html b/CAAT/documentation/jsdoc/symbols/CAAT.Event.KeyEvent.html new file mode 100644 index 0000000..dcda1de --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Event.KeyEvent.html @@ -0,0 +1,899 @@ + + + + + + + JsDoc Reference - CAAT.Event.KeyEvent + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Event.KeyEvent +

    + + +

    + + + + + + +
    Defined in: KeyEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(keyCode, up_or_down, modifiers, originalEvent) +
    +
    Define a key event.
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Event.KeyEvent() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(keyCode, up_or_down, modifiers, originalEvent) + +
    +
    + Define a key event. + + +
    + + + + +
    +
    Parameters:
    + +
    + keyCode + +
    +
    + +
    + up_or_down + +
    +
    + +
    + modifiers + +
    +
    + +
    + originalEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getAction() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getKeyCode() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getSourceEvent() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isAltPressed() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isControlPressed() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isShiftPressed() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + modifiers() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + preventDefault() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Event.MouseEvent.html b/CAAT/documentation/jsdoc/symbols/CAAT.Event.MouseEvent.html new file mode 100644 index 0000000..82b4d54 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Event.MouseEvent.html @@ -0,0 +1,1154 @@ + + + + + + + JsDoc Reference - CAAT.Event.MouseEvent + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Event.MouseEvent +

    + + +

    + + + + + + +
    Defined in: MouseEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + alt +
    +
    was alt pressed ?
    +
      +
    + control +
    +
    Was control pressed ?
    +
      +
    + meta +
    +
    was Meta key pressed ?
    +
      +
    + point +
    +
    Transformed in-actor coordinate
    +
      + +
    Original mouse/touch screen coord
    +
      +
    + shift +
    +
    Was shift pressed ?
    +
      +
    + source +
    +
    Actor the event was produced in.
    +
      + +
    Original mouse/touch event
    +
      +
    + time +
    +
    scene time when the event was triggered.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    Constructor delegate
    +
      + +
    +
      +
    init(x, y, sourceEvent, source, screenPoint, time) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Event.MouseEvent() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + alt + +
    +
    + was alt pressed ? + + +
    + + + + + + + + +
    + + +
    + + + control + +
    +
    + Was control pressed ? + + +
    + + + + + + + + +
    + + +
    + + + meta + +
    +
    + was Meta key pressed ? + + +
    + + + + + + + + +
    + + +
    + + + point + +
    +
    + Transformed in-actor coordinate + + +
    + + + + + + + + +
    + + +
    + + + screenPoint + +
    +
    + Original mouse/touch screen coord + + +
    + + + + + + + + +
    + + +
    + + + shift + +
    +
    + Was shift pressed ? + + +
    + + + + + + + + +
    + + +
    + + + source + +
    +
    + Actor the event was produced in. + + +
    + + + + + + + + +
    + + +
    + + + sourceEvent + +
    +
    + Original mouse/touch event + + +
    + + + + + + + + +
    + + +
    + + + time + +
    +
    + scene time when the event was triggered. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + Constructor delegate + + +
    + + + + + + + + + + + +
    + + +
    + + + getSourceEvent() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + init(x, y, sourceEvent, source, screenPoint, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + sourceEvent + +
    +
    + +
    + source + +
    +
    + +
    + screenPoint + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isAltDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isControlDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isMetaDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isShiftDown() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchEvent.html b/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchEvent.html new file mode 100644 index 0000000..e4391ac --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchEvent.html @@ -0,0 +1,1238 @@ + + + + + + + JsDoc Reference - CAAT.Event.TouchEvent + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Event.TouchEvent +

    + + +

    + + + + + + +
    Defined in: TouchEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + alt +
    +
    Was alt pressed ?
    +
      + +
    changed touches collection
    +
      +
    + control +
    +
    Was control pressed ?
    +
      +
    + meta +
    +
    Was meta pressed ?
    +
      +
    + shift +
    +
    Was shift pressed ?
    +
      +
    + source +
    +
    Source Actor the event happened in.
    +
      + +
    Original touch event.
    +
      +
    + time +
    +
    Time the touch event was triggered at.
    +
      +
    + touches +
    +
    touches collection
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    Constructor delegate
    +
      +
    addChangedTouch(touchInfo) +
    +
    +
      +
    addTouch(touchInfo) +
    +
    +
      + +
    +
      +
    init(sourceEvent, source, time) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Event.TouchEvent() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + alt + +
    +
    + Was alt pressed ? + + +
    + + + + + + + + +
    + + +
    + + + changedTouches + +
    +
    + changed touches collection + + +
    + + + + + + + + +
    + + +
    + + + control + +
    +
    + Was control pressed ? + + +
    + + + + + + + + +
    + + +
    + + + meta + +
    +
    + Was meta pressed ? + + +
    + + + + + + + + +
    + + +
    + + + shift + +
    +
    + Was shift pressed ? + + +
    + + + + + + + + +
    + + +
    + + + source + +
    +
    + Source Actor the event happened in. + + +
    + + + + + + + + +
    + + +
    + + + sourceEvent + +
    +
    + Original touch event. + + +
    + + + + + + + + +
    + + +
    + + + time + +
    +
    + Time the touch event was triggered at. + + +
    + + + + + + + + +
    + + +
    + + + touches + +
    +
    + touches collection + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + Constructor delegate + + +
    + + + + + + + + + + + +
    + + +
    + + + addChangedTouch(touchInfo) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + touchInfo + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {*} + addTouch(touchInfo) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + touchInfo + +
    +
    <{ + id : , + point : { + x: , + y: }� + }>
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + getSourceEvent() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + init(sourceEvent, source, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + sourceEvent + +
    +
    + +
    + source + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isAltDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isControlDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isMetaDown() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isShiftDown() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchInfo.html b/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchInfo.html new file mode 100644 index 0000000..a8e702e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Event.TouchInfo.html @@ -0,0 +1,627 @@ + + + + + + + JsDoc Reference - CAAT.Event.TouchInfo + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Event.TouchInfo +

    + + +

    + + + + + + +
    Defined in: TouchInfo.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(id, x, y, target) +
    +
    Constructor delegate.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Event.TouchInfo() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(id, x, y, target) + +
    +
    + Constructor delegate. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {number}
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + target + +
    +
    {DOMElement}
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Event.html b/CAAT/documentation/jsdoc/symbols/CAAT.Event.html new file mode 100644 index 0000000..14ae0cc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Event.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Event + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Event +

    + + +

    + + + + + + +
    Defined in: KeyEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Event +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Actor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Actor.html new file mode 100644 index 0000000..c502f09 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Actor.html @@ -0,0 +1,8931 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Actor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Actor +

    + + +

    + + + + + + +
    Defined in: Actor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    CAAT.Foundation.Actor is the base animable element.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + __super +
    +
    +
      +
    + AABB +
    +
    This rectangle keeps the axis aligned bounding box in screen coords of this actor.
    +
      +
    + alpha +
    +
    Transparency value.
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_BOTTOM +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_CENTER +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_CUSTOM +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_LEFT +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_RIGHT +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_TOP +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_TOP_LEFT +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT +
    +
    +
      + +
    Define this actor´s background image.
    +
      + +
    A collection of behaviors to modify this actor´s properties.
    +
    <static>   +
    + CAAT.Foundation.Actor.CACHE_DEEP +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.CACHE_NONE +
    +
    +
    <static>   +
    + CAAT.Foundation.Actor.CACHE_SIMPLE +
    +
    +
      +
    + cached +
    +
    Caching as bitmap strategy.
    +
      +
    + clip +
    +
    Will this actor be clipped before being drawn on screen ?
    +
      +
    + clipPath +
    +
    If this.clip and this.clipPath===null, a rectangle will be used as clip area.
    +
    <private>   +
    + dirty +
    +
    Local matrix dirtyness flag.
    +
      + +
    Mark this actor as discardable.
    +
      +
    + duration +
    +
    Marks from the time this actor is going to be animated, during how much time.
    +
      +
    + expired +
    +
    Mark this actor as expired, or out of the scene time.
    +
      +
    + fillStyle +
    +
    any canvas rendering valid fill style.
    +
    <private>   + +
    +
      + +
    Is gesture recognition enabled on this actor ??
    +
      +
    + glEnabled +
    +
    Is this actor enabled on WebGL ?
    +
      +
    + height +
    +
    Actor's height.
    +
      +
    + id +
    +
    Set this actor´ id so that it can be later identified easily.
    +
      +
    + inFrame +
    +
    Is this actor processed in the last frame ?
    +
      +
    + invalid +
    +
    If dirty rects are enabled, this flag indicates the rendering engine to invalidate this +actor´s screen area.
    +
    <private>   +
    + isAA +
    +
    is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated.
    +
      + +
    if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some +internal properties.
    +
      + +
    true to make all children transparent, false, only this actor/container will be transparent.
    +
      + +
    A collection of this Actors lifecycle observers.
    +
      + +
    actor's layout minimum size.
    +
      + +
    This actor´s affine transformation matrix.
    +
      + +
    +
      + +
    Enable or disable input on this actor.
    +
    <private>   +
    + oldX +
    +
    +
    <private>   +
    + oldY +
    +
    +
      +
    + parent +
    +
    This actor's parent container.
    +
      +
    + pointed +
    +
    +
      + +
    actor´s layout preferred size.
    +
      + +
    Exclude this actor from automatic layout on its parent.
    +
      + +
    This actor´s rotation angle in radians.
    +
      +
    + rotationX +
    +
    Rotation Anchor Y.
    +
      +
    + rotationY +
    +
    Rotation Anchor X.
    +
      + +
    A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value.
    +
      +
    + scaleTX +
    +
    Scale Anchor X.
    +
      +
    + scaleTY +
    +
    Scale Anchor Y.
    +
      +
    + scaleX +
    +
    ScaleX value.
    +
      +
    + scaleY +
    +
    ScaleY value.
    +
      + +
    debug info.
    +
      + +
    debug info.
    +
      + +
    Marks since when this actor, relative to scene time, is going to be animated/drawn.
    +
      + +
    any canvas rendering valid stroke style.
    +
      +
    + tAnchorX +
    +
    Translation x anchor.
    +
      +
    + tAnchorY +
    +
    Translation y anchor.
    +
      +
    + time +
    +
    This actor´s scene time.
    +
      + +
    These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding +box.
    +
      +
    + visible +
    +
    Make this actor visible or not.
    +
    <private>   +
    + wdirty +
    +
    Global matrix dirtyness flag.
    +
      +
    + width +
    +
    Actor's width.
    +
      + +
    This actor´s world affine transformation matrix.
    +
      + +
    +
      +
    + x +
    +
    x position on parent.
    +
      +
    + y +
    +
    y position on parent.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
    <private>   +
    __paintActor(director, time) +
    +
    for js2native
    +
    <private>   +
    __scale1To(axis, scale, duration, delay, anchorX, anchorY, interpolator) +
    +
    +
    <private>   + +
    +
      +
    addAnimation(name, array, time, callback) +
    +
    +
      +
    addBehavior(behavior) +
    +
    Add a Behavior to the Actor.
    +
      +
    addListener(actorListener) +
    +
    Adds an Actor's life cycle listener.
    +
      +
    animate(director, time) +
    +
    Private +This method is called by the Director instance.
    +
      +
    cacheAsBitmap(time, stragegy) +
    +
    +
      +
    centerAt(x, y) +
    +
    Center this actor at position (x,y).
    +
      +
    centerOn(x, y) +
    +
    Center this actor at position (x,y).
    +
      +
    clean() +
    +
    +
      +
    contains(x, y) +
    +
    Checks whether a coordinate is inside the Actor's bounding box.
    +
      +
    create() +
    +
    +
    <private>   +
    destroy(time) +
    +
    This method will be called internally by CAAT when an Actor is expired, and at the +same time, is flagged as discardable.
    +
      + +
    +
      +
    drawScreenBoundingBox(director, time) +
    +
    Draw a bounding box with on-screen coordinates regardless of the transformations +applied to the Actor.
    +
      + +
    Removes all behaviors from an Actor.
    +
      + +
    Enables a default dragging routine for the Actor.
    +
      +
    enableEvents(enable) +
    +
    Enable or disable the event bubbling for this Actor.
    +
      +
    endAnimate(director, time) +
    +
    +
      + +
    Private +This method does the needed point transformations across an Actor hierarchy to devise +whether the parameter point coordinate lies inside the Actor.
    +
      + +
    +
      +
    fireEvent(sEventType, time) +
    +
    Notifies the registered Actor's life cycle listener about some event.
    +
      +
    gestureChange(rotation, scaleX, scaleY) +
    +
    +
      +
    gestureEnd(rotation, scaleX, scaleY) +
    +
    +
      +
    gestureStart(rotation, scaleX, scaleY) +
    +
    +
      +
    getAnchor(anchor) +
    +
    Private.
    +
      +
    getAnchorPercent(anchor) +
    +
    +
      + +
    +
      +
    getId() +
    +
    +
      + +
    +
      + +
    +
      + +
    If GL is enables, get this background image's texture page, otherwise it will fail.
    +
      +
    glNeedsFlush(director) +
    +
    Test for compulsory gl flushing: + 1.
    +
      +
    glSetShader(director) +
    +
    Change texture shader program parameters.
    +
      +
    initialize(overrides) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
    <private>   + +
    This method is called by the Director to know whether the actor is on Scene time.
    +
      + +
    +
      +
    modelToModel(point, otherActor) +
    +
    Transform a local coordinate point on this Actor's coordinate system into +another point in otherActor's coordinate system.
    +
    <private>   +
    modelToView(point) +
    +
    Transform a point or array of points in model space to view space.
    +
      +
    mouseClick(mouseEvent) +
    +
    Default mouseClick handler.
    +
      +
    mouseDblClick(mouseEvent) +
    +
    Default double click handler
    +
      +
    mouseDown(mouseEvent) +
    +
    default mouse press in Actor handler.
    +
      +
    mouseDrag(mouseEvent) +
    +
    default Actor mouse drag handler.
    +
      +
    mouseEnter(mouseEvent) +
    +
    Default mouse enter on Actor handler.
    +
      +
    mouseExit(mouseEvent) +
    +
    Default mouse exit on Actor handler.
    +
      +
    mouseMove(mouseEvent) +
    +
    Default mouse move inside Actor handler.
    +
      +
    mouseOut(mouseEvent) +
    +
    +
      +
    mouseOver(mouseEvent) +
    +
    +
      +
    mouseUp(mouseEvent) +
    +
    default mouse release in Actor handler.
    +
      +
    moveTo(x, y, duration, delay, interpolator, callback) +
    +
    Move this actor to a position.
    +
      +
    paint(director, time) +
    +
    This method should me overriden by every custom Actor.
    +
      +
    paintActor(director, time) +
    +
    +
      +
    paintActorGL(director, time) +
    +
    Set coordinates and uv values for this actor.
    +
      +
    playAnimation(name) +
    +
    +
      + +
    Remove a Behavior with id param as behavior identifier from this actor.
    +
      +
    removeBehaviour(behavior) +
    +
    Remove a Behavior from the Actor.
    +
      +
    removeListener(actorListener) +
    +
    Removes an Actor's life cycle listener.
    +
      + +
    +
      + +
    +
      + +
    Remove all transformation values for the Actor.
    +
      +
    rotateTo(angle, duration, delay, anchorX, anchorY, interpolator) +
    +
    +
      +
    scaleTo(scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) +
    +
    +
      +
    scaleXTo(scaleX, duration, delay, anchorX, anchorY, interpolator) +
    +
    +
      +
    scaleYTo(scaleY, duration, delay, anchorX, anchorY, interpolator) +
    +
    +
      +
    setAlpha(alpha) +
    +
    Stablishes the Alpha transparency for the Actor.
    +
      + +
    +
      + +
    Set this actor's background SpriteImage its animation sequence.
    +
      +
    setAsButton(buttonImage, iNormal, iOver, iPress, iDisabled, fn) +
    +
    Set this actor behavior as if it were a Button.
    +
      +
    setBackgroundImage(image, adjust_size_to_image) +
    +
    Set this actor's background image.
    +
      + +
    Set this actor's background SpriteImage offset displacement.
    +
      +
    setBounds(x{number}, y{number}, w{number}, h{number}) +
    +
    Set location and dimension of an Actor at once.
    +
      +
    setButtonImageIndex(_normal, _over, _press, _disabled) +
    +
    +
      +
    setCachedActor(cached) +
    +
    +
      +
    setChangeFPS(time) +
    +
    +
      +
    setClip(enable, clipPath) +
    +
    Set this Actor's clipping area.
    +
      +
    setDiscardable(discardable) +
    +
    Set discardable property.
    +
      +
    setExpired(time) +
    +
    Sets this Actor as Expired.
    +
      +
    setFillStyle(style) +
    +
    Caches a fillStyle in the Actor.
    +
      +
    setFrameTime(startTime, duration) +
    +
    Sets the time life cycle for an Actor.
    +
      + +
    +
      +
    setGLCoords(glCoords, glCoordsIndex) +
    +
    TODO: set GLcoords for different image transformations.
    +
      +
    setGlobalAlpha(global) +
    +
    Set alpha composition scope.
    +
      +
    setGlobalAnchor(ax, ay) +
    +
    +
      +
    setId(id) +
    +
    +
      + +
    Set this background image transformation.
    +
      +
    setLocation(x{number}, y{number}) +
    +
    This method sets the position of an Actor inside its parent.
    +
      +
    setMinimumSize(pw, ph) +
    +
    Set this actors minimum layout size.
    +
      + +
    Set this model view matrix if the actor is Dirty.
    +
      + +
    Puts an Actor out of time line, that is, won't be transformed nor rendered.
    +
      +
    setPaint(paint) +
    +
    +
      +
    setParent(parent) +
    +
    Set this actor's parent.
    +
      +
    setPosition(x, y) +
    +
    +
      +
    setPositionAnchor(pax, pay) +
    +
    +
      +
    setPositionAnchored(x, y, pax, pay) +
    +
    +
      +
    setPreferredSize(pw, ph) +
    +
    Set this actors preferred layout size.
    +
      + +
    Make this actor not be laid out.
    +
      +
    setRotation(angle) +
    +
    A helper method for setRotationAnchored.
    +
      +
    setRotationAnchor(rax, ray) +
    +
    +
      +
    setRotationAnchored(angle, rx, ry) +
    +
    This method sets Actor rotation around a given position.
    +
      +
    setScale(sx, sy) +
    +
    A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER
    +
      +
    setScaleAnchor(sax, say) +
    +
    +
      +
    setScaleAnchored(sx, sy, anchorx, anchory) +
    +
    Modify the dimensions on an Actor.
    +
    <private>   + +
    Calculates the 2D bounding box in canvas coordinates of the Actor.
    +
      +
    setSize(w, h) +
    +
    Sets an Actor's dimension
    +
      +
    setSpriteIndex(index) +
    +
    Set the actor's SpriteImage index from animation sheet.
    +
      +
    setStrokeStyle(style) +
    +
    Caches a stroke style in the Actor.
    +
      +
    setUV(uvBuffer, uvIndex) +
    +
    Set UV for this actor's quad.
    +
      +
    setVisible(visible) +
    +
    Set this actor invisible.
    +
      + +
    +
      +
    touchEnd(e) +
    +
    +
      +
    touchMove(e) +
    +
    +
      + +
    Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
    +
      +
    viewToModel(point) +
    +
    Transform a point from model to view space.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Actor() +
    + +
    + CAAT.Foundation.Actor is the base animable element. It is the base object for Director, Scene and +Container. +

    CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance. + An Actor has entity, it has a size, position and can have input sent to it. Everything that has a + visual representation is an Actor, including Director and Scene objects.

    +

    This object has functionality for:

    +
      +
    1. Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
    2. +
    3. Set affine transforms (rotation, scale and translation).
    4. +
    5. Define life cycle.
    6. +
    7. Manage alpha transparency.
    8. +
    9. Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.
    10. +
    11. Compose transformations. A container Actor will transform its children before they apply their own transformation.
    12. +
    13. Clipping capabilities. Either rectangular or arbitrary shapes.
    14. +
    15. The API is developed to allow method chaining when possible.
    16. +
    17. Handle input (either mouse events, touch, multitouch, keys and accelerometer).
    18. +
    19. Show an image.
    20. +
    21. Show some image animations.
    22. +
    23. etc.
    24. +
    + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + __super + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + AABB + +
    +
    + This rectangle keeps the axis aligned bounding box in screen coords of this actor. +In can be used, among other uses, to realize whether two given actors collide regardless +the affine transformation is being applied on them. + + +
    + + + + + + + + +
    + + +
    + + + alpha + +
    +
    + Transparency value. 0 is totally transparent, 1 is totally opaque. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_BOTTOM + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_CENTER + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_CUSTOM + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_LEFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_TOP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_TOP_LEFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + backgroundImage + +
    +
    + Define this actor´s background image. +See SpriteImage object. + + +
    + + + + + + + + +
    + + +
    + + + behaviorList + +
    +
    + A collection of behaviors to modify this actor´s properties. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.CACHE_DEEP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.CACHE_NONE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Actor.CACHE_SIMPLE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + cached + +
    +
    + Caching as bitmap strategy. Suitable to cache very complex actors. + +0 : no cache. +CACHE_SIMPLE : if a container, only cache the container. +CACHE_DEEP : if a container, cache the container and recursively all of its children. + + +
    + + + + + + + + +
    + + +
    + + + clip + +
    +
    + Will this actor be clipped before being drawn on screen ? + + +
    + + + + + + + + +
    + + +
    + + + clipPath + +
    +
    + If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise, +clipPath contains a reference to a CAAT.PathUtil.Path object. + + +
    + + + + + + + + +
    + + +
    <private> + + + dirty + +
    +
    + Local matrix dirtyness flag. + + +
    + + + + + + + + +
    + + +
    + + + discardable + +
    +
    + Mark this actor as discardable. If an actor is expired and mark as discardable, if will be +removed from its parent. + + +
    + + + + + + + + +
    + + +
    + + + duration + +
    +
    + Marks from the time this actor is going to be animated, during how much time. +Forever by default. + + +
    + + + + + + + + +
    + + +
    + + + expired + +
    +
    + Mark this actor as expired, or out of the scene time. + + +
    + + + + + + + + +
    + + +
    + + + fillStyle + +
    +
    + any canvas rendering valid fill style. + + +
    + + + + + + + + +
    + + +
    <private> + + + frameAlpha + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + gestureEnabled + +
    +
    + Is gesture recognition enabled on this actor ?? + + +
    + + + + + + + + +
    + + +
    + + + glEnabled + +
    +
    + Is this actor enabled on WebGL ? + + +
    + + + + + + + + +
    + + +
    + + + height + +
    +
    + Actor's height. In parent's local coord. system. + + +
    + + + + + + + + +
    + + +
    + + + id + +
    +
    + Set this actor´ id so that it can be later identified easily. + + +
    + + + + + + + + +
    + + +
    + + + inFrame + +
    +
    + Is this actor processed in the last frame ? + + +
    + + + + + + + + +
    + + +
    + + + invalid + +
    +
    + If dirty rects are enabled, this flag indicates the rendering engine to invalidate this +actor´s screen area. + + +
    + + + + + + + + +
    + + +
    <private> + + + isAA + +
    +
    + is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated. + + +
    + + + + + + + + +
    + + +
    + + + isCachedActor + +
    +
    + if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some +internal properties. + + +
    + + + + + + + + +
    + + +
    + + + isGlobalAlpha + +
    +
    + true to make all children transparent, false, only this actor/container will be transparent. + + +
    + + + + + + + + +
    + + +
    + + + lifecycleListenerList + +
    +
    + A collection of this Actors lifecycle observers. + + +
    + + + + + + + + +
    + + +
    + + + minimumSize + +
    +
    + actor's layout minimum size. + + +
    + + + + + + + + +
    + + +
    + + + modelViewMatrix + +
    +
    + This actor´s affine transformation matrix. + + +
    + + + + + + + + +
    + + +
    + + + modelViewMatrixI + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + mouseEnabled + +
    +
    + Enable or disable input on this actor. By default, all actors receive input. +See also priority lists. +see demo4 for an example of input and priority lists. + + +
    + + + + + + + + +
    + + +
    <private> + + + oldX + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <private> + + + oldY + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + parent + +
    +
    + This actor's parent container. + + +
    + + + + + + + + +
    + + +
    + + + pointed + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + preferredSize + +
    +
    + actor´s layout preferred size. + + +
    + + + + + + + + +
    + + +
    + + + preventLayout + +
    +
    + Exclude this actor from automatic layout on its parent. + + +
    + + + + + + + + +
    + + +
    + + + rotationAngle + +
    +
    + This actor´s rotation angle in radians. + + +
    + + + + + + + + +
    + + +
    + + + rotationX + +
    +
    + Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + + +
    + + + + + + + + +
    + + +
    + + + rotationY + +
    +
    + Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + + +
    + + + + + + + + +
    + + +
    + + + scaleAnchor + +
    +
    + A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value. + + +
    + + + + + + + + +
    + + +
    + + + scaleTX + +
    +
    + Scale Anchor X. Value 0-1 + + +
    + + + + + + + + +
    + + +
    + + + scaleTY + +
    +
    + Scale Anchor Y. Value 0-1 + + +
    + + + + + + + + +
    + + +
    + + + scaleX + +
    +
    + ScaleX value. + + +
    + + + + + + + + +
    + + +
    + + + scaleY + +
    +
    + ScaleY value. + + +
    + + + + + + + + +
    + + +
    + + + size_active + +
    +
    + debug info. + + +
    + + + + + + + + +
    + + +
    + + + size_total + +
    +
    + debug info. + + +
    + + + + + + + + +
    + + +
    + + + start_time + +
    +
    + Marks since when this actor, relative to scene time, is going to be animated/drawn. + + +
    + + + + + + + + +
    + + +
    + + + strokeStyle + +
    +
    + any canvas rendering valid stroke style. + + +
    + + + + + + + + +
    + + +
    + + + tAnchorX + +
    +
    + Translation x anchor. 0..1 + + +
    + + + + + + + + +
    + + +
    + + + tAnchorY + +
    +
    + Translation y anchor. 0..1 + + +
    + + + + + + + + +
    + + +
    + + + time + +
    +
    + This actor´s scene time. + + +
    + + + + + + + + +
    + + +
    + + + viewVertices + +
    +
    + These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding +box. If the actor is not rotated, viewVertices and AABB define the same bounding box. + + +
    + + + + + + + + +
    + + +
    + + + visible + +
    +
    + Make this actor visible or not. +An invisible actor avoids making any calculation, applying any behavior on it. + + +
    + + + + + + + + +
    + + +
    <private> + + + wdirty + +
    +
    + Global matrix dirtyness flag. + + +
    + + + + + + + + +
    + + +
    + + + width + +
    +
    + Actor's width. In parent's local coord. system. + + +
    + + + + + + + + +
    + + +
    + + + worldModelViewMatrix + +
    +
    + This actor´s world affine transformation matrix. + + +
    + + + + + + + + +
    + + +
    + + + worldModelViewMatrixI + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + x + +
    +
    + x position on parent. In parent's local coord. system. + + +
    + + + + + + + + +
    + + +
    + + + y + +
    +
    + y position on parent. In parent's local coord. system. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __paintActor(director, time) + +
    +
    + for js2native + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + {*} + __scale1To(axis, scale, duration, delay, anchorX, anchorY, interpolator) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + axis + +
    +
    {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis
    + +
    + scale + +
    +
    {number} new Y scale
    + +
    + duration + +
    +
    {number} time to rotate
    + +
    + delay + +
    +
    {=number} millis to start rotation
    + +
    + anchorX + +
    +
    {=number} rotation anchor x
    + +
    + anchorY + +
    +
    {=number} rotation anchor y
    + +
    + interpolator + +
    +
    {=CAAT.Bahavior.Interpolator}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    <private> + + + __validateLayout() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addAnimation(name, array, time, callback) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + array + +
    +
    + +
    + time + +
    +
    + +
    + callback + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addBehavior(behavior) + +
    +
    + Add a Behavior to the Actor. +An Actor accepts an undefined number of Behaviors. + + +
    + + + + +
    +
    Parameters:
    + +
    + behavior + +
    +
    {CAAT.Behavior.BaseBehavior}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + addListener(actorListener) + +
    +
    + Adds an Actor's life cycle listener. +The developer must ensure the actorListener is not already a listener, otherwise +it will notified more than once. + + +
    + + + + +
    +
    Parameters:
    + +
    + actorListener + +
    +
    {object} an object with at least a method of the form: +actorLyfeCycleEvent( actor, string_event_type, long_time )
    + +
    + + + + + + + + +
    + + +
    + + + animate(director, time) + +
    +
    + Private +This method is called by the Director instance. +It applies the list of behaviors the Actor has registered. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    + + + cacheAsBitmap(time, stragegy) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {Number=}
    + +
    + stragegy + +
    +
    {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + centerAt(x, y) + +
    +
    + Center this actor at position (x,y). + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} x position
    + +
    + y + +
    +
    {number} y position
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + centerOn(x, y) + +
    +
    + Center this actor at position (x,y). + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} x position
    + +
    + y + +
    +
    {number} y position
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + clean() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + contains(x, y) + +
    +
    + Checks whether a coordinate is inside the Actor's bounding box. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} a float
    + +
    + y + +
    +
    {number} a float
    + +
    + + + + + +
    +
    Returns:
    + +
    boolean indicating whether it is inside.
    + +
    + + + + +
    + + +
    + + {*} + create() + +
    +
    + + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    <private> + + + destroy(time) + +
    +
    + This method will be called internally by CAAT when an Actor is expired, and at the +same time, is flagged as discardable. +It notifies the Actor life cycle listeners about the destruction event. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    an integer indicating the time at wich the Actor has been destroyed.
    + +
    + + + + + + + + +
    + + +
    + + + disableDrag() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + drawScreenBoundingBox(director, time) + +
    +
    + Draw a bounding box with on-screen coordinates regardless of the transformations +applied to the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    {number} integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    + + + emptyBehaviorList() + +
    +
    + Removes all behaviors from an Actor. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + enableDrag() + +
    +
    + Enables a default dragging routine for the Actor. +This default dragging routine allows to: +
  • scale the Actor by pressing shift+drag +
  • rotate the Actor by pressing control+drag +
  • scale non uniformly by pressing alt+shift+drag + + + + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + enableEvents(enable) + +
    +
    + Enable or disable the event bubbling for this Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + enable + +
    +
    {boolean} a boolean indicating whether the event bubbling is enabled.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + endAnimate(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + findActorAtPosition(point) + +
    +
    + Private +This method does the needed point transformations across an Actor hierarchy to devise +whether the parameter point coordinate lies inside the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Math.Point}
    + +
    + + + + + +
    +
    Returns:
    + +
    null if the point is not inside the Actor. The Actor otherwise.
    + +
    + + + + +
    + + +
    + + + findActorById(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + fireEvent(sEventType, time) + +
    +
    + Notifies the registered Actor's life cycle listener about some event. + + +
    + + + + +
    +
    Parameters:
    + +
    + sEventType + +
    +
    an string indicating the type of event being notified.
    + +
    + time + +
    +
    an integer indicating the time related to Scene's timeline when the event +is being notified.
    + +
    + + + + + + + + +
    + + +
    + + + gestureChange(rotation, scaleX, scaleY) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rotation + +
    +
    + +
    + scaleX + +
    +
    + +
    + scaleY + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + gestureEnd(rotation, scaleX, scaleY) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rotation + +
    +
    + +
    + scaleX + +
    +
    + +
    + scaleY + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + gestureStart(rotation, scaleX, scaleY) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rotation + +
    +
    + +
    + scaleX + +
    +
    + +
    + scaleY + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getAnchor(anchor) + +
    +
    + Private. +Gets a given anchor position referred to the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + anchor + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    an object of the form { x: float, y: float }
    + +
    + + + + +
    + + +
    + + + getAnchorPercent(anchor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + anchor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getBehavior(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getId() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getMinimumSize() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getPreferredSize() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {CAAT.GLTexturePage} + getTextureGLPage() + +
    +
    + If GL is enables, get this background image's texture page, otherwise it will fail. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.GLTexturePage}
    + +
    + + + + +
    + + +
    + + + glNeedsFlush(director) + +
    +
    + Test for compulsory gl flushing: + 1.- opacity has changed. + 2.- texture page has changed. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + glSetShader(director) + +
    +
    + Change texture shader program parameters. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initialize(overrides) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + overrides + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + invalidate() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + invalidateLayout() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isCached() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isGestureEnabled() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + isInAnimationFrame(time) + +
    +
    + This method is called by the Director to know whether the actor is on Scene time. +In case it was necessary, this method will notify any life cycle behaviors about +an Actor expiration. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time indicating the Scene time.
    + +
    + + + + + + + + +
    + + +
    + + + isVisible() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + modelToModel(point, otherActor) + +
    +
    + Transform a local coordinate point on this Actor's coordinate system into +another point in otherActor's coordinate system. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Math.Point}
    + +
    + otherActor + +
    +
    {CAAT.Math.Actor}
    + +
    + + + + + + + + +
    + + +
    <private> + + + modelToView(point) + +
    +
    + Transform a point or array of points in model space to view space. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Math.Point|Array} an object of the form {x : float, y: float}
    + +
    + + + + + +
    +
    Returns:
    + +
    the source transformed elements.
    + +
    + + + + +
    + + +
    + + + mouseClick(mouseEvent) + +
    +
    + Default mouseClick handler. +Mouse click events are received after a call to mouseUp method if no dragging was in progress. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseDblClick(mouseEvent) + +
    +
    + Default double click handler + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseDown(mouseEvent) + +
    +
    + default mouse press in Actor handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseDrag(mouseEvent) + +
    +
    + default Actor mouse drag handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseEnter(mouseEvent) + +
    +
    + Default mouse enter on Actor handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseExit(mouseEvent) + +
    +
    + Default mouse exit on Actor handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseMove(mouseEvent) + +
    +
    + Default mouse move inside Actor handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseOut(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseOver(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseUp(mouseEvent) + +
    +
    + default mouse release in Actor handler. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + moveTo(x, y, duration, delay, interpolator, callback) + +
    +
    + Move this actor to a position. +It creates and adds a new PathBehavior. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} new x position
    + +
    + y + +
    +
    {number} new y position
    + +
    + duration + +
    +
    {number} time to take to get to new position
    + +
    + delay + +
    +
    {=number} time to wait before start moving
    + +
    + interpolator + +
    +
    {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance
    + +
    + callback + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + This method should me overriden by every custom Actor. +It will be the drawing routine called by the Director to show every Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director} instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    {number} indicating the Scene time in which the drawing is performed.
    + +
    + + + + + + + + +
    + + +
    + + + paintActor(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + +
    +
    Returns:
    + +
    boolean indicating whether the Actor isInFrameTime
    + +
    + + + + +
    + + +
    + + + paintActorGL(director, time) + +
    +
    + Set coordinates and uv values for this actor. +This function uses Director's coords and indexCoords values. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + playAnimation(name) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + removeBehaviorById(id) + +
    +
    + Remove a Behavior with id param as behavior identifier from this actor. +This function will remove ALL behavior instances with the given id. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {number} an integer. +return this;
    + +
    + + + + + + + + +
    + + +
    + + + removeBehaviour(behavior) + +
    +
    + Remove a Behavior from the Actor. +If the Behavior is not present at the actor behavior collection nothing happends. + + +
    + + + + +
    +
    Parameters:
    + +
    + behavior + +
    +
    {CAAT.Behavior.BaseBehavior}
    + +
    + + + + + + + + +
    + + +
    + + + removeListener(actorListener) + +
    +
    + Removes an Actor's life cycle listener. +It will only remove the first occurrence of the given actorListener. + + +
    + + + + +
    +
    Parameters:
    + +
    + actorListener + +
    +
    {object} an Actor's life cycle listener.
    + +
    + + + + + + + + +
    + + +
    + + + resetAnimationTime() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + resetAsButton() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + resetTransform() + +
    +
    + Remove all transformation values for the Actor. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {*} + rotateTo(angle, duration, delay, anchorX, anchorY, interpolator) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number} new rotation angle
    + +
    + duration + +
    +
    {number} time to rotate
    + +
    + delay + +
    +
    {number=} millis to start rotation
    + +
    + anchorX + +
    +
    {number=} rotation anchor x
    + +
    + anchorY + +
    +
    {number=} rotation anchor y
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator=}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + scaleTo(scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scaleX + +
    +
    {number} new X scale
    + +
    + scaleY + +
    +
    {number} new Y scale
    + +
    + duration + +
    +
    {number} time to rotate
    + +
    + delay + +
    +
    {=number} millis to start rotation
    + +
    + anchorX + +
    +
    {=number} rotation anchor x
    + +
    + anchorY + +
    +
    {=number} rotation anchor y
    + +
    + interpolator + +
    +
    {=CAAT.Behavior.Interpolator}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + scaleXTo(scaleX, duration, delay, anchorX, anchorY, interpolator) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scaleX + +
    +
    {number} new X scale
    + +
    + duration + +
    +
    {number} time to rotate
    + +
    + delay + +
    +
    {=number} millis to start rotation
    + +
    + anchorX + +
    +
    {=number} rotation anchor x
    + +
    + anchorY + +
    +
    {=number} rotation anchor y
    + +
    + interpolator + +
    +
    {=CAAT.Behavior.Interpolator}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + scaleYTo(scaleY, duration, delay, anchorX, anchorY, interpolator) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scaleY + +
    +
    {number} new Y scale
    + +
    + duration + +
    +
    {number} time to rotate
    + +
    + delay + +
    +
    {=number} millis to start rotation
    + +
    + anchorX + +
    +
    {=number} rotation anchor x
    + +
    + anchorY + +
    +
    {=number} rotation anchor y
    + +
    + interpolator + +
    +
    {=CAAT.Behavior.Interpolator}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setAlpha(alpha) + +
    +
    + Stablishes the Alpha transparency for the Actor. +If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors. +The alpha must be between 0 and 1. + + +
    + + + + +
    +
    Parameters:
    + +
    + alpha + +
    +
    a float indicating the alpha value.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setAnimationEndCallback(f) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + f + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAnimationImageIndex(ii) + +
    +
    + Set this actor's background SpriteImage its animation sequence. +In its simplet's form a SpriteImage treats a given image as an array of rows by columns +subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages. +This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the +animation sequence + + +
    + + + + +
    +
    Parameters:
    + +
    + ii + +
    +
    {Array} an array of integers.
    + +
    + + + + + + + + +
    + + +
    + + + setAsButton(buttonImage, iNormal, iOver, iPress, iDisabled, fn) + +
    +
    + Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's +single size. + + +
    + + + + +
    +
    Parameters:
    + +
    + buttonImage + +
    +
    {CAAT.Foundation.SpriteImage} sprite image with button's state images.
    + +
    + iNormal + +
    +
    {number} button's normal state image index
    + +
    + iOver + +
    +
    {number} button's mouse over state image index
    + +
    + iPress + +
    +
    {number} button's pressed state image index
    + +
    + iDisabled + +
    +
    {number} button's disabled state image index
    + +
    + fn + +
    +
    {function(button{CAAT.Foundation.Actor})} callback function
    + +
    + + + + + + + + +
    + + +
    + + + setBackgroundImage(image, adjust_size_to_image) + +
    +
    + Set this actor's background image. +The need of a background image is to kept compatibility with the new CSSDirector class. +The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image +is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column. +If the actor has set an image in the background, the paint method will draw the image, otherwise +and if set, will fill its background with a solid color. +If adjust_size_to_image is true, the host actor will be redimensioned to the size of one +single image from the SpriteImage (either supplied or generated because of passing an Image or +Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth, +height:singleHeight]. + +WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage}
    + +
    + adjust_size_to_image + +
    +
    {boolean} whether to set this actor's size based on image parameter.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + +
    +
    See:
    + +
    CAAT.Foundation.SpriteImage
    + +
    + + +
    + + +
    + + + setBackgroundImageOffset(ox, oy) + +
    +
    + Set this actor's background SpriteImage offset displacement. +The values can be either positive or negative meaning the texture space of this background +image does not start at (0,0) but at the desired position. + + +
    + + + + +
    +
    Parameters:
    + +
    + ox + +
    +
    {number} horizontal offset
    + +
    + oy + +
    +
    {number} vertical offset
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + +
    +
    See:
    + +
    CAAT.Foundation.SpriteImage
    + +
    + + +
    + + +
    + + + setBounds(x{number}, y{number}, w{number}, h{number}) + +
    +
    + Set location and dimension of an Actor at once. + + +
    + + + + +
    +
    Parameters:
    + +
    + x{number} + +
    +
    a float indicating Actor's x position.
    + +
    + y{number} + +
    +
    a float indicating Actor's y position
    + +
    + w{number} + +
    +
    a float indicating Actor's width
    + +
    + h{number} + +
    +
    a float indicating Actor's height
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setButtonImageIndex(_normal, _over, _press, _disabled) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + _normal + +
    +
    + +
    + _over + +
    +
    + +
    + _press + +
    +
    + +
    + _disabled + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setCachedActor(cached) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + cached + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setChangeFPS(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setClip(enable, clipPath) + +
    +
    + Set this Actor's clipping area. + + +
    + + + + +
    +
    Parameters:
    + +
    + enable + +
    +
    {boolean} enable clip area.
    + +
    + clipPath + +
    +
    {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set, + a rectangle will be used.
    + +
    + + + + + + + + +
    + + +
    + + + setDiscardable(discardable) + +
    +
    + Set discardable property. If an actor is discardable, upon expiration will be removed from +scene graph and hence deleted. + + +
    + + + + +
    +
    Parameters:
    + +
    + discardable + +
    +
    {boolean} a boolean indicating whether the Actor is discardable.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setExpired(time) + +
    +
    + Sets this Actor as Expired. +If this is a Container, all the contained Actors won't be nor drawn nor will receive +any event. That is, expiring an Actor means totally taking it out the Scene's timeline. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} an integer indicating the time the Actor was expired at.
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + + setFillStyle(style) + +
    +
    + Caches a fillStyle in the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    a valid Canvas rendering context fillStyle.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setFrameTime(startTime, duration) + +
    +
    + Sets the time life cycle for an Actor. +These values are related to Scene time. + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    an integer indicating the time until which the Actor won't be visible on the Scene.
    + +
    + duration + +
    +
    an integer indicating how much the Actor will last once visible.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setGestureEnabled(enable) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + enable + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setGLCoords(glCoords, glCoordsIndex) + +
    +
    + TODO: set GLcoords for different image transformations. + + +
    + + + + +
    +
    Parameters:
    + +
    + glCoords + +
    +
    + +
    + glCoordsIndex + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setGlobalAlpha(global) + +
    +
    + Set alpha composition scope. global will mean this alpha value will be its children maximum. +If set to false, only this actor will have this alpha value. + + +
    + + + + +
    +
    Parameters:
    + +
    + global + +
    +
    {boolean} whether the alpha value should be propagated to children.
    + +
    + + + + + + + + +
    + + +
    + + + setGlobalAnchor(ax, ay) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ax + +
    +
    + +
    + ay + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setId(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setImageTransformation(it) + +
    +
    + Set this background image transformation. +If GL is enabled, this parameter has no effect. + + +
    + + + + +
    +
    Parameters:
    + +
    + it + +
    +
    any value from CAAT.Foundation.SpriteImage.TR_*
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setLocation(x{number}, y{number}) + +
    +
    + This method sets the position of an Actor inside its parent. + + +
    + + + + +
    +
    Parameters:
    + +
    + x{number} + +
    +
    a float indicating Actor's x position
    + +
    + y{number} + +
    +
    a float indicating Actor's y position
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {*} + setMinimumSize(pw, ph) + +
    +
    + Set this actors minimum layout size. + + +
    + + + + +
    +
    Parameters:
    + +
    + pw + +
    +
    {number}
    + +
    + ph + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setModelViewMatrix() + +
    +
    + Set this model view matrix if the actor is Dirty. + + mm[2]+= this.x; + mm[5]+= this.y; + if ( this.rotationAngle ) { + this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) ); + this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle ); + } + if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) { + this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) ); + this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) ); + } + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setOutOfFrameTime() + +
    +
    + Puts an Actor out of time line, that is, won't be transformed nor rendered. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setPaint(paint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + paint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setParent(parent) + +
    +
    + Set this actor's parent. + + +
    + + + + +
    +
    Parameters:
    + +
    + parent + +
    +
    {CAAT.Foundation.ActorContainer}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setPosition(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPositionAnchor(pax, pay) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + pax + +
    +
    + +
    + pay + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPositionAnchored(x, y, pax, pay) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + pax + +
    +
    + +
    + pay + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {*} + setPreferredSize(pw, ph) + +
    +
    + Set this actors preferred layout size. + + +
    + + + + +
    +
    Parameters:
    + +
    + pw + +
    +
    {number}
    + +
    + ph + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + setPreventLayout(b) + +
    +
    + Make this actor not be laid out. + + +
    + + + + +
    +
    Parameters:
    + +
    + b + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRotation(angle) + +
    +
    + A helper method for setRotationAnchored. This methods stablishes the center +of rotation to be the center of the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    a float indicating the angle in radians to rotate the Actor.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setRotationAnchor(rax, ray) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rax + +
    +
    + +
    + ray + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRotationAnchored(angle, rx, ry) + +
    +
    + This method sets Actor rotation around a given position. + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number} indicating the angle in radians to rotate the Actor.
    + +
    + rx + +
    +
    {number} value in the range 0..1
    + +
    + ry + +
    +
    {number} value in the range 0..1
    + +
    + + + + + +
    +
    Returns:
    + +
    this;
    + +
    + + + + +
    + + +
    + + + setScale(sx, sy) + +
    +
    + A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER + + +
    + + + + +
    +
    Parameters:
    + +
    + sx + +
    +
    a float indicating a width size multiplier.
    + +
    + sy + +
    +
    a float indicating a height size multiplier.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + +
    +
    See:
    + +
    setScaleAnchored
    + +
    + + +
    + + +
    + + + setScaleAnchor(sax, say) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + sax + +
    +
    + +
    + say + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScaleAnchored(sx, sy, anchorx, anchory) + +
    +
    + Modify the dimensions on an Actor. +The dimension will not affect the local coordinates system in opposition +to setSize or setBounds. + + +
    + + + + +
    +
    Parameters:
    + +
    + sx + +
    +
    {number} width scale.
    + +
    + sy + +
    +
    {number} height scale.
    + +
    + anchorx + +
    +
    {number} x anchor to perform the Scale operation.
    + +
    + anchory + +
    +
    {number} y anchor to perform the Scale operation.
    + +
    + + + + + +
    +
    Returns:
    + +
    this;
    + +
    + + + + +
    + + +
    <private> + + + setScreenBounds() + +
    +
    + Calculates the 2D bounding box in canvas coordinates of the Actor. +This bounding box takes into account the transformations applied hierarchically for +each Scene Actor. + + +
    + + + + + + + + + + + +
    + + +
    + + + setSize(w, h) + +
    +
    + Sets an Actor's dimension + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    a float indicating Actor's width.
    + +
    + h + +
    +
    a float indicating Actor's height.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setSpriteIndex(index) + +
    +
    + Set the actor's SpriteImage index from animation sheet. + + +
    + + + + +
    +
    Parameters:
    + +
    + index + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + +
    +
    See:
    + +
    CAAT.Foundation.SpriteImage
    + +
    + + +
    + + +
    + + + setStrokeStyle(style) + +
    +
    + Caches a stroke style in the Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    a valid canvas rendering context stroke style.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setUV(uvBuffer, uvIndex) + +
    +
    + Set UV for this actor's quad. + + +
    + + + + +
    +
    Parameters:
    + +
    + uvBuffer + +
    +
    {Float32Array}
    + +
    + uvIndex + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setVisible(visible) + +
    +
    + Set this actor invisible. +The actor is animated but not visible. +A container won't show any of its children if set visible to false. + + +
    + + + + +
    +
    Parameters:
    + +
    + visible + +
    +
    {boolean} set this actor visible or not.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + stopCacheAsBitmap() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + touchEnd(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + touchMove(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + touchStart(e) + +
    +
    + Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + viewToModel(point) + +
    +
    + Transform a point from model to view space. +

    +WARNING: every call to this method calculates +actor's world model view matrix. + + +

    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Math.Point} a point in screen space to be transformed to model space.
    + +
    + + + + + +
    +
    Returns:
    + +
    the source point object
    + +
    + + + + + + + + + + + +
    + + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html new file mode 100644 index 0000000..38ecc5e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html @@ -0,0 +1,653 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.ActorContainer.ADDHINT + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation.ActorContainer.ADDHINT +

    + + +

    + + + + + + +
    Defined in: ActorContainer.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Foundation.ActorContainer.ADDHINT.CONFORM +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <static>   +
    CAAT.Foundation.ActorContainer.ADDHINT.extendsWith() +
    +
    +
    + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation.ActorContainer.ADDHINT +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Foundation.ActorContainer.ADDHINT.CONFORM + +
    +
    + + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <static> + + + CAAT.Foundation.ActorContainer.ADDHINT.extendsWith() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.html new file mode 100644 index 0000000..7fde28d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.html @@ -0,0 +1,2428 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.ActorContainer + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.ActorContainer +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: ActorContainer.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   + +
    This container active children.
    +
    <private>   +
    + addHint +
    +
    Container redimension policy when adding children: + 0 : no resize.
    +
    <private>   + +
    If container redimension on children add, use this rectangle as bounding box store.
    +
      + +
    This container children.
    +
      + +
    +
      + +
    Define a layout manager for this container that enforces children position and/or sizes.
    +
    <private>   + +
    This container pending to be added children.
    +
    <private>   +
    + runion +
    +
    Spare rectangle to avoid new allocations when adding children to this container.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(hint) +
    +
    Constructor delegate
    +
    <private>   +
    __paintActor(director, time) +
    +
    +
    <private>   + +
    +
    <private>   + +
    +
      +
    addActor(child, constraint) +
    +
    +
      +
    addActorImmediately(child, constraint) +
    +
    +
      +
    addChild(child, constraint) +
    +
    Adds an Actor to this ActorContainer.
    +
      +
    addChildAt(child, index) +
    +
    Adds an Actor to this ActorContainer.
    +
      +
    addChildDelayed(child, constraint) +
    +
    Add a child element and make it active in the next frame.
    +
      +
    addChildImmediately(child, constraint) +
    +
    Adds an Actor to this Container.
    +
      +
    animate(director, time) +
    +
    Private.
    +
      +
    destroy() +
    +
    Destroys this ActorContainer.
    +
      +
    drawScreenBoundingBox(director, time) +
    +
    Draws this ActorContainer and all of its children screen bounding box.
    +
      + +
    Removes all children from this ActorContainer.
    +
      +
    endAnimate(director, time) +
    +
    Removes Actors from this ActorContainer which are expired and flagged as Discardable.
    +
    <private>   + +
    +
      + +
    Find the first actor with the supplied ID.
    +
      +
    findChild(child) +
    +
    Private +Gets a contained Actor z-index on this ActorContainer.
    +
      +
    getChildAt(iPosition) +
    +
    Returns the Actor at the iPosition(th) position.
    +
      + +
    +
      + +
    +
      + +
    Get number of Actors into this container.
    +
      + +
    +
      +
    paintActor(director, time) +
    +
    Private +Paints this container and every contained children.
    +
      +
    paintActorGL(director, time) +
    +
    +
      + +
    Recalc this container size by computing the union of every children bounding box.
    +
      +
    removeChild(child) +
    +
    Removed an Actor form this ActorContainer.
    +
      + +
    +
      + +
    +
      + +
    +
      +
    setBounds(x, y, w, h) +
    +
    +
      +
    setLayout(layout) +
    +
    +
      +
    setZOrder(actor, index) +
    +
    Changes an actor's ZOrder.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, emptyBehaviorList, enableDrag, enableEvents, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paint, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.ActorContainer() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + activeChildren + +
    +
    + This container active children. + + +
    + + + + + + + + +
    + + +
    <private> + + + addHint + +
    +
    + Container redimension policy when adding children: + 0 : no resize. + CAAT.Foundation.ActorContainer.AddHint.CONFORM : resize container to a bounding box. + + +
    + + + + + + + + +
    + + +
    <private> + + + boundingBox + +
    +
    + If container redimension on children add, use this rectangle as bounding box store. + + +
    + + + + + + + + +
    + + +
    + + + childrenList + +
    +
    + This container children. + + +
    + + + + + + + + +
    + + +
    + + + layoutInvalidated + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + layoutManager + +
    +
    + Define a layout manager for this container that enforces children position and/or sizes. + + +
    + + + + + + +
    +
    See:
    + +
    demo26 for an example of layouts.
    + +
    + + + +
    + + +
    <private> + + + pendingChildrenList + +
    +
    + This container pending to be added children. + + +
    + + + + + + + + +
    + + +
    <private> + + + runion + +
    +
    + Spare rectangle to avoid new allocations when adding children to this container. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + {*} + __init(hint) + +
    +
    + Constructor delegate + + +
    + + + + +
    +
    Parameters:
    + +
    + hint + +
    +
    {CAAT.Foundation.ActorContainer.AddHint}
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    <private> + + + __paintActor(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __validateLayout() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __validateTree() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addActor(child, constraint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + constraint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addActorImmediately(child, constraint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + constraint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addChild(child, constraint) + +
    +
    + Adds an Actor to this ActorContainer. +The Actor will be added to the container AFTER frame animation, and not on method call time. +Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this +method directly. + +If the container has addingHint as CAAT.Foundation.ActorContainer.AddHint.CONFORM, new continer size will be +calculated by summing up the union of every client actor bounding box. +This method will not take into acount actor's affine transformations, so the bounding box will be +AABB. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    {CAAT.Foundation.Actor} object instance.
    + +
    + constraint + +
    +
    {object}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + addChildAt(child, index) + +
    +
    + Adds an Actor to this ActorContainer. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    {CAAT.Foundation.Actor}.
    + +
    + index + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + addChildDelayed(child, constraint) + +
    +
    + Add a child element and make it active in the next frame. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    {CAAT.Foundation.Actor}
    + +
    + constraint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addChildImmediately(child, constraint) + +
    +
    + Adds an Actor to this Container. +The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at +the time of method call. + +This method is only used by director's transitionScene. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    {CAAT.Foundation.Actor}
    + +
    + constraint + +
    +
    {object}
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + {boolean} + animate(director, time) + +
    +
    + Private. +Performs the animate method for this ActorContainer and every contained Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean} is this actor in active children list ??
    + +
    + + + + +
    + + +
    + + + destroy() + +
    +
    + Destroys this ActorContainer. +The process falls down recursively for each contained Actor into this ActorContainer. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + drawScreenBoundingBox(director, time) + +
    +
    + Draws this ActorContainer and all of its children screen bounding box. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    + + + emptyChildren() + +
    +
    + Removes all children from this ActorContainer. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + endAnimate(director, time) + +
    +
    + Removes Actors from this ActorContainer which are expired and flagged as Discardable. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    <private> + + + findActorAtPosition(point) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    an object of the form { x: float, y: float }
    + +
    + + + + + +
    +
    Returns:
    + +
    the Actor contained inside this ActorContainer if found, or the ActorContainer itself.
    + +
    + + + + +
    + + +
    + + + findActorById(id) + +
    +
    + Find the first actor with the supplied ID. +This method is not recommended to be used since executes a linear search. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {number} + findChild(child) + +
    +
    + Private +Gets a contained Actor z-index on this ActorContainer. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    a CAAT.Foundation.Actor object instance.
    + +
    + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + + getChildAt(iPosition) + +
    +
    + Returns the Actor at the iPosition(th) position. + + +
    + + + + +
    +
    Parameters:
    + +
    + iPosition + +
    +
    an integer indicating the position array.
    + +
    + + + + + +
    +
    Returns:
    + +
    the CAAT.Foundation.Actor object at position.
    + +
    + + + + +
    + + +
    + + + getLayout() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getNumActiveChildren() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getNumChildren() + +
    +
    + Get number of Actors into this container. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    integer indicating the number of children.
    + +
    + + + + +
    + + +
    + + + invalidateLayout() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + paintActor(director, time) + +
    +
    + Private +Paints this container and every contained children. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    + +
    + time + +
    +
    an integer indicating the Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    + + + paintActorGL(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + recalcSize() + +
    +
    + Recalc this container size by computing the union of every children bounding box. + + +
    + + + + + + + + + + + +
    + + +
    + + + removeChild(child) + +
    +
    + Removed an Actor form this ActorContainer. +If the Actor is not contained into this Container, nothing happends. + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    a CAAT.Foundation.Actor object instance.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + removeChildAt(pos) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + pos + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + removeFirstChild() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + removeLastChild() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setLayout(layout) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + layout + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setZOrder(actor, index) + +
    +
    + Changes an actor's ZOrder. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    the actor to change ZOrder for
    + +
    + index + +
    +
    an integer indicating the new ZOrder. a value greater than children list size means to be the +last ZOrder Actor.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DBodyActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DBodyActor.html new file mode 100644 index 0000000..a7e9927 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DBodyActor.html @@ -0,0 +1,1720 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Box2D.B2DBodyActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Box2D.B2DBodyActor +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: B2DBodyActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + bodyData +
    +
    BodyData object linked to the box2D body.
    +
      +
    + bodyDef +
    +
    Box2D body definition.
    +
      +
    + bodyType +
    +
    Dynamic bodies by default
    +
      +
    + density +
    +
    Body dentisy
    +
      + +
    Box2D fixture definition.
    +
      +
    + friction +
    +
    Body friction.
    +
      +
    + recycle +
    +
    Recycle this actor when the body is not needed anymore ??
    +
      + +
    Body restitution.
    +
      +
    + world +
    +
    Box2D world reference.
    +
      +
    + worldBody +
    +
    Box2D body
    +
      + +
    Box2d fixture
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    animate(director, time) +
    +
    Method override to get position and rotation angle from box2d body.
    +
      +
    check(obj, prop, def) +
    +
    Helper method to check whether this js object contains a given property and if it doesn't exist +create and set it to def value.
    +
      +
    createBody(world, bodyData) +
    +
    Create an actor as a box2D body binding, create it on the given world and with +the initialization data set in bodyData object.
    +
      +
    destroy() +
    +
    +
      + +
    Get this body's center on screen regardless of its shape.
    +
      + +
    Get a distance joint's position on pixels.
    +
      +
    setAwake(bool) +
    +
    +
      +
    setBodyType(bodyType) +
    +
    Set this body's type:
    +
      + +
    Set this body's +density.
    +
      + +
    Set this body's friction.
    +
      +
    setLocation(x, y) +
    +
    +
      + +
    +
      +
    setPositionAnchored(x, y, ax, ay) +
    +
    +
      + +
    set this actor to recycle its body, that is, do not destroy it.
    +
      + +
    Set this body's restitution coeficient.
    +
      + +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paint, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Box2D.B2DBodyActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + bodyData + +
    +
    + BodyData object linked to the box2D body. + + +
    + + + + + + + + +
    + + +
    + + + bodyDef + +
    +
    + Box2D body definition. + + +
    + + + + + + + + +
    + + +
    + + + bodyType + +
    +
    + Dynamic bodies by default + + +
    + + + + + + + + +
    + + +
    + + + density + +
    +
    + Body dentisy + + +
    + + + + + + + + +
    + + +
    + + + fixtureDef + +
    +
    + Box2D fixture definition. + + +
    + + + + + + + + +
    + + +
    + + + friction + +
    +
    + Body friction. + + +
    + + + + + + + + +
    + + +
    + + + recycle + +
    +
    + Recycle this actor when the body is not needed anymore ?? + + +
    + + + + + + + + +
    + + +
    + + + restitution + +
    +
    + Body restitution. + + +
    + + + + + + + + +
    + + +
    + + + world + +
    +
    + Box2D world reference. + + +
    + + + + + + + + +
    + + +
    + + + worldBody + +
    +
    + Box2D body + + +
    + + + + + + + + +
    + + +
    + + + worldBodyFixture + +
    +
    + Box2d fixture + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + animate(director, time) + +
    +
    + Method override to get position and rotation angle from box2d body. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + check(obj, prop, def) + +
    +
    + Helper method to check whether this js object contains a given property and if it doesn't exist +create and set it to def value. + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    {object}
    + +
    + prop + +
    +
    {string}
    + +
    + def + +
    +
    {object}
    + +
    + + + + + + + + +
    + + +
    + + + createBody(world, bodyData) + +
    +
    + Create an actor as a box2D body binding, create it on the given world and with +the initialization data set in bodyData object. + + +
    + + + + +
    +
    Parameters:
    + +
    + world + +
    +
    {Box2D.Dynamics.b2World} a Box2D world instance
    + +
    + bodyData + +
    +
    {object} An object with body info.
    + +
    + + + + + + + + +
    + + +
    + + + destroy() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getCenter() + +
    +
    + Get this body's center on screen regardless of its shape. +This method will return box2d body's centroid. + + +
    + + + + + + + + + + + +
    + + +
    + + + getDistanceJointLocalAnchor() + +
    +
    + Get a distance joint's position on pixels. + + +
    + + + + + + + + + + + +
    + + +
    + + + setAwake(bool) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bool + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setBodyType(bodyType) + +
    +
    + Set this body's type: + + +
    + + + + +
    +
    Parameters:
    + +
    + bodyType + +
    +
    {Box2D.Dynamics.b2Body.b2_*}
    + +
    + + + + + + + + +
    + + +
    + + + setDensity(d) + +
    +
    + Set this body's +density. + + +
    + + + + +
    +
    Parameters:
    + +
    + d + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setFriction(f) + +
    +
    + Set this body's friction. + + +
    + + + + +
    +
    Parameters:
    + +
    + f + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setLocation(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPositionAnchor(ax, ay) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ax + +
    +
    + +
    + ay + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPositionAnchored(x, y, ax, ay) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + ax + +
    +
    + +
    + ay + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRecycle() + +
    +
    + set this actor to recycle its body, that is, do not destroy it. + + +
    + + + + + + + + + + + +
    + + +
    + + + setRestitution(r) + +
    +
    + Set this body's restitution coeficient. + + +
    + + + + +
    +
    Parameters:
    + +
    + r + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setSleepingAllowed(bool) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + bool + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DCircularBody.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DCircularBody.html new file mode 100644 index 0000000..1936c59 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DCircularBody.html @@ -0,0 +1,731 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Box2D.B2DCircularBody + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Box2D.B2DCircularBody +

    + + +

    + +
    Extends + CAAT.Foundation.Box2D.B2DBodyActor.
    + + + + + +
    Defined in: B2DCircularBody.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + radius +
    +
    Default radius.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Box2D.B2DBodyActor:
    bodyData, bodyDef, bodyType, density, fixtureDef, friction, recycle, restitution, world, worldBody, worldBodyFixture
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    createBody(world, bodyData) +
    +
    Create a box2d body and link it to this CAAT.Actor instance.
    +
    <static>   +
    CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(world, bodyData) +
    +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Box2D.B2DBodyActor:
    __init, animate, check, destroy, getCenter, getDistanceJointLocalAnchor, setAwake, setBodyType, setDensity, setFriction, setLocation, setPositionAnchor, setPositionAnchored, setRecycle, setRestitution, setSleepingAllowed
    Methods borrowed from class CAAT.Foundation.Actor:
    __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paint, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Box2D.B2DCircularBody() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + radius + +
    +
    + Default radius. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + createBody(world, bodyData) + +
    +
    + Create a box2d body and link it to this CAAT.Actor instance. + + +
    + + + + +
    +
    Parameters:
    + +
    + world + +
    +
    {Box2D.Dynamics.b2World} a Box2D world instance
    + +
    + bodyData + +
    +
    {object}
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(world, bodyData) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + world + +
    +
    + +
    + bodyData + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DPolygonBody.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DPolygonBody.html new file mode 100644 index 0000000..0590f04 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.B2DPolygonBody.html @@ -0,0 +1,765 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Box2D.B2DPolygonBody + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Box2D.B2DPolygonBody +

    + + +

    + +
    Extends + CAAT.Foundation.Box2D.B2DBodyActor.
    + + + + + +
    Defined in: B2DPolygonBody.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    Measured body's bounding box.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Box2D.B2DBodyActor:
    bodyData, bodyDef, bodyType, density, fixtureDef, friction, recycle, restitution, world, worldBody, worldBodyFixture
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    createBody(world, bodyData) +
    +
    Create a box2d body and link it to this CAAT.Actor.
    +
    <static>   +
    CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(world, bodyData) +
    +
    Helper function to aid in box2d polygon shaped bodies.
    +
      + +
    Get on-screen distance joint coordinate.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Box2D.B2DBodyActor:
    __init, animate, check, destroy, getCenter, setAwake, setBodyType, setDensity, setFriction, setLocation, setPositionAnchor, setPositionAnchored, setRecycle, setRestitution, setSleepingAllowed
    Methods borrowed from class CAAT.Foundation.Actor:
    __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paint, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Box2D.B2DPolygonBody() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + boundingBox + +
    +
    + Measured body's bounding box. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + createBody(world, bodyData) + +
    +
    + Create a box2d body and link it to this CAAT.Actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + world + +
    +
    {Box2D.Dynamics.b2World}
    + +
    + bodyData + +
    +
    {object}
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(world, bodyData) + +
    +
    + Helper function to aid in box2d polygon shaped bodies. + + +
    + + + + +
    +
    Parameters:
    + +
    + world + +
    +
    + +
    + bodyData + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getDistanceJointLocalAnchor() + +
    +
    + Get on-screen distance joint coordinate. + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.html new file mode 100644 index 0000000..16c2054 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Box2D.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Box2D + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation.Box2D +

    + + +

    + + + + + + +
    Defined in: B2DBodyActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation.Box2D +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:17 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Director.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Director.html new file mode 100644 index 0000000..8eda44f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Director.html @@ -0,0 +1,7654 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Director + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Director +

    + + +

    + +
    Extends + CAAT.Foundation.ActorContainer.
    + + + + + +
    Defined in: Director.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   + +
    Calculated gesture event rotation.
    +
    <private>   + +
    Calculated gesture event scale.
    +
    <private>   + +
    this director´s audio manager.
    +
      + +
    Some browser related information.
    +
    <private>   +
    + canvas +
    +
    The canvas the Director draws on.
    +
    <private>   + +
    current dirty rects.
    +
      +
    + clear +
    +
    Clear screen strategy: +CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background.
    +
    <static>   +
    + CAAT.Foundation.Director.CLEAR_ALL +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.CLEAR_DIRTY_RECTS +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.CLEAR_NONE +
    +
    +
    <private>   +
    + coords +
    +
    webGL vertex array
    +
    <private>   + +
    webGL vertex indices.
    +
      +
    + ctx +
    +
    This director´s canvas rendering context.
    +
    <private>   + +
    webGL current shader opacity.
    +
      + +
    The current Scene.
    +
    <private>   + +
    webGL current texture page.
    +
      +
    + debug +
    +
    flag indicating debug mode.
    +
    <private>   + +
    Dirty rects cache.
    +
    <private>   + +
    Dirty rects enabled ??
    +
    <private>   + +
    Number of currently allocated dirty rects.
    +
      +
    + dragging +
    +
    is input in drag mode ?
    +
    <private>   + +
    Dirty rects count debug info.
    +
      + +
    Rendered frames counter.
    +
    <private>   + +
    draw tris front_to_back or back_to_front ?
    +
    <private>   +
    + gl +
    +
    3d context
    +
    <private>   +
    + glEnabled +
    +
    is WebGL enabled as renderer ?
    +
    <private>   + +
    if webGL is on, CAAT will texture pack all images transparently.
    +
    <private>   + +
    The only GLSL program for webGL
    +
      + +
    An array of JSON elements of the form { id:string, image:Image }
    +
    <private>   + +
    if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned +id.
    +
      + +
    is the left mouse button pressed ?.
    +
      + +
    director's last actor receiving input.
    +
    <private>   + +
    mouse coordinate related to canvas 0,0 coord.
    +
    <private>   + +
    Number of dirty rects.
    +
    <private>   + +
    currently unused.
    +
    <private>   + +
    This method will be called after rendering any director scene.
    +
    <private>   + +
    This method will be called before rendering any director scene.
    +
      + +
    Callback when the window is resized.
    +
    <private>   +
    + pMatrix +
    +
    webGL projection matrix
    +
    <private>   + +
    previous mouse position cache.
    +
    <static>   +
    + CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.RENDER_MODE_DIRTY +
    +
    +
      + +
    Set CAAT render mode.
    +
    <private>   +
    + resize +
    +
    Window resize strategy.
    +
    <static>   +
    + CAAT.Foundation.Director.RESIZE_BOTH +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.RESIZE_HEIGHT +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.RESIZE_NONE +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.RESIZE_PROPORTIONAL +
    +
    +
    <static>   +
    + CAAT.Foundation.Director.RESIZE_WIDTH +
    +
    +
      +
    + scenes +
    +
    This director scene collection.
    +
    <private>   + +
    Retina display deicePixels/backingStorePixels ratio
    +
    <private>   + +
    screen mouse coordinates.
    +
    <private>   + +
    Currently used dirty rects.
    +
      + +
    statistics object
    +
      +
    + stopped +
    +
    Is this director stopped ?
    +
    <private>   +
    + time +
    +
    director time.
    +
    <private>   +
    + timeline +
    +
    global director timeline.
    +
    <private>   + +
    Director´s timer manager.
    +
    <private>   +
    + touches +
    +
    Touches information.
    +
    <private>   + +
    if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene.
    +
    <private>   +
    + uv +
    +
    webGL uv texture indices
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.ActorContainer:
    activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   + +
    +
    <private>   +
    __gestureChange(scale, rotation) +
    +
    +
    <private>   +
    __gestureEnd(scale, rotation) +
    +
    +
    <private>   +
    __gestureStart(scale, rotation) +
    +
    +
    <private>   +
    __init() +
    +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    +
    <private>   + +
    Same as mouseDown but not preventing event.
    +
    <private>   + +
    +
      +
    addAudio(id, url) +
    +
    Adds an audio to the cache.
    +
      +
    addChild(scene) +
    +
    Adds an scene to this Director.
    +
      +
    addDirtyRect(rectangle) +
    +
    Add a rectangle to the list of dirty screen areas which should be redrawn.
    +
      +
    addHandlers(canvas) +
    +
    +
      +
    addImage(id, image, noUpdateGL) +
    +
    Add a new image to director's image cache.
    +
      +
    addScene(scene) +
    +
    Add a new Scene to Director's Scene list.
    +
      +
    animate(director, time) +
    +
    A director is a very special kind of actor.
    +
      +
    audioLoop(id) +
    +
    Loops an audio instance identified by the id.
    +
      +
    audioPlay(id) +
    +
    Plays the audio instance identified by the id.
    +
      +
    cancelPlay(id) +
    +
    +
      +
    cancelPlayByChannel(audioObject) +
    +
    +
      + +
    +
      +
    clean() +
    +
    +
      + +
    +
      + +
    Creates an initializes a Scene object.
    +
      +
    createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel) +
    +
    +
      +
    cumulateOffset(node, parent, prop) +
    +
    Acculumate dom elements position to properly offset on-screen mouse/touch events.
    +
      +
    deleteImage(id, noUpdateGL) +
    +
    +
      +
    easeEnd(scene, b_easeIn) +
    +
    Scene easing listener.
    +
      +
    easeIn(inSceneIndex, type, time, alpha, anchor, interpolator) +
    +
    This method changes Director's current Scene to the scene index indicated by +inSceneIndex parameter.
    +
      +
    easeInOut(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) +
    +
    This method offers full control over the process of switching between any given two Scenes.
    +
      +
    easeInOutRandom(inIndex, outIndex, time, alpha) +
    +
    This method will switch between two given Scene indexes (ie, take away scene number 2, +and bring in scene number 5).
    +
      + +
    Removes Director's scenes.
    +
      +
    enableEvents(onElement) +
    +
    +
      +
    enableResizeEvents(mode, onResizeCallback) +
    +
    Enable window resize events and set redimension policy.
    +
      +
    endLoop() +
    +
    +
      + +
    +
      + +
    +
      + +
    Get this Director's AudioManager instance.
    +
      + +
    Return the running browser name.
    +
      + +
    Return the running browser version.
    +
      +
    getCanvasCoord(point, e) +
    +
    Normalize input event coordinates to be related to (0,0) canvas position.
    +
      + +
    +
      + +
    Return the index of the current scene in the Director's scene list.
    +
      +
    getImage(sId) +
    +
    Gets the resource with the specified resource name.
    +
      + +
    Get the number of scenes contained in the Director.
    +
      +
    getOffset(node) +
    +
    +
      + +
    Return the operating system name.
    +
      + +
    +
      +
    getScene(index) +
    +
    Get a concrete director's scene.
    +
      + +
    +
      +
    getSceneIndex(scene) +
    +
    Return the index for a given Scene object contained in the Director.
    +
      + +
    +
      +
    glFlush() +
    +
    +
      +
    glRender(vertex, coordsIndex, uv) +
    +
    Render buffered elements.
    +
      +
    glReset() +
    +
    +
      + +
    +
      +
    initialize(width, height, canvas, proxy) +
    +
    This method performs Director initialization.
    +
      +
    initializeGL(width, height, canvas, proxy) +
    +
    Experimental.
    +
      + +
    +
      + +
    +
      +
    loop(fps, callback, callback2) +
    +
    +
      +
    mouseDown(mouseEvent) +
    +
    +
      +
    mouseDrag(mouseEvent) +
    +
    +
      +
    mouseEnter(mouseEvent) +
    +
    +
      +
    mouseExit(mouseEvent) +
    +
    +
      +
    mouseMove(mouseEvent) +
    +
    +
      +
    mouseUp(mouseEvent) +
    +
    +
      +
    musicPlay(id) +
    +
    +
      + +
    +
      +
    render(time) +
    +
    This is the entry point for the animation system of the Director.
    +
      + +
    Starts the director animation.If no scene is explicitly selected, the current Scene will +be the first scene added to the Director.
    +
      +
    renderToContext(ctx, scene) +
    +
    This method draws an Scene to an offscreen canvas.
    +
      + +
    +
    <private>   + +
    Reset statistics information.
    +
      + +
    If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement.
    +
      +
    scheduleDirtyRect(rectangle) +
    +
    This method is used when asynchronous operations must produce some dirty rectangle painting.
    +
      + +
    +
      +
    setBounds(x, y, w, h) +
    +
    Set this director's bounds as well as its contained scenes.
    +
      +
    setClear(clear) +
    +
    This method states whether the director must clear background before rendering +each frame.
    +
      + +
    +
      + +
    +
      +
    setImagesCache(imagesCache, tpW, tpH) +
    +
    +
      +
    setMusicEnabled(enabled) +
    +
    +
      + +
    +
      +
    setScene(sceneIndex) +
    +
    Changes (or sets) the current Director scene to the index +parameter.
    +
      + +
    +
      +
    setValueForKey(key, value) +
    +
    +
      +
    setVolume(id, volume) +
    +
    +
      +
    switchToNextScene(time, alpha, transition) +
    +
    Sets the previous Scene in sequence as the current Scene.
    +
      +
    switchToPrevScene(time, alpha, transition) +
    +
    Sets the previous Scene in sequence as the current Scene.
    +
      +
    switchToScene(iNewSceneIndex, time, alpha, transition) +
    +
    This method will change the current Scene by the Scene indicated as parameter.
    +
      + +
    +
      +
    windowResized(w, h) +
    +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.ActorContainer:
    __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setLayout, setZOrder
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, disableDrag, emptyBehaviorList, enableDrag, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseOut, mouseOver, moveTo, paint, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Director() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + __gestureRotation + +
    +
    + Calculated gesture event rotation. + + +
    + + + + + + + + +
    + + +
    <private> + + + __gestureScale + +
    +
    + Calculated gesture event scale. + + +
    + + + + + + + + +
    + + +
    <private> + + + audioManager + +
    +
    + this director´s audio manager. + + +
    + + + + + + + + +
    + + +
    + + + browserInfo + +
    +
    + Some browser related information. + + +
    + + + + + + + + +
    + + +
    <private> + + + canvas + +
    +
    + The canvas the Director draws on. + + +
    + + + + + + + + +
    + + +
    <private> + + + cDirtyRects + +
    +
    + current dirty rects. + + +
    + + + + + + + + +
    + + +
    + + + clear + +
    +
    + Clear screen strategy: +CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background. +CAAT.Foundation.Director.CLEAR_DIRTY_RECTS : clear only affected actors screen area. +CAAT.Foundation.Director.CLEAR_ALL : clear the whole canvas object. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.CLEAR_ALL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.CLEAR_DIRTY_RECTS + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.CLEAR_NONE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <private> + + + coords + +
    +
    + webGL vertex array + + +
    + + + + + + + + +
    + + +
    <private> + + + coordsIndex + +
    +
    + webGL vertex indices. + + +
    + + + + + + + + +
    + + +
    + + + ctx + +
    +
    + This director´s canvas rendering context. + + +
    + + + + + + + + +
    + + +
    <private> + + + currentOpacity + +
    +
    + webGL current shader opacity. +BUGBUG: change this by vertex colors. + + +
    + + + + + + + + +
    + + +
    + + + currentScene + +
    +
    + The current Scene. This and only this will receive events. + + +
    + + + + + + + + +
    + + +
    <private> + + + currentTexturePage + +
    +
    + webGL current texture page. This minimizes webGL context changes. + + +
    + + + + + + + + +
    + + +
    + + + debug + +
    +
    + flag indicating debug mode. It will draw affedted screen areas. + + +
    + + + + + + + + +
    + + +
    <private> + + + dirtyRects + +
    +
    + Dirty rects cache. +An array of CAAT.Math.Rectangle object. + + +
    + + + + + + + + +
    + + +
    <private> + + + dirtyRectsEnabled + +
    +
    + Dirty rects enabled ?? + + +
    + + + + + + + + +
    + + +
    <private> + + + dirtyRectsIndex + +
    +
    + Number of currently allocated dirty rects. + + +
    + + + + + + + + +
    + + +
    + + + dragging + +
    +
    + is input in drag mode ? + + +
    + + + + + + + + +
    + + +
    <private> + + + drDiscarded + +
    +
    + Dirty rects count debug info. + + +
    + + + + + + + + +
    + + +
    + + + frameCounter + +
    +
    + Rendered frames counter. + + +
    + + + + + + + + +
    + + +
    <private> + + + front_to_back + +
    +
    + draw tris front_to_back or back_to_front ? + + +
    + + + + + + + + +
    + + +
    <private> + + + gl + +
    +
    + 3d context + + +
    + + + + + + + + +
    + + +
    <private> + + + glEnabled + +
    +
    + is WebGL enabled as renderer ? + + +
    + + + + + + + + +
    + + +
    <private> + + + glTextureManager + +
    +
    + if webGL is on, CAAT will texture pack all images transparently. + + +
    + + + + + + + + +
    + + +
    <private> + + + glTtextureProgram + +
    +
    + The only GLSL program for webGL + + +
    + + + + + + + + +
    + + +
    + + + imagesCache + +
    +
    + An array of JSON elements of the form { id:string, image:Image } + + +
    + + + + + + + + +
    + + +
    <private> + + + intervalId + +
    +
    + if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned +id. + + +
    + + + + + + + + +
    + + +
    + + + isMouseDown + +
    +
    + is the left mouse button pressed ?. +Needed to handle dragging. + + +
    + + + + + + + + +
    + + +
    + + + lastSelectedActor + +
    +
    + director's last actor receiving input. +Needed to set capture for dragging events. + + +
    + + + + + + + + +
    + + +
    <private> + + + mousePoint + +
    +
    + mouse coordinate related to canvas 0,0 coord. + + +
    + + + + + + + + +
    + + +
    <private> + + + nDirtyRects + +
    +
    + Number of dirty rects. + + +
    + + + + + + + + +
    + + +
    <private> + + + needsRepaint + +
    +
    + currently unused. +Intended to run caat in evented mode. + + +
    + + + + + + + + +
    + + +
    <private> + + + onRenderEnd + +
    +
    + This method will be called after rendering any director scene. +Use this method to clean your physics forces for example. + + +
    + + + + + + + + +
    + + +
    <private> + + + onRenderStart + +
    +
    + This method will be called before rendering any director scene. +Use this method to calculate your physics for example. + + +
    + + + + + + + + +
    + + +
    + + + onResizeCallback + +
    +
    + Callback when the window is resized. + + +
    + + + + + + + + +
    + + +
    <private> + + + pMatrix + +
    +
    + webGL projection matrix + + +
    + + + + + + + + +
    + + +
    <private> + + + prevMousePoint + +
    +
    + previous mouse position cache. Needed for drag events. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RENDER_MODE_DIRTY + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + renderMode + +
    +
    + Set CAAT render mode. Right now, this takes no effect. + + +
    + + + + + + + + +
    + + +
    <private> + + + resize + +
    +
    + Window resize strategy. +see CAAT.Foundation.Director.RESIZE_* constants. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RESIZE_BOTH + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RESIZE_HEIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RESIZE_NONE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RESIZE_PROPORTIONAL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Director.RESIZE_WIDTH + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + scenes + +
    +
    + This director scene collection. + + +
    + + + + + + + + +
    + + +
    <private> + + + SCREEN_RATIO + +
    +
    + Retina display deicePixels/backingStorePixels ratio + + +
    + + + + + + + + +
    + + +
    <private> + + + screenMousePoint + +
    +
    + screen mouse coordinates. + + +
    + + + + + + + + +
    + + +
    <private> + + + sDirtyRects + +
    +
    + Currently used dirty rects. + + +
    + + + + + + + + +
    + + +
    + + + statistics + +
    +
    + statistics object + + +
    + + + + + + + + +
    + + +
    + + + stopped + +
    +
    + Is this director stopped ? + + +
    + + + + + + + + +
    + + +
    <private> + + + time + +
    +
    + director time. + + +
    + + + + + + + + +
    + + +
    <private> + + + timeline + +
    +
    + global director timeline. + + +
    + + + + + + + + +
    + + +
    <private> + + + timerManager + +
    +
    + Director´s timer manager. +Each scene has a timerManager as well. +The difference is the scope. Director´s timers will always be checked whereas scene´ timers +will only be scheduled/checked when the scene is director´ current scene. + + +
    + + + + + + + + +
    + + +
    <private> + + + touches + +
    +
    + Touches information. Associate touch.id with an actor and original touch info. + + +
    + + + + + + + + +
    + + +
    <private> + + + transitionScene + +
    +
    + if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene. + + +
    + + + + + + + + +
    + + +
    <private> + + + uv + +
    +
    + webGL uv texture indices + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __findTouchFirstActor() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __gestureChange(scale, rotation) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scale + +
    +
    + +
    + rotation + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __gestureEnd(scale, rotation) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scale + +
    +
    + +
    + rotation + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __gestureStart(scale, rotation) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scale + +
    +
    + +
    + rotation + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __mouseDBLClickHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __mouseDownHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __mouseMoveHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __mouseOutHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __mouseOverHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __mouseUpHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __setupRetina() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __touchCancelHandleMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchEndHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchEndHandlerMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchGestureChangeHandleMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchGestureEndHandleMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchGestureStartHandleMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchMoveHandler(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchMoveHandlerMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchStartHandler(e) + +
    +
    + Same as mouseDown but not preventing event. +Will only take care of first touch. + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __touchStartHandlerMT(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addAudio(id, url) + +
    +
    + Adds an audio to the cache. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + url + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + +
    +
    See:
    + +
    CAAT.Module.Audio.AudioManager.addAudio
    + +
    + + +
    + + +
    + + + addChild(scene) + +
    +
    + Adds an scene to this Director. + + +
    + + + + +
    +
    Parameters:
    + +
    + scene + +
    +
    {CAAT.Foundation.Scene} a scene object.
    + +
    + + + + + + + + +
    + + +
    + + + addDirtyRect(rectangle) + +
    +
    + Add a rectangle to the list of dirty screen areas which should be redrawn. +This is the opposite method to clear the whole screen and repaint everything again. +Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this +procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or +even lowers performance under others, so it is a developer choice to activate them via a call to +setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). + +This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping +rectangles will be removed and intersecting ones will be unioned. + +Before calling this method, check if this.dirtyRectsEnabled is true. + + +
    + + + + +
    +
    Parameters:
    + +
    + rectangle + +
    +
    {CAAT.Rectangle}
    + +
    + + + + + + + + +
    + + +
    + + + addHandlers(canvas) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + canvas + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addImage(id, image, noUpdateGL) + +
    +
    + Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this +function will try to recreate the whole GL texture pages. +If many handcrafted images are to be added to the director, some performance can be achieved by calling +director.addImage(id,image,false) many times and a final call with +director.addImage(id,image,true) to finally command the director to create texture pages. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {string|object} an identitifier to retrieve the image with
    + +
    + image + +
    +
    {Image|HTMLCanvasElement} image to add to cache
    + +
    + noUpdateGL + +
    +
    {!boolean} unless otherwise stated, the director will + try to recreate the texture pages.
    + +
    + + + + + + + + +
    + + +
    + + + addScene(scene) + +
    +
    + Add a new Scene to Director's Scene list. By adding a Scene to the Director +does not mean it will be immediately visible, you should explicitly call either +
      +
    • easeIn +
    • easeInOut +
    • easeInOutRandom +
    • setScene +
    • or any of the scene switching methods +
    + + +
    + + + + +
    +
    Parameters:
    + +
    + scene + +
    +
    {CAAT.Foundation.Scene}
    + +
    + + + + + + + + +
    + + +
    + + + animate(director, time) + +
    +
    + A director is a very special kind of actor. +Its animation routine simple sets its modelViewMatrix in case some transformation's been +applied. +No behaviors are allowed for Director instances. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director} redundant reference to CAAT.Director itself
    + +
    + time + +
    +
    {number} director time.
    + +
    + + + + + + + + +
    + + +
    + + {HTMLElement|null} + audioLoop(id) + +
    +
    + Loops an audio instance identified by the id. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} the object used to store a sound in the audioCache.
    + +
    + + + + + +
    +
    Returns:
    + +
    {HTMLElement|null} the value from audioManager.loop
    + +
    + + + + +
    + + +
    + + + audioPlay(id) + +
    +
    + Plays the audio instance identified by the id. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} the object used to store a sound in the audioCache.
    + +
    + + + + + + + + +
    + + +
    + + + cancelPlay(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + cancelPlayByChannel(audioObject) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + audioObject + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + checkDebug() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + clean() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + createEventHandler() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {CAAT.Scene} + createScene() + +
    +
    + Creates an initializes a Scene object. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Scene}
    + +
    + + + + +
    + + +
    + + + createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    + +
    + duration + +
    +
    + +
    + callback_timeout + +
    +
    + +
    + callback_tick + +
    +
    + +
    + callback_cancel + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + cumulateOffset(node, parent, prop) + +
    +
    + Acculumate dom elements position to properly offset on-screen mouse/touch events. + + +
    + + + + +
    +
    Parameters:
    + +
    + node + +
    +
    + +
    + parent + +
    +
    + +
    + prop + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + deleteImage(id, noUpdateGL) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + noUpdateGL + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + easeEnd(scene, b_easeIn) + +
    +
    + Scene easing listener. Notifies scenes when they're about to be activated (set as current +director's scene). + + +
    + + + + +
    +
    Parameters:
    + +
    + scene + +
    +
    {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director.
    + +
    + b_easeIn + +
    +
    {boolean} scene enters or exits ?
    + +
    + + + + + + + + +
    + + +
    + + + easeIn(inSceneIndex, type, time, alpha, anchor, interpolator) + +
    +
    + This method changes Director's current Scene to the scene index indicated by +inSceneIndex parameter. The Scene running in the director won't be eased out. + + +
    + + + + +
    +
    Parameters:
    + +
    + inSceneIndex + +
    +
    integer indicating the new Scene to set as current.
    + +
    + type + +
    +
    integer indicating the type of transition to apply to bring the new current +Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, +CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION.
    + +
    + time + +
    +
    integer indicating how much time in milliseconds the Scene entrance will take.
    + +
    + alpha + +
    +
    boolean indicating whether alpha transparency fading will be applied to the +entereing Scene.
    + +
    + anchor + +
    +
    integer indicating the anchor to fix for Scene transition. It will be any of +CAAT.Actor.prototype.ANCHOR_* values.
    + +
    + interpolator + +
    +
    an CAAT.Interpolator object indicating the interpolation function to +apply.
    + +
    + + + + + + + +
    +
    See:
    + +
    + +
    + +
    + +
    + + +
    + + +
    + + + easeInOut(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) + +
    +
    + This method offers full control over the process of switching between any given two Scenes. +To apply this method, you must specify the type of transition to apply for each Scene and +the anchor to keep the Scene pinned at. +

    +The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype: +

      +
    • EASE_ROTATION +
    • EASE_SCALE +
    • EASE_TRANSLATION +
    + +

    +The anchor will be any of these values defined in CAAT.Foundation.Actor: +

      +
    • ANCHOR_CENTER +
    • ANCHOR_TOP +
    • ANCHOR_BOTTOM +
    • ANCHOR_LEFT +
    • ANCHOR_RIGHT +
    • ANCHOR_TOP_LEFT +
    • ANCHOR_TOP_RIGHT +
    • ANCHOR_BOTTOM_LEFT +
    • ANCHOR_BOTTOM_RIGHT +
    + +

    +In example, for an entering scene performing a EASE_SCALE transition, the anchor is the +point by which the scene will scaled. + + +

    + + + + +
    +
    Parameters:
    + +
    + inSceneIndex + +
    +
    integer indicating the Scene index to bring in to the Director.
    + +
    + typein + +
    +
    integer indicating the type of transition to apply to the bringing in Scene.
    + +
    + anchorin + +
    +
    integer indicating the anchor of the bringing in Scene.
    + +
    + outSceneIndex + +
    +
    integer indicating the Scene index to take away from the Director.
    + +
    + typeout + +
    +
    integer indicating the type of transition to apply to the taking away in Scene.
    + +
    + anchorout + +
    +
    integer indicating the anchor of the taking away Scene.
    + +
    + time + +
    +
    inteter indicating the time to perform the process of switchihg between Scene object +in milliseconds.
    + +
    + alpha + +
    +
    boolean boolean indicating whether alpha transparency fading will be applied to +the scenes.
    + +
    + interpolatorIn + +
    +
    CAAT.Behavior.Interpolator object to apply to entering scene.
    + +
    + interpolatorOut + +
    +
    CAAT.Behavior.Interpolator object to apply to exiting scene.
    + +
    + + + + + + + + +
    + + +
    + + + easeInOutRandom(inIndex, outIndex, time, alpha) + +
    +
    + This method will switch between two given Scene indexes (ie, take away scene number 2, +and bring in scene number 5). +

    +It will randomly choose for each Scene the type of transition to apply and the anchor +point of each transition type. +

    +It will also set for different kind of transitions the following interpolators: +

      +
    • EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +
    • EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +
    • EASE_TRANSLATION -> BounceOutInterpolator +
    + +

    +These are the default values, and could not be changed by now. +This method in final instance delegates the process to easeInOutMethod. + + +

    + + + + +
    +
    Parameters:
    + +
    + inIndex + +
    +
    integer indicating the entering scene index.
    + +
    + outIndex + +
    +
    integer indicating the exiting scene index.
    + +
    + time + +
    +
    integer indicating the time to take for the process of Scene in/out in milliseconds.
    + +
    + alpha + +
    +
    boolean indicating whether alpha transparency fading should be applied to transitions.
    + +
    + + + + + + + +
    +
    See:
    + +
    easeInOutMethod.
    + +
    + + +
    + + +
    + + + emptyScenes() + +
    +
    + Removes Director's scenes. + + +
    + + + + + + + + + + + +
    + + +
    + + + enableEvents(onElement) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + onElement + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + enableResizeEvents(mode, onResizeCallback) + +
    +
    + Enable window resize events and set redimension policy. A callback functio could be supplied +to be notified on a Director redimension event. This is necessary in the case you set a redim +policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their +children scenes are resized to fit the new area. But scenes content is not resized, and have +no option of knowing so uless an onResizeCallback function is supplied. + + +
    + + + + +
    +
    Parameters:
    + +
    + mode + +
    +
    {number} RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE.
    + +
    + onResizeCallback + +
    +
    {function(director{CAAT.Director}, width{integer}, height{integer})} a callback +to notify on canvas resize.
    + +
    + + + + + + + + +
    + + +
    + + + endLoop() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + endSound() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + findActorAtPosition(point) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.AudioManager} + getAudioManager() + +
    +
    + Get this Director's AudioManager instance. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.AudioManager} the AudioManager instance.
    + +
    + + + + +
    + + +
    + + {string} + getBrowserName() + +
    +
    + Return the running browser name. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {string} the browser name.
    + +
    + + + + +
    + + +
    + + {string} + getBrowserVersion() + +
    +
    + Return the running browser version. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {string} the browser version.
    + +
    + + + + +
    + + +
    + + + getCanvasCoord(point, e) + +
    +
    + Normalize input event coordinates to be related to (0,0) canvas position. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Math.Point} canvas coordinate.
    + +
    + e + +
    +
    {MouseEvent} a mouse event from an input event.
    + +
    + + + + + + + + +
    + + +
    + + + getCurrentScene() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {number} + getCurrentSceneIndex() + +
    +
    + Return the index of the current scene in the Director's scene list. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number} the current scene's index.
    + +
    + + + + +
    + + +
    + + + getImage(sId) + +
    +
    + Gets the resource with the specified resource name. +The Director holds a collection called imagesCache +where you can store a JSON of the form + [ { id: imageId, image: imageObject } ]. +This structure will be used as a resources cache. +There's a CAAT.Module.ImagePreloader class to preload resources and +generate this structure on loading finalization. + + +
    + + + + +
    +
    Parameters:
    + +
    + sId + +
    +
    {object} an String identifying a resource.
    + +
    + + + + + + + + +
    + + +
    + + {number} + getNumScenes() + +
    +
    + Get the number of scenes contained in the Director. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number} the number of scenes contained in the Director.
    + +
    + + + + +
    + + +
    + + + getOffset(node) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + node + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {string} + getOSName() + +
    +
    + Return the operating system name. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {string} the os name.
    + +
    + + + + +
    + + +
    + + + getRenderType() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {CAAT.Foundation.Scene} + getScene(index) + +
    +
    + Get a concrete director's scene. + + +
    + + + + +
    +
    Parameters:
    + +
    + index + +
    +
    {number} an integer indicating the scene index.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob.
    + +
    + + + + +
    + + +
    + + + getSceneById(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getSceneIndex(scene) + +
    +
    + Return the index for a given Scene object contained in the Director. + + +
    + + + + +
    +
    Parameters:
    + +
    + scene + +
    +
    {CAAT.Foundation.Scene}
    + +
    + + + + + + + + +
    + + +
    + + + getValueForKey(key) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + key + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + glFlush() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + glRender(vertex, coordsIndex, uv) + +
    +
    + Render buffered elements. + + +
    + + + + +
    +
    Parameters:
    + +
    + vertex + +
    +
    + +
    + coordsIndex + +
    +
    + +
    + uv + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + glReset() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + inDirtyRect() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + initialize(width, height, canvas, proxy) + +
    +
    + This method performs Director initialization. Must be called once. +If the canvas parameter is not set, it will create a Canvas itself, +and the developer must explicitly add the canvas to the desired DOM position. +This method will also set the Canvas dimension to the specified values +by width and height parameters. + + +
    + + + + +
    +
    Parameters:
    + +
    + width + +
    +
    {number} a canvas width
    + +
    + height + +
    +
    {number} a canvas height
    + +
    + canvas + +
    +
    {HTMLCanvasElement=} An optional Canvas object.
    + +
    + proxy + +
    +
    {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + and want events delivered to the correct element.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initializeGL(width, height, canvas, proxy) + +
    +
    + Experimental. +Initialize a gl enabled director. + + +
    + + + + +
    +
    Parameters:
    + +
    + width + +
    +
    + +
    + height + +
    +
    + +
    + canvas + +
    +
    + +
    + proxy + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isMusicEnabled() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isSoundEffectsEnabled() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + loop(fps, callback, callback2) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + fps + +
    +
    + +
    + callback + +
    +
    + +
    + callback2 + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseDown(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseDrag(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseEnter(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseExit(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseMove(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseUp(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + musicPlay(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + musicStop() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + render(time) + +
    +
    + This is the entry point for the animation system of the Director. +The director is fed with the elapsed time value to maintain a virtual timeline. +This virtual timeline will provide each Scene with its own virtual timeline, and will only +feed time when the Scene is the current Scene, or is being switched. + +If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be +set up as a single clip area. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} integer indicating the elapsed time between two consecutive frames of the +Director.
    + +
    + + + + + + + + +
    + + +
    + + + renderFrame() + +
    +
    + Starts the director animation.If no scene is explicitly selected, the current Scene will +be the first scene added to the Director. +

    +The fps parameter will set the animation quality. Higher values, +means CAAT will try to render more frames in the same second (at the +expense of cpu power at least until hardware accelerated canvas rendering +context are available). A value of 60 is a high frame rate and should not be exceeded. + + +

    + + + + + + + + + + + +
    + + +
    + + + renderToContext(ctx, scene) + +
    +
    + This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of +another Scene (transitionScene). So instead of drawing two scenes while transitioning from +one to another, first of all an scene is drawn to offscreen, and that image is translated. +

    +Until the creation of this method, both scenes where drawn while transitioning with +its performance penalty since drawing two scenes could be twice as expensive than drawing +only one. +

    +Though a high performance increase, we should keep an eye on memory consumption. + + +

    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    a canvas.getContext('2d') instnce.
    + +
    + scene + +
    +
    {CAAT.Foundation.Scene} the scene to draw offscreen.
    + +
    + + + + + + + + +
    + + +
    + + + requestRepaint() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + resetStats() + +
    +
    + Reset statistics information. + + +
    + + + + + + + + + + + +
    + + +
    + + + resetTimeline() + +
    +
    + If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement. + + +
    + + + + + + + + + + + +
    + + +
    + + + scheduleDirtyRect(rectangle) + +
    +
    + This method is used when asynchronous operations must produce some dirty rectangle painting. +This means that every operation out of the regular CAAT loop must add dirty rect operations +by calling this method. +For example setVisible() and remove. + + +
    + + + + +
    +
    Parameters:
    + +
    + rectangle + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAudioFormatExtensions(extensions) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + extensions + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + Set this director's bounds as well as its contained scenes. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} ignored, will be 0.
    + +
    + y + +
    +
    {number} ignored, will be 0.
    + +
    + w + +
    +
    {number} director width.
    + +
    + h + +
    +
    {number} director height.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setClear(clear) + +
    +
    + This method states whether the director must clear background before rendering +each frame. + +The clearing method could be: + + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. + + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled + will have their areas redrawn. + + CAAT.Director.CLEAR_NONE. clears nothing. + + +
    + + + + +
    +
    Parameters:
    + +
    + clear + +
    +
    {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS}
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + + setGLCurrentOpacity(opacity) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + opacity + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setGLTexturePage(tp) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + tp + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setImagesCache(imagesCache, tpW, tpH) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + imagesCache + +
    +
    + +
    + tpW + +
    +
    + +
    + tpH + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setMusicEnabled(enabled) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + enabled + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScaleProportional(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScene(sceneIndex) + +
    +
    + Changes (or sets) the current Director scene to the index +parameter. There will be no transition on scene change. + + +
    + + + + +
    +
    Parameters:
    + +
    + sceneIndex + +
    +
    {number} an integer indicating the index of the target Scene +to be shown.
    + +
    + + + + + + + + +
    + + +
    + + + setSoundEffectsEnabled(enabled) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + enabled + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setValueForKey(key, value) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + key + +
    +
    + +
    + value + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setVolume(id, volume) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + volume + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + switchToNextScene(time, alpha, transition) + +
    +
    + Sets the previous Scene in sequence as the current Scene. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} integer indicating the time the Scene transition will take.
    + +
    + alpha + +
    +
    {boolean} a boolean indicating whether Scene transition should be fading.
    + +
    + transition + +
    +
    {boolean} a boolean indicating whether the scene change must smoothly animated.
    + +
    + + + + + + + +
    +
    See:
    + +
    switchToScene.
    + +
    + + +
    + + +
    + + + switchToPrevScene(time, alpha, transition) + +
    +
    + Sets the previous Scene in sequence as the current Scene. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} integer indicating the time the Scene transition will take.
    + +
    + alpha + +
    +
    {boolean} a boolean indicating whether Scene transition should be fading.
    + +
    + transition + +
    +
    {boolean} a boolean indicating whether the scene change must smoothly animated.
    + +
    + + + + + + + +
    +
    See:
    + +
    switchToScene.
    + +
    + + +
    + + +
    + + + switchToScene(iNewSceneIndex, time, alpha, transition) + +
    +
    + This method will change the current Scene by the Scene indicated as parameter. +It will apply random values for anchor and transition type. + + +
    + + + + +
    +
    Parameters:
    + +
    + iNewSceneIndex + +
    +
    {number} an integer indicating the index of the new scene to run on the Director.
    + +
    + time + +
    +
    {number} an integer indicating the time the Scene transition will take.
    + +
    + alpha + +
    +
    {boolean} a boolean indicating whether Scene transition should be fading.
    + +
    + transition + +
    +
    {boolean} a boolean indicating whether the scene change must smoothly animated.
    + +
    + + + + + + + +
    +
    See:
    + +
    easeInOutRandom
    + +
    + + +
    + + +
    + + + updateGLPages() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + windowResized(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Scene.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Scene.html new file mode 100644 index 0000000..838c359 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Scene.html @@ -0,0 +1,2384 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Scene + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Scene +

    + + +

    + +
    Extends + CAAT.Foundation.ActorContainer.
    + + + + + +
    Defined in: Scene.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Foundation.Scene.EASE_ROTATION +
    +
    +
    <static>   +
    + CAAT.Foundation.Scene.EASE_SCALE +
    +
    +
    <static>   +
    + CAAT.Foundation.Scene.EASE_TRANSLATE +
    +
    +
    <private>   + +
    Behavior container used uniquely for Scene switching.
    +
    <private>   + +
    Array of container behaviour events observer.
    +
    <private>   +
    + easeIn +
    +
    When Scene switching, this boolean identifies whether the Scene is being brought in, or taken away.
    +
    <private>   +
    + paused +
    +
    is this scene paused ?
    +
    <private>   + +
    This scene´s timer manager.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.ActorContainer:
    activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      + +
    This method should be overriden in case the developer wants to do some special actions when +the scene has just been brought in.
    +
      +
    addActorToInputList(actor, index, position) +
    +
    Add an actor to a given inputList.
    +
      +
    addBehavior(behaviour) +
    +
    Overriden method to disallow default behavior.
    +
      +
    behaviorExpired(actor) +
    +
    Private.
    +
    <private>   +
    createAlphaBehaviour(time, isIn) +
    +
    Helper method to manage alpha transparency fading on Scene switch by the Director.
    +
      +
    createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel) +
    +
    +
      +
    easeRotation(time, alpha, anchor, interpolator, isIn) +
    +
    Called from CAAT.Director to use Rotations for taking away or bringing Scenes in.
    +
      +
    easeRotationIn(time, alpha, anchor, interpolator) +
    +
    Called from CAAT.Director to use Rotations for bringing in.
    +
      +
    easeRotationOut(time, alpha, anchor, interpolator) +
    +
    Called from CAAT.Director to use Rotations for taking Scenes away.
    +
      +
    easeScale(time, alpha, anchor, interpolator, starttime, isIn) +
    +
    Called from CAAT.Foundation.Director to bring in ot take away an Scene.
    +
      +
    easeScaleIn(time, alpha, anchor, interpolator, starttime) +
    +
    Called from CAAT.Foundation.Director to bring in a Scene.
    +
      +
    easeScaleOut(time, alpha, anchor, interpolator, starttime) +
    +
    Called from CAAT.Foundation.Director to take away a Scene.
    +
      +
    easeTranslation(time, alpha, anchor, isIn, interpolator) +
    +
    This method will setup Scene behaviours to switch an Scene via a translation.
    +
      +
    easeTranslationIn(time, alpha, anchor, interpolator) +
    +
    Called from CAAT.Director to bring in an Scene.
    +
      +
    easeTranslationOut(time, alpha, anchor, interpolator) +
    +
    Called from CAAT.Director to bring in an Scene.
    +
      +
    emptyInputList(index) +
    +
    Remove all elements from an input list.
    +
      + +
    Enable a number of input lists.
    +
      + +
    Find a pointed actor at position point.
    +
      +
    getIn(out_scene) +
    +
    +
      +
    goOut(in_scene) +
    +
    +
      + +
    +
      +
    paint(director, time) +
    +
    An scene by default does not paint anything because has not fillStyle set.
    +
      +
    removeActorFromInputList(actor, index) +
    +
    remove an actor from a given input list index.
    +
      +
    setEaseListener(listener) +
    +
    Registers a listener for listen for transitions events.
    +
      +
    setExpired(bExpired) +
    +
    Scenes, do not expire the same way Actors do.
    +
      +
    setPaused(paused) +
    +
    +
      +
    setTimeout(duration, callback_timeout, callback_tick, callback_cancel) +
    +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.ActorContainer:
    __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setBounds, setLayout, setZOrder
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, emptyBehaviorList, enableDrag, enableEvents, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Scene() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Foundation.Scene.EASE_ROTATION + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Scene.EASE_SCALE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.Scene.EASE_TRANSLATE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <private> + + + easeContainerBehaviour + +
    +
    + Behavior container used uniquely for Scene switching. + + +
    + + + + + + + + +
    + + +
    <private> + + + easeContainerBehaviourListener + +
    +
    + Array of container behaviour events observer. + + +
    + + + + + + + + +
    + + +
    <private> + + + easeIn + +
    +
    + When Scene switching, this boolean identifies whether the Scene is being brought in, or taken away. + + +
    + + + + + + + + +
    + + +
    <private> + + + paused + +
    +
    + is this scene paused ? + + +
    + + + + + + + + +
    + + +
    <private> + + + timerManager + +
    +
    + This scene´s timer manager. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + activated() + +
    +
    + This method should be overriden in case the developer wants to do some special actions when +the scene has just been brought in. + + +
    + + + + + + + + + + + +
    + + +
    + + + addActorToInputList(actor, index, position) + +
    +
    + Add an actor to a given inputList. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    an actor instance
    + +
    + index + +
    +
    the inputList index to add the actor to. This value will be clamped to the number of +available lists.
    + +
    + position + +
    +
    the position on the selected inputList to add the actor at. This value will be +clamped to the number of available lists.
    + +
    + + + + + + + + +
    + + +
    + + + addBehavior(behaviour) + +
    +
    + Overriden method to disallow default behavior. +Do not use directly. + + +
    + + + + +
    +
    Parameters:
    + +
    + behaviour + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + behaviorExpired(actor) + +
    +
    + Private. +listener for the Scene's easeContainerBehaviour. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + createAlphaBehaviour(time, isIn) + +
    +
    + Helper method to manage alpha transparency fading on Scene switch by the Director. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds then fading will taableIne.
    + +
    + isIn + +
    +
    {boolean} whether this Scene is being brought in.
    + +
    + + + + + + + + +
    + + +
    + + + createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    + +
    + duration + +
    +
    + +
    + callback_timeout + +
    +
    + +
    + callback_tick + +
    +
    + +
    + callback_cancel + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + easeRotation(time, alpha, anchor, interpolator, isIn) + +
    +
    + Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    integer indicating time in milliseconds for the Scene to be taken away or brought in.
    + +
    + alpha + +
    +
    boolean indicating whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    integer indicating the Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
    + +
    + isIn + +
    +
    boolean indicating whehter the Scene is brought in.
    + +
    + + + + + + + + +
    + + +
    + + + easeRotationIn(time, alpha, anchor, interpolator) + +
    +
    + Called from CAAT.Director to use Rotations for bringing in. +This method is a Helper for the method easeRotation. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    integer indicating time in milliseconds for the Scene to be brought in.
    + +
    + alpha + +
    +
    boolean indicating whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    integer indicating the Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
    + +
    + + + + + + + + +
    + + +
    + + + easeRotationOut(time, alpha, anchor, interpolator) + +
    +
    + Called from CAAT.Director to use Rotations for taking Scenes away. +This method is a Helper for the method easeRotation. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    integer indicating time in milliseconds for the Scene to be taken away.
    + +
    + alpha + +
    +
    boolean indicating whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    integer indicating the Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
    + +
    + + + + + + + + +
    + + +
    + + + easeScale(time, alpha, anchor, interpolator, starttime, isIn) + +
    +
    + Called from CAAT.Foundation.Director to bring in ot take away an Scene. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene to be brought in.
    + +
    + alpha + +
    +
    {boolean} whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {number} Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + starttime + +
    +
    {number} scene time milliseconds from which the behavior will be applied.
    + +
    + isIn + +
    +
    boolean indicating whether the Scene is being brought in.
    + +
    + + + + + + + + +
    + + +
    + + + easeScaleIn(time, alpha, anchor, interpolator, starttime) + +
    +
    + Called from CAAT.Foundation.Director to bring in a Scene. +A helper method for easeScale. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene to be brought in.
    + +
    + alpha + +
    +
    {boolean} whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {number} Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + starttime + +
    +
    {number} scene time milliseconds from which the behavior will be applied.
    + +
    + + + + + + + + +
    + + +
    + + + easeScaleOut(time, alpha, anchor, interpolator, starttime) + +
    +
    + Called from CAAT.Foundation.Director to take away a Scene. +A helper method for easeScale. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene to be brought in.
    + +
    + alpha + +
    +
    {boolean} whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {number} Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + starttime + +
    +
    {number} scene time milliseconds from which the behavior will be applied.
    + +
    + + + + + + + + +
    + + +
    + + + easeTranslation(time, alpha, anchor, isIn, interpolator) + +
    +
    + This method will setup Scene behaviours to switch an Scene via a translation. +The anchor value can only be +
  • CAAT.Actor.ANCHOR_LEFT +
  • CAAT.Actor.ANCHOR_RIGHT +
  • CAAT.Actor.ANCHOR_TOP +
  • CAAT.Actor.ANCHOR_BOTTOM +if any other value is specified, any of the previous ones will be applied. + + + + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene.
    + +
    + alpha + +
    +
    {boolean} whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {numnber} Scene switch anchor.
    + +
    + isIn + +
    +
    {boolean} whether the scene will be brought in.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + + + + + + + + +
    + + +
    + + + easeTranslationIn(time, alpha, anchor, interpolator) + +
    +
    + Called from CAAT.Director to bring in an Scene. +A helper method for easeTranslation. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene to be brought in.
    + +
    + alpha + +
    +
    {boolean} whether fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {number} Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + + + + + + + + +
    + + +
    + + + easeTranslationOut(time, alpha, anchor, interpolator) + +
    +
    + Called from CAAT.Director to bring in an Scene. +A helper method for easeTranslation. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} time in milliseconds for the Scene to be taken away.
    + +
    + alpha + +
    +
    {boolean} fading will be applied to the Scene.
    + +
    + anchor + +
    +
    {number} Scene switch anchor.
    + +
    + interpolator + +
    +
    {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
    + +
    + + + + + + + + +
    + + +
    + + + emptyInputList(index) + +
    +
    + Remove all elements from an input list. + + +
    + + + + +
    +
    Parameters:
    + +
    + index + +
    +
    the inputList index to add the actor to. This value will be clamped to the number of +available lists so take care when emptying a non existant inputList index since you could end up emptying +an undesired input list.
    + +
    + + + + + + + + +
    + + +
    + + + enableInputList(size) + +
    +
    + Enable a number of input lists. +These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed +actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance. +The system will traverse the whole lists in order trying to find a pointed actor. + +Elements are added to each list either in head or tail. + + +
    + + + + +
    +
    Parameters:
    + +
    + size + +
    +
    number of lists.
    + +
    + + + + + + + + +
    + + +
    + + + findActorAtPosition(point) + +
    +
    + Find a pointed actor at position point. +This method tries lo find the correctly pointed actor in two different ways. + + first of all, if inputList is defined, it will look for an actor in it. + + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getIn(out_scene) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + out_scene + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + goOut(in_scene) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + in_scene + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isPaused() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + An scene by default does not paint anything because has not fillStyle set. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + removeActorFromInputList(actor, index) + +
    +
    + remove an actor from a given input list index. +If no index is supplied, the actor will be removed from every input list. + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + index + +
    +
    an optional input list index. This value will be clamped to the number of +available lists.
    + +
    + + + + + + + + +
    + + +
    + + + setEaseListener(listener) + +
    +
    + Registers a listener for listen for transitions events. +Al least, the Director registers himself as Scene easing transition listener. +When the transition is done, it restores the Scene's capability of receiving events. + + +
    + + + + +
    +
    Parameters:
    + +
    + listener + +
    +
    {function(caat_behavior,time,actor)} an object which contains a method of the form +behaviorExpired( caat_behaviour, time, actor);
    + +
    + + + + + + + + +
    + + +
    + + + setExpired(bExpired) + +
    +
    + Scenes, do not expire the same way Actors do. +It simply will be set expired=true, but the frameTime won't be modified. + + +
    + + + + +
    +
    Parameters:
    + +
    + bExpired + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPaused(paused) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + paused + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTimeout(duration, callback_timeout, callback_tick, callback_cancel) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + duration + +
    +
    + +
    + callback_timeout + +
    +
    + +
    + callback_tick + +
    +
    + +
    + callback_cancel + +
    +
    + +
    + + + + + + + + + + + + + + + +
    + + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImage.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImage.html new file mode 100644 index 0000000..31cf4d2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImage.html @@ -0,0 +1,4134 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.SpriteImage + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.SpriteImage +

    + + +

    + + + + + + +
    Defined in: SpriteImage.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    an Array defining the sprite frame sequence
    +
      + +
    This property allows to have multiple different animations defined for one actor.
    +
      +
    + callback +
    +
    When an animation sequence ends, this callback function will be called.
    +
      +
    + changeFPS +
    +
    how much Scene time to take before changing an Sprite frame.
    +
      +
    + columns +
    +
    Number of columns.
    +
      + +
    current animation name
    +
      +
    + fontScale +
    +
    pending: refactor -> font scale to a font object.
    +
      +
    + height +
    +
    This sprite image image´s width
    +
      +
    + image +
    +
    Image to get frames from.
    +
      +
    + map +
    +
    If the sprite image is defined out of a JSON object (sprite packer for example), this is +the subimages original definition map.
    +
      +
    + mapInfo +
    +
    If the sprite image is defined out of a JSON object (sprite packer for example), this is +the subimages calculated definition map.
    +
      +
    + offsetX +
    +
    Displacement offset to get the sub image from.
    +
      +
    + offsetY +
    +
    Displacement offset to get the sub image from.
    +
      + +
    The actor this sprite image belongs to.
    +
      + +
    When nesting sprite images, this value is the star X position of this sprite image in the parent.
    +
      + +
    When nesting sprite images, this value is the star Y position of this sprite image in the parent.
    +
      + +
    Previous animation frame time.
    +
      +
    + prevIndex +
    +
    current index of sprite frames array.
    +
      +
    + rows +
    +
    Number of rows
    +
      + +
    For each element in the sprite image array, its height.
    +
      + +
    For each element in the sprite image array, its size.
    +
      + +
    the current sprite frame
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_FIXED_WIDTH_TO_SIZE +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_FLIP_ALL +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_FLIP_VERTICAL +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_NONE +
    +
    +
    <static>   +
    + CAAT.Foundation.SpriteImage.TR_TILE +
    +
    +
      + +
    any of the TR_* constants.
    +
      +
    + width +
    +
    This sprite image image´s width
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    addAnimation(name, array, time, callback) +
    +
    Add an animation to this sprite image.
    +
      +
    addElement(key, value) +
    +
    Add one element to the spriteImage.
    +
      + +
    Create elements as director.getImage values.
    +
      +
    copy(other) +
    +
    +
      +
    drawText(str, ctx, x, y) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    getMapInfo(index) +
    +
    +
      + +
    Get the number of subimages in this compoundImage
    +
      + +
    +
      +
    getRef() +
    +
    Get a reference to the same image information (rows, columns, image and uv cache) of this +SpriteImage.
    +
      +
    getRows() +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    initialize(image, rows, columns) +
    +
    Initialize a grid of subimages out of a given image.
    +
      +
    initializeAsFontMap(image, chars) +
    +
    +
      + +
    +
      + +
    This method creates a font sprite image based on a proportional font +It assumes the font is evenly spaced in the image +Example: +var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( + director.getImage('numbers'), + "0123456789" +);
    +
      + +
    +
      +
    initializeFromMap(image, map) +
    +
    This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html +and creates a map into that image.
    +
      + +
    +
      +
    paintAtRect(director, time, x, y, w, h) +
    +
    +
      +
    paintChunk(ctx, dx, dy, x, y, w, h) +
    +
    +
      +
    paintInvertedH(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex horizontally inverted.
    +
      +
    paintInvertedHV(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex both horizontal and vertically inverted.
    +
      +
    paintInvertedV(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex vertically inverted.
    +
      +
    paintN(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex.
    +
      +
    paintScaled(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex scaled to the size of w and h.
    +
      +
    paintScaledWidth(director, time, x, y) +
    +
    Draws the subimage pointed by imageIndex.
    +
      +
    paintTile(ctx, index, x, y) +
    +
    +
      +
    paintTiled(director, time, x, y) +
    +
    Must be used to draw actor background and the actor should have setClip(true) so that the image tiles +properly.
    +
      +
    playAnimation(name) +
    +
    Start playing a SpriteImage animation.
    +
      + +
    +
      + +
    +
      +
    setAnimationImageIndex(aAnimationImageIndex) +
    +
    Set the sprite animation images index.
    +
      +
    setChangeFPS(fps) +
    +
    Set the elapsed time needed to change the image index.
    +
      +
    setOffset(x, y) +
    +
    +
      + +
    Set horizontal displacement to draw image.
    +
      + +
    Set vertical displacement to draw image.
    +
      +
    setOwner(actor) +
    +
    +
      +
    setSpriteIndex(index) +
    +
    +
      + +
    Draws the sprite image calculated and stored in spriteIndex.
    +
      +
    setSpriteTransformation(transformation) +
    +
    Set the transformation to apply to the Sprite image.
    +
      +
    setUV(uvBuffer, uvIndex) +
    +
    +
      + +
    +
      +
    stringWidth(str) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.SpriteImage() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + animationImageIndex + +
    +
    + an Array defining the sprite frame sequence + + +
    + + + + + + + + +
    + + +
    + + + animationsMap + +
    +
    + This property allows to have multiple different animations defined for one actor. +see demo31 for a sample. + + +
    + + + + + + + + +
    + + +
    + + + callback + +
    +
    + When an animation sequence ends, this callback function will be called. + + +
    + + + + + + + + +
    + + +
    + + + changeFPS + +
    +
    + how much Scene time to take before changing an Sprite frame. + + +
    + + + + + + + + +
    + + +
    + + + columns + +
    +
    + Number of columns. + + +
    + + + + + + + + +
    + + +
    + + + currentAnimation + +
    +
    + current animation name + + +
    + + + + + + + + +
    + + +
    + + + fontScale + +
    +
    + pending: refactor -> font scale to a font object. + + +
    + + + + + + + + +
    + + +
    + + + height + +
    +
    + This sprite image image´s width + + +
    + + + + + + + + +
    + + +
    + + + image + +
    +
    + Image to get frames from. + + +
    + + + + + + + + +
    + + +
    + + + map + +
    +
    + If the sprite image is defined out of a JSON object (sprite packer for example), this is +the subimages original definition map. + + +
    + + + + + + + + +
    + + +
    + + + mapInfo + +
    +
    + If the sprite image is defined out of a JSON object (sprite packer for example), this is +the subimages calculated definition map. + + +
    + + + + + + + + +
    + + +
    + + + offsetX + +
    +
    + Displacement offset to get the sub image from. Useful to make images shift. + + +
    + + + + + + + + +
    + + +
    + + + offsetY + +
    +
    + Displacement offset to get the sub image from. Useful to make images shift. + + +
    + + + + + + + + +
    + + +
    + + + ownerActor + +
    +
    + The actor this sprite image belongs to. + + +
    + + + + + + + + +
    + + +
    + + + parentOffsetX + +
    +
    + When nesting sprite images, this value is the star X position of this sprite image in the parent. + + +
    + + + + + + + + +
    + + +
    + + + parentOffsetY + +
    +
    + When nesting sprite images, this value is the star Y position of this sprite image in the parent. + + +
    + + + + + + + + +
    + + +
    + + + prevAnimationTime + +
    +
    + Previous animation frame time. + + +
    + + + + + + + + +
    + + +
    + + + prevIndex + +
    +
    + current index of sprite frames array. + + +
    + + + + + + + + +
    + + +
    + + + rows + +
    +
    + Number of rows + + +
    + + + + + + + + +
    + + +
    + + + singleHeight + +
    +
    + For each element in the sprite image array, its height. + + +
    + + + + + + + + +
    + + +
    + + + singleWidth + +
    +
    + For each element in the sprite image array, its size. + + +
    + + + + + + + + +
    + + +
    + + + spriteIndex + +
    +
    + the current sprite frame + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_FIXED_WIDTH_TO_SIZE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_FLIP_ALL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_FLIP_VERTICAL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_NONE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.SpriteImage.TR_TILE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + transformation + +
    +
    + any of the TR_* constants. + + +
    + + + + + + + + +
    + + +
    + + + width + +
    +
    + This sprite image image´s width + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addAnimation(name, array, time, callback) + +
    +
    + Add an animation to this sprite image. +An animation is defines by an array of pretend-to-be-played sprite sequence. + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    {string} animation name.
    + +
    + array + +
    +
    {Array} the sprite animation sequence array. It can be defined + as number array for Grid-like sprite images or strings for a map-like sprite + image.
    + +
    + time + +
    +
    {number} change animation sequence every 'time' ms.
    + +
    + callback + +
    +
    {function({SpriteImage},{string}} a callback function to invoke when the sprite + animation sequence has ended.
    + +
    + + + + + + + + +
    + + +
    + + {*} + addElement(key, value) + +
    +
    + Add one element to the spriteImage. + + +
    + + + + +
    +
    Parameters:
    + +
    + key + +
    +
    {string|number} index or sprite identifier.
    + +
    + value + +
    +
    object{ + x: {number}, + y: {number}, + width: {number}, + height: {number}, + xoffset: {number=}, + yoffset: {number=}, + xadvance: {number=} + }
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + addElementsAsImages(prefix) + +
    +
    + Create elements as director.getImage values. +Create as much as elements defined in this sprite image. +The elements will be named prefix+ + + +
    + + + + +
    +
    Parameters:
    + +
    + prefix + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + copy(other) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + other + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + drawText(str, ctx, x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + str + +
    +
    + +
    + ctx + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getColumns() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getCurrentSpriteImageCSSPosition() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getFontData() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getHeight() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getMapInfo(index) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + index + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {number} + getNumImages() + +
    +
    + Get the number of subimages in this compoundImage + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + + getOwnerActor() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getRef() + +
    +
    + Get a reference to the same image information (rows, columns, image and uv cache) of this +SpriteImage. This means that re-initializing this objects image info (that is, calling initialize +method) will change all reference's image information at the same time. + + +
    + + + + + + + + + + + +
    + + +
    + + + getRows() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getWidth() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getWrappedImageHeight() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getWrappedImageWidth() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + initialize(image, rows, columns) + +
    +
    + Initialize a grid of subimages out of a given image. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {HTMLImageElement|Image} an image object.
    + +
    + rows + +
    +
    {number} number of rows.
    + +
    + columns + +
    +
    {number} number of columns
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initializeAsFontMap(image, chars) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + chars + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initializeAsGlyphDesigner(image, map) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {Image|HTMLImageElement|Canvas}
    + +
    + map + +
    +
    object with pairs "" : { + id : {number}, + height : {number}, + xoffset : {number}, + letter : {string}, + yoffset : {number}, + width : {number}, + xadvance: {number}, + y : {number}, + x : {number} + }
    + +
    + + + + + + + + +
    + +
    +
    + + + initializeAsMonoTypeFontMap(image, chars) + +
    +
    + This method creates a font sprite image based on a proportional font +It assumes the font is evenly spaced in the image +Example: +var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( + director.getImage('numbers'), + "0123456789" +); + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + chars + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initializeFromGlyphDesigner(text) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + text + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initializeFromMap(image, map) + +
    +
    + This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html +and creates a map into that image. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {Image|HTMLImageElement|Canvas} an image
    + +
    + map + +
    +
    {object} the map into the image to define subimages.
    + +
    + + + + + + + + +
    + + +
    + + + initializeFromTexturePackerJSON(image, obj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paintAtRect(director, time, x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paintChunk(ctx, dx, dy, x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + dx + +
    +
    + +
    + dy + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paintInvertedH(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex horizontally inverted. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintInvertedHV(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex both horizontal and vertically inverted. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintInvertedV(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex vertically inverted. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintN(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintScaled(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex scaled to the size of w and h. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintScaledWidth(director, time, x, y) + +
    +
    + Draws the subimage pointed by imageIndex. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + x + +
    +
    {number} x position in canvas to draw the image.
    + +
    + y + +
    +
    {number} y position in canvas to draw the image.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paintTile(ctx, index, x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + index + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paintTiled(director, time, x, y) + +
    +
    + Must be used to draw actor background and the actor should have setClip(true) so that the image tiles +properly. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + playAnimation(name) + +
    +
    + Start playing a SpriteImage animation. +If it does not exist, nothing happens. + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + resetAnimationTime() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setAnimationEndCallback(f) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + f + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAnimationImageIndex(aAnimationImageIndex) + +
    +
    + Set the sprite animation images index. This method accepts an array of objects which define indexes to +subimages inside this sprite image. +If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of +aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages +with size rows*columns. +If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected +to be an array of strings which are the names of the subobjects contained in the map object. + + +
    + + + + +
    +
    Parameters:
    + +
    + aAnimationImageIndex + +
    +
    an array indicating the Sprite's frames.
    + +
    + + + + + + + + +
    + + +
    + + + setChangeFPS(fps) + +
    +
    + Set the elapsed time needed to change the image index. + + +
    + + + + +
    +
    Parameters:
    + +
    + fps + +
    +
    an integer indicating the time in milliseconds to change.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setOffset(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setOffsetX(x) + +
    +
    + Set horizontal displacement to draw image. Positive values means drawing the image more to the +right. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setOffsetY(y) + +
    +
    + Set vertical displacement to draw image. Positive values means drawing the image more to the +bottom. + + +
    + + + + +
    +
    Parameters:
    + +
    + y + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setOwner(actor) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setSpriteIndex(index) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + index + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setSpriteIndexAtTime(time) + +
    +
    + Draws the sprite image calculated and stored in spriteIndex. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} Scene time when the bounding box is to be drawn.
    + +
    + + + + + + + + +
    + + +
    + + + setSpriteTransformation(transformation) + +
    +
    + Set the transformation to apply to the Sprite image. +Any value of +
  • TR_NONE +
  • TR_FLIP_HORIZONTAL +
  • TR_FLIP_VERTICAL +
  • TR_FLIP_ALL + + + + + + + +
    +
    Parameters:
    + +
    + transformation + +
    +
    an integer indicating one of the previous values.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setUV(uvBuffer, uvIndex) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + uvBuffer + +
    +
    + +
    + uvIndex + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + stringHeight() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + stringWidth(str) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + str + +
    +
    + +
    + + + + + + + + + + + + + + + +
    + + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageAnimationHelper.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageAnimationHelper.html new file mode 100644 index 0000000..a5ac63b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageAnimationHelper.html @@ -0,0 +1,744 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.SpriteImageAnimationHelper + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.SpriteImageAnimationHelper +

    + + +

    + + + + + + +
    Defined in: SpriteImageAnimationHelper.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    Define an animation frame sequence, name it and supply with a callback which be called when the +sequence ends playing.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + animation +
    +
    A sequence of integer values defining a frame animation.
    +
      + +
    Call this callback function when the sequence ends.
    +
      +
    + time +
    +
    Time between any two animation frames.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(animation, time, onEndPlayCallback) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.SpriteImageAnimationHelper() +
    + +
    + Define an animation frame sequence, name it and supply with a callback which be called when the +sequence ends playing. + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + animation + +
    +
    + A sequence of integer values defining a frame animation. +For example [1,2,3,4,3,2,3,4,3,2] +Array. + + +
    + + + + + + + + +
    + + +
    + + + onEndPlayCallback + +
    +
    + Call this callback function when the sequence ends. + + +
    + + + + + + + + +
    + + +
    + + + time + +
    +
    + Time between any two animation frames. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(animation, time, onEndPlayCallback) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + animation + +
    +
    + +
    + time + +
    +
    + +
    + onEndPlayCallback + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageHelper.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageHelper.html new file mode 100644 index 0000000..e5838e0 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.SpriteImageHelper.html @@ -0,0 +1,702 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.SpriteImageHelper + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.SpriteImageHelper +

    + + +

    + + + + + + +
    Defined in: SpriteImageHelper.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    Define a drawable sub-image inside a bigger image as an independant drawable item.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(x, y, w, h, iw, ih) +
    +
    +
      +
    setGL(u, v, u1, v1) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.SpriteImageHelper() +
    + +
    + Define a drawable sub-image inside a bigger image as an independant drawable item. + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(x, y, w, h, iw, ih) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + iw + +
    +
    + +
    + ih + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setGL(u, v, u1, v1) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + u + +
    +
    + +
    + v + +
    +
    + +
    + u1 + +
    +
    + +
    + v1 + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerManager.html new file mode 100644 index 0000000..56babdf --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerManager.html @@ -0,0 +1,953 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Timer.TimerManager + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Timer.TimerManager +

    + + +

    + + + + + + +
    Defined in: TimerManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   +
    + timerList +
    +
    Collection of registered timers.
    +
    <private>   + +
    Index sequence to idenfity registered timers.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    checkTimers(time) +
    +
    Check and apply timers in frame time.
    +
      +
    createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) +
    +
    Creates a timer task.
    +
      +
    ensureTimerTask(timertask) +
    +
    Make sure the timertask is contained in the timer task list by adding it to the list in case it +is not contained.
    +
      +
    hasTimer(timertask) +
    +
    Check whether the timertask is in this scene's timer task list.
    +
      + +
    Removes expired timers.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Timer.TimerManager() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + timerList + +
    +
    + Collection of registered timers. + + +
    + + + + + + + + +
    + + +
    <private> + + + timerSequence + +
    +
    + Index sequence to idenfity registered timers. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + checkTimers(time) + +
    +
    + Check and apply timers in frame time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} the current Scene time.
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.TimerTask} + createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) + +
    +
    + Creates a timer task. Timertask object live and are related to scene's time, so when an Scene +is taken out of the Director the timer task is paused, and resumed on Scene restoration. + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    {number} an integer indicating the scene time this task must start executing at.
    + +
    + duration + +
    +
    {number} an integer indicating the timerTask duration.
    + +
    + callback_timeout + +
    +
    {function} timer on timeout callback function.
    + +
    + callback_tick + +
    +
    {function} timer on tick callback function.
    + +
    + callback_cancel + +
    +
    {function} timer on cancel callback function.
    + +
    + scene + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.TimerTask} a CAAT.TimerTask class instance.
    + +
    + + + + +
    + + +
    + + + ensureTimerTask(timertask) + +
    +
    + Make sure the timertask is contained in the timer task list by adding it to the list in case it +is not contained. + + +
    + + + + +
    +
    Parameters:
    + +
    + timertask + +
    +
    {CAAT.Foundation.Timer.TimerTask}.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {boolean} + hasTimer(timertask) + +
    +
    + Check whether the timertask is in this scene's timer task list. + + +
    + + + + +
    +
    Parameters:
    + +
    + timertask + +
    +
    {CAAT.Foundation.Timer.TimerTask}.
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean} a boolean indicating whether the timertask is in this scene or not.
    + +
    + + + + +
    + + +
    + + + removeExpiredTimers() + +
    +
    + Removes expired timers. This method must not be called directly. + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerTask.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerTask.html new file mode 100644 index 0000000..26095a9 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.TimerTask.html @@ -0,0 +1,1178 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Timer.TimerTask + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.Timer.TimerTask +

    + + +

    + + + + + + +
    Defined in: TimerTask.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    This callback will be called when the timer is cancelled.
    +
      + +
    This callback will be called whenever the timer is checked in time.
    +
      + +
    This callback will be called only once, when the timer expires.
    +
      +
    + duration +
    +
    Timer duration.
    +
      +
    + owner +
    +
    What TimerManager instance owns this task.
    +
      +
    + remove +
    +
    Remove this timer task on expiration/cancellation ?
    +
      +
    + scene +
    +
    Scene or director instance that owns this TimerTask owner.
    +
      +
    + startTime +
    +
    Timer start time.
    +
      +
    + taskId +
    +
    An arbitrry id.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    addTime(time) +
    +
    +
      +
    cancel() +
    +
    Cancels this timer by removing it on scene's next frame.
    +
      +
    checkTask(time) +
    +
    Performs TimerTask operation.
    +
      +
    create(startTime, duration, callback_timeout, callback_tick, callback_cancel) +
    +
    Create a TimerTask.
    +
      + +
    +
      +
    reset(time) +
    +
    Reschedules this TimerTask by changing its startTime to current scene's time.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.Timer.TimerTask() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + callback_cancel + +
    +
    + This callback will be called when the timer is cancelled. + + +
    + + + + + + + + +
    + + +
    + + + callback_tick + +
    +
    + This callback will be called whenever the timer is checked in time. + + +
    + + + + + + + + +
    + + +
    + + + callback_timeout + +
    +
    + This callback will be called only once, when the timer expires. + + +
    + + + + + + + + +
    + + +
    + + + duration + +
    +
    + Timer duration. + + +
    + + + + + + + + +
    + + +
    + + + owner + +
    +
    + What TimerManager instance owns this task. + + +
    + + + + + + + + +
    + + +
    + + + remove + +
    +
    + Remove this timer task on expiration/cancellation ? + + +
    + + + + + + + + +
    + + +
    + + + scene + +
    +
    + Scene or director instance that owns this TimerTask owner. + + +
    + + + + + + + + +
    + + +
    + + + startTime + +
    +
    + Timer start time. Relative to Scene or Director time, depending who owns this TimerTask. + + +
    + + + + + + + + +
    + + +
    + + + taskId + +
    +
    + An arbitrry id. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + addTime(time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + cancel() + +
    +
    + Cancels this timer by removing it on scene's next frame. The function callback_cancel will +be called. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + checkTask(time) + +
    +
    + Performs TimerTask operation. The task will check whether it is in frame time, and will +either notify callback_timeout or callback_tick. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} an integer indicating scene time.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + create(startTime, duration, callback_timeout, callback_tick, callback_cancel) + +
    +
    + Create a TimerTask. +The taskId will be set by the scene. + + +
    + + + + +
    +
    Parameters:
    + +
    + startTime + +
    +
    {number} an integer indicating TimerTask enable time.
    + +
    + duration + +
    +
    {number} an integer indicating TimerTask duration.
    + +
    + callback_timeout + +
    +
    {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on timeout callback function.
    + +
    + callback_tick + +
    +
    {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on tick callback function.
    + +
    + callback_cancel + +
    +
    {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on cancel callback function.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + remainingTime() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + reset(time) + +
    +
    + Reschedules this TimerTask by changing its startTime to current scene's time. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    {number} an integer indicating scene time.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.html new file mode 100644 index 0000000..1085319 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.Timer.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.Timer + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation.Timer +

    + + +

    + + + + + + +
    Defined in: TimerManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation.Timer +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Dock.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Dock.html new file mode 100644 index 0000000..37ec6f2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Dock.html @@ -0,0 +1,1490 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Dock + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Dock +

    + + +

    + +
    Extends + CAAT.Foundation.ActorContainer.
    + + + + + +
    Defined in: Dock.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + layoutOp +
    +
    Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_*
    +
      +
    + maxSize +
    +
    max contained actor size
    +
      +
    + minSize +
    +
    min contained actor size.
    +
    <static>   +
    + CAAT.Foundation.UI.Dock.OP_LAYOUT_BOTTOM +
    +
    +
    <static>   +
    + CAAT.Foundation.UI.Dock.OP_LAYOUT_LEFT +
    +
    +
    <static>   +
    + CAAT.Foundation.UI.Dock.OP_LAYOUT_RIGHT +
    +
    +
    <static>   +
    + CAAT.Foundation.UI.Dock.OP_LAYOUT_TOP +
    +
    +
      +
    + range +
    +
    aproximated number of elements affected.
    +
      +
    + scene +
    +
    scene the actor is in.
    +
      +
    + ttask +
    +
    resetting dimension timer task.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.ActorContainer:
    activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    actorMouseEnter(mouseEvent) +
    +
    Perform the beginning of docking elements.
    +
    <private>   +
    actorMouseExit(mouseEvent) +
    +
    Perform the process of exiting the docking element, that is, animate elements to the minimum +size.
    +
    <private>   + +
    Performs operation when the mouse is not in the dock element.
    +
    <private>   +
    actorPointed(x, y, pointedActor) +
    +
    Perform the process of pointing a docking actor.
    +
      +
    addChild(actor) +
    +
    Adds an actor to Dock.
    +
      +
    initialize(scene) +
    +
    +
    <private>   +
    layout() +
    +
    Lay out the docking elements.
    +
      +
    mouseExit(mouseEvent) +
    +
    +
      +
    mouseMove(mouseEvent) +
    +
    +
      + +
    Set the number of elements that will be affected (zoomed) when the mouse is inside the component.
    +
      + +
    Set layout orientation.
    +
      +
    setSizes(min, max) +
    +
    Set maximum and minimum size of docked elements.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.ActorContainer:
    __init, __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setBounds, setLayout, setZOrder
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, emptyBehaviorList, enableDrag, enableEvents, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseOut, mouseOver, mouseUp, moveTo, paint, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Dock() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + layoutOp + +
    +
    + Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_* + + +
    + + + + + + + + +
    + + +
    + + + maxSize + +
    +
    + max contained actor size + + +
    + + + + + + + + +
    + + +
    + + + minSize + +
    +
    + min contained actor size. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.Dock.OP_LAYOUT_BOTTOM + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.Dock.OP_LAYOUT_LEFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.Dock.OP_LAYOUT_RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.Dock.OP_LAYOUT_TOP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + range + +
    +
    + aproximated number of elements affected. + + +
    + + + + + + + + +
    + + +
    + + + scene + +
    +
    + scene the actor is in. + + +
    + + + + + + + + +
    + + +
    + + + ttask + +
    +
    + resetting dimension timer task. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + actorMouseEnter(mouseEvent) + +
    +
    + Perform the beginning of docking elements. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.MouseEvent} a CAAT.MouseEvent object.
    + +
    + + + + + + + + +
    + + +
    <private> + + + actorMouseExit(mouseEvent) + +
    +
    + Perform the process of exiting the docking element, that is, animate elements to the minimum +size. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.MouseEvent} a CAAT.MouseEvent object.
    + +
    + + + + + + + + +
    + + +
    <private> + + + actorNotPointed() + +
    +
    + Performs operation when the mouse is not in the dock element. + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + actorPointed(x, y, pointedActor) + +
    +
    + Perform the process of pointing a docking actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + pointedActor + +
    +
    {CAAT.Actor}
    + +
    + + + + + + + + +
    + + +
    + + + addChild(actor) + +
    +
    + Adds an actor to Dock. +

    +Be aware that actor mouse functions must be set prior to calling this method. The Dock actor +needs set his own actor input events functions for mouseEnter, mouseExit and mouseMove and +will then chain to the original methods set by the developer. + + +

    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    {CAAT.Actor} a CAAT.Actor instance.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initialize(scene) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scene + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + layout() + +
    +
    + Lay out the docking elements. The lay out will be a row with the orientation set by calling +the method setLayoutOp. + + +
    + + + + + + + + + + + +
    + + +
    + + + mouseExit(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseMove(mouseEvent) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setApplicationRange(range) + +
    +
    + Set the number of elements that will be affected (zoomed) when the mouse is inside the component. + + +
    + + + + +
    +
    Parameters:
    + +
    + range + +
    +
    {number} a number. Defaults to 2.
    + +
    + + + + + + + + +
    + + +
    + + + setLayoutOp(lo) + +
    +
    + Set layout orientation. Choose from +
      +
    • CAAT.Dock.OP_LAYOUT_BOTTOM +
    • CAAT.Dock.OP_LAYOUT_TOP +
    • CAAT.Dock.OP_LAYOUT_BOTTOM +
    • CAAT.Dock.OP_LAYOUT_RIGHT +
    +By default, the layou operation is OP_LAYOUT_BOTTOM, that is, elements zoom bottom anchored. + + +
    + + + + +
    +
    Parameters:
    + +
    + lo + +
    +
    {number} one of CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_TOP, +CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_RIGHT.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setSizes(min, max) + +
    +
    + Set maximum and minimum size of docked elements. By default, every contained actor will be +of 'min' size, and will be scaled up to 'max' size. + + +
    + + + + +
    +
    Parameters:
    + +
    + min + +
    +
    {number}
    + +
    + max + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.IMActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.IMActor.html new file mode 100644 index 0000000..095a91d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.IMActor.html @@ -0,0 +1,834 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.IMActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.IMActor +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: IMActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    Calculate another image processing frame every this milliseconds.
    +
      + +
    Image processing interface.
    +
      + +
    Last scene time this actor calculated a frame.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    paint(director, time) +
    +
    +
      + +
    Call image processor to update image every time milliseconds.
    +
      + +
    Set the image processor.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __init, __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, animate, cacheAsBitmap, centerAt, centerOn, clean, contains, create, destroy, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.IMActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + changeTime + +
    +
    + Calculate another image processing frame every this milliseconds. + + +
    + + + + + + + + +
    + + +
    + + + imageProcessor + +
    +
    + Image processing interface. + + +
    + + + + + + + + +
    + + +
    + + + lastApplicationTime + +
    +
    + Last scene time this actor calculated a frame. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + paint(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setImageProcessingTime(time) + +
    +
    + Call image processor to update image every time milliseconds. + + +
    + + + + +
    +
    Parameters:
    + +
    + time + +
    +
    an integer indicating milliseconds to elapse before updating the frame.
    + +
    + + + + + + + + +
    + + +
    + + + setImageProcessor(im) + +
    +
    + Set the image processor. + + +
    + + + + +
    +
    Parameters:
    + +
    + im + +
    +
    {CAAT.ImageProcessor} a CAAT.ImageProcessor instance.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.InterpolatorActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.InterpolatorActor.html new file mode 100644 index 0000000..1caf5b4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.InterpolatorActor.html @@ -0,0 +1,928 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.InterpolatorActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.InterpolatorActor +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: InterpolatorActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + contour +
    +
    This interpolator´s contour.
    +
      +
    + gap +
    +
    padding when drawing the interpolator.
    +
      + +
    The interpolator instance to draw.
    +
      +
    + S +
    +
    Number of samples to calculate a contour.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      + +
    Return the represented interpolator.
    +
      +
    paint(director, time) +
    +
    Paint this actor.
    +
      +
    setGap(gap) +
    +
    Sets a padding border size.
    +
      +
    setInterpolator(interpolator, size) +
    +
    Sets the CAAT.Interpolator instance to draw.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __init, __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, animate, cacheAsBitmap, centerAt, centerOn, clean, contains, create, destroy, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.InterpolatorActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + contour + +
    +
    + This interpolator´s contour. + + +
    + + + + + + + + +
    + + +
    + + + gap + +
    +
    + padding when drawing the interpolator. + + +
    + + + + + + + + +
    + + +
    + + + interpolator + +
    +
    + The interpolator instance to draw. + + +
    + + + + + + + + +
    + + +
    + + + S + +
    +
    + Number of samples to calculate a contour. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + {CAAT.Interpolator} + getInterpolator() + +
    +
    + Return the represented interpolator. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Interpolator}
    + +
    + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + Paint this actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number} scene time.
    + +
    + + + + + + + + +
    + + +
    + + + setGap(gap) + +
    +
    + Sets a padding border size. By default is 5 pixels. + + +
    + + + + +
    +
    Parameters:
    + +
    + gap + +
    +
    {number} border size in pixels.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setInterpolator(interpolator, size) + +
    +
    + Sets the CAAT.Interpolator instance to draw. + + +
    + + + + +
    +
    Parameters:
    + +
    + interpolator + +
    +
    a CAAT.Interpolator instance.
    + +
    + size + +
    +
    an integer indicating the number of polyline segments so draw to show the CAAT.Interpolator +instance.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Label.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Label.html new file mode 100644 index 0000000..6d43a42 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Label.html @@ -0,0 +1,1861 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Label + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Label +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: Label.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   + +
    Registered callback to notify on anchor click event.
    +
    <private>   + +
    Calculated document Height.
    +
    <private>   + +
    Calculated document width.
    +
    <private>   +
    + documentX +
    +
    Document x position.
    +
    <private>   +
    + documentY +
    +
    Document y position.
    +
    <private>   + +
    This Label document´s horizontal alignment.
    +
    <private>   +
    + images +
    +
    Collection of image objects in this label´s document.
    +
    <private>   +
    + lines +
    +
    Collection of text lines calculated for the label.
    +
    <private>   +
    + rc +
    +
    This label document´s render context
    +
    <private>   +
    + reflow +
    +
    Does this label document flow ?
    +
    <private>   +
    + styles +
    +
    Styles object.
    +
    <private>   +
    + text +
    +
    This label text.
    +
    <private>   + +
    This Label document´s vertical alignment.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __calculateDocumentDimension(suggestedWidth) +
    +
    +
    <private>   + +
    +
    <private>   +
    __init() +
    +
    +
      +
    addImage(name, spriteImage) +
    +
    +
      + +
    +
      +
    mouseExit(e) +
    +
    +
      +
    mouseMove(e) +
    +
    +
      +
    paint(director, time) +
    +
    +
      +
    setBounds(x, y, w, h) +
    +
    +
      +
    setClickCallback(callback) +
    +
    +
      +
    setDocumentPosition(halign, valign) +
    +
    +
      + +
    +
      + +
    +
      + +
    Make the label actor the size the label document has been calculated for.
    +
      +
    setSize(w, h) +
    +
    +
      +
    setStyle(name, styleData) +
    +
    +
      +
    setText(_text, width) +
    +
    +
      + +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, animate, cacheAsBitmap, centerAt, centerOn, clean, contains, create, destroy, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseOut, mouseOver, mouseUp, moveTo, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Label() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + clickCallback + +
    +
    + Registered callback to notify on anchor click event. + + +
    + + + + + + + + +
    + + +
    <private> + + + documentHeight + +
    +
    + Calculated document Height. + + +
    + + + + + + + + +
    + + +
    <private> + + + documentWidth + +
    +
    + Calculated document width. + + +
    + + + + + + + + +
    + + +
    <private> + + + documentX + +
    +
    + Document x position. + + +
    + + + + + + + + +
    + + +
    <private> + + + documentY + +
    +
    + Document y position. + + +
    + + + + + + + + +
    + + +
    <private> + + + halignment + +
    +
    + This Label document´s horizontal alignment. + + +
    + + + + + + + + +
    + + +
    <private> + + + images + +
    +
    + Collection of image objects in this label´s document. + + +
    + + + + + + + + +
    + + +
    <private> + + + lines + +
    +
    + Collection of text lines calculated for the label. + + +
    + + + + + + + + +
    + + +
    <private> + + + rc + +
    +
    + This label document´s render context + + +
    + + + + + + + + +
    + + +
    <private> + + + reflow + +
    +
    + Does this label document flow ? + + +
    + + + + + + + + +
    + + +
    <private> + + + styles + +
    +
    + Styles object. + + +
    + + + + + + + + +
    + + +
    <private> + + + text + +
    +
    + This label text. + + +
    + + + + + + + + +
    + + +
    <private> + + + valignment + +
    +
    + This Label document´s vertical alignment. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __calculateDocumentDimension(suggestedWidth) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + suggestedWidth + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __getDocumentElementAt(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addImage(name, spriteImage) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + spriteImage + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseClick(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseExit(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + mouseMove(e) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + e + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setClickCallback(callback) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + callback + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setDocumentPosition(halign, valign) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + halign + +
    +
    + +
    + valign + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setHorizontalAlignment(align) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setLinesAlignment() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setMatchTextSize(match) + +
    +
    + Make the label actor the size the label document has been calculated for. + + +
    + + + + +
    +
    Parameters:
    + +
    + match + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    + + + setSize(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setStyle(name, styleData) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + name + +
    +
    + +
    + styleData + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setText(_text, width) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + _text + +
    +
    + +
    + width + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setVerticalAlignment(align) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BorderLayout.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BorderLayout.html new file mode 100644 index 0000000..288b324 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BorderLayout.html @@ -0,0 +1,1067 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Layout.BorderLayout + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Layout.BorderLayout +

    + + +

    + +
    Extends + CAAT.Foundation.UI.Layout.LayoutManager.
    + + + + + +
    Defined in: BorderLayout.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + bottom +
    +
    An actor to position botton.
    +
      +
    + center +
    +
    An actor to position center.
    +
      +
    + left +
    +
    An actor to position left.
    +
      +
    + right +
    +
    An actor to position right.
    +
      +
    + top +
    +
    An actor to position top.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    animated, hgap, invalid, moveElementInterpolator, newChildren, newElementInterpolator, padding, vgap
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __getChild(constraint) +
    +
    +
    <private>   +
    __init() +
    +
    +
      +
    addChild(child, constraint) +
    +
    +
      +
    doLayout(container) +
    +
    +
      +
    getMinimumLayoutSize(container) +
    +
    +
      + +
    +
      +
    removeChild(child) +
    +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    invalidateLayout, isInvalidated, isValid, setAllPadding, setAnimated, setHGap, setPadding, setVGap
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Layout.BorderLayout() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + bottom + +
    +
    + An actor to position botton. + + +
    + + + + + + + + +
    + + +
    + + + center + +
    +
    + An actor to position center. + + +
    + + + + + + + + +
    + + +
    + + + left + +
    +
    + An actor to position left. + + +
    + + + + + + + + +
    + + +
    + + + right + +
    +
    + An actor to position right. + + +
    + + + + + + + + +
    + + +
    + + + top + +
    +
    + An actor to position top. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __getChild(constraint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + constraint + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addChild(child, constraint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + constraint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayout(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getMinimumLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPreferredLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + removeChild(child) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BoxLayout.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BoxLayout.html new file mode 100644 index 0000000..acb4695 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.BoxLayout.html @@ -0,0 +1,1110 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Layout.BoxLayout + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Layout.BoxLayout +

    + + +

    + +
    Extends + CAAT.Foundation.UI.Layout.LayoutManager.
    + + + + + +
    Defined in: BoxLayout.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + axis +
    +
    Stack elements in this axis.
    +
      +
    + halign +
    +
    Horizontal alignment.
    +
      +
    + valign +
    +
    Vertical alignment.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    animated, hgap, invalid, moveElementInterpolator, newChildren, newElementInterpolator, padding, vgap
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __setActorPosition(actor, xoffset, yoffset) +
    +
    +
      +
    doLayout(container) +
    +
    +
      +
    doLayoutHorizontal(container) +
    +
    +
      +
    doLayoutVertical(container) +
    +
    +
      +
    getMinimumLayoutSize(container) +
    +
    +
      + +
    +
      +
    setAxis(axis) +
    +
    +
      + +
    +
      + +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    __init, addChild, invalidateLayout, isInvalidated, isValid, removeChild, setAllPadding, setAnimated, setHGap, setPadding, setVGap
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Layout.BoxLayout() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + axis + +
    +
    + Stack elements in this axis. + + +
    + + + + + + + + +
    + + +
    + + + halign + +
    +
    + Horizontal alignment. + + +
    + + + + + + + + +
    + + +
    + + + valign + +
    +
    + Vertical alignment. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __setActorPosition(actor, xoffset, yoffset) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + actor + +
    +
    + +
    + xoffset + +
    +
    + +
    + yoffset + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayout(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayoutHorizontal(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayoutVertical(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getMinimumLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPreferredLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAxis(axis) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + axis + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setHorizontalAlignment(align) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setVerticalAlignment(align) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.GridLayout.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.GridLayout.html new file mode 100644 index 0000000..2952e82 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.GridLayout.html @@ -0,0 +1,847 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Layout.GridLayout + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Layout.GridLayout +

    + + +

    + +
    Extends + CAAT.Foundation.UI.Layout.LayoutManager.
    + + + + + +
    Defined in: GridLayout.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + columns +
    +
    Layout elements using this number of columns.
    +
      +
    + rows +
    +
    Layout elements using this number of rows.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    animated, hgap, invalid, moveElementInterpolator, newChildren, newElementInterpolator, padding, vgap
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(rows, columns) +
    +
    +
      +
    doLayout(container) +
    +
    +
      +
    getMinimumLayoutSize(container) +
    +
    +
      + +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.UI.Layout.LayoutManager:
    addChild, invalidateLayout, isInvalidated, isValid, removeChild, setAllPadding, setAnimated, setHGap, setPadding, setVGap
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Layout.GridLayout() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + columns + +
    +
    + Layout elements using this number of columns. + + +
    + + + + + + + + +
    + + +
    + + + rows + +
    +
    + Layout elements using this number of rows. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(rows, columns) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rows + +
    +
    + +
    + columns + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayout(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getMinimumLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPreferredLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.LayoutManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.LayoutManager.html new file mode 100644 index 0000000..8ac5ad9 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.LayoutManager.html @@ -0,0 +1,1528 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Layout.LayoutManager + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.Layout.LayoutManager +

    + + +

    + + + + + + +
    Defined in: LayoutManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT +
    +
    +
      +
    + animated +
    +
    Animate on adding/removing elements.
    +
    <static>   +
    + CAAT.Foundation.UI.Layout.LayoutManager.AXIS +
    +
    +
      +
    + hgap +
    +
    Horizontal gap between children.
    +
      +
    + invalid +
    +
    Needs relayout ??
    +
      + +
    If animation enabled, relayout elements interpolator.
    +
      + +
    pending to be laid-out actors.
    +
      + +
    If animation enabled, new element interpolator.
    +
      +
    + padding +
    +
    Defines insets:
    +
      +
    + vgap +
    +
    Vertical gap between children.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    addChild(child, constraints) +
    +
    +
      +
    doLayout(container) +
    +
    +
      +
    getMinimumLayoutSize(container) +
    +
    +
      + +
    +
      +
    invalidateLayout(container) +
    +
    +
      + +
    +
      +
    isValid() +
    +
    +
      +
    removeChild(child) +
    +
    +
      + +
    +
      +
    setAnimated(animate) +
    +
    +
      +
    setHGap(gap) +
    +
    +
      +
    setPadding(l, r, t, b) +
    +
    +
      +
    setVGap(gap) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.Layout.LayoutManager() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + animated + +
    +
    + Animate on adding/removing elements. + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.Layout.LayoutManager.AXIS + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + hgap + +
    +
    + Horizontal gap between children. + + +
    + + + + + + + + +
    + + +
    + + + invalid + +
    +
    + Needs relayout ?? + + +
    + + + + + + + + +
    + + +
    + + + moveElementInterpolator + +
    +
    + If animation enabled, relayout elements interpolator. + + +
    + + + + + + + + +
    + + +
    + + + newChildren + +
    +
    + pending to be laid-out actors. + + +
    + + + + + + + + +
    + + +
    + + + newElementInterpolator + +
    +
    + If animation enabled, new element interpolator. + + +
    + + + + + + + + +
    + + +
    + + + padding + +
    +
    + Defines insets: + + +
    + + + + + + + + +
    + + +
    + + + vgap + +
    +
    + Vertical gap between children. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addChild(child, constraints) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + constraints + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + doLayout(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getMinimumLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getPreferredLayoutSize(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + invalidateLayout(container) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + container + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isInvalidated() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isValid() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + removeChild(child) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + child + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAllPadding(s) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + s + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAnimated(animate) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + animate + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setHGap(gap) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + gap + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPadding(l, r, t, b) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + l + +
    +
    + +
    + r + +
    +
    + +
    + t + +
    +
    + +
    + b + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setVGap(gap) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + gap + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.html new file mode 100644 index 0000000..1022a45 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.Layout.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.Layout + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation.UI.Layout +

    + + +

    + + + + + + +
    Defined in: LayoutManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation.UI.Layout +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.PathActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.PathActor.html new file mode 100644 index 0000000..06724ee --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.PathActor.html @@ -0,0 +1,1211 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.PathActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.PathActor +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: PathActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + bOutline +
    +
    draw the bounding rectangle too ?
    +
      + +
    Set this path as interactive.
    +
      + +
    If the path is interactive, some handlers are shown to modify the path.
    +
      + +
    Outline the path in this color.
    +
      +
    + path +
    +
    Path to draw.
    +
      + +
    Calculated path´s bounding box.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    getPath() +
    +
    Return the contained path.
    +
      +
    mouseDown(mouseEvent) +
    +
    Route mouse down functionality to the contained path.
    +
      +
    mouseDrag(mouseEvent) +
    +
    Route mouse dragging functionality to the contained path.
    +
      +
    mouseUp(mouseEvent) +
    +
    Route mouse up functionality to the contained path.
    +
      +
    paint(director, time) +
    +
    Paint this actor.
    +
      +
    setInteractive(interactive) +
    +
    Set the contained path as interactive.
    +
      + +
    +
      +
    setPath(path) +
    +
    Sets the path to manage.
    +
      +
    showBoundingBox(show, color) +
    +
    Enables/disables drawing of the contained path's bounding box.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __init, __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, animate, cacheAsBitmap, centerAt, centerOn, clean, contains, create, destroy, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, moveTo, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.PathActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + bOutline + +
    +
    + draw the bounding rectangle too ? + + +
    + + + + + + + + +
    + + +
    + + + interactive + +
    +
    + Set this path as interactive. + + +
    + + + + + + + + +
    + + +
    + + + onUpdateCallback + +
    +
    + If the path is interactive, some handlers are shown to modify the path. +This callback function will be called when the path is interactively changed. + + +
    + + + + + + + + +
    + + +
    + + + outlineColor + +
    +
    + Outline the path in this color. + + +
    + + + + + + + + +
    + + +
    + + + path + +
    +
    + Path to draw. + + +
    + + + + + + + + +
    + + +
    + + + pathBoundingRectangle + +
    +
    + Calculated path´s bounding box. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + {CAAT.Path} + getPath() + +
    +
    + Return the contained path. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Path}
    + +
    + + + + +
    + + +
    + + + mouseDown(mouseEvent) + +
    +
    + Route mouse down functionality to the contained path. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseDrag(mouseEvent) + +
    +
    + Route mouse dragging functionality to the contained path. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + mouseUp(mouseEvent) + +
    +
    + Route mouse up functionality to the contained path. + + +
    + + + + +
    +
    Parameters:
    + +
    + mouseEvent + +
    +
    {CAAT.Event.MouseEvent}
    + +
    + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + Paint this actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Foundation.Director}
    + +
    + time + +
    +
    {number}. Scene time.
    + +
    + + + + + + + + +
    + + +
    + + + setInteractive(interactive) + +
    +
    + Set the contained path as interactive. This means it can be changed on the fly by manipulation +of its control points. + + +
    + + + + +
    +
    Parameters:
    + +
    + interactive + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setOnUpdateCallback(fn) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + fn + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPath(path) + +
    +
    + Sets the path to manage. + + +
    + + + + +
    +
    Parameters:
    + +
    + path + +
    +
    {CAAT.PathUtil.PathSegment}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + showBoundingBox(show, color) + +
    +
    + Enables/disables drawing of the contained path's bounding box. + + +
    + + + + +
    +
    Parameters:
    + +
    + show + +
    +
    {boolean} whether to show the bounding box
    + +
    + color + +
    +
    {=string} optional parameter defining the path's bounding box stroke style.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.ShapeActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.ShapeActor.html new file mode 100644 index 0000000..294e9e3 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.ShapeActor.html @@ -0,0 +1,1465 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.ShapeActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.ShapeActor +

    + + +

    + +
    Extends + CAAT.Foundation.ActorContainer.
    + + + + + +
    Defined in: ShapeActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    Set this shape composite operation when drawing it.
    +
      +
    + lineCap +
    +
    Stroke the shape with this line cap.
    +
      +
    + lineJoin +
    +
    Stroke the shape with this line Join.
    +
      +
    + lineWidth +
    +
    Stroke the shape with this line width.
    +
      + +
    Stroke the shape with this line mitter limit.
    +
      +
    + shape +
    +
    Define this actor shape: rectangle or circle
    +
    <static>   +
    + CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE +
    +
    +
    <static>   +
    + CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE +
    +
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.ActorContainer:
    activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    paint(director, time) +
    +
    Draws the shape.
    +
    <private>   +
    paintCircle(director, time) +
    +
    +
      +
    paintRectangle(director, time) +
    +
    Private +Draws a Rectangle.
    +
      +
    setCompositeOp(compositeOp) +
    +
    Sets the composite operation to apply on shape drawing.
    +
      +
    setLineCap(lc) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    setShape(iShape) +
    +
    Sets shape type.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.ActorContainer:
    __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setBounds, setLayout, setZOrder
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, emptyBehaviorList, enableDrag, enableEvents, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.ShapeActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + compositeOp + +
    +
    + Set this shape composite operation when drawing it. + + +
    + + + + + + + + +
    + + +
    + + + lineCap + +
    +
    + Stroke the shape with this line cap. + + +
    + + + + + + + + +
    + + +
    + + + lineJoin + +
    +
    + Stroke the shape with this line Join. + + +
    + + + + + + + + +
    + + +
    + + + lineWidth + +
    +
    + Stroke the shape with this line width. + + +
    + + + + + + + + +
    + + +
    + + + miterLimit + +
    +
    + Stroke the shape with this line mitter limit. + + +
    + + + + + + + + +
    + + +
    + + + shape + +
    +
    + Define this actor shape: rectangle or circle + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE + +
    +
    + + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineCap() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineJoin() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineWidth() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getMiterLimit() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + Draws the shape. +Applies the values of fillStype, strokeStyle, compositeOp, etc. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    <private> + + + paintCircle(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + paintRectangle(director, time) + +
    +
    + Private +Draws a Rectangle. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + setCompositeOp(compositeOp) + +
    +
    + Sets the composite operation to apply on shape drawing. + + +
    + + + + +
    +
    Parameters:
    + +
    + compositeOp + +
    +
    an string with a valid canvas rendering context string describing compositeOps.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setLineCap(lc) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + lc + +
    +
    {string{butt|round|square}}
    + +
    + + + + + + + + +
    + + +
    + + + setLineJoin(lj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + lj + +
    +
    {string{bevel|round|miter}}
    + +
    + + + + + + + + +
    + + +
    + + + setLineWidth(l) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + l + +
    +
    {number>0}
    + +
    + + + + + + + + +
    + + +
    + + + setMiterLimit(ml) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ml + +
    +
    {integer>0}
    + +
    + + + + + + + + +
    + + +
    + + + setShape(iShape) + +
    +
    + Sets shape type. +No check for parameter validity is performed. +Set paint method according to the shape. + + +
    + + + + +
    +
    Parameters:
    + +
    + iShape + +
    +
    an integer with any of the SHAPE_* constants.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.StarActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.StarActor.html new file mode 100644 index 0000000..c058d21 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.StarActor.html @@ -0,0 +1,1539 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.StarActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.StarActor +

    + + +

    + +
    Extends + CAAT.Foundation.ActorContainer.
    + + + + + +
    Defined in: StarActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    Draw the star with this composite operation.
    +
      + +
    Staring angle in radians.
    +
      +
    + lineCap +
    +
    +
      +
    + lineJoin +
    +
    +
      +
    + lineWidth +
    +
    +
      +
    + maxRadius +
    +
    Maximum radius.
    +
      +
    + minRadius +
    +
    Minimum radius.
    +
      + +
    +
      +
    + nPeaks +
    +
    Number of star peaks.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.ActorContainer:
    activeChildren, addHint, boundingBox, childrenList, layoutInvalidated, layoutManager, pendingChildrenList, runion
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    initialize(nPeaks, maxRadius, minRadius) +
    +
    Initialize the star values.
    +
      +
    paint(director, timer) +
    +
    Paint the star.
    +
      +
    setCompositeOp(compositeOp) +
    +
    Sets the composite operation to apply on shape drawing.
    +
      +
    setFilled(filled) +
    +
    Sets whether the star will be color filled.
    +
      +
    setInitialAngle(angle) +
    +
    +
      +
    setLineCap(lc) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    setOutlined(outlined) +
    +
    Sets whether the star will be outlined.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.ActorContainer:
    __paintActor, __validateLayout, __validateTree, addActor, addActorImmediately, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getLayout, getNumActiveChildren, getNumChildren, invalidateLayout, paintActor, paintActorGL, recalcSize, removeChild, removeChildAt, removeFirstChild, removeLastChild, setBounds, setLayout, setZOrder
    Methods borrowed from class CAAT.Foundation.Actor:
    __scale1To, addAnimation, addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, clean, contains, create, disableDrag, emptyBehaviorList, enableDrag, enableEvents, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.StarActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + compositeOp + +
    +
    + Draw the star with this composite operation. + + +
    + + + + + + + + +
    + + +
    + + + initialAngle + +
    +
    + Staring angle in radians. + + +
    + + + + + + + + +
    + + +
    + + + lineCap + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + lineJoin + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + lineWidth + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + maxRadius + +
    +
    + Maximum radius. + + +
    + + + + + + + + +
    + + +
    + + + minRadius + +
    +
    + Minimum radius. + + +
    + + + + + + + + +
    + + +
    + + + miterLimit + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + nPeaks + +
    +
    + Number of star peaks. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineCap() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineJoin() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getLineWidth() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getMiterLimit() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + initialize(nPeaks, maxRadius, minRadius) + +
    +
    + Initialize the star values. +

    +The star actor will be of size 2*maxRadius. + + +

    + + + + +
    +
    Parameters:
    + +
    + nPeaks + +
    +
    {number} number of star points.
    + +
    + maxRadius + +
    +
    {number} maximum star radius
    + +
    + minRadius + +
    +
    {number} minimum star radius
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + paint(director, timer) + +
    +
    + Paint the star. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + timer + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setCompositeOp(compositeOp) + +
    +
    + Sets the composite operation to apply on shape drawing. + + +
    + + + + +
    +
    Parameters:
    + +
    + compositeOp + +
    +
    an string with a valid canvas rendering context string describing compositeOps.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setFilled(filled) + +
    +
    + Sets whether the star will be color filled. + + +
    + + + + +
    +
    Parameters:
    + +
    + filled + +
    +
    {boolean}
    + +
    + + + + + + + + +
    + + +
    + + + setInitialAngle(angle) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number} number in radians.
    + +
    + + + + + + + + +
    + + +
    + + + setLineCap(lc) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + lc + +
    +
    {string{butt|round|square}}
    + +
    + + + + + + + + +
    + + +
    + + + setLineJoin(lj) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + lj + +
    +
    {string{bevel|round|miter}}
    + +
    + + + + + + + + +
    + + +
    + + + setLineWidth(l) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + l + +
    +
    {number>0}
    + +
    + + + + + + + + +
    + + +
    + + + setMiterLimit(ml) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ml + +
    +
    {integer>0}
    + +
    + + + + + + + + +
    + + +
    + + + setOutlined(outlined) + +
    +
    + Sets whether the star will be outlined. + + +
    + + + + +
    +
    Parameters:
    + +
    + outlined + +
    +
    {boolean}
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.TextActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.TextActor.html new file mode 100644 index 0000000..0c9b3c2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.TextActor.html @@ -0,0 +1,2386 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI.TextActor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Foundation.UI.TextActor +

    + + +

    + +
    Extends + CAAT.Foundation.Actor.
    + + + + + +
    Defined in: TextActor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + fill +
    +
    a boolean indicating whether the text should be filled.
    +
      +
    + font +
    +
    a valid canvas rendering context font description.
    +
      +
    + fontData +
    +
    Font info.
    +
      +
    + lineWidth +
    +
    text's stroke line width.
    +
      +
    + outline +
    +
    a boolean indicating whether the text should be outlined.
    +
      + +
    a valid color description string.
    +
      +
    + path +
    +
    a CAAT.PathUtil.Path which will be traversed by the text.
    +
      + +
    time to be taken to traverse the path.
    +
      + +
    A CAAT.Behavior.Interpolator to apply to the path traversal.
    +
      +
    + sign +
    +
    traverse the path forward (1) or backwards (-1).
    +
      +
    + text +
    +
    a string with the text to draw.
    +
      +
    + textAlign +
    +
    a valid canvas rendering context textAlign string.
    +
      + +
    a valid canvas rendering context textBaseLine string.
    +
      + +
    text fill color
    +
      + +
    calculated text height in pixels.
    +
      +
    + textWidth +
    +
    calculated text width in pixels.
    +
    + + + +
    +
    Fields borrowed from class CAAT.Foundation.Actor:
    __super, AABB, alpha, backgroundImage, behaviorList, cached, clip, clipPath, dirty, discardable, duration, expired, fillStyle, frameAlpha, gestureEnabled, glEnabled, height, id, inFrame, invalid, isAA, isCachedActor, isGlobalAlpha, lifecycleListenerList, minimumSize, modelViewMatrix, modelViewMatrixI, mouseEnabled, oldX, oldY, parent, pointed, preferredSize, preventLayout, rotationAngle, rotationX, rotationY, scaleAnchor, scaleTX, scaleTY, scaleX, scaleY, size_active, size_total, start_time, strokeStyle, tAnchorX, tAnchorY, time, viewVertices, visible, wdirty, width, worldModelViewMatrix, worldModelViewMatrixI, x, y
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   + +
    +
    <private>   +
    __init() +
    +
    +
    <private>   + +
    +
      +
    calcTextSize(director) +
    +
    Calculates the text dimension in pixels and stores the values in textWidth and textHeight +attributes.
    +
      +
    centerAt(x, y) +
    +
    +
      +
    drawOnPath(director, time) +
    +
    Private.
    +
      +
    drawSpriteText(director, time) +
    +
    Private.
    +
      +
    drawSpriteTextOnPath(director, time) +
    +
    Private.
    +
      +
    paint(director, time) +
    +
    Custom paint method for TextActor instances.
    +
      +
    setAlign(align) +
    +
    Sets text alignment
    +
      +
    setBaseline(baseline) +
    +
    +
      +
    setBounds(x, y, w, h) +
    +
    +
      +
    setFill(fill) +
    +
    Set the text to be filled.
    +
      +
    setFont(font) +
    +
    Sets the font to be applied for the text.
    +
      + +
    +
      +
    setLocation(x, y) +
    +
    +
      +
    setOutline(outline) +
    +
    Sets whether the text will be outlined.
    +
      +
    setOutlineColor(color) +
    +
    Defines text's outline color.
    +
      +
    setPath(path, interpolator, duration) +
    +
    Set the path, interpolator and duration to draw the text on.
    +
      + +
    +
      +
    setPosition(x, y) +
    +
    +
      +
    setSize(w, h) +
    +
    +
      +
    setText(sText) +
    +
    Set the text to be shown by the actor.
    +
      +
    setTextAlign(align) +
    +
    +
      +
    setTextBaseline(baseline) +
    +
    Set text baseline.
    +
      + +
    +
    + + + +
    +
    Methods borrowed from class CAAT.Foundation.Actor:
    __paintActor, __scale1To, __validateLayout, addAnimation, addBehavior, addListener, animate, cacheAsBitmap, centerOn, clean, contains, create, destroy, disableDrag, drawScreenBoundingBox, emptyBehaviorList, enableDrag, enableEvents, endAnimate, findActorAtPosition, findActorById, fireEvent, gestureChange, gestureEnd, gestureStart, getAnchor, getAnchorPercent, getBehavior, getId, getMinimumSize, getPreferredSize, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, invalidateLayout, isCached, isGestureEnabled, isInAnimationFrame, isVisible, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, moveTo, paintActor, paintActorGL, playAnimation, removeBehaviorById, removeBehaviour, removeListener, resetAnimationTime, resetAsButton, resetTransform, rotateTo, scaleTo, scaleXTo, scaleYTo, setAlpha, setAnimationEndCallback, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setCachedActor, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setMinimumSize, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPositionAnchor, setPositionAnchored, setPreferredSize, setPreventLayout, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSpriteIndex, setStrokeStyle, setUV, setVisible, stopCacheAsBitmap, touchEnd, touchMove, touchStart, viewToModel
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Foundation.UI.TextActor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + fill + +
    +
    + a boolean indicating whether the text should be filled. + + +
    + + + + + + + + +
    + + +
    + + + font + +
    +
    + a valid canvas rendering context font description. Default font will be "10px sans-serif". + + +
    + + + + + + + + +
    + + +
    + + + fontData + +
    +
    + Font info. Calculated in CAAT. + + +
    + + + + + + + + +
    + + +
    + + + lineWidth + +
    +
    + text's stroke line width. + + +
    + + + + + + + + +
    + + +
    + + + outline + +
    +
    + a boolean indicating whether the text should be outlined. not all browsers support it. + + +
    + + + + + + + + +
    + + +
    + + + outlineColor + +
    +
    + a valid color description string. + + +
    + + + + + + + + +
    + + +
    + + + path + +
    +
    + a CAAT.PathUtil.Path which will be traversed by the text. + + +
    + + + + + + + + +
    + + +
    + + + pathDuration + +
    +
    + time to be taken to traverse the path. ms. + + +
    + + + + + + + + +
    + + +
    + + + pathInterpolator + +
    +
    + A CAAT.Behavior.Interpolator to apply to the path traversal. + + +
    + + + + + + + + +
    + + +
    + + + sign + +
    +
    + traverse the path forward (1) or backwards (-1). + + +
    + + + + + + + + +
    + + +
    + + + text + +
    +
    + a string with the text to draw. + + +
    + + + + + + + + +
    + + +
    + + + textAlign + +
    +
    + a valid canvas rendering context textAlign string. Any of: + start, end, left, right, center. +defaults to "left". + + +
    + + + + + + + + +
    + + +
    + + + textBaseline + +
    +
    + a valid canvas rendering context textBaseLine string. Any of: + top, hanging, middle, alphabetic, ideographic, bottom. +defaults to "top". + + +
    + + + + + + + + +
    + + +
    + + + textFillStyle + +
    +
    + text fill color + + +
    + + + + + + + + +
    + + +
    + + + textHeight + +
    +
    + calculated text height in pixels. + + +
    + + + + + + + + +
    + + +
    + + + textWidth + +
    +
    + calculated text width in pixels. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __calcFontData() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __setLocation() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + calcTextSize(director) + +
    +
    + Calculates the text dimension in pixels and stores the values in textWidth and textHeight +attributes. +If Actor's width and height were not set, the Actor's dimension will be set to these values. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a CAAT.Director instance.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + centerAt(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + drawOnPath(director, time) + +
    +
    + Private. +Draw the text traversing a path. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + drawSpriteText(director, time) + +
    +
    + Private. +Draw the text using a sprited font instead of a canvas font. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + drawSpriteTextOnPath(director, time) + +
    +
    + Private. +Draw the text traversing a path using a sprited font. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + Custom paint method for TextActor instances. +If the path attribute is set, the text will be drawn traversing the path. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    a valid CAAT.Director instance.
    + +
    + time + +
    +
    an integer with the Scene time the Actor is being drawn.
    + +
    + + + + + + + + +
    + + +
    + + + setAlign(align) + +
    +
    + Sets text alignment + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + +
    +
    Deprecated:
    +
    + use setTextAlign +
    +
    + + + + + + + +
    + + +
    + + + setBaseline(baseline) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + baseline + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setFill(fill) + +
    +
    + Set the text to be filled. The default Filling style will be set by calling setFillStyle method. +Default value is true. + + +
    + + + + +
    +
    Parameters:
    + +
    + fill + +
    +
    {boolean} a boolean indicating whether the text will be filled.
    + +
    + + + + + +
    +
    Returns:
    + +
    this;
    + +
    + + + + +
    + + +
    + + + setFont(font) + +
    +
    + Sets the font to be applied for the text. + + +
    + + + + +
    +
    Parameters:
    + +
    + font + +
    +
    a string with a valid canvas rendering context font description.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setLineWidth(lw) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + lw + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setLocation(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setOutline(outline) + +
    +
    + Sets whether the text will be outlined. + + +
    + + + + +
    +
    Parameters:
    + +
    + outline + +
    +
    {boolean} a boolean indicating whether the text will be outlined.
    + +
    + + + + + +
    +
    Returns:
    + +
    this;
    + +
    + + + + +
    + + +
    + + + setOutlineColor(color) + +
    +
    + Defines text's outline color. + + +
    + + + + +
    +
    Parameters:
    + +
    + color + +
    +
    {string} sets a valid canvas context color.
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + + setPath(path, interpolator, duration) + +
    +
    + Set the path, interpolator and duration to draw the text on. + + +
    + + + + +
    +
    Parameters:
    + +
    + path + +
    +
    a valid CAAT.Path instance.
    + +
    + interpolator + +
    +
    a CAAT.Interpolator object. If not set, a Linear Interpolator will be used.
    + +
    + duration + +
    +
    an integer indicating the time to take to traverse the path. Optional. 10000 ms +by default.
    + +
    + + + + + + + + +
    + + +
    + + + setPathTraverseDirection(direction) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + direction + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPosition(x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setSize(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setText(sText) + +
    +
    + Set the text to be shown by the actor. + + +
    + + + + +
    +
    Parameters:
    + +
    + sText + +
    +
    a string with the text to be shwon.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setTextAlign(align) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + align + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTextBaseline(baseline) + +
    +
    + Set text baseline. + + +
    + + + + +
    +
    Parameters:
    + +
    + baseline + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTextFillStyle(style) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.html new file mode 100644 index 0000000..4001629 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.UI.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Foundation.UI + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation.UI +

    + + +

    + + + + + + +
    Defined in: Dock.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation.UI +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:18 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.html b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.html new file mode 100644 index 0000000..d0baba6 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Foundation.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Foundation + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Foundation +

    + + +

    + + + + + + +
    Defined in: Actor.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    CAAT.Foundation is the base namespace for all the core animation elements.
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Foundation +
    + +
    + CAAT.Foundation is the base namespace for all the core animation elements. + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:16 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.KEYS.html b/CAAT/documentation/jsdoc/symbols/CAAT.KEYS.html new file mode 100644 index 0000000..9d8708c --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.KEYS.html @@ -0,0 +1,3316 @@ + + + + + + + JsDoc Reference - CAAT.KEYS + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.KEYS +

    + + +

    + + + + + + +
    Defined in: KeyEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      +
    + CAAT.KEYS +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.KEYS.a +
    +
    +
    <static>   +
    + CAAT.KEYS.ADD +
    +
    +
    <static>   +
    + CAAT.KEYS.ALT +
    +
    +
    <static>   +
    + CAAT.KEYS.b +
    +
    +
    <static>   +
    + CAAT.KEYS.BACKSLASH +
    +
    +
    <static>   +
    + CAAT.KEYS.BACKSPACE +
    +
    +
    <static>   +
    + CAAT.KEYS.c +
    +
    +
    <static>   +
    + CAAT.KEYS.CAPSLOCK +
    +
    +
    <static>   +
    + CAAT.KEYS.CLOSEBRAKET +
    +
    +
    <static>   +
    + CAAT.KEYS.COMMA +
    +
    +
    <static>   +
    + CAAT.KEYS.CTRL +
    +
    +
    <static>   +
    + CAAT.KEYS.d +
    +
    +
    <static>   +
    + CAAT.KEYS.DASH +
    +
    +
    <static>   +
    + CAAT.KEYS.DECIMALPOINT +
    +
    +
    <static>   +
    + CAAT.KEYS.DELETE +
    +
    +
    <static>   +
    + CAAT.KEYS.DIVIDE +
    +
    +
    <static>   +
    + CAAT.KEYS.DOWN +
    +
    +
    <static>   +
    + CAAT.KEYS.e +
    +
    +
    <static>   +
    + CAAT.KEYS.END +
    +
    +
    <static>   +
    + CAAT.KEYS.ENTER +
    +
    +
    <static>   +
    + CAAT.KEYS.EQUALSIGN +
    +
    +
    <static>   +
    + CAAT.KEYS.ESCAPE +
    +
    +
    <static>   +
    + CAAT.KEYS.f +
    +
    +
    <static>   +
    + CAAT.KEYS.F1 +
    +
    +
    <static>   +
    + CAAT.KEYS.F10 +
    +
    +
    <static>   +
    + CAAT.KEYS.F11 +
    +
    +
    <static>   +
    + CAAT.KEYS.F12 +
    +
    +
    <static>   +
    + CAAT.KEYS.F2 +
    +
    +
    <static>   +
    + CAAT.KEYS.F3 +
    +
    +
    <static>   +
    + CAAT.KEYS.F4 +
    +
    +
    <static>   +
    + CAAT.KEYS.F5 +
    +
    +
    <static>   +
    + CAAT.KEYS.F6 +
    +
    +
    <static>   +
    + CAAT.KEYS.F7 +
    +
    +
    <static>   +
    + CAAT.KEYS.F8 +
    +
    +
    <static>   +
    + CAAT.KEYS.F9 +
    +
    +
    <static>   +
    + CAAT.KEYS.FORWARDSLASH +
    +
    +
    <static>   +
    + CAAT.KEYS.g +
    +
    +
    <static>   +
    + CAAT.KEYS.GRAVEACCENT +
    +
    +
    <static>   +
    + CAAT.KEYS.h +
    +
    +
    <static>   +
    + CAAT.KEYS.HOME +
    +
    +
    <static>   +
    + CAAT.KEYS.i +
    +
    +
    <static>   +
    + CAAT.KEYS.INSERT +
    +
    +
    <static>   +
    + CAAT.KEYS.j +
    +
    +
    <static>   +
    + CAAT.KEYS.k +
    +
    +
    <static>   +
    + CAAT.KEYS.l +
    +
    +
    <static>   +
    + CAAT.KEYS.LEFT +
    +
    +
    <static>   +
    + CAAT.KEYS.m +
    +
    +
    <static>   +
    + CAAT.KEYS.MULTIPLY +
    +
    +
    <static>   +
    + CAAT.KEYS.n +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMLOCK +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD0 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD1 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD2 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD3 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD4 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD5 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD6 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD7 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD8 +
    +
    +
    <static>   +
    + CAAT.KEYS.NUMPAD9 +
    +
    +
    <static>   +
    + CAAT.KEYS.o +
    +
    +
    <static>   +
    + CAAT.KEYS.OPENBRACKET +
    +
    +
    <static>   +
    + CAAT.KEYS.p +
    +
    +
    <static>   +
    + CAAT.KEYS.PAGEDOWN +
    +
    +
    <static>   +
    + CAAT.KEYS.PAGEUP +
    +
    +
    <static>   +
    + CAAT.KEYS.PAUSE +
    +
    +
    <static>   +
    + CAAT.KEYS.PERIOD +
    +
    +
    <static>   +
    + CAAT.KEYS.q +
    +
    +
    <static>   +
    + CAAT.KEYS.r +
    +
    +
    <static>   +
    + CAAT.KEYS.RIGHT +
    +
    +
    <static>   +
    + CAAT.KEYS.s +
    +
    +
    <static>   +
    + CAAT.KEYS.SCROLLLOCK +
    +
    +
    <static>   +
    + CAAT.KEYS.SELECT +
    +
    +
    <static>   +
    + CAAT.KEYS.SEMICOLON +
    +
    +
    <static>   +
    + CAAT.KEYS.SHIFT +
    +
    +
    <static>   +
    + CAAT.KEYS.SINGLEQUOTE +
    +
    +
    <static>   +
    + CAAT.KEYS.SUBTRACT +
    +
    +
    <static>   +
    + CAAT.KEYS.t +
    +
    +
    <static>   +
    + CAAT.KEYS.TAB +
    +
    +
    <static>   +
    + CAAT.KEYS.u +
    +
    +
    <static>   +
    + CAAT.KEYS.UP +
    +
    +
    <static>   +
    + CAAT.KEYS.v +
    +
    +
    <static>   +
    + CAAT.KEYS.w +
    +
    +
    <static>   +
    + CAAT.KEYS.x +
    +
    +
    <static>   +
    + CAAT.KEYS.y +
    +
    +
    <static>   +
    + CAAT.KEYS.z +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.KEYS +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.KEYS.a + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.ADD + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.ALT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.b + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.BACKSLASH + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.BACKSPACE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.c + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.CAPSLOCK + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.CLOSEBRAKET + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.COMMA + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.CTRL + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.d + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.DASH + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.DECIMALPOINT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.DELETE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.DIVIDE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.DOWN + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.e + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.END + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.ENTER + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.EQUALSIGN + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.ESCAPE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.f + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F1 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F10 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F11 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F12 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F2 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F3 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F4 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F5 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F6 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F7 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F8 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.F9 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.FORWARDSLASH + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.g + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.GRAVEACCENT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.h + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.HOME + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.i + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.INSERT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.j + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.k + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.l + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.LEFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.m + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.MULTIPLY + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.n + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMLOCK + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD0 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD1 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD2 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD3 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD4 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD5 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD6 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD7 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD8 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.NUMPAD9 + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.o + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.OPENBRACKET + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.p + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.PAGEDOWN + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.PAGEUP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.PAUSE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.PERIOD + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.q + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.r + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.RIGHT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.s + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SCROLLLOCK + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SELECT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SEMICOLON + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SHIFT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SINGLEQUOTE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.SUBTRACT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.t + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.TAB + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.u + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.UP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.v + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.w + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.x + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.y + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEYS.z + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.KEY_MODIFIERS.html b/CAAT/documentation/jsdoc/symbols/CAAT.KEY_MODIFIERS.html new file mode 100644 index 0000000..bf25d2b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.KEY_MODIFIERS.html @@ -0,0 +1,660 @@ + + + + + + + JsDoc Reference - CAAT.KEY_MODIFIERS + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.KEY_MODIFIERS +

    + + +

    + + + + + + +
    Defined in: KeyEvent.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.KEY_MODIFIERS.alt +
    +
    +
    <static>   +
    + CAAT.KEY_MODIFIERS.control +
    +
    +
    <static>   +
    + CAAT.KEY_MODIFIERS.shift +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.KEY_MODIFIERS +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.KEY_MODIFIERS.alt + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEY_MODIFIERS.control + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.KEY_MODIFIERS.shift + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Bezier.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Bezier.html new file mode 100644 index 0000000..51af9e0 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Bezier.html @@ -0,0 +1,1239 @@ + + + + + + + JsDoc Reference - CAAT.Math.Bezier + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Bezier +

    + + +

    + +
    Extends + CAAT.Math.Curve.
    + + + + + +
    Defined in: Bezier.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + cubic +
    +
    This curbe is cubic or quadratic bezier ?
    +
    + + + +
    +
    Fields borrowed from class CAAT.Math.Curve:
    coordlist, drawHandles, HANDLE_SIZE, k, length
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyAsPath(director) +
    +
    +
      +
    isCubic() +
    +
    +
      + +
    +
      +
    paint(director) +
    +
    Paint this curve.
    +
    <private>   +
    paintCuadric(director) +
    +
    Paint this quadric Bezier curve.
    +
    <private>   +
    paintCubic(director) +
    +
    Paint this cubic Bezier curve.
    +
      +
    setCubic(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y) +
    +
    Set this curve as a cubic bezier defined by the given four control points.
    +
      +
    setPoints(points) +
    +
    +
      +
    setQuadric(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y) +
    +
    Set this curve as a quadric bezier defined by the three control points.
    +
      +
    solve(point, t) +
    +
    Solves the curve for any given parameter t.
    +
      +
    solveCubic(point, t) +
    +
    Solves a cubic Bezier.
    +
      +
    solveQuadric(point, t) +
    +
    Solves a quadric Bezier.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Math.Curve:
    calcLength, endCurvePosition, getBoundingBox, getContour, getLength, setPoint, startCurvePosition, update
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Bezier() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + cubic + +
    +
    + This curbe is cubic or quadratic bezier ? + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + applyAsPath(director) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + isCubic() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isQuadric() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + paint(director) + +
    +
    + Paint this curve. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + + + + + + + + +
    + + +
    <private> + + + paintCuadric(director) + +
    +
    + Paint this quadric Bezier curve. Each time the curve is drawn it will be solved again from 0 to 1 with +CAAT.Bezier.k increments. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + + + + + + + + +
    + + +
    <private> + + + paintCubic(director) + +
    +
    + Paint this cubic Bezier curve. Each time the curve is drawn it will be solved again from 0 to 1 with +CAAT.Bezier.k increments. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + + + + + + + + +
    + + +
    + + + setCubic(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y) + +
    +
    + Set this curve as a cubic bezier defined by the given four control points. + + +
    + + + + +
    +
    Parameters:
    + +
    + cp0x + +
    +
    {number}
    + +
    + cp0y + +
    +
    {number}
    + +
    + cp1x + +
    +
    {number}
    + +
    + cp1y + +
    +
    {number}
    + +
    + cp2x + +
    +
    {number}
    + +
    + cp2y + +
    +
    {number}
    + +
    + cp3x + +
    +
    {number}
    + +
    + cp3y + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setPoints(points) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + points + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setQuadric(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y) + +
    +
    + Set this curve as a quadric bezier defined by the three control points. + + +
    + + + + +
    +
    Parameters:
    + +
    + cp0x + +
    +
    {number}
    + +
    + cp0y + +
    +
    {number}
    + +
    + cp1x + +
    +
    {number}
    + +
    + cp1y + +
    +
    {number}
    + +
    + cp2x + +
    +
    {number}
    + +
    + cp2y + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + solve(point, t) + +
    +
    + Solves the curve for any given parameter t. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point} the point to store the solved value on the curve.
    + +
    + t + +
    +
    {number} a number in the range 0..1
    + +
    + + + + + + + + +
    + + +
    + + + solveCubic(point, t) + +
    +
    + Solves a cubic Bezier. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point} the point to store the solved value on the curve.
    + +
    + t + +
    +
    {number} the value to solve the curve for.
    + +
    + + + + + + + + +
    + + +
    + + + solveQuadric(point, t) + +
    +
    + Solves a quadric Bezier. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point} the point to store the solved value on the curve.
    + +
    + t + +
    +
    {number} the value to solve the curve for.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.CatmullRom.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.CatmullRom.html new file mode 100644 index 0000000..ad3721d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.CatmullRom.html @@ -0,0 +1,865 @@ + + + + + + + JsDoc Reference - CAAT.Math.CatmullRom + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.CatmullRom +

    + + +

    + +
    Extends + CAAT.Math.Curve.
    + + + + + +
    Defined in: CatmullRom.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + +
    +
    Fields borrowed from class CAAT.Math.Curve:
    coordlist, drawHandles, HANDLE_SIZE, k, length
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyAsPath(director) +
    +
    +
      + +
    Return the first curve control point.
    +
      +
    paint(director) +
    +
    Paint the contour by solving again the entire curve.
    +
      +
    setCurve(p0, p1, p2, p3) +
    +
    Set curve control points.
    +
      +
    solve(point, t) +
    +
    Solves the curve for any given parameter t.
    +
      + +
    Return the last curve control point.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Math.Curve:
    calcLength, getBoundingBox, getContour, getLength, setPoint, setPoints, update
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.CatmullRom() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + applyAsPath(director) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Point} + endCurvePosition() + +
    +
    + Return the first curve control point. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Point}
    + +
    + + + + +
    + + +
    + + + paint(director) + +
    +
    + Paint the contour by solving again the entire curve. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + + + + + + + + +
    + + +
    + + + setCurve(p0, p1, p2, p3) + +
    +
    + Set curve control points. + + +
    + + + + +
    +
    Parameters:
    + +
    + p0 + +
    +
    + +
    + p1 + +
    +
    + +
    + p2 + +
    +
    + +
    + p3 + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + solve(point, t) + +
    +
    + Solves the curve for any given parameter t. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point} the point to store the solved value on the curve.
    + +
    + t + +
    +
    {number} a number in the range 0..1
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Point} + startCurvePosition() + +
    +
    + Return the last curve control point. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Point}
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Curve.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Curve.html new file mode 100644 index 0000000..268489a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Curve.html @@ -0,0 +1,1288 @@ + + + + + + + JsDoc Reference - CAAT.Math.Curve + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Curve +

    + + +

    + + + + + + +
    Defined in: Curve.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + coordlist +
    +
    A collection of CAAT.Math.Point objects.
    +
      + +
    Draw interactive handlers ?
    +
      + +
    If this segments belongs to an interactive path, the handlers will be this size.
    +
      +
    + k +
    +
    Minimun solver step.
    +
      +
    + length +
    +
    Curve length.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyAsPath(director) +
    +
    +
      + +
    Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k.
    +
      + +
    Return the first curve control point.
    +
      +
    getBoundingBox(rectangle) +
    +
    Calculates a curve bounding box.
    +
      +
    getContour(numSamples) +
    +
    Get an array of points defining the curve contour.
    +
      + +
    Return the cached curve length.
    +
      +
    paint(director) +
    +
    Paint the curve control points.
    +
      +
    setPoint(point, index) +
    +
    +
      +
    setPoints(points) +
    +
    +
      +
    solve(point, t) +
    +
    This method must be overriden by subclasses.
    +
      + +
    Return the last curve control point.
    +
      +
    update() +
    +
    Signal the curve has been modified and recalculate curve length.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Curve() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + coordlist + +
    +
    + A collection of CAAT.Math.Point objects. + + +
    + + + + + + + + +
    + + +
    + + + drawHandles + +
    +
    + Draw interactive handlers ? + + +
    + + + + + + + + +
    + + +
    + + + HANDLE_SIZE + +
    +
    + If this segments belongs to an interactive path, the handlers will be this size. + + +
    + + + + + + + + +
    + + +
    + + + k + +
    +
    + Minimun solver step. + + +
    + + + + + + + + +
    + + +
    + + + length + +
    +
    + Curve length. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    + + + applyAsPath(director) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    <=CAAT.Director>
    + +
    + + + + + + + + +
    + + +
    + + {number} + calcLength() + +
    +
    + Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k. This value defaults +to .05 so at least 20 iterations will be performed. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number} the approximate curve length.
    + +
    + + + + +
    + + +
    + + {CAAT.Point} + endCurvePosition() + +
    +
    + Return the first curve control point. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Point}
    + +
    + + + + +
    + + +
    + + {CAAT.Rectangle} + getBoundingBox(rectangle) + +
    +
    + Calculates a curve bounding box. + + +
    + + + + +
    +
    Parameters:
    + +
    + rectangle + +
    +
    {CAAT.Rectangle} a rectangle to hold the bounding box.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Rectangle} the rectangle parameter.
    + +
    + + + + +
    + + +
    + + + getContour(numSamples) + +
    +
    + Get an array of points defining the curve contour. + + +
    + + + + +
    +
    Parameters:
    + +
    + numSamples + +
    +
    {number} number of segments to get.
    + +
    + + + + + + + + +
    + + +
    + + {number} + getLength() + +
    +
    + Return the cached curve length. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number} the cached curve length.
    + +
    + + + + +
    + + +
    + + + paint(director) + +
    +
    + Paint the curve control points. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + + + + + + + + +
    + + +
    + + + setPoint(point, index) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    + +
    + index + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPoints(points) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + points + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Point} + solve(point, t) + +
    +
    + This method must be overriden by subclasses. It is called whenever the curve must be solved for some time=t. +The t parameter must be in the range 0..1 + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point} to store curve solution for t.
    + +
    + t + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Point} the point parameter.
    + +
    + + + + +
    + + +
    + + {CAAT.Point} + startCurvePosition() + +
    +
    + Return the last curve control point. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Point}
    + +
    + + + + +
    + + +
    + + + update() + +
    +
    + Signal the curve has been modified and recalculate curve length. + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Dimension.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Dimension.html new file mode 100644 index 0000000..157422f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Dimension.html @@ -0,0 +1,702 @@ + + + + + + + JsDoc Reference - CAAT.Math.Dimension + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Dimension +

    + + +

    + + + + + + +
    Defined in: Dimension.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + height +
    +
    Height dimension.
    +
      +
    + width +
    +
    Width dimension.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(w, h) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Dimension() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + height + +
    +
    + Height dimension. + + +
    + + + + + + + + +
    + + +
    + + + width + +
    +
    + Width dimension. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix.html new file mode 100644 index 0000000..2cf1057 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix.html @@ -0,0 +1,1604 @@ + + + + + + + JsDoc Reference - CAAT.Math.Matrix + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Matrix +

    + + +

    + + + + + + +
    Defined in: Matrix.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + matrix +
    +
    An array of 9 numbers.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    copy(matrix) +
    +
    Copy into this matrix the given matrix values.
    +
      + +
    Creates a new inverse matrix from this matrix.
    +
      + +
    Set this matrix to the identity matrix.
    +
      +
    multiply(m) +
    +
    Multiply this matrix by a given matrix.
    +
      +
    multiplyScalar(scalar) +
    +
    Multiply this matrix by a scalar.
    +
      + +
    Premultiply this matrix by a given matrix.
    +
      +
    rotate(angle) +
    +
    Create a new rotation matrix and set it up for the specified angle in radians.
    +
      +
    scale(scalex, scaley) +
    +
    Create a scale matrix.
    +
      + +
    +
      +
    setModelViewMatrix(x, y, sx, sy, r) +
    +
    +
      +
    setRotation(angle) +
    +
    +
      +
    setScale(scalex, scaley) +
    +
    +
      +
    setTranslate(x, y) +
    +
    Sets this matrix as a translation matrix.
    +
      +
    transformCoord(point) +
    +
    Transform a point by this matrix.
    +
      + +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    translate(x, y) +
    +
    Create a translation matrix.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Matrix() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + matrix + +
    +
    + An array of 9 numbers. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + copy(matrix) + +
    +
    + Copy into this matrix the given matrix values. + + +
    + + + + +
    +
    Parameters:
    + +
    + matrix + +
    +
    {CAAT.Matrix}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {CAAT.Matrix} + getInverse() + +
    +
    + Creates a new inverse matrix from this matrix. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix} an inverse matrix.
    + +
    + + + + +
    + + +
    + + + identity() + +
    +
    + Set this matrix to the identity matrix. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + multiply(m) + +
    +
    + Multiply this matrix by a given matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + m + +
    +
    {CAAT.Matrix}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + multiplyScalar(scalar) + +
    +
    + Multiply this matrix by a scalar. + + +
    + + + + +
    +
    Parameters:
    + +
    + scalar + +
    +
    {number} scalar value
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + premultiply(m) + +
    +
    + Premultiply this matrix by a given matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + m + +
    +
    {CAAT.Matrix}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {CAAT.Matrix} + rotate(angle) + +
    +
    + Create a new rotation matrix and set it up for the specified angle in radians. + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix} a matrix object.
    + +
    + + + + +
    + + +
    + + {CAAT.Matrix} + scale(scalex, scaley) + +
    +
    + Create a scale matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + scalex + +
    +
    {number} x scale magnitude.
    + +
    + scaley + +
    +
    {number} y scale magnitude.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix} a matrix object.
    + +
    + + + + +
    + + +
    + + + setCoordinateClamping(clamp) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + clamp + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setModelViewMatrix(x, y, sx, sy, r) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + sx + +
    +
    + +
    + sy + +
    +
    + +
    + r + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRotation(angle) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScale(scalex, scaley) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + scalex + +
    +
    + +
    + scaley + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTranslate(x, y) + +
    +
    + Sets this matrix as a translation matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Point} + transformCoord(point) + +
    +
    + Transform a point by this matrix. The parameter point will be modified with the transformation values. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point}.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Point} the parameter point.
    + +
    + + + + +
    + + +
    + + + transformRenderingContext_Clamp(ctx) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + transformRenderingContext_NoClamp(ctx) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + transformRenderingContextSet_Clamp(ctx) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + transformRenderingContextSet_NoClamp(ctx) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + ctx + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Matrix} + translate(x, y) + +
    +
    + Create a translation matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} x translation magnitude.
    + +
    + y + +
    +
    {number} y translation magnitude.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix} a matrix object.
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix3.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix3.html new file mode 100644 index 0000000..32d6547 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Matrix3.html @@ -0,0 +1,1894 @@ + + + + + + + JsDoc Reference - CAAT.Math.Matrix3 + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Matrix3 +

    + + +

    + + + + + + +
    Defined in: Matrix3.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + fmatrix +
    +
    An array of 16 numbers.
    +
      +
    + matrix +
    +
    An Array of 4 Array of 4 numbers.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      + +
    Calculate this matrix's determinant.
    +
      +
    copy(m) +
    +
    Copy a given matrix values into this one's.
    +
      +
    flatten() +
    +
    +
      + +
    Creates a new matrix being a copy of this matrix.
    +
      + +
    Return a new matrix which is this matrix's inverse matrix.
    +
      + +
    Get this matri'x internal representation data.
    +
      + +
    Set this matrix to identity matrix.
    +
      +
    initialize(x0, y0, z0, x1, y1, z1, x2, y2, z2) +
    +
    +
      +
    initWithMatrix(matrixData) +
    +
    +
      +
    multiply(n) +
    +
    Multiplies this matrix by another matrix.
    +
      +
    multiplyScalar(scalar) +
    +
    Multiply this matrix by a scalar.
    +
      + +
    Pre multiplies this matrix by a given matrix.
    +
      +
    rotate(xy, xz, yz) +
    +
    Creates a matrix to represent arbitrary rotations around the given planes.
    +
      +
    rotateModelView(xy, xz, yz) +
    +
    Set this matrix as the rotation matrix around the given axes.
    +
      +
    rotateXY(xy) +
    +
    Multiply this matrix by a created rotation matrix.
    +
      +
    rotateXZ(xz) +
    +
    Multiply this matrix by a created rotation matrix.
    +
      +
    rotateYZ(yz) +
    +
    Multiply this matrix by a created rotation matrix.
    +
      +
    scale(sx, sy, sz) +
    +
    +
      +
    setRotate(xy, xz, yz) +
    +
    +
      +
    setScale(sx, sy, sz) +
    +
    +
      +
    setTranslate(x, y, z) +
    +
    Set this matrix translation values to be the given parameters.
    +
      +
    transformCoord(point) +
    +
    +
      +
    translate(x, y, z) +
    +
    Create a translation matrix.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Matrix3() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + fmatrix + +
    +
    + An array of 16 numbers. + + +
    + + + + + + + + +
    + + +
    + + + matrix + +
    +
    + An Array of 4 Array of 4 numbers. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {number} + calculateDeterminant() + +
    +
    + Calculate this matrix's determinant. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number} matrix determinant.
    + +
    + + + + +
    + + +
    + + + copy(m) + +
    +
    + Copy a given matrix values into this one's. + + +
    + + + + +
    +
    Parameters:
    + +
    + m + +
    +
    {CAAT.Matrix} a matrix
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + flatten() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {CAAT.Matrix3} + getClone() + +
    +
    + Creates a new matrix being a copy of this matrix. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix3} a newly allocated matrix object.
    + +
    + + + + +
    + + +
    + + {CAAT.Matrix3} + getInverse() + +
    +
    + Return a new matrix which is this matrix's inverse matrix. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix3} a new matrix.
    + +
    + + + + +
    + + +
    + + + getMatrix() + +
    +
    + Get this matri'x internal representation data. The bakced structure is a 4x4 array of number. + + +
    + + + + + + + + + + + +
    + + +
    + + + identity() + +
    +
    + Set this matrix to identity matrix. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initialize(x0, y0, z0, x1, y1, z1, x2, y2, z2) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x0 + +
    +
    + +
    + y0 + +
    +
    + +
    + z0 + +
    +
    + +
    + x1 + +
    +
    + +
    + y1 + +
    +
    + +
    + z1 + +
    +
    + +
    + x2 + +
    +
    + +
    + y2 + +
    +
    + +
    + z2 + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initWithMatrix(matrixData) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + matrixData + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + multiply(n) + +
    +
    + Multiplies this matrix by another matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + n + +
    +
    {CAAT.Matrix3} a CAAT.Matrix3 object.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + multiplyScalar(scalar) + +
    +
    + Multiply this matrix by a scalar. + + +
    + + + + +
    +
    Parameters:
    + +
    + scalar + +
    +
    {number} scalar value
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + premultiply(m) + +
    +
    + Pre multiplies this matrix by a given matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + m + +
    +
    {CAAT.Matrix3} a CAAT.Matrix3 object.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {CAAT.Matrix3} + rotate(xy, xz, yz) + +
    +
    + Creates a matrix to represent arbitrary rotations around the given planes. + + +
    + + + + +
    +
    Parameters:
    + +
    + xy + +
    +
    {number} radians to rotate around xy plane.
    + +
    + xz + +
    +
    {number} radians to rotate around xz plane.
    + +
    + yz + +
    +
    {number} radians to rotate around yz plane.
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix3} a newly allocated matrix.
    + +
    + + + + +
    + + +
    + + + rotateModelView(xy, xz, yz) + +
    +
    + Set this matrix as the rotation matrix around the given axes. + + +
    + + + + +
    +
    Parameters:
    + +
    + xy + +
    +
    {number} radians of rotation around z axis.
    + +
    + xz + +
    +
    {number} radians of rotation around y axis.
    + +
    + yz + +
    +
    {number} radians of rotation around x axis.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + rotateXY(xy) + +
    +
    + Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around +xy axis. + + +
    + + + + +
    +
    Parameters:
    + +
    + xy + +
    +
    {Number} radians to rotate.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + rotateXZ(xz) + +
    +
    + Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around +xz axis. + + +
    + + + + +
    +
    Parameters:
    + +
    + xz + +
    +
    {Number} radians to rotate.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + rotateYZ(yz) + +
    +
    + Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate aroind +yz axis. + + +
    + + + + +
    +
    Parameters:
    + +
    + yz + +
    +
    {Number} radians to rotate.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + scale(sx, sy, sz) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + sx + +
    +
    + +
    + sy + +
    +
    + +
    + sz + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRotate(xy, xz, yz) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + xy + +
    +
    + +
    + xz + +
    +
    + +
    + yz + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScale(sx, sy, sz) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + sx + +
    +
    + +
    + sy + +
    +
    + +
    + sz + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTranslate(x, y, z) + +
    +
    + Set this matrix translation values to be the given parameters. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number} x component of translation point.
    + +
    + y + +
    +
    {number} y component of translation point.
    + +
    + z + +
    +
    {number} z component of translation point.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + transformCoord(point) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Matrix3} + translate(x, y, z) + +
    +
    + Create a translation matrix. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + z + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {CAAT.Matrix3} a new matrix.
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Point.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Point.html new file mode 100644 index 0000000..9f6734f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Point.html @@ -0,0 +1,1582 @@ + + + + + + + JsDoc Reference - CAAT.Math.Point + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Point +

    + + +

    + + + + + + +
    Defined in: Point.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + x +
    +
    point x coordinate.
    +
      +
    + y +
    +
    point y coordinate.
    +
      +
    + z +
    +
    point z coordinate.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(xpos, ypos, zpos) +
    +
    +
      +
    clone() +
    +
    Create a new CAAT.Point equal to this one.
    +
      + +
    Return the angle from -Pi to Pi of this point.
    +
      +
    getDistance(point) +
    +
    Get the distance between two points.
    +
      + +
    Get the squared distance between two points.
    +
      + +
    Get this point's lenght.
    +
      + +
    Get this point's squared length.
    +
      +
    limit(max) +
    +
    Set this point coordinates proportinally to a maximum value.
    +
      +
    multiply(factor) +
    +
    Multiply this point by a scalar.
    +
      + +
    Normalize this point, that is, both set coordinates proportionally to values raning 0.
    +
      +
    rotate(angle) +
    +
    Rotate this point by an angle.
    +
      +
    set(x, y, z) +
    +
    Sets this point coordinates.
    +
      +
    setAngle(angle) +
    +
    +
      +
    setLength(length) +
    +
    +
      +
    subtract(aPoint) +
    +
    Substract a point from this one.
    +
      + +
    Get a string representation.
    +
      +
    translate(x, y, z) +
    +
    Translate this point to another position.
    +
      +
    translatePoint(aPoint) +
    +
    Translate this point to another point.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Point() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + x + +
    +
    + point x coordinate. + + +
    + + + + + + + + +
    + + +
    + + + y + +
    +
    + point y coordinate. + + +
    + + + + + + + + +
    + + +
    + + + z + +
    +
    + point z coordinate. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(xpos, ypos, zpos) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + xpos + +
    +
    + +
    + ypos + +
    +
    + +
    + zpos + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {CAAT.Point} + clone() + +
    +
    + Create a new CAAT.Point equal to this one. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {CAAT.Point}
    + +
    + + + + +
    + + +
    + + {number} + getAngle() + +
    +
    + Return the angle from -Pi to Pi of this point. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + {number} + getDistance(point) + +
    +
    + Get the distance between two points. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point}
    + +
    + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + {number} + getDistanceSquared(point) + +
    +
    + Get the squared distance between two points. + + +
    + + + + +
    +
    Parameters:
    + +
    + point + +
    +
    {CAAT.Point}
    + +
    + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + {number} + getLength() + +
    +
    + Get this point's lenght. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + {number} + getLengthSquared() + +
    +
    + Get this point's squared length. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {number}
    + +
    + + + + +
    + + +
    + + + limit(max) + +
    +
    + Set this point coordinates proportinally to a maximum value. + + +
    + + + + +
    +
    Parameters:
    + +
    + max + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + multiply(factor) + +
    +
    + Multiply this point by a scalar. + + +
    + + + + +
    +
    Parameters:
    + +
    + factor + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + normalize() + +
    +
    + Normalize this point, that is, both set coordinates proportionally to values raning 0..1 + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + rotate(angle) + +
    +
    + Rotate this point by an angle. The rotation is held by (0,0) coordinate as center. + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + set(x, y, z) + +
    +
    + Sets this point coordinates. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + z + +
    +
    {number=}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setAngle(angle) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + angle + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setLength(length) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + length + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + subtract(aPoint) + +
    +
    + Substract a point from this one. + + +
    + + + + +
    +
    Parameters:
    + +
    + aPoint + +
    +
    {CAAT.Point}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {string} + toString() + +
    +
    + Get a string representation. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {string}
    + +
    + + + + +
    + + +
    + + + translate(x, y, z) + +
    +
    + Translate this point to another position. The final point will be (point.x+x, point.y+y) + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + z + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + translatePoint(aPoint) + +
    +
    + Translate this point to another point. + + +
    + + + + +
    +
    Parameters:
    + +
    + aPoint + +
    +
    {CAAT.Point}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.Rectangle.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Rectangle.html new file mode 100644 index 0000000..896030f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.Rectangle.html @@ -0,0 +1,1395 @@ + + + + + + + JsDoc Reference - CAAT.Math.Rectangle + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Math.Rectangle +

    + + +

    + + + + + + +
    Defined in: Rectangle.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + height +
    +
    Rectangle height.
    +
      +
    + width +
    +
    Rectangle width.
    +
      +
    + x +
    +
    Rectangle x position.
    +
      +
    + x1 +
    +
    Rectangle x1 position.
    +
      +
    + y +
    +
    Rectangle y position.
    +
      +
    + y1 +
    +
    Rectangle y1 position.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init(x, y, w, h) +
    +
    +
      +
    contains(px, py) +
    +
    Return whether the coordinate is inside this rectangle.
    +
      +
    intersect(i, r) +
    +
    +
      + +
    +
      +
    intersectsRect(x, y, w, h) +
    +
    +
      +
    isEmpty() +
    +
    Return whether this rectangle is empty, that is, has zero dimension.
    +
      +
    setBounds(x, y, w, h) +
    +
    +
      +
    setDimension(w, h) +
    +
    Set this rectangle's dimension.
    +
      + +
    +
      +
    setLocation(x, y) +
    +
    Set this rectangle's location.
    +
      +
    union(px, py) +
    +
    Set this rectangle as the union of this rectangle and the given point.
    +
      +
    unionRectangle(rectangle) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Math.Rectangle() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + height + +
    +
    + Rectangle height. + + +
    + + + + + + + + +
    + + +
    + + + width + +
    +
    + Rectangle width. + + +
    + + + + + + + + +
    + + +
    + + + x + +
    +
    + Rectangle x position. + + +
    + + + + + + + + +
    + + +
    + + + x1 + +
    +
    + Rectangle x1 position. + + +
    + + + + + + + + +
    + + +
    + + + y + +
    +
    + Rectangle y position. + + +
    + + + + + + + + +
    + + +
    + + + y1 + +
    +
    + Rectangle y1 position. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {boolean} + contains(px, py) + +
    +
    + Return whether the coordinate is inside this rectangle. + + +
    + + + + +
    +
    Parameters:
    + +
    + px + +
    +
    {number}
    + +
    + py + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + +
    + + +
    + + + intersect(i, r) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + i + +
    +
    + +
    + r + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + intersects(r) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + r + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + intersectsRect(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {boolean} + isEmpty() + +
    +
    + Return whether this rectangle is empty, that is, has zero dimension. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {boolean}
    + +
    + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setDimension(w, h) + +
    +
    + Set this rectangle's dimension. + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    {number}
    + +
    + h + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setEmpty() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setLocation(x, y) + +
    +
    + Set this rectangle's location. + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    {number}
    + +
    + y + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + union(px, py) + +
    +
    + Set this rectangle as the union of this rectangle and the given point. + + +
    + + + + +
    +
    Parameters:
    + +
    + px + +
    +
    {number}
    + +
    + py + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + unionRectangle(rectangle) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rectangle + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Math.html b/CAAT/documentation/jsdoc/symbols/CAAT.Math.html new file mode 100644 index 0000000..85e041f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Math.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Math + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Math +

    + + +

    + + + + + + +
    Defined in: Bezier.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      +
    + CAAT.Math +
    +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Math +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.AudioManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.AudioManager.html new file mode 100644 index 0000000..a725dc3 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.AudioManager.html @@ -0,0 +1,1984 @@ + + + + + + + JsDoc Reference - CAAT.Module.Audio.AudioManager + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Audio.AudioManager +

    + + +

    + + + + + + +
    Defined in: AudioManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    A collection of Audio objects.
    +
      + +
    available formats for audio elements.
    +
      + +
    Audio formats.
    +
      +
    + channels +
    +
    A cache of empty Audio objects.
    +
      +
    + fxEnabled +
    +
    Are FX sounds enabled ?
    +
      + +
    Currently looping Audio objects.
    +
      + +
    The only background music audio channel.
    +
      + +
    Is music enabled ?
    +
      + +
    Currently used Audio objects.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   + +
    +
    <private>   +
    __init() +
    +
    +
    <private>   + +
    +
      +
    addAudio(id, array_of_url_or_domnodes, endplaying_callback) +
    +
    creates an Audio object and adds it to the audio cache.
    +
    <private>   +
    addAudioElement(id, element, endplaying_callback) +
    +
    Adds an elements to the audio cache.
    +
    <private>   +
    addAudioFromDomNode(id, audio, endplaying_callback) +
    +
    Tries to add an audio tag to the available list of valid audios.
    +
    <private>   +
    addAudioFromURL(id, url, endplaying_callback) +
    +
    Tries to add an audio tag to the available list of valid audios.
    +
      +
    cancelPlay(id) +
    +
    cancel all instances of a sound identified by id.
    +
      +
    cancelPlayByChannel(audioObject) +
    +
    cancel a channel sound
    +
      + +
    Cancel all playing audio channels +Get back the playing channels to available channel list.
    +
      +
    getAudio(aId) +
    +
    Returns an audio object.
    +
      +
    initialize(numChannels) +
    +
    Initializes the sound subsystem by creating a fixed number of Audio channels.
    +
      + +
    +
      + +
    +
      +
    loop(id) +
    +
    This method creates a new AudioChannel to loop the sound with.
    +
      +
    play(id) +
    +
    Plays an audio file from the cache if any sound channel is available.
    +
      +
    playMusic(id) +
    +
    +
      + +
    +
      +
    setMusicEnabled(enable) +
    +
    +
      + +
    +
      +
    setVolume(id, volume) +
    +
    Set an audio object volume.
    +
      + +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Audio.AudioManager() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + audioCache + +
    +
    + A collection of Audio objects. + + +
    + + + + + + + + +
    + + +
    + + + audioFormatExtensions + +
    +
    + available formats for audio elements. +the system will load audio files with the extensions in this preferred order. + + +
    + + + + + + + + +
    + + +
    + + + audioTypes + +
    +
    + Audio formats. + + +
    + + + + + + + + +
    + + +
    + + + channels + +
    +
    + A cache of empty Audio objects. + + +
    + + + + + + + + +
    + + +
    + + + fxEnabled + +
    +
    + Are FX sounds enabled ? + + +
    + + + + + + + + +
    + + +
    + + + loopingChannels + +
    +
    + Currently looping Audio objects. + + +
    + + + + + + + + +
    + + +
    + + + musicChannel + +
    +
    + The only background music audio channel. + + +
    + + + + + + + + +
    + + +
    + + + musicEnabled + +
    +
    + Is music enabled ? + + +
    + + + + + + + + +
    + + +
    + + + workingChannels + +
    +
    + Currently used Audio objects. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __getAudioUrl(url) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + url + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <private> + + + __setCurrentAudioFormatExtension() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addAudio(id, array_of_url_or_domnodes, endplaying_callback) + +
    +
    + creates an Audio object and adds it to the audio cache. +This function expects audio data described by two elements, an id and an object which will +describe an audio element to be associated with the id. The object will be of the form +array, dom node or a url string. + +

    +The audio element can be one of the two forms: + +

      +
    1. Either an HTMLAudioElement/Audio object or a string url. +
    2. An array of elements of the previous form. +
    + +

    +When the audio attribute is an array, this function will iterate throught the array elements +until a suitable audio element to be played is found. When this is the case, the other array +elements won't be taken into account. The valid form of using this addAudio method will be: + +

    +1.
    +addAudio( id, url } ). In this case, if the resource pointed by url is +not suitable to be played (i.e. a call to the Audio element's canPlayType method return 'no') +no resource will be added under such id, so no sound will be played when invoking the play(id) +method. +

    +2.
    +addAudio( id, dom_audio_tag ). In this case, the same logic than previous case is applied, but +this time, the parameter url is expected to be an audio tag present in the html file. +

    +3.
    +addAudio( id, [array_of_url_or_domaudiotag] ). In this case, the function tries to locate a valid +resource to be played in any of the elements contained in the array. The array element's can +be any type of case 1 and 2. As soon as a valid resource is found, it will be associated to the +id in the valid audio resources to be played list. + + +

    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + array_of_url_or_domnodes + +
    +
    + +
    + endplaying_callback + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    <private> + + {boolean} + addAudioElement(id, element, endplaying_callback) + +
    +
    + Adds an elements to the audio cache. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} an object to associate the audio element (if suitable to be played).
    + +
    + element + +
    +
    {URL|HTMLElement} an url or html audio tag.
    + +
    + endplaying_callback + +
    +
    {function} callback to be called upon sound end.
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean} a boolean indicating whether the browser can play this resource.
    + +
    + + + + +
    + + +
    <private> + + {boolean} + addAudioFromDomNode(id, audio, endplaying_callback) + +
    +
    + Tries to add an audio tag to the available list of valid audios. The audio element comes from +an HTMLAudioElement. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} an object to associate the audio element (if suitable to be played).
    + +
    + audio + +
    +
    {HTMLAudioElement} a DOM audio node.
    + +
    + endplaying_callback + +
    +
    {function} callback to be called upon sound end.
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean} a boolean indicating whether the browser can play this resource.
    + +
    + + + + +
    + + +
    <private> + + {boolean} + addAudioFromURL(id, url, endplaying_callback) + +
    +
    + Tries to add an audio tag to the available list of valid audios. The audio is described by a url. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} an object to associate the audio element (if suitable to be played).
    + +
    + url + +
    +
    {string} a string describing an url.
    + +
    + endplaying_callback + +
    +
    {function} callback to be called upon sound end.
    + +
    + + + + + +
    +
    Returns:
    + +
    {boolean} a boolean indicating whether the browser can play this resource.
    + +
    + + + + +
    + + +
    + + {*} + cancelPlay(id) + +
    +
    + cancel all instances of a sound identified by id. This id is the value set +to identify a sound. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + {*} + cancelPlayByChannel(audioObject) + +
    +
    + cancel a channel sound + + +
    + + + + +
    +
    Parameters:
    + +
    + audioObject + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    + + + endSound() + +
    +
    + Cancel all playing audio channels +Get back the playing channels to available channel list. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {object} + getAudio(aId) + +
    +
    + Returns an audio object. + + +
    + + + + +
    +
    Parameters:
    + +
    + aId + +
    +
    {object} the id associated to the target Audio object.
    + +
    + + + + + +
    +
    Returns:
    + +
    {object} the HTMLAudioElement addociated to the given id.
    + +
    + + + + +
    + + +
    + + + initialize(numChannels) + +
    +
    + Initializes the sound subsystem by creating a fixed number of Audio channels. +Every channel registers a handler for sound playing finalization. If a callback is set, the +callback function will be called with the associated sound id in the cache. + + +
    + + + + +
    +
    Parameters:
    + +
    + numChannels + +
    +
    {number} number of channels to pre-create. 8 by default.
    + +
    + + + + + +
    +
    Returns:
    + +
    this.
    + +
    + + + + +
    + + +
    + + + isMusicEnabled() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + isSoundEffectsEnabled() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + {HTMLElement} + loop(id) + +
    +
    + This method creates a new AudioChannel to loop the sound with. +It returns an Audio object so that the developer can cancel the sound loop at will. +The user must call pause() method to stop playing a loop. +

    +Firefox does not honor the loop property, so looping is performed by attending end playing +event on audio elements. + + +

    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {HTMLElement} an Audio instance if a valid sound id is supplied. Null otherwise
    + +
    + + + + +
    + + +
    + + {id: {Object}|audio: {(Audio|HTMLAudioElement)}} + play(id) + +
    +
    + Plays an audio file from the cache if any sound channel is available. +The playing sound will occupy a sound channel and when ends playing will leave +the channel free for any other sound to be played in. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} an object identifying a sound in the sound cache.
    + +
    + + + + + +
    +
    Returns:
    + +
    {id: {Object}|audio: {(Audio|HTMLAudioElement)}}
    + +
    + + + + +
    + + +
    + + + playMusic(id) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setAudioFormatExtensions(formats) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + formats + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setMusicEnabled(enable) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + enable + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setSoundEffectsEnabled(enable) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + enable + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setVolume(id, volume) + +
    +
    + Set an audio object volume. + + +
    + + + + +
    +
    Parameters:
    + +
    + id + +
    +
    {object} an audio Id
    + +
    + volume + +
    +
    {number} volume to set. The volume value is not checked.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + stopMusic() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.html new file mode 100644 index 0000000..3f46bad --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Audio.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Audio + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Audio +

    + + +

    + + + + + + +
    Defined in: AudioManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Audio +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircle.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircle.html new file mode 100644 index 0000000..2e7df24 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircle.html @@ -0,0 +1,1688 @@ + + + + + + + JsDoc Reference - CAAT.Module.CircleManager.PackedCircle + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.CircleManager.PackedCircle +

    + + +

    + + + + + + +
    Defined in: PackedCircle.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_CONSTRAINT +
    +
    +
    <static>   +
    + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_DESTROY +
    +
    +
    <static>   +
    + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE +
    +
    +
    <static>   +
    + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_WRAP +
    +
    +
      + +
    +
      + +
    +
      + +
    +
      +
    + delegate +
    +
    +
      +
    + id +
    +
    +
      +
    + isFixed +
    +
    +
      +
    + offset +
    +
    +
      +
    + position +
    +
    +
      + +
    +
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    containsPoint(aPoint) +
    +
    +
      +
    dealloc() +
    +
    +
      + +
    +
      +
    initialize(overrides) +
    +
    +
      +
    intersects(aCircle) +
    +
    +
      +
    setCollisionGroup(aCollisionGroup) +
    +
    +
      +
    setCollisionMask(aCollisionMask) +
    +
    +
      +
    setDelegate(aDelegate) +
    +
    +
      +
    setIsFixed(value) +
    +
    +
      +
    setOffset(aPosition) +
    +
    +
      +
    setPosition(aPosition) +
    +
    ACCESSORS
    +
      +
    setRadius(aRadius) +
    +
    +
      +
    setTargetChaseSpeed(aTargetChaseSpeed) +
    +
    +
      +
    setTargetPosition(aTargetPosition) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.CircleManager.PackedCircle() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_CONSTRAINT + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_DESTROY + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE + +
    +
    + + + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_WRAP + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + boundsRule + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + collisionGroup + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + collisionMask + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + delegate + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + id + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + isFixed + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + offset + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + position + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + targetChaseSpeed + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + targetPosition + +
    +
    + + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + containsPoint(aPoint) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aPoint + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + dealloc() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getDistanceSquaredFromPosition(aPosition) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aPosition + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initialize(overrides) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + overrides + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + intersects(aCircle) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aCircle + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setCollisionGroup(aCollisionGroup) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aCollisionGroup + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setCollisionMask(aCollisionMask) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aCollisionMask + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setDelegate(aDelegate) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aDelegate + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setIsFixed(value) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + value + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setOffset(aPosition) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aPosition + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPosition(aPosition) + +
    +
    + ACCESSORS + + +
    + + + + +
    +
    Parameters:
    + +
    + aPosition + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setRadius(aRadius) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aRadius + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTargetChaseSpeed(aTargetChaseSpeed) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aTargetChaseSpeed + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setTargetPosition(aTargetPosition) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aTargetPosition + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircleManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircleManager.html new file mode 100644 index 0000000..15d0bcd --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.PackedCircleManager.html @@ -0,0 +1,1397 @@ + + + + + + + JsDoc Reference - CAAT.Module.CircleManager.PackedCircleManager + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.CircleManager.PackedCircleManager +

    + + +

    + + + + + + +
    Defined in: PackedCircleManager.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      + +
    +
      +
    + bounds +
    +
    +
      + +
    +
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __init() +
    +
    +
      +
    addCircle(aCircle) +
    +
    Adds a circle to the simulation
    +
      +
    circlesCanCollide(circleA, circleB) +
    +
    +
      + +
    Forces all circles to move to where their delegate position is +Assumes all targets have a 'position' property!
    +
      +
    getCircleAt(xpos, ypos, buffer) +
    +
    Given an x,y position finds circle underneath and sets it to the currently grabbed circle
    +
      +
    handleBoundaryForCircle(aCircle, boundsRule) +
    +
    +
      + +
    Packs the circles towards the center of the bounds.
    +
      +
    initialize(overrides) +
    +
    +
      + +
    +
      +
    removeCircle(aCircle) +
    +
    Removes a circle from the simulations
    +
      + +
    Memory Management
    +
      +
    setBounds(x, y, w, h) +
    +
    Accessors
    +
      + +
    +
      + +
    +
      +
    sortOnDistanceToTarget(circleA, circleB) +
    +
    Helpers
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.CircleManager.PackedCircleManager() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + allCircles + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + bounds + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + numberOfCollisionPasses + +
    +
    + + + +
    + + + + + + + + +
    + + +
    + + + numberOfTargetingPasses + +
    +
    + + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __init() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + addCircle(aCircle) + +
    +
    + Adds a circle to the simulation + + +
    + + + + +
    +
    Parameters:
    + +
    + aCircle + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + circlesCanCollide(circleA, circleB) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + circleA + +
    +
    + +
    + circleB + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + forceCirclesToMatchDelegatePositions() + +
    +
    + Forces all circles to move to where their delegate position is +Assumes all targets have a 'position' property! + + +
    + + + + + + + + + + + +
    + + +
    + + + getCircleAt(xpos, ypos, buffer) + +
    +
    + Given an x,y position finds circle underneath and sets it to the currently grabbed circle + + +
    + + + + +
    +
    Parameters:
    + +
    + {Number} xpos + +
    +
    An x position
    + +
    + {Number} ypos + +
    +
    A y position
    + +
    + {Number} buffer + +
    +
    A radiusSquared around the point in question where something is considered to match
    + +
    + + + + + + + + +
    + + +
    + + + handleBoundaryForCircle(aCircle, boundsRule) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aCircle + +
    +
    + +
    + boundsRule + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + handleCollisions() + +
    +
    + Packs the circles towards the center of the bounds. +Each circle will have it's own 'targetPosition' later on + + +
    + + + + + + + + + + + +
    + + +
    + + + initialize(overrides) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + overrides + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + pushAllCirclesTowardTarget(aTarget) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + aTarget + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + removeCircle(aCircle) + +
    +
    + Removes a circle from the simulations + + +
    + + + + +
    +
    Parameters:
    + +
    + aCircle + +
    +
    Circle to remove
    + +
    + + + + + + + + +
    + + +
    + + + removeExpiredElements() + +
    +
    + Memory Management + + +
    + + + + + + + + + + + +
    + + +
    + + + setBounds(x, y, w, h) + +
    +
    + Accessors + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setNumberOfCollisionPasses(value) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + value + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setNumberOfTargetingPasses(value) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + value + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + sortOnDistanceToTarget(circleA, circleB) + +
    +
    + Helpers + + +
    + + + + +
    +
    Parameters:
    + +
    + circleA + +
    +
    + +
    + circleB + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.html new file mode 100644 index 0000000..6e23dc8 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.CircleManager.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.CircleManager + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.CircleManager +

    + + +

    + + + + + + +
    Defined in: PackedCircle.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.CircleManager +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.QuadTree.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.QuadTree.html new file mode 100644 index 0000000..0b06361 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.QuadTree.html @@ -0,0 +1,829 @@ + + + + + + + JsDoc Reference - CAAT.Module.Collision.QuadTree + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Collision.QuadTree +

    + + +

    + + + + + + +
    Defined in: Quadtree.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + bgActors +
    +
    For each quadtree level this keeps the list of overlapping elements.
    +
      +
    + quadData +
    +
    For each quadtree, this quadData keeps another 4 quadtrees up to the maximum recursion level.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   + +
    +
      +
    create(l, t, r, b, backgroundElements, minWidth, maxElements) +
    +
    +
      +
    getOverlappingActors(rectangle) +
    +
    Call this method to thet the list of colliding elements with the parameter rectangle.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Collision.QuadTree() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + bgActors + +
    +
    + For each quadtree level this keeps the list of overlapping elements. + + +
    + + + + + + + + +
    + + +
    + + + quadData + +
    +
    + For each quadtree, this quadData keeps another 4 quadtrees up to the maximum recursion level. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __getOverlappingActorList(actorList) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + actorList + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + create(l, t, r, b, backgroundElements, minWidth, maxElements) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + l + +
    +
    + +
    + t + +
    +
    + +
    + r + +
    +
    + +
    + b + +
    +
    + +
    + backgroundElements + +
    +
    + +
    + minWidth + +
    +
    + +
    + maxElements + +
    +
    + +
    + + + + + + + + +
    + + +
    + + {Array} + getOverlappingActors(rectangle) + +
    +
    + Call this method to thet the list of colliding elements with the parameter rectangle. + + +
    + + + + +
    +
    Parameters:
    + +
    + rectangle + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {Array}
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.SpatialHash.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.SpatialHash.html new file mode 100644 index 0000000..e702cfc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.SpatialHash.html @@ -0,0 +1,1181 @@ + + + + + + + JsDoc Reference - CAAT.Module.Collision.SpatialHash + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Collision.SpatialHash +

    + + +

    + + + + + + +
    Defined in: SpatialHash.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
      +
    + columns +
    +
    Columns to partition the space.
    +
      +
    + elements +
    +
    A collection ob objects to test collision among them.
    +
      +
    + height +
    +
    Space height
    +
      +
    + r0 +
    +
    Spare rectangle to hold temporary calculations.
    +
      +
    + r1 +
    +
    Spare rectangle to hold temporary calculations.
    +
      +
    + rows +
    +
    Rows to partition the space.
    +
      +
    + width +
    +
    Space width
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __getCells(x, y, width, height) +
    +
    +
    <private>   +
    _solveCollisionCell(cell, callback) +
    +
    +
      +
    addObject(obj) +
    +
    Add an element of the form { id, x,y,width,height, rectangular }
    +
      + +
    +
      +
    collide(x, y, w, h, oncollide) +
    +
    +
      +
    initialize(w, h, rows, columns) +
    +
    +
      +
    solveCollision(callback) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Collision.SpatialHash() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    + + + columns + +
    +
    + Columns to partition the space. + + +
    + + + + + + + + +
    + + +
    + + + elements + +
    +
    + A collection ob objects to test collision among them. + + +
    + + + + + + + + +
    + + +
    + + + height + +
    +
    + Space height + + +
    + + + + + + + + +
    + + +
    + + + r0 + +
    +
    + Spare rectangle to hold temporary calculations. + + +
    + + + + + + + + +
    + + +
    + + + r1 + +
    +
    + Spare rectangle to hold temporary calculations. + + +
    + + + + + + + + +
    + + +
    + + + rows + +
    +
    + Rows to partition the space. + + +
    + + + + + + + + +
    + + +
    + + + width + +
    +
    + Space width + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + + __getCells(x, y, width, height) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + width + +
    +
    + +
    + height + +
    +
    + +
    + + + + + + + + +
    + + +
    <private> + + + _solveCollisionCell(cell, callback) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + cell + +
    +
    + +
    + callback + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + addObject(obj) + +
    +
    + Add an element of the form { id, x,y,width,height, rectangular } + + +
    + + + + +
    +
    Parameters:
    + +
    + obj + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + clearObject() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + collide(x, y, w, h, oncollide) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + oncollide + +
    +
    function that returns boolean. if returns true, stop testing collision.
    + +
    + + + + + + + + +
    + + +
    + + + initialize(w, h, rows, columns) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + rows + +
    +
    + +
    + columns + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + solveCollision(callback) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + callback + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.html new file mode 100644 index 0000000..9ad203a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Collision.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Collision + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Collision +

    + + +

    + + + + + + +
    Defined in: Quadtree.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Collision +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.Color.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.Color.html new file mode 100644 index 0000000..a6dcabc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.Color.html @@ -0,0 +1,886 @@ + + + + + + + JsDoc Reference - CAAT.Module.ColorUtil.Color + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.ColorUtil.Color +

    + + +

    + + + + + + +
    Defined in: Color.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <static>   +
    + CAAT.Module.ColorUtil.Color.RampEnumeration +
    +
    Enumeration to define types of color ramps.
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <static>   +
    CAAT.Module.ColorUtil.Color.hsvToRgb(h, s, v) +
    +
    HSV to RGB color conversion +

    +H runs from 0 to 360 degrees
    +S and V run from 0 to 100 +

    +Ported from the excellent java algorithm by Eugene Vishnevsky at: +http://www.cs.rit.edu/~ncs/color/t_convert.html

    +
    <static>   +
    CAAT.Module.ColorUtil.Color.interpolate(r0, g0, b0, r1, g1, b1, nsteps, step) +
    +
    Interpolate the color between two given colors.
    +
    <static>   +
    CAAT.Module.ColorUtil.Color.makeRGBColorRamp(fromColorsArray, rampSize, returnType) +
    +
    Generate a ramp of colors from an array of given colors.
    +
    <static>   +
    CAAT.Module.ColorUtil.Color.random() +
    +
    +
    + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.ColorUtil.Color +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <static> + + + CAAT.Module.ColorUtil.Color.RampEnumeration + +
    +
    + Enumeration to define types of color ramps. + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <static> + + + CAAT.Module.ColorUtil.Color.hsvToRgb(h, s, v) + +
    +
    + HSV to RGB color conversion +

    +H runs from 0 to 360 degrees
    +S and V run from 0 to 100 +

    +Ported from the excellent java algorithm by Eugene Vishnevsky at: +http://www.cs.rit.edu/~ncs/color/t_convert.html + + +

    + + + + +
    +
    Parameters:
    + +
    + h + +
    +
    + +
    + s + +
    +
    + +
    + v + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + {{r{number}|g{number}|b{number}}} + CAAT.Module.ColorUtil.Color.interpolate(r0, g0, b0, r1, g1, b1, nsteps, step) + +
    +
    + Interpolate the color between two given colors. The return value will be a calculated color +among the two given initial colors which corresponds to the 'step'th color of the 'nsteps' +calculated colors. + + +
    + + + + +
    +
    Parameters:
    + +
    + r0 + +
    +
    {number} initial color red component.
    + +
    + g0 + +
    +
    {number} initial color green component.
    + +
    + b0 + +
    +
    {number} initial color blue component.
    + +
    + r1 + +
    +
    {number} final color red component.
    + +
    + g1 + +
    +
    {number} final color green component.
    + +
    + b1 + +
    +
    {number} final color blue component.
    + +
    + nsteps + +
    +
    {number} number of colors to calculate including the two given colors. If 16 is passed as value, +14 colors plus the two initial ones will be calculated.
    + +
    + step + +
    +
    {number} return this color index of all the calculated colors.
    + +
    + + + + + +
    +
    Returns:
    + +
    {{r{number}|g{number}|b{number}}} return an object with the new calculated color components.
    + +
    + + + + +
    + + +
    <static> + + {[{number}|{number}|{number}|{number}]} + CAAT.Module.ColorUtil.Color.makeRGBColorRamp(fromColorsArray, rampSize, returnType) + +
    +
    + Generate a ramp of colors from an array of given colors. + + +
    + + + + +
    +
    Parameters:
    + +
    + fromColorsArray + +
    +
    {[number]} an array of colors. each color is defined by an integer number from which +color components will be extracted. Be aware of the alpha component since it will also be interpolated for +new colors.
    + +
    + rampSize + +
    +
    {number} number of colors to produce.
    + +
    + returnType + +
    +
    {CAAT.ColorUtils.RampEnumeration} a value of CAAT.ColorUtils.RampEnumeration enumeration.
    + +
    + + + + + +
    +
    Returns:
    + +
    {[{number}|{number}|{number}|{number}]} an array of integers each of which represents a color of +the calculated color ramp.
    + +
    + + + + +
    + + +
    <static> + + + CAAT.Module.ColorUtil.Color.random() + +
    +
    + + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.html new file mode 100644 index 0000000..7dfbba6 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.ColorUtil.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Module.ColorUtil + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.ColorUtil +

    + + +

    + + + + + + +
    Defined in: Color.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.ColorUtil +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.Debug.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.Debug.html new file mode 100644 index 0000000..2dc76ce --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.Debug.html @@ -0,0 +1,750 @@ + + + + + + + JsDoc Reference - CAAT.Module.Debug.Debug + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Debug.Debug +

    + + +

    + + + + + + +
    Defined in: Debug.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    debugInfo(statistics) +
    +
    +
      +
    initialize(w, h) +
    +
    +
      +
    paint(rafValue) +
    +
    +
      +
    setScale(s) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Debug.Debug() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + debugInfo(statistics) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + statistics + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + initialize(w, h) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + paint(rafValue) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + rafValue + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setScale(s) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + s + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.html new file mode 100644 index 0000000..f72f052 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Debug.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Debug + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Debug +

    + + +

    + + + + + + +
    Defined in: Debug.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Debug +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.Font.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.Font.html new file mode 100644 index 0000000..811d546 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.Font.html @@ -0,0 +1,1486 @@ + + + + + + + JsDoc Reference - CAAT.Module.Font.Font + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Font.Font +

    + + +

    + + + + + + +
    Defined in: Font.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    create(chars, padding) +
    +
    +
      +
    createDefault(padding) +
    +
    +
      +
    drawSpriteText(director, time) +
    +
    +
      +
    drawText(str, ctx, x, y) +
    +
    +
      + +
    +
      + +
    +
      + +
    +
    <static>   +
    CAAT.Module.Font.Font.getFontMetrics(font) +
    +
    +
    <static>   +
    CAAT.Module.Font.Font.getFontMetricsCSS(font) +
    +
    Totally ripped from: + +jQuery (offset function) +Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas
    +
    <static>   +
    CAAT.Module.Font.Font.getFontMetricsNoCSS(font) +
    +
    +
      +
    save() +
    +
    +
      + +
    +
      +
    setFillStyle(style) +
    +
    +
      +
    setFont(font) +
    +
    +
      +
    setFontSize(fontSize) +
    +
    +
      +
    setFontStyle(style) +
    +
    +
      +
    setPadding(padding) +
    +
    +
      +
    setStrokeSize(size) +
    +
    +
      +
    setStrokeStyle(style) +
    +
    +
      + +
    +
      +
    stringWidth(str) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Font.Font() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + create(chars, padding) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + chars + +
    +
    + +
    + padding + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + createDefault(padding) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + padding + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + drawSpriteText(director, time) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    + +
    + time + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + drawText(str, ctx, x, y) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + str + +
    +
    + +
    + ctx + +
    +
    + +
    + x + +
    +
    + +
    + y + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + getAscent() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getDescent() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + getFontData() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.Font.Font.getFontMetrics(font) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + font + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + {*} + CAAT.Module.Font.Font.getFontMetricsCSS(font) + +
    +
    + Totally ripped from: + +jQuery (offset function) +Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas + + +
    + + + + +
    +
    Parameters:
    + +
    + font + +
    +
    + +
    + + + + + +
    +
    Returns:
    + +
    {*}
    + +
    + + + + +
    + + +
    <static> + + + CAAT.Module.Font.Font.getFontMetricsNoCSS(font) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + font + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + save() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setAsSpriteImage() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + setFillStyle(style) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setFont(font) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + font + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setFontSize(fontSize) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + fontSize + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setFontStyle(style) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setPadding(padding) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + padding + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setStrokeSize(size) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + size + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + setStrokeStyle(style) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + style + +
    +
    + +
    + + + + + + + + +
    + + +
    + + + stringHeight() + +
    +
    + + + +
    + + + + + + + + + + + +
    + + +
    + + + stringWidth(str) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + str + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.html new file mode 100644 index 0000000..b345b6a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Font.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Font + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Font +

    + + +

    + + + + + + +
    Defined in: Font.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Font +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMBumpMapping.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMBumpMapping.html new file mode 100644 index 0000000..93aa424 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMBumpMapping.html @@ -0,0 +1,975 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageProcessor.IMBumpMapping + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Image.ImageProcessor.IMBumpMapping +

    + + +

    + +
    Extends + CAAT.Module.Image.ImageProcessor.ImageProcessor.
    + + + + + +
    Defined in: IMBumpMapping.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyIM(director, time) +
    +
    Applies the bump effect and makes it visible on the canvas surface.
    +
    <private>   + +
    Create a phong image to apply bump effect.
    +
      +
    drawColored(dstPixels) +
    +
    Generates a bump image.
    +
      +
    initialize(image, radius) +
    +
    Initialize the bump image processor.
    +
    <private>   +
    prepareBump(image, radius) +
    +
    Initializes internal bump effect data.
    +
      +
    setLightColors(colors_rgb_array) +
    +
    Sets lights color.
    +
      +
    setLightPosition(lightIndex, x, y) +
    +
    Set a light position.
    +
      +
    soften(bump) +
    +
    Soften source images extracted data on prepareBump method.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Module.Image.ImageProcessor.ImageProcessor:
    clear, createPattern, getCanvas, getImageData, grabPixels, makeArray, makeArray2D, paint
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Image.ImageProcessor.IMBumpMapping() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + applyIM(director, time) + +
    +
    + Applies the bump effect and makes it visible on the canvas surface. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    <private> + + + calculatePhong() + +
    +
    + Create a phong image to apply bump effect. + + +
    + + + + + + + + + + + +
    + + +
    + + + drawColored(dstPixels) + +
    +
    + Generates a bump image. + + +
    + + + + +
    +
    Parameters:
    + +
    + dstPixels + +
    +
    {ImageData.data} destinarion pixel array to store the calculated image.
    + +
    + + + + + + + + +
    + + +
    + + + initialize(image, radius) + +
    +
    + Initialize the bump image processor. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {HTMLImageElement} source image to bump.
    + +
    + radius + +
    +
    {number} light radius.
    + +
    + + + + + + + + +
    + + +
    <private> + + + prepareBump(image, radius) + +
    +
    + Initializes internal bump effect data. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {HTMLImageElement}
    + +
    + radius + +
    +
    {number} lights radius.
    + +
    + + + + + + + + +
    + + +
    + + + setLightColors(colors_rgb_array) + +
    +
    + Sets lights color. + + +
    + + + + +
    +
    Parameters:
    + +
    + colors_rgb_array + +
    +
    an array of arrays. Each internal array has three integers defining an RGB color. +ie: + [ + [ 255,0,0 ], + [ 0,255,0 ] + ]
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setLightPosition(lightIndex, x, y) + +
    +
    + Set a light position. + + +
    + + + + +
    +
    Parameters:
    + +
    + lightIndex + +
    +
    {number} light index to position.
    + +
    + x + +
    +
    {number} light x coordinate.
    + +
    + y + +
    +
    {number} light y coordinate.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + soften(bump) + +
    +
    + Soften source images extracted data on prepareBump method. + + +
    + + + + +
    +
    Parameters:
    + +
    + bump + +
    +
    bidimensional array of black and white source image version.
    + +
    + + + + + +
    +
    Returns:
    + +
    bidimensional array with softened version of source image's b&w representation.
    + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMPlasma.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMPlasma.html new file mode 100644 index 0000000..e8227cc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMPlasma.html @@ -0,0 +1,732 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageProcessor.IMPlasma + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Image.ImageProcessor.IMPlasma +

    + + +

    + +
    Extends + CAAT.Module.Image.ImageProcessor.ImageProcessor.
    + + + + + +
    Defined in: IMPlasma.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    apply(director, time) +
    +
    Apply image processing to create the plasma and call superclass's apply to make the result +visible.
    +
      +
    initialize(width, height, colors) +
    +
    Initialize the plasma image processor.
    +
      +
    setB() +
    +
    Initialize internal plasma structures.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Module.Image.ImageProcessor.ImageProcessor:
    applyIM, clear, createPattern, getCanvas, getImageData, grabPixels, makeArray, makeArray2D, paint
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Image.ImageProcessor.IMPlasma() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + apply(director, time) + +
    +
    + Apply image processing to create the plasma and call superclass's apply to make the result +visible. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initialize(width, height, colors) + +
    +
    + Initialize the plasma image processor. +

    +This image processor creates a color ramp of 256 elements from the colors of the parameter 'colors'. +Be aware of color definition since the alpha values count to create the ramp. + + +

    + + + + +
    +
    Parameters:
    + +
    + width + +
    +
    {number}
    + +
    + height + +
    +
    {number}
    + +
    + colors + +
    +
    {Array.} an array of color values.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + setB() + +
    +
    + Initialize internal plasma structures. Calling repeatedly this method will make the plasma +look different. + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMRotoZoom.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMRotoZoom.html new file mode 100644 index 0000000..211e96e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.IMRotoZoom.html @@ -0,0 +1,778 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageProcessor.IMRotoZoom + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Image.ImageProcessor.IMRotoZoom +

    + + +

    + +
    Extends + CAAT.Module.Image.ImageProcessor.ImageProcessor.
    + + + + + +
    Defined in: IMRotoZoom.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyIM(director, time) +
    +
    Perform and apply the rotozoom effect.
    +
      +
    initialize(width, height, patternImage) +
    +
    Initialize the rotozoom.
    +
    <private>   +
    rotoZoom(director, time) +
    +
    Performs the process of tiling rotozoom.
    +
      + +
    Change the effect's rotation anchor.
    +
    + + + +
    +
    Methods borrowed from class CAAT.Module.Image.ImageProcessor.ImageProcessor:
    clear, createPattern, getCanvas, getImageData, grabPixels, makeArray, makeArray2D, paint
    +
    + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Image.ImageProcessor.IMRotoZoom() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + applyIM(director, time) + +
    +
    + Perform and apply the rotozoom effect. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + initialize(width, height, patternImage) + +
    +
    + Initialize the rotozoom. + + +
    + + + + +
    +
    Parameters:
    + +
    + width + +
    +
    {number}
    + +
    + height + +
    +
    {number}
    + +
    + patternImage + +
    +
    {HTMLImageElement} image to tile with.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    <private> + + + rotoZoom(director, time) + +
    +
    + Performs the process of tiling rotozoom. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + + + + +
    + + +
    + + + setCenter() + +
    +
    + Change the effect's rotation anchor. Call this method repeatedly to make the effect look +different. + + +
    + + + + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.ImageProcessor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.ImageProcessor.html new file mode 100644 index 0000000..8b5a73d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.ImageProcessor.html @@ -0,0 +1,1113 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageProcessor.ImageProcessor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Image.ImageProcessor.ImageProcessor +

    + + +

    + + + + + + +
    Defined in: ImageProcessor.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
      +
    applyIM(director, time) +
    +
    Sets canvas pixels to be the applied effect.
    +
      +
    clear(r, g, b, a) +
    +
    Clear this ImageData object to the given color components.
    +
      +
    createPattern(type) +
    +
    Creates a pattern that will make this ImageProcessor object suitable as a fillStyle value.
    +
      + +
    Returns the offscreen canvas.
    +
      + +
    Get this ImageData.
    +
      +
    grabPixels(image) +
    +
    Grabs an image pixels.
    +
      +
    initialize(width, height) +
    +
    Initializes and creates an offscreen Canvas object.
    +
      +
    makeArray(size, initValue) +
    +
    Helper method to create an array.
    +
      +
    makeArray2D(size, size2, initvalue) +
    +
    Helper method to create a bidimensional array.
    +
      +
    paint(director, time) +
    +
    Paint this ImageProcessor object result.
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Image.ImageProcessor.ImageProcessor() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    + + + applyIM(director, time) + +
    +
    + Sets canvas pixels to be the applied effect. After process pixels, this method must be called +to show the result of such processing. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}
    + +
    + time + +
    +
    {number}
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + clear(r, g, b, a) + +
    +
    + Clear this ImageData object to the given color components. + + +
    + + + + +
    +
    Parameters:
    + +
    + r + +
    +
    {number} red color component 0..255.
    + +
    + g + +
    +
    {number} green color component 0..255.
    + +
    + b + +
    +
    {number} blue color component 0..255.
    + +
    + a + +
    +
    {number} alpha color component 0..255.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + + createPattern(type) + +
    +
    + Creates a pattern that will make this ImageProcessor object suitable as a fillStyle value. +This effect can be drawn too as an image by calling: canvas_context.drawImage methods. + + +
    + + + + +
    +
    Parameters:
    + +
    + type + +
    +
    {string} the pattern type. if no value is supplied 'repeat' will be used.
    + +
    + + + + + +
    +
    Returns:
    + +
    CanvasPattern.
    + +
    + + + + +
    + + +
    + + {HTMLCanvasElement} + getCanvas() + +
    +
    + Returns the offscreen canvas. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {HTMLCanvasElement}
    + +
    + + + + +
    + + +
    + + {ImageData} + getImageData() + +
    +
    + Get this ImageData. + + +
    + + + + + + + + +
    +
    Returns:
    + +
    {ImageData}
    + +
    + + + + +
    + + +
    + + {ImageData} + grabPixels(image) + +
    +
    + Grabs an image pixels. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    {HTMLImageElement}
    + +
    + + + + + +
    +
    Returns:
    + +
    {ImageData} returns an ImageData object with the image representation or null in +case the pixels can not be grabbed.
    + +
    + + + + +
    + + +
    + + + initialize(width, height) + +
    +
    + Initializes and creates an offscreen Canvas object. It also creates an ImageData object and +initializes the internal bufferImage attribute to imageData's data. + + +
    + + + + +
    +
    Parameters:
    + +
    + width + +
    +
    {number} canvas width.
    + +
    + height + +
    +
    {number} canvas height.
    + +
    + + + + + +
    +
    Returns:
    + +
    this
    + +
    + + + + +
    + + +
    + + {[]} + makeArray(size, initValue) + +
    +
    + Helper method to create an array. + + +
    + + + + +
    +
    Parameters:
    + +
    + size + +
    +
    {number} integer number of elements in the array.
    + +
    + initValue + +
    +
    {number} initial array values.
    + +
    + + + + + +
    +
    Returns:
    + +
    {[]} an array of 'initialValue' elements.
    + +
    + + + + +
    + + +
    + + {[]} + makeArray2D(size, size2, initvalue) + +
    +
    + Helper method to create a bidimensional array. + + +
    + + + + +
    +
    Parameters:
    + +
    + size + +
    +
    {number} number of array rows.
    + +
    + size2 + +
    +
    {number} number of array columns.
    + +
    + initvalue + +
    +
    array initial values.
    + +
    + + + + + +
    +
    Returns:
    + +
    {[]} a bidimensional array of 'initvalue' elements.
    + +
    + + + + +
    + + +
    + + + paint(director, time) + +
    +
    + Paint this ImageProcessor object result. + + +
    + + + + +
    +
    Parameters:
    + +
    + director + +
    +
    {CAAT.Director}.
    + +
    + time + +
    +
    {number} scene time.
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.html new file mode 100644 index 0000000..95a269f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageProcessor.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageProcessor + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Image.ImageProcessor +

    + + +

    + + + + + + +
    Defined in: ImageProcessor.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Image.ImageProcessor +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageUtil.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageUtil.html new file mode 100644 index 0000000..ec45f7f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.ImageUtil.html @@ -0,0 +1,805 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image.ImageUtil + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Image.ImageUtil +

    + + +

    + + + + + + +
    Defined in: ImageUtil.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <static>   +
    CAAT.Module.Image.ImageUtil.createAlphaSpriteSheet(maxAlpha, minAlpha, sheetSize, image, bg_fill_style) +
    +
    +
    <static>   +
    CAAT.Module.Image.ImageUtil.createThumb(image, w, h, best_fit) +
    +
    +
    <static>   +
    CAAT.Module.Image.ImageUtil.optimize(image, threshold, areas) +
    +
    Remove an image's padding transparent border.
    +
    <static>   +
    CAAT.Module.Image.ImageUtil.rotate(image, angle) +
    +
    Creates a rotated canvas image element.
    +
    + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Image.ImageUtil +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + +
    + Method Detail +
    + + +
    <static> + + + CAAT.Module.Image.ImageUtil.createAlphaSpriteSheet(maxAlpha, minAlpha, sheetSize, image, bg_fill_style) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + maxAlpha + +
    +
    + +
    + minAlpha + +
    +
    + +
    + sheetSize + +
    +
    + +
    + image + +
    +
    + +
    + bg_fill_style + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.Image.ImageUtil.createThumb(image, w, h, best_fit) + +
    +
    + + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + w + +
    +
    + +
    + h + +
    +
    + +
    + best_fit + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.Image.ImageUtil.optimize(image, threshold, areas) + +
    +
    + Remove an image's padding transparent border. +Transparent means that every scan pixel is alpha=0. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + threshold + +
    +
    + +
    + areas + +
    +
    + +
    + + + + + + + + +
    + + +
    <static> + + + CAAT.Module.Image.ImageUtil.rotate(image, angle) + +
    +
    + Creates a rotated canvas image element. + + +
    + + + + +
    +
    Parameters:
    + +
    + image + +
    +
    + +
    + angle + +
    +
    + +
    + + + + + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.html new file mode 100644 index 0000000..10a88b5 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Image.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Module.Image + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Namespace CAAT.Module.Image +

    + + +

    + + + + + + +
    Defined in: ImageProcessor.js. + +

    + + + + + + + + + + + + + + + + + +
    Namespace Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + +
    +
    + Namespace Detail +
    + +
    + CAAT.Module.Image +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + + + + + + + + +
    +
    + + + +
    + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
    + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.ResourceBundle.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.ResourceBundle.html new file mode 100644 index 0000000..a3daedd --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.ResourceBundle.html @@ -0,0 +1,1026 @@ + + + + + + + JsDoc Reference - CAAT.Module.Locale.ResourceBundle + + + + + + + + + + + +
    + + +
    +

    Classes

    + +
    + +
    + +
    + +

    + + Class CAAT.Module.Locale.ResourceBundle +

    + + +

    + + + + + + +
    Defined in: ResourceBundle.js. + +

    + + + + + + + + + + + + + + + + + +
    Class Summary
    Constructor AttributesConstructor Name and Description
      + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Field Summary
    Field AttributesField Name and Description
    <private>   + +
    Current set locale.
    +
    <private>   + +
    Default locale info.
    +
      + +
    Original file contents.
    +
      +
    + valid +
    +
    Is this bundle valid ?
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Method Summary
    Method AttributesMethod Name and Description
    <private>   +
    __formatString(string, args) +
    +
    A formated string is a regular string that has embedded holder for string values.
    +
    <private>   +
    __init(resourceFile, asynch, onSuccess, onError) +
    +

    +Load a bundle file.

    +
      +
    getString(id, defaultValue, args) +
    +
    +
      +
    loadDoc(resourceFile, asynch, onSuccess, onError) +
    +
    +
    + + + + + + + + + +
    +
    + Class Detail +
    + +
    + CAAT.Module.Locale.ResourceBundle() +
    + +
    + + +
    + + + + + + + + + + + + +
    + + + + +
    + Field Detail +
    + + +
    <private> + + + __currentLocale + +
    +
    + Current set locale. + + +
    + + + + + + + + +
    + + +
    <private> + + + __defaultLocale + +
    +
    + Default locale info. + + +
    + + + + + + + + +
    + + +
    + + + localeInfo + +
    +
    + Original file contents. + + +
    + + + + + + + + +
    + + +
    + + + valid + +
    +
    + Is this bundle valid ? + + +
    + + + + + + + + + + + + + + +
    + Method Detail +
    + + +
    <private> + + {string} + __formatString(string, args) + +
    +
    + A formated string is a regular string that has embedded holder for string values. +for example a string like: + +"hi this is a $2 $1" + +will be after calling __formatString( str, ["string","parameterized"] ); + +"hi this is a parameterized string" + +IMPORTANT: Holder values start in 1. + + +
    + + + + +
    +
    Parameters:
    + +
    + string + +
    +
    {string} a parameterized string
    + +
    + args + +
    +
    {object} object whose keys are used to find holders and replace them in string parameter
    + +
    + + + + + +
    +
    Returns:
    + +
    {string}
    + +
    + + + + +
    + + +
    <private> + + {*} + __init(resourceFile, asynch, onSuccess, onError) + +
    +
    +

    +Load a bundle file. +The expected file format is as follows: + + +{ + "defaultLocale" : "en-US", + "en-US" : { + "key1", "value1", + "key2", "value2", + ... + }, + "en-UK" : { + "key1", "value1", + "key2", "value2", + ... + } +} + + +

    +defaultLocale is compulsory. + +

    +The function getString solves as follows: + +

  • a ResouceBundle object will honor browser/system locale by searching for these strings in + the navigator object to define the value of currentLocale: + +
      navigator.language +
        navigator.browserLanguage +
          navigator.systemLanguage +
            navigator.userLanguage + +
          • the ResouceBundle class will also get defaultLocale value, and set the corresponding key + as default Locale. + +
          • a call to getString(id,defaultValue) will work as follows: + +
            +  1)     will get the value associated in currentLocale[id]
            +  2)     if the value is set, it is returned.
            +  2.1)       else if it is not set, will get the value from defaultLocale[id] (sort of fallback)
            +  3)     if the value of defaultLocale is set, it is returned.
            +  3.1)       else defaultValue is returned.
            +
            + + + + + + + +
            +
            Parameters:
            + +
            + resourceFile + +
            +
            + +
            + asynch + +
            +
            + +
            + onSuccess + +
            +
            + +
            + onError + +
            +
            + +
            + + + + + +
            +
            Returns:
            + +
            {*}
            + +
            + + + + +
            + + +
            + + {string} + getString(id, defaultValue, args) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            {string} a key from the bundle file.
            + +
            + defaultValue + +
            +
            {string} default value in case
            + +
            + args + +
            +
            {Array.=} optional arguments array in case the returned string is a + parameterized string.
            + +
            + + + + + +
            +
            Returns:
            + +
            {string}
            + +
            + + + + +
            + + +
            + + + loadDoc(resourceFile, asynch, onSuccess, onError) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + resourceFile + +
            +
            + +
            + asynch + +
            +
            + +
            + onSuccess + +
            +
            + +
            + onError + +
            +
            + +
            + + + + + + + + + + + + + + + +
            + + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.html new file mode 100644 index 0000000..9e7cf55 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Locale.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Locale + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Locale +

            + + +

            + + + + + + +
            Defined in: ResourceBundle.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Locale +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.ImagePreloader.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.ImagePreloader.html new file mode 100644 index 0000000..355069c --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.ImagePreloader.html @@ -0,0 +1,777 @@ + + + + + + + JsDoc Reference - CAAT.Module.Preloader.ImagePreloader + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Preloader.ImagePreloader +

            + + +

            + + + + + + +
            Defined in: ImagePreloader.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            elements counter.
            +
              +
            + images +
            +
            a list of elements to load.
            +
              + +
            notification callback invoked for each image loaded.
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            loadImages(aImages, callback_loaded_one_image, callback_error) +
            +
            Start images loading asynchronous process.
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Preloader.ImagePreloader() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + imageCounter + +
            +
            + elements counter. + + +
            + + + + + + + + +
            + + +
            + + + images + +
            +
            + a list of elements to load. + + +
            + + + + + + + + +
            + + +
            + + + notificationCallback + +
            +
            + notification callback invoked for each image loaded. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + loadImages(aImages, callback_loaded_one_image, callback_error) + +
            +
            + Start images loading asynchronous process. This method will notify every image loaded event +and is responsibility of the caller to count the number of loaded images to see if it fits his +needs. + + +
            + + + + +
            +
            Parameters:
            + +
            + aImages + +
            +
            {{ id:{url}, id2:{url}, ...} an object with id/url pairs.
            + +
            + callback_loaded_one_image + +
            +
            {function( imageloader {CAAT.ImagePreloader}, counter {number}, images {{ id:{string}, image: {Image}}} )} +function to call on every image load.
            + +
            + callback_error + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.Preloader.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.Preloader.html new file mode 100644 index 0000000..57c00fe --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.Preloader.html @@ -0,0 +1,1090 @@ + + + + + + + JsDoc Reference - CAAT.Module.Preloader.Preloader + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Preloader.Preloader +

            + + +

            + + + + + + +
            Defined in: Preloader.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + cerrored +
            +
            Callback error loading.
            +
              +
            + cfinished +
            +
            Callback finished loading.
            +
              +
            + cloaded +
            +
            Callback element loaded.
            +
              +
            + elements +
            +
            a list of elements to load.
            +
              + +
            elements counter.
            +
              + +
            loaded elements count.
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
            <private>   +
            __onerror(d) +
            +
            +
            <private>   +
            __onload(d) +
            +
            +
              +
            addElement(id, path) +
            +
            +
              +
            clear() +
            +
            +
              +
            load(onfinished, onload_one, onerror) +
            +
            +
              +
            setBaseURL(base) +
            +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Preloader.Preloader() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + cerrored + +
            +
            + Callback error loading. + + +
            + + + + + + + + +
            + + +
            + + + cfinished + +
            +
            + Callback finished loading. + + +
            + + + + + + + + +
            + + +
            + + + cloaded + +
            +
            + Callback element loaded. + + +
            + + + + + + + + +
            + + +
            + + + elements + +
            +
            + a list of elements to load. + + +
            + + + + + + + + +
            + + +
            + + + imageCounter + +
            +
            + elements counter. + + +
            + + + + + + + + +
            + + +
            + + + loadedCount + +
            +
            + loaded elements count. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            <private> + + + __onerror(d) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + d + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __onload(d) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + d + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addElement(id, path) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            + +
            + path + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + clear() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + load(onfinished, onload_one, onerror) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + onfinished + +
            +
            + +
            + onload_one + +
            +
            + +
            + onerror + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setBaseURL(base) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + base + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.html new file mode 100644 index 0000000..318f650 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Preloader.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Preloader + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Preloader +

            + + +

            + + + + + + +
            Defined in: ImagePreloader.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Preloader +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.BrowserInfo.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.BrowserInfo.html new file mode 100644 index 0000000..9304156 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.BrowserInfo.html @@ -0,0 +1,654 @@ + + + + + + + JsDoc Reference - CAAT.Module.Runtime.BrowserInfo + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Runtime.BrowserInfo +

            + + +

            + + + + + + +
            Defined in: BrowserInfo.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <inner>   +
            searchString(data) +
            +
            +
            <inner>   +
            searchVersion(dataString) +
            +
            +
            + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Runtime.BrowserInfo +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + +
            + Method Detail +
            + + +
            <inner> + + + searchString(data) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + data + +
            +
            + +
            + + + + + + + + +
            + + +
            <inner> + + + searchVersion(dataString) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + dataString + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.html new file mode 100644 index 0000000..f3788e5 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Runtime.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Module.Runtime + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Runtime +

            + + +

            + + + + + + +
            Defined in: BrowserInfo.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Runtime +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton#SkeletonActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton#SkeletonActor.html new file mode 100644 index 0000000..9162c6b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton#SkeletonActor.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Skeleton#SkeletonActor + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Skeleton#SkeletonActor +

            + + +

            + + + + + + +
            Defined in: SkeletonActor.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Skeleton#SkeletonActor() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Bone.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Bone.html new file mode 100644 index 0000000..1a9a214 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Bone.html @@ -0,0 +1,2217 @@ + + + + + + + JsDoc Reference - CAAT.Module.Skeleton.Bone + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Skeleton.Bone +

            + + +

            + + + + + + +
            Defined in: Bone.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + children +
            +
            +
              + +
            +
              + +
            +
              + +
            +
              + +
            +
              + +
            +
              +
            + matrix +
            +
            +
              +
            + parent +
            +
            +
              + +
            Bone rotation angle
            +
              +
            + size +
            +
            Bone size.
            +
              +
            + wmatrix +
            +
            +
              +
            + x +
            +
            Bone x position relative parent
            +
              +
            + y +
            +
            Bone y position relative parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   + +
            +
            <private>   + +
            +
            <private>   +
            __init(id) +
            +
            +
            <private>   +
            __noValue(keyframes) +
            +
            +
            <private>   +
            __setInterpolator(behavior, curve) +
            +
            +
            <private>   + +
            +
            <private>   +
            __setParent(parent) +
            +
            +
              +
            addBone(bone) +
            +
            +
              +
            addRotationKeyframe(name, angleStart, angleEnd, timeStart, timeEnd, curve) +
            +
            +
              +
            addScaleKeyframe(name, scaleX, endScaleX, scaleY, endScaleY, timeStart, timeEnd, curve) +
            +
            +
              +
            addTranslationKeyframe(name, startX, startY, endX, endY, timeStart, timeEnd, curve) +
            +
            +
              +
            apply(time, animationTime) +
            +
            +
              + +
            +
              + +
            +
              + +
            +
              +
            paint(actorMatrix, ctx) +
            +
            +
              +
            setAnimation(name) +
            +
            +
              + +
            +
              +
            setPosition(x, y) +
            +
            +
              +
            setRotateTransform(angle, anchorX, anchorY) +
            +
            default anchor values are for spine tool.
            +
              +
            setScaleTransform(sx, sy, anchorX, anchorY) +
            +
            +
              +
            setSize(s) +
            +
            +
              + +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Skeleton.Bone() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + {Array.} + children + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {object} + keyframesByAnimation + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Behavior.ContainerBehavior} + keyframesRotate + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Behavior.ContainerBehavior} + keyframesScale + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Behavior.ContainerBehavior} + keyframesTranslate + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.PathUtil.Path} + keyframesTranslatePath + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Math.Matrix} + matrix + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Skeleton.Bone} + parent + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + rotationAngle + +
            +
            + Bone rotation angle + + +
            + + + + + + + + +
            + + +
            + + {number} + size + +
            +
            + Bone size. + + +
            + + + + + + + + +
            + + +
            + + {CAAT.Math.Matrix} + wmatrix + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + {number} + x + +
            +
            + Bone x position relative parent + + +
            + + + + + + + + +
            + + +
            + + + y + +
            +
            + Bone y position relative parent + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __createAnimation(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __getAnimation(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __init(id) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __noValue(keyframes) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + keyframes + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __setInterpolator(behavior, curve) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + behavior + +
            +
            + +
            + curve + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __setModelViewMatrix() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            <private> + + {*} + __setParent(parent) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + parent + +
            +
            {CAAT.Skeleton.Bone}
            + +
            + + + + + +
            +
            Returns:
            + +
            {*}
            + +
            + + + + +
            + + +
            + + + addBone(bone) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + bone + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addRotationKeyframe(name, angleStart, angleEnd, timeStart, timeEnd, curve) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            {string} keyframe animation name
            + +
            + angleStart + +
            +
            {number} rotation start angle
            + +
            + angleEnd + +
            +
            {number} rotation end angle
            + +
            + timeStart + +
            +
            {number} keyframe start time
            + +
            + timeEnd + +
            +
            {number} keyframe end time
            + +
            + curve + +
            +
            {Array.=} 4 numbers definint a quadric bezier info. two first points + assumed to be 0,0.
            + +
            + + + + + + + + +
            + + +
            + + + addScaleKeyframe(name, scaleX, endScaleX, scaleY, endScaleY, timeStart, timeEnd, curve) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + scaleX + +
            +
            + +
            + endScaleX + +
            +
            + +
            + scaleY + +
            +
            + +
            + endScaleY + +
            +
            + +
            + timeStart + +
            +
            + +
            + timeEnd + +
            +
            + +
            + curve + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addTranslationKeyframe(name, startX, startY, endX, endY, timeStart, timeEnd, curve) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + startX + +
            +
            + +
            + startY + +
            +
            + +
            + endX + +
            +
            + +
            + endY + +
            +
            + +
            + timeStart + +
            +
            + +
            + timeEnd + +
            +
            + +
            + curve + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + apply(time, animationTime) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            {number}
            + +
            + animationTime + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endRotationKeyframes(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endScaleKeyframes(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endTranslationKeyframes(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + paint(actorMatrix, ctx) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + actorMatrix + +
            +
            + +
            + ctx + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setAnimation(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setBehaviorApplicationTime(t) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + t + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPosition(x, y) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {*} + setRotateTransform(angle, anchorX, anchorY) + +
            +
            + default anchor values are for spine tool. + + +
            + + + + +
            +
            Parameters:
            + +
            + angle + +
            +
            {number}
            + +
            + anchorX + +
            +
            {number=}
            + +
            + anchorY + +
            +
            {number=}
            + +
            + + + + + +
            +
            Returns:
            + +
            {*}
            + +
            + + + + +
            + + +
            + + {*} + setScaleTransform(sx, sy, anchorX, anchorY) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + sx + +
            +
            {number}
            + +
            + sy + +
            +
            {number}
            + +
            + anchorX + +
            +
            {number=} anchorX: .5 by default
            + +
            + anchorY + +
            +
            {number=} anchorY. .5 by default
            + +
            + + + + + +
            +
            Returns:
            + +
            {*}
            + +
            + + + + +
            + + +
            + + + setSize(s) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + s + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + transformContext(ctx) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ctx + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.BoneActor.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.BoneActor.html new file mode 100644 index 0000000..30e535e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.BoneActor.html @@ -0,0 +1,1286 @@ + + + + + + + JsDoc Reference - CAAT.Module.Skeleton.BoneActor + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Skeleton.BoneActor +

            + + +

            + + + + + + +
            Defined in: BoneActor.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   + +
            +
            <private>   +
            __init() +
            +
            +
            <private>   + +
            +
              +
            addAttachment(id, normalized_x, normalized_y, callback) +
            +
            +
              + +
            +
              +
            addSkinDataKeyframe(name, start, duration) +
            +
            +
              + +
            +
              + +
            +
              + +
            +
              +
            paint(ctx, time) +
            +
            +
              +
            prepareAABB(time) +
            +
            +
              +
            setBone(bone) +
            +
            +
              + +
            +
              + +
            +
              + +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Skeleton.BoneActor() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + attachments + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __getCurrentSkinInfo(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            <private> + + + __setupAttachments() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + addAttachment(id, normalized_x, normalized_y, callback) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            + +
            + normalized_x + +
            +
            + +
            + normalized_y + +
            +
            + +
            + callback + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addAttachmentListener(al) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + al + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addSkinDataKeyframe(name, start, duration) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + start + +
            +
            + +
            + duration + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addSkinInfo(si) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + si + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + emptySkinDataKeyframe() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getAttachment(id) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + paint(ctx, time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ctx + +
            +
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + prepareAABB(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setBone(bone) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + bone + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setDefaultSkinInfoByName(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setModelViewMatrix() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + setupAnimation(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Skeleton.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Skeleton.html new file mode 100644 index 0000000..26ff3c7 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.Skeleton.html @@ -0,0 +1,1468 @@ + + + + + + + JsDoc Reference - CAAT.Module.Skeleton.Skeleton + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.Skeleton.Skeleton +

            + + +

            + + + + + + +
            Defined in: Skeleton.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(skeletonDataFromFile) +
            +
            +
            <private>   +
            __setSkeleton(skeletonDataFromFile) +
            +
            +
              +
            addAnimation(name, animation) +
            +
            +
              +
            addAnimationFromFile(name, url) +
            +
            +
              +
            addBone(boneInfo) +
            +
            +
              +
            addRotationKeyframe(name, keyframeInfo) +
            +
            +
              +
            addScaleKeyframe(name, keyframeInfo) +
            +
            +
              +
            addTranslationKeyframe(name, keyframeInfo) +
            +
            +
              +
            calculate(time, animationTime) +
            +
            +
              +
            endKeyframes(name, boneId) +
            +
            +
              + +
            +
              + +
            +
              +
            getBoneByIndex(index) +
            +
            +
              + +
            +
              + +
            +
              +
            getRoot() +
            +
            +
              + +
            +
              +
            paint(actorMatrix, ctx) +
            +
            +
              +
            setAnimation(name) +
            +
            +
              + +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.Skeleton.Skeleton() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(skeletonDataFromFile) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + skeletonDataFromFile + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __setSkeleton(skeletonDataFromFile) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + skeletonDataFromFile + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addAnimation(name, animation) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + animation + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addAnimationFromFile(name, url) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + url + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addBone(boneInfo) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + boneInfo + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addRotationKeyframe(name, keyframeInfo) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + keyframeInfo + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addScaleKeyframe(name, keyframeInfo) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + keyframeInfo + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addTranslationKeyframe(name, keyframeInfo) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + keyframeInfo + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + calculate(time, animationTime) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + animationTime + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endKeyframes(name, boneId) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + boneId + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getAnimationDataByName(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getBoneById(id) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getBoneByIndex(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getCurrentAnimationData() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getNumBones() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getRoot() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getSkeletonDataFromFile() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + paint(actorMatrix, ctx) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + actorMatrix + +
            +
            + +
            + ctx + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setAnimation(name) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + name + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setSkeletonFromFile(url) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + url + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.html new file mode 100644 index 0000000..f5b82ee --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Skeleton.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.Skeleton + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Skeleton +

            + + +

            + + + + + + +
            Defined in: Bone.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Skeleton +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.LocalStorage.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.LocalStorage.html new file mode 100644 index 0000000..80d8847 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.LocalStorage.html @@ -0,0 +1,732 @@ + + + + + + + JsDoc Reference - CAAT.Module.Storage.LocalStorage + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Storage.LocalStorage +

            + + +

            + + + + + + +
            Defined in: LocalStorage.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <static>   +
            CAAT.Module.Storage.LocalStorage.load(key, defValue) +
            +
            Retrieve a value from local storage.
            +
            <static>   +
            CAAT.Module.Storage.LocalStorage.remove(key) +
            +
            Removes a value stored in local storage.
            +
            <static>   +
            CAAT.Module.Storage.LocalStorage.save(key, data) +
            +
            Stores an object in local storage.
            +
            + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Storage.LocalStorage +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + +
            + Method Detail +
            + + +
            <static> + + {object} + CAAT.Module.Storage.LocalStorage.load(key, defValue) + +
            +
            + Retrieve a value from local storage. + + +
            + + + + +
            +
            Parameters:
            + +
            + key + +
            +
            {string} the key to retrieve.
            + +
            + defValue + +
            +
            + +
            + + + + + +
            +
            Returns:
            + +
            {object} object stored under the key parameter.
            + +
            + + + + +
            + + +
            <static> + + + CAAT.Module.Storage.LocalStorage.remove(key) + +
            +
            + Removes a value stored in local storage. + + +
            + + + + +
            +
            Parameters:
            + +
            + key + +
            +
            {string}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            <static> + + + CAAT.Module.Storage.LocalStorage.save(key, data) + +
            +
            + Stores an object in local storage. The data will be saved as JSON.stringify. + + +
            + + + + +
            +
            Parameters:
            + +
            + key + +
            +
            {string} key to store data under.
            + +
            + data + +
            +
            {object} an object.
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.html new file mode 100644 index 0000000..0bc6cbf --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.Storage.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.Module.Storage + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.Storage +

            + + +

            + + + + + + +
            Defined in: LocalStorage.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.Storage +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureElement.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureElement.html new file mode 100644 index 0000000..6cd3b08 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureElement.html @@ -0,0 +1,724 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker.TextureElement + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.TexturePacker.TextureElement +

            + + +

            + + + + + + +
            Defined in: TextureElement.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + glTexture +
            +
            +
              +
            + image +
            +
            +
              +
            + inverted +
            +
            +
              +
            + u +
            +
            +
              +
            + v +
            +
            +
            + + + + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.TexturePacker.TextureElement() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + glTexture + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + image + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + inverted + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + u + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + v + +
            +
            + + + +
            + + + + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePage.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePage.html new file mode 100644 index 0000000..8b1df16 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePage.html @@ -0,0 +1,1424 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker.TexturePage + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.TexturePacker.TexturePage +

            + + +

            + + + + + + +
            Defined in: TexturePage.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            +
              +
            + criteria +
            +
            +
              +
            + gl +
            +
            +
              +
            + height +
            +
            +
              +
            + images +
            +
            +
              +
            + padding +
            +
            +
              +
            + scan +
            +
            +
              +
            + texture +
            +
            +
              +
            + width +
            +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(w, h) +
            +
            +
              +
            addImage(image, invert, padding) +
            +
            +
              +
            changeHeuristic(criteria) +
            +
            +
              +
            clear() +
            +
            +
              +
            create(imagesCache) +
            +
            +
              +
            createFromImages(images) +
            +
            +
              + +
            +
              + +
            +
              +
            initialize(gl) +
            +
            +
              +
            packImage(img) +
            +
            +
              +
            toCanvas(canvass, outline) +
            +
            +
              +
            update(invert, padding, width, height) +
            +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.TexturePacker.TexturePage() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + allowImagesInvertion + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + criteria + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + gl + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + height + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + images + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + padding + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + scan + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + texture + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + width + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(w, h) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + w + +
            +
            + +
            + h + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addImage(image, invert, padding) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + image + +
            +
            + +
            + invert + +
            +
            + +
            + padding + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + changeHeuristic(criteria) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + criteria + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + clear() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + create(imagesCache) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + imagesCache + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + createFromImages(images) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + images + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + deletePage() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + endCreation() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + initialize(gl) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + packImage(img) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + img + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + toCanvas(canvass, outline) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + canvass + +
            +
            + +
            + outline + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + update(invert, padding, width, height) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + invert + +
            +
            + +
            + padding + +
            +
            + +
            + width + +
            +
            + +
            + height + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePageManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePageManager.html new file mode 100644 index 0000000..9a039ac --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TexturePageManager.html @@ -0,0 +1,750 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker.TexturePageManager + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.TexturePacker.TexturePageManager +

            + + +

            + + + + + + +
            Defined in: TexturePageManager.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + pages +
            +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            createPages(gl, width, height, imagesCache) +
            +
            +
              + +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.TexturePacker.TexturePageManager() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + pages + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + createPages(gl, width, height, imagesCache) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + width + +
            +
            + +
            + height + +
            +
            + +
            + imagesCache + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + deletePages() + +
            +
            + + + +
            + + + + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScan.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScan.html new file mode 100644 index 0000000..65d3891 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScan.html @@ -0,0 +1,856 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker.TextureScan + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.TexturePacker.TextureScan +

            + + +

            + + + + + + +
            Defined in: TextureScan.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(w) +
            +
            +
              +
            findWhereFits(width) +
            +
            return an array of values where a chunk of width size fits in this scan.
            +
              +
            fits(position, size) +
            +
            +
              +
            log(index) +
            +
            +
              +
            substract(position, size) +
            +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.TexturePacker.TextureScan() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + freeChunks + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(w) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + w + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + findWhereFits(width) + +
            +
            + return an array of values where a chunk of width size fits in this scan. + + +
            + + + + +
            +
            Parameters:
            + +
            + width + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + fits(position, size) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + position + +
            +
            + +
            + size + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + log(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + substract(position, size) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + position + +
            +
            + +
            + size + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScanMap.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScanMap.html new file mode 100644 index 0000000..7db2606 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.TextureScanMap.html @@ -0,0 +1,882 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker.TextureScanMap + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.Module.TexturePacker.TextureScanMap +

            + + +

            + + + + + + +
            Defined in: TextureScanMap.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + scanMap +
            +
            +
              + +
            +
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(w, h) +
            +
            +
              +
            log() +
            +
            +
              +
            substract(x, y, width, height) +
            +
            +
              +
            whereFitsChunk(width, height) +
            +
            Always try to fit a chunk of size width*height pixels from left-top.
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.Module.TexturePacker.TextureScanMap() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + scanMap + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + scanMapHeight + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + scanMapWidth + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(w, h) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + w + +
            +
            + +
            + h + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + log() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + substract(x, y, width, height) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + width + +
            +
            + +
            + height + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + whereFitsChunk(width, height) + +
            +
            + Always try to fit a chunk of size width*height pixels from left-top. + + +
            + + + + +
            +
            Parameters:
            + +
            + width + +
            +
            + +
            + height + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.html b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.html new file mode 100644 index 0000000..3ad9a00 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.Module.TexturePacker.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.Module.TexturePacker + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.Module.TexturePacker +

            + + +

            + + + + + + +
            Defined in: TextureElement.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.Module.TexturePacker +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.ModuleManager.html b/CAAT/documentation/jsdoc/symbols/CAAT.ModuleManager.html new file mode 100644 index 0000000..33abe32 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.ModuleManager.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.ModuleManager + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.ModuleManager +

            + + +

            + + + + + + +
            Defined in: ModuleManager.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.ModuleManager +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.ArcPath.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.ArcPath.html new file mode 100644 index 0000000..17d504e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.ArcPath.html @@ -0,0 +1,1834 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.ArcPath + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.ArcPath +

            + + +

            + +
            Extends + CAAT.PathUtil.PathSegment.
            + + + + + +
            Defined in: ArcPath.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + angle +
            +
            Arc end angle.
            +
              +
            + arcTo +
            +
            is a relative or absolute arc ?
            +
              +
            + cw +
            +
            Defined clockwise or counterclockwise ?
            +
              + +
            spare point for calculations
            +
              +
            + points +
            +
            A collection of CAAT.Math.Point objects which defines the arc (center, start, end)
            +
              +
            + radius +
            +
            Arc radius.
            +
              + +
            Arc start angle.
            +
            + + + +
            +
            Fields borrowed from class CAAT.PathUtil.PathSegment:
            bbox, color, length, parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            applyAsPath(director) +
            +
            +
              + +
            An arc starts and ends in the same point.
            +
              + +
            Returns final path segment point's x coordinate.
            +
              +
            getContour(iSize) +
            +
            +
              +
            getControlPoint(index) +
            +
            +
              +
            getPosition(time) +
            +
            +
              + +
            +
              +
            initialize(x, y, r, angle) +
            +
            +
              + +
            Returns initial path segment point's x coordinate.
            +
              +
            isArcTo() +
            +
            +
              + +
            +
              + +
            Get the number of control points.
            +
              +
            paint(director, bDrawHandles) +
            +
            Draws this path segment on screen.
            +
              +
            setArcTo(b) +
            +
            +
              + +
            +
              +
            setFinalPosition(finalX, finalY) +
            +
            Set a rectangle from points[0] to (finalX, finalY)
            +
              + +
            Set this path segment's starting position.
            +
              +
            setPoint(point, index) +
            +
            +
              +
            setPoints(points) +
            +
            An array of {CAAT.Point} composed of two points.
            +
              +
            setRadius(r) +
            +
            +
              + +
            +
              +
            updatePath(point) +
            +
            +
            + + + +
            +
            Methods borrowed from class CAAT.PathUtil.PathSegment:
            drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.ArcPath() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + angle + +
            +
            + Arc end angle. + + +
            + + + + + + + + +
            + + +
            + + + arcTo + +
            +
            + is a relative or absolute arc ? + + +
            + + + + + + + + +
            + + +
            + + + cw + +
            +
            + Defined clockwise or counterclockwise ? + + +
            + + + + + + + + +
            + + +
            + + + newPosition + +
            +
            + spare point for calculations + + +
            + + + + + + + + +
            + + +
            + + + points + +
            +
            + A collection of CAAT.Math.Point objects which defines the arc (center, start, end) + + +
            + + + + + + + + +
            + + +
            + + + radius + +
            +
            + Arc radius. + + +
            + + + + + + + + +
            + + +
            + + + startAngle + +
            +
            + Arc start angle. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + applyAsPath(director) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endCurvePosition() + +
            +
            + An arc starts and ends in the same point. + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + finalPositionX() + +
            +
            + Returns final path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + getContour(iSize) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + iSize + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getControlPoint(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPosition(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPositionFromLength(iLength) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + iLength + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + initialize(x, y, r, angle) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + r + +
            +
            + +
            + angle + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {number} + initialPositionX() + +
            +
            + Returns initial path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + isArcTo() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + isClockWise() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + numControlPoints() + +
            +
            + Get the number of control points. For this type of path segment, start and +ending path segment points. Defaults to 2. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + paint(director, bDrawHandles) + +
            +
            + Draws this path segment on screen. Optionally it can draw handles for every control point, in +this case, start and ending path segment points. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            {CAAT.Director}
            + +
            + bDrawHandles + +
            +
            {boolean}
            + +
            + + + + + + + + +
            + + +
            + + + setArcTo(b) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + b + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setClockWise(cw) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + cw + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setFinalPosition(finalX, finalY) + +
            +
            + Set a rectangle from points[0] to (finalX, finalY) + + +
            + + + + +
            +
            Parameters:
            + +
            + finalX + +
            +
            {number}
            + +
            + finalY + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setInitialPosition(x, y) + +
            +
            + Set this path segment's starting position. +This method should not be called again after setFinalPosition has been called. + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            {number}
            + +
            + y + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + An array of {CAAT.Point} composed of two points. + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            {Array}
            + +
            + + + + + + + + +
            + + +
            + + + setRadius(r) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + r + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + startCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + updatePath(point) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.CurvePath.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.CurvePath.html new file mode 100644 index 0000000..8f96746 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.CurvePath.html @@ -0,0 +1,1482 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.CurvePath + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.CurvePath +

            + + +

            + +
            Extends + CAAT.PathUtil.PathSegment.
            + + + + + +
            Defined in: CurvePath.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + curve +
            +
            A CAAT.Math.Curve instance.
            +
              + +
            spare holder for getPosition coordinate return.
            +
            + + + +
            +
            Fields borrowed from class CAAT.PathUtil.PathSegment:
            bbox, color, length, parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            applyAsPath(director) +
            +
            +
              + +
            +
              + +
            Get path segment's last point's y coordinate.
            +
              +
            getContour(iSize) +
            +
            +
              +
            getControlPoint(index) +
            +
            +
              +
            getPosition(time) +
            +
            +
              + +
            Gets the coordinate on the path relative to the path length.
            +
              + +
            Get path segment's first point's x coordinate.
            +
              + +
            +
              +
            paint(director, bDrawHandles) +
            +
            +
              +
            setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) +
            +
            Set the pathSegment as a CAAT.Bezier cubic instance.
            +
              +
            setPoint(point, index) +
            +
            +
              +
            setPoints(points) +
            +
            Set this curve segment's points.
            +
              +
            setQuadric(p0x, p0y, p1x, p1y, p2x, p2y) +
            +
            Set the pathSegment as a CAAT.Bezier quadric instance.
            +
              + +
            +
              +
            updatePath(point) +
            +
            +
            + + + +
            +
            Methods borrowed from class CAAT.PathUtil.PathSegment:
            drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.CurvePath() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + curve + +
            +
            + A CAAT.Math.Curve instance. + + +
            + + + + + + + + +
            + + +
            + + + newPosition + +
            +
            + spare holder for getPosition coordinate return. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + applyAsPath(director) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + finalPositionX() + +
            +
            + Get path segment's last point's y coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + getContour(iSize) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + iSize + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getControlPoint(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPosition(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {CAAT.Point} + getPositionFromLength(iLength) + +
            +
            + Gets the coordinate on the path relative to the path length. + + +
            + + + + +
            +
            Parameters:
            + +
            + iLength + +
            +
            {number} the length at which the coordinate will be taken from.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Point} a CAAT.Point instance with the coordinate on the path corresponding to the +iLenght parameter relative to segment's length.
            + +
            + + + + +
            + + +
            + + {number} + initialPositionX() + +
            +
            + Get path segment's first point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + numControlPoints() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + paint(director, bDrawHandles) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            {CAAT.Director}
            + +
            + bDrawHandles + +
            +
            {boolean}
            + +
            + + + + + + + + +
            + + +
            + + + setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) + +
            +
            + Set the pathSegment as a CAAT.Bezier cubic instance. +Parameters are cubic coordinates control points. + + +
            + + + + +
            +
            Parameters:
            + +
            + p0x + +
            +
            {number}
            + +
            + p0y + +
            +
            {number}
            + +
            + p1x + +
            +
            {number}
            + +
            + p1y + +
            +
            {number}
            + +
            + p2x + +
            +
            {number}
            + +
            + p2y + +
            +
            {number}
            + +
            + p3x + +
            +
            {number}
            + +
            + p3y + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + Set this curve segment's points. + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            {Array}
            + +
            + + + + + + + + +
            + + +
            + + + setQuadric(p0x, p0y, p1x, p1y, p2x, p2y) + +
            +
            + Set the pathSegment as a CAAT.Bezier quadric instance. +Parameters are quadric coordinates control points. + + +
            + + + + +
            +
            Parameters:
            + +
            + p0x + +
            +
            {number}
            + +
            + p0y + +
            +
            {number}
            + +
            + p1x + +
            +
            {number}
            + +
            + p1y + +
            +
            {number}
            + +
            + p2x + +
            +
            {number}
            + +
            + p2y + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + startCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + updatePath(point) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.LinearPath.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.LinearPath.html new file mode 100644 index 0000000..0d363d9 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.LinearPath.html @@ -0,0 +1,1407 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.LinearPath + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.LinearPath +

            + + +

            + +
            Extends + CAAT.PathUtil.PathSegment.
            + + + + + +
            Defined in: LinearPath.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            spare holder for getPosition coordinate return.
            +
              +
            + points +
            +
            A collection of points.
            +
            + + + +
            +
            Fields borrowed from class CAAT.PathUtil.PathSegment:
            bbox, color, length, parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            applyAsPath(director) +
            +
            +
              + +
            +
              + +
            Returns final path segment point's x coordinate.
            +
              +
            getContour(iSize) +
            +
            +
              +
            getControlPoint(index) +
            +
            +
              +
            getPosition(time) +
            +
            +
              + +
            +
              + +
            Returns initial path segment point's x coordinate.
            +
              + +
            Get the number of control points.
            +
              +
            paint(director, bDrawHandles) +
            +
            Draws this path segment on screen.
            +
              +
            setFinalPosition(finalX, finalY) +
            +
            Set this path segment's ending position.
            +
              + +
            Set this path segment's starting position.
            +
              +
            setPoint(point, index) +
            +
            +
              +
            setPoints(points) +
            +
            +
              + +
            +
              +
            updatePath(point) +
            +
            Update this segments length and bounding box info.
            +
            + + + +
            +
            Methods borrowed from class CAAT.PathUtil.PathSegment:
            drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.LinearPath() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + newPosition + +
            +
            + spare holder for getPosition coordinate return. + + +
            + + + + + + + + +
            + + +
            + + + points + +
            +
            + A collection of points. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + applyAsPath(director) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + finalPositionX() + +
            +
            + Returns final path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + getContour(iSize) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + iSize + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getControlPoint(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPosition(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPositionFromLength(len) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + len + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {number} + initialPositionX() + +
            +
            + Returns initial path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + {number} + numControlPoints() + +
            +
            + Get the number of control points. For this type of path segment, start and +ending path segment points. Defaults to 2. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + paint(director, bDrawHandles) + +
            +
            + Draws this path segment on screen. Optionally it can draw handles for every control point, in +this case, start and ending path segment points. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            {CAAT.Director}
            + +
            + bDrawHandles + +
            +
            {boolean}
            + +
            + + + + + + + + +
            + + +
            + + + setFinalPosition(finalX, finalY) + +
            +
            + Set this path segment's ending position. + + +
            + + + + +
            +
            Parameters:
            + +
            + finalX + +
            +
            {number}
            + +
            + finalY + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setInitialPosition(x, y) + +
            +
            + Set this path segment's starting position. + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            {number}
            + +
            + y + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + startCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + updatePath(point) + +
            +
            + Update this segments length and bounding box info. + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.Path.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.Path.html new file mode 100644 index 0000000..8203756 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.Path.html @@ -0,0 +1,4511 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.Path + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.Path +

            + + +

            + +
            Extends + CAAT.PathUtil.PathSegment.
            + + + + + +
            Defined in: Path.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            starting path x position
            +
              + +
            starting path y position
            +
              + +
            A list of behaviors to apply to this path.
            +
              + +
            Path bounding box X position.
            +
              + +
            Path bounding box Y position.
            +
              +
            + closed +
            +
            Is this path closed ?
            +
              +
            + height +
            +
            Path bounding box height.
            +
              + +
            Is this path interactive ?.
            +
              +
            + matrix +
            +
            Path behaviors matrix.
            +
              + +
            spare CAAT.Math.Point to return calculated values in the path.
            +
              + +
            path length (sum of every segment length)
            +
              + +
            Original Path´s path segments points.
            +
              + +
            For each path segment in this path, the normalized calculated duration.
            +
              + +
            A collection of PathSegments.
            +
              + +
            For each path segment in this path, the normalized calculated start time.
            +
              +
            + rb_angle +
            +
            Path rotation angle.
            +
              + +
            Path rotation x anchor.
            +
              + +
            Path rotation x anchor.
            +
              + +
            Path scale X anchor.
            +
              + +
            Path scale Y anchor.
            +
              +
            + sb_scaleX +
            +
            Path X scale.
            +
              +
            + sb_scaleY +
            +
            Path Y scale.
            +
              +
            + tAnchorX +
            +
            Path translation anchor X.
            +
              +
            + tAnchorY +
            +
            Path translation anchor Y.
            +
              +
            + tb_x +
            +
            Path translation X.
            +
              +
            + tb_y +
            +
            Path translation Y.
            +
              +
            + tmpMatrix +
            +
            Spare calculation matrix.
            +
              +
            + width +
            +
            Path bounding box width.
            +
            + + + +
            +
            Fields borrowed from class CAAT.PathUtil.PathSegment:
            bbox, color, length, parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   + +
            +
            <private>   +
            __init() +
            +
            +
              +
            addArcTo(x1, y1, x2, y2, radius, cw, color) +
            +
            +
              +
            addBehavior(behavior) +
            +
            Add a Behavior to the Actor.
            +
              +
            addCatmullTo(px1, py1, px2, py2, px3, py3, color) +
            +
            Add a Catmull-Rom segment to this path.
            +
              +
            addCubicTo(px1, py1, px2, py2, px3, py3, color) +
            +
            Add a Cubic Bezier segment to this path.
            +
              +
            addLineTo(px1, py1, color) +
            +
            Adds a line segment to this path.
            +
              +
            addQuadricTo(px1, py1, px2, py2, color) +
            +
            Add a Quadric Bezier path segment to this path.
            +
              +
            addRectangleTo(x1, y1, cw, color) +
            +
            +
              +
            addSegment(pathSegment) +
            +
            Add a CAAT.PathSegment instance to this path.
            +
              +
            applyAsPath(director) +
            +
            Apply this path as a Canvas context path.
            +
              + +
            +
              +
            beginPath(px0, py0) +
            +
            Set the path's starting point.
            +
              + +
            Close the path by adding a line path segment from the current last path +coordinate to startCurvePosition coordinate.
            +
              +
            drag(x, y, callback) +
            +
            Drags a path's control point.
            +
              + +
            Removes all behaviors from an Actor.
            +
              + +
            Return the last point of the last path segment of this compound path.
            +
              +
            endPath() +
            +
            Finishes the process of building the path.
            +
              + +
            +
              +
            flatten(npatches, closed) +
            +
            +
              +
            getContour(iSize) +
            +
            Returns a collection of CAAT.Point objects which conform a path's contour.
            +
              +
            getControlPoint(index) +
            +
            +
              + +
            Return the last path segment added to this path.
            +
              + +
            +
              + +
            +
              + +
            Returns an integer with the number of path segments that conform this path.
            +
              +
            getPosition(time, open_contour) +
            +
            This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path.
            +
              + +
            Analogously to the method getPosition, this method returns a CAAT.Point instance with +the coordinate on the path that corresponds to the given length.
            +
              +
            getSegment(index) +
            +
            Gets a CAAT.PathSegment instance.
            +
              +
            isEmpty() +
            +
            +
              + +
            +
              +
            paint(director) +
            +
            Paints the path.
            +
              +
            press(x, y) +
            +
            Sent by a CAAT.PathActor instance object to try to drag a path's control point.
            +
              +
            release() +
            +
            Method invoked when a CAAT.PathActor stops dragging a control point.
            +
              + +
            Remove a Behavior with id param as behavior identifier from this actor.
            +
              +
            removeBehaviour(behavior) +
            +
            Remove a Behavior from the Actor.
            +
              + +
            +
              +
            setCatmullRom(points, closed) +
            +
            +
              +
            setCubic(x0, y0, x1, y1, x2, y2, x3, y3) +
            +
            Sets this path to be composed by a single Cubic Bezier path segment.
            +
              +
            setInteractive(interactive) +
            +
            Set whether this path should paint handles for every control point.
            +
              +
            setLinear(x0, y0, x1, y1) +
            +
            Set the path to be composed by a single LinearPath segment.
            +
              +
            setLocation(x, y) +
            +
            +
              +
            setPoint(point, index) +
            +
            Set a point from this path.
            +
              +
            setPoints(points) +
            +
            Reposition this path points.
            +
              +
            setPosition(x, y) +
            +
            +
              + +
            +
              +
            setPositionAnchored(x, y, ax, ay) +
            +
            +
              +
            setQuadric(x0, y0, x1, y1, x2, y2) +
            +
            Set this path to be composed by a single Quadric Bezier path segment.
            +
              +
            setRectangle(x0, y0, x1, y1) +
            +
            +
              +
            setRotation(angle) +
            +
            +
              + +
            +
              +
            setRotationAnchored(angle, rx, ry) +
            +
            +
              +
            setScale(sx, sy) +
            +
            +
              +
            setScaleAnchor(ax, ay) +
            +
            +
              +
            setScaleAnchored(scaleX, scaleY, sx, sy) +
            +
            +
              + +
            Return the first point of the first path segment of this compound path.
            +
              +
            updatePath(point, callback) +
            +
            Indicates that some path control point has changed, and that the path must recalculate +its internal data, ie: length and bbox.
            +
            + + + +
            +
            Methods borrowed from class CAAT.PathUtil.PathSegment:
            drawHandle, getBoundingBox, getLength, setColor, setParent, transform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.Path() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + beginPathX + +
            +
            + starting path x position + + +
            + + + + + + + + +
            + + +
            + + + beginPathY + +
            +
            + starting path y position + + +
            + + + + + + + + +
            + + +
            + + + behaviorList + +
            +
            + A list of behaviors to apply to this path. +A path can be affine transformed to create a different path. + + +
            + + + + + + + + +
            + + +
            + + + clipOffsetX + +
            +
            + Path bounding box X position. + + +
            + + + + + + + + +
            + + +
            + + + clipOffsetY + +
            +
            + Path bounding box Y position. + + +
            + + + + + + + + +
            + + +
            + + + closed + +
            +
            + Is this path closed ? + + +
            + + + + + + + + +
            + + +
            + + + height + +
            +
            + Path bounding box height. + + +
            + + + + + + + + +
            + + +
            + + + interactive + +
            +
            + Is this path interactive ?. If so, controls points can be moved with a CAAT.Foundation.UI.PathActor. + + +
            + + + + + + + + +
            + + +
            + + + matrix + +
            +
            + Path behaviors matrix. + + +
            + + + + + + + + +
            + + +
            + + + newPosition + +
            +
            + spare CAAT.Math.Point to return calculated values in the path. + + +
            + + + + + + + + +
            + + +
            + + + pathLength + +
            +
            + path length (sum of every segment length) + + +
            + + + + + + + + +
            + + +
            + + + pathPoints + +
            +
            + Original Path´s path segments points. + + +
            + + + + + + + + +
            + + +
            + + + pathSegmentDurationTime + +
            +
            + For each path segment in this path, the normalized calculated duration. +precomputed segment duration relative to segment legnth/path length + + +
            + + + + + + + + +
            + + +
            + + + pathSegments + +
            +
            + A collection of PathSegments. + + +
            + + + + + + + + +
            + + +
            + + + pathSegmentStartTime + +
            +
            + For each path segment in this path, the normalized calculated start time. +precomputed segment start time relative to segment legnth/path length and duration. + + +
            + + + + + + + + +
            + + +
            + + + rb_angle + +
            +
            + Path rotation angle. + + +
            + + + + + + + + +
            + + +
            + + + rb_rotateAnchorX + +
            +
            + Path rotation x anchor. + + +
            + + + + + + + + +
            + + +
            + + + rb_rotateAnchorY + +
            +
            + Path rotation x anchor. + + +
            + + + + + + + + +
            + + +
            + + + sb_scaleAnchorX + +
            +
            + Path scale X anchor. + + +
            + + + + + + + + +
            + + +
            + + + sb_scaleAnchorY + +
            +
            + Path scale Y anchor. + + +
            + + + + + + + + +
            + + +
            + + + sb_scaleX + +
            +
            + Path X scale. + + +
            + + + + + + + + +
            + + +
            + + + sb_scaleY + +
            +
            + Path Y scale. + + +
            + + + + + + + + +
            + + +
            + + + tAnchorX + +
            +
            + Path translation anchor X. + + +
            + + + + + + + + +
            + + +
            + + + tAnchorY + +
            +
            + Path translation anchor Y. + + +
            + + + + + + + + +
            + + +
            + + + tb_x + +
            +
            + Path translation X. + + +
            + + + + + + + + +
            + + +
            + + + tb_y + +
            +
            + Path translation Y. + + +
            + + + + + + + + +
            + + +
            + + + tmpMatrix + +
            +
            + Spare calculation matrix. + + +
            + + + + + + + + +
            + + +
            + + + width + +
            +
            + Path bounding box width. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __getPositionImpl(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + addArcTo(x1, y1, x2, y2, radius, cw, color) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x1 + +
            +
            + +
            + y1 + +
            +
            + +
            + x2 + +
            +
            + +
            + y2 + +
            +
            + +
            + radius + +
            +
            + +
            + cw + +
            +
            + +
            + color + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addBehavior(behavior) + +
            +
            + Add a Behavior to the Actor. +An Actor accepts an undefined number of Behaviors. + + +
            + + + + +
            +
            Parameters:
            + +
            + behavior + +
            +
            {CAAT.Behavior} a CAAT.Behavior instance
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + addCatmullTo(px1, py1, px2, py2, px3, py3, color) + +
            +
            + Add a Catmull-Rom segment to this path. +The segment starts in the current last path coordinate. + + +
            + + + + +
            +
            Parameters:
            + +
            + px1 + +
            +
            {number}
            + +
            + py1 + +
            +
            {number}
            + +
            + px2 + +
            +
            {number}
            + +
            + py2 + +
            +
            {number}
            + +
            + px3 + +
            +
            {number}
            + +
            + py3 + +
            +
            {number}
            + +
            + color + +
            +
            {color=}. optional parameter. determines the color to draw the segment with (if + being drawn by a CAAT.PathActor).
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + addCubicTo(px1, py1, px2, py2, px3, py3, color) + +
            +
            + Add a Cubic Bezier segment to this path. +The segment starts in the current last path coordinate. + + +
            + + + + +
            +
            Parameters:
            + +
            + px1 + +
            +
            {number}
            + +
            + py1 + +
            +
            {number}
            + +
            + px2 + +
            +
            {number}
            + +
            + py2 + +
            +
            {number}
            + +
            + px3 + +
            +
            {number}
            + +
            + py3 + +
            +
            {number}
            + +
            + color + +
            +
            {color=}. optional parameter. determines the color to draw the segment with (if + being drawn by a CAAT.PathActor).
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + addLineTo(px1, py1, color) + +
            +
            + Adds a line segment to this path. +The segment starts in the current last path coordinate. + + +
            + + + + +
            +
            Parameters:
            + +
            + px1 + +
            +
            {number}
            + +
            + py1 + +
            +
            {number}
            + +
            + color + +
            +
            {color=}. optional parameter. determines the color to draw the segment with (if + being drawn by a CAAT.PathActor).
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + addQuadricTo(px1, py1, px2, py2, color) + +
            +
            + Add a Quadric Bezier path segment to this path. +The segment starts in the current last path coordinate. + + +
            + + + + +
            +
            Parameters:
            + +
            + px1 + +
            +
            {number}
            + +
            + py1 + +
            +
            {number}
            + +
            + px2 + +
            +
            {number}
            + +
            + py2 + +
            +
            {number}
            + +
            + color + +
            +
            {color=}. optional parameter. determines the color to draw the segment with (if + being drawn by a CAAT.PathActor).
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + addRectangleTo(x1, y1, cw, color) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x1 + +
            +
            + +
            + y1 + +
            +
            + +
            + cw + +
            +
            + +
            + color + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + addSegment(pathSegment) + +
            +
            + Add a CAAT.PathSegment instance to this path. + + +
            + + + + +
            +
            Parameters:
            + +
            + pathSegment + +
            +
            {CAAT.PathSegment}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + {*} + applyAsPath(director) + +
            +
            + Apply this path as a Canvas context path. +You must explicitly call context.beginPath + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + +
            +
            Returns:
            + +
            {*}
            + +
            + + + + +
            + + +
            + + + applyBehaviors(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + beginPath(px0, py0) + +
            +
            + Set the path's starting point. The method startCurvePosition will return this coordinate. +

            +If a call to any method of the form addTo is called before this calling +this method, they will assume to start at -1,-1 and probably you'll get the wrong path. + + +

            + + + + +
            +
            Parameters:
            + +
            + px0 + +
            +
            {number}
            + +
            + py0 + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + closePath() + +
            +
            + Close the path by adding a line path segment from the current last path +coordinate to startCurvePosition coordinate. +

            +This method closes a path by setting its last path segment's last control point +to be the first path segment's first control point. +

            + This method also sets the path as finished, and calculates all path's information + such as length and bounding box. + + +

            + + + + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + drag(x, y, callback) + +
            +
            + Drags a path's control point. +If the method press has not set needed internal data to drag a control point, this +method will do nothing, regardless the user is dragging on the CAAT.PathActor delegate. + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            {number}
            + +
            + y + +
            +
            {number}
            + +
            + callback + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + emptyBehaviorList() + +
            +
            + Removes all behaviors from an Actor. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + {CAAT.Point} + endCurvePosition() + +
            +
            + Return the last point of the last path segment of this compound path. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + + endPath() + +
            +
            + Finishes the process of building the path. It involves calculating each path segments length +and proportional length related to a normalized path length of 1. +It also sets current paths length. +These calculi are needed to traverse the path appropriately. +

            +This method must be called explicitly, except when closing a path (that is, calling the +method closePath) which calls this method as well. + + +

            + + + + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + extractPathPoints() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + flatten(npatches, closed) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + npatches + +
            +
            + +
            + closed + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {[CAAT.Point]} + getContour(iSize) + +
            +
            + Returns a collection of CAAT.Point objects which conform a path's contour. + + +
            + + + + +
            +
            Parameters:
            + +
            + iSize + +
            +
            {number}. Number of samples for each path segment.
            + +
            + + + + + +
            +
            Returns:
            + +
            {[CAAT.Point]}
            + +
            + + + + +
            + + +
            + + + getControlPoint(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {CAAT.PathSegment} + getCurrentPathSegment() + +
            +
            + Return the last path segment added to this path. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.PathSegment}
            + +
            + + + + +
            + + +
            + + + getFirstPathSegment() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getLastPathSegment() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + getNumSegments() + +
            +
            + Returns an integer with the number of path segments that conform this path. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + {CAAT.Foundation.Point} + getPosition(time, open_contour) + +
            +
            + This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path. +The returned coordinate is the corresponding to normalizing the path's length to 1, +and then finding what path segment and what coordinate in that path segment corresponds +for the input time parameter. +

            +The parameter time must be a value ranging 0..1. +If not constrained to these values, the parameter will be modulus 1, and then, if less +than 0, be normalized to 1+time, so that the value always ranges from 0 to 1. +

            +This method is needed when traversing the path throughout a CAAT.Interpolator instance. + + +

            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate. +1 will return path's end coordinate.
            + +
            + open_contour + +
            +
            {boolean=} treat this path as an open contour. It is intended for +open paths, and interpolators which give values above 1. see tutorial 7.1.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Foundation.Point}
            + +
            + + + + +
            + + +
            + + {CAAT.Point} + getPositionFromLength(iLength) + +
            +
            + Analogously to the method getPosition, this method returns a CAAT.Point instance with +the coordinate on the path that corresponds to the given length. The input length is +related to path's length. + + +
            + + + + +
            +
            Parameters:
            + +
            + iLength + +
            +
            {number} a float with the target length.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + + getSegment(index) + +
            +
            + Gets a CAAT.PathSegment instance. + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            {number} the index of the desired CAAT.PathSegment.
            + +
            + + + + + +
            +
            Returns:
            + +
            CAAT.PathSegment
            + +
            + + + + +
            + + +
            + + + isEmpty() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + numControlPoints() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + paint(director) + +
            +
            + Paints the path. +This method is called by CAAT.PathActor instances. +If the path is set as interactive (by default) path segment will draw curve modification +handles as well. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            {CAAT.Director} a CAAT.Director instance.
            + +
            + + + + + + + + +
            + + +
            + + + press(x, y) + +
            +
            + Sent by a CAAT.PathActor instance object to try to drag a path's control point. + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            {number}
            + +
            + y + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + release() + +
            +
            + Method invoked when a CAAT.PathActor stops dragging a control point. + + +
            + + + + + + + + + + + +
            + + +
            + + + removeBehaviorById(id) + +
            +
            + Remove a Behavior with id param as behavior identifier from this actor. +This function will remove ALL behavior instances with the given id. + + +
            + + + + +
            +
            Parameters:
            + +
            + id + +
            +
            {number} an integer. +return this;
            + +
            + + + + + + + + +
            + + +
            + + + removeBehaviour(behavior) + +
            +
            + Remove a Behavior from the Actor. +If the Behavior is not present at the actor behavior collection nothing happends. + + +
            + + + + +
            +
            Parameters:
            + +
            + behavior + +
            +
            {CAAT.Behavior} a CAAT.Behavior instance.
            + +
            + + + + + + + + +
            + + +
            + + + setATMatrix() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + setCatmullRom(points, closed) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            + +
            + closed + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setCubic(x0, y0, x1, y1, x2, y2, x3, y3) + +
            +
            + Sets this path to be composed by a single Cubic Bezier path segment. + + +
            + + + + +
            +
            Parameters:
            + +
            + x0 + +
            +
            {number}
            + +
            + y0 + +
            +
            {number}
            + +
            + x1 + +
            +
            {number}
            + +
            + y1 + +
            +
            {number}
            + +
            + x2 + +
            +
            {number}
            + +
            + y2 + +
            +
            {number}
            + +
            + x3 + +
            +
            {number}
            + +
            + y3 + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + setInteractive(interactive) + +
            +
            + Set whether this path should paint handles for every control point. + + +
            + + + + +
            +
            Parameters:
            + +
            + interactive + +
            +
            {boolean}.
            + +
            + + + + + + + + +
            + + +
            + + + setLinear(x0, y0, x1, y1) + +
            +
            + Set the path to be composed by a single LinearPath segment. + + +
            + + + + +
            +
            Parameters:
            + +
            + x0 + +
            +
            {number}
            + +
            + y0 + +
            +
            {number}
            + +
            + x1 + +
            +
            {number}
            + +
            + y1 + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + setLocation(x, y) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + Set a point from this path. + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            {CAAT.Point}
            + +
            + index + +
            +
            {integer} a point index.
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + Reposition this path points. +This operation will only take place if the supplied points array equals in size to +this path's already set points. + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            {Array}
            + +
            + + + + + + + + +
            + + +
            + + + setPosition(x, y) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPositionAnchor(ax, ay) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ax + +
            +
            + +
            + ay + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPositionAnchored(x, y, ax, ay) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + ax + +
            +
            + +
            + ay + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setQuadric(x0, y0, x1, y1, x2, y2) + +
            +
            + Set this path to be composed by a single Quadric Bezier path segment. + + +
            + + + + +
            +
            Parameters:
            + +
            + x0 + +
            +
            {number}
            + +
            + y0 + +
            +
            {number}
            + +
            + x1 + +
            +
            {number}
            + +
            + y1 + +
            +
            {number}
            + +
            + x2 + +
            +
            {number}
            + +
            + y2 + +
            +
            {number}
            + +
            + + + + + +
            +
            Returns:
            + +
            this
            + +
            + + + + +
            + + +
            + + + setRectangle(x0, y0, x1, y1) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + x0 + +
            +
            + +
            + y0 + +
            +
            + +
            + x1 + +
            +
            + +
            + y1 + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setRotation(angle) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + angle + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setRotationAnchor(ax, ay) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ax + +
            +
            + +
            + ay + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setRotationAnchored(angle, rx, ry) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + angle + +
            +
            + +
            + rx + +
            +
            + +
            + ry + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setScale(sx, sy) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + sx + +
            +
            + +
            + sy + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setScaleAnchor(ax, ay) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ax + +
            +
            + +
            + ay + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setScaleAnchored(scaleX, scaleY, sx, sy) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + scaleX + +
            +
            + +
            + scaleY + +
            +
            + +
            + sx + +
            +
            + +
            + sy + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {CAAT.Point} + startCurvePosition() + +
            +
            + Return the first point of the first path segment of this compound path. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + + updatePath(point, callback) + +
            +
            + Indicates that some path control point has changed, and that the path must recalculate +its internal data, ie: length and bbox. + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + callback + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.PathSegment.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.PathSegment.html new file mode 100644 index 0000000..8a43f7a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.PathSegment.html @@ -0,0 +1,1540 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.PathSegment + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.PathSegment +

            + + +

            + + + + + + +
            Defined in: PathSegment.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + bbox +
            +
            Segment bounding box.
            +
              +
            + color +
            +
            Color to draw the segment.
            +
              +
            + length +
            +
            Segment length.
            +
              +
            + parent +
            +
            Path this segment belongs to.
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            applyAsPath(ctx) +
            +
            Draw this path using RenderingContext2D drawing primitives.
            +
              +
            drawHandle(ctx, x, y) +
            +
            +
              + +
            Get path's last coordinate.
            +
              +
            endPath() +
            +
            Instruments the path has finished building, and that no more segments will be added to it.
            +
              +
            getBoundingBox(rectangle) +
            +
            Gets the path bounding box (or the rectangle that contains the whole path).
            +
              +
            getContour(iSize) +
            +
            Gets a polyline describing the path contour.
            +
              +
            getControlPoint(index) +
            +
            Gets CAAT.Point instance with the 2d position of a control point.
            +
              + +
            Gets Path length.
            +
              +
            getPosition(time) +
            +
            Get a coordinate on path.
            +
              + +
            Gets the number of control points needed to create the path.
            +
              +
            setColor(color) +
            +
            +
              +
            setParent(parent) +
            +
            Set a PathSegment's parent
            +
              +
            setPoint(point, index) +
            +
            Set a point from this path segment.
            +
              +
            setPoints(points) +
            +
            Set this path segment's points information.
            +
              + +
            Get path's starting coordinate.
            +
              +
            transform(matrix) +
            +
            Transform this path with the given affinetransform matrix.
            +
              +
            updatePath(point) +
            +
            Recalculate internal path structures.
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.PathSegment() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + bbox + +
            +
            + Segment bounding box. + + +
            + + + + + + + + +
            + + +
            + + + color + +
            +
            + Color to draw the segment. + + +
            + + + + + + + + +
            + + +
            + + + length + +
            +
            + Segment length. + + +
            + + + + + + + + +
            + + +
            + + + parent + +
            +
            + Path this segment belongs to. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + applyAsPath(ctx) + +
            +
            + Draw this path using RenderingContext2D drawing primitives. +The intention is to set a path or pathsegment as a clipping region. + + +
            + + + + +
            +
            Parameters:
            + +
            + ctx + +
            +
            {RenderingContext2D}
            + +
            + + + + + + + + +
            + + +
            + + + drawHandle(ctx, x, y) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + ctx + +
            +
            + +
            + x + +
            +
            + +
            + y + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {CAAT.Point} + endCurvePosition() + +
            +
            + Get path's last coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + + endPath() + +
            +
            + Instruments the path has finished building, and that no more segments will be added to it. +You could later add more PathSegments and endPath must be called again. + + +
            + + + + + + + + + + + +
            + + +
            + + {CAAT.Rectangle} + getBoundingBox(rectangle) + +
            +
            + Gets the path bounding box (or the rectangle that contains the whole path). + + +
            + + + + +
            +
            Parameters:
            + +
            + rectangle + +
            +
            a CAAT.Rectangle instance with the bounding box.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Rectangle}
            + +
            + + + + +
            + + +
            + + {[CAAT.Point]} + getContour(iSize) + +
            +
            + Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments. + + +
            + + + + +
            +
            Parameters:
            + +
            + iSize + +
            +
            an integer indicating the number of segments of the contour polyline.
            + +
            + + + + + +
            +
            Returns:
            + +
            {[CAAT.Point]}
            + +
            + + + + +
            + + +
            + + {CAAT.Point} + getControlPoint(index) + +
            +
            + Gets CAAT.Point instance with the 2d position of a control point. + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            an integer indicating the desired control point coordinate.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + {number} + getLength() + +
            +
            + Gets Path length. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + {CAAT.Point} + getPosition(time) + +
            +
            + Get a coordinate on path. +The parameter time is normalized, that is, its values range from zero to one. +zero will mean startCurvePosition and one will be endCurvePosition. Other values +will be a position on the path relative to the path length. if the value is greater that 1, if will be set +to modulus 1. + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            a float with a value between zero and 1 inclusive both.
            + +
            + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + {number} + numControlPoints() + +
            +
            + Gets the number of control points needed to create the path. +Each PathSegment type can have different control points. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number} an integer with the number of control points.
            + +
            + + + + +
            + + +
            + + + setColor(color) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + color + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setParent(parent) + +
            +
            + Set a PathSegment's parent + + +
            + + + + +
            +
            Parameters:
            + +
            + parent + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + Set a point from this path segment. + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            {CAAT.Point}
            + +
            + index + +
            +
            {integer} a point index.
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + Set this path segment's points information. + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            {Array}
            + +
            + + + + + + + + +
            + + +
            + + {CAAT.Point} + startCurvePosition() + +
            +
            + Get path's starting coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.Point}
            + +
            + + + + +
            + + +
            + + + transform(matrix) + +
            +
            + Transform this path with the given affinetransform matrix. + + +
            + + + + +
            +
            Parameters:
            + +
            + matrix + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + updatePath(point) + +
            +
            + Recalculate internal path structures. + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.RectPath.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.RectPath.html new file mode 100644 index 0000000..3b652da --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.RectPath.html @@ -0,0 +1,1508 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.RectPath + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.RectPath +

            + + +

            + +
            Extends + CAAT.PathUtil.PathSegment.
            + + + + + +
            Defined in: RectPath.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + cw +
            +
            Traverse this path clockwise or counterclockwise (false).
            +
              + +
            spare point for calculations
            +
              +
            + points +
            +
            A collection of Points.
            +
            + + + +
            +
            Fields borrowed from class CAAT.PathUtil.PathSegment:
            bbox, color, length, parent
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init() +
            +
            +
              +
            applyAsPath(director) +
            +
            +
              + +
            +
              + +
            Returns final path segment point's x coordinate.
            +
              + +
            +
              +
            getControlPoint(index) +
            +
            +
              +
            getPosition(time) +
            +
            +
              + +
            +
              + +
            Returns initial path segment point's x coordinate.
            +
              + +
            +
              + +
            Get the number of control points.
            +
              +
            paint(director, bDrawHandles) +
            +
            Draws this path segment on screen.
            +
              + +
            +
              +
            setFinalPosition(finalX, finalY) +
            +
            Set a rectangle from points[0] to (finalX, finalY)
            +
              + +
            Set this path segment's starting position.
            +
              +
            setPoint(point, index) +
            +
            +
              +
            setPoints(points) +
            +
            An array of {CAAT.Point} composed of two points.
            +
              + +
            +
              +
            updatePath(point) +
            +
            +
            + + + +
            +
            Methods borrowed from class CAAT.PathUtil.PathSegment:
            drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.RectPath() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + cw + +
            +
            + Traverse this path clockwise or counterclockwise (false). + + +
            + + + + + + + + +
            + + +
            + + + newPosition + +
            +
            + spare point for calculations + + +
            + + + + + + + + +
            + + +
            + + + points + +
            +
            + A collection of Points. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + applyAsPath(director) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + endCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + finalPositionX() + +
            +
            + Returns final path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + getContour() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getControlPoint(index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPosition(time) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + time + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getPositionFromLength(iLength) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + iLength + +
            +
            + +
            + + + + + + + + +
            + + +
            + + {number} + initialPositionX() + +
            +
            + Returns initial path segment point's x coordinate. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + isClockWise() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + {number} + numControlPoints() + +
            +
            + Get the number of control points. For this type of path segment, start and +ending path segment points. Defaults to 2. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number}
            + +
            + + + + +
            + + +
            + + + paint(director, bDrawHandles) + +
            +
            + Draws this path segment on screen. Optionally it can draw handles for every control point, in +this case, start and ending path segment points. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            {CAAT.Director}
            + +
            + bDrawHandles + +
            +
            {boolean}
            + +
            + + + + + + + + +
            + + +
            + + + setClockWise(cw) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + cw + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setFinalPosition(finalX, finalY) + +
            +
            + Set a rectangle from points[0] to (finalX, finalY) + + +
            + + + + +
            +
            Parameters:
            + +
            + finalX + +
            +
            {number}
            + +
            + finalY + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setInitialPosition(x, y) + +
            +
            + Set this path segment's starting position. +This method should not be called again after setFinalPosition has been called. + + +
            + + + + +
            +
            Parameters:
            + +
            + x + +
            +
            {number}
            + +
            + y + +
            +
            {number}
            + +
            + + + + + + + + +
            + + +
            + + + setPoint(point, index) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + index + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setPoints(points) + +
            +
            + An array of {CAAT.Point} composed of two points. + + +
            + + + + +
            +
            Parameters:
            + +
            + points + +
            +
            {Array}
            + +
            + + + + + + + + +
            + + +
            + + + startCurvePosition() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + updatePath(point) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + point + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.SVGPath.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.SVGPath.html new file mode 100644 index 0000000..c3ece98 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.SVGPath.html @@ -0,0 +1,1689 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil.SVGPath + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.PathUtil.SVGPath +

            + + +

            + + + + + + +
            Defined in: SVGPath.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +

            +This class is a SVG Path parser.

            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
            <private>   + +
            +
            <private>   +
            + c +
            +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            ____getNumbers(pathInfo, c, v, n, error) +
            +
            +
            <private>   +
            __findNumber(pathInfo, c) +
            +
            +
            <private>   +
            __getNumber(pathInfo, c, v, error) +
            +
            +
            <private>   +
            __init() +
            +
            +
            <private>   +
            __isDigit(c) +
            +
            +
            <private>   +
            __maybeNumber(pathInfo, c) +
            +
            +
            <private>   +
            __parseClosePath(pathInfo, c, path, error) +
            +
            +
            <private>   +
            __parseCubic(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseCubicS(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseLine(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseLineH(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseLineV(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseMoveTo(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseQuadric(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __parseQuadricS(pathInfo, c, absolute, path, error) +
            +
            +
            <private>   +
            __skipBlank(pathInfo, c) +
            +
            +
              +
            parsePath(pathInfo) +
            +
            This method will create a CAAT.PathUtil.Path object with as many contours as needed.
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.PathUtil.SVGPath() +
            + +
            +

            +This class is a SVG Path parser. +By calling the method parsePath( svgpath ) an instance of CAAT.PathUtil.Path will be built by parsing +its contents. + +

            +See demo32 + +

            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            <private> + + + bezierInfo + +
            +
            + + + +
            + + + + + + + + +
            + + +
            <private> + + + c + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + ____getNumbers(pathInfo, c, v, n, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + v + +
            +
            + +
            + n + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __findNumber(pathInfo, c) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __getNumber(pathInfo, c, v, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + v + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __init() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            <private> + + + __isDigit(c) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + c + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __maybeNumber(pathInfo, c) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseClosePath(pathInfo, c, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseCubic(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseCubicS(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseLine(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseLineH(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseLineV(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseMoveTo(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseQuadric(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __parseQuadricS(pathInfo, c, absolute, path, error) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + absolute + +
            +
            + +
            + path + +
            +
            + +
            + error + +
            +
            + +
            + + + + + + + + +
            + + +
            <private> + + + __skipBlank(pathInfo, c) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            + +
            + c + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + parsePath(pathInfo) + +
            +
            + This method will create a CAAT.PathUtil.Path object with as many contours as needed. + + +
            + + + + +
            +
            Parameters:
            + +
            + pathInfo + +
            +
            {string} a SVG path
            + +
            + + + + + +
            +
            Returns:
            + +
            Array.
            + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.html b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.html new file mode 100644 index 0000000..044f83a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.PathUtil.html @@ -0,0 +1,541 @@ + + + + + + + JsDoc Reference - CAAT.PathUtil + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.PathUtil +

            + + +

            + + + + + + +
            Defined in: PathSegment.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.PathUtil +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:19 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.ColorProgram.html b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.ColorProgram.html new file mode 100644 index 0000000..0e75aad --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.ColorProgram.html @@ -0,0 +1,885 @@ + + + + + + + JsDoc Reference - CAAT.WebGL.ColorProgram + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.WebGL.ColorProgram +

            + + +

            + +
            Extends + CAAT.WebGL.Program.
            + + + + + +
            Defined in: ColorProgram.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            int32 Array for color Buffer
            +
              + +
            Float32 Array for vertex buffer.
            +
              + +
            GLBuffer for vertex buffer.
            +
            + + + +
            +
            Fields borrowed from class CAAT.WebGL.Program:
            gl, shaderProgram
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(gl) +
            +
            +
              + +
            +
              + +
            +
              + +
            +
              +
            setColor(colorArray) +
            +
            +
            + + + +
            +
            Methods borrowed from class CAAT.WebGL.Program:
            create, getDomShader, getShader, setAlpha, setMatrixUniform, useProgram
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.WebGL.ColorProgram() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + colorBuffer + +
            +
            + int32 Array for color Buffer + + +
            + + + + + + + + +
            + + +
            + + + vertexPositionArray + +
            +
            + Float32 Array for vertex buffer. + + +
            + + + + + + + + +
            + + +
            + + + vertexPositionBuffer + +
            +
            + GLBuffer for vertex buffer. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(gl) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getFragmentShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getVertexShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + initialize() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + setColor(colorArray) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + colorArray + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.GLU.html b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.GLU.html new file mode 100644 index 0000000..c5d69e6 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.GLU.html @@ -0,0 +1,789 @@ + + + + + + + JsDoc Reference - CAAT.WebGL.GLU + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.WebGL.GLU +

            + + +

            + + + + + + +
            Defined in: GLU.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <static>   +
            CAAT.WebGL.GLU.makeFrustum(left, right, bottom, top, znear, zfar, viewportHeight) +
            +
            Create a matrix for a frustum.
            +
            <static>   +
            CAAT.WebGL.GLU.makeOrtho(left, right, bottom, top, znear, zfar) +
            +
            Create an orthogonal projection matrix.
            +
            <static>   +
            CAAT.WebGL.GLU.makePerspective(fovy, aspect, znear, zfar, viewportHeight) +
            +
            Create a perspective matrix.
            +
            + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.WebGL.GLU +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + +
            + Method Detail +
            + + +
            <static> + + + CAAT.WebGL.GLU.makeFrustum(left, right, bottom, top, znear, zfar, viewportHeight) + +
            +
            + Create a matrix for a frustum. + + +
            + + + + +
            +
            Parameters:
            + +
            + left + +
            +
            + +
            + right + +
            +
            + +
            + bottom + +
            +
            + +
            + top + +
            +
            + +
            + znear + +
            +
            + +
            + zfar + +
            +
            + +
            + viewportHeight + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.WebGL.GLU.makeOrtho(left, right, bottom, top, znear, zfar) + +
            +
            + Create an orthogonal projection matrix. + + +
            + + + + +
            +
            Parameters:
            + +
            + left + +
            +
            + +
            + right + +
            +
            + +
            + bottom + +
            +
            + +
            + top + +
            +
            + +
            + znear + +
            +
            + +
            + zfar + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.WebGL.GLU.makePerspective(fovy, aspect, znear, zfar, viewportHeight) + +
            +
            + Create a perspective matrix. + + +
            + + + + +
            +
            Parameters:
            + +
            + fovy + +
            +
            + +
            + aspect + +
            +
            + +
            + znear + +
            +
            + +
            + zfar + +
            +
            + +
            + viewportHeight + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.Program.html b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.Program.html new file mode 100644 index 0000000..2a4c8e0 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.Program.html @@ -0,0 +1,1064 @@ + + + + + + + JsDoc Reference - CAAT.WebGL.Program + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.WebGL.Program +

            + + +

            + + + + + + +
            Defined in: Program.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + gl +
            +
            Canvas 3D context.
            +
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(gl) +
            +
            +
              +
            create() +
            +
            +
              +
            getDomShader(gl, id) +
            +
            +
              + +
            +
              +
            getShader(gl, type, str) +
            +
            +
              + +
            +
              + +
            +
              +
            setAlpha(alpha) +
            +
            Set fragment shader's alpha composite value.
            +
              +
            setMatrixUniform(caatMatrix4) +
            +
            +
              + +
            +
            + + + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.WebGL.Program() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + gl + +
            +
            + Canvas 3D context. + + +
            + + + + + + + + +
            + + +
            + + + shaderProgram + +
            +
            + + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(gl) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + create() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getDomShader(gl, id) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + id + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getFragmentShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getShader(gl, type, str) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + type + +
            +
            + +
            + str + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getVertexShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + initialize() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + setAlpha(alpha) + +
            +
            + Set fragment shader's alpha composite value. + + +
            + + + + +
            +
            Parameters:
            + +
            + alpha + +
            +
            {number} float value 0..1.
            + +
            + + + + + + + + +
            + + +
            + + + setMatrixUniform(caatMatrix4) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + caatMatrix4 + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + useProgram() + +
            +
            + + + +
            + + + + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.TextureProgram.html b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.TextureProgram.html new file mode 100644 index 0000000..14997f0 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.TextureProgram.html @@ -0,0 +1,1573 @@ + + + + + + + JsDoc Reference - CAAT.WebGL.TextureProgram + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Class CAAT.WebGL.TextureProgram +

            + + +

            + +
            Extends + CAAT.WebGL.Program.
            + + + + + +
            Defined in: TextureProgram.js. + +

            + + + + + + + + + + + + + + + + + +
            Class Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              + +
            Lines GLBuffer
            +
              +
            + prevA +
            +
            +
              +
            + prevAlpha +
            +
            +
              +
            + prevB +
            +
            +
              +
            + prevG +
            +
            +
              +
            + prevR +
            +
            +
              + +
            +
              + +
            VertexIndex GLBuffer.
            +
              + +
            VertextBuffer Float32 Array
            +
              + +
            VertextBuffer GLBuffer
            +
              + +
            VertexBuffer Float32 Array
            +
              + +
            UVBuffer GLBuffer
            +
            + + + +
            +
            Fields borrowed from class CAAT.WebGL.Program:
            gl, shaderProgram
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <private>   +
            __init(gl) +
            +
            +
              +
            drawLines(lines_data, size, r, g, b, a, lineWidth) +
            +
            +
              +
            drawPolylines(polyline_data, size, r, g, b, a, lineWidth) +
            +
            +
              + +
            +
              + +
            +
              + +
            +
              +
            setAlpha(alpha) +
            +
            +
              +
            setTexture(glTexture) +
            +
            +
              +
            setUseColor(use, r, g, b, a) +
            +
            +
              +
            updateUVBuffer(uvArray) +
            +
            +
              +
            updateVertexBuffer(vertexArray) +
            +
            +
              + +
            +
            + + + +
            +
            Methods borrowed from class CAAT.WebGL.Program:
            create, getDomShader, getShader, setMatrixUniform
            +
            + + + + + + + +
            +
            + Class Detail +
            + +
            + CAAT.WebGL.TextureProgram() +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            + + + linesBuffer + +
            +
            + Lines GLBuffer + + +
            + + + + + + + + +
            + + +
            + + + prevA + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + prevAlpha + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + prevB + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + prevG + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + prevR + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + prevTexture + +
            +
            + + + +
            + + + + + + + + +
            + + +
            + + + vertexIndexBuffer + +
            +
            + VertexIndex GLBuffer. + + +
            + + + + + + + + +
            + + +
            + + + vertexPositionArray + +
            +
            + VertextBuffer Float32 Array + + +
            + + + + + + + + +
            + + +
            + + + vertexPositionBuffer + +
            +
            + VertextBuffer GLBuffer + + +
            + + + + + + + + +
            + + +
            + + + vertexUVArray + +
            +
            + VertexBuffer Float32 Array + + +
            + + + + + + + + +
            + + +
            + + + vertexUVBuffer + +
            +
            + UVBuffer GLBuffer + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <private> + + + __init(gl) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + gl + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + drawLines(lines_data, size, r, g, b, a, lineWidth) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + lines_data + +
            +
            {Float32Array} array of number with x,y,z coords for each line point.
            + +
            + size + +
            +
            {number} number of lines to draw.
            + +
            + r + +
            +
            + +
            + g + +
            +
            + +
            + b + +
            +
            + +
            + a + +
            +
            + +
            + lineWidth + +
            +
            {number} drawing line size.
            + +
            + + + + + + + + +
            + + +
            + + + drawPolylines(polyline_data, size, r, g, b, a, lineWidth) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + polyline_data + +
            +
            + +
            + size + +
            +
            + +
            + r + +
            +
            + +
            + g + +
            +
            + +
            + b + +
            +
            + +
            + a + +
            +
            + +
            + lineWidth + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + getFragmentShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + getVertexShader() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + initialize() + +
            +
            + + + +
            + + + + + + + + + + + +
            + + +
            + + + setAlpha(alpha) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + alpha + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setTexture(glTexture) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + glTexture + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + setUseColor(use, r, g, b, a) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + use + +
            +
            + +
            + r + +
            +
            + +
            + g + +
            +
            + +
            + b + +
            +
            + +
            + a + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + updateUVBuffer(uvArray) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + uvArray + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + updateVertexBuffer(vertexArray) + +
            +
            + + + +
            + + + + +
            +
            Parameters:
            + +
            + vertexArray + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + useProgram() + +
            +
            + + + +
            + + + + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.html b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.html new file mode 100644 index 0000000..e4a95ca --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.WebGL.html @@ -0,0 +1,546 @@ + + + + + + + JsDoc Reference - CAAT.WebGL + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT.WebGL +

            + + +

            + + + + + + +
            Defined in: Program.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              + +
            +
            + + + + + + + + + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT.WebGL +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/CAAT.html b/CAAT/documentation/jsdoc/symbols/CAAT.html new file mode 100644 index 0000000..68a8565 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/CAAT.html @@ -0,0 +1,2561 @@ + + + + + + + JsDoc Reference - CAAT + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Namespace CAAT +

            + + +

            + + + + + + +
            Defined in: CAAT.js. + +

            + + + + + + + + + + + + + + + + + +
            Namespace Summary
            Constructor AttributesConstructor Name and Description
              +
            + CAAT +
            +
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
            <static>   + +
            Acceleration data.
            +
            <static>   +
            + CAAT.ALT_KEY +
            +
            Alt key code
            +
            <static>   + +
            When switching scenes, cache exiting scene or not.
            +
            <private> <static>   +
            + CAAT.CLAMP +
            +
            // do not clamp coordinates.
            +
            <static>   +
            + CAAT.CONTROL_KEY +
            +
            Control key code
            +
            <static>   +
            + CAAT.CSS_TEXT_METRICS +
            +
            Control how CAAT.Font and CAAT.TextActor control font ascent/descent values.
            +
            <static>   +
            + CAAT.currentDirector +
            +
            Current animated director.
            +
            <static>   +
            + CAAT.DEBUG +
            +
            set this variable before building CAAT.Director intances to enable debug panel.
            +
            <static>   +
            + CAAT.DEBUG_DIRTYRECTS +
            +
            if CAAT.Director.setClear uses CLEAR_DIRTY_RECTS, this will show them on screen.
            +
            <static>   +
            + CAAT.DEBUGAABB +
            +
            debug axis aligned bounding boxes.
            +
            <static>   +
            + CAAT.DEBUGAABBCOLOR +
            +
            Bounding boxes color.
            +
            <static>   +
            + CAAT.DEBUGBB +
            +
            show Bounding Boxes
            +
            <static>   +
            + CAAT.DEBUGBBBCOLOR +
            +
            Bounding Boxes color.
            +
            <static>   +
            + CAAT.director +
            +
            Registered director objects.
            +
            <static>   +
            + CAAT.DRAG_THRESHOLD_X +
            +
            Do not consider mouse drag gesture at least until you have dragged +DRAG_THRESHOLD_X and DRAG_THRESHOLD_Y pixels.
            +
            <static>   +
            + CAAT.ENDRAF +
            +
            if RAF, this value signals end of RAF.
            +
            <static>   +
            + CAAT.ENTER_KEY +
            +
            Enter key code
            +
            <static>   +
            + CAAT.FPS +
            +
            expected FPS when using setInterval animation.
            +
            <static>   +
            + CAAT.FPS_REFRESH +
            +
            debug panel update time.
            +
            <static>   +
            + CAAT.FRAME_TIME +
            +
            time to process one frame.
            +
            <static>   +
            + CAAT.GLRENDER +
            +
            is GLRendering enabled.
            +
            <static>   +
            + CAAT.INTERVAL_ID +
            +
            if setInterval, this value holds CAAT.setInterval return value.
            +
            <static>   +
            + CAAT.keyListeners +
            +
            Aray of Key listeners.
            +
            <static>   +
            + CAAT.Keys +
            +
            +
            <static>   +
            + CAAT.Module +
            +
            This function defines CAAT modules, and creates Constructor Class objects.
            +
            <static>   +
            + CAAT.NO_RAF +
            +
            Use RAF shim instead of setInterval.
            +
            <static>   +
            + CAAT.PMR +
            +
            Points to Meter ratio value.
            +
            <static>   +
            + CAAT.RAF +
            +
            requestAnimationFrame time reference.
            +
            <static>   +
            + CAAT.renderEnabled +
            +
            Boolean flag to determine if CAAT.loop has already been called.
            +
            <static>   + +
            time between two consecutive RAF.
            +
            <static>   +
            + CAAT.rotationRate +
            +
            Device motion angles.
            +
            <static>   +
            + CAAT.SET_INTERVAL +
            +
            time between two consecutive setInterval calls.
            +
            <static>   +
            + CAAT.SHIFT_KEY +
            +
            Shift key code
            +
            <static> <constant>   +
            + CAAT.TOUCH_AS_MOUSE +
            +
            Constant to set touch behavior as single touch, compatible with mouse.
            +
            <static>   + +
            Constant to set CAAT touch behavior as multitouch.
            +
            <static>   +
            + CAAT.TOUCH_BEHAVIOR +
            +
            Set CAAT touch behavior as single or multi touch.
            +
            <static>   + +
            Array of window resize listeners.
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
            <static>   +
            CAAT.enableBox2DDebug(set, director, world, scale) +
            +
            (As Eemeli Kelokorpi suggested) + +Enable Box2D debug renderer.
            +
            <static>   + +
            Enable device motion events.
            +
            <static>   +
            CAAT.endLoop() +
            +
            Stop animation loop.
            +
            <static>   +
            CAAT.getCurrentScene() +
            +
            Return current scene.
            +
            <static>   + +
            Return current director's current scene's time.
            +
            <static>   +
            CAAT.log() +
            +
            Log function which deals with window's Console object.
            +
            <static>   +
            CAAT.loop(fps) +
            +
            Main animation loop entry point.
            +
            <static>   +
            CAAT.RegisterDirector(director) +
            +
            Register and keep track of every CAAT.Director instance in the document.
            +
            <static>   + +
            Register a function callback as key listener.
            +
            <static>   + +
            Register a function callback as window resize listener.
            +
            <static>   +
            CAAT.renderFrameRAF(now) +
            +
            +
            <static>   +
            CAAT.setCoordinateClamping(clamp) +
            +
            This function makes the system obey decimal point calculations for actor's position, size, etc.
            +
            <static>   +
            CAAT.setCursor(cursor) +
            +
            Set the cursor.
            +
            <static>   +
            CAAT.unregisterResizeListener(director) +
            +
            Remove a function callback as window resize listener.
            +
            + + + + + + + + + +
            +
            + Namespace Detail +
            + +
            + CAAT +
            + +
            + + +
            + + + + + + + + + + + + +
            + + + + +
            + Field Detail +
            + + +
            <static> + + + CAAT.accelerationIncludingGravity + +
            +
            + Acceleration data. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.ALT_KEY + +
            +
            + Alt key code + +
            + Defined in: KeyEvent.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.CACHE_SCENE_ON_CHANGE + +
            +
            + When switching scenes, cache exiting scene or not. Set before building director instance. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <private> <static> + + + CAAT.CLAMP + +
            +
            + // do not clamp coordinates. speeds things up in older browsers. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.CONTROL_KEY + +
            +
            + Control key code + +
            + Defined in: KeyEvent.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.CSS_TEXT_METRICS + +
            +
            + Control how CAAT.Font and CAAT.TextActor control font ascent/descent values. +0 means it will guess values from a font height +1 means it will try to use css to get accurate ascent/descent values and fall back to the previous method + in case it couldn't. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.currentDirector + +
            +
            + Current animated director. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUG + +
            +
            + set this variable before building CAAT.Director intances to enable debug panel. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUG_DIRTYRECTS + +
            +
            + if CAAT.Director.setClear uses CLEAR_DIRTY_RECTS, this will show them on screen. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUGAABB + +
            +
            + debug axis aligned bounding boxes. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUGAABBCOLOR + +
            +
            + Bounding boxes color. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUGBB + +
            +
            + show Bounding Boxes + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DEBUGBBBCOLOR + +
            +
            + Bounding Boxes color. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.director + +
            +
            + Registered director objects. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.DRAG_THRESHOLD_X + +
            +
            + Do not consider mouse drag gesture at least until you have dragged +DRAG_THRESHOLD_X and DRAG_THRESHOLD_Y pixels. +This is suitable for tablets, where just by touching, drag events are delivered. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.ENDRAF + +
            +
            + if RAF, this value signals end of RAF. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.ENTER_KEY + +
            +
            + Enter key code + +
            + Defined in: KeyEvent.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.FPS + +
            +
            + expected FPS when using setInterval animation. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.FPS_REFRESH + +
            +
            + debug panel update time. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.FRAME_TIME + +
            +
            + time to process one frame. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.GLRENDER + +
            +
            + is GLRendering enabled. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.INTERVAL_ID + +
            +
            + if setInterval, this value holds CAAT.setInterval return value. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.keyListeners + +
            +
            + Aray of Key listeners. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.Keys + +
            +
            + + +
            + Defined in: KeyEvent.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.Module + +
            +
            + This function defines CAAT modules, and creates Constructor Class objects. + +obj parameter has the following structure: +{ + defines{string}, // class name + depends{Array=}, // dependencies class names + extendsClass{string}, // class to extend from + extensdWith{object}, // actual prototype to extend + aliases{Array} // other class names +} + +
            + Defined in: ModuleManager.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.NO_RAF + +
            +
            + Use RAF shim instead of setInterval. Set to != 0 to use setInterval. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.PMR + +
            +
            + Points to Meter ratio value. + +
            + Defined in: B2DBodyActor.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.RAF + +
            +
            + requestAnimationFrame time reference. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.renderEnabled + +
            +
            + Boolean flag to determine if CAAT.loop has already been called. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.REQUEST_ANIMATION_FRAME_TIME + +
            +
            + time between two consecutive RAF. usually bigger than FRAME_TIME + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.rotationRate + +
            +
            + Device motion angles. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.SET_INTERVAL + +
            +
            + time between two consecutive setInterval calls. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.SHIFT_KEY + +
            +
            + Shift key code + +
            + Defined in: KeyEvent.js. + + +
            + + + + + + + + +
            + + +
            <static> <constant> + + + CAAT.TOUCH_AS_MOUSE + +
            +
            + Constant to set touch behavior as single touch, compatible with mouse. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.TOUCH_AS_MULTITOUCH + +
            +
            + Constant to set CAAT touch behavior as multitouch. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.TOUCH_BEHAVIOR + +
            +
            + Set CAAT touch behavior as single or multi touch. + +
            + Defined in: Input.js. + + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.windowResizeListeners + +
            +
            + Array of window resize listeners. + +
            + Defined in: Input.js. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            <static> + + + CAAT.enableBox2DDebug(set, director, world, scale) + +
            +
            + (As Eemeli Kelokorpi suggested) + +Enable Box2D debug renderer. + +
            + Defined in: B2DBodyActor.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + set + +
            +
            {boolean} enable or disable
            + +
            + director + +
            +
            {CAAT.Foundation.Director}
            + +
            + world + +
            +
            {object} box2d world
            + +
            + scale + +
            +
            {numner} a scale value.
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.enableDeviceMotion() + +
            +
            + Enable device motion events. +This function does not register a callback, instear it sets +CAAT.rotationRate and CAAt.accelerationIncludingGravity values. + +
            + Defined in: Input.js. + + +
            + + + + + + + + + + + +
            + + +
            <static> + + + CAAT.endLoop() + +
            +
            + Stop animation loop. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + + + + +
            + + +
            <static> + + {CAAT.Foundation.Scene} + CAAT.getCurrentScene() + +
            +
            + Return current scene. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {CAAT.Foundation.Scene}
            + +
            + + + + +
            + + +
            <static> + + {number} + CAAT.getCurrentSceneTime() + +
            +
            + Return current director's current scene's time. +The way to go should be keep local scene references, but anyway, this function is always handy. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + + + + + +
            +
            Returns:
            + +
            {number} current scene's virtual time.
            + +
            + + + + +
            + + +
            <static> + + + CAAT.log() + +
            +
            + Log function which deals with window's Console object. + +
            + Defined in: Constants.js. + + +
            + + + + + + + + + + + +
            + + +
            <static> + + + CAAT.loop(fps) + +
            +
            + Main animation loop entry point. +Must called only once, or only after endLoop. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + fps + +
            +
            {number} desired fps. fps parameter will only be used if CAAT.NO_RAF is specified, that is +switch from RequestAnimationFrame to setInterval for animation loop.
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.RegisterDirector(director) + +
            +
            + Register and keep track of every CAAT.Director instance in the document. + +
            + Defined in: AnimationLoop.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.registerKeyListener(f) + +
            +
            + Register a function callback as key listener. + +
            + Defined in: Input.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + f + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.registerResizeListener(f) + +
            +
            + Register a function callback as window resize listener. + +
            + Defined in: Input.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + f + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.renderFrameRAF(now) + +
            +
            + + +
            + Defined in: AnimationLoop.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + now + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.setCoordinateClamping(clamp) + +
            +
            + This function makes the system obey decimal point calculations for actor's position, size, etc. +This may speed things up in some browsers, but at the cost of affecting visuals (like in rotating +objects). + +Latest Chrome (20+) is not affected by this. + +Default CAAT.Matrix try to speed things up. + +
            + Defined in: Constants.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + clamp + +
            +
            {boolean}
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.setCursor(cursor) + +
            +
            + Set the cursor. + +
            + Defined in: Input.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + cursor + +
            +
            + +
            + + + + + + + + +
            + + +
            <static> + + + CAAT.unregisterResizeListener(director) + +
            +
            + Remove a function callback as window resize listener. + +
            + Defined in: Input.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + director + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/String.html b/CAAT/documentation/jsdoc/symbols/String.html new file mode 100644 index 0000000..6666057 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/String.html @@ -0,0 +1,562 @@ + + + + + + + JsDoc Reference - String + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Built-In Namespace String +

            + + +

            + + + + + + +

            + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
              +
            endsWith(suffix) +
            +
            +
            + + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            + + + endsWith(suffix) + +
            +
            + + +
            + Defined in: ModuleManager.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + suffix + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/_global_.html b/CAAT/documentation/jsdoc/symbols/_global_.html new file mode 100644 index 0000000..148273e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/_global_.html @@ -0,0 +1,749 @@ + + + + + + + JsDoc Reference - _global_ + + + + + + + + + + + +
            + + +
            +

            Classes

            + +
            + +
            + +
            + +

            + + Built-In Namespace _global_ +

            + + +

            + + + + + + +

            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Field Summary
            Field AttributesField Name and Description
              +
            + i +
            +
            remove already loaded modules dependencies.
            +
              +
            + nmodule +
            +
            Avoid name clash: +CAAT.Foundation and CAAT.Foundation.Timer will both be valid for +CAAT.Foundation.Timer.TimerManager module.
            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Method Summary
            Method AttributesMethod Name and Description
              +
            extend(subc, superc) +
            +
            +
              +
            extendWith(base, subclass, with_object) +
            +
            Sintactic sugar to add a __super attribute on every overriden method.
            +
            + + + + + + + + + + + + +
            + Field Detail +
            + + +
            + + + i + +
            +
            + remove already loaded modules dependencies. + +
            + Defined in: ModuleManager.js. + + +
            + + + + + + + + +
            + + +
            + + + nmodule + +
            +
            + Avoid name clash: +CAAT.Foundation and CAAT.Foundation.Timer will both be valid for +CAAT.Foundation.Timer.TimerManager module. +So in the end, the module name can't have '.' after chopping the class +namespace. + +
            + Defined in: ModuleManager.js. + + +
            + + + + + + + + + + + + + + +
            + Method Detail +
            + + +
            + + + extend(subc, superc) + +
            +
            + + +
            + Defined in: Class.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + subc + +
            +
            + +
            + superc + +
            +
            + +
            + + + + + + + + +
            + + +
            + + + extendWith(base, subclass, with_object) + +
            +
            + Sintactic sugar to add a __super attribute on every overriden method. +Despite comvenient, it slows things down by 5fps. + +Uncomment at your own risk. + + // tenemos en super un metodo con igual nombre. + if ( superc.prototype[method]) { + subc.prototype[method]= (function(fn, fnsuper) { + return function() { + var prevMethod= this.__super; + + this.__super= fnsuper; + + var retValue= fn.apply( + this, + Array.prototype.slice.call(arguments) ); + + this.__super= prevMethod; + + return retValue; + }; + })(subc.prototype[method], superc.prototype[method]); + } + +
            + Defined in: Class.js. + + +
            + + + + +
            +
            Parameters:
            + +
            + base + +
            +
            + +
            + subclass + +
            +
            + +
            + with_object + +
            +
            + +
            + + + + + + + + + + + + + + + +
            +
            + + + +
            + + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) +
            + + diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_AlphaBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_AlphaBehavior.js.html new file mode 100644 index 0000000..4dc3981 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_AlphaBehavior.js.html @@ -0,0 +1,140 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name AlphaBehavior
            +  5      * @memberOf CAAT.Behavior
            +  6      * @extends CAAT.Behavior.BaseBehavior
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Behavior.AlphaBehavior",
            + 11     aliases:["CAAT.AlphaBehavior"],
            + 12     depends:["CAAT.Behavior.BaseBehavior"],
            + 13     extendsClass:"CAAT.Behavior.BaseBehavior",
            + 14     extendsWith:function () {
            + 15         return {
            + 16 
            + 17             /**
            + 18              * @lends CAAT.Behavior.AlphaBehavior.prototype
            + 19              */
            + 20 
            + 21             /**
            + 22              * Starting alpha transparency value. Between 0 and 1.
            + 23              * @type {number}
            + 24              * @private
            + 25              */
            + 26             startAlpha:0,
            + 27 
            + 28             /**
            + 29              * Ending alpha transparency value. Between 0 and 1.
            + 30              * @type {number}
            + 31              * @private
            + 32              */
            + 33             endAlpha:0,
            + 34 
            + 35             /**
            + 36              * @inheritsDoc
            + 37              * @param obj
            + 38              */
            + 39             parse : function( obj ) {
            + 40                 CAAT.Behavior.AlphaBehavior.superclass.parse.call(this,obj);
            + 41                 this.startAlpha= obj.start || 0;
            + 42                 this.endAlpha= obj.end || 0;
            + 43             },
            + 44 
            + 45             /**
            + 46              * @inheritDoc
            + 47              */
            + 48             getPropertyName:function () {
            + 49                 return "opacity";
            + 50             },
            + 51 
            + 52             /**
            + 53              * Applies corresponding alpha transparency value for a given time.
            + 54              *
            + 55              * @param time the time to apply the scale for.
            + 56              * @param actor the target actor to set transparency for.
            + 57              * @return {number} the alpha value set. Normalized from 0 (total transparency) to 1 (total opacity)
            + 58              */
            + 59             setForTime:function (time, actor) {
            + 60 
            + 61                 CAAT.Behavior.AlphaBehavior.superclass.setForTime.call(this, time, actor);
            + 62 
            + 63                 var alpha = (this.startAlpha + time * (this.endAlpha - this.startAlpha));
            + 64                 if (this.doValueApplication) {
            + 65                     actor.setAlpha(alpha);
            + 66                 }
            + 67                 return alpha;
            + 68             },
            + 69 
            + 70             /**
            + 71              * Set alpha transparency minimum and maximum value.
            + 72              * This value can be coerced by Actor's property isGloblAlpha.
            + 73              *
            + 74              * @param start {number} a float indicating the starting alpha value.
            + 75              * @param end {number} a float indicating the ending alpha value.
            + 76              */
            + 77             setValues:function (start, end) {
            + 78                 this.startAlpha = start;
            + 79                 this.endAlpha = end;
            + 80                 return this;
            + 81             },
            + 82 
            + 83             /**
            + 84              * @inheritDoc
            + 85              */
            + 86             calculateKeyFrameData:function (time) {
            + 87                 time = this.interpolator.getPosition(time).y;
            + 88                 return  (this.startAlpha + time * (this.endAlpha - this.startAlpha));
            + 89             },
            + 90 
            + 91             /**
            + 92              * @inheritDoc
            + 93              */
            + 94             getKeyFrameDataValues : function(time) {
            + 95                 time = this.interpolator.getPosition(time).y;
            + 96                 return {
            + 97                     alpha : this.startAlpha + time * (this.endAlpha - this.startAlpha)
            + 98                 };
            + 99             },
            +100 
            +101             /**
            +102              * @inheritDoc
            +103              * @override
            +104              */
            +105             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +106 
            +107                 if (typeof keyframessize === 'undefined') {
            +108                     keyframessize = 100;
            +109                 }
            +110                 keyframessize >>= 0;
            +111 
            +112                 var i;
            +113                 var kfr;
            +114                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +115 
            +116                 for (i = 0; i <= keyframessize; i++) {
            +117                     kfr = "" +
            +118                         (i / keyframessize * 100) + "%" + // percentage
            +119                         "{" +
            +120                         "opacity: " + this.calculateKeyFrameData(i / keyframessize) +
            +121                         "}";
            +122 
            +123                     kfd += kfr;
            +124                 }
            +125 
            +126                 kfd += "}";
            +127 
            +128                 return kfd;
            +129             }
            +130         }
            +131     }
            +132 });
            +133 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_BaseBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_BaseBehavior.js.html new file mode 100644 index 0000000..e8aadd2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_BaseBehavior.js.html @@ -0,0 +1,667 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Behaviors are keyframing elements.
            +  5  * By using a BehaviorContainer, you can specify different actions on any animation Actor.
            +  6  * An undefined number of Behaviors can be defined for each Actor.
            +  7  *
            +  8  * There're the following Behaviors:
            +  9  *  + AlphaBehavior:   controls container/actor global alpha.
            + 10  *  + RotateBehavior:  takes control of rotation affine transform.
            + 11  *  + ScaleBehavior:   takes control of scaling on x and y axis affine transform.
            + 12  *  + Scale1Behavior:  takes control of scaling on x or y axis affine transform.
            + 13  *  + PathBehavior:    takes control of translating an Actor/ActorContainer across a path [ie. pathSegment collection].
            + 14  *  + GenericBehavior: applies a behavior to any given target object's property, or notifies a callback.
            + 15  *
            + 16  *
            + 17  **/
            + 18 
            + 19 CAAT.Module({
            + 20 
            + 21     /**
            + 22      *
            + 23      * Namespace for all behavior-based actor properties instrumenter objects.
            + 24      *
            + 25      * @name Behavior
            + 26      * @memberOf CAAT
            + 27      * @namespace
            + 28      */
            + 29 
            + 30     /**
            + 31      *
            + 32      * The BaseBehavior is the base class of all Behavior modifiers:
            + 33      *
            + 34      * <li>AlphaBehabior
            + 35      * <li>RotateBehavior
            + 36      * <li>ScaleBehavior
            + 37      * <li>Scale1Behavior
            + 38      * <li>PathBehavior
            + 39      * <li>GenericBehavior
            + 40      * <li>ContainerBehavior
            + 41      *
            + 42      * Behavior base class.
            + 43      *
            + 44      * <p>
            + 45      * A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator.
            + 46      * In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same
            + 47      * time interval.
            + 48      * <p>
            + 49      * A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified
            + 50      * period.
            + 51      * <p>
            + 52      * A behavior is guaranteed to notify (if any observer is registered) on behavior expiration.
            + 53      * <p>
            + 54      * A behavior can keep an unlimited observers. Observers are objects of the form:
            + 55      * <p>
            + 56      * <code>
            + 57      * {
            + 58      *      behaviorExpired : function( behavior, time, actor);
            + 59      *      behaviorApplied : function( behavior, time, normalizedTime, actor, value);
            + 60      * }
            + 61      * </code>
            + 62      * <p>
            + 63      * <strong>behaviorExpired</strong>: function( behavior, time, actor). This method will be called for any registered observer when
            + 64      * the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time
            + 65      * granurality.
            + 66      * <p>
            + 67      * <strong>behaviorApplied</strong> : function( behavior, time, normalizedTime, actor, value). This method will be called once per
            + 68      * frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be
            + 69      * called multiple times.
            + 70      * <p>
            + 71      * Every behavior is applied to a concrete Actor.
            + 72      * Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and
            + 73      * is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration.
            + 74      * <p>
            + 75      * You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify
            + 76      * behaviorExpired to its registered observers.
            + 77      * <p>
            + 78      * Other Behaviors simply must supply with the method <code>setForTime(time, actor)</code> overriden.
            + 79      *
            + 80      * @name BaseBehavior
            + 81      * @memberOf CAAT.Behavior
            + 82      * @constructor
            + 83      *
            + 84      */
            + 85 
            + 86     /**
            + 87      *
            + 88      * Internal behavior status values. Do not assign directly.
            + 89      *
            + 90      * @name Status
            + 91      * @memberOf CAAT.Behavior.BaseBehavior
            + 92      * @namespace
            + 93      * @enum {number}
            + 94      */
            + 95 
            + 96 
            + 97     defines:        "CAAT.Behavior.BaseBehavior",
            + 98     constants:      {
            + 99 
            +100         Status: {
            +101             /**
            +102              * @lends CAAT.Behavior.BaseBehavior.Status
            +103              */
            +104 
            +105             /** @const @type {number}*/ NOT_STARTED: 0,
            +106             /** @const @type {number} */ STARTED:    1,
            +107             /** @const  @type {number}*/ EXPIRED:    2
            +108         },
            +109 
            +110         /**
            +111          * @lends CAAT.Behavior.BaseBehavior
            +112          * @function
            +113          * @param obj a JSON object with a behavior definition.
            +114          */
            +115         parse : function( obj ) {
            +116 
            +117             function findClass( qualifiedClassName ) {
            +118                 var ns= qualifiedClassName.split(".");
            +119                 var _global= window;
            +120                 for( var i=0; i<ns.length; i++ ) {
            +121                     if ( !_global[ns[i]] ) {
            +122                         return null;
            +123                     }
            +124 
            +125                     _global= _global[ns[i]];
            +126                 }
            +127 
            +128                 return _global;
            +129             }
            +130 
            +131             try {
            +132 
            +133                 var type= obj.type.toLowerCase();
            +134                 type= "CAAT.Behavior."+type.substr(0,1).toUpperCase() + type.substr(1) + "Behavior";
            +135                 var cl= new findClass(type);
            +136 
            +137                 var behavior= new cl();
            +138                 behavior.parse(obj);
            +139                 return behavior;
            +140 
            +141             } catch(e) {
            +142                 console.log("Error parsing behavior: "+e);
            +143             }
            +144 
            +145             return null;
            +146         }
            +147     },
            +148     depends:        ["CAAT.Behavior.Interpolator"],
            +149     extendsWith:   function() {
            +150 
            +151         var DefaultInterpolator=    new CAAT.Behavior.Interpolator().createLinearInterpolator(false);
            +152         var DefaultInterpolatorPP=  new CAAT.Behavior.Interpolator().createLinearInterpolator(true);
            +153 
            +154         /** @lends CAAT.Behavior.BaseBehavior.prototype */
            +155         return {
            +156 
            +157             /**
            +158              * @lends CAAT.Behavior.BaseBehavior.prototype
            +159              */
            +160 
            +161             /**
            +162              * Constructor delegate function.
            +163              * @return {this}
            +164              * @private
            +165              */
            +166             __init:function () {
            +167                 this.lifecycleListenerList = [];
            +168                 this.setDefaultInterpolator();
            +169                 return this;
            +170             },
            +171 
            +172             /**
            +173              * Behavior lifecycle observer list.
            +174              * @private
            +175              */
            +176             lifecycleListenerList:null,
            +177 
            +178             /**
            +179              * Behavior application start time related to scene time.
            +180              * @private
            +181              */
            +182             behaviorStartTime:-1,
            +183 
            +184             /**
            +185              * Behavior application duration time related to scene time.
            +186              * @private
            +187              */
            +188             behaviorDuration:-1,
            +189 
            +190             /**
            +191              * Will this behavior apply for ever in a loop ?
            +192              * @private
            +193              */
            +194             cycleBehavior:false,
            +195 
            +196             /**
            +197              * behavior status.
            +198              * @private
            +199              */
            +200             status: CAAT.Behavior.BaseBehavior.Status.NOT_STARTED, // Status.NOT_STARTED
            +201 
            +202             /**
            +203              * An interpolator object to apply behaviors using easing functions, etc.
            +204              * Unless otherwise specified, it will be linearly applied.
            +205              * @type {CAAT.Behavior.Interpolator}
            +206              * @private
            +207              */
            +208             interpolator:null,
            +209 
            +210             /**
            +211              * The actor this behavior will be applied to.
            +212              * @type {CAAT.Foundation.Actor}
            +213              * @private
            +214              */
            +215             actor:null, // actor the Behavior acts on.
            +216 
            +217             /**
            +218              * An id to identify this behavior.
            +219              */
            +220             id:0, // an integer id suitable to identify this behavior by number.
            +221 
            +222             /**
            +223              * Initial offset to apply this behavior the first time.
            +224              * @type {number}
            +225              * @private
            +226              */
            +227             timeOffset:0,
            +228 
            +229             /**
            +230              * Apply the behavior, or just calculate the values ?
            +231              * @type {boolean}
            +232              */
            +233             doValueApplication:true,
            +234 
            +235             /**
            +236              * Is this behavior solved ? When called setDelayTime, this flag identifies whether the behavior
            +237              * is in time relative to the scene.
            +238              * @type {boolean}
            +239              * @private
            +240              */
            +241             solved:true,
            +242 
            +243             /**
            +244              * if true, this behavior will be removed from the this.actor instance when it expires.
            +245              * @type {boolean}
            +246              * @private
            +247              */
            +248             discardable:false,
            +249 
            +250             /**
            +251              * does this behavior apply relative values ??
            +252              */
            +253             isRelative : false,
            +254 
            +255             /**
            +256              * Set this behavior as relative value application to some other measures.
            +257              * Each Behavior will define its own.
            +258              * @param bool
            +259              * @returns {*}
            +260              */
            +261             setRelative : function( bool ) {
            +262                 this.isRelative= bool;
            +263                 return this;
            +264             },
            +265 
            +266             setRelativeValues : function() {
            +267                 this.isRelative= true;
            +268                 return this;
            +269             },
            +270 
            +271             /**
            +272              * Parse a behavior of this type.
            +273              * @param obj {object} an object with a behavior definition.
            +274              */
            +275             parse : function( obj ) {
            +276                 if ( obj.pingpong ) {
            +277                     this.setPingPong();
            +278                 }
            +279                 if ( obj.cycle ) {
            +280                     this.setCycle(true);
            +281                 }
            +282                 var delay= obj.delay || 0;
            +283                 var duration= obj.duration || 1000;
            +284 
            +285                 this.setDelayTime( delay, duration );
            +286 
            +287                 if ( obj.interpolator ) {
            +288                     this.setInterpolator( CAAT.Behavior.Interpolator.parse(obj.interpolator) );
            +289                 }
            +290             },
            +291 
            +292             /**
            +293              * Set whether this behavior will apply behavior values to a reference Actor instance.
            +294              * @param apply {boolean}
            +295              * @return {*}
            +296              */
            +297             setValueApplication:function (apply) {
            +298                 this.doValueApplication = apply;
            +299                 return this;
            +300             },
            +301 
            +302             /**
            +303              * Set this behavior offset time.
            +304              * This method is intended to make a behavior start applying (the first) time from a different
            +305              * start time.
            +306              * @param offset {number} between 0 and 1
            +307              * @return {*}
            +308              */
            +309             setTimeOffset:function (offset) {
            +310                 this.timeOffset = offset;
            +311                 return this;
            +312             },
            +313 
            +314             /**
            +315              * Set this behavior status
            +316              * @param st {CAAT.Behavior.BaseBehavior.Status}
            +317              * @return {*}
            +318              * @private
            +319              */
            +320             setStatus : function(st) {
            +321                 this.status= st;
            +322                 return this;
            +323             },
            +324 
            +325             /**
            +326              * Sets this behavior id.
            +327              * @param id {object}
            +328              *
            +329              */
            +330             setId:function (id) {
            +331                 this.id = id;
            +332                 return this;
            +333             },
            +334 
            +335             /**
            +336              * Sets the default interpolator to a linear ramp, that is, behavior will be applied linearly.
            +337              * @return this
            +338              */
            +339             setDefaultInterpolator:function () {
            +340                 this.interpolator = DefaultInterpolator;
            +341                 return this;
            +342             },
            +343 
            +344             /**
            +345              * Sets default interpolator to be linear from 0..1 and from 1..0.
            +346              * @return this
            +347              */
            +348             setPingPong:function () {
            +349                 this.interpolator = DefaultInterpolatorPP;
            +350                 return this;
            +351             },
            +352 
            +353             /**
            +354              * Sets behavior start time and duration. Start time is set absolutely relative to scene time.
            +355              * @param startTime {number} an integer indicating behavior start time in scene time in ms..
            +356              * @param duration {number} an integer indicating behavior duration in ms.
            +357              */
            +358             setFrameTime:function (startTime, duration) {
            +359                 this.behaviorStartTime = startTime;
            +360                 this.behaviorDuration = duration;
            +361                 this.status =CAAT.Behavior.BaseBehavior.Status.NOT_STARTED;
            +362 
            +363                 return this;
            +364             },
            +365 
            +366             /**
            +367              * Sets behavior start time and duration. Start time is relative to scene time.
            +368              *
            +369              * a call to
            +370              *   setFrameTime( scene.time, duration ) is equivalent to
            +371              *   setDelayTime( 0, duration )
            +372              * @param delay {number}
            +373              * @param duration {number}
            +374              */
            +375             setDelayTime:function (delay, duration) {
            +376                 this.behaviorStartTime = delay;
            +377                 this.behaviorDuration = duration;
            +378                 this.status =CAAT.Behavior.BaseBehavior.Status.NOT_STARTED;
            +379                 this.solved = false;
            +380                 this.expired = false;
            +381 
            +382                 return this;
            +383 
            +384             },
            +385 
            +386             /**
            +387              * Make this behavior not applicable.
            +388              * @return {*}
            +389              */
            +390             setOutOfFrameTime:function () {
            +391                 this.status =CAAT.Behavior.BaseBehavior.Status.EXPIRED;
            +392                 this.behaviorStartTime = Number.MAX_VALUE;
            +393                 this.behaviorDuration = 0;
            +394                 return this;
            +395             },
            +396 
            +397             /**
            +398              * Changes behavior default interpolator to another instance of CAAT.Interpolator.
            +399              * If the behavior is not defined by CAAT.Interpolator factory methods, the interpolation function must return
            +400              * its values in the range 0..1. The behavior will only apply for such value range.
            +401              * @param interpolator a CAAT.Interpolator instance.
            +402              */
            +403             setInterpolator:function (interpolator) {
            +404                 this.interpolator = interpolator;
            +405                 return this;
            +406             },
            +407 
            +408             /**
            +409              * This method must no be called directly.
            +410              * The director loop will call this method in orther to apply actor behaviors.
            +411              * @param time the scene time the behaviro is being applied at.
            +412              * @param actor a CAAT.Actor instance the behavior is being applied to.
            +413              */
            +414             apply:function (time, actor) {
            +415 
            +416                 if (!this.solved) {
            +417                     this.behaviorStartTime += time;
            +418                     this.solved = true;
            +419                 }
            +420 
            +421                 time += this.timeOffset * this.behaviorDuration;
            +422 
            +423                 var orgTime = time;
            +424                 if (this.isBehaviorInTime(time, actor)) {
            +425                     time = this.normalizeTime(time);
            +426                     this.fireBehaviorAppliedEvent(
            +427                         actor,
            +428                         orgTime,
            +429                         time,
            +430                         this.setForTime(time, actor));
            +431                 }
            +432             },
            +433 
            +434             /**
            +435              * Sets the behavior to cycle, ie apply forever.
            +436              * @param bool a boolean indicating whether the behavior is cycle.
            +437              */
            +438             setCycle:function (bool) {
            +439                 this.cycleBehavior = bool;
            +440                 return this;
            +441             },
            +442 
            +443             isCycle : function() {
            +444                 return this.cycleBehavior;
            +445             },
            +446 
            +447             /**
            +448              * Adds an observer to this behavior.
            +449              * @param behaviorListener an observer instance.
            +450              */
            +451             addListener:function (behaviorListener) {
            +452                 this.lifecycleListenerList.push(behaviorListener);
            +453                 return this;
            +454             },
            +455 
            +456             /**
            +457              * Remove all registered listeners to the behavior.
            +458              */
            +459             emptyListenerList:function () {
            +460                 this.lifecycleListenerList = [];
            +461                 return this;
            +462             },
            +463 
            +464             /**
            +465              * @return an integer indicating the behavior start time in ms..
            +466              */
            +467             getStartTime:function () {
            +468                 return this.behaviorStartTime;
            +469             },
            +470 
            +471             /**
            +472              * @return an integer indicating the behavior duration time in ms.
            +473              */
            +474             getDuration:function () {
            +475                 return this.behaviorDuration;
            +476 
            +477             },
            +478 
            +479             /**
            +480              * Chekcs whether the behaviour is in scene time.
            +481              * In case it gets out of scene time, and has not been tagged as expired, the behavior is expired and observers
            +482              * are notified about that fact.
            +483              * @param time the scene time to check the behavior against.
            +484              * @param actor the actor the behavior is being applied to.
            +485              * @return a boolean indicating whether the behavior is in scene time.
            +486              */
            +487             isBehaviorInTime:function (time, actor) {
            +488 
            +489                 var st= CAAT.Behavior.BaseBehavior.Status;
            +490 
            +491                 if (this.status === st.EXPIRED || this.behaviorStartTime < 0) {
            +492                     return false;
            +493                 }
            +494 
            +495                 if (this.cycleBehavior) {
            +496                     if (time >= this.behaviorStartTime) {
            +497                         time = (time - this.behaviorStartTime) % this.behaviorDuration + this.behaviorStartTime;
            +498                     }
            +499                 }
            +500 
            +501                 if (time > this.behaviorStartTime + this.behaviorDuration) {
            +502                     if (this.status !== st.EXPIRED) {
            +503                         this.setExpired(actor, time);
            +504                     }
            +505 
            +506                     return false;
            +507                 }
            +508 
            +509                 if (this.status === st.NOT_STARTED) {
            +510                     this.status = st.STARTED;
            +511                     this.fireBehaviorStartedEvent(actor, time);
            +512                 }
            +513 
            +514                 return this.behaviorStartTime <= time; // && time<this.behaviorStartTime+this.behaviorDuration;
            +515             },
            +516 
            +517             /**
            +518              * Notify observers the first time the behavior is applied.
            +519              * @param actor
            +520              * @param time
            +521              * @private
            +522              */
            +523             fireBehaviorStartedEvent:function (actor, time) {
            +524                 for (var i = 0, l = this.lifecycleListenerList.length; i < l; i++) {
            +525                     var b = this.lifecycleListenerList[i];
            +526                     if (b.behaviorStarted) {
            +527                         b.behaviorStarted(this, time, actor);
            +528                     }
            +529                 }
            +530             },
            +531 
            +532             /**
            +533              * Notify observers about expiration event.
            +534              * @param actor a CAAT.Actor instance
            +535              * @param time an integer with the scene time the behavior was expired at.
            +536              * @private
            +537              */
            +538             fireBehaviorExpiredEvent:function (actor, time) {
            +539                 for (var i = 0, l = this.lifecycleListenerList.length; i < l; i++) {
            +540                     var b = this.lifecycleListenerList[i];
            +541                     if (b.behaviorExpired) {
            +542                         b.behaviorExpired(this, time, actor);
            +543                     }
            +544                 }
            +545             },
            +546 
            +547             /**
            +548              * Notify observers about behavior being applied.
            +549              * @param actor a CAAT.Actor instance the behavior is being applied to.
            +550              * @param time the scene time of behavior application.
            +551              * @param normalizedTime the normalized time (0..1) considering 0 behavior start time and 1
            +552              * behaviorStartTime+behaviorDuration.
            +553              * @param value the value being set for actor properties. each behavior will supply with its own value version.
            +554              * @private
            +555              */
            +556             fireBehaviorAppliedEvent:function (actor, time, normalizedTime, value) {
            +557                 for (var i = 0, l = this.lifecycleListenerList.length; i < l; i++) {
            +558                     var b = this.lifecycleListenerList[i];
            +559                     if (b.behaviorApplied) {
            +560                         b.behaviorApplied(this, time, normalizedTime, actor, value);
            +561                     }
            +562                 }
            +563             },
            +564 
            +565             /**
            +566              * Convert scene time into something more manageable for the behavior.
            +567              * behaviorStartTime will be 0 and behaviorStartTime+behaviorDuration will be 1.
            +568              * the time parameter will be proportional to those values.
            +569              * @param time the scene time to be normalized. an integer.
            +570              * @private
            +571              */
            +572             normalizeTime:function (time) {
            +573                 time = time - this.behaviorStartTime;
            +574                 if (this.cycleBehavior) {
            +575                     time %= this.behaviorDuration;
            +576                 }
            +577 
            +578                 return this.interpolator.getPosition(time / this.behaviorDuration).y;
            +579             },
            +580 
            +581             /**
            +582              * Sets the behavior as expired.
            +583              * This method must not be called directly. It is an auxiliary method to isBehaviorInTime method.
            +584              * @param actor {CAAT.Actor}
            +585              * @param time {integer} the scene time.
            +586              * @private
            +587              */
            +588             setExpired:function (actor, time) {
            +589                 // set for final interpolator value.
            +590                 this.status = CAAT.Behavior.BaseBehavior.Status.EXPIRED;
            +591                 this.setForTime(this.interpolator.getPosition(1).y, actor);
            +592                 this.fireBehaviorExpiredEvent(actor, time);
            +593 
            +594                 if (this.discardable) {
            +595                     this.actor.removeBehavior(this);
            +596                 }
            +597             },
            +598 
            +599             /**
            +600              * This method must be overriden for every Behavior breed.
            +601              * Must not be called directly.
            +602              * @param actor {CAAT.Actor} a CAAT.Actor instance.
            +603              * @param time {number} an integer with the scene time.
            +604              * @private
            +605              */
            +606             setForTime:function (time, actor) {
            +607 
            +608             },
            +609 
            +610             /**
            +611              * @param overrides
            +612              */
            +613             initialize:function (overrides) {
            +614                 if (overrides) {
            +615                     for (var i in overrides) {
            +616                         this[i] = overrides[i];
            +617                     }
            +618                 }
            +619 
            +620                 return this;
            +621             },
            +622 
            +623             /**
            +624              * Get this behaviors CSS property name application.
            +625              * @return {String}
            +626              */
            +627             getPropertyName:function () {
            +628                 return "";
            +629             },
            +630 
            +631             /**
            +632              * Calculate a CSS3 @key-frame for this behavior at the given time.
            +633              * @param time {number}
            +634              */
            +635             calculateKeyFrameData:function (time) {
            +636             },
            +637 
            +638             /**
            +639              * Calculate a CSS3 @key-frame data values instead of building a CSS3 @key-frame value.
            +640              * @param time {number}
            +641              */
            +642             getKeyFrameDataValues : function(time) {
            +643             },
            +644 
            +645             /**
            +646              * Calculate a complete CSS3 @key-frame set for this behavior.
            +647              * @param prefix {string} browser vendor prefix
            +648              * @param name {string} keyframes animation name
            +649              * @param keyframessize {number} number of keyframes to generate
            +650              */
            +651             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +652             }
            +653 
            +654         }
            +655     }
            +656 });
            +657 
            +658 
            +659 
            +660 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ContainerBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ContainerBehavior.js.html new file mode 100644 index 0000000..c04f6a4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ContainerBehavior.js.html @@ -0,0 +1,456 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name ContainerBehavior
            +  5      * @memberOf CAAT.Behavior
            +  6      * @extends CAAT.Behavior.BaseBehavior
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Behavior.ContainerBehavior",
            + 11     depends:["CAAT.Behavior.BaseBehavior", "CAAT.Behavior.GenericBehavior"],
            + 12     aliases: ["CAAT.ContainerBehavior"],
            + 13     extendsClass : "CAAT.Behavior.BaseBehavior",
            + 14     extendsWith:function () {
            + 15 
            + 16         return {
            + 17 
            + 18             /**
            + 19              * @lends CAAT.Behavior.ContainerBehavior.prototype
            + 20              */
            + 21 
            + 22             /**
            + 23              * @inheritDoc
            + 24              */
            + 25             parse : function( obj ) {
            + 26                 if ( obj.behaviors && obj.behaviors.length ) {
            + 27                     for( var i=0; i<obj.behaviors.length; i+=1 ) {
            + 28                         this.addBehavior( CAAT.Behavior.BaseBehavior.parse( obj.behaviors[i] ) );
            + 29                     }
            + 30                 }
            + 31                 CAAT.Behavior.ContainerBehavior.superclass.parse.call(this,obj);
            + 32             },
            + 33 
            + 34             /**
            + 35              * A collection of behaviors.
            + 36              * @type {Array.<CAAT.Behavior.BaseBehavior>}
            + 37              */
            + 38             behaviors:null, // contained behaviors array
            + 39             recursiveCycleBehavior : false,
            + 40             conforming : false,
            + 41 
            + 42             /**
            + 43              * @param conforming {bool=} conform this behavior duration to that of its children.
            + 44              * @inheritDoc
            + 45              * @private
            + 46              */
            + 47             __init:function ( conforming ) {
            + 48                 this.__super();
            + 49                 this.behaviors = [];
            + 50                 if ( conforming ) {
            + 51                     this.conforming= true;
            + 52                 }
            + 53                 return this;
            + 54             },
            + 55 
            + 56             /**
            + 57              * Proportionally change this container duration to its children.
            + 58              * @param duration {number} new duration in ms.
            + 59              * @return this;
            + 60              */
            + 61             conformToDuration:function (duration) {
            + 62                 this.duration = duration;
            + 63 
            + 64                 var f = duration / this.duration;
            + 65                 var bh;
            + 66                 for (var i = 0; i < this.behaviors.length; i++) {
            + 67                     bh = this.behaviors[i];
            + 68                     bh.setFrameTime(bh.getStartTime() * f, bh.getDuration() * f);
            + 69                 }
            + 70 
            + 71                 return this;
            + 72             },
            + 73 
            + 74             /**
            + 75              * Get a behavior by mathing its id.
            + 76              * @param id {object}
            + 77              */
            + 78             getBehaviorById : function(id) {
            + 79                 for( var i=0; i<this.behaviors.length; i++ ) {
            + 80                     if ( this.behaviors[i].id===id ) {
            + 81                         return this.behaviors[i];
            + 82                     }
            + 83                 }
            + 84 
            + 85                 return null;
            + 86             },
            + 87 
            + 88             setCycle : function( cycle, recurse ) {
            + 89                 CAAT.Behavior.ContainerBehavior.superclass.setCycle.call(this,cycle);
            + 90 
            + 91                 if ( recurse ) {
            + 92                     for( var i=0; i<this.behaviors.length; i++ ) {
            + 93                         this.behaviors[i].setCycle(cycle);
            + 94                     }
            + 95                 }
            + 96 
            + 97                 this.recursiveCycleBehavior= recurse;
            + 98 
            + 99                 return this;
            +100             },
            +101 
            +102             /**
            +103              * Add a new behavior to the container.
            +104              * @param behavior {CAAT.Behavior.BaseBehavior}
            +105              */
            +106             addBehavior:function (behavior) {
            +107                 this.behaviors.push(behavior);
            +108                 behavior.addListener(this);
            +109 
            +110                 if ( this.conforming ) {
            +111                     var len= behavior.behaviorDuration + behavior.behaviorStartTime;
            +112                     if ( this.behaviorDuration < len ) {
            +113                         this.behaviorDuration= len;
            +114                         this.behaviorStartTime= 0;
            +115                     }
            +116                 }
            +117 
            +118                 if ( this.recursiveCycleBehavior ) {
            +119                     behavior.setCycle( this.isCycle() );
            +120                 }
            +121 
            +122                 return this;
            +123             },
            +124 
            +125             /**
            +126              * Applies every contained Behaviors.
            +127              * The application time the contained behaviors will receive will be ContainerBehavior related and not the
            +128              * received time.
            +129              * @param time an integer indicating the time to apply the contained behaviors at.
            +130              * @param actor a CAAT.Foundation.Actor instance indicating the actor to apply the behaviors for.
            +131              */
            +132             apply:function (time, actor) {
            +133 
            +134                 if (!this.solved) {
            +135                     this.behaviorStartTime += time;
            +136                     this.solved = true;
            +137                 }
            +138 
            +139                 time += this.timeOffset * this.behaviorDuration;
            +140 
            +141                 if (this.isBehaviorInTime(time, actor)) {
            +142                     time -= this.behaviorStartTime;
            +143                     if (this.cycleBehavior) {
            +144                         time %= this.behaviorDuration;
            +145                     }
            +146 
            +147                     var bh = this.behaviors;
            +148                     for (var i = 0; i < bh.length; i++) {
            +149                         bh[i].apply(time, actor);
            +150                     }
            +151                 }
            +152             },
            +153 
            +154             /**
            +155              * This method is the observer implementation for every contained behavior.
            +156              * If a container is Cycle=true, won't allow its contained behaviors to be expired.
            +157              * @param behavior a CAAT.Behavior.BaseBehavior instance which has been expired.
            +158              * @param time an integer indicating the time at which has become expired.
            +159              * @param actor a CAAT.Foundation.Actor the expired behavior is being applied to.
            +160              */
            +161             behaviorExpired:function (behavior, time, actor) {
            +162                 if (this.cycleBehavior) {
            +163                     behavior.setStatus(CAAT.Behavior.BaseBehavior.Status.STARTED);
            +164                 }
            +165             },
            +166 
            +167             behaviorApplied : function(behavior, scenetime, time, actor, value ) {
            +168                 this.fireBehaviorAppliedEvent(actor, scenetime, time, value);
            +169             },
            +170 
            +171             /**
            +172              * Implementation method of the behavior.
            +173              * Just call implementation method for its contained behaviors.
            +174              * @param time{number} an integer indicating the time the behavior is being applied at.
            +175              * @param actor{CAAT.Foundation.Actor} an actor the behavior is being applied to.
            +176              */
            +177             setForTime:function (time, actor) {
            +178                 var retValue= null;
            +179                 var bh = this.behaviors;
            +180                 for (var i = 0; i < bh.length; i++) {
            +181                     retValue= bh[i].setForTime(time, actor);
            +182                 }
            +183 
            +184                 return retValue;
            +185             },
            +186 
            +187             /**
            +188              * Expire this behavior and the children applied at the parameter time.
            +189              * @param actor {CAAT.Foundation.Actor}
            +190              * @param time {number}
            +191              * @return {*}
            +192              */
            +193             setExpired:function (actor, time) {
            +194 
            +195                 var bh = this.behaviors;
            +196                 // set for final interpolator value.
            +197                 for (var i = 0; i < bh.length; i++) {
            +198                     var bb = bh[i];
            +199                     if ( bb.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED) {
            +200                         bb.setExpired(actor, time - this.behaviorStartTime);
            +201                     }
            +202                 }
            +203 
            +204                 /**
            +205                  * moved here from the beggining of the method.
            +206                  * allow for expiration observers to reset container behavior and its sub-behaviors
            +207                  * to redeem.
            +208                  */
            +209                 CAAT.Behavior.ContainerBehavior.superclass.setExpired.call(this, actor, time);
            +210 
            +211                 return this;
            +212             },
            +213 
            +214             /**
            +215              * @inheritDoc
            +216              */
            +217             setFrameTime:function (start, duration) {
            +218                 CAAT.Behavior.ContainerBehavior.superclass.setFrameTime.call(this, start, duration);
            +219 
            +220                 var bh = this.behaviors;
            +221                 for (var i = 0; i < bh.length; i++) {
            +222                     bh[i].setStatus(CAAT.Behavior.BaseBehavior.Status.NOT_STARTED);
            +223                 }
            +224                 return this;
            +225             },
            +226 
            +227             /**
            +228              * @inheritDoc
            +229              */
            +230             setDelayTime:function (start, duration) {
            +231                 CAAT.Behavior.ContainerBehavior.superclass.setDelayTime.call(this, start, duration);
            +232 
            +233                 var bh = this.behaviors;
            +234                 for (var i = 0; i < bh.length; i++) {
            +235                     bh[i].setStatus(CAAT.Behavior.BaseBehavior.Status.NOT_STARTED);
            +236                 }
            +237                 return this;
            +238             },
            +239 
            +240             /**
            +241              * @inheritDoc
            +242              */
            +243             getKeyFrameDataValues : function(referenceTime) {
            +244 
            +245                 var i, bh, time;
            +246                 var keyFrameData= {
            +247                     angle : 0,
            +248                     scaleX : 1,
            +249                     scaleY : 1,
            +250                     x : 0,
            +251                     y : 0
            +252                 };
            +253 
            +254                 for (i = 0; i < this.behaviors.length; i++) {
            +255                     bh = this.behaviors[i];
            +256                     if (bh.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED && !(bh instanceof CAAT.Behavior.GenericBehavior)) {
            +257 
            +258                         // ajustar tiempos:
            +259                         //  time es tiempo normalizado a duracion de comportamiento contenedor.
            +260                         //      1.- desnormalizar
            +261                         time = referenceTime * this.behaviorDuration;
            +262 
            +263                         //      2.- calcular tiempo relativo de comportamiento respecto a contenedor
            +264                         if (bh.behaviorStartTime <= time && bh.behaviorStartTime + bh.behaviorDuration >= time) {
            +265                             //      3.- renormalizar tiempo reltivo a comportamiento.
            +266                             time = (time - bh.behaviorStartTime) / bh.behaviorDuration;
            +267 
            +268                             //      4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor
            +269                             var obj= bh.getKeyFrameDataValues(time);
            +270                             for( var pr in obj ) {
            +271                                 keyFrameData[pr]= obj[pr];
            +272                             }
            +273                         }
            +274                     }
            +275                 }
            +276 
            +277                 return keyFrameData;
            +278             },
            +279 
            +280             /**
            +281              * @inheritDoc
            +282              */
            +283             calculateKeyFrameData:function (referenceTime, prefix) {
            +284 
            +285                 var i;
            +286                 var bh;
            +287 
            +288                 var retValue = {};
            +289                 var time;
            +290                 var cssRuleValue;
            +291                 var cssProperty;
            +292                 var property;
            +293 
            +294                 for (i = 0; i < this.behaviors.length; i++) {
            +295                     bh = this.behaviors[i];
            +296                     if (bh.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED && !(bh instanceof CAAT.Behavior.GenericBehavior)) {
            +297 
            +298                         // ajustar tiempos:
            +299                         //  time es tiempo normalizado a duracion de comportamiento contenedor.
            +300                         //      1.- desnormalizar
            +301                         time = referenceTime * this.behaviorDuration;
            +302 
            +303                         //      2.- calcular tiempo relativo de comportamiento respecto a contenedor
            +304                         if (bh.behaviorStartTime <= time && bh.behaviorStartTime + bh.behaviorDuration >= time) {
            +305                             //      3.- renormalizar tiempo reltivo a comportamiento.
            +306                             time = (time - bh.behaviorStartTime) / bh.behaviorDuration;
            +307 
            +308                             //      4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor
            +309                             cssRuleValue = bh.calculateKeyFrameData(time);
            +310                             cssProperty = bh.getPropertyName(prefix);
            +311 
            +312                             if (typeof retValue[cssProperty] === 'undefined') {
            +313                                 retValue[cssProperty] = "";
            +314                             }
            +315 
            +316                             //      5.- asignar a objeto, par de propiedad/valor css
            +317                             retValue[cssProperty] += cssRuleValue + " ";
            +318                         }
            +319 
            +320                     }
            +321                 }
            +322 
            +323 
            +324                 var tr = "";
            +325                 var pv;
            +326 
            +327                 function xx(pr) {
            +328                     if (retValue[pr]) {
            +329                         tr += retValue[pr];
            +330                     } else {
            +331                         if (prevValues) {
            +332                             pv = prevValues[pr];
            +333                             if (pv) {
            +334                                 tr += pv;
            +335                                 retValue[pr] = pv;
            +336                             }
            +337                         }
            +338                     }
            +339                 }
            +340 
            +341                 xx('translate');
            +342                 xx('rotate');
            +343                 xx('scale');
            +344 
            +345                 var keyFrameRule = "";
            +346 
            +347                 if (tr) {
            +348                     keyFrameRule = '-' + prefix + '-transform: ' + tr + ';';
            +349                 }
            +350 
            +351                 tr = "";
            +352                 xx('opacity');
            +353                 if (tr) {
            +354                     keyFrameRule += ' opacity: ' + tr + ';';
            +355                 }
            +356 
            +357                 keyFrameRule+=" -webkit-transform-origin: 0% 0%";
            +358 
            +359                 return {
            +360                     rules:keyFrameRule,
            +361                     ret:retValue
            +362                 };
            +363 
            +364             },
            +365 
            +366             /**
            +367              * @inheritDoc
            +368              */
            +369             calculateKeyFramesData:function (prefix, name, keyframessize, anchorX, anchorY) {
            +370 
            +371                 function toKeyFrame(obj, prevKF) {
            +372 
            +373                     for( var i in prevKF ) {
            +374                         if ( !obj[i] ) {
            +375                             obj[i]= prevKF[i];
            +376                         }
            +377                     }
            +378 
            +379                     var ret= "-" + prefix + "-transform:";
            +380 
            +381                     if ( obj.x || obj.y ) {
            +382                         var x= obj.x || 0;
            +383                         var y= obj.y || 0;
            +384                         ret+= "translate("+x+"px,"+y+"px)";
            +385                     }
            +386 
            +387                     if ( obj.angle ) {
            +388                         ret+= " rotate("+obj.angle+"rad)";
            +389                     }
            +390 
            +391                     if ( obj.scaleX!==1 || obj.scaleY!==1 ) {
            +392                         ret+= " scale("+(obj.scaleX)+","+(obj.scaleY)+")";
            +393                     }
            +394 
            +395                     ret+=";";
            +396 
            +397                     if ( obj.alpha ) {
            +398                         ret+= " opacity: "+obj.alpha+";";
            +399                     }
            +400 
            +401                     if ( anchorX!==.5 || anchorY!==.5) {
            +402                         ret+= " -" + prefix + "-transform-origin:"+ (anchorX*100) + "% " + (anchorY*100) + "%;";
            +403                     }
            +404 
            +405                     return ret;
            +406                 }
            +407 
            +408                 if (this.duration === Number.MAX_VALUE) {
            +409                     return "";
            +410                 }
            +411 
            +412                 if (typeof anchorX==="undefined") {
            +413                     anchorX= .5;
            +414                 }
            +415 
            +416                 if (typeof anchorY==="undefined") {
            +417                     anchorY= .5;
            +418                 }
            +419 
            +420                 if (typeof keyframessize === 'undefined') {
            +421                     keyframessize = 100;
            +422                 }
            +423 
            +424                 var i;
            +425                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +426                 var time;
            +427                 var prevKF= {};
            +428 
            +429                 for (i = 0; i <= keyframessize; i++) {
            +430                     time = this.interpolator.getPosition(i / keyframessize).y;
            +431 
            +432                     var obj = this.getKeyFrameDataValues(time);
            +433 
            +434                     kfd += "" +
            +435                         (i / keyframessize * 100) + "%" + // percentage
            +436                         "{" + toKeyFrame(obj, prevKF) + "}\n";
            +437 
            +438                     prevKF= obj;
            +439 
            +440                 }
            +441 
            +442                 kfd += "}\n";
            +443 
            +444                 return kfd;
            +445             }
            +446         }
            +447     }
            +448 });
            +449 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_GenericBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_GenericBehavior.js.html new file mode 100644 index 0000000..2b46f49 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_GenericBehavior.js.html @@ -0,0 +1,87 @@ +
              1 CAAT.Module({
            +  2     /**
            +  3      * @name GenericBehavior
            +  4      * @memberOf CAAT.Behavior
            +  5      * @extends CAAT.Behavior.BaseBehavior
            +  6      * @constructor
            +  7      */
            +  8     defines:"CAAT.Behavior.GenericBehavior",
            +  9     depends:["CAAT.Behavior.BaseBehavior"],
            + 10     aliases:["CAAT.GenericBehavior"],
            + 11     extendsClass:"CAAT.Behavior.BaseBehavior",
            + 12     extendsWith:function () {
            + 13 
            + 14         return {
            + 15 
            + 16             /**
            + 17              *  @lends CAAT.Behavior.GenericBehavior.prototype
            + 18              */
            + 19 
            + 20 
            + 21             /**
            + 22              * starting value.
            + 23              */
            + 24             start:0,
            + 25 
            + 26             /**
            + 27              * ending value.
            + 28              */
            + 29             end:0,
            + 30 
            + 31             /**
            + 32              * target to apply this generic behvior.
            + 33              */
            + 34             target:null,
            + 35 
            + 36             /**
            + 37              * property to apply values to.
            + 38              */
            + 39             property:null,
            + 40 
            + 41             /**
            + 42              * this callback will be invoked for every behavior application.
            + 43              */
            + 44             callback:null,
            + 45 
            + 46             /**
            + 47              * @inheritDoc
            + 48              */
            + 49             setForTime:function (time, actor) {
            + 50                 var value = this.start + time * (this.end - this.start);
            + 51                 if (this.callback) {
            + 52                     this.callback(value, this.target, actor);
            + 53                 }
            + 54 
            + 55                 if (this.property) {
            + 56                     this.target[this.property] = value;
            + 57                 }
            + 58             },
            + 59 
            + 60             /**
            + 61              * Defines the values to apply this behavior.
            + 62              *
            + 63              * @param start {number} initial behavior value.
            + 64              * @param end {number} final behavior value.
            + 65              * @param target {object} an object. Usually a CAAT.Actor.
            + 66              * @param property {string} target object's property to set value to.
            + 67              * @param callback {function} a function of the form <code>function( target, value )</code>.
            + 68              */
            + 69             setValues:function (start, end, target, property, callback) {
            + 70                 this.start = start;
            + 71                 this.end = end;
            + 72                 this.target = target;
            + 73                 this.property = property;
            + 74                 this.callback = callback;
            + 75                 return this;
            + 76             }
            + 77         };
            + 78     }
            + 79 });
            + 80 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Interpolator.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Interpolator.js.html new file mode 100644 index 0000000..f39c05c --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Interpolator.js.html @@ -0,0 +1,493 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Partially based on Robert Penner easing equations.
            +  5  * http://www.robertpenner.com/easing/
            +  6  *
            +  7  *
            +  8  **/
            +  9 
            + 10 CAAT.Module({
            + 11 
            + 12     /**
            + 13      * @name Interpolator
            + 14      * @memberOf CAAT.Behavior
            + 15      * @constructor
            + 16      */
            + 17 
            + 18     defines:"CAAT.Behavior.Interpolator",
            + 19     depends:["CAAT.Math.Point"],
            + 20     aliases:["CAAT.Interpolator"],
            + 21     constants : {
            + 22         /**
            + 23          * @lends CAAT.Behavior.Interpolator
            + 24          */
            + 25 
            + 26         enumerateInterpolators: function () {
            + 27             return [
            + 28                 new CAAT.Behavior.Interpolator().createLinearInterpolator(false, false), 'Linear pingpong=false, inverse=false',
            + 29                 new CAAT.Behavior.Interpolator().createLinearInterpolator(true, false), 'Linear pingpong=true, inverse=false',
            + 30 
            + 31                 new CAAT.Behavior.Interpolator().createBackOutInterpolator(false), 'BackOut pingpong=true, inverse=false',
            + 32                 new CAAT.Behavior.Interpolator().createBackOutInterpolator(true), 'BackOut pingpong=true, inverse=true',
            + 33 
            + 34                 new CAAT.Behavior.Interpolator().createLinearInterpolator(false, true), 'Linear pingpong=false, inverse=true',
            + 35                 new CAAT.Behavior.Interpolator().createLinearInterpolator(true, true), 'Linear pingpong=true, inverse=true',
            + 36 
            + 37                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, false), 'ExponentialIn pingpong=false, exponent=2',
            + 38                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, false), 'ExponentialOut pingpong=false, exponent=2',
            + 39                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, false), 'ExponentialInOut pingpong=false, exponent=2',
            + 40                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, true), 'ExponentialIn pingpong=true, exponent=2',
            + 41                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, true), 'ExponentialOut pingpong=true, exponent=2',
            + 42                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, true), 'ExponentialInOut pingpong=true, exponent=2',
            + 43 
            + 44                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, false), 'ExponentialIn pingpong=false, exponent=4',
            + 45                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, false), 'ExponentialOut pingpong=false, exponent=4',
            + 46                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, false), 'ExponentialInOut pingpong=false, exponent=4',
            + 47                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, true), 'ExponentialIn pingpong=true, exponent=4',
            + 48                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, true), 'ExponentialOut pingpong=true, exponent=4',
            + 49                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, true), 'ExponentialInOut pingpong=true, exponent=4',
            + 50 
            + 51                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, false), 'ExponentialIn pingpong=false, exponent=6',
            + 52                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, false), 'ExponentialOut pingpong=false, exponent=6',
            + 53                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, false), 'ExponentialInOut pingpong=false, exponent=6',
            + 54                 new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, true), 'ExponentialIn pingpong=true, exponent=6',
            + 55                 new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, true), 'ExponentialOut pingpong=true, exponent=6',
            + 56                 new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, true), 'ExponentialInOut pingpong=true, exponent=6',
            + 57 
            + 58                 new CAAT.Behavior.Interpolator().createBounceInInterpolator(false), 'BounceIn pingpong=false',
            + 59                 new CAAT.Behavior.Interpolator().createBounceOutInterpolator(false), 'BounceOut pingpong=false',
            + 60                 new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(false), 'BounceInOut pingpong=false',
            + 61                 new CAAT.Behavior.Interpolator().createBounceInInterpolator(true), 'BounceIn pingpong=true',
            + 62                 new CAAT.Behavior.Interpolator().createBounceOutInterpolator(true), 'BounceOut pingpong=true',
            + 63                 new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(true), 'BounceInOut pingpong=true',
            + 64 
            + 65                 new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, false), 'ElasticIn pingpong=false, amp=1.1, d=.4',
            + 66                 new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, false), 'ElasticOut pingpong=false, amp=1.1, d=.4',
            + 67                 new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, false), 'ElasticInOut pingpong=false, amp=1.1, d=.4',
            + 68                 new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, true), 'ElasticIn pingpong=true, amp=1.1, d=.4',
            + 69                 new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, true), 'ElasticOut pingpong=true, amp=1.1, d=.4',
            + 70                 new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, true), 'ElasticInOut pingpong=true, amp=1.1, d=.4',
            + 71 
            + 72                 new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, false), 'ElasticIn pingpong=false, amp=1.0, d=.2',
            + 73                 new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, false), 'ElasticOut pingpong=false, amp=1.0, d=.2',
            + 74                 new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, false), 'ElasticInOut pingpong=false, amp=1.0, d=.2',
            + 75                 new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, true), 'ElasticIn pingpong=true, amp=1.0, d=.2',
            + 76                 new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, true), 'ElasticOut pingpong=true, amp=1.0, d=.2',
            + 77                 new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, true), 'ElasticInOut pingpong=true, amp=1.0, d=.2'
            + 78             ];
            + 79         },
            + 80 
            + 81         parse : function( obj ) {
            + 82             var name= "create"+obj.type+"Interpolator";
            + 83             var interpolator= new CAAT.Behavior.Interpolator();
            + 84             try {
            + 85                 interpolator[name].apply( interpolator, obj.params||[] );
            + 86             } catch(e) {
            + 87                 interpolator.createLinearInterpolator(false, false);
            + 88             }
            + 89 
            + 90             return interpolator;
            + 91         }
            + 92 
            + 93     },
            + 94     extendsWith:function () {
            + 95 
            + 96         return {
            + 97 
            + 98             /**
            + 99              * @lends CAAT.Behavior.Interpolator.prototype
            +100              */
            +101 
            +102             interpolated:null, // a coordinate holder for not building a new CAAT.Point for each interpolation call.
            +103             paintScale:90, // the size of the interpolation draw on screen in pixels.
            +104 
            +105             __init:function () {
            +106                 this.interpolated = new CAAT.Math.Point(0, 0, 0);
            +107                 return this;
            +108             },
            +109 
            +110             /**
            +111              * Set a linear interpolation function.
            +112              *
            +113              * @param bPingPong {boolean}
            +114              * @param bInverse {boolean} will values will be from 1 to 0 instead of 0 to 1 ?.
            +115              */
            +116             createLinearInterpolator:function (bPingPong, bInverse) {
            +117                 /**
            +118                  * Linear and inverse linear interpolation function.
            +119                  * @param time {number}
            +120                  */
            +121                 this.getPosition = function getPosition(time) {
            +122 
            +123                     var orgTime = time;
            +124 
            +125                     if (bPingPong) {
            +126                         if (time < 0.5) {
            +127                             time *= 2;
            +128                         } else {
            +129                             time = 1 - (time - 0.5) * 2;
            +130                         }
            +131                     }
            +132 
            +133                     if (bInverse !== null && bInverse) {
            +134                         time = 1 - time;
            +135                     }
            +136 
            +137                     return this.interpolated.set(orgTime, time);
            +138                 };
            +139 
            +140                 return this;
            +141             },
            +142 
            +143             createBackOutInterpolator:function (bPingPong) {
            +144                 this.getPosition = function getPosition(time) {
            +145                     var orgTime = time;
            +146 
            +147                     if (bPingPong) {
            +148                         if (time < 0.5) {
            +149                             time *= 2;
            +150                         } else {
            +151                             time = 1 - (time - 0.5) * 2;
            +152                         }
            +153                     }
            +154 
            +155                     time = time - 1;
            +156                     var overshoot = 1.70158;
            +157 
            +158                     return this.interpolated.set(
            +159                         orgTime,
            +160                         time * time * ((overshoot + 1) * time + overshoot) + 1);
            +161                 };
            +162 
            +163                 return this;
            +164             },
            +165             /**
            +166              * Set an exponential interpolator function. The function to apply will be Math.pow(time,exponent).
            +167              * This function starts with 0 and ends in values of 1.
            +168              *
            +169              * @param exponent {number} exponent of the function.
            +170              * @param bPingPong {boolean}
            +171              */
            +172             createExponentialInInterpolator:function (exponent, bPingPong) {
            +173                 this.getPosition = function getPosition(time) {
            +174                     var orgTime = time;
            +175 
            +176                     if (bPingPong) {
            +177                         if (time < 0.5) {
            +178                             time *= 2;
            +179                         } else {
            +180                             time = 1 - (time - 0.5) * 2;
            +181                         }
            +182                     }
            +183                     return this.interpolated.set(orgTime, Math.pow(time, exponent));
            +184                 };
            +185 
            +186                 return this;
            +187             },
            +188             /**
            +189              * Set an exponential interpolator function. The function to apply will be 1-Math.pow(time,exponent).
            +190              * This function starts with 1 and ends in values of 0.
            +191              *
            +192              * @param exponent {number} exponent of the function.
            +193              * @param bPingPong {boolean}
            +194              */
            +195             createExponentialOutInterpolator:function (exponent, bPingPong) {
            +196                 this.getPosition = function getPosition(time) {
            +197                     var orgTime = time;
            +198 
            +199                     if (bPingPong) {
            +200                         if (time < 0.5) {
            +201                             time *= 2;
            +202                         } else {
            +203                             time = 1 - (time - 0.5) * 2;
            +204                         }
            +205                     }
            +206                     return this.interpolated.set(orgTime, 1 - Math.pow(1 - time, exponent));
            +207                 };
            +208 
            +209                 return this;
            +210             },
            +211             /**
            +212              * Set an exponential interpolator function. Two functions will apply:
            +213              * Math.pow(time*2,exponent)/2 for the first half of the function (t<0.5) and
            +214              * 1-Math.abs(Math.pow(time*2-2,exponent))/2 for the second half (t>=.5)
            +215              * This function starts with 0 and goes to values of 1 and ends with values of 0.
            +216              *
            +217              * @param exponent {number} exponent of the function.
            +218              * @param bPingPong {boolean}
            +219              */
            +220             createExponentialInOutInterpolator:function (exponent, bPingPong) {
            +221                 this.getPosition = function getPosition(time) {
            +222                     var orgTime = time;
            +223 
            +224                     if (bPingPong) {
            +225                         if (time < 0.5) {
            +226                             time *= 2;
            +227                         } else {
            +228                             time = 1 - (time - 0.5) * 2;
            +229                         }
            +230                     }
            +231                     if (time * 2 < 1) {
            +232                         return this.interpolated.set(orgTime, Math.pow(time * 2, exponent) / 2);
            +233                     }
            +234 
            +235                     return this.interpolated.set(orgTime, 1 - Math.abs(Math.pow(time * 2 - 2, exponent)) / 2);
            +236                 };
            +237 
            +238                 return this;
            +239             },
            +240             /**
            +241              * Creates a Quadric bezier curbe as interpolator.
            +242              *
            +243              * @param p0 {CAAT.Math.Point}
            +244              * @param p1 {CAAT.Math.Point}
            +245              * @param p2 {CAAT.Math.Point}
            +246              * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong.
            +247              */
            +248             createQuadricBezierInterpolator:function (p0, p1, p2, bPingPong) {
            +249                 this.getPosition = function getPosition(time) {
            +250                     var orgTime = time;
            +251 
            +252                     if (bPingPong) {
            +253                         if (time < 0.5) {
            +254                             time *= 2;
            +255                         } else {
            +256                             time = 1 - (time - 0.5) * 2;
            +257                         }
            +258                     }
            +259 
            +260                     time = (1 - time) * (1 - time) * p0.y + 2 * (1 - time) * time * p1.y + time * time * p2.y;
            +261 
            +262                     return this.interpolated.set(orgTime, time);
            +263                 };
            +264 
            +265                 return this;
            +266             },
            +267             /**
            +268              * Creates a Cubic bezier curbe as interpolator.
            +269              *
            +270              * @param p0 {CAAT.Math.Point}
            +271              * @param p1 {CAAT.Math.Point}
            +272              * @param p2 {CAAT.Math.Point}
            +273              * @param p3 {CAAT.Math.Point}
            +274              * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong.
            +275              */
            +276             createCubicBezierInterpolator:function (p0, p1, p2, p3, bPingPong) {
            +277                 this.getPosition = function getPosition(time) {
            +278                     var orgTime = time;
            +279 
            +280                     if (bPingPong) {
            +281                         if (time < 0.5) {
            +282                             time *= 2;
            +283                         } else {
            +284                             time = 1 - (time - 0.5) * 2;
            +285                         }
            +286                     }
            +287 
            +288                     var t2 = time * time;
            +289                     var t3 = time * t2;
            +290 
            +291                     time = (p0.y + time * (-p0.y * 3 + time * (3 * p0.y -
            +292                         p0.y * time))) + time * (3 * p1.y + time * (-6 * p1.y +
            +293                         p1.y * 3 * time)) + t2 * (p2.y * 3 - p2.y * 3 * time) +
            +294                         p3.y * t3;
            +295 
            +296                     return this.interpolated.set(orgTime, time);
            +297                 };
            +298 
            +299                 return this;
            +300             },
            +301             createElasticOutInterpolator:function (amplitude, p, bPingPong) {
            +302                 this.getPosition = function getPosition(time) {
            +303 
            +304                     if (bPingPong) {
            +305                         if (time < 0.5) {
            +306                             time *= 2;
            +307                         } else {
            +308                             time = 1 - (time - 0.5) * 2;
            +309                         }
            +310                     }
            +311 
            +312                     if (time === 0) {
            +313                         return {x:0, y:0};
            +314                     }
            +315                     if (time === 1) {
            +316                         return {x:1, y:1};
            +317                     }
            +318 
            +319                     var s = p / (2 * Math.PI) * Math.asin(1 / amplitude);
            +320                     return this.interpolated.set(
            +321                         time,
            +322                         (amplitude * Math.pow(2, -10 * time) * Math.sin((time - s) * (2 * Math.PI) / p) + 1 ));
            +323                 };
            +324                 return this;
            +325             },
            +326             createElasticInInterpolator:function (amplitude, p, bPingPong) {
            +327                 this.getPosition = function getPosition(time) {
            +328 
            +329                     if (bPingPong) {
            +330                         if (time < 0.5) {
            +331                             time *= 2;
            +332                         } else {
            +333                             time = 1 - (time - 0.5) * 2;
            +334                         }
            +335                     }
            +336 
            +337                     if (time === 0) {
            +338                         return {x:0, y:0};
            +339                     }
            +340                     if (time === 1) {
            +341                         return {x:1, y:1};
            +342                     }
            +343 
            +344                     var s = p / (2 * Math.PI) * Math.asin(1 / amplitude);
            +345                     return this.interpolated.set(
            +346                         time,
            +347                         -(amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p) ));
            +348                 };
            +349 
            +350                 return this;
            +351             },
            +352             createElasticInOutInterpolator:function (amplitude, p, bPingPong) {
            +353                 this.getPosition = function getPosition(time) {
            +354 
            +355                     if (bPingPong) {
            +356                         if (time < 0.5) {
            +357                             time *= 2;
            +358                         } else {
            +359                             time = 1 - (time - 0.5) * 2;
            +360                         }
            +361                     }
            +362 
            +363                     var s = p / (2 * Math.PI) * Math.asin(1 / amplitude);
            +364                     time *= 2;
            +365                     if (time <= 1) {
            +366                         return this.interpolated.set(
            +367                             time,
            +368                             -0.5 * (amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p)));
            +369                     }
            +370 
            +371                     return this.interpolated.set(
            +372                         time,
            +373                         1 + 0.5 * (amplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p)));
            +374                 };
            +375 
            +376                 return this;
            +377             },
            +378             /**
            +379              * @param time {number}
            +380              * @private
            +381              */
            +382             bounce:function (time) {
            +383                 if ((time /= 1) < (1 / 2.75)) {
            +384                     return {x:time, y:7.5625 * time * time};
            +385                 } else if (time < (2 / 2.75)) {
            +386                     return {x:time, y:7.5625 * (time -= (1.5 / 2.75)) * time + 0.75};
            +387                 } else if (time < (2.5 / 2.75)) {
            +388                     return {x:time, y:7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375};
            +389                 } else {
            +390                     return {x:time, y:7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375};
            +391                 }
            +392             },
            +393             createBounceOutInterpolator:function (bPingPong) {
            +394                 this.getPosition = function getPosition(time) {
            +395                     if (bPingPong) {
            +396                         if (time < 0.5) {
            +397                             time *= 2;
            +398                         } else {
            +399                             time = 1 - (time - 0.5) * 2;
            +400                         }
            +401                     }
            +402                     return this.bounce(time);
            +403                 };
            +404 
            +405                 return this;
            +406             },
            +407             createBounceInInterpolator:function (bPingPong) {
            +408 
            +409                 this.getPosition = function getPosition(time) {
            +410                     if (bPingPong) {
            +411                         if (time < 0.5) {
            +412                             time *= 2;
            +413                         } else {
            +414                             time = 1 - (time - 0.5) * 2;
            +415                         }
            +416                     }
            +417                     var r = this.bounce(1 - time);
            +418                     r.y = 1 - r.y;
            +419                     return r;
            +420                 };
            +421 
            +422                 return this;
            +423             },
            +424             createBounceInOutInterpolator:function (bPingPong) {
            +425 
            +426                 this.getPosition = function getPosition(time) {
            +427                     if (bPingPong) {
            +428                         if (time < 0.5) {
            +429                             time *= 2;
            +430                         } else {
            +431                             time = 1 - (time - 0.5) * 2;
            +432                         }
            +433                     }
            +434 
            +435                     var r;
            +436                     if (time < 0.5) {
            +437                         r = this.bounce(1 - time * 2);
            +438                         r.y = (1 - r.y) * 0.5;
            +439                         return r;
            +440                     }
            +441                     r = this.bounce(time * 2 - 1, bPingPong);
            +442                     r.y = r.y * 0.5 + 0.5;
            +443                     return r;
            +444                 };
            +445 
            +446                 return this;
            +447             },
            +448 
            +449             /**
            +450              * Paints an interpolator on screen.
            +451              * @param ctx {CanvasRenderingContext}
            +452              */
            +453             paint:function (ctx) {
            +454 
            +455                 ctx.save();
            +456                 ctx.beginPath();
            +457 
            +458                 ctx.moveTo(0, this.getPosition(0).y * this.paintScale);
            +459 
            +460                 for (var i = 0; i <= this.paintScale; i++) {
            +461                     ctx.lineTo(i, this.getPosition(i / this.paintScale).y * this.paintScale);
            +462                 }
            +463 
            +464                 ctx.strokeStyle = 'black';
            +465                 ctx.stroke();
            +466                 ctx.restore();
            +467             },
            +468 
            +469             /**
            +470              * Gets an array of coordinates which define the polyline of the intepolator's curve contour.
            +471              * Values for both coordinates range from 0 to 1.
            +472              * @param iSize {number} an integer indicating the number of contour segments.
            +473              * @return Array.<CAAT.Math.Point> of object of the form {x:float, y:float}.
            +474              */
            +475             getContour:function (iSize) {
            +476                 var contour = [];
            +477                 for (var i = 0; i <= iSize; i++) {
            +478                     contour.push({x:i / iSize, y:this.getPosition(i / iSize).y});
            +479                 }
            +480 
            +481                 return contour;
            +482             }
            +483         }
            +484     }
            +485 });
            +486 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_PathBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_PathBehavior.js.html new file mode 100644 index 0000000..8439fe2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_PathBehavior.js.html @@ -0,0 +1,352 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name PathBehavior
            +  5      * @memberOf CAAT.Behavior
            +  6      * @extends CAAT.Behavior.BaseBehavior
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     /**
            + 11      *
            + 12      * Internal PathBehavior rotation constants.
            + 13      *
            + 14      * @name AUTOROTATE
            + 15      * @memberOf CAAT.Behavior.PathBehavior
            + 16      * @namespace
            + 17      * @enum {number}
            + 18      */
            + 19 
            + 20     /**
            + 21      *
            + 22      * Internal PathBehavior rotation constants.
            + 23      *
            + 24      * @name autorotate
            + 25      * @memberOf CAAT.Behavior.PathBehavior
            + 26      * @namespace
            + 27      * @enum {number}
            + 28      * @deprecated
            + 29      */
            + 30 
            + 31     defines:"CAAT.Behavior.PathBehavior",
            + 32     aliases: ["CAAT.PathBehavior"],
            + 33     depends:[
            + 34         "CAAT.Behavior.BaseBehavior",
            + 35         "CAAT.Foundation.SpriteImage"
            + 36     ],
            + 37     constants : {
            + 38 
            + 39         AUTOROTATE : {
            + 40 
            + 41             /**
            + 42              * @lends CAAT.Behavior.PathBehavior.AUTOROTATE
            + 43              */
            + 44 
            + 45             /** @const */ LEFT_TO_RIGHT:  0,
            + 46             /** @const */ RIGHT_TO_LEFT:  1,
            + 47             /** @const */ FREE:           2
            + 48         },
            + 49 
            + 50         autorotate: {
            + 51             /**
            + 52              * @lends CAAT.Behavior.PathBehavior.autorotate
            + 53              */
            + 54 
            + 55             /** @const */ LEFT_TO_RIGHT:  0,
            + 56             /** @const */ RIGHT_TO_LEFT:  1,
            + 57             /** @const */ FREE:           2
            + 58         }
            + 59     },
            + 60     extendsClass : "CAAT.Behavior.BaseBehavior",
            + 61     extendsWith:function () {
            + 62 
            + 63         return {
            + 64 
            + 65             /**
            + 66              * @lends CAAT.Behavior.PathBehavior.prototype
            + 67              * @param obj
            + 68              */
            + 69 
            + 70             /**
            + 71              * @inheritDoc
            + 72              */
            + 73             parse : function( obj ) {
            + 74                 CAAT.Behavior.PathBehavior.superclass.parse.call(this,obj);
            + 75 
            + 76                 if ( obj.SVG ) {
            + 77                     var parser= new CAAT.PathUtil.SVGPath();
            + 78                     var path=parser.parsePath( obj.SVG );
            + 79                     this.setValues(path);
            + 80                 }
            + 81 
            + 82                 if ( obj.autoRotate ) {
            + 83                     this.autoRotate= obj.autoRotate;
            + 84                 }
            + 85             },
            + 86 
            + 87             /**
            + 88              * A path to traverse.
            + 89              * @type {CAAT.PathUtil.Path}
            + 90              * @private
            + 91              */
            + 92             path:null,
            + 93 
            + 94             /**
            + 95              * Whether to set rotation angle while traversing the path.
            + 96              * @private
            + 97              */
            + 98             autoRotate:false,
            + 99 
            +100             prevX:-1, // private, do not use.
            +101             prevY:-1, // private, do not use.
            +102 
            +103             /**
            +104              * Autorotation hint.
            +105              * @type {CAAT.Behavior.PathBehavior.autorotate}
            +106              * @private
            +107              */
            +108             autoRotateOp: CAAT.Behavior.PathBehavior.autorotate.FREE,
            +109 
            +110             isOpenContour : false,
            +111 
            +112             relativeX : 0,
            +113             relativeY : 0,
            +114 
            +115             setOpenContour : function(b) {
            +116                 this.isOpenContour= b;
            +117                 return this;
            +118             },
            +119 
            +120             /**
            +121              * @inheritDoc
            +122              */
            +123             getPropertyName:function () {
            +124                 return "translate";
            +125             },
            +126 
            +127             setRelativeValues : function( x, y ) {
            +128                 this.relativeX= x;
            +129                 this.relativeY= y;
            +130                 this.isRelative= true;
            +131                 return this;
            +132             },
            +133 
            +134 
            +135             /**
            +136              * Sets an actor rotation to be heading from past to current path's point.
            +137              * Take into account that this will be incompatible with rotation Behaviors
            +138              * since they will set their own rotation configuration.
            +139              * @param autorotate {boolean}
            +140              * @param autorotateOp {CAAT.PathBehavior.autorotate} whether the sprite is drawn heading to the right.
            +141              * @return this.
            +142              */
            +143             setAutoRotate:function (autorotate, autorotateOp) {
            +144                 this.autoRotate = autorotate;
            +145                 if (autorotateOp !== undefined) {
            +146                     this.autoRotateOp = autorotateOp;
            +147                 }
            +148                 return this;
            +149             },
            +150 
            +151             /**
            +152              * Set the behavior path.
            +153              * The path can be any length, and will take behaviorDuration time to be traversed.
            +154              * @param {CAAT.Path}
            +155                 *
            +156              * @deprecated
            +157              */
            +158             setPath:function (path) {
            +159                 this.path = path;
            +160                 return this;
            +161             },
            +162 
            +163             /**
            +164              * Set the behavior path.
            +165              * The path can be any length, and will take behaviorDuration time to be traversed.
            +166              * @param {CAAT.Path}
            +167                 * @return this
            +168              */
            +169             setValues:function (path) {
            +170                 return this.setPath(path);
            +171             },
            +172 
            +173             /**
            +174              * @see Actor.setPositionAnchor
            +175              * @deprecated
            +176              * @param tx a float with xoffset.
            +177              * @param ty a float with yoffset.
            +178              */
            +179             setTranslation:function (tx, ty) {
            +180                 return this;
            +181             },
            +182 
            +183             /**
            +184              * @inheritDoc
            +185              */
            +186             calculateKeyFrameData:function (time) {
            +187                 time = this.interpolator.getPosition(time).y;
            +188                 var point = this.path.getPosition(time);
            +189                 return "translateX(" + point.x + "px) translateY(" + point.y + "px)";
            +190             },
            +191 
            +192             /**
            +193              * @inheritDoc
            +194              */
            +195             getKeyFrameDataValues : function(time) {
            +196                 time = this.interpolator.getPosition(time).y;
            +197                 var point = this.path.getPosition(time);
            +198                 var obj= {
            +199                     x : point.x,
            +200                     y : point.y
            +201                 };
            +202 
            +203                 if ( this.autoRotate ) {
            +204 
            +205                     var point2= time===0 ? point : this.path.getPosition(time -.001);
            +206                     var ax = point.x - point2.x;
            +207                     var ay = point.y - point2.y;
            +208                     var angle = Math.atan2(ay, ax);
            +209 
            +210                     obj.angle= angle;
            +211                 }
            +212 
            +213                 return obj;
            +214             },
            +215 
            +216             /**
            +217              * @inheritDoc
            +218              */
            +219             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +220 
            +221                 if (typeof keyframessize === 'undefined') {
            +222                     keyframessize = 100;
            +223                 }
            +224                 keyframessize >>= 0;
            +225 
            +226                 var i;
            +227                 var kfr;
            +228                 var time;
            +229                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +230 
            +231                 for (i = 0; i <= keyframessize; i++) {
            +232                     kfr = "" +
            +233                         (i / keyframessize * 100) + "%" + // percentage
            +234                         "{" +
            +235                         "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) +
            +236                         "}";
            +237 
            +238                     kfd += kfr;
            +239                 }
            +240 
            +241                 kfd += "}";
            +242 
            +243                 return kfd;
            +244             },
            +245 
            +246             /**
            +247              * @inheritDoc
            +248              */
            +249             setForTime:function (time, actor) {
            +250 
            +251                 if (!this.path) {
            +252                     return {
            +253                         x:actor.x,
            +254                         y:actor.y
            +255                     };
            +256                 }
            +257 
            +258                 var point = this.path.getPosition(time, this.isOpenContour,.001);
            +259                 if (this.isRelative ) {
            +260                     point.x+= this.relativeX;
            +261                     point.y+= this.relativeY;
            +262                 }
            +263 
            +264                 if (this.autoRotate) {
            +265 
            +266                     if (-1 === this.prevX && -1 === this.prevY) {
            +267                         this.prevX = point.x;
            +268                         this.prevY = point.y;
            +269                     }
            +270 
            +271                     var ax = point.x - this.prevX;
            +272                     var ay = point.y - this.prevY;
            +273 
            +274                     if (ax === 0 && ay === 0) {
            +275                         actor.setLocation(point.x, point.y);
            +276                         return { x:actor.x, y:actor.y };
            +277                     }
            +278 
            +279                     var angle = Math.atan2(ay, ax);
            +280                     var si = CAAT.Foundation.SpriteImage;
            +281                     var pba = CAAT.Behavior.PathBehavior.AUTOROTATE;
            +282 
            +283                     // actor is heading left to right
            +284                     if (this.autoRotateOp === pba.LEFT_TO_RIGHT) {
            +285                         if (this.prevX <= point.x) {
            +286                             actor.setImageTransformation(si.TR_NONE);
            +287                         }
            +288                         else {
            +289                             actor.setImageTransformation(si.TR_FLIP_HORIZONTAL);
            +290                             angle += Math.PI;
            +291                         }
            +292                     } else if (this.autoRotateOp === pba.RIGHT_TO_LEFT) {
            +293                         if (this.prevX <= point.x) {
            +294                             actor.setImageTransformation(si.TR_FLIP_HORIZONTAL);
            +295                         }
            +296                         else {
            +297                             actor.setImageTransformation(si.TR_NONE);
            +298                             angle -= Math.PI;
            +299                         }
            +300                     }
            +301 
            +302                     actor.setRotation(angle);
            +303 
            +304                     this.prevX = point.x;
            +305                     this.prevY = point.y;
            +306 
            +307                     var modulo = Math.sqrt(ax * ax + ay * ay);
            +308                     ax /= modulo;
            +309                     ay /= modulo;
            +310                 }
            +311 
            +312                 if (this.doValueApplication) {
            +313                     actor.setLocation(point.x, point.y);
            +314                     return { x:actor.x, y:actor.y };
            +315                 } else {
            +316                     return {
            +317                         x:point.x,
            +318                         y:point.y
            +319                     };
            +320                 }
            +321 
            +322 
            +323             },
            +324 
            +325             /**
            +326              * Get a point on the path.
            +327              * If the time to get the point at is in behaviors frame time, a point on the path will be returned, otherwise
            +328              * a default {x:-1, y:-1} point will be returned.
            +329              *
            +330              * @param time {number} the time at which the point will be taken from the path.
            +331              * @return {object} an object of the form {x:float y:float}
            +332              */
            +333             positionOnTime:function (time) {
            +334                 if (this.isBehaviorInTime(time, null)) {
            +335                     time = this.normalizeTime(time);
            +336                     return this.path.getPosition(time);
            +337                 }
            +338 
            +339                 return {x:-1, y:-1};
            +340 
            +341             }
            +342         };
            +343     }
            +344 });
            +345 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_RotateBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_RotateBehavior.js.html new file mode 100644 index 0000000..ebce715 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_RotateBehavior.js.html @@ -0,0 +1,220 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name RotateBehavior
            +  5      * @memberOf CAAT.Behavior
            +  6      * @extends CAAT.Behavior.BaseBehavior
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Behavior.RotateBehavior",
            + 11     extendsClass: "CAAT.Behavior.BaseBehavior",
            + 12     depends:[
            + 13         "CAAT.Behavior.BaseBehavior",
            + 14         "CAAT.Foundation.Actor"
            + 15     ],
            + 16     aliases: ["CAAT.RotateBehavior"],
            + 17     extendsWith:function () {
            + 18 
            + 19         return {
            + 20 
            + 21             /**
            + 22              * @lends CAAT.Behavior.RotateBehavior.prototype
            + 23              */
            + 24 
            + 25 
            + 26             __init:function () {
            + 27                 this.__super();
            + 28                 this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER;
            + 29                 return this;
            + 30             },
            + 31 
            + 32             /**
            + 33              * @inheritDoc
            + 34              */
            + 35             parse : function( obj ) {
            + 36                 CAAT.Behavior.RotateBehavior.superclass.parse.call(this,obj);
            + 37                 this.startAngle= obj.start || 0;
            + 38                 this.endAngle= obj.end || 0;
            + 39                 this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5);
            + 40                 this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5);
            + 41             },
            + 42 
            + 43             /**
            + 44              * Start rotation angle.
            + 45              * @type {number}
            + 46              * @private
            + 47              */
            + 48             startAngle:0,
            + 49 
            + 50             /**
            + 51              * End rotation angle.
            + 52              * @type {number}
            + 53              * @private
            + 54              */
            + 55             endAngle:0,
            + 56 
            + 57             /**
            + 58              * Rotation X anchor.
            + 59              * @type {number}
            + 60              * @private
            + 61              */
            + 62             anchorX:.50,
            + 63 
            + 64             /**
            + 65              * Rotation Y anchor.
            + 66              * @type {number}
            + 67              * @private
            + 68              */
            + 69             anchorY:.50,
            + 70 
            + 71             rotationRelative: 0,
            + 72 
            + 73             setRelativeValues : function(r) {
            + 74                 this.rotationRelative= r;
            + 75                 this.isRelative= true;
            + 76                 return this;
            + 77             },
            + 78 
            + 79             /**
            + 80              * @inheritDoc
            + 81              */
            + 82             getPropertyName:function () {
            + 83                 return "rotate";
            + 84             },
            + 85 
            + 86             /**
            + 87              * @inheritDoc
            + 88              */
            + 89             setForTime:function (time, actor) {
            + 90                 var angle = this.startAngle + time * (this.endAngle - this.startAngle);
            + 91 
            + 92                 if ( this.isRelative ) {
            + 93                     angle+= this.rotationRelative;
            + 94                     if (angle>=Math.PI) {
            + 95                         angle= (angle-2*Math.PI)
            + 96                     }
            + 97                     if ( angle<-2*Math.PI) {
            + 98                         angle= (angle+2*Math.PI);
            + 99                     }
            +100                 }
            +101 
            +102                 if (this.doValueApplication) {
            +103                     actor.setRotationAnchored(angle, this.anchorX, this.anchorY);
            +104                 }
            +105 
            +106                 return angle;
            +107 
            +108             },
            +109 
            +110             /**
            +111              * Set behavior bound values.
            +112              * if no anchorx,anchory values are supplied, the behavior will assume
            +113              * 50% for both values, that is, the actor's center.
            +114              *
            +115              * Be aware the anchor values are supplied in <b>RELATIVE PERCENT</b> to
            +116              * actor's size.
            +117              *
            +118              * @param startAngle {float} indicating the starting angle.
            +119              * @param endAngle {float} indicating the ending angle.
            +120              * @param anchorx {float} the percent position for anchorX
            +121              * @param anchory {float} the percent position for anchorY
            +122              */
            +123             setValues:function (startAngle, endAngle, anchorx, anchory) {
            +124                 this.startAngle = startAngle;
            +125                 this.endAngle = endAngle;
            +126                 if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') {
            +127                     this.anchorX = anchorx;
            +128                     this.anchorY = anchory;
            +129                 }
            +130                 return this;
            +131             },
            +132 
            +133             /**
            +134              * @deprecated
            +135              * Use setValues instead
            +136              * @param start
            +137              * @param end
            +138              */
            +139             setAngles:function (start, end) {
            +140                 return this.setValues(start, end);
            +141             },
            +142 
            +143             /**
            +144              * Set the behavior rotation anchor. Use this method when setting an exact percent
            +145              * by calling setValues is complicated.
            +146              * @see CAAT.Actor
            +147              *
            +148              * These parameters are to set a custom rotation anchor point. if <code>anchor==CAAT.Actor.ANCHOR_CUSTOM
            +149              * </code> the custom rotation point is set.
            +150              * @param actor
            +151              * @param rx
            +152              * @param ry
            +153              *
            +154              */
            +155             setAnchor:function (actor, rx, ry) {
            +156                 this.anchorX = rx / actor.width;
            +157                 this.anchorY = ry / actor.height;
            +158                 return this;
            +159             },
            +160 
            +161             /**
            +162              * @inheritDoc
            +163              */
            +164             calculateKeyFrameData:function (time) {
            +165                 time = this.interpolator.getPosition(time).y;
            +166                 return "rotate(" + (this.startAngle + time * (this.endAngle - this.startAngle)) + "rad)";
            +167             },
            +168 
            +169             /**
            +170              * @inheritDoc
            +171              */
            +172             getKeyFrameDataValues : function(time) {
            +173                 time = this.interpolator.getPosition(time).y;
            +174                 return {
            +175                     angle : this.startAngle + time * (this.endAngle - this.startAngle)
            +176                 };
            +177             },
            +178 
            +179             /**
            +180              * @inheritDoc
            +181              */
            +182             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +183 
            +184                 if (typeof keyframessize === 'undefined') {
            +185                     keyframessize = 100;
            +186                 }
            +187                 keyframessize >>= 0;
            +188 
            +189                 var i;
            +190                 var kfr;
            +191                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +192 
            +193                 for (i = 0; i <= keyframessize; i++) {
            +194                     kfr = "" +
            +195                         (i / keyframessize * 100) + "%" + // percentage
            +196                         "{" +
            +197                         "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) +
            +198                         "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " +
            +199                         "}\n";
            +200 
            +201                     kfd += kfr;
            +202                 }
            +203 
            +204                 kfd += "}\n";
            +205 
            +206                 return kfd;
            +207             }
            +208 
            +209         };
            +210 
            +211     }
            +212 });
            +213 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Scale1Behavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Scale1Behavior.js.html new file mode 100644 index 0000000..5b511a7 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_Scale1Behavior.js.html @@ -0,0 +1,248 @@ +
              1 CAAT.Module({
            +  2     /**
            +  3      * @name Scale1Behavior
            +  4      * @memberOf CAAT.Behavior
            +  5      * @extends CAAT.Behavior.BaseBehavior
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name AXIS
            + 11      * @memberOf CAAT.Behavior.Scale1Behavior
            + 12      * @enum {number}
            + 13      * @namespace
            + 14      */
            + 15 
            + 16     /**
            + 17      * @name Axis
            + 18      * @memberOf CAAT.Behavior.Scale1Behavior
            + 19      * @enum {number}
            + 20      * @namespace
            + 21      * @deprecated
            + 22      */
            + 23 
            + 24 
            + 25     defines:"CAAT.Behavior.Scale1Behavior",
            + 26     depends:[
            + 27         "CAAT.Behavior.BaseBehavior",
            + 28         "CAAT.Foundation.Actor"
            + 29     ],
            + 30     aliases: ["CAAT.Scale1Behavior"],
            + 31     constants : {
            + 32 
            + 33         AXIS : {
            + 34             /**
            + 35              * @lends CAAT.Behavior.Scale1Behavior.AXIS
            + 36              */
            + 37 
            + 38             /** @const */ X:  0,
            + 39             /** @const */ Y:  1
            + 40         },
            + 41 
            + 42         Axis : {
            + 43             /**
            + 44              * @lends CAAT.Behavior.Scale1Behavior.Axis
            + 45              */
            + 46 
            + 47             /** @const */ X:  0,
            + 48             /** @const */ Y:  1
            + 49         }
            + 50     },
            + 51     extendsClass:"CAAT.Behavior.BaseBehavior",
            + 52     extendsWith:function () {
            + 53 
            + 54         return {
            + 55 
            + 56             /**
            + 57              * @lends CAAT.Behavior.Scale1Behavior.prototype
            + 58              */
            + 59 
            + 60             __init:function () {
            + 61                 this.__super();
            + 62                 this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER;
            + 63                 return this;
            + 64             },
            + 65 
            + 66             /**
            + 67              * Start scale value.
            + 68              * @private
            + 69              */
            + 70             startScale:1,
            + 71 
            + 72             /**
            + 73              * End scale value.
            + 74              * @private
            + 75              */
            + 76             endScale:1,
            + 77 
            + 78             /**
            + 79              * Scale X anchor.
            + 80              * @private
            + 81              */
            + 82             anchorX:.50,
            + 83 
            + 84             /**
            + 85              * Scale Y anchor.
            + 86              * @private
            + 87              */
            + 88             anchorY:.50,
            + 89 
            + 90             /**
            + 91              * Apply on Axis X or Y ?
            + 92              */
            + 93             applyOnX:true,
            + 94 
            + 95             parse : function( obj ) {
            + 96                 CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,obj);
            + 97                 this.startScale= obj.start || 0;
            + 98                 this.endScale= obj.end || 0;
            + 99                 this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5);
            +100                 this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5);
            +101                 this.applyOnX= obj.axis ? obj.axis.toLowerCase()==="x" : true;
            +102             },
            +103 
            +104             /**
            +105              * @param axis {CAAT.Behavior.Scale1Behavior.AXIS}
            +106              */
            +107             applyOnAxis:function (axis) {
            +108                 if (axis === CAAT.Behavior.Scale1Behavior.AXIS.X) {
            +109                     this.applyOnX = false;
            +110                 } else {
            +111                     this.applyOnX = true;
            +112                 }
            +113             },
            +114 
            +115             /**
            +116              * @inheritDoc
            +117              */
            +118             getPropertyName:function () {
            +119                 return "scale";
            +120             },
            +121 
            +122             /**
            +123              * @inheritDoc
            +124              */
            +125             setForTime:function (time, actor) {
            +126 
            +127                 var scale = this.startScale + time * (this.endScale - this.startScale);
            +128 
            +129                 // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0.
            +130                 if (0 === scale) {
            +131                     scale = 0.01;
            +132                 }
            +133 
            +134                 if (this.doValueApplication) {
            +135                     if (this.applyOnX) {
            +136                         actor.setScaleAnchored(scale, actor.scaleY, this.anchorX, this.anchorY);
            +137                     } else {
            +138                         actor.setScaleAnchored(actor.scaleX, scale, this.anchorX, this.anchorY);
            +139                     }
            +140                 }
            +141 
            +142                 return scale;
            +143             },
            +144 
            +145             /**
            +146              * Define this scale behaviors values.
            +147              *
            +148              * Be aware the anchor values are supplied in <b>RELATIVE PERCENT</b> to
            +149              * actor's size.
            +150              *
            +151              * @param start {number} initial X axis scale value.
            +152              * @param end {number} final X axis scale value.
            +153              * @param anchorx {float} the percent position for anchorX
            +154              * @param anchory {float} the percent position for anchorY
            +155              *
            +156              * @return this.
            +157              */
            +158             setValues:function (start, end, applyOnX, anchorx, anchory) {
            +159                 this.startScale = start;
            +160                 this.endScale = end;
            +161                 this.applyOnX = !!applyOnX;
            +162 
            +163                 if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') {
            +164                     this.anchorX = anchorx;
            +165                     this.anchorY = anchory;
            +166                 }
            +167 
            +168                 return this;
            +169             },
            +170 
            +171             /**
            +172              * Set an exact position scale anchor. Use this method when it is hard to
            +173              * set a thorough anchor position expressed in percentage.
            +174              * @param actor
            +175              * @param x
            +176              * @param y
            +177              */
            +178             setAnchor:function (actor, x, y) {
            +179                 this.anchorX = x / actor.width;
            +180                 this.anchorY = y / actor.height;
            +181 
            +182                 return this;
            +183             },
            +184 
            +185             /**
            +186              * @inheritDoc
            +187              */
            +188             calculateKeyFrameData:function (time) {
            +189                 var scale;
            +190 
            +191                 time = this.interpolator.getPosition(time).y;
            +192                 scale = this.startScale + time * (this.endScale - this.startScale);
            +193 
            +194                 return this.applyOnX ? "scaleX(" + scale + ")" : "scaleY(" + scale + ")";
            +195             },
            +196 
            +197             /**
            +198              * @inheritDoc
            +199              */
            +200             getKeyFrameDataValues : function(time) {
            +201                 time = this.interpolator.getPosition(time).y;
            +202                 var obj= {};
            +203                 obj[ this.applyOnX ? "scaleX" : "scaleY" ]= this.startScale + time * (this.endScale - this.startScale);
            +204 
            +205                 return obj;
            +206             },
            +207 
            +208             /**
            +209              * @inheritDoc
            +210              */
            +211             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +212 
            +213                 if (typeof keyframessize === 'undefined') {
            +214                     keyframessize = 100;
            +215                 }
            +216                 keyframessize >>= 0;
            +217 
            +218                 var i;
            +219                 var kfr;
            +220                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +221 
            +222                 for (i = 0; i <= keyframessize; i++) {
            +223                     kfr = "" +
            +224                         (i / keyframessize * 100) + "%" + // percentage
            +225                         "{" +
            +226                         "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) +
            +227                         "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " +
            +228                         "}\n";
            +229 
            +230                     kfd += kfr;
            +231                 }
            +232 
            +233                 kfd += "}\n";
            +234 
            +235                 return kfd;
            +236             }
            +237         }
            +238 
            +239     }
            +240 });
            +241 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ScaleBehavior.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ScaleBehavior.js.html new file mode 100644 index 0000000..e5ea8b2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Behavior_ScaleBehavior.js.html @@ -0,0 +1,227 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name ScaleBehavior
            +  5      * @memberOf CAAT.Behavior
            +  6      * @extends CAAT.Behavior.BaseBehavior
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Behavior.ScaleBehavior",
            + 11     depends:[
            + 12         "CAAT.Behavior.BaseBehavior",
            + 13         "CAAT.Foundation.Actor"
            + 14     ],
            + 15     extendsClass:"CAAT.Behavior.BaseBehavior",
            + 16     aliases : ["CAAT.ScaleBehavior"],
            + 17     extendsWith:function () {
            + 18 
            + 19         return  {
            + 20 
            + 21             /**
            + 22              * @lends CAAT.Behavior.ScaleBehavior
            + 23              */
            + 24 
            + 25             __init:function () {
            + 26                 this.__super();
            + 27                 this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER;
            + 28                 return this;
            + 29             },
            + 30 
            + 31             /**
            + 32              * Start X scale value.
            + 33              * @private
            + 34              * @type {number}
            + 35              */
            + 36             startScaleX:1,
            + 37 
            + 38             /**
            + 39              * End X scale value.
            + 40              * @private
            + 41              * @type {number}
            + 42              */
            + 43             endScaleX:1,
            + 44 
            + 45             /**
            + 46              * Start Y scale value.
            + 47              * @private
            + 48              * @type {number}
            + 49              */
            + 50             startScaleY:1,
            + 51 
            + 52             /**
            + 53              * End Y scale value.
            + 54              * @private
            + 55              * @type {number}
            + 56              */
            + 57             endScaleY:1,
            + 58 
            + 59             /**
            + 60              * Scale X anchor value.
            + 61              * @private
            + 62              * @type {number}
            + 63              */
            + 64             anchorX:.50,
            + 65 
            + 66             /**
            + 67              * Scale Y anchor value.
            + 68              * @private
            + 69              * @type {number}
            + 70              */
            + 71             anchorY:.50,
            + 72 
            + 73             /**
            + 74              * @inheritDoc
            + 75              */
            + 76             parse : function( obj ) {
            + 77                 CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,obj);
            + 78                 this.startScaleX= (obj.scaleX && obj.scaleX.start) || 0;
            + 79                 this.endScaleX= (obj.scaleX && obj.scaleX.end) || 0;
            + 80                 this.startScaleY= (obj.scaleY && obj.scaleY.start) || 0;
            + 81                 this.endScaleY= (obj.scaleY && obj.scaleY.end) || 0;
            + 82                 this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5);
            + 83                 this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5);
            + 84             },
            + 85 
            + 86             /**
            + 87              * @inheritDoc
            + 88              */
            + 89             getPropertyName:function () {
            + 90                 return "scale";
            + 91             },
            + 92 
            + 93             /**
            + 94              * Applies corresponding scale values for a given time.
            + 95              *
            + 96              * @param time the time to apply the scale for.
            + 97              * @param actor the target actor to Scale.
            + 98              * @return {object} an object of the form <code>{ scaleX: {float}, scaleY: {float}�}</code>
            + 99              */
            +100             setForTime:function (time, actor) {
            +101 
            +102                 var scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX);
            +103                 var scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY);
            +104 
            +105                 // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0.
            +106                 if (0 === scaleX) {
            +107                     scaleX = 0.01;
            +108                 }
            +109                 if (0 === scaleY) {
            +110                     scaleY = 0.01;
            +111                 }
            +112 
            +113                 if (this.doValueApplication) {
            +114                     actor.setScaleAnchored(scaleX, scaleY, this.anchorX, this.anchorY);
            +115                 }
            +116 
            +117                 return { scaleX:scaleX, scaleY:scaleY };
            +118             },
            +119             /**
            +120              * Define this scale behaviors values.
            +121              *
            +122              * Be aware the anchor values are supplied in <b>RELATIVE PERCENT</b> to
            +123              * actor's size.
            +124              *
            +125              * @param startX {number} initial X axis scale value.
            +126              * @param endX {number} final X axis scale value.
            +127              * @param startY {number} initial Y axis scale value.
            +128              * @param endY {number} final Y axis scale value.
            +129              * @param anchorx {float} the percent position for anchorX
            +130              * @param anchory {float} the percent position for anchorY
            +131              *
            +132              * @return this.
            +133              */
            +134             setValues:function (startX, endX, startY, endY, anchorx, anchory) {
            +135                 this.startScaleX = startX;
            +136                 this.endScaleX = endX;
            +137                 this.startScaleY = startY;
            +138                 this.endScaleY = endY;
            +139 
            +140                 if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') {
            +141                     this.anchorX = anchorx;
            +142                     this.anchorY = anchory;
            +143                 }
            +144 
            +145                 return this;
            +146             },
            +147             /**
            +148              * Set an exact position scale anchor. Use this method when it is hard to
            +149              * set a thorough anchor position expressed in percentage.
            +150              * @param actor
            +151              * @param x
            +152              * @param y
            +153              */
            +154             setAnchor:function (actor, x, y) {
            +155                 this.anchorX = x / actor.width;
            +156                 this.anchorY = y / actor.height;
            +157 
            +158                 return this;
            +159             },
            +160 
            +161             /**
            +162              * @inheritDoc
            +163              */
            +164             calculateKeyFrameData:function (time) {
            +165                 var scaleX;
            +166                 var scaleY;
            +167 
            +168                 time = this.interpolator.getPosition(time).y;
            +169                 scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX);
            +170                 scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY);
            +171 
            +172                 return "scale(" + scaleX +"," + scaleY + ")";
            +173             },
            +174 
            +175             /**
            +176              * @inheritDoc
            +177              */
            +178             getKeyFrameDataValues : function(time) {
            +179                 time = this.interpolator.getPosition(time).y;
            +180                 return {
            +181                     scaleX : this.startScaleX + time * (this.endScaleX - this.startScaleX),
            +182                     scaleY : this.startScaleY + time * (this.endScaleY - this.startScaleY)
            +183                 };
            +184             },
            +185 
            +186 
            +187             /**
            +188              * @inheritDoc
            +189              */
            +190             calculateKeyFramesData:function (prefix, name, keyframessize) {
            +191 
            +192                 if (typeof keyframessize === 'undefined') {
            +193                     keyframessize = 100;
            +194                 }
            +195                 keyframessize >>= 0;
            +196 
            +197                 var i;
            +198                 var kfr;
            +199                 var kfd = "@-" + prefix + "-keyframes " + name + " {";
            +200 
            +201                 for (i = 0; i <= keyframessize; i++) {
            +202                     kfr = "" +
            +203                         (i / keyframessize * 100) + "%" + // percentage
            +204                         "{" +
            +205                         "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) +
            +206                         "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " +
            +207                         "}\n";
            +208 
            +209                     kfd += kfr;
            +210                 }
            +211 
            +212                 kfd += "}\n";
            +213 
            +214                 return kfd;
            +215             }
            +216         }
            +217 
            +218     }
            +219 });
            +220 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_CAAT.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_CAAT.js.html new file mode 100644 index 0000000..b3187fa --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_CAAT.js.html @@ -0,0 +1,20 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Library namespace.
            +  5  * CAAT stands for: Canvas Advanced Animation Tookit.
            +  6  */
            +  7 
            +  8 
            +  9     /**
            + 10      * @namespace
            + 11      */
            + 12 var CAAT= CAAT || {};
            + 13 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_Constants.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_Constants.js.html new file mode 100644 index 0000000..160df33 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_Constants.js.html @@ -0,0 +1,127 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module( {
            +  7 
            +  8     defines: "CAAT.Core.Constants",
            +  9     depends : [
            + 10         "CAAT.Math.Matrix"
            + 11     ],
            + 12 
            + 13     extendsWith: function() {
            + 14 
            + 15         /**
            + 16          * @lends CAAT
            + 17          */
            + 18 
            + 19         /**
            + 20          * // do not clamp coordinates. speeds things up in older browsers.
            + 21          * @type {Boolean}
            + 22          * @private
            + 23          */
            + 24         CAAT.CLAMP= false;
            + 25 
            + 26         /**
            + 27          * This function makes the system obey decimal point calculations for actor's position, size, etc.
            + 28          * This may speed things up in some browsers, but at the cost of affecting visuals (like in rotating
            + 29          * objects).
            + 30          *
            + 31          * Latest Chrome (20+) is not affected by this.
            + 32          *
            + 33          * Default CAAT.Matrix try to speed things up.
            + 34          *
            + 35          * @param clamp {boolean}
            + 36          */
            + 37         CAAT.setCoordinateClamping= function( clamp ) {
            + 38             CAAT.CLAMP= clamp;
            + 39             CAAT.Math.Matrix.setCoordinateClamping(clamp);
            + 40         };
            + 41 
            + 42         /**
            + 43          * Log function which deals with window's Console object.
            + 44          */
            + 45         CAAT.log= function() {
            + 46             if(window.console){
            + 47                 window.console.log( Array.prototype.slice.call(arguments) );
            + 48             }
            + 49         };
            + 50 
            + 51         /**
            + 52          * Control how CAAT.Font and CAAT.TextActor control font ascent/descent values.
            + 53          * 0 means it will guess values from a font height
            + 54          * 1 means it will try to use css to get accurate ascent/descent values and fall back to the previous method
            + 55          *   in case it couldn't.
            + 56          *
            + 57          * @type {Number}
            + 58          */
            + 59         CAAT.CSS_TEXT_METRICS=      0;
            + 60 
            + 61         /**
            + 62          * is GLRendering enabled.
            + 63          * @type {Boolean}
            + 64          */
            + 65         CAAT.GLRENDER= false;
            + 66 
            + 67         /**
            + 68          * set this variable before building CAAT.Director intances to enable debug panel.
            + 69          */
            + 70         CAAT.DEBUG= false;
            + 71 
            + 72         /**
            + 73          * show Bounding Boxes
            + 74          * @type {Boolean}
            + 75          */
            + 76         CAAT.DEBUGBB= false;
            + 77 
            + 78         /**
            + 79          * Bounding Boxes color.
            + 80          * @type {String}
            + 81          */
            + 82         CAAT.DEBUGBBBCOLOR = '#00f';
            + 83 
            + 84         /**
            + 85          * debug axis aligned bounding boxes.
            + 86          * @type {Boolean}
            + 87          */
            + 88         CAAT.DEBUGAABB = false;
            + 89 
            + 90         /**
            + 91          * Bounding boxes color.
            + 92          * @type {String}
            + 93          */
            + 94         CAAT.DEBUGAABBCOLOR = '#f00';
            + 95 
            + 96         /**
            + 97          * if CAAT.Director.setClear uses CLEAR_DIRTY_RECTS, this will show them on screen.
            + 98          * @type {Boolean}
            + 99          */
            +100         CAAT.DEBUG_DIRTYRECTS= false;
            +101 
            +102         /**
            +103          * Do not consider mouse drag gesture at least until you have dragged
            +104          * DRAG_THRESHOLD_X and DRAG_THRESHOLD_Y pixels.
            +105          * This is suitable for tablets, where just by touching, drag events are delivered.
            +106          */
            +107         CAAT.DRAG_THRESHOLD_X=      5;
            +108         CAAT.DRAG_THRESHOLD_Y=      5;
            +109 
            +110         /**
            +111          * When switching scenes, cache exiting scene or not. Set before building director instance.
            +112          * @type {Boolean}
            +113          */
            +114         CAAT.CACHE_SCENE_ON_CHANGE= true;
            +115 
            +116         return {
            +117         }
            +118     }
            +119 } );
            +120 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_ModuleManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_ModuleManager.js.html new file mode 100644 index 0000000..4e87cbe --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Core_ModuleManager.js.html @@ -0,0 +1,925 @@ +
              1 (function(global, __obj_namespace) {
            +  2 
            +  3     String.prototype.endsWith= function(suffix) {
            +  4         return this.indexOf(suffix, this.length - suffix.length) !== -1;
            +  5     };
            +  6 
            +  7     Function.prototype.bind = Function.prototype.bind || function () {
            +  8                 var fn = this;                                   // the function
            +  9                 var args = Array.prototype.slice.call(arguments);  // copy the arguments.
            + 10                 var obj = args.shift();                           // first parameter will be context 'this'
            + 11                 return function () {
            + 12                     return fn.apply(
            + 13                         obj,
            + 14                         args.concat(Array.prototype.slice.call(arguments)));
            + 15                 }
            + 16             };
            + 17 
            + 18     global.isArray = function (input) {
            + 19         return typeof(input) == 'object' && (input instanceof Array);
            + 20     };
            + 21     global.isString = function (input) {
            + 22         return typeof(input) == 'string';
            + 23     };
            + 24     global.isFunction = function( input ) {
            + 25         return typeof input == "function"
            + 26     }
            + 27 
            + 28     var initializing = false;
            + 29 
            + 30     // The base Class implementation (does nothing)
            + 31     var Class = function () {
            + 32     };
            + 33 
            + 34     Class['__CLASS']='Class';
            + 35 
            + 36     // Create a new Class that inherits from this class
            + 37     Class.extend = function (extendingProt, constants, name, aliases, flags) {
            + 38 
            + 39         var _super = this.prototype;
            + 40 
            + 41         // Instantiate a base class (but only create the instance,
            + 42         // don't run the init constructor)
            + 43         initializing = true;
            + 44         var prototype = new this();
            + 45         initializing = false;
            + 46 
            + 47         // The dummy class constructor
            + 48         function CAATClass() {
            + 49             // All construction is actually done in the init method
            + 50             if (!initializing && this.__init) {
            + 51                 this.__init.apply(this, arguments);
            + 52             }
            + 53         }
            + 54 
            + 55         // Populate our constructed prototype object
            + 56         CAATClass.prototype = prototype;
            + 57         // Enforce the constructor to be what we expect
            + 58         CAATClass.prototype.constructor = CAATClass;
            + 59         CAATClass.superclass = _super;
            + 60         // And make this class extendable
            + 61         CAATClass.extend = Class.extend;
            + 62 
            + 63         assignNamespace( name, CAATClass );
            + 64         if ( constants ) {
            + 65             constants= (isFunction(constants) ? constants() : constants);
            + 66             for( var constant in constants ) {
            + 67                 if ( constants.hasOwnProperty(constant) ) {
            + 68                     CAATClass[ constant ]= constants[constant];
            + 69                 }
            + 70             }
            + 71         }
            + 72 
            + 73         CAATClass["__CLASS"]= name;
            + 74 
            + 75         if ( aliases ) {
            + 76             if ( !isArray(aliases) ) {
            + 77                 aliases= [aliases];
            + 78             }
            + 79             for( var i=0; i<aliases.length; i++ ) {
            + 80                 ensureNamespace( aliases[i] );
            + 81                 var ns= assignNamespace( aliases[i], CAATClass );
            + 82 
            + 83                 // assign constants to alias classes.
            + 84                 if ( constants ) {
            + 85                     for( var constant in constants ) {
            + 86                         if ( constants.hasOwnProperty(constant) ) {
            + 87                             ns[ constant ]= constants[constant];
            + 88                         }
            + 89                     }
            + 90                 }
            + 91             }
            + 92         }
            + 93 
            + 94         extendingProt= (isFunction(extendingProt) ? extendingProt() : extendingProt);
            + 95 
            + 96         // Copy the properties over onto the new prototype
            + 97         for (var fname in extendingProt) {
            + 98             // Check if we're overwriting an existing function
            + 99             prototype[fname] = ( (fname === "__init" || (flags && flags.decorated) ) && isFunction(extendingProt[fname]) && isFunction(_super[fname]) ) ?
            +100                 (function (name, fn) {
            +101                     return function () {
            +102                         var tmp = this.__super;
            +103                         this.__super = _super[name];
            +104                         var ret = fn.apply(this, arguments);
            +105                         this.__super = tmp;
            +106                         return ret;
            +107                     };
            +108                 })(fname, extendingProt[fname]) :
            +109 
            +110                 extendingProt[fname];
            +111         }
            +112 
            +113         return CAATClass;
            +114     }
            +115 
            +116     var Node= function( obj ) { //name, dependencies, callback ) {
            +117         this.name= obj.defines;
            +118         this.extendWith= obj.extendsWith;
            +119         this.callback= obj.onCreate;
            +120         this.callbackPreCreation= obj.onPreCreate;
            +121         this.dependencies= obj.depends;
            +122         this.baseClass= obj.extendsClass;
            +123         this.aliases= obj.aliases;
            +124         this.constants= obj.constants;
            +125         this.decorated= obj.decorated;
            +126 
            +127         this.children= [];
            +128 
            +129         return this;
            +130     };
            +131 
            +132     Node.prototype= {
            +133         children:       null,
            +134         name:           null,
            +135         extendWith:     null,
            +136         callback:       null,
            +137         dependencies:   null,
            +138         baseClass:      null,
            +139         aliases:        null,
            +140         constants:      null,
            +141 
            +142         decorated:      false,
            +143 
            +144         solved:         false,
            +145         visited:        false,
            +146 
            +147         status : function() {
            +148             console.log("  Module: "+this.name+
            +149                 (this.dependencies.length ?
            +150                     (" unsolved_deps:["+this.dependencies+"]") :
            +151                     " no dependencies.")+
            +152                 ( this.solved ? " solved" : " ------> NOT solved.")
            +153             );
            +154         },
            +155 
            +156         removeDependency : function( modulename ) {
            +157             for( var i=0; i<this.dependencies.length; i++ ) {
            +158                 if ( this.dependencies[i]===modulename ) {
            +159                     this.dependencies.splice(i,1);
            +160                     break;
            +161                 }
            +162             }
            +163 
            +164 
            +165         },
            +166 
            +167         assignDependency : function( node ) {
            +168 
            +169             var i;
            +170             for( i=0; i<this.dependencies.length; i++ ) {
            +171                 if ( this.dependencies[i] === node.name ) {
            +172                     this.children.push( node );
            +173                     this.dependencies.splice(i,1);
            +174 //                    console.log("Added dependency: "+node.name+" on "+this.name);
            +175                     break;
            +176                 }
            +177             }
            +178         },
            +179 
            +180         isSolved : function() {
            +181             return this.solved;
            +182         },
            +183 
            +184         solveDeep : function() {
            +185 
            +186             if ( this.visited ) {
            +187                 return true;
            +188             }
            +189 
            +190             this.visited= true;
            +191 
            +192             if ( this.solved ) {
            +193                 return true;
            +194             }
            +195 
            +196             if ( this.dependencies.length!==0 ) {
            +197                 return false;
            +198             }
            +199 
            +200             var b= true;
            +201             for( var i=0; i<this.children.length; i++ ) {
            +202                 if (! this.children[i].solveDeep() ) {
            +203                     return false;
            +204                 }
            +205             }
            +206 
            +207             //////
            +208             this.__initModule();
            +209 
            +210             this.solved= true;
            +211             mm.solved( this );
            +212 
            +213             return true;
            +214         },
            +215 
            +216         __initModule : function() {
            +217 
            +218             var c= null;
            +219             if ( this.baseClass ) {
            +220                 c= findClass( this.baseClass );
            +221 
            +222                 if ( !c ) {
            +223                     console.log("  "+this.name+" -> Can't extend non-existant class: "+this.baseClass );
            +224                     return;
            +225                 }
            +226 
            +227             } else {
            +228                 c= Class;
            +229             }
            +230 
            +231             c= c.extend( this.extendWith, this.constants, this.name, this.aliases, { decorated : this.decorated } );
            +232 
            +233             console.log("Created module: "+this.name);
            +234 
            +235             if ( this.callback ) {
            +236                 this.callback();
            +237             }
            +238 
            +239         }
            +240     };
            +241 
            +242     var ScriptFile= function(path, module) {
            +243         this.path= path;
            +244         this.module= module;
            +245         return this;
            +246     }
            +247 
            +248     ScriptFile.prototype= {
            +249         path : null,
            +250         processed: false,
            +251         module: null,
            +252 
            +253         setProcessed : function() {
            +254             this.processed= true;
            +255         },
            +256 
            +257         isProcessed : function() {
            +258             return this.processed;
            +259         }
            +260     };
            +261 
            +262     var ModuleManager= function() {
            +263         this.nodes= [];
            +264         this.loadedFiles= [];
            +265         this.path= {};
            +266         this.solveListener= [];
            +267         this.orderedSolvedModules= [];
            +268         this.readyListener= [];
            +269 
            +270         return this;
            +271     };
            +272 
            +273     ModuleManager.baseURL= "";
            +274     ModuleManager.modulePath= {};
            +275     ModuleManager.sortedModulePath= [];
            +276     ModuleManager.symbol= {};
            +277 
            +278     ModuleManager.prototype= {
            +279 
            +280         nodes:      null,           // built nodes.
            +281         loadedFiles:null,           // list of loaded files. avoid loading each file more than once
            +282         solveListener: null,        // listener for a module solved
            +283         readyListener: null,        // listener for all modules solved
            +284         orderedSolvedModules: null, // order in which modules where solved.
            +285 
            +286         addSolvedListener : function( modulename, callback ) {
            +287             this.solveListener.push( {
            +288                 name : modulename,
            +289                 callback : callback
            +290             });
            +291         },
            +292 
            +293         solved : function( module ) {
            +294             var i;
            +295 
            +296             for( i=0; i<this.solveListener.length; i++ ) {
            +297                 if ( this.solveListener[i].name===module.name) {
            +298                     this.solveListener[i].callback();
            +299                 }
            +300             }
            +301 
            +302             this.orderedSolvedModules.push( module );
            +303 
            +304             this.notifyReady();
            +305         },
            +306 
            +307         notifyReady : function() {
            +308             var i;
            +309 
            +310             for( i=0; i<this.nodes.length; i++ ) {
            +311                 if ( !this.nodes[i].isSolved() ) {
            +312                     return;
            +313                 }
            +314             }
            +315 
            +316             // if there's any pending files to be processed, still not notify about being solved.
            +317             for( i=0; i<this.loadedFiles.length; i++ ) {
            +318                 if ( !this.loadedFiles[i].isProcessed() ) {
            +319                     // aun hay ficheros sin procesar, no notificar.
            +320                     return;
            +321                 }
            +322             }
            +323 
            +324             /**
            +325              * Make ModuleManager.bring reentrant.
            +326              */
            +327             var me= this;
            +328             var arr= Array.prototype.slice.call(this.readyListener);
            +329             setTimeout( function() {
            +330                 for( var i=0; i<arr.length; i++ ) {
            +331                     arr[i]();
            +332                 }
            +333             }, 0 );
            +334 
            +335             this.readyListener= [];
            +336         },
            +337 
            +338         status : function() {
            +339             for( var i=0; i<this.nodes.length; i++ ) {
            +340                 this.nodes[i].status();
            +341             }
            +342         },
            +343 
            +344         module : function( obj ) {//name, dependencies, callback ) {
            +345 
            +346             var node, nnode, i;
            +347 
            +348             if ( this.isModuleScheduledToSolve( obj.defines ) ) {
            +349 //                console.log("Discarded module: "+obj.class+" (already loaded)");
            +350                 return this;
            +351             }
            +352 
            +353             if ( obj.onPreCreate ) {
            +354 //                console.log("  --> "+obj.defines+" onPrecreation");
            +355                 try {
            +356                     obj.onPreCreate();
            +357                 } catch(e) {
            +358                     console.log("  -> catched "+e+" on module "+obj.defines+" preCreation.");
            +359                 }
            +360             }
            +361 
            +362             if (!obj.depends ) {
            +363                 obj.depends= [];
            +364             }
            +365 
            +366             var dependencies= obj.depends;
            +367 
            +368             if ( dependencies ) {
            +369                 if ( !isArray(dependencies) ) {
            +370                     dependencies= [ dependencies ];
            +371                     obj.depends= dependencies;
            +372                 }
            +373             }
            +374 
            +375             // elimina dependencias ya resueltas en otras cargas.
            +376             i=0;
            +377             while( i<dependencies.length ) {
            +378                 if ( this.alreadySolved( dependencies[i] ) ) {
            +379                      dependencies.splice(i,1);
            +380                 } else {
            +381                     i++;
            +382                 }
            +383             }
            +384 
            +385             nnode= new Node( obj );
            +386 
            +387             // asignar nuevo nodo a quien lo tenga como dependencia.
            +388             for( var i=0; i<this.nodes.length; i++ ) {
            +389                 this.nodes[i].assignDependency(nnode);
            +390             }
            +391             this.nodes.push( nnode );
            +392 
            +393             /**
            +394              * Making dependency resolution a two step process will allow us to pack all modules into one
            +395              * single file so that the module manager does not have to load external files.
            +396              * Useful when CAAt has been packed into one single bundle.
            +397              */
            +398 
            +399             /**
            +400              * remove already loaded modules dependencies.
            +401              */
            +402             for( i=0; i<obj.depends.length;  ) {
            +403 
            +404                 if ( this.isModuleScheduledToSolve( obj.depends[i] ) ) {
            +405                     var dep= this.findNode( obj.depends[i] );
            +406                     if ( null!==dep ) {
            +407                         nnode.assignDependency( dep );
            +408                     } else {
            +409                         //// ERRR
            +410                         alert("Module loaded and does not exist in loaded modules nodes. "+obj.depends[i]);
            +411                         i++;
            +412                     }
            +413                 } else {
            +414                     i+=1;
            +415                 }
            +416             }
            +417 
            +418             /**
            +419              * now, for the rest of non solved dependencies, load their files.
            +420              */
            +421             (function(mm, obj) {
            +422                 setTimeout( function() {
            +423                     for( i=0; i<obj.depends.length; i++ ) {
            +424                         mm.loadFile( obj.depends[i] );
            +425                     }
            +426                 }, 0 );
            +427             })(this, obj);
            +428 
            +429             return this;
            +430 
            +431         },
            +432 
            +433         findNode : function( name ) {
            +434             for( var i=0; i<this.nodes.length; i++ ) {
            +435                 if ( this.nodes[i].name===name ) {
            +436                     return this.nodes[i];
            +437                 }
            +438             }
            +439 
            +440             return null;
            +441         } ,
            +442 
            +443         alreadySolved : function( name ) {
            +444             for( var i= 0; i<this.nodes.length; i++ ) {
            +445                 if ( this.nodes[i].name===name && this.nodes[i].isSolved() ) {
            +446                     return true;
            +447                 }
            +448             }
            +449 
            +450             return false;
            +451         },
            +452 
            +453         exists : function(path) {
            +454             var path= path.split(".");
            +455             var root= global;
            +456 
            +457             for( var i=0; i<path.length; i++ ) {
            +458                 if (!root[path[i]]) {
            +459                     return false;
            +460                 }
            +461 
            +462                 root= root[path[i]];
            +463             }
            +464 
            +465             return true;
            +466         },
            +467 
            +468         loadFile : function( module ) {
            +469 
            +470 
            +471             if (this.exists(module)) {
            +472                 return;
            +473             }
            +474 
            +475             var path= this.getPath( module );
            +476 
            +477             // avoid loading any js file more than once.
            +478             for( var i=0; i<this.loadedFiles.length; i++ ) {
            +479                 if ( this.loadedFiles[i].path===path ) {
            +480                     return;
            +481                 }
            +482             }
            +483 
            +484             var sf= new ScriptFile( path, module );
            +485             this.loadedFiles.push( sf );
            +486 
            +487             var node= document.createElement("script");
            +488             node.type = 'text/javascript';
            +489             node.charset = 'utf-8';
            +490             node.async = true;
            +491             node.addEventListener('load', this.moduleLoaded.bind(this), false);
            +492             node.addEventListener('error', this.moduleErrored.bind(this), false);
            +493             node.setAttribute('module-name', module);
            +494             node.src = path+(!DEBUG ? "?"+(new Date().getTime()) : "");
            +495 
            +496             document.getElementsByTagName('head')[0].appendChild( node );
            +497 
            +498         },
            +499 
            +500         /**
            +501          * Resolve a module name.
            +502          *
            +503          *  + if the module ends with .js
            +504          *    if starts with /, return as is.
            +505          *    else reppend baseURL and return.
            +506          *
            +507          * @param module
            +508          */
            +509         getPath : function( module ) {
            +510 
            +511             // endsWith
            +512             if ( module.endsWith(".js") ) {
            +513                 if ( module.charAt(0)!=="/" ) {
            +514                     module= ModuleManager.baseURL+module;
            +515                 } else {
            +516                     module= module.substring(1);
            +517                 }
            +518                 return module;
            +519             }
            +520 
            +521             var i, symbol;
            +522 
            +523             for( symbol in ModuleManager.symbol ) {
            +524                 if ( module===symbol ) {
            +525                     return  ModuleManager.baseURL + ModuleManager.symbol[symbol];
            +526                 }
            +527             }
            +528 
            +529             //for( var modulename in ModuleManager.modulePath ) {
            +530             for( i=0; i<ModuleManager.sortedModulePath.length; i++ ) {
            +531                 var modulename= ModuleManager.sortedModulePath[i];
            +532 
            +533                 if ( ModuleManager.modulePath.hasOwnProperty(modulename) ) {
            +534                     var path= ModuleManager.modulePath[modulename];
            +535 
            +536                     // startsWith
            +537                     if ( module.indexOf(modulename)===0 ) {
            +538                         // +1 to skip '.' class separator.
            +539                         var nmodule= module.substring(modulename.length + 1);
            +540 
            +541                         /**
            +542                          * Avoid name clash:
            +543                          * CAAT.Foundation and CAAT.Foundation.Timer will both be valid for
            +544                          * CAAT.Foundation.Timer.TimerManager module.
            +545                          * So in the end, the module name can't have '.' after chopping the class
            +546                          * namespace.
            +547                          */
            +548 
            +549                         nmodule= nmodule.replace(/\./g,"/");
            +550 
            +551                         //if ( nmodule.indexOf(".")===-1 ) {
            +552                             nmodule= path+nmodule+".js";
            +553                             return ModuleManager.baseURL + nmodule;
            +554                         //}
            +555                     }
            +556                 }
            +557             }
            +558 
            +559             // what's that ??!?!?!?
            +560             return ModuleManager.baseURL + module.replace(/\./g,"/") + ".js";
            +561         },
            +562 
            +563         isModuleScheduledToSolve : function( name ) {
            +564             for( var i=0; i<this.nodes.length; i++ ) {
            +565                 if ( this.nodes[i].name===name ) {
            +566                     return true;
            +567                 }
            +568             }
            +569             return false;
            +570         },
            +571 
            +572         moduleLoaded : function(e) {
            +573             if (e.type==="load") {
            +574 
            +575                 var node = e.currentTarget || e.srcElement || e.target;
            +576                 var mod= node.getAttribute("module-name");
            +577 
            +578                 // marcar fichero de modulo como procesado.
            +579                 for( var i=0; i<this.loadedFiles.length; i++ ) {
            +580                     if ( this.loadedFiles[i].module===mod ) {
            +581                         this.loadedFiles[i].setProcessed();
            +582                         break;
            +583                     }
            +584                 }
            +585 
            +586                 for( var i=0; i<this.nodes.length; i++ ) {
            +587                     this.nodes[i].removeDependency( mod );
            +588                 }
            +589 
            +590                 for( var i=0; i<this.nodes.length; i++ ) {
            +591                     for( var j=0; j<this.nodes.length; j++ ) {
            +592                         this.nodes[j].visited= false;
            +593                     }
            +594                     this.nodes[i].solveDeep();
            +595                 }
            +596 
            +597                 /**
            +598                  * Despues de cargar un fichero, este puede contener un modulo o no.
            +599                  * Si todos los ficheros que se cargan fueran bibliotecas, nunca se pasaria de aqui porque
            +600                  * no se hace una llamada a solveDeep, y notificacion a solved, y de ahí a notifyReady.
            +601                  * Por eso se hace aqui una llamada a notifyReady, aunque pueda ser redundante.
            +602                  */
            +603                 var me= this;
            +604                 setTimeout(function() {
            +605                     me.notifyReady();
            +606                 }, 0 );
            +607             }
            +608         },
            +609 
            +610         moduleErrored : function(e) {
            +611             var node = e.currentTarget || e.srcElement;
            +612             console.log("Error loading module: "+ node.getAttribute("module-name") );
            +613         },
            +614 
            +615         solvedInOrder : function() {
            +616             for( var i=0; i<this.orderedSolvedModules.length; i++ ) {
            +617                 console.log(this.orderedSolvedModules[i].name);
            +618             }
            +619         },
            +620 
            +621         solveAll : function() {
            +622             for( var i=0; i<this.nodes.length; i++ ) {
            +623                 this.nodes[i].solveDeep();
            +624             }
            +625         },
            +626 
            +627         onReady : function( f ) {
            +628             this.readyListener.push(f);
            +629         }
            +630 
            +631     };
            +632 
            +633     function ensureNamespace( qualifiedClassName ) {
            +634         var ns= qualifiedClassName.split(".");
            +635         var _global= global;
            +636         var ret= null;
            +637         for( var i=0; i<ns.length-1; i++ ) {
            +638             if ( !_global[ns[i]] ) {
            +639                 _global[ns[i]]= {};
            +640             }
            +641             _global= _global[ns[i]];
            +642             ret= _global;
            +643         }
            +644 
            +645         return ret;
            +646     }
            +647 
            +648     /**
            +649      *
            +650      * Create a namespace object from a string.
            +651      *
            +652      * @param namespace {string}
            +653      * @param obj {object}
            +654      * @return {object} the namespace object
            +655      */
            +656     function assignNamespace( namespace, obj ) {
            +657         var ns= namespace.split(".");
            +658         var _global= global;
            +659         for( var i=0; i<ns.length-1; i++ ) {
            +660             if ( !_global[ns[i]] ) {
            +661                 console.log("    Error assigning value to namespace :"+namespace+". '"+ns[i]+"' does not exist.");
            +662                 return null;
            +663             }
            +664 
            +665             _global= _global[ns[i]];
            +666         }
            +667 
            +668         _global[ ns[ns.length-1] ]= obj;
            +669 
            +670         return _global[ ns[ns.length-1] ];
            +671     }
            +672 
            +673     function findClass( qualifiedClassName ) {
            +674         var ns= qualifiedClassName.split(".");
            +675         var _global= global;
            +676         for( var i=0; i<ns.length; i++ ) {
            +677             if ( !_global[ns[i]] ) {
            +678                 return null;
            +679             }
            +680 
            +681             _global= _global[ns[i]];
            +682         }
            +683 
            +684         return _global;
            +685     }
            +686 
            +687     var mm= new ModuleManager();
            +688     var DEBUG= false;
            +689 
            +690 
            +691     /**
            +692      * CAAT is the namespace for all CAAT gaming engine object classes.
            +693      *
            +694      * @name CAAT
            +695      * @namespace
            +696      */
            +697 
            +698     if ( typeof(__obj_namespace)==="undefined" ) {
            +699         __obj_namespace= (window.CAAT = window.CAAT || {} );
            +700     }
            +701 
            +702     NS= __obj_namespace;
            +703 
            +704 //    global.CAAT= global.CAAT || {};
            +705 
            +706     /**
            +707      *
            +708      * This function defines CAAT modules, and creates Constructor Class objects.
            +709      *
            +710      * obj parameter has the following structure:
            +711      * {
            +712      *   defines{string},           // class name
            +713      *   depends{Array<string>=},   // dependencies class names
            +714      *   extendsClass{string},      // class to extend from
            +715      *   extensdWith{object},       // actual prototype to extend
            +716      *   aliases{Array<string>}     // other class names
            +717      * }
            +718      *
            +719      * @name Module
            +720      * @memberof CAAT
            +721      * @static
            +722      *
            +723      * @param obj {object}
            +724      */
            +725     NS.Module= function loadModule(obj) {
            +726 
            +727         if (!obj.defines) {
            +728             console.error("Bad module definition: "+obj);
            +729             return;
            +730         }
            +731 
            +732         ensureNamespace(obj.defines);
            +733 
            +734         mm.module( obj );
            +735 
            +736     };
            +737 
            +738     /**
            +739      * @name ModuleManager
            +740      * @memberOf CAAT
            +741      * @namespace
            +742      */
            +743     NS.ModuleManager= {};
            +744 
            +745     /**
            +746      * Define global base position for modules structure.
            +747      * @param baseURL {string}
            +748      * @return {*}
            +749      */
            +750     NS.ModuleManager.baseURL= function(baseURL) {
            +751 
            +752         if ( !baseURL ) {
            +753             return NS.Module;
            +754         }
            +755 
            +756         if (!baseURL.endsWith("/") ) {
            +757             baseURL= baseURL + "/";
            +758         }
            +759 
            +760         ModuleManager.baseURL= baseURL;
            +761         return NS.ModuleManager;
            +762     };
            +763 
            +764     /**
            +765      * Define a module path. Multiple module paths can be specified.
            +766      * @param module {string}
            +767      * @param path {string}
            +768      */
            +769     NS.ModuleManager.setModulePath= function( module, path ) {
            +770 
            +771         if ( !path.endsWith("/") ) {
            +772             path= path + "/";
            +773         }
            +774 
            +775         if ( !ModuleManager.modulePath[module] ) {
            +776             ModuleManager.modulePath[ module ]= path;
            +777 
            +778             ModuleManager.sortedModulePath.push( module );
            +779 
            +780             /**
            +781              * Sort function so that CAAT.AB is below CAAT.AB.CD
            +782              */
            +783             ModuleManager.sortedModulePath.sort( function(a,b) {
            +784                 if (a==b) {
            +785                     return 0;
            +786                 }
            +787                 return a<b ? 1 : -1;
            +788             } );
            +789         }
            +790         return NS.ModuleManager;
            +791     };
            +792 
            +793     /**
            +794      * Define a symbol, or file to be loaded and checked dependencies against.
            +795      * @param symbol {string}
            +796      * @param path {string}
            +797      * @return {*}
            +798      */
            +799     NS.ModuleManager.symbol= function( symbol, path ) {
            +800 
            +801         if ( !ModuleManager.symbol[symbol] ) {
            +802             ModuleManager.symbol[symbol]= path;
            +803         }
            +804 
            +805         return NS.ModuleManager;
            +806     };
            +807 
            +808     /**
            +809      * Bring the given object, and if no present, start solving and loading dependencies.
            +810      * @param file {string}
            +811      * @return {*}
            +812      */
            +813     NS.ModuleManager.bring= function( file ) {
            +814 
            +815         if ( !isArray(file) ) {
            +816             file= [file];
            +817         }
            +818 
            +819         for( var i=0; i<file.length; i++ ) {
            +820             mm.loadFile( file[i] );
            +821         }
            +822 
            +823         return NS.ModuleManager;
            +824     };
            +825 
            +826     /**
            +827      * Get CAAT´s module manager status.
            +828      */
            +829     NS.ModuleManager.status= function() {
            +830         mm.status();
            +831     }
            +832 
            +833     /**
            +834      * Add an observer for a given module load event.
            +835      * @param modulename {string}
            +836      * @param callback {function()}
            +837      * @return {*}
            +838      */
            +839     NS.ModuleManager.addModuleSolvedListener= function(modulename,callback) {
            +840         mm.addSolveListener( modulename, callback );
            +841         return NS.ModuleManager;
            +842     }
            +843 
            +844     /**
            +845      * Load a javascript file.
            +846      * @param file {string}
            +847      * @param onload {function()}
            +848      * @param onerror {function()}
            +849      */
            +850     NS.ModuleManager.load= function(file, onload, onerror) {
            +851         var node= document.createElement("script");
            +852         node.type = 'text/javascript';
            +853         node.charset = 'utf-8';
            +854         node.async = true;
            +855         if ( onload ) {
            +856             node.addEventListener('load', onload, false);
            +857         }
            +858         if ( onerror ) {
            +859             node.addEventListener('error', onerror, false);
            +860         }
            +861 
            +862         node.addEventListener("load", function( ) {
            +863             mm.solveAll();
            +864         }, false);
            +865 
            +866         node.src = file+(!DEBUG ? "?"+(new Date().getTime()) : "");
            +867 
            +868         document.getElementsByTagName('head')[0].appendChild( node );
            +869 
            +870         // maybe this file has all the modules needed so no more file loading/module resolution must be performed.
            +871 
            +872     }
            +873 
            +874     /**
            +875      * Dump solved modules and get them sorted in the order they were resolved.
            +876      */
            +877     NS.ModuleManager.solvedInOrder= function() {
            +878         mm.solvedInOrder();
            +879     }
            +880 
            +881     /**
            +882      * This method will be called everytime all the specified to-be-brought dependencies have been solved.
            +883      * @param f
            +884      * @return {*}
            +885      */
            +886     NS.ModuleManager.onReady= function(f) {
            +887         mm.onReady(f);
            +888         return NS.ModuleManager;
            +889     }
            +890 
            +891     /**
            +892      * Solve all elements specified in the module loaded.
            +893      * It is useful when minimizing a file.
            +894      */
            +895     NS.ModuleManager.solveAll= function() {
            +896         mm.solveAll();
            +897     }
            +898 
            +899     /**
            +900      * Enable debug capabilities for the loaded modules.
            +901      * Otherwise, the modules will have cache invalidation features.
            +902      * @param d {boolean}
            +903      * @return {*}
            +904      */
            +905     NS.ModuleManager.debug= function(d) {
            +906         DEBUG= d;
            +907         return NS.ModuleManager;
            +908     }
            +909 
            +910     /**
            +911      * @name Class
            +912      * @memberOf CAAT
            +913      * @constructor
            +914      */
            +915     NS.Class= Class;
            +916 
            +917 })(this, undefined);
            +918 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_AnimationLoop.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_AnimationLoop.js.html new file mode 100644 index 0000000..04b3cc8 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_AnimationLoop.js.html @@ -0,0 +1,219 @@ +
              1 CAAT.Module({
            +  2     defines:"CAAT.Event.AnimationLoop",
            +  3     onCreate : function() {
            +  4 
            +  5         /**
            +  6          * @lends CAAT
            +  7          */
            +  8 
            +  9         /**
            + 10          * if RAF, this value signals end of RAF.
            + 11          * @type {Boolean}
            + 12          */
            + 13         CAAT.ENDRAF=false;
            + 14 
            + 15         /**
            + 16          * if setInterval, this value holds CAAT.setInterval return value.
            + 17          * @type {null}
            + 18          */
            + 19         CAAT.INTERVAL_ID=null;
            + 20 
            + 21         /**
            + 22          * Boolean flag to determine if CAAT.loop has already been called.
            + 23          * @type {Boolean}
            + 24          */
            + 25         CAAT.renderEnabled=false;
            + 26 
            + 27         /**
            + 28          * expected FPS when using setInterval animation.
            + 29          * @type {Number}
            + 30          */
            + 31         CAAT.FPS=60;
            + 32 
            + 33         /**
            + 34          * Use RAF shim instead of setInterval. Set to != 0 to use setInterval.
            + 35          * @type {Number}
            + 36          */
            + 37         CAAT.NO_RAF=0;
            + 38 
            + 39         /**
            + 40          * debug panel update time.
            + 41          * @type {Number}
            + 42          */
            + 43         CAAT.FPS_REFRESH=500;
            + 44 
            + 45         /**
            + 46          * requestAnimationFrame time reference.
            + 47          * @type {Number}
            + 48          */
            + 49         CAAT.RAF=0;
            + 50 
            + 51         /**
            + 52          * time between two consecutive RAF. usually bigger than FRAME_TIME
            + 53          * @type {Number}
            + 54          */
            + 55         CAAT.REQUEST_ANIMATION_FRAME_TIME=0;
            + 56 
            + 57         /**
            + 58          * time between two consecutive setInterval calls.
            + 59          * @type {Number}
            + 60          */
            + 61         CAAT.SET_INTERVAL=0;
            + 62 
            + 63         /**
            + 64          * time to process one frame.
            + 65          * @type {Number}
            + 66          */
            + 67         CAAT.FRAME_TIME=0;
            + 68 
            + 69         /**
            + 70          * Current animated director.
            + 71          * @type {CAAT.Foundation.Director}
            + 72          */
            + 73         CAAT.currentDirector=null;
            + 74 
            + 75         /**
            + 76          * Registered director objects.
            + 77          * @type {Array}
            + 78          */
            + 79         CAAT.director=[];
            + 80 
            + 81         /**
            + 82          * Register and keep track of every CAAT.Director instance in the document.
            + 83          */
            + 84         CAAT.RegisterDirector=function (director) {
            + 85             if (!CAAT.currentDirector) {
            + 86                 CAAT.currentDirector = director;
            + 87             }
            + 88             CAAT.director.push(director);
            + 89         };
            + 90 
            + 91         /**
            + 92          * Return current scene.
            + 93          * @return {CAAT.Foundation.Scene}
            + 94          */
            + 95         CAAT.getCurrentScene=function () {
            + 96             return CAAT.currentDirector.getCurrentScene();
            + 97         };
            + 98 
            + 99         /**
            +100          * Return current director's current scene's time.
            +101          * The way to go should be keep local scene references, but anyway, this function is always handy.
            +102          * @return {number} current scene's virtual time.
            +103          */
            +104         CAAT.getCurrentSceneTime=function () {
            +105             return CAAT.currentDirector.getCurrentScene().time;
            +106         };
            +107 
            +108         /**
            +109          * Stop animation loop.
            +110          */
            +111         CAAT.endLoop=function () {
            +112             if (CAAT.NO_RAF) {
            +113                 if (CAAT.INTERVAL_ID !== null) {
            +114                     clearInterval(CAAT.INTERVAL_ID);
            +115                 }
            +116             } else {
            +117                 CAAT.ENDRAF = true;
            +118             }
            +119 
            +120             CAAT.renderEnabled = false;
            +121         };
            +122 
            +123         /**
            +124          * Main animation loop entry point.
            +125          * Must called only once, or only after endLoop.
            +126          *
            +127          * @param fps {number} desired fps. fps parameter will only be used if CAAT.NO_RAF is specified, that is
            +128          * switch from RequestAnimationFrame to setInterval for animation loop.
            +129          */
            +130         CAAT.loop=function (fps) {
            +131             if (CAAT.renderEnabled) {
            +132                 return;
            +133             }
            +134 
            +135             for (var i = 0, l = CAAT.director.length; i < l; i++) {
            +136                 CAAT.director[i].timeline = new Date().getTime();
            +137             }
            +138 
            +139             CAAT.FPS = fps || 60;
            +140             CAAT.renderEnabled = true;
            +141             if (CAAT.NO_RAF) {
            +142                 CAAT.INTERVAL_ID = setInterval(
            +143                     function () {
            +144                         var t = new Date().getTime();
            +145 
            +146                         for (var i = 0, l = CAAT.director.length; i < l; i++) {
            +147                             var dr = CAAT.director[i];
            +148                             if (dr.renderMode === CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS || dr.needsRepaint) {
            +149                                 dr.renderFrame();
            +150                             }
            +151                         }
            +152 
            +153                         CAAT.FRAME_TIME = t - CAAT.SET_INTERVAL;
            +154 
            +155                         if (CAAT.RAF) {
            +156                             CAAT.REQUEST_ANIMATION_FRAME_TIME = new Date().getTime() - CAAT.RAF;
            +157                         }
            +158                         CAAT.RAF = new Date().getTime();
            +159 
            +160                         CAAT.SET_INTERVAL = t;
            +161 
            +162                     },
            +163                     1000 / CAAT.FPS
            +164                 );
            +165             } else {
            +166                 CAAT.renderFrameRAF();
            +167             }
            +168         };
            +169         
            +170         CAAT.renderFrameRAF= function (now) {
            +171             var c= CAAT;
            +172 
            +173             if (c.ENDRAF) {
            +174                 c.ENDRAF = false;
            +175                 return;
            +176             }
            +177 
            +178             if (!now) now = new Date().getTime();
            +179 
            +180             var t= new Date().getTime();
            +181             c.REQUEST_ANIMATION_FRAME_TIME = c.RAF ? now - c.RAF : 16;
            +182             for (var i = 0, l = c.director.length; i < l; i++) {
            +183                 c.director[i].renderFrame();
            +184             }
            +185             c.RAF = now;
            +186             c.FRAME_TIME = new Date().getTime() - t;
            +187 
            +188 
            +189             window.requestAnimFrame(c.renderFrameRAF, 0);
            +190         };
            +191         
            +192         /**
            +193          * Polyfill for requestAnimationFrame.
            +194          */
            +195         window.requestAnimFrame = (function () {
            +196             return  window.requestAnimationFrame ||
            +197                 window.webkitRequestAnimationFrame ||
            +198                 window.mozRequestAnimationFrame ||
            +199                 window.oRequestAnimationFrame ||
            +200                 window.msRequestAnimationFrame ||
            +201                 function raf(/* function */ callback, /* DOMElement */ element) {
            +202                     window.setTimeout(callback, 1000 / CAAT.FPS);
            +203                 };
            +204         })();        
            +205     },
            +206 
            +207     extendsWith:function () {
            +208         return {
            +209         };
            +210     }
            +211 });
            +212 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_Input.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_Input.js.html new file mode 100644 index 0000000..ea36b44 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_Input.js.html @@ -0,0 +1,216 @@ +
              1 CAAT.Module( {
            +  2     defines : "CAAT.Event.Input",
            +  3     depends : [
            +  4         "CAAT.Event.KeyEvent",
            +  5         "CAAT.Event.MouseEvent",
            +  6         "CAAT.Event.TouchEvent"
            +  7     ],
            +  8     onCreate : function() {
            +  9 
            + 10         /**
            + 11          * @lends CAAT
            + 12          */
            + 13 
            + 14         /**
            + 15          * Set the cursor.
            + 16          * @param cursor
            + 17          */
            + 18         CAAT.setCursor= function(cursor) {
            + 19             if ( navigator.browser!=='iOS' ) {
            + 20                 document.body.style.cursor= cursor;
            + 21             }
            + 22         };
            + 23 
            + 24 
            + 25         /**
            + 26          * Constant to set touch behavior as single touch, compatible with mouse.
            + 27          * @type {Number}
            + 28          * @constant
            + 29          */
            + 30         CAAT.TOUCH_AS_MOUSE=        1;
            + 31 
            + 32         /**
            + 33          * Constant to set CAAT touch behavior as multitouch.
            + 34          * @type {Number}
            + 35          * @contant
            + 36          */
            + 37         CAAT.TOUCH_AS_MULTITOUCH=   2;
            + 38 
            + 39         /**
            + 40          * Set CAAT touch behavior as single or multi touch.
            + 41          * @type {Number}
            + 42          */
            + 43         CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MOUSE;
            + 44 
            + 45         /**
            + 46          * Array of window resize listeners.
            + 47          * @type {Array}
            + 48          */
            + 49         CAAT.windowResizeListeners= [];
            + 50 
            + 51         /**
            + 52          * Register a function callback as window resize listener.
            + 53          * @param f
            + 54          */
            + 55         CAAT.registerResizeListener= function(f) {
            + 56             CAAT.windowResizeListeners.push(f);
            + 57         };
            + 58 
            + 59         /**
            + 60          * Remove a function callback as window resize listener.
            + 61          * @param director
            + 62          */
            + 63         CAAT.unregisterResizeListener= function(director) {
            + 64             for( var i=0; i<CAAT.windowResizeListeners.length; i++ ) {
            + 65                 if ( director===CAAT.windowResizeListeners[i] ) {
            + 66                     CAAT.windowResizeListeners.splice(i,1);
            + 67                     return;
            + 68                 }
            + 69             }
            + 70         };
            + 71 
            + 72         /**
            + 73          * Aray of Key listeners.
            + 74          */
            + 75         CAAT.keyListeners= [];
            + 76 
            + 77         /**
            + 78          * Register a function callback as key listener.
            + 79          * @param f
            + 80          */
            + 81         CAAT.registerKeyListener= function(f) {
            + 82             CAAT.keyListeners.push(f);
            + 83         };
            + 84 
            + 85         /**
            + 86          * Acceleration data.
            + 87          * @type {Object}
            + 88          */
            + 89         CAAT.accelerationIncludingGravity= {
            + 90             x:0,
            + 91             y:0,
            + 92             z:0
            + 93         };
            + 94 
            + 95         /**
            + 96          * Device motion angles.
            + 97          * @type {Object}
            + 98          */
            + 99         CAAT.rotationRate= {
            +100             alpha: 0,
            +101             beta:0,
            +102             gamma: 0 };
            +103 
            +104         /**
            +105          * Enable device motion events.
            +106          * This function does not register a callback, instear it sets
            +107          * CAAT.rotationRate and CAAt.accelerationIncludingGravity values.
            +108          */
            +109         CAAT.enableDeviceMotion= function() {
            +110 
            +111             CAAT.prevOnDeviceMotion=    null;   // previous accelerometer callback function.
            +112             CAAT.onDeviceMotion=        null;   // current accelerometer callback set for CAAT.
            +113 
            +114             function tilt(data) {
            +115                 CAAT.rotationRate= {
            +116                         alpha : 0,
            +117                         beta  : data[0],
            +118                         gamma : data[1]
            +119                     };
            +120             }
            +121 
            +122             if (window.DeviceOrientationEvent) {
            +123                 window.addEventListener("deviceorientation", function (event) {
            +124                     tilt([event.beta, event.gamma]);
            +125                 }, true);
            +126             } else if (window.DeviceMotionEvent) {
            +127                 window.addEventListener('devicemotion', function (event) {
            +128                     tilt([event.acceleration.x * 2, event.acceleration.y * 2]);
            +129                 }, true);
            +130             } else {
            +131                 window.addEventListener("MozOrientation", function (event) {
            +132                     tilt([-event.y * 45, event.x * 45]);
            +133                 }, true);
            +134             }
            +135 
            +136         };
            +137 
            +138 
            +139         /**
            +140          * Enable window level input events, keys and redimension.
            +141          */
            +142         window.addEventListener('keydown',
            +143             function(evt) {
            +144                 var key = (evt.which) ? evt.which : evt.keyCode;
            +145 
            +146                 if ( key===CAAT.SHIFT_KEY ) {
            +147                     CAAT.KEY_MODIFIERS.shift= true;
            +148                 } else if ( key===CAAT.CONTROL_KEY ) {
            +149                     CAAT.KEY_MODIFIERS.control= true;
            +150                 } else if ( key===CAAT.ALT_KEY ) {
            +151                     CAAT.KEY_MODIFIERS.alt= true;
            +152                 } else {
            +153                     for( var i=0; i<CAAT.keyListeners.length; i++ ) {
            +154                         CAAT.keyListeners[i]( new CAAT.KeyEvent(
            +155                             key,
            +156                             'down',
            +157                             {
            +158                                 alt:        CAAT.KEY_MODIFIERS.alt,
            +159                                 control:    CAAT.KEY_MODIFIERS.control,
            +160                                 shift:      CAAT.KEY_MODIFIERS.shift
            +161                             },
            +162                             evt)) ;
            +163                     }
            +164                 }
            +165             },
            +166             false);
            +167 
            +168         window.addEventListener('keyup',
            +169             function(evt) {
            +170 
            +171                 var key = (evt.which) ? evt.which : evt.keyCode;
            +172                 if ( key===CAAT.SHIFT_KEY ) {
            +173                     CAAT.KEY_MODIFIERS.shift= false;
            +174                 } else if ( key===CAAT.CONTROL_KEY ) {
            +175                     CAAT.KEY_MODIFIERS.control= false;
            +176                 } else if ( key===CAAT.ALT_KEY ) {
            +177                     CAAT.KEY_MODIFIERS.alt= false;
            +178                 } else {
            +179 
            +180                     for( var i=0; i<CAAT.keyListeners.length; i++ ) {
            +181                         CAAT.keyListeners[i]( new CAAT.KeyEvent(
            +182                             key,
            +183                             'up',
            +184                             {
            +185                                 alt:        CAAT.KEY_MODIFIERS.alt,
            +186                                 control:    CAAT.KEY_MODIFIERS.control,
            +187                                 shift:      CAAT.KEY_MODIFIERS.shift
            +188                             },
            +189                             evt));
            +190                     }
            +191                 }
            +192             },
            +193             false );
            +194 
            +195         window.addEventListener('resize',
            +196             function(evt) {
            +197                 for( var i=0; i<CAAT.windowResizeListeners.length; i++ ) {
            +198                     CAAT.windowResizeListeners[i].windowResized(
            +199                             window.innerWidth,
            +200                             window.innerHeight);
            +201                 }
            +202             },
            +203             false);
            +204 
            +205     },
            +206     extendsWith : {
            +207     }
            +208 });
            +209 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_KeyEvent.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_KeyEvent.js.html new file mode 100644 index 0000000..c475138 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_KeyEvent.js.html @@ -0,0 +1,241 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name Event
            +  5      * @memberOf CAAT
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name KeyEvent
            + 11      * @memberOf CAAT.Event
            + 12      * @constructor
            + 13      */
            + 14 
            + 15     /**
            + 16      * @name KEYS
            + 17      * @memberOf CAAT
            + 18      * @namespace
            + 19      */
            + 20 
            + 21     /**
            + 22      * @name KEY_MODIFIERS
            + 23      * @memberOf CAAT
            + 24      * @namespace
            + 25      */
            + 26 
            + 27     defines : "CAAT.Event.KeyEvent",
            + 28     aliases : "CAAT.KeyEvent",
            + 29     extendsWith : {
            + 30 
            + 31         /**
            + 32          * @lends CAAT.Event.KeyEvent.prototype
            + 33          */
            + 34 
            + 35         /**
            + 36          * Define a key event.
            + 37          * @param keyCode
            + 38          * @param up_or_down
            + 39          * @param modifiers
            + 40          * @param originalEvent
            + 41          */
            + 42         __init : function( keyCode, up_or_down, modifiers, originalEvent ) {
            + 43             this.keyCode= keyCode;
            + 44             this.action=  up_or_down;
            + 45             this.modifiers= modifiers;
            + 46             this.sourceEvent= originalEvent;
            + 47 
            + 48             this.preventDefault= function() {
            + 49                 this.sourceEvent.preventDefault();
            + 50             }
            + 51 
            + 52             this.getKeyCode= function() {
            + 53                 return this.keyCode;
            + 54             };
            + 55 
            + 56             this.getAction= function() {
            + 57                 return this.action;
            + 58             };
            + 59 
            + 60             this.modifiers= function() {
            + 61                 return this.modifiers;
            + 62             };
            + 63 
            + 64             this.isShiftPressed= function() {
            + 65                 return this.modifiers.shift;
            + 66             };
            + 67 
            + 68             this.isControlPressed= function() {
            + 69                 return this.modifiers.control;
            + 70             };
            + 71 
            + 72             this.isAltPressed= function() {
            + 73                 return this.modifiers.alt;
            + 74             };
            + 75 
            + 76             this.getSourceEvent= function() {
            + 77                 return this.sourceEvent;
            + 78             };
            + 79         }
            + 80     },
            + 81     onCreate : function() {
            + 82 
            + 83         /**
            + 84          * @lends CAAT
            + 85          */
            + 86 
            + 87         /**
            + 88          * Key codes
            + 89          * @type {enum}
            + 90          */
            + 91         CAAT.KEYS = {
            + 92 
            + 93             /** @const */ ENTER:13,
            + 94             /** @const */ BACKSPACE:8,
            + 95             /** @const */ TAB:9,
            + 96             /** @const */ SHIFT:16,
            + 97             /** @const */ CTRL:17,
            + 98             /** @const */ ALT:18,
            + 99             /** @const */ PAUSE:19,
            +100             /** @const */ CAPSLOCK:20,
            +101             /** @const */ ESCAPE:27,
            +102             /** @const */ PAGEUP:33,
            +103             /** @const */ PAGEDOWN:34,
            +104             /** @const */ END:35,
            +105             /** @const */ HOME:36,
            +106             /** @const */ LEFT:37,
            +107             /** @const */ UP:38,
            +108             /** @const */ RIGHT:39,
            +109             /** @const */ DOWN:40,
            +110             /** @const */ INSERT:45,
            +111             /** @const */ DELETE:46,
            +112             /** @const */ 0:48,
            +113             /** @const */ 1:49,
            +114             /** @const */ 2:50,
            +115             /** @const */ 3:51,
            +116             /** @const */ 4:52,
            +117             /** @const */ 5:53,
            +118             /** @const */ 6:54,
            +119             /** @const */ 7:55,
            +120             /** @const */ 8:56,
            +121             /** @const */ 9:57,
            +122             /** @const */ a:65,
            +123             /** @const */ b:66,
            +124             /** @const */ c:67,
            +125             /** @const */ d:68,
            +126             /** @const */ e:69,
            +127             /** @const */ f:70,
            +128             /** @const */ g:71,
            +129             /** @const */ h:72,
            +130             /** @const */ i:73,
            +131             /** @const */ j:74,
            +132             /** @const */ k:75,
            +133             /** @const */ l:76,
            +134             /** @const */ m:77,
            +135             /** @const */ n:78,
            +136             /** @const */ o:79,
            +137             /** @const */ p:80,
            +138             /** @const */ q:81,
            +139             /** @const */ r:82,
            +140             /** @const */ s:83,
            +141             /** @const */ t:84,
            +142             /** @const */ u:85,
            +143             /** @const */ v:86,
            +144             /** @const */ w:87,
            +145             /** @const */ x:88,
            +146             /** @const */ y:89,
            +147             /** @const */ z:90,
            +148             /** @const */ SELECT:93,
            +149             /** @const */ NUMPAD0:96,
            +150             /** @const */ NUMPAD1:97,
            +151             /** @const */ NUMPAD2:98,
            +152             /** @const */ NUMPAD3:99,
            +153             /** @const */ NUMPAD4:100,
            +154             /** @const */ NUMPAD5:101,
            +155             /** @const */ NUMPAD6:102,
            +156             /** @const */ NUMPAD7:103,
            +157             /** @const */ NUMPAD8:104,
            +158             /** @const */ NUMPAD9:105,
            +159             /** @const */ MULTIPLY:106,
            +160             /** @const */ ADD:107,
            +161             /** @const */ SUBTRACT:109,
            +162             /** @const */ DECIMALPOINT:110,
            +163             /** @const */ DIVIDE:111,
            +164             /** @const */ F1:112,
            +165             /** @const */ F2:113,
            +166             /** @const */ F3:114,
            +167             /** @const */ F4:115,
            +168             /** @const */ F5:116,
            +169             /** @const */ F6:117,
            +170             /** @const */ F7:118,
            +171             /** @const */ F8:119,
            +172             /** @const */ F9:120,
            +173             /** @const */ F10:121,
            +174             /** @const */ F11:122,
            +175             /** @const */ F12:123,
            +176             /** @const */ NUMLOCK:144,
            +177             /** @const */ SCROLLLOCK:145,
            +178             /** @const */ SEMICOLON:186,
            +179             /** @const */ EQUALSIGN:187,
            +180             /** @const */ COMMA:188,
            +181             /** @const */ DASH:189,
            +182             /** @const */ PERIOD:190,
            +183             /** @const */ FORWARDSLASH:191,
            +184             /** @const */ GRAVEACCENT:192,
            +185             /** @const */ OPENBRACKET:219,
            +186             /** @const */ BACKSLASH:220,
            +187             /** @const */ CLOSEBRAKET:221,
            +188             /** @const */ SINGLEQUOTE:222
            +189         };
            +190 
            +191         /**
            +192          * @deprecated
            +193          * @type {Object}
            +194          */
            +195         CAAT.Keys= CAAT.KEYS;
            +196 
            +197         /**
            +198          * Shift key code
            +199          * @type {Number}
            +200          */
            +201         CAAT.SHIFT_KEY=    16;
            +202 
            +203         /**
            +204          * Control key code
            +205          * @type {Number}
            +206          */
            +207         CAAT.CONTROL_KEY=  17;
            +208 
            +209         /**
            +210          * Alt key code
            +211          * @type {Number}
            +212          */
            +213         CAAT.ALT_KEY=      18;
            +214 
            +215         /**
            +216          * Enter key code
            +217          * @type {Number}
            +218          */
            +219         CAAT.ENTER_KEY=    13;
            +220 
            +221         /**
            +222          * Event modifiers.
            +223          * @type enum
            +224          */
            +225         CAAT.KEY_MODIFIERS= {
            +226 
            +227             /** @const */ alt:        false,
            +228             /** @const */ control:    false,
            +229             /** @const */ shift:      false
            +230         };
            +231     }
            +232 
            +233 });
            +234 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_MouseEvent.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_MouseEvent.js.html new file mode 100644 index 0000000..cac92d5 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_MouseEvent.js.html @@ -0,0 +1,116 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name MouseEvent
            +  5      * @memberOf CAAT.Event
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Event.MouseEvent",
            + 10     aliases : ["CAAT.MouseEvent"],
            + 11     depends : [
            + 12         "CAAT.Math.Point"
            + 13     ],
            + 14     extendsWith : {
            + 15 
            + 16         /**
            + 17          * @lends CAAT.Event.MouseEvent.prototype
            + 18          */
            + 19 
            + 20         /**
            + 21          * Constructor delegate
            + 22          * @private
            + 23          */
            + 24         __init : function() {
            + 25             this.point= new CAAT.Math.Point(0,0,0);
            + 26             this.screenPoint= new CAAT.Math.Point(0,0,0);
            + 27             this.touches= [];
            + 28             return this;
            + 29         },
            + 30 
            + 31         /**
            + 32          * Original mouse/touch screen coord
            + 33          */
            + 34 		screenPoint:	null,
            + 35 
            + 36         /**
            + 37          * Transformed in-actor coordinate
            + 38          */
            + 39 		point:			null,
            + 40 
            + 41         /**
            + 42          * scene time when the event was triggered.
            + 43          */
            + 44 		time:			0,
            + 45 
            + 46         /**
            + 47          * Actor the event was produced in.
            + 48          */
            + 49 		source:			null,
            + 50 
            + 51         /**
            + 52          * Was shift pressed ?
            + 53          */
            + 54         shift:          false,
            + 55 
            + 56         /**
            + 57          * Was control pressed ?
            + 58          */
            + 59         control:        false,
            + 60 
            + 61         /**
            + 62          * was alt pressed ?
            + 63          */
            + 64         alt:            false,
            + 65 
            + 66         /**
            + 67          * was Meta key pressed ?
            + 68          */
            + 69         meta:           false,
            + 70 
            + 71         /**
            + 72          * Original mouse/touch event
            + 73          */
            + 74         sourceEvent:    null,
            + 75 
            + 76         touches     :   null,
            + 77 
            + 78 		init : function( x,y,sourceEvent,source,screenPoint,time ) {
            + 79 			this.point.set(x,y);
            + 80 			this.source=        source;
            + 81 			this.screenPoint=   screenPoint;
            + 82             this.alt =          sourceEvent.altKey;
            + 83             this.control =      sourceEvent.ctrlKey;
            + 84             this.shift =        sourceEvent.shiftKey;
            + 85             this.meta =         sourceEvent.metaKey;
            + 86             this.sourceEvent=   sourceEvent;
            + 87             this.x=             x;
            + 88             this.y=             y;
            + 89             this.time=          time;
            + 90 			return this;
            + 91 		},
            + 92 		isAltDown : function() {
            + 93 			return this.alt;
            + 94 		},
            + 95 		isControlDown : function() {
            + 96 			return this.control;
            + 97 		},
            + 98 		isShiftDown : function() {
            + 99 			return this.shift;
            +100 		},
            +101         isMetaDown: function() {
            +102             return this.meta;
            +103         },
            +104         getSourceEvent : function() {
            +105             return this.sourceEvent;
            +106         }
            +107 	}
            +108 });
            +109 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchEvent.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchEvent.js.html new file mode 100644 index 0000000..1e0ab93 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchEvent.js.html @@ -0,0 +1,135 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TouchEvent
            +  5      * @memberOf CAAT.Event
            +  6      * @constructor
            +  7      */
            +  8 
            +  9 
            + 10     defines : "CAAT.Event.TouchEvent",
            + 11     aliases : ["CAAT.TouchEvent"],
            + 12     depends : [
            + 13         "CAAT.Event.TouchInfo"
            + 14     ],
            + 15     extendsWith : {
            + 16 
            + 17         /**
            + 18          * @lends CAAT.Event.TouchEvent.prototype
            + 19          */
            + 20 
            + 21         /**
            + 22          * Constructor delegate
            + 23          * @private
            + 24          */
            + 25         __init : function() {
            + 26             this.touches= [];
            + 27             this.changedTouches= [];
            + 28             return this;
            + 29         },
            + 30 
            + 31         /**
            + 32          * Time the touch event was triggered at.
            + 33          */
            + 34 		time:			0,
            + 35 
            + 36         /**
            + 37          * Source Actor the event happened in.
            + 38          */
            + 39 		source:			null,
            + 40 
            + 41         /**
            + 42          * Original touch event.
            + 43          */
            + 44         sourceEvent:    null,
            + 45 
            + 46         /**
            + 47          * Was shift pressed ?
            + 48          */
            + 49         shift:          false,
            + 50 
            + 51         /**
            + 52          * Was control pressed ?
            + 53          */
            + 54         control:        false,
            + 55 
            + 56         /**
            + 57          * Was alt pressed ?
            + 58          */
            + 59         alt:            false,
            + 60 
            + 61         /**
            + 62          * Was meta pressed ?
            + 63          */
            + 64         meta:           false,
            + 65 
            + 66         /**
            + 67          * touches collection
            + 68          */
            + 69         touches         : null,
            + 70 
            + 71         /**
            + 72          * changed touches collection
            + 73          */
            + 74         changedTouches  : null,
            + 75 
            + 76 		init : function( sourceEvent,source,time ) {
            + 77 
            + 78 			this.source=        source;
            + 79             this.alt =          sourceEvent.altKey;
            + 80             this.control =      sourceEvent.ctrlKey;
            + 81             this.shift =        sourceEvent.shiftKey;
            + 82             this.meta =         sourceEvent.metaKey;
            + 83             this.sourceEvent=   sourceEvent;
            + 84             this.time=          time;
            + 85 
            + 86 			return this;
            + 87 		},
            + 88         /**
            + 89          *
            + 90          * @param touchInfo
            + 91          *  <{
            + 92          *      id : <number>,
            + 93          *      point : {
            + 94          *          x: <number>,
            + 95          *          y: <number> }�
            + 96          *  }>
            + 97          * @return {*}
            + 98          */
            + 99         addTouch : function( touchInfo ) {
            +100             if ( -1===this.touches.indexOf( touchInfo ) ) {
            +101                 this.touches.push( touchInfo );
            +102             }
            +103             return this;
            +104         },
            +105         addChangedTouch : function( touchInfo ) {
            +106             if ( -1===this.changedTouches.indexOf( touchInfo ) ) {
            +107                 this.changedTouches.push( touchInfo );
            +108             }
            +109             return this;
            +110         },
            +111 		isAltDown : function() {
            +112 			return this.alt;
            +113 		},
            +114 		isControlDown : function() {
            +115 			return this.control;
            +116 		},
            +117 		isShiftDown : function() {
            +118 			return this.shift;
            +119 		},
            +120         isMetaDown: function() {
            +121             return this.meta;
            +122         },
            +123         getSourceEvent : function() {
            +124             return this.sourceEvent;
            +125         }
            +126 	}
            +127 });
            +128 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchInfo.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchInfo.js.html new file mode 100644 index 0000000..29524ee --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Event_TouchInfo.js.html @@ -0,0 +1,46 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TouchInfo
            +  5      * @memberOf CAAT.Event
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Event.TouchInfo",
            + 10     aliases : ["CAAT.TouchInfo"],
            + 11     extendsWith : {
            + 12 
            + 13         /**
            + 14          * @lends CAAT.Event.TouchInfo.prototype
            + 15          */
            + 16 
            + 17         /**
            + 18          * Constructor delegate.
            + 19          * @param id {number}
            + 20          * @param x {number}
            + 21          * @param y {number}
            + 22          * @param target {DOMElement}
            + 23          * @private
            + 24          */
            + 25         __init : function( id, x, y, target ) {
            + 26 
            + 27             this.identifier= id;
            + 28             this.clientX= x;
            + 29             this.pageX= x;
            + 30             this.clientY= y;
            + 31             this.pageY= y;
            + 32             this.target= target;
            + 33             this.time= new Date().getTime();
            + 34 
            + 35             return this;
            + 36         }
            + 37     }
            + 38 });
            + 39 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Actor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Actor.js.html new file mode 100644 index 0000000..87a810b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Actor.js.html @@ -0,0 +1,2597 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8 
            +  9 
            + 10 
            + 11     /**
            + 12      *
            + 13      * CAAT.Foundation is the base namespace for all the core animation elements.
            + 14      *
            + 15      * @name Foundation
            + 16      * @namespace
            + 17      * @memberOf CAAT
            + 18      *
            + 19      */
            + 20 
            + 21     /**
            + 22      *
            + 23      * CAAT.Foundation.Actor is the base animable element. It is the base object for Director, Scene and
            + 24      * Container.
            + 25      *    <p>CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance.
            + 26      *        An Actor has entity, it has a size, position and can have input sent to it. Everything that has a
            + 27      *        visual representation is an Actor, including Director and Scene objects.</p>
            + 28      *    <p>This object has functionality for:</p>
            + 29      *    <ol>
            + 30      *        <li>Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.</li>
            + 31      *        <li>Set affine transforms (rotation, scale and translation).</li>
            + 32      *        <li>Define life cycle.</li>
            + 33      *        <li>Manage alpha transparency.</li>
            + 34      *        <li>Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.</li>
            + 35      *        <li>Compose transformations. A container Actor will transform its children before they apply their own transformation.</li>
            + 36      *        <li>Clipping capabilities. Either rectangular or arbitrary shapes.</li>
            + 37      *        <li>The API is developed to allow method chaining when possible.</li>
            + 38      *        <li>Handle input (either mouse events, touch, multitouch, keys and accelerometer).</li>
            + 39      *        <li>Show an image.</li>
            + 40      *        <li>Show some image animations.</li>
            + 41      *        <li>etc.</li>
            + 42      *    </ol>
            + 43      *
            + 44      * @name Actor
            + 45      * @memberOf CAAT.Foundation
            + 46      * @constructor
            + 47      *
            + 48      */
            + 49 
            + 50     defines:"CAAT.Foundation.Actor",
            + 51     aliases: [ "CAAT.Actor" ],
            + 52     depends: [
            + 53         "CAAT.Math.Dimension",
            + 54         "CAAT.Event.AnimationLoop",
            + 55         "CAAT.Foundation.SpriteImage",
            + 56         "CAAT.Core.Constants",
            + 57         "CAAT.Behavior.PathBehavior",
            + 58         "CAAT.Behavior.RotateBehavior",
            + 59         "CAAT.Behavior.ScaleBehavior",
            + 60         "CAAT.Behavior.Scale1Behavior",
            + 61         "CAAT.PathUtil.LinearPath",
            + 62         "CAAT.Event.AnimationLoop"
            + 63     ],
            + 64     constants :  {
            + 65         /**
            + 66          * @lends  CAAT.Foundation.Actor
            + 67          */
            + 68 
            + 69         /** @const @type {number} */ ANCHOR_CENTER:0, // constant values to determine different affine transform
            + 70         /** @const @type {number} */ ANCHOR_TOP:1, // anchors.
            + 71         /** @const @type {number} */ ANCHOR_BOTTOM:2,
            + 72         /** @const @type {number} */ ANCHOR_LEFT:3,
            + 73         /** @const @type {number} */ ANCHOR_RIGHT:4,
            + 74         /** @const @type {number} */ ANCHOR_TOP_LEFT:5,
            + 75         /** @const @type {number} */ ANCHOR_TOP_RIGHT:6,
            + 76         /** @const @type {number} */ ANCHOR_BOTTOM_LEFT:7,
            + 77         /** @const @type {number} */ ANCHOR_BOTTOM_RIGHT:8,
            + 78         /** @const @type {number} */ ANCHOR_CUSTOM:9,
            + 79 
            + 80         /** @const @type {number} */ CACHE_NONE:0,
            + 81         /** @const @type {number} */ CACHE_SIMPLE:1,
            + 82         /** @const @type {number} */ CACHE_DEEP:2
            + 83     },
            + 84 
            + 85     extendsWith : function () {
            + 86 
            + 87         var __index = 0;
            + 88 
            + 89         return  {
            + 90 
            + 91             /**
            + 92              * @lends CAAT.Foundation.Actor.prototype
            + 93              */
            + 94 
            + 95             __init:function () {
            + 96                 this.behaviorList = [];
            + 97                 this.lifecycleListenerList = [];
            + 98                 this.AABB = new CAAT.Math.Rectangle();
            + 99                 this.viewVertices = [
            +100                     new CAAT.Math.Point(0, 0, 0),
            +101                     new CAAT.Math.Point(0, 0, 0),
            +102                     new CAAT.Math.Point(0, 0, 0),
            +103                     new CAAT.Math.Point(0, 0, 0)
            +104                 ];
            +105 
            +106                 this.scaleAnchor = CAAT.Foundation.Actor.ANCHOR_CENTER;
            +107 
            +108                 this.modelViewMatrix = new CAAT.Math.Matrix();
            +109                 this.worldModelViewMatrix = new CAAT.Math.Matrix();
            +110 
            +111                 this.resetTransform();
            +112                 this.setScale(1, 1);
            +113                 this.setRotation(0);
            +114 
            +115                 this.id = __index++;
            +116 
            +117                 return this;
            +118             },
            +119 
            +120             /**
            +121              * @type {object}
            +122              */
            +123             __super : null,
            +124 
            +125             /**
            +126              * A collection of this Actors lifecycle observers.
            +127              * @type { Array.<{actorLifeCycleEvent : function( CAAT.Foundation.Actor, string, number ) }> }
            +128              */
            +129             lifecycleListenerList:null,
            +130 
            +131             /**
            +132              * A collection of behaviors to modify this actor´s properties.
            +133              * @type { Array.<CAAT.Behavior.Behavior> }
            +134              */
            +135             behaviorList:null,
            +136 
            +137             /**
            +138              * This actor's parent container.
            +139              * @type { CAAT.Foundation.ActorContainer }
            +140              */
            +141             parent:null, // Parent of this Actor. May be Scene.
            +142 
            +143             /**
            +144              * x position on parent. In parent's local coord. system.
            +145              * @type {number}
            +146              */
            +147             x:0,
            +148             /**
            +149              * y position on parent. In parent's local coord. system.
            +150              * @type {number}
            +151              */
            +152             y:0,
            +153 
            +154             /**
            +155              * Actor's width. In parent's local coord. system.
            +156              * @type {number}
            +157              */
            +158             width:0,
            +159 
            +160             /**
            +161              * Actor's height. In parent's local coord. system.
            +162              * @type {number}
            +163              */
            +164             height:0,
            +165 
            +166             /**
            +167              * actor´s layout preferred size.
            +168              * @type {CAAT.Math.Dimension}
            +169              */
            +170             preferredSize:null,
            +171 
            +172             /**
            +173              * actor's layout minimum size.
            +174              * @type {CAAT.Math.Dimension}
            +175              */
            +176             minimumSize:null,
            +177 
            +178             /**
            +179              * Marks since when this actor, relative to scene time, is going to be animated/drawn.
            +180              * @type {number}
            +181              */
            +182             start_time:0,
            +183 
            +184             /**
            +185              * Marks from the time this actor is going to be animated, during how much time.
            +186              * Forever by default.
            +187              * @type {number}
            +188              */
            +189             duration:Number.MAX_VALUE,
            +190 
            +191             /**
            +192              * Will this actor be clipped before being drawn on screen ?
            +193              * @type {boolean}
            +194              */
            +195             clip:false,
            +196 
            +197             /**
            +198              * If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise,
            +199              * clipPath contains a reference to a CAAT.PathUtil.Path object.
            +200              * @type {CAAT.PathUtil.Path}
            +201              */
            +202             clipPath:null,
            +203 
            +204             /**
            +205              * Translation x anchor. 0..1
            +206              * @type {number}
            +207              */
            +208             tAnchorX:0,
            +209 
            +210             /**
            +211              * Translation y anchor. 0..1
            +212              * @type {number}
            +213              */
            +214             tAnchorY:0,
            +215 
            +216             /**
            +217              * ScaleX value.
            +218              * @type {number}
            +219              */
            +220             scaleX:1, // transformation. width scale parameter
            +221 
            +222             /**
            +223              * ScaleY value.
            +224              * @type {number}
            +225              */
            +226             scaleY:1, // transformation. height scale parameter
            +227 
            +228             /**
            +229              * Scale Anchor X. Value 0-1
            +230              * @type {number}
            +231              */
            +232             scaleTX:.50, // transformation. scale anchor x position
            +233 
            +234             /**
            +235              * Scale Anchor Y. Value 0-1
            +236              * @type {number}
            +237              */
            +238             scaleTY:.50, // transformation. scale anchor y position
            +239 
            +240             /**
            +241              * A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value.
            +242              * @type {CAAT.Foundation.Actor.ANCHOR_*}
            +243              */
            +244             scaleAnchor:0, // transformation. scale anchor
            +245 
            +246             /**
            +247              * This actor´s rotation angle in radians.
            +248              * @type {number}
            +249              */
            +250             rotationAngle:0, // transformation. rotation angle in radians
            +251 
            +252             /**
            +253              * Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
            +254              * @type {number}
            +255              */
            +256             rotationY:.50, // transformation. rotation center y
            +257 
            +258             /**
            +259              * Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
            +260              * @type {number}
            +261              */
            +262             rotationX:.50, // transformation. rotation center x
            +263 
            +264             /**
            +265              * Transparency value. 0 is totally transparent, 1 is totally opaque.
            +266              * @type {number}
            +267              */
            +268             alpha:1, // alpha transparency value
            +269 
            +270             /**
            +271              * true to make all children transparent, false, only this actor/container will be transparent.
            +272              * @type {boolean}
            +273              */
            +274             isGlobalAlpha:false, // is this a global alpha
            +275 
            +276             /**
            +277              * @type {number}
            +278              * @private
            +279              */
            +280             frameAlpha:1, // hierarchically calculated alpha for this Actor.
            +281 
            +282             /**
            +283              * Mark this actor as expired, or out of the scene time.
            +284              * @type {boolean}
            +285              */
            +286             expired:false,
            +287 
            +288             /**
            +289              * Mark this actor as discardable. If an actor is expired and mark as discardable, if will be
            +290              * removed from its parent.
            +291              * @type {boolean}
            +292              */
            +293             discardable:false, // set when you want this actor to be removed if expired
            +294 
            +295             /**
            +296              * @type {boolean}
            +297              */
            +298             pointed:false, // is the mouse pointer inside this actor
            +299 
            +300             /**
            +301              * Enable or disable input on this actor. By default, all actors receive input.
            +302              * See also priority lists.
            +303              * see demo4 for an example of input and priority lists.
            +304              * @type {boolean}
            +305              */
            +306             mouseEnabled:true, // events enabled ?
            +307 
            +308             /**
            +309              * Make this actor visible or not.
            +310              * An invisible actor avoids making any calculation, applying any behavior on it.
            +311              * @type {boolean}
            +312              */
            +313             visible:true,
            +314 
            +315             /**
            +316              * any canvas rendering valid fill style.
            +317              * @type {string}
            +318              */
            +319             fillStyle:null,
            +320 
            +321             /**
            +322              * any canvas rendering valid stroke style.
            +323              * @type {string}
            +324              */
            +325             strokeStyle:null,
            +326 
            +327             /**
            +328              * This actor´s scene time.
            +329              * @type {number}
            +330              */
            +331             time:0, // Cache Scene time.
            +332 
            +333             /**
            +334              * This rectangle keeps the axis aligned bounding box in screen coords of this actor.
            +335              * In can be used, among other uses, to realize whether two given actors collide regardless
            +336              * the affine transformation is being applied on them.
            +337              * @type {CAAT.Math.Rectangle}
            +338              */
            +339             AABB:null,
            +340 
            +341             /**
            +342              * These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding
            +343              * box. If the actor is not rotated, viewVertices and AABB define the same bounding box.
            +344              * @type {Array.<CAAT.Math.Point>}
            +345              */
            +346             viewVertices:null, // model to view transformed vertices.
            +347 
            +348             /**
            +349              * Is this actor processed in the last frame ?
            +350              * @type {boolean}
            +351              */
            +352             inFrame:false, // boolean indicating whether this Actor was present on last frame.
            +353 
            +354             /**
            +355              * Local matrix dirtyness flag.
            +356              * @type {boolean}
            +357              * @private
            +358              */
            +359             dirty:true, // model view is dirty ?
            +360 
            +361             /**
            +362              * Global matrix dirtyness flag.
            +363              * @type {boolean}
            +364              * @private
            +365              */
            +366             wdirty:true, // world model view is dirty ?
            +367 
            +368             /**
            +369              * @type {number}
            +370              * @private
            +371              */
            +372             oldX:-1,
            +373 
            +374             /**
            +375              * @type {number}
            +376              * @private
            +377              */
            +378             oldY:-1,
            +379 
            +380             /**
            +381              * This actor´s affine transformation matrix.
            +382              * @type {CAAT.Math.Matrix}
            +383              */
            +384             modelViewMatrix:null, // model view matrix.
            +385 
            +386             /**
            +387              * This actor´s world affine transformation matrix.
            +388              * @type {CAAT.Math.Matrix}
            +389              */
            +390             worldModelViewMatrix:null, // world model view matrix.
            +391 
            +392             /**
            +393              * @type {CAAT.Math.Matrix}
            +394              */
            +395             modelViewMatrixI:null, // model view matrix.
            +396 
            +397             /**
            +398              * @type {CAAT.Math.Matrix}
            +399              */
            +400             worldModelViewMatrixI:null, // world model view matrix.
            +401 
            +402             /**
            +403              * Is this actor enabled on WebGL ?
            +404              * @type {boolean}
            +405              */
            +406             glEnabled:false,
            +407 
            +408             /**
            +409              * Define this actor´s background image.
            +410              * See SpriteImage object.
            +411              * @type {CAAT.Foundation.SpriteImage}
            +412              */
            +413             backgroundImage:null,
            +414 
            +415             /**
            +416              * Set this actor´ id so that it can be later identified easily.
            +417              * @type {object}
            +418              */
            +419             id:null,
            +420 
            +421             /**
            +422              * debug info.
            +423              * @type {number}
            +424              */
            +425             size_active:1, // number of animated children
            +426 
            +427             /**
            +428              * debug info.
            +429              * @type {number}
            +430              */
            +431             size_total:1,
            +432 
            +433             __d_ax:-1, // for drag-enabled actors.
            +434             __d_ay:-1,
            +435 
            +436             /**
            +437              * Is gesture recognition enabled on this actor ??
            +438              * @type {boolean}
            +439              */
            +440             gestureEnabled:false,
            +441 
            +442             /**
            +443              * If dirty rects are enabled, this flag indicates the rendering engine to invalidate this
            +444              * actor´s screen area.
            +445              * @type {boolean}
            +446              */
            +447             invalid:true,
            +448 
            +449             /**
            +450              * Caching as bitmap strategy. Suitable to cache very complex actors.
            +451              *
            +452              * 0 : no cache.
            +453              * CACHE_SIMPLE : if a container, only cache the container.
            +454              * CACHE_DEEP : if a container, cache the container and recursively all of its children.
            +455              *
            +456              * @type {number}
            +457              */
            +458             cached:0, // 0 no, CACHE_SIMPLE | CACHE_DEEP
            +459 
            +460             /**
            +461              * Exclude this actor from automatic layout on its parent.
            +462              * @type {boolean}
            +463              */
            +464             preventLayout : false,
            +465 
            +466             /**
            +467              * is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated.
            +468              * @type {boolean}
            +469              * @private
            +470              */
            +471             isAA:true,
            +472 
            +473             /**
            +474              * if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some
            +475              * internal properties.
            +476              */
            +477             isCachedActor : false,
            +478 
            +479             setCachedActor : function(cached) {
            +480                 this.isCachedActor= cached;
            +481                 return this;
            +482             },
            +483 
            +484             /**
            +485              * Make this actor not be laid out.
            +486              */
            +487             setPreventLayout : function(b) {
            +488                 this.preventLayout= b;
            +489                 return this;
            +490             },
            +491 
            +492             invalidateLayout:function () {
            +493                 if (this.parent && !this.parent.layoutInvalidated) {
            +494                     this.parent.invalidateLayout();
            +495                 }
            +496 
            +497                 return this;
            +498             },
            +499 
            +500             __validateLayout:function () {
            +501 
            +502             },
            +503 
            +504             /**
            +505              * Set this actors preferred layout size.
            +506              *
            +507              * @param pw {number}
            +508              * @param ph {number}
            +509              * @return {*}
            +510              */
            +511             setPreferredSize:function (pw, ph) {
            +512                 if (!this.preferredSize) {
            +513                     this.preferredSize = new CAAT.Math.Dimension();
            +514                 }
            +515                 this.preferredSize.width = pw;
            +516                 this.preferredSize.height = ph;
            +517                 return this;
            +518             },
            +519 
            +520             getPreferredSize:function () {
            +521                 return this.preferredSize ? this.preferredSize :
            +522                     this.getMinimumSize();
            +523             },
            +524 
            +525             /**
            +526              * Set this actors minimum layout size.
            +527              *
            +528              * @param pw {number}
            +529              * @param ph {number}
            +530              * @return {*}
            +531              */
            +532             setMinimumSize:function (pw, ph) {
            +533                 if (!this.minimumSize) {
            +534                     this.minimumSize = new CAAT.Math.Dimension();
            +535                 }
            +536 
            +537                 this.minimumSize.width = pw;
            +538                 this.minimumSize.height = ph;
            +539                 return this;
            +540             },
            +541 
            +542             getMinimumSize:function () {
            +543                 return this.minimumSize ? this.minimumSize :
            +544                     new CAAT.Math.Dimension(this.width, this.height);
            +545             },
            +546 
            +547             /**
            +548              * @deprecated
            +549              * @return {*}
            +550              */
            +551             create:function () {
            +552                 return this;
            +553             },
            +554             /**
            +555              * Move this actor to a position.
            +556              * It creates and adds a new PathBehavior.
            +557              * @param x {number} new x position
            +558              * @param y {number} new y position
            +559              * @param duration {number} time to take to get to new position
            +560              * @param delay {=number} time to wait before start moving
            +561              * @param interpolator {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance
            +562              */
            +563             moveTo:function (x, y, duration, delay, interpolator, callback) {
            +564 
            +565                 if (x === this.x && y === this.y) {
            +566                     return;
            +567                 }
            +568 
            +569                 var id = '__moveTo';
            +570                 var b = this.getBehavior(id);
            +571                 if (!b) {
            +572                     b = new CAAT.Behavior.PathBehavior().
            +573                         setId(id).
            +574                         setValues(new CAAT.PathUtil.LinearPath());
            +575                     this.addBehavior(b);
            +576                 }
            +577 
            +578                 b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y);
            +579                 b.setDelayTime(delay ? delay : 0, duration);
            +580                 if (interpolator) {
            +581                     b.setInterpolator(interpolator);
            +582                 }
            +583 
            +584                 if (callback) {
            +585                     b.lifecycleListenerList = [];
            +586                     b.addListener({
            +587                         behaviorExpired:function (behavior, time, actor) {
            +588                             callback(behavior, time, actor);
            +589                         }
            +590                     });
            +591                 }
            +592 
            +593                 return this;
            +594             },
            +595 
            +596             /**
            +597              *
            +598              * @param angle {number} new rotation angle
            +599              * @param duration {number} time to rotate
            +600              * @param delay {number=} millis to start rotation
            +601              * @param anchorX {number=} rotation anchor x
            +602              * @param anchorY {number=} rotation anchor y
            +603              * @param interpolator {CAAT.Behavior.Interpolator=}
            +604              * @return {*}
            +605              */
            +606             rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) {
            +607 
            +608                 if (angle === this.rotationAngle) {
            +609                     return;
            +610                 }
            +611 
            +612                 var id = '__rotateTo';
            +613                 var b = this.getBehavior(id);
            +614                 if (!b) {
            +615                     b = new CAAT.Behavior.RotateBehavior().
            +616                         setId(id).
            +617                         setValues(0, 0, .5, .5);
            +618                     this.addBehavior(b);
            +619                 }
            +620 
            +621                 b.setValues(this.rotationAngle, angle, anchorX, anchorY).
            +622                     setDelayTime(delay ? delay : 0, duration);
            +623 
            +624                 if (interpolator) {
            +625                     b.setInterpolator(interpolator);
            +626                 }
            +627 
            +628                 return this;
            +629             },
            +630 
            +631             /**
            +632              *
            +633              * @param scaleX {number} new X scale
            +634              * @param scaleY {number} new Y scale
            +635              * @param duration {number} time to rotate
            +636              * @param delay {=number} millis to start rotation
            +637              * @param anchorX {=number} rotation anchor x
            +638              * @param anchorY {=number} rotation anchor y
            +639              * @param interpolator {=CAAT.Behavior.Interpolator}
            +640              * @return {*}
            +641              */
            +642             scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) {
            +643 
            +644                 if (this.scaleX === scaleX && this.scaleY === scaleY) {
            +645                     return;
            +646                 }
            +647 
            +648                 var id = '__scaleTo';
            +649                 var b = this.getBehavior(id);
            +650                 if (!b) {
            +651                     b = new CAAT.Behavior.ScaleBehavior().
            +652                         setId(id).
            +653                         setValues(1, 1, 1, 1, .5, .5);
            +654                     this.addBehavior(b);
            +655                 }
            +656 
            +657                 b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY).
            +658                     setDelayTime(delay ? delay : 0, duration);
            +659 
            +660                 if (interpolator) {
            +661                     b.setInterpolator(interpolator);
            +662                 }
            +663 
            +664                 return this;
            +665             },
            +666 
            +667             /**
            +668              *
            +669              * @param scaleX {number} new X scale
            +670              * @param duration {number} time to rotate
            +671              * @param delay {=number} millis to start rotation
            +672              * @param anchorX {=number} rotation anchor x
            +673              * @param anchorY {=number} rotation anchor y
            +674              * @param interpolator {=CAAT.Behavior.Interpolator}
            +675              * @return {*}
            +676              */
            +677             scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) {
            +678                 return this.__scale1To(
            +679                     CAAT.Behavior.Scale1Behavior.AXIS_X,
            +680                     scaleX,
            +681                     duration,
            +682                     delay,
            +683                     anchorX,
            +684                     anchorY,
            +685                     interpolator
            +686                 );
            +687             },
            +688 
            +689             /**
            +690              *
            +691              * @param scaleY {number} new Y scale
            +692              * @param duration {number} time to rotate
            +693              * @param delay {=number} millis to start rotation
            +694              * @param anchorX {=number} rotation anchor x
            +695              * @param anchorY {=number} rotation anchor y
            +696              * @param interpolator {=CAAT.Behavior.Interpolator}
            +697              * @return {*}
            +698              */
            +699             scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) {
            +700                 return this.__scale1To(
            +701                     CAAT.Behavior.Scale1Behavior.AXIS_Y,
            +702                     scaleY,
            +703                     duration,
            +704                     delay,
            +705                     anchorX,
            +706                     anchorY,
            +707                     interpolator
            +708                 );
            +709             },
            +710 
            +711             /**
            +712              * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis
            +713              * @param scale {number} new Y scale
            +714              * @param duration {number} time to rotate
            +715              * @param delay {=number} millis to start rotation
            +716              * @param anchorX {=number} rotation anchor x
            +717              * @param anchorY {=number} rotation anchor y
            +718              * @param interpolator {=CAAT.Bahavior.Interpolator}
            +719              * @return {*}
            +720              */
            +721             __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) {
            +722 
            +723                 if (( axis === CAAT.Behavior.Scale1Behavior.AXIS_X && scale === this.scaleX) ||
            +724                     ( axis === CAAT.Behavior.Scale1Behavior.AXIS_Y && scale === this.scaleY)) {
            +725 
            +726                     return;
            +727                 }
            +728 
            +729                 var id = '__scaleXTo';
            +730                 var b = this.getBehavior(id);
            +731                 if (!b) {
            +732                     b = new CAAT.Behavior.Scale1Behavior().
            +733                         setId(id).
            +734                         setValues(1, 1, axis === CAAT.Behavior.Scale1Behavior.AXIS_X, .5, .5);
            +735                     this.addBehavior(b);
            +736                 }
            +737 
            +738                 b.setValues(
            +739                     axis ? this.scaleX : this.scaleY,
            +740                     scale,
            +741                     anchorX,
            +742                     anchorY).
            +743                     setDelayTime(delay ? delay : 0, duration);
            +744 
            +745                 if (interpolator) {
            +746                     b.setInterpolator(interpolator);
            +747                 }
            +748 
            +749                 return this;
            +750             },
            +751 
            +752             /**
            +753              * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
            +754              * @param e <CAAT.TouchEvent>
            +755              */
            +756             touchStart:function (e) {
            +757             },
            +758             touchMove:function (e) {
            +759             },
            +760             touchEnd:function (e) {
            +761             },
            +762             gestureStart:function (rotation, scaleX, scaleY) {
            +763             },
            +764             gestureChange:function (rotation, scaleX, scaleY) {
            +765                 if (this.gestureEnabled) {
            +766                     this.setRotation(rotation);
            +767                     this.setScale(scaleX, scaleY);
            +768                 }
            +769                 return this;
            +770             },
            +771             gestureEnd:function (rotation, scaleX, scaleY) {
            +772             },
            +773 
            +774             isVisible:function () {
            +775                 return this.visible;
            +776             },
            +777 
            +778             invalidate:function () {
            +779                 this.invalid = true;
            +780                 return this;
            +781             },
            +782             setGestureEnabled:function (enable) {
            +783                 this.gestureEnabled = !!enable;
            +784                 return this;
            +785             },
            +786             isGestureEnabled:function () {
            +787                 return this.gestureEnabled;
            +788             },
            +789             getId:function () {
            +790                 return this.id;
            +791             },
            +792             setId:function (id) {
            +793                 this.id = id;
            +794                 return this;
            +795             },
            +796             /**
            +797              * Set this actor's parent.
            +798              * @param parent {CAAT.Foundation.ActorContainer}
            +799              * @return this
            +800              */
            +801             setParent:function (parent) {
            +802                 this.parent = parent;
            +803                 return this;
            +804             },
            +805             /**
            +806              * Set this actor's background image.
            +807              * The need of a background image is to kept compatibility with the new CSSDirector class.
            +808              * The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image
            +809              * is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column.
            +810              * If the actor has set an image in the background, the paint method will draw the image, otherwise
            +811              * and if set, will fill its background with a solid color.
            +812              * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one
            +813              * single image from the SpriteImage (either supplied or generated because of passing an Image or
            +814              * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth,
            +815              * height:singleHeight].
            +816              *
            +817              * WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance.
            +818              *
            +819              * @see CAAT.Foundation.SpriteImage
            +820              *
            +821              * @param image {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage}
            +822              * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter.
            +823              *
            +824              * @return this
            +825              */
            +826             setBackgroundImage:function (image, adjust_size_to_image) {
            +827                 if (image) {
            +828                     if (!(image instanceof CAAT.Foundation.SpriteImage)) {
            +829                         if ( isString(image) ) {
            +830                             image = new CAAT.Foundation.SpriteImage().initialize(CAAT.currentDirector.getImage(image), 1, 1);
            +831                         } else {
            +832                             image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1);
            +833                         }
            +834                     } else {
            +835                         image= image.getRef();
            +836                     }
            +837 
            +838                     image.setOwner(this);
            +839                     this.backgroundImage = image;
            +840                     if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) {
            +841                         this.width = image.getWidth();
            +842                         this.height = image.getHeight();
            +843                     }
            +844 
            +845                     this.glEnabled = true;
            +846 
            +847                     this.invalidate();
            +848 
            +849                 } else {
            +850                     this.backgroundImage = null;
            +851                 }
            +852 
            +853                 return this;
            +854             },
            +855             /**
            +856              * Set the actor's SpriteImage index from animation sheet.
            +857              * @see CAAT.Foundation.SpriteImage
            +858              * @param index {number}
            +859              *
            +860              * @return this
            +861              */
            +862             setSpriteIndex:function (index) {
            +863                 if (this.backgroundImage) {
            +864                     this.backgroundImage.setSpriteIndex(index);
            +865                     this.invalidate();
            +866                 }
            +867 
            +868                 return this;
            +869 
            +870             },
            +871             /**
            +872              * Set this actor's background SpriteImage offset displacement.
            +873              * The values can be either positive or negative meaning the texture space of this background
            +874              * image does not start at (0,0) but at the desired position.
            +875              * @see CAAT.Foundation.SpriteImage
            +876              * @param ox {number} horizontal offset
            +877              * @param oy {number} vertical offset
            +878              *
            +879              * @return this
            +880              */
            +881             setBackgroundImageOffset:function (ox, oy) {
            +882                 if (this.backgroundImage) {
            +883                     this.backgroundImage.setOffset(ox, oy);
            +884                 }
            +885 
            +886                 return this;
            +887             },
            +888             /**
            +889              * Set this actor's background SpriteImage its animation sequence.
            +890              * In its simplet's form a SpriteImage treats a given image as an array of rows by columns
            +891              * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages.
            +892              * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the
            +893              * animation sequence
            +894              * @param ii {Array<number>} an array of integers.
            +895              */
            +896             setAnimationImageIndex:function (ii) {
            +897                 if (this.backgroundImage) {
            +898                     this.backgroundImage.resetAnimationTime();
            +899                     this.backgroundImage.setAnimationImageIndex(ii);
            +900                     this.invalidate();
            +901                 }
            +902                 return this;
            +903             },
            +904 
            +905             addAnimation : function( name, array, time, callback ) {
            +906                 if (this.backgroundImage) {
            +907                     this.backgroundImage.addAnimation(name, array, time, callback);
            +908                 }
            +909                 return this;
            +910             },
            +911 
            +912             playAnimation : function(name) {
            +913                 if (this.backgroundImage) {
            +914                     this.backgroundImage.playAnimation(name);
            +915                 }
            +916                 return this;
            +917             },
            +918 
            +919             setAnimationEndCallback : function(f) {
            +920                 if (this.backgroundImage) {
            +921                     this.backgroundImage.setAnimationEndCallback(f);
            +922                 }
            +923                 return this;
            +924             },
            +925 
            +926             resetAnimationTime:function () {
            +927                 if (this.backgroundImage) {
            +928                     this.backgroundImage.resetAnimationTime();
            +929                     this.invalidate();
            +930                 }
            +931                 return this;
            +932             },
            +933 
            +934             setChangeFPS:function (time) {
            +935                 if (this.backgroundImage) {
            +936                     this.backgroundImage.setChangeFPS(time);
            +937                 }
            +938                 return this;
            +939 
            +940             },
            +941             /**
            +942              * Set this background image transformation.
            +943              * If GL is enabled, this parameter has no effect.
            +944              * @param it any value from CAAT.Foundation.SpriteImage.TR_*
            +945              * @return this
            +946              */
            +947             setImageTransformation:function (it) {
            +948                 if (this.backgroundImage) {
            +949                     this.backgroundImage.setSpriteTransformation(it);
            +950                 }
            +951                 return this;
            +952             },
            +953             /**
            +954              * Center this actor at position (x,y).
            +955              * @param x {number} x position
            +956              * @param y {number} y position
            +957              *
            +958              * @return this
            +959              * @deprecated
            +960              */
            +961             centerOn:function (x, y) {
            +962                 this.setPosition(x - this.width / 2, y - this.height / 2);
            +963                 return this;
            +964             },
            +965             /**
            +966              * Center this actor at position (x,y).
            +967              * @param x {number} x position
            +968              * @param y {number} y position
            +969              *
            +970              * @return this
            +971              */
            +972             centerAt:function (x, y) {
            +973                 this.setPosition(
            +974                     x - this.width * (.5 - this.tAnchorX ),
            +975                     y - this.height * (.5 - this.tAnchorY ) );
            +976                 return this;
            +977             },
            +978             /**
            +979              * If GL is enables, get this background image's texture page, otherwise it will fail.
            +980              * @return {CAAT.GLTexturePage}
            +981              */
            +982             getTextureGLPage:function () {
            +983                 return this.backgroundImage.image.__texturePage;
            +984             },
            +985             /**
            +986              * Set this actor invisible.
            +987              * The actor is animated but not visible.
            +988              * A container won't show any of its children if set visible to false.
            +989              *
            +990              * @param visible {boolean} set this actor visible or not.
            +991              * @return this
            +992              */
            +993             setVisible:function (visible) {
            +994                 this.invalidate();
            +995                 // si estoy visible y quiero hacerme no visible
            +996                 if (CAAT.currentDirector && CAAT.currentDirector.dirtyRectsEnabled && !visible && this.visible) {
            +997                     // if dirty rects, add this actor
            +998                     CAAT.currentDirector.scheduleDirtyRect(this.AABB);
            +999                 }
            +1000 
            +1001                 if ( visible && !this.visible) {
            +1002                     this.dirty= true;
            +1003                 }
            +1004 
            +1005                 this.visible = visible;
            +1006                 return this;
            +1007             },
            +1008             /**
            +1009              * Puts an Actor out of time line, that is, won't be transformed nor rendered.
            +1010              * @return this
            +1011              */
            +1012             setOutOfFrameTime:function () {
            +1013                 this.setFrameTime(-1, 0);
            +1014                 return this;
            +1015             },
            +1016             /**
            +1017              * Adds an Actor's life cycle listener.
            +1018              * The developer must ensure the actorListener is not already a listener, otherwise
            +1019              * it will notified more than once.
            +1020              * @param actorListener {object} an object with at least a method of the form:
            +1021              * <code>actorLyfeCycleEvent( actor, string_event_type, long_time )</code>
            +1022              */
            +1023             addListener:function (actorListener) {
            +1024                 this.lifecycleListenerList.push(actorListener);
            +1025                 return this;
            +1026             },
            +1027             /**
            +1028              * Removes an Actor's life cycle listener.
            +1029              * It will only remove the first occurrence of the given actorListener.
            +1030              * @param actorListener {object} an Actor's life cycle listener.
            +1031              */
            +1032             removeListener:function (actorListener) {
            +1033                 var n = this.lifecycleListenerList.length;
            +1034                 while (n--) {
            +1035                     if (this.lifecycleListenerList[n] === actorListener) {
            +1036                         // remove the nth element.
            +1037                         this.lifecycleListenerList.splice(n, 1);
            +1038                         return;
            +1039                     }
            +1040                 }
            +1041             },
            +1042             /**
            +1043              * Set alpha composition scope. global will mean this alpha value will be its children maximum.
            +1044              * If set to false, only this actor will have this alpha value.
            +1045              * @param global {boolean} whether the alpha value should be propagated to children.
            +1046              */
            +1047             setGlobalAlpha:function (global) {
            +1048                 this.isGlobalAlpha = global;
            +1049                 return this;
            +1050             },
            +1051             /**
            +1052              * Notifies the registered Actor's life cycle listener about some event.
            +1053              * @param sEventType an string indicating the type of event being notified.
            +1054              * @param time an integer indicating the time related to Scene's timeline when the event
            +1055              * is being notified.
            +1056              */
            +1057             fireEvent:function (sEventType, time) {
            +1058                 for (var i = 0; i < this.lifecycleListenerList.length; i++) {
            +1059                     this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time);
            +1060                 }
            +1061             },
            +1062             /**
            +1063              * Sets this Actor as Expired.
            +1064              * If this is a Container, all the contained Actors won't be nor drawn nor will receive
            +1065              * any event. That is, expiring an Actor means totally taking it out the Scene's timeline.
            +1066              * @param time {number} an integer indicating the time the Actor was expired at.
            +1067              * @return this.
            +1068              */
            +1069             setExpired:function (time) {
            +1070                 this.expired = true;
            +1071                 this.fireEvent('expired', time);
            +1072                 return this;
            +1073             },
            +1074             /**
            +1075              * Enable or disable the event bubbling for this Actor.
            +1076              * @param enable {boolean} a boolean indicating whether the event bubbling is enabled.
            +1077              * @return this
            +1078              */
            +1079             enableEvents:function (enable) {
            +1080                 this.mouseEnabled = enable;
            +1081                 return this;
            +1082             },
            +1083             /**
            +1084              * Removes all behaviors from an Actor.
            +1085              * @return this
            +1086              */
            +1087             emptyBehaviorList:function () {
            +1088                 this.behaviorList = [];
            +1089                 return this;
            +1090             },
            +1091             /**
            +1092              * Caches a fillStyle in the Actor.
            +1093              * @param style a valid Canvas rendering context fillStyle.
            +1094              * @return this
            +1095              */
            +1096             setFillStyle:function (style) {
            +1097                 this.fillStyle = style;
            +1098                 this.invalidate();
            +1099                 return this;
            +1100             },
            +1101             /**
            +1102              * Caches a stroke style in the Actor.
            +1103              * @param style a valid canvas rendering context stroke style.
            +1104              * @return this
            +1105              */
            +1106             setStrokeStyle:function (style) {
            +1107                 this.strokeStyle = style;
            +1108                 this.invalidate();
            +1109                 return this;
            +1110             },
            +1111             /**
            +1112              * @deprecated
            +1113              * @param paint
            +1114              */
            +1115             setPaint:function (paint) {
            +1116                 return this.setFillStyle(paint);
            +1117             },
            +1118             /**
            +1119              * Stablishes the Alpha transparency for the Actor.
            +1120              * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors.
            +1121              * The alpha must be between 0 and 1.
            +1122              * @param alpha a float indicating the alpha value.
            +1123              * @return this
            +1124              */
            +1125             setAlpha:function (alpha) {
            +1126                 this.alpha = alpha;
            +1127                 this.invalidate();
            +1128                 return this;
            +1129             },
            +1130             /**
            +1131              * Remove all transformation values for the Actor.
            +1132              * @return this
            +1133              */
            +1134             resetTransform:function () {
            +1135                 this.rotationAngle = 0;
            +1136                 this.rotationX = .5;
            +1137                 this.rotationY = .5;
            +1138                 this.scaleX = 1;
            +1139                 this.scaleY = 1;
            +1140                 this.scaleTX = .5;
            +1141                 this.scaleTY = .5;
            +1142                 this.scaleAnchor = 0;
            +1143                 this.oldX = -1;
            +1144                 this.oldY = -1;
            +1145                 this.dirty = true;
            +1146 
            +1147                 return this;
            +1148             },
            +1149             /**
            +1150              * Sets the time life cycle for an Actor.
            +1151              * These values are related to Scene time.
            +1152              * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene.
            +1153              * @param duration an integer indicating how much the Actor will last once visible.
            +1154              * @return this
            +1155              */
            +1156             setFrameTime:function (startTime, duration) {
            +1157                 this.start_time = startTime;
            +1158                 this.duration = duration;
            +1159                 this.expired = false;
            +1160                 this.dirty = true;
            +1161 
            +1162                 return this;
            +1163             },
            +1164             /**
            +1165              * This method should me overriden by every custom Actor.
            +1166              * It will be the drawing routine called by the Director to show every Actor.
            +1167              * @param director {CAAT.Foundation.Director} instance that contains the Scene the Actor is in.
            +1168              * @param time {number} indicating the Scene time in which the drawing is performed.
            +1169              */
            +1170             paint:function (director, time) {
            +1171                 if (this.backgroundImage) {
            +1172                     this.backgroundImage.paint(director, time, 0, 0);
            +1173                 } else if (this.fillStyle) {
            +1174                     var ctx = director.ctx;
            +1175                     ctx.fillStyle = this.fillStyle;
            +1176                     ctx.fillRect(0, 0, this.width, this.height);
            +1177                 }
            +1178 
            +1179             },
            +1180             /**
            +1181              * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER
            +1182              *
            +1183              * @see setScaleAnchored
            +1184              *
            +1185              * @param sx a float indicating a width size multiplier.
            +1186              * @param sy a float indicating a height size multiplier.
            +1187              * @return this
            +1188              */
            +1189             setScale:function (sx, sy) {
            +1190                 this.scaleX = sx;
            +1191                 this.scaleY = sy;
            +1192                 this.dirty = true;
            +1193                 return this;
            +1194             },
            +1195             getAnchorPercent:function (anchor) {
            +1196 
            +1197                 var anchors = [
            +1198                     .50, .50, .50, 0, .50, 1.00,
            +1199                     0, .50, 1.00, .50, 0, 0,
            +1200                     1.00, 0, 0, 1.00, 1.00, 1.00
            +1201                 ];
            +1202 
            +1203                 return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] };
            +1204             },
            +1205             /**
            +1206              * Private.
            +1207              * Gets a given anchor position referred to the Actor.
            +1208              * @param anchor
            +1209              * @return an object of the form { x: float, y: float }
            +1210              */
            +1211             getAnchor:function (anchor) {
            +1212                 var tx = 0, ty = 0;
            +1213 
            +1214                 var A= CAAT.Foundation.Actor;
            +1215 
            +1216                 switch (anchor) {
            +1217                     case A.ANCHOR_CENTER:
            +1218                         tx = .5;
            +1219                         ty = .5;
            +1220                         break;
            +1221                     case A.ANCHOR_TOP:
            +1222                         tx = .5;
            +1223                         ty = 0;
            +1224                         break;
            +1225                     case A.ANCHOR_BOTTOM:
            +1226                         tx = .5;
            +1227                         ty = 1;
            +1228                         break;
            +1229                     case A.ANCHOR_LEFT:
            +1230                         tx = 0;
            +1231                         ty = .5;
            +1232                         break;
            +1233                     case A.ANCHOR_RIGHT:
            +1234                         tx = 1;
            +1235                         ty = .5;
            +1236                         break;
            +1237                     case A.ANCHOR_TOP_RIGHT:
            +1238                         tx = 1;
            +1239                         ty = 0;
            +1240                         break;
            +1241                     case A.ANCHOR_BOTTOM_LEFT:
            +1242                         tx = 0;
            +1243                         ty = 1;
            +1244                         break;
            +1245                     case A.ANCHOR_BOTTOM_RIGHT:
            +1246                         tx = 1;
            +1247                         ty = 1;
            +1248                         break;
            +1249                     case A.ANCHOR_TOP_LEFT:
            +1250                         tx = 0;
            +1251                         ty = 0;
            +1252                         break;
            +1253                 }
            +1254 
            +1255                 return {x:tx, y:ty};
            +1256             },
            +1257 
            +1258             setGlobalAnchor:function (ax, ay) {
            +1259                 this.tAnchorX = ax;
            +1260                 this.rotationX = ax;
            +1261                 this.scaleTX = ax;
            +1262 
            +1263                 this.tAnchorY = ay;
            +1264                 this.rotationY = ay;
            +1265                 this.scaleTY = ay;
            +1266 
            +1267                 this.dirty = true;
            +1268                 return this;
            +1269             },
            +1270 
            +1271             setScaleAnchor:function (sax, say) {
            +1272                 this.scaleTX = sax;
            +1273                 this.scaleTY = say;
            +1274                 this.dirty = true;
            +1275                 return this;
            +1276             },
            +1277             /**
            +1278              * Modify the dimensions on an Actor.
            +1279              * The dimension will not affect the local coordinates system in opposition
            +1280              * to setSize or setBounds.
            +1281              *
            +1282              * @param sx {number} width scale.
            +1283              * @param sy {number} height scale.
            +1284              * @param anchorx {number} x anchor to perform the Scale operation.
            +1285              * @param anchory {number} y anchor to perform the Scale operation.
            +1286              *
            +1287              * @return this;
            +1288              */
            +1289             setScaleAnchored:function (sx, sy, anchorx, anchory) {
            +1290                 this.scaleTX = anchorx;
            +1291                 this.scaleTY = anchory;
            +1292 
            +1293                 this.scaleX = sx;
            +1294                 this.scaleY = sy;
            +1295 
            +1296                 this.dirty = true;
            +1297 
            +1298                 return this;
            +1299             },
            +1300 
            +1301             setRotationAnchor:function (rax, ray) {
            +1302                 this.rotationX = ray;
            +1303                 this.rotationY = rax;
            +1304                 this.dirty = true;
            +1305                 return this;
            +1306             },
            +1307             /**
            +1308              * A helper method for setRotationAnchored. This methods stablishes the center
            +1309              * of rotation to be the center of the Actor.
            +1310              *
            +1311              * @param angle a float indicating the angle in radians to rotate the Actor.
            +1312              * @return this
            +1313              */
            +1314             setRotation:function (angle) {
            +1315                 this.rotationAngle = angle;
            +1316                 this.dirty = true;
            +1317                 return this;
            +1318             },
            +1319             /**
            +1320              * This method sets Actor rotation around a given position.
            +1321              * @param angle {number} indicating the angle in radians to rotate the Actor.
            +1322              * @param rx {number} value in the range 0..1
            +1323              * @param ry {number} value in the range 0..1
            +1324              * @return this;
            +1325              */
            +1326             setRotationAnchored:function (angle, rx, ry) {
            +1327                 this.rotationAngle = angle;
            +1328                 this.rotationX = rx;
            +1329                 this.rotationY = ry;
            +1330                 this.dirty = true;
            +1331                 return this;
            +1332             },
            +1333             /**
            +1334              * Sets an Actor's dimension
            +1335              * @param w a float indicating Actor's width.
            +1336              * @param h a float indicating Actor's height.
            +1337              * @return this
            +1338              */
            +1339             setSize:function (w, h) {
            +1340 
            +1341                 this.width = w;
            +1342                 this.height = h;
            +1343 
            +1344                 this.dirty = true;
            +1345 
            +1346                 return this;
            +1347             },
            +1348             /**
            +1349              * Set location and dimension of an Actor at once.
            +1350              *
            +1351              * @param x{number} a float indicating Actor's x position.
            +1352              * @param y{number} a float indicating Actor's y position
            +1353              * @param w{number} a float indicating Actor's width
            +1354              * @param h{number} a float indicating Actor's height
            +1355              * @return this
            +1356              */
            +1357             setBounds:function (x, y, w, h) {
            +1358 
            +1359                 this.x = x;
            +1360                 this.y = y;
            +1361                 this.width = w;
            +1362                 this.height = h;
            +1363 
            +1364                 this.dirty = true;
            +1365 
            +1366                 return this;
            +1367             },
            +1368             /**
            +1369              * This method sets the position of an Actor inside its parent.
            +1370              *
            +1371              * @param x{number} a float indicating Actor's x position
            +1372              * @param y{number} a float indicating Actor's y position
            +1373              * @return this
            +1374              *
            +1375              * @deprecated
            +1376              */
            +1377             setLocation:function (x, y) {
            +1378                 this.x = x;
            +1379                 this.y = y;
            +1380                 this.oldX = x;
            +1381                 this.oldY = y;
            +1382 
            +1383                 this.dirty = true;
            +1384 
            +1385                 return this;
            +1386             },
            +1387 
            +1388             setPosition:function (x, y) {
            +1389                 return this.setLocation(x, y);
            +1390             },
            +1391 
            +1392             setPositionAnchor:function (pax, pay) {
            +1393                 this.tAnchorX = pax;
            +1394                 this.tAnchorY = pay;
            +1395                 return this;
            +1396             },
            +1397 
            +1398             setPositionAnchored:function (x, y, pax, pay) {
            +1399                 this.setLocation(x, y);
            +1400                 this.tAnchorX = pax;
            +1401                 this.tAnchorY = pay;
            +1402                 return this;
            +1403             },
            +1404 
            +1405 
            +1406             /**
            +1407              * This method is called by the Director to know whether the actor is on Scene time.
            +1408              * In case it was necessary, this method will notify any life cycle behaviors about
            +1409              * an Actor expiration.
            +1410              * @param time {number} time indicating the Scene time.
            +1411              *
            +1412              * @private
            +1413              *
            +1414              */
            +1415             isInAnimationFrame:function (time) {
            +1416                 if (this.expired) {
            +1417                     return false;
            +1418                 }
            +1419 
            +1420                 if (this.duration === Number.MAX_VALUE) {
            +1421                     return this.start_time <= time;
            +1422                 }
            +1423 
            +1424                 if (time >= this.start_time + this.duration) {
            +1425                     if (!this.expired) {
            +1426                         this.setExpired(time);
            +1427                     }
            +1428 
            +1429                     return false;
            +1430                 }
            +1431 
            +1432                 return this.start_time <= time && time < this.start_time + this.duration;
            +1433             },
            +1434             /**
            +1435              * Checks whether a coordinate is inside the Actor's bounding box.
            +1436              * @param x {number} a float
            +1437              * @param y {number} a float
            +1438              *
            +1439              * @return boolean indicating whether it is inside.
            +1440              */
            +1441             contains:function (x, y) {
            +1442                 return x >= 0 && y >= 0 && x < this.width && y < this.height;
            +1443             },
            +1444 
            +1445             /**
            +1446              * Add a Behavior to the Actor.
            +1447              * An Actor accepts an undefined number of Behaviors.
            +1448              *
            +1449              * @param behavior {CAAT.Behavior.BaseBehavior}
            +1450              * @return this
            +1451              */
            +1452             addBehavior:function (behavior) {
            +1453                 this.behaviorList.push(behavior);
            +1454                 return this;
            +1455             },
            +1456 
            +1457             /**
            +1458              * Remove a Behavior from the Actor.
            +1459              * If the Behavior is not present at the actor behavior collection nothing happends.
            +1460              *
            +1461              * @param behavior {CAAT.Behavior.BaseBehavior}
            +1462              */
            +1463             removeBehaviour:function (behavior) {
            +1464                 var c = this.behaviorList;
            +1465                 var n = c.length - 1;
            +1466                 while (n) {
            +1467                     if (c[n] === behavior) {
            +1468                         c.splice(n, 1);
            +1469                         return this;
            +1470                     }
            +1471                 }
            +1472                 return this;
            +1473             },
            +1474             /**
            +1475              * Remove a Behavior with id param as behavior identifier from this actor.
            +1476              * This function will remove ALL behavior instances with the given id.
            +1477              *
            +1478              * @param id {number} an integer.
            +1479              * return this;
            +1480              */
            +1481             removeBehaviorById:function (id) {
            +1482                 var c = this.behaviorList;
            +1483                 for (var n = 0; n < c.length; n++) {
            +1484                     if (c[n].id === id) {
            +1485                         c.splice(n, 1);
            +1486                     }
            +1487                 }
            +1488 
            +1489                 return this;
            +1490 
            +1491             },
            +1492             getBehavior:function (id) {
            +1493                 var c = this.behaviorList;
            +1494                 for (var n = 0; n < c.length; n++) {
            +1495                     var cc = c[n];
            +1496                     if (cc.id === id) {
            +1497                         return cc;
            +1498                     }
            +1499                 }
            +1500                 return null;
            +1501             },
            +1502             /**
            +1503              * Set discardable property. If an actor is discardable, upon expiration will be removed from
            +1504              * scene graph and hence deleted.
            +1505              * @param discardable {boolean} a boolean indicating whether the Actor is discardable.
            +1506              * @return this
            +1507              */
            +1508             setDiscardable:function (discardable) {
            +1509                 this.discardable = discardable;
            +1510                 return this;
            +1511             },
            +1512             /**
            +1513              * This method will be called internally by CAAT when an Actor is expired, and at the
            +1514              * same time, is flagged as discardable.
            +1515              * It notifies the Actor life cycle listeners about the destruction event.
            +1516              *
            +1517              * @param time an integer indicating the time at wich the Actor has been destroyed.
            +1518              *
            +1519              * @private
            +1520              *
            +1521              */
            +1522             destroy:function (time) {
            +1523                 if (this.parent) {
            +1524                     this.parent.removeChild(this);
            +1525                 }
            +1526 
            +1527                 this.fireEvent('destroyed', time);
            +1528                 if ( !this.isCachedActor ) {
            +1529                     this.clean();
            +1530                 }
            +1531 
            +1532             },
            +1533 
            +1534             clean : function() {
            +1535                 this.backgroundImage= null;
            +1536                 this.emptyBehaviorList();
            +1537                 this.lifecycleListenerList= [];
            +1538             },
            +1539 
            +1540             /**
            +1541              * Transform a point or array of points in model space to view space.
            +1542              *
            +1543              * @param point {CAAT.Math.Point|Array} an object of the form {x : float, y: float}
            +1544              *
            +1545              * @return the source transformed elements.
            +1546              *
            +1547              * @private
            +1548              *
            +1549              */
            +1550             modelToView:function (point) {
            +1551                 var x, y, pt, tm;
            +1552 
            +1553                 if (this.dirty) {
            +1554                     this.setModelViewMatrix();
            +1555                 }
            +1556 
            +1557                 tm = this.worldModelViewMatrix.matrix;
            +1558 
            +1559                 if (point instanceof Array) {
            +1560                     for (var i = 0; i < point.length; i++) {
            +1561                         //this.worldModelViewMatrix.transformCoord(point[i]);
            +1562                         pt = point[i];
            +1563                         x = pt.x;
            +1564                         y = pt.y;
            +1565                         pt.x = x * tm[0] + y * tm[1] + tm[2];
            +1566                         pt.y = x * tm[3] + y * tm[4] + tm[5];
            +1567                     }
            +1568                 }
            +1569                 else {
            +1570 //                this.worldModelViewMatrix.transformCoord(point);
            +1571                     x = point.x;
            +1572                     y = point.y;
            +1573                     point.x = x * tm[0] + y * tm[1] + tm[2];
            +1574                     point.y = x * tm[3] + y * tm[4] + tm[5];
            +1575                 }
            +1576 
            +1577                 return point;
            +1578             },
            +1579             /**
            +1580              * Transform a local coordinate point on this Actor's coordinate system into
            +1581              * another point in otherActor's coordinate system.
            +1582              * @param point {CAAT.Math.Point}
            +1583              * @param otherActor {CAAT.Math.Actor}
            +1584              */
            +1585             modelToModel:function (point, otherActor) {
            +1586                 if (this.dirty) {
            +1587                     this.setModelViewMatrix();
            +1588                 }
            +1589 
            +1590                 return otherActor.viewToModel(this.modelToView(point));
            +1591             },
            +1592             /**
            +1593              * Transform a point from model to view space.
            +1594              * <p>
            +1595              * WARNING: every call to this method calculates
            +1596              * actor's world model view matrix.
            +1597              *
            +1598              * @param point {CAAT.Math.Point} a point in screen space to be transformed to model space.
            +1599              *
            +1600              * @return the source point object
            +1601              *
            +1602              *
            +1603              */
            +1604             viewToModel:function (point) {
            +1605                 if (this.dirty) {
            +1606                     this.setModelViewMatrix();
            +1607                 }
            +1608                 this.worldModelViewMatrixI = this.worldModelViewMatrix.getInverse();
            +1609                 this.worldModelViewMatrixI.transformCoord(point);
            +1610                 return point;
            +1611             },
            +1612             /**
            +1613              * Private
            +1614              * This method does the needed point transformations across an Actor hierarchy to devise
            +1615              * whether the parameter point coordinate lies inside the Actor.
            +1616              * @param point {CAAT.Math.Point}
            +1617              *
            +1618              * @return null if the point is not inside the Actor. The Actor otherwise.
            +1619              */
            +1620             findActorAtPosition:function (point) {
            +1621                 if (this.scaleX===0 || this.scaleY===0) {
            +1622                     return null;
            +1623                 }
            +1624                 if (!this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time)) {
            +1625                     return null;
            +1626                 }
            +1627 
            +1628                 this.modelViewMatrixI = this.modelViewMatrix.getInverse();
            +1629                 this.modelViewMatrixI.transformCoord(point);
            +1630                 return this.contains(point.x, point.y) ? this : null;
            +1631             },
            +1632             /**
            +1633              * Enables a default dragging routine for the Actor.
            +1634              * This default dragging routine allows to:
            +1635              *  <li>scale the Actor by pressing shift+drag
            +1636              *  <li>rotate the Actor by pressing control+drag
            +1637              *  <li>scale non uniformly by pressing alt+shift+drag
            +1638              *
            +1639              * @return this
            +1640              */
            +1641             enableDrag:function () {
            +1642 
            +1643                 this.ax = 0;
            +1644                 this.ay = 0;
            +1645                 this.asx = 1;
            +1646                 this.asy = 1;
            +1647                 this.ara = 0;
            +1648                 this.screenx = 0;
            +1649                 this.screeny = 0;
            +1650 
            +1651                 /**
            +1652                  * Mouse enter handler for default drag behavior.
            +1653                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +1654                  *
            +1655                  * @ignore
            +1656                  */
            +1657                 this.mouseEnter = function (mouseEvent) {
            +1658                     this.__d_ax = -1;
            +1659                     this.__d_ay = -1;
            +1660                     this.pointed = true;
            +1661                     CAAT.setCursor('move');
            +1662                 };
            +1663 
            +1664                 /**
            +1665                  * Mouse exit handler for default drag behavior.
            +1666                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +1667                  *
            +1668                  * @ignore
            +1669                  */
            +1670                 this.mouseExit = function (mouseEvent) {
            +1671                     this.__d_ax = -1;
            +1672                     this.__d_ay = -1;
            +1673                     this.pointed = false;
            +1674                     CAAT.setCursor('default');
            +1675                 };
            +1676 
            +1677                 /**
            +1678                  * Mouse move handler for default drag behavior.
            +1679                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +1680                  *
            +1681                  * @ignore
            +1682                  */
            +1683                 this.mouseMove = function (mouseEvent) {
            +1684                 };
            +1685 
            +1686                 /**
            +1687                  * Mouse up handler for default drag behavior.
            +1688                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +1689                  *
            +1690                  * @ignore
            +1691                  */
            +1692                 this.mouseUp = function (mouseEvent) {
            +1693                     this.__d_ax = -1;
            +1694                     this.__d_ay = -1;
            +1695                 };
            +1696 
            +1697                 /**
            +1698                  * Mouse drag handler for default drag behavior.
            +1699                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +1700                  *
            +1701                  * @ignore
            +1702                  */
            +1703                 this.mouseDrag = function (mouseEvent) {
            +1704 
            +1705                     var pt;
            +1706 
            +1707                     pt = this.modelToView(new CAAT.Math.Point(mouseEvent.x, mouseEvent.y));
            +1708                     this.parent.viewToModel(pt);
            +1709 
            +1710                     if (this.__d_ax === -1 || this.__d_ay === -1) {
            +1711                         this.__d_ax = pt.x;
            +1712                         this.__d_ay = pt.y;
            +1713                         this.__d_asx = this.scaleX;
            +1714                         this.__d_asy = this.scaleY;
            +1715                         this.__d_ara = this.rotationAngle;
            +1716                         this.__d_screenx = mouseEvent.screenPoint.x;
            +1717                         this.__d_screeny = mouseEvent.screenPoint.y;
            +1718                     }
            +1719 
            +1720                     if (mouseEvent.isShiftDown()) {
            +1721                         var scx = (mouseEvent.screenPoint.x - this.__d_screenx) / 100;
            +1722                         var scy = (mouseEvent.screenPoint.y - this.__d_screeny) / 100;
            +1723                         if (!mouseEvent.isAltDown()) {
            +1724                             var sc = Math.max(scx, scy);
            +1725                             scx = sc;
            +1726                             scy = sc;
            +1727                         }
            +1728                         this.setScale(scx + this.__d_asx, scy + this.__d_asy);
            +1729 
            +1730                     } else if (mouseEvent.isControlDown()) {
            +1731                         var vx = mouseEvent.screenPoint.x - this.__d_screenx;
            +1732                         var vy = mouseEvent.screenPoint.y - this.__d_screeny;
            +1733                         this.setRotation(-Math.atan2(vx, vy) + this.__d_ara);
            +1734                     } else {
            +1735                         this.x += pt.x - this.__d_ax;
            +1736                         this.y += pt.y - this.__d_ay;
            +1737                     }
            +1738 
            +1739                     this.__d_ax = pt.x;
            +1740                     this.__d_ay = pt.y;
            +1741                 };
            +1742 
            +1743                 return this;
            +1744             },
            +1745             disableDrag:function () {
            +1746 
            +1747                 this.mouseEnter = function (mouseEvent) {
            +1748                 };
            +1749                 this.mouseExit = function (mouseEvent) {
            +1750                 };
            +1751                 this.mouseMove = function (mouseEvent) {
            +1752                 };
            +1753                 this.mouseUp = function (mouseEvent) {
            +1754                 };
            +1755                 this.mouseDrag = function (mouseEvent) {
            +1756                 };
            +1757 
            +1758                 return this;
            +1759             },
            +1760             /**
            +1761              * Default mouseClick handler.
            +1762              * Mouse click events are received after a call to mouseUp method if no dragging was in progress.
            +1763              *
            +1764              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1765              */
            +1766             mouseClick:function (mouseEvent) {
            +1767             },
            +1768             /**
            +1769              * Default double click handler
            +1770              *
            +1771              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1772              */
            +1773             mouseDblClick:function (mouseEvent) {
            +1774             },
            +1775             /**
            +1776              * Default mouse enter on Actor handler.
            +1777              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1778              */
            +1779             mouseEnter:function (mouseEvent) {
            +1780                 this.pointed = true;
            +1781             },
            +1782             /**
            +1783              * Default mouse exit on Actor handler.
            +1784              *
            +1785              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1786              */
            +1787             mouseExit:function (mouseEvent) {
            +1788                 this.pointed = false;
            +1789             },
            +1790             /**
            +1791              * Default mouse move inside Actor handler.
            +1792              *
            +1793              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1794              */
            +1795             mouseMove:function (mouseEvent) {
            +1796             },
            +1797             /**
            +1798              * default mouse press in Actor handler.
            +1799              *
            +1800              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1801              */
            +1802             mouseDown:function (mouseEvent) {
            +1803             },
            +1804             /**
            +1805              * default mouse release in Actor handler.
            +1806              *
            +1807              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1808              */
            +1809             mouseUp:function (mouseEvent) {
            +1810             },
            +1811             mouseOut:function (mouseEvent) {
            +1812             },
            +1813             mouseOver:function (mouseEvent) {
            +1814             },
            +1815             /**
            +1816              * default Actor mouse drag handler.
            +1817              *
            +1818              * @param mouseEvent {CAAT.Event.MouseEvent}
            +1819              */
            +1820             mouseDrag:function (mouseEvent) {
            +1821             },
            +1822             /**
            +1823              * Draw a bounding box with on-screen coordinates regardless of the transformations
            +1824              * applied to the Actor.
            +1825              *
            +1826              * @param director {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in.
            +1827              * @param time {number} integer indicating the Scene time when the bounding box is to be drawn.
            +1828              */
            +1829             drawScreenBoundingBox:function (director, time) {
            +1830                 if (null !== this.AABB && this.inFrame) {
            +1831                     var s = this.AABB;
            +1832                     var ctx = director.ctx;
            +1833                     ctx.strokeStyle = CAAT.DEBUGAABBCOLOR;
            +1834                     ctx.strokeRect(.5 + (s.x | 0), .5 + (s.y | 0), s.width | 0, s.height | 0);
            +1835                     if (CAAT.DEBUGBB) {
            +1836                         var vv = this.viewVertices;
            +1837                         ctx.beginPath();
            +1838                         ctx.lineTo(vv[0].x, vv[0].y);
            +1839                         ctx.lineTo(vv[1].x, vv[1].y);
            +1840                         ctx.lineTo(vv[2].x, vv[2].y);
            +1841                         ctx.lineTo(vv[3].x, vv[3].y);
            +1842                         ctx.closePath();
            +1843                         ctx.strokeStyle = CAAT.DEBUGBBCOLOR;
            +1844                         ctx.stroke();
            +1845                     }
            +1846                 }
            +1847             },
            +1848             /**
            +1849              * Private
            +1850              * This method is called by the Director instance.
            +1851              * It applies the list of behaviors the Actor has registered.
            +1852              *
            +1853              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +1854              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +1855              */
            +1856             animate:function (director, time) {
            +1857 
            +1858                 if (!this.visible) {
            +1859                     return false;
            +1860                 }
            +1861 
            +1862                 var i;
            +1863 
            +1864                 if (!this.isInAnimationFrame(time)) {
            +1865                     this.inFrame = false;
            +1866                     this.dirty = true;
            +1867                     return false;
            +1868                 }
            +1869 
            +1870                 if (this.x !== this.oldX || this.y !== this.oldY) {
            +1871                     this.dirty = true;
            +1872                     this.oldX = this.x;
            +1873                     this.oldY = this.y;
            +1874                 }
            +1875 
            +1876                 for (i = 0; i < this.behaviorList.length; i++) {
            +1877                     this.behaviorList[i].apply(time, this);
            +1878                 }
            +1879 
            +1880                 if (this.clipPath) {
            +1881                     this.clipPath.applyBehaviors(time);
            +1882                 }
            +1883 
            +1884                 // transformation stuff.
            +1885                 this.setModelViewMatrix();
            +1886 
            +1887                 if (this.dirty || this.wdirty || this.invalid) {
            +1888                     if (director.dirtyRectsEnabled) {
            +1889                         director.addDirtyRect(this.AABB);
            +1890                     }
            +1891                     this.setScreenBounds();
            +1892                     if (director.dirtyRectsEnabled) {
            +1893                         director.addDirtyRect(this.AABB);
            +1894                     }
            +1895                 }
            +1896                 this.dirty = false;
            +1897                 this.invalid = false;
            +1898 
            +1899                 this.inFrame = true;
            +1900 
            +1901                 if ( this.backgroundImage ) {
            +1902                     this.backgroundImage.setSpriteIndexAtTime(time);
            +1903                 }
            +1904 
            +1905                 return this.AABB.intersects(director.AABB);
            +1906                 //return true;
            +1907             },
            +1908             /**
            +1909              * Set this model view matrix if the actor is Dirty.
            +1910              *
            +1911              mm[2]+= this.x;
            +1912              mm[5]+= this.y;
            +1913              if ( this.rotationAngle ) {
            +1914                  this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) );
            +1915                  this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) );
            +1916                  this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) );                    c= Math.cos( this.rotationAngle );
            +1917              }
            +1918              if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) {
            +1919                  this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) );
            +1920                  this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) );
            +1921                  this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) );
            +1922              }
            +1923              *
            +1924              * @return this
            +1925              */
            +1926             setModelViewMatrix:function () {
            +1927                 var c, s, _m00, _m01, _m10, _m11;
            +1928                 var mm0, mm1, mm2, mm3, mm4, mm5;
            +1929                 var mm;
            +1930 
            +1931                 this.wdirty = false;
            +1932                 mm = this.modelViewMatrix.matrix;
            +1933 
            +1934                 if (this.dirty) {
            +1935 
            +1936                     mm0 = 1;
            +1937                     mm1 = 0;
            +1938                     //mm2= mm[2];
            +1939                     mm3 = 0;
            +1940                     mm4 = 1;
            +1941                     //mm5= mm[5];
            +1942 
            +1943                     mm2 = this.x - this.tAnchorX * this.width;
            +1944                     mm5 = this.y - this.tAnchorY * this.height;
            +1945 
            +1946                     if (this.rotationAngle) {
            +1947 
            +1948                         var rx = this.rotationX * this.width;
            +1949                         var ry = this.rotationY * this.height;
            +1950 
            +1951                         mm2 += mm0 * rx + mm1 * ry;
            +1952                         mm5 += mm3 * rx + mm4 * ry;
            +1953 
            +1954                         c = Math.cos(this.rotationAngle);
            +1955                         s = Math.sin(this.rotationAngle);
            +1956                         _m00 = mm0;
            +1957                         _m01 = mm1;
            +1958                         _m10 = mm3;
            +1959                         _m11 = mm4;
            +1960                         mm0 = _m00 * c + _m01 * s;
            +1961                         mm1 = -_m00 * s + _m01 * c;
            +1962                         mm3 = _m10 * c + _m11 * s;
            +1963                         mm4 = -_m10 * s + _m11 * c;
            +1964 
            +1965                         mm2 += -mm0 * rx - mm1 * ry;
            +1966                         mm5 += -mm3 * rx - mm4 * ry;
            +1967                     }
            +1968                     if (this.scaleX != 1 || this.scaleY != 1) {
            +1969 
            +1970                         var sx = this.scaleTX * this.width;
            +1971                         var sy = this.scaleTY * this.height;
            +1972 
            +1973                         mm2 += mm0 * sx + mm1 * sy;
            +1974                         mm5 += mm3 * sx + mm4 * sy;
            +1975 
            +1976                         mm0 = mm0 * this.scaleX;
            +1977                         mm1 = mm1 * this.scaleY;
            +1978                         mm3 = mm3 * this.scaleX;
            +1979                         mm4 = mm4 * this.scaleY;
            +1980 
            +1981                         mm2 += -mm0 * sx - mm1 * sy;
            +1982                         mm5 += -mm3 * sx - mm4 * sy;
            +1983                     }
            +1984 
            +1985                     mm[0] = mm0;
            +1986                     mm[1] = mm1;
            +1987                     mm[2] = mm2;
            +1988                     mm[3] = mm3;
            +1989                     mm[4] = mm4;
            +1990                     mm[5] = mm5;
            +1991                 }
            +1992 
            +1993                 if (this.parent) {
            +1994 
            +1995 
            +1996                     this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA;
            +1997 
            +1998                     if (this.dirty || this.parent.wdirty) {
            +1999                         this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix);
            +2000                         if (this.isAA) {
            +2001                             var mmm = this.worldModelViewMatrix.matrix;
            +2002                             mmm[2] += mm[2];
            +2003                             mmm[5] += mm[5];
            +2004                         } else {
            +2005                             this.worldModelViewMatrix.multiply(this.modelViewMatrix);
            +2006                         }
            +2007                         this.wdirty = true;
            +2008                     }
            +2009 
            +2010                 } else {
            +2011                     if (this.dirty) {
            +2012                         this.wdirty = true;
            +2013                     }
            +2014 
            +2015                     this.worldModelViewMatrix.identity();
            +2016                     this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1;
            +2017                 }
            +2018 
            +2019 
            +2020 //if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) {
            +2021                 // screen bounding boxes will always be calculated.
            +2022                 /*
            +2023                  if ( this.dirty || this.wdirty || this.invalid ) {
            +2024                  if ( director.dirtyRectsEnabled ) {
            +2025                  director.addDirtyRect( this.AABB );
            +2026                  }
            +2027                  this.setScreenBounds();
            +2028                  if ( director.dirtyRectsEnabled ) {
            +2029                  director.addDirtyRect( this.AABB );
            +2030                  }
            +2031                  }
            +2032                  this.dirty= false;
            +2033                  this.invalid= false;
            +2034                  */
            +2035             },
            +2036             /**
            +2037              * Calculates the 2D bounding box in canvas coordinates of the Actor.
            +2038              * This bounding box takes into account the transformations applied hierarchically for
            +2039              * each Scene Actor.
            +2040              *
            +2041              * @private
            +2042              *
            +2043              */
            +2044             setScreenBounds:function () {
            +2045 
            +2046                 var AABB = this.AABB;
            +2047                 var vv = this.viewVertices;
            +2048                 var vvv, m, x, y, w, h;
            +2049 
            +2050                 if (this.isAA) {
            +2051                     m = this.worldModelViewMatrix.matrix;
            +2052                     x = m[2];
            +2053                     y = m[5];
            +2054                     w = this.width;
            +2055                     h = this.height;
            +2056                     AABB.x = x;
            +2057                     AABB.y = y;
            +2058                     AABB.x1 = x + w;
            +2059                     AABB.y1 = y + h;
            +2060                     AABB.width = w;
            +2061                     AABB.height = h;
            +2062 
            +2063                     if (CAAT.GLRENDER) {
            +2064                         vvv = vv[0];
            +2065                         vvv.x = x;
            +2066                         vvv.y = y;
            +2067                         vvv = vv[1];
            +2068                         vvv.x = x + w;
            +2069                         vvv.y = y;
            +2070                         vvv = vv[2];
            +2071                         vvv.x = x + w;
            +2072                         vvv.y = y + h;
            +2073                         vvv = vv[3];
            +2074                         vvv.x = x;
            +2075                         vvv.y = y + h;
            +2076                     }
            +2077 
            +2078                     return this;
            +2079                 }
            +2080 
            +2081                 vvv = vv[0];
            +2082                 vvv.x = 0;
            +2083                 vvv.y = 0;
            +2084                 vvv = vv[1];
            +2085                 vvv.x = this.width;
            +2086                 vvv.y = 0;
            +2087                 vvv = vv[2];
            +2088                 vvv.x = this.width;
            +2089                 vvv.y = this.height;
            +2090                 vvv = vv[3];
            +2091                 vvv.x = 0;
            +2092                 vvv.y = this.height;
            +2093 
            +2094                 this.modelToView(this.viewVertices);
            +2095 
            +2096                 var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE;
            +2097                 var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE;
            +2098 
            +2099                 vvv = vv[0];
            +2100                 if (vvv.x < xmin) {
            +2101                     xmin = vvv.x;
            +2102                 }
            +2103                 if (vvv.x > xmax) {
            +2104                     xmax = vvv.x;
            +2105                 }
            +2106                 if (vvv.y < ymin) {
            +2107                     ymin = vvv.y;
            +2108                 }
            +2109                 if (vvv.y > ymax) {
            +2110                     ymax = vvv.y;
            +2111                 }
            +2112                 vvv = vv[1];
            +2113                 if (vvv.x < xmin) {
            +2114                     xmin = vvv.x;
            +2115                 }
            +2116                 if (vvv.x > xmax) {
            +2117                     xmax = vvv.x;
            +2118                 }
            +2119                 if (vvv.y < ymin) {
            +2120                     ymin = vvv.y;
            +2121                 }
            +2122                 if (vvv.y > ymax) {
            +2123                     ymax = vvv.y;
            +2124                 }
            +2125                 vvv = vv[2];
            +2126                 if (vvv.x < xmin) {
            +2127                     xmin = vvv.x;
            +2128                 }
            +2129                 if (vvv.x > xmax) {
            +2130                     xmax = vvv.x;
            +2131                 }
            +2132                 if (vvv.y < ymin) {
            +2133                     ymin = vvv.y;
            +2134                 }
            +2135                 if (vvv.y > ymax) {
            +2136                     ymax = vvv.y;
            +2137                 }
            +2138                 vvv = vv[3];
            +2139                 if (vvv.x < xmin) {
            +2140                     xmin = vvv.x;
            +2141                 }
            +2142                 if (vvv.x > xmax) {
            +2143                     xmax = vvv.x;
            +2144                 }
            +2145                 if (vvv.y < ymin) {
            +2146                     ymin = vvv.y;
            +2147                 }
            +2148                 if (vvv.y > ymax) {
            +2149                     ymax = vvv.y;
            +2150                 }
            +2151 
            +2152                 AABB.x = xmin;
            +2153                 AABB.y = ymin;
            +2154                 AABB.x1 = xmax;
            +2155                 AABB.y1 = ymax;
            +2156                 AABB.width = (xmax - xmin);
            +2157                 AABB.height = (ymax - ymin);
            +2158 
            +2159                 return this;
            +2160             },
            +2161             /**
            +2162              * @private.
            +2163              * This method will be called by the Director to set the whole Actor pre-render process.
            +2164              *
            +2165              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +2166              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +2167              *
            +2168              * @return boolean indicating whether the Actor isInFrameTime
            +2169              */
            +2170             paintActor:function (director, time) {
            +2171 
            +2172                 if (!this.visible || !director.inDirtyRect(this)) {
            +2173                     return true;
            +2174                 }
            +2175 
            +2176                 var ctx = director.ctx;
            +2177 
            +2178                 this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1;
            +2179                 ctx.globalAlpha = this.frameAlpha;
            +2180 
            +2181                 director.modelViewMatrix.transformRenderingContextSet(ctx);
            +2182                 this.worldModelViewMatrix.transformRenderingContext(ctx);
            +2183 
            +2184                 if (this.clip) {
            +2185                     ctx.beginPath();
            +2186                     if (!this.clipPath) {
            +2187                         ctx.rect(0, 0, this.width, this.height);
            +2188                     } else {
            +2189                         this.clipPath.applyAsPath(director);
            +2190                     }
            +2191                     ctx.clip();
            +2192                 }
            +2193 
            +2194                 this.paint(director, time);
            +2195 
            +2196                 return true;
            +2197             },
            +2198             /**
            +2199              * for js2native
            +2200              * @param director
            +2201              * @param time
            +2202              */
            +2203             __paintActor:function (director, time) {
            +2204                 if (!this.visible) {
            +2205                     return true;
            +2206                 }
            +2207                 var ctx = director.ctx;
            +2208 
            +2209                 // global opt: set alpha as owns alpha, not take globalAlpha procedure.
            +2210                 this.frameAlpha = this.alpha;
            +2211 
            +2212                 var m = this.worldModelViewMatrix.matrix;
            +2213                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha);
            +2214                 this.paint(director, time);
            +2215                 return true;
            +2216             },
            +2217 
            +2218             /**
            +2219              * Set coordinates and uv values for this actor.
            +2220              * This function uses Director's coords and indexCoords values.
            +2221              * @param director
            +2222              * @param time
            +2223              */
            +2224             paintActorGL:function (director, time) {
            +2225 
            +2226                 this.frameAlpha = this.parent.frameAlpha * this.alpha;
            +2227 
            +2228                 if (!this.glEnabled || !this.visible) {
            +2229                     return;
            +2230                 }
            +2231 
            +2232                 if (this.glNeedsFlush(director)) {
            +2233                     director.glFlush();
            +2234                     this.glSetShader(director);
            +2235 
            +2236                     if (!this.__uv) {
            +2237                         this.__uv = new Float32Array(8);
            +2238                     }
            +2239                     if (!this.__vv) {
            +2240                         this.__vv = new Float32Array(12);
            +2241                     }
            +2242 
            +2243                     this.setGLCoords(this.__vv, 0);
            +2244                     this.setUV(this.__uv, 0);
            +2245                     director.glRender(this.__vv, 12, this.__uv);
            +2246 
            +2247                     return;
            +2248                 }
            +2249 
            +2250                 var glCoords = director.coords;
            +2251                 var glCoordsIndex = director.coordsIndex;
            +2252 
            +2253                 ////////////////// XYZ
            +2254                 this.setGLCoords(glCoords, glCoordsIndex);
            +2255                 director.coordsIndex = glCoordsIndex + 12;
            +2256 
            +2257                 ////////////////// UV
            +2258                 this.setUV(director.uv, director.uvIndex);
            +2259                 director.uvIndex += 8;
            +2260             },
            +2261             /**
            +2262              * TODO: set GLcoords for different image transformations.
            +2263              *
            +2264              * @param glCoords
            +2265              * @param glCoordsIndex
            +2266              */
            +2267             setGLCoords:function (glCoords, glCoordsIndex) {
            +2268 
            +2269                 var vv = this.viewVertices;
            +2270                 glCoords[glCoordsIndex++] = vv[0].x;
            +2271                 glCoords[glCoordsIndex++] = vv[0].y;
            +2272                 glCoords[glCoordsIndex++] = 0;
            +2273 
            +2274                 glCoords[glCoordsIndex++] = vv[1].x;
            +2275                 glCoords[glCoordsIndex++] = vv[1].y;
            +2276                 glCoords[glCoordsIndex++] = 0;
            +2277 
            +2278                 glCoords[glCoordsIndex++] = vv[2].x;
            +2279                 glCoords[glCoordsIndex++] = vv[2].y;
            +2280                 glCoords[glCoordsIndex++] = 0;
            +2281 
            +2282                 glCoords[glCoordsIndex++] = vv[3].x;
            +2283                 glCoords[glCoordsIndex++] = vv[3].y;
            +2284                 glCoords[glCoordsIndex  ] = 0;
            +2285 
            +2286             },
            +2287             /**
            +2288              * Set UV for this actor's quad.
            +2289              *
            +2290              * @param uvBuffer {Float32Array}
            +2291              * @param uvIndex {number}
            +2292              */
            +2293             setUV:function (uvBuffer, uvIndex) {
            +2294                 this.backgroundImage.setUV(uvBuffer, uvIndex);
            +2295             },
            +2296             /**
            +2297              * Test for compulsory gl flushing:
            +2298              *  1.- opacity has changed.
            +2299              *  2.- texture page has changed.
            +2300              *
            +2301              */
            +2302             glNeedsFlush:function (director) {
            +2303                 if (this.getTextureGLPage() !== director.currentTexturePage) {
            +2304                     return true;
            +2305                 }
            +2306                 if (this.frameAlpha !== director.currentOpacity) {
            +2307                     return true;
            +2308                 }
            +2309                 return false;
            +2310             },
            +2311             /**
            +2312              * Change texture shader program parameters.
            +2313              * @param director
            +2314              */
            +2315             glSetShader:function (director) {
            +2316 
            +2317                 var tp = this.getTextureGLPage();
            +2318                 if (tp !== director.currentTexturePage) {
            +2319                     director.setGLTexturePage(tp);
            +2320                 }
            +2321 
            +2322                 if (this.frameAlpha !== director.currentOpacity) {
            +2323                     director.setGLCurrentOpacity(this.frameAlpha);
            +2324                 }
            +2325             },
            +2326             /**
            +2327              * @private.
            +2328              * This method is called after the Director has transformed and drawn a whole frame.
            +2329              *
            +2330              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +2331              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +2332              * @return this
            +2333              *
            +2334              * @deprecated
            +2335              */
            +2336             endAnimate:function (director, time) {
            +2337                 return this;
            +2338             },
            +2339             initialize:function (overrides) {
            +2340                 if (overrides) {
            +2341                     for (var i in overrides) {
            +2342                         this[i] = overrides[i];
            +2343                     }
            +2344                 }
            +2345 
            +2346                 return this;
            +2347             },
            +2348             /**
            +2349              * Set this Actor's clipping area.
            +2350              * @param enable {boolean} enable clip area.
            +2351              * @param clipPath {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set,
            +2352              *  a rectangle will be used.
            +2353              */
            +2354             setClip:function (enable, clipPath) {
            +2355                 this.clip = enable;
            +2356                 this.clipPath = clipPath;
            +2357                 return this;
            +2358             },
            +2359 
            +2360             isCached : function() {
            +2361                 return this.cached;
            +2362             },
            +2363 
            +2364             stopCacheAsBitmap:function () {
            +2365                 if (this.cached) {
            +2366                     this.backgroundImage = null;
            +2367                     this.cached = CAAT.Foundation.Actor.CACHE_NONE;
            +2368                 }
            +2369             },
            +2370 
            +2371             /**
            +2372              *
            +2373              * @param time {Number=}
            +2374              * @param stragegy {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP}
            +2375              * @return this
            +2376              */
            +2377             cacheAsBitmap:function (time, strategy) {
            +2378 
            +2379                 if (this.width<=0 || this.height<=0 ) {
            +2380                     return this;
            +2381                 }
            +2382 
            +2383                 time = time || 0;
            +2384                 var canvas = document.createElement('canvas');
            +2385                 canvas.width = this.width;
            +2386                 canvas.height = this.height;
            +2387                 var ctx = canvas.getContext('2d');
            +2388 
            +2389                 CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,time);
            +2390 
            +2391                 var director = {
            +2392                     ctx:ctx,
            +2393                     modelViewMatrix: new CAAT.Math.Matrix(),
            +2394                     worldModelViewMatrix: new CAAT.Math.Matrix(),
            +2395                     dirtyRectsEnabled:false,
            +2396                     inDirtyRect:function () {
            +2397                         return true;
            +2398                     },
            +2399                     AABB : new CAAT.Math.Rectangle(0,0,this.width,this.height)
            +2400                 };
            +2401 
            +2402                 var pmv = this.modelViewMatrix;
            +2403                 var pwmv = this.worldModelViewMatrix;
            +2404 
            +2405                 this.modelViewMatrix = new CAAT.Math.Matrix();
            +2406                 this.worldModelViewMatrix = new CAAT.Math.Matrix();
            +2407 
            +2408                 this.cached = CAAT.Foundation.Actor.CACHE_NONE;
            +2409 
            +2410                 if ( typeof strategy==="undefined" ) {
            +2411                     strategy= CAAT.Foundation.Actor.CACHE_SIMPLE;
            +2412                 }
            +2413                 if ( strategy===CAAT.Foundation.Actor.CACHE_DEEP ) {
            +2414                     this.animate(director, time );
            +2415                     this.paintActor(director, time);
            +2416                 } else {
            +2417                     if ( this instanceof CAAT.Foundation.ActorContainer || this instanceof CAAT.ActorContainer ) {
            +2418                         CAAT.Foundation.ActorContainer.superclass.paintActor.call(this, director, time);
            +2419                     } else {
            +2420                         this.animate(director, time );
            +2421                         this.paintActor(director, time);
            +2422                     }
            +2423                 }
            +2424                 this.setBackgroundImage(canvas);
            +2425 
            +2426                 this.cached = strategy;
            +2427 
            +2428                 this.modelViewMatrix = pmv;
            +2429                 this.worldModelViewMatrix = pwmv;
            +2430 
            +2431                 return this;
            +2432             },
            +2433             resetAsButton : function() {
            +2434                 this.actionPerformed= null;
            +2435                 this.mouseEnter=    function() {};
            +2436                 this.mouseExit=     function() {};
            +2437                 this.mouseDown=     function() {};
            +2438                 this.mouseUp=       function() {};
            +2439                 this.mouseClick=    function() {};
            +2440                 this.mouseDrag=     function() {};
            +2441                 return this;
            +2442             },
            +2443             /**
            +2444              * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's
            +2445              * single size.
            +2446              *
            +2447              * @param buttonImage {CAAT.Foundation.SpriteImage} sprite image with button's state images.
            +2448              * @param iNormal {number} button's normal state image index
            +2449              * @param iOver {number} button's mouse over state image index
            +2450              * @param iPress {number} button's pressed state image index
            +2451              * @param iDisabled {number} button's disabled state image index
            +2452              * @param fn {function(button{CAAT.Foundation.Actor})} callback function
            +2453              */
            +2454             setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) {
            +2455 
            +2456                 var me = this;
            +2457 
            +2458                 this.setBackgroundImage(buttonImage, true);
            +2459 
            +2460                 this.iNormal = iNormal || 0;
            +2461                 this.iOver = iOver || this.iNormal;
            +2462                 this.iPress = iPress || this.iNormal;
            +2463                 this.iDisabled = iDisabled || this.iNormal;
            +2464                 this.fnOnClick = fn;
            +2465                 this.enabled = true;
            +2466 
            +2467                 this.setSpriteIndex(iNormal);
            +2468 
            +2469                 /**
            +2470                  * Enable or disable the button.
            +2471                  * @param enabled {boolean}
            +2472                  * @ignore
            +2473                  */
            +2474                 this.setEnabled = function (enabled) {
            +2475                     this.enabled = enabled;
            +2476                     this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled);
            +2477                     return this;
            +2478                 };
            +2479 
            +2480                 /**
            +2481                  * This method will be called by CAAT *before* the mouseUp event is fired.
            +2482                  * @param event {CAAT.Event.MouseEvent}
            +2483                  * @ignore
            +2484                  */
            +2485                 this.actionPerformed = function (event) {
            +2486                     if (this.enabled && this.fnOnClick) {
            +2487                         this.fnOnClick(this);
            +2488                     }
            +2489                 };
            +2490 
            +2491                 /**
            +2492                  * Button's mouse enter handler. It makes the button provide visual feedback
            +2493                  * @param mouseEvent {CAAT.Event.MouseEvent}
            +2494                  * @ignore
            +2495                  */
            +2496                 this.mouseEnter = function (mouseEvent) {
            +2497                     if (!this.enabled) {
            +2498                         return;
            +2499                     }
            +2500 
            +2501                     if (this.dragging) {
            +2502                         this.setSpriteIndex(this.iPress);
            +2503                     } else {
            +2504                         this.setSpriteIndex(this.iOver);
            +2505                     }
            +2506                     CAAT.setCursor('pointer');
            +2507                 };
            +2508 
            +2509                 /**
            +2510                  * Button's mouse exit handler. Release visual apperance.
            +2511                  * @param mouseEvent {CAAT.MouseEvent}
            +2512                  * @ignore
            +2513                  */
            +2514                 this.mouseExit = function (mouseEvent) {
            +2515                     if (!this.enabled) {
            +2516                         return;
            +2517                     }
            +2518 
            +2519                     this.setSpriteIndex(this.iNormal);
            +2520                     CAAT.setCursor('default');
            +2521                 };
            +2522 
            +2523                 /**
            +2524                  * Button's mouse down handler.
            +2525                  * @param mouseEvent {CAAT.MouseEvent}
            +2526                  * @ignore
            +2527                  */
            +2528                 this.mouseDown = function (mouseEvent) {
            +2529                     if (!this.enabled) {
            +2530                         return;
            +2531                     }
            +2532 
            +2533                     this.setSpriteIndex(this.iPress);
            +2534                 };
            +2535 
            +2536                 /**
            +2537                  * Button's mouse up handler.
            +2538                  * @param mouseEvent {CAAT.MouseEvent}
            +2539                  * @ignore
            +2540                  */
            +2541                 this.mouseUp = function (mouseEvent) {
            +2542                     if (!this.enabled) {
            +2543                         return;
            +2544                     }
            +2545 
            +2546                     this.setSpriteIndex(this.iNormal);
            +2547                     this.dragging = false;
            +2548                 };
            +2549 
            +2550                 /**
            +2551                  * Button's mouse click handler. Do nothing by default. This event handler will be
            +2552                  * called ONLY if it has not been drag on the button.
            +2553                  * @param mouseEvent {CAAT.MouseEvent}
            +2554                  * @ignore
            +2555                  */
            +2556                 this.mouseClick = function (mouseEvent) {
            +2557                 };
            +2558 
            +2559                 /**
            +2560                  * Button's mouse drag handler.
            +2561                  * @param mouseEvent {CAAT.MouseEvent}
            +2562                  * @ignore
            +2563                  */
            +2564                 this.mouseDrag = function (mouseEvent) {
            +2565                     if (!this.enabled) {
            +2566                         return;
            +2567                     }
            +2568 
            +2569                     this.dragging = true;
            +2570                 };
            +2571 
            +2572                 this.setButtonImageIndex = function (_normal, _over, _press, _disabled) {
            +2573                     this.iNormal = _normal || 0;
            +2574                     this.iOver = _over || this.iNormal;
            +2575                     this.iPress = _press || this.iNormal;
            +2576                     this.iDisabled = _disabled || this.iNormal;
            +2577                     this.setSpriteIndex(this.iNormal);
            +2578                     return this;
            +2579                 };
            +2580 
            +2581                 return this;
            +2582             },
            +2583 
            +2584             findActorById : function(id) {
            +2585                 return this.id===id ? this : null;
            +2586             }
            +2587         }
            +2588     }
            +2589 });
            +2590 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_ActorContainer.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_ActorContainer.js.html new file mode 100644 index 0000000..a315e51 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_ActorContainer.js.html @@ -0,0 +1,722 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name ActorContainer
            +  5      * @memberOf CAAT.Foundation
            +  6      * @extends CAAT.Foundation.Actor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     /**
            + 11      * @name ADDHINT
            + 12      * @memberOf CAAT.Foundation.ActorContainer
            + 13      * @namespace
            + 14      */
            + 15 
            + 16     /**
            + 17      * @name AddHint
            + 18      * @memberOf CAAT.Foundation.ActorContainer
            + 19      * @namespace
            + 20      * @deprecated
            + 21      */
            + 22 
            + 23     defines:"CAAT.Foundation.ActorContainer",
            + 24     aliases:["CAAT.ActorContainer"],
            + 25     depends:[
            + 26         "CAAT.Foundation.Actor",
            + 27         "CAAT.Math.Point",
            + 28         "CAAT.Math.Rectangle"
            + 29     ],
            + 30     constants :  {
            + 31 
            + 32         /**
            + 33          * @lends CAAT.Foundation.ActorContainer
            + 34          * */
            + 35 
            + 36         ADDHINT:{
            + 37 
            + 38             /**
            + 39              * @lends CAAT.Foundation.ActorContainer.ADDHINT
            + 40              */
            + 41 
            + 42             /** @const */ CONFORM:1
            + 43         },
            + 44 
            + 45         AddHint : {
            + 46 
            + 47             /**
            + 48              * @lends CAAT.Foundation.ActorContainer.AddHint
            + 49              */
            + 50             /** @const */ CONFORM:1
            + 51         }
            + 52     },
            + 53     extendsClass : "CAAT.Foundation.Actor",
            + 54     extendsWith : function () {
            + 55 
            + 56 
            + 57 
            + 58         var __CD =                      CAAT.Foundation.Actor.CACHE_DEEP;
            + 59 
            + 60         var sc=                         CAAT.Foundation.ActorContainer.superclass;
            + 61         var sc_drawScreenBoundingBox=   sc.drawScreenBoundingBox;
            + 62         var sc_paintActor=              sc.paintActor;
            + 63         var sc_paintActorGL=            sc.paintActorGL;
            + 64         var sc_animate=                 sc.animate;
            + 65         var sc_findActorAtPosition =    sc.findActorAtPosition;
            + 66         var sc_destroy =                sc.destroy;
            + 67 
            + 68         return {
            + 69 
            + 70             /**
            + 71              *
            + 72              * @lends CAAT.Foundation.ActorContainer.prototype
            + 73              */
            + 74 
            + 75             /**
            + 76              * Constructor delegate
            + 77              * @param hint {CAAT.Foundation.ActorContainer.AddHint}
            + 78              * @return {*}
            + 79              * @private
            + 80              */
            + 81             __init:function (hint) {
            + 82 
            + 83                 this.__super();
            + 84 
            + 85                 this.childrenList = [];
            + 86                 this.activeChildren = [];
            + 87                 this.pendingChildrenList = [];
            + 88                 if (typeof hint !== 'undefined') {
            + 89                     this.addHint = hint;
            + 90                     this.boundingBox = new CAAT.Math.Rectangle();
            + 91                 }
            + 92                 return this;
            + 93             },
            + 94 
            + 95             /**
            + 96              * This container children.
            + 97              * @type {Array.<CAAT.Foundation.Actor>}
            + 98              */
            + 99             childrenList:null,
            +100 
            +101             /**
            +102              * This container active children.
            +103              * @type {Array.<CAAT.Foundation.Actor>}
            +104              * @private
            +105              */
            +106             activeChildren:null,
            +107 
            +108             /**
            +109              * This container pending to be added children.
            +110              * @type {Array.<CAAT.Foundation.Actor>}
            +111              * @private
            +112              */
            +113             pendingChildrenList:null,
            +114 
            +115             /**
            +116              * Container redimension policy when adding children:
            +117              *  0 : no resize.
            +118              *  CAAT.Foundation.ActorContainer.AddHint.CONFORM : resize container to a bounding box.
            +119              *
            +120              * @type {number}
            +121              * @private
            +122              */
            +123             addHint:0,
            +124 
            +125             /**
            +126              * If container redimension on children add, use this rectangle as bounding box store.
            +127              * @type {CAAT.Math.Rectangle}
            +128              * @private
            +129              */
            +130             boundingBox:null,
            +131 
            +132             /**
            +133              * Spare rectangle to avoid new allocations when adding children to this container.
            +134              * @type {CAAT.Math.Rectangle}
            +135              * @private
            +136              */
            +137             runion:new CAAT.Math.Rectangle(), // Watch out. one for every container.
            +138 
            +139             /**
            +140              * Define a layout manager for this container that enforces children position and/or sizes.
            +141              * @see demo26 for an example of layouts.
            +142              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
            +143              */
            +144             layoutManager:null, // a layout manager instance.
            +145 
            +146             /**
            +147              * @type {boolean}
            +148              */
            +149             layoutInvalidated:true,
            +150 
            +151             setLayout:function (layout) {
            +152                 this.layoutManager = layout;
            +153                 return this;
            +154             },
            +155 
            +156             setBounds:function (x, y, w, h) {
            +157                 CAAT.Foundation.ActorContainer.superclass.setBounds.call(this, x, y, w, h);
            +158                 if (CAAT.currentDirector && !CAAT.currentDirector.inValidation) {
            +159                     this.invalidateLayout();
            +160                 }
            +161                 return this;
            +162             },
            +163 
            +164             __validateLayout:function () {
            +165 
            +166                 this.__validateTree();
            +167                 this.layoutInvalidated = false;
            +168             },
            +169 
            +170             __validateTree:function () {
            +171                 if (this.layoutManager && this.layoutManager.isInvalidated()) {
            +172 
            +173                     CAAT.currentDirector.inValidation = true;
            +174 
            +175                     this.layoutManager.doLayout(this);
            +176 
            +177                     for (var i = 0; i < this.getNumChildren(); i += 1) {
            +178                         this.getChildAt(i).__validateLayout();
            +179                     }
            +180                 }
            +181             },
            +182 
            +183             invalidateLayout:function () {
            +184                 this.layoutInvalidated = true;
            +185 
            +186                 if (this.layoutManager) {
            +187                     this.layoutManager.invalidateLayout(this);
            +188 
            +189                     for (var i = 0; i < this.getNumChildren(); i += 1) {
            +190                         this.getChildAt(i).invalidateLayout();
            +191                     }
            +192                 }
            +193             },
            +194 
            +195             getLayout:function () {
            +196                 return this.layoutManager;
            +197             },
            +198 
            +199             /**
            +200              * Draws this ActorContainer and all of its children screen bounding box.
            +201              *
            +202              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +203              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +204              */
            +205             drawScreenBoundingBox:function (director, time) {
            +206 
            +207                 if (!this.inFrame) {
            +208                     return;
            +209                 }
            +210 
            +211                 var cl = this.activeChildren;
            +212                 for (var i = 0; i < cl.length; i++) {
            +213                     cl[i].drawScreenBoundingBox(director, time);
            +214                 }
            +215                 sc_drawScreenBoundingBox.call(this, director, time);
            +216             },
            +217             /**
            +218              * Removes all children from this ActorContainer.
            +219              *
            +220              * @return this
            +221              */
            +222             emptyChildren:function () {
            +223                 this.childrenList = [];
            +224 
            +225                 return this;
            +226             },
            +227             /**
            +228              * Private
            +229              * Paints this container and every contained children.
            +230              *
            +231              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +232              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +233              */
            +234             paintActor:function (director, time) {
            +235 
            +236                 if (!this.visible) {
            +237                     return false;
            +238                 }
            +239 
            +240                 var ctx = director.ctx;
            +241 
            +242                 ctx.save();
            +243 
            +244                 if (!sc_paintActor.call(this, director, time)) {
            +245                     return false;
            +246                 }
            +247 
            +248                 if (this.cached === __CD) {
            +249                     return false;
            +250                 }
            +251 
            +252                 if (!this.isGlobalAlpha) {
            +253                     this.frameAlpha = this.parent ? this.parent.frameAlpha : 1;
            +254                 }
            +255 
            +256                 for (var i = 0, l = this.activeChildren.length; i < l; ++i) {
            +257                     var actor = this.activeChildren[i];
            +258 
            +259                     if (actor.visible) {
            +260                         ctx.save();
            +261                         actor.paintActor(director, time);
            +262                         ctx.restore();
            +263                     }
            +264                 }
            +265 
            +266                 if (this.postPaint) {
            +267                     this.postPaint( director, time );
            +268                 }
            +269 
            +270                 ctx.restore();
            +271 
            +272                 return true;
            +273             },
            +274             __paintActor:function (director, time) {
            +275                 if (!this.visible) {
            +276                     return true;
            +277                 }
            +278 
            +279                 var ctx = director.ctx;
            +280 
            +281                 this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1;
            +282                 var m = this.worldModelViewMatrix.matrix;
            +283                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha);
            +284                 this.paint(director, time);
            +285 
            +286                 if (!this.isGlobalAlpha) {
            +287                     this.frameAlpha = this.parent ? this.parent.frameAlpha : 1;
            +288                 }
            +289 
            +290                 for (var i = 0, l = this.activeChildren.length; i < l; ++i) {
            +291                     var actor = this.activeChildren[i];
            +292                     actor.paintActor(director, time);
            +293                 }
            +294                 return true;
            +295             },
            +296             paintActorGL:function (director, time) {
            +297 
            +298                 var i, l, c;
            +299 
            +300                 if (!this.visible) {
            +301                     return true;
            +302                 }
            +303 
            +304                 sc_paintActorGL.call(this, director, time);
            +305 
            +306                 if (!this.isGlobalAlpha) {
            +307                     this.frameAlpha = this.parent.frameAlpha;
            +308                 }
            +309 
            +310                 for (i = 0, l = this.activeChildren.length; i < l; ++i) {
            +311                     c = this.activeChildren[i];
            +312                     c.paintActorGL(director, time);
            +313                 }
            +314 
            +315             },
            +316             /**
            +317              * Private.
            +318              * Performs the animate method for this ActorContainer and every contained Actor.
            +319              *
            +320              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +321              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +322              *
            +323              * @return {boolean} is this actor in active children list ??
            +324              */
            +325             animate:function (director, time) {
            +326 
            +327                 if (!this.visible) {
            +328                     return false;
            +329                 }
            +330 
            +331                 this.activeChildren = [];
            +332                 var last = null;
            +333 
            +334                 if (false === sc_animate.call(this, director, time)) {
            +335                     return false;
            +336                 }
            +337 
            +338                 if (this.cached === __CD) {
            +339                     return true;
            +340                 }
            +341 
            +342                 this.__validateLayout();
            +343                 CAAT.currentDirector.inValidation = false;
            +344 
            +345                 var i, l;
            +346 
            +347                 /**
            +348                  * Incluir los actores pendientes.
            +349                  * El momento es ahora, antes de procesar ninguno del contenedor.
            +350                  */
            +351                 var pcl = this.pendingChildrenList;
            +352                 for (i = 0; i < pcl.length; i++) {
            +353                     var child = pcl[i];
            +354                     this.addChildImmediately(child.child, child.constraint);
            +355                 }
            +356 
            +357                 this.pendingChildrenList = [];
            +358                 var markDelete = [];
            +359 
            +360                 var cl = this.childrenList;
            +361                 this.size_active = 1;
            +362                 this.size_total = 1;
            +363                 for (i = 0; i < cl.length; i++) {
            +364                     var actor = cl[i];
            +365                     actor.time = time;
            +366                     this.size_total += actor.size_total;
            +367                     if (actor.animate(director, time)) {
            +368                         this.activeChildren.push(actor);
            +369                         this.size_active += actor.size_active;
            +370                     } else {
            +371                         if (actor.expired && actor.discardable) {
            +372                             markDelete.push(actor);
            +373                         }
            +374                     }
            +375                 }
            +376 
            +377                 for (i = 0, l = markDelete.length; i < l; i++) {
            +378                     var md = markDelete[i];
            +379                     md.destroy(time);
            +380                     if (director.dirtyRectsEnabled) {
            +381                         director.addDirtyRect(md.AABB);
            +382                     }
            +383                 }
            +384 
            +385                 return true;
            +386             },
            +387             /**
            +388              * Removes Actors from this ActorContainer which are expired and flagged as Discardable.
            +389              *
            +390              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
            +391              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
            +392              *
            +393              * @deprecated
            +394              */
            +395             endAnimate:function (director, time) {
            +396             },
            +397             /**
            +398              * Adds an Actor to this Container.
            +399              * The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at
            +400              * the time of method call.
            +401              *
            +402              * This method is only used by director's transitionScene.
            +403              *
            +404              * @param child {CAAT.Foundation.Actor}
            +405              * @param constraint {object}
            +406              * @return this.
            +407              */
            +408             addChildImmediately:function (child, constraint) {
            +409                 return this.addChild(child, constraint);
            +410             },
            +411 
            +412             addActorImmediately: function(child,constraint) {
            +413                 return this.addChildImmediately(child,constraint);
            +414             },
            +415 
            +416             addActor : function( child, constraint ) {
            +417                 return this.addChild(child,constraint);
            +418             },
            +419 
            +420             /**
            +421              * Adds an Actor to this ActorContainer.
            +422              * The Actor will be added to the container AFTER frame animation, and not on method call time.
            +423              * Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this
            +424              * method directly.
            +425              *
            +426              * If the container has addingHint as CAAT.Foundation.ActorContainer.AddHint.CONFORM, new continer size will be
            +427              * calculated by summing up the union of every client actor bounding box.
            +428              * This method will not take into acount actor's affine transformations, so the bounding box will be
            +429              * AABB.
            +430              *
            +431              * @param child {CAAT.Foundation.Actor} object instance.
            +432              * @param constraint {object}
            +433              * @return this
            +434              */
            +435             addChild:function (child, constraint) {
            +436 
            +437                 if (child.parent != null) {
            +438                     throw('adding to a container an element with parent.');
            +439                 }
            +440 
            +441                 child.parent = this;
            +442                 this.childrenList.push(child);
            +443                 child.dirty = true;
            +444 
            +445                 if (this.layoutManager) {
            +446                     this.layoutManager.addChild(child, constraint);
            +447                     this.invalidateLayout();
            +448                 } else {
            +449                     /**
            +450                      * if Conforming size, recalc new bountainer size.
            +451                      */
            +452                     if (this.addHint === CAAT.Foundation.ActorContainer.AddHint.CONFORM) {
            +453                         this.recalcSize();
            +454                     }
            +455                 }
            +456 
            +457                 return this;
            +458             },
            +459 
            +460             /**
            +461              * Recalc this container size by computing the union of every children bounding box.
            +462              */
            +463             recalcSize:function () {
            +464                 var bb = this.boundingBox;
            +465                 bb.setEmpty();
            +466                 var cl = this.childrenList;
            +467                 var ac;
            +468                 for (var i = 0; i < cl.length; i++) {
            +469                     ac = cl[i];
            +470                     this.runion.setBounds(
            +471                         ac.x < 0 ? 0 : ac.x,
            +472                         ac.y < 0 ? 0 : ac.y,
            +473                         ac.width,
            +474                         ac.height);
            +475                     bb.unionRectangle(this.runion);
            +476                 }
            +477                 this.setSize(bb.x1, bb.y1);
            +478 
            +479                 return this;
            +480             },
            +481 
            +482             /**
            +483              * Add a child element and make it active in the next frame.
            +484              * @param child {CAAT.Foundation.Actor}
            +485              */
            +486             addChildDelayed:function (child, constraint) {
            +487                 this.pendingChildrenList.push({ child:child, constraint: constraint });
            +488                 return this;
            +489             },
            +490             /**
            +491              * Adds an Actor to this ActorContainer.
            +492              *
            +493              * @param child {CAAT.Foundation.Actor}.
            +494              * @param index {number}
            +495              *
            +496              * @return this
            +497              */
            +498             addChildAt:function (child, index) {
            +499 
            +500                 if (index <= 0) {
            +501                     child.parent = this;
            +502                     child.dirty = true;
            +503                     this.childrenList.splice(0, 0, child);
            +504                     this.invalidateLayout();
            +505                     return this;
            +506                 } else {
            +507                     if (index >= this.childrenList.length) {
            +508                         index = this.childrenList.length;
            +509                     }
            +510                 }
            +511 
            +512                 child.parent = this;
            +513                 child.dirty = true;
            +514                 this.childrenList.splice(index, 0, child);
            +515                 this.invalidateLayout();
            +516 
            +517                 return this;
            +518             },
            +519             /**
            +520              * Find the first actor with the supplied ID.
            +521              * This method is not recommended to be used since executes a linear search.
            +522              * @param id
            +523              */
            +524             findActorById:function (id) {
            +525 
            +526                 if ( CAAT.Foundation.ActorContainer.superclass.findActorById.call(this,id) ) {
            +527                     return this;
            +528                 }
            +529 
            +530                 var cl = this.childrenList;
            +531                 for (var i = 0, l = cl.length; i < l; i++) {
            +532                     var ret= cl[i].findActorById(id);
            +533                     if (null!=ret) {
            +534                         return ret;
            +535                     }
            +536                 }
            +537 
            +538                 return null;
            +539             },
            +540             /**
            +541              * Private
            +542              * Gets a contained Actor z-index on this ActorContainer.
            +543              *
            +544              * @param child a CAAT.Foundation.Actor object instance.
            +545              *
            +546              * @return {number}
            +547              */
            +548             findChild:function (child) {
            +549                 var cl = this.childrenList;
            +550                 var i;
            +551                 var len = cl.length;
            +552 
            +553                 for (i = 0; i < len; i++) {
            +554                     if (cl[i] === child) {
            +555                         return i;
            +556                     }
            +557                 }
            +558                 return -1;
            +559             },
            +560             removeChildAt:function (pos) {
            +561                 var cl = this.childrenList;
            +562                 var rm;
            +563                 if (-1 !== pos && pos>=0 && pos<this.childrenList.length) {
            +564                     cl[pos].setParent(null);
            +565                     rm = cl.splice(pos, 1);
            +566                     if (rm[0].isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
            +567                         CAAT.currentDirector.scheduleDirtyRect(rm[0].AABB);
            +568                     }
            +569 
            +570                     this.invalidateLayout();
            +571                     return rm[0];
            +572                 }
            +573 
            +574                 return null;
            +575             },
            +576             /**
            +577              * Removed an Actor form this ActorContainer.
            +578              * If the Actor is not contained into this Container, nothing happends.
            +579              *
            +580              * @param child a CAAT.Foundation.Actor object instance.
            +581              *
            +582              * @return this
            +583              */
            +584             removeChild:function (child) {
            +585                 var pos = this.findChild(child);
            +586                 var ret = this.removeChildAt(pos);
            +587 
            +588                 return ret;
            +589             },
            +590             removeFirstChild:function () {
            +591                 var first = this.childrenList.shift();
            +592                 first.parent = null;
            +593                 if (first.isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
            +594                     CAAT.currentDirector.scheduleDirtyRect(first.AABB);
            +595                 }
            +596 
            +597                 this.invalidateLayout();
            +598 
            +599                 return first;
            +600             },
            +601             removeLastChild:function () {
            +602                 if (this.childrenList.length) {
            +603                     var last = this.childrenList.pop();
            +604                     last.parent = null;
            +605                     if (last.isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
            +606                         CAAT.currentDirector.scheduleDirtyRect(last.AABB);
            +607                     }
            +608 
            +609                     this.invalidateLayout();
            +610 
            +611                     return last;
            +612                 }
            +613 
            +614                 return null;
            +615             },
            +616             /**
            +617              * @private
            +618              *
            +619              * Gets the Actor inside this ActorContainer at a given Screen coordinate.
            +620              *
            +621              * @param point an object of the form { x: float, y: float }
            +622              *
            +623              * @return the Actor contained inside this ActorContainer if found, or the ActorContainer itself.
            +624              */
            +625             findActorAtPosition:function (point) {
            +626 
            +627                 if (null === sc_findActorAtPosition.call(this, point)) {
            +628                     return null;
            +629                 }
            +630 
            +631                 // z-order
            +632                 var cl = this.childrenList;
            +633                 for (var i = cl.length - 1; i >= 0; i--) {
            +634                     var child = this.childrenList[i];
            +635 
            +636                     var np = new CAAT.Math.Point(point.x, point.y, 0);
            +637                     var contained = child.findActorAtPosition(np);
            +638                     if (null !== contained) {
            +639                         return contained;
            +640                     }
            +641                 }
            +642 
            +643                 return this;
            +644             },
            +645             /**
            +646              * Destroys this ActorContainer.
            +647              * The process falls down recursively for each contained Actor into this ActorContainer.
            +648              *
            +649              * @return this
            +650              */
            +651             destroy:function () {
            +652                 var cl = this.childrenList;
            +653                 for (var i = cl.length - 1; i >= 0; i--) {
            +654                     cl[i].destroy();
            +655                 }
            +656                 sc_destroy.call(this);
            +657 
            +658                 return this;
            +659             },
            +660             /**
            +661              * Get number of Actors into this container.
            +662              * @return integer indicating the number of children.
            +663              */
            +664             getNumChildren:function () {
            +665                 return this.childrenList.length;
            +666             },
            +667             getNumActiveChildren:function () {
            +668                 return this.activeChildren.length;
            +669             },
            +670             /**
            +671              * Returns the Actor at the iPosition(th) position.
            +672              * @param iPosition an integer indicating the position array.
            +673              * @return the CAAT.Foundation.Actor object at position.
            +674              */
            +675             getChildAt:function (iPosition) {
            +676                 return this.childrenList[ iPosition ];
            +677             },
            +678             /**
            +679              * Changes an actor's ZOrder.
            +680              * @param actor the actor to change ZOrder for
            +681              * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the
            +682              * last ZOrder Actor.
            +683              */
            +684             setZOrder:function (actor, index) {
            +685                 var actorPos = this.findChild(actor);
            +686                 // the actor is present
            +687                 if (-1 !== actorPos) {
            +688                     var cl = this.childrenList;
            +689                     // trivial reject.
            +690                     if (index === actorPos) {
            +691                         return;
            +692                     }
            +693 
            +694                     if (index >= cl.length) {
            +695                         cl.splice(actorPos, 1);
            +696                         cl.push(actor);
            +697                     } else {
            +698                         var nActor = cl.splice(actorPos, 1);
            +699                         if (index < 0) {
            +700                             index = 0;
            +701                         } else if (index > cl.length) {
            +702                             index = cl.length;
            +703                         }
            +704 
            +705                         cl.splice(index, 0, nActor[0]);
            +706                     }
            +707 
            +708                     this.invalidateLayout();
            +709                 }
            +710             }
            +711         }
            +712 
            +713     }
            +714 });
            +715 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DBodyActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DBodyActor.js.html new file mode 100644 index 0000000..596e9e6 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DBodyActor.js.html @@ -0,0 +1,305 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name Box2D
            +  5      * @memberOf CAAT.Foundation
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name B2DBodyActor
            + 11      * @memberOf CAAT.Foundation.Box2D
            + 12      * @extends CAAT.Foundation.Actor
            + 13      * @constructor
            + 14      */
            + 15 
            + 16     defines:"CAAT.Foundation.Box2D.B2DBodyActor",
            + 17     depends:[
            + 18         "CAAT.Foundation.Actor"
            + 19     ],
            + 20     aliases : ["CAAT.B2DBodyActor"],
            + 21     extendsClass:"CAAT.Foundation.Actor",
            + 22     extendsWith:function () {
            + 23 
            + 24         /**
            + 25          * @lends CAAT
            + 26          */
            + 27 
            + 28         /**
            + 29          * Points to Meter ratio value.
            + 30          * @type {Number}
            + 31          */
            + 32         CAAT.PMR = 64;
            + 33 
            + 34         /**
            + 35          * (As Eemeli Kelokorpi suggested)
            + 36          *
            + 37          * Enable Box2D debug renderer.
            + 38          *
            + 39          * @param set {boolean} enable or disable
            + 40          * @param director {CAAT.Foundation.Director}
            + 41          * @param world {object} box2d world
            + 42          * @param scale {numner} a scale value.
            + 43          */
            + 44         CAAT.enableBox2DDebug = function (set, director, world, scale) {
            + 45 
            + 46             if (set) {
            + 47                 var debugDraw = new Box2D.Dynamics.b2DebugDraw();
            + 48                 try {
            + 49                     debugDraw.m_sprite.graphics.clear = function () {
            + 50                     };
            + 51                 } catch (e) {
            + 52                 }
            + 53 
            + 54                 world.SetDebugDraw(debugDraw);
            + 55 
            + 56                 debugDraw.SetSprite(director.ctx);
            + 57                 debugDraw.SetDrawScale(scale || CAAT.PMR);
            + 58                 debugDraw.SetFillAlpha(.5);
            + 59                 debugDraw.SetLineThickness(1.0);
            + 60                 debugDraw.SetFlags(0x0001 | 0x0002);
            + 61 
            + 62             } else {
            + 63                 world.SetDebugDraw(null);
            + 64             }
            + 65         };
            + 66 
            + 67         return {
            + 68 
            + 69             /**
            + 70              * @lends CAAT.Foundation.Box2D.B2DBodyActor.prototype
            + 71              */
            + 72 
            + 73             /**
            + 74              * Body restitution.
            + 75              */
            + 76             restitution:.5,
            + 77 
            + 78             /**
            + 79              * Body friction.
            + 80              */
            + 81             friction:.5,
            + 82 
            + 83             /**
            + 84              * Body dentisy
            + 85              */
            + 86             density:1,
            + 87 
            + 88             /**
            + 89              * Dynamic bodies by default
            + 90              */
            + 91             bodyType:Box2D.Dynamics.b2Body.b2_dynamicBody,
            + 92 
            + 93             /**
            + 94              * Box2D body
            + 95              */
            + 96             worldBody:null,
            + 97 
            + 98             /**
            + 99              * Box2D world reference.
            +100              */
            +101             world:null,
            +102 
            +103             /**
            +104              * Box2d fixture
            +105              */
            +106             worldBodyFixture:null,
            +107 
            +108             /**
            +109              * Box2D body definition.
            +110              */
            +111             bodyDef:null,
            +112 
            +113             /**
            +114              * Box2D fixture definition.
            +115              */
            +116             fixtureDef:null,
            +117 
            +118             /**
            +119              * BodyData object linked to the box2D body.
            +120              */
            +121             bodyData:null,
            +122 
            +123             /**
            +124              * Recycle this actor when the body is not needed anymore ??
            +125              */
            +126             recycle:false,
            +127 
            +128             __init : function() {
            +129                 this.__super();
            +130                 this.setPositionAnchor(.5,.5);
            +131 
            +132                 return this;
            +133             },
            +134 
            +135             setPositionAnchor : function( ax, ay ) {
            +136                 this.tAnchorX= .5;
            +137                 this.tAnchorY= .5;
            +138             },
            +139 
            +140             setPositionAnchored : function(x,y,ax,ay) {
            +141                 this.x= x;
            +142                 this.y= y;
            +143                 this.tAnchorX= .5;
            +144                 this.tAnchorY= .5;
            +145             },
            +146 
            +147             /**
            +148              * set this actor to recycle its body, that is, do not destroy it.
            +149              */
            +150             setRecycle:function () {
            +151                 this.recycle = true;
            +152                 return this;
            +153             },
            +154             destroy:function () {
            +155 
            +156                 CAAT.Foundation.Box2D.B2DBodyActor.superclass.destroy.call(this);
            +157                 if (this.recycle) {
            +158                     this.setLocation(-Number.MAX_VALUE, -Number.MAX_VALUE);
            +159                     this.setAwake(false);
            +160                 } else {
            +161                     var body = this.worldBody;
            +162                     body.DestroyFixture(this.worldBodyFixture);
            +163                     this.world.DestroyBody(body);
            +164                 }
            +165 
            +166                 return this;
            +167             },
            +168             setAwake:function (bool) {
            +169                 this.worldBody.SetAwake(bool);
            +170                 return this;
            +171             },
            +172             setSleepingAllowed:function (bool) {
            +173                 this.worldBody.SetSleepingAllowed(bool);
            +174                 return this;
            +175             },
            +176             setLocation:function (x, y) {
            +177                 this.worldBody.SetPosition(
            +178                     new Box2D.Common.Math.b2Vec2(
            +179                         x / CAAT.PMR,
            +180                         y / CAAT.PMR));
            +181                 return this;
            +182             },
            +183             /**
            +184              * Set this body's
            +185              * density.
            +186              * @param d {number}
            +187              */
            +188             setDensity:function (d) {
            +189                 this.density = d;
            +190                 return this;
            +191             },
            +192 
            +193             /**
            +194              * Set this body's friction.
            +195              * @param f {number}
            +196              */
            +197             setFriction:function (f) {
            +198                 this.friction = f;
            +199                 return this;
            +200             },
            +201 
            +202             /**
            +203              * Set this body's restitution coeficient.
            +204              * @param r {number}
            +205              */
            +206             setRestitution:function (r) {
            +207                 this.restitution = r;
            +208                 return this;
            +209             },
            +210 
            +211             /**
            +212              * Set this body's type:
            +213              * @param bodyType {Box2D.Dynamics.b2Body.b2_*}
            +214              */
            +215             setBodyType:function (bodyType) {
            +216                 this.bodyType = bodyType;
            +217                 return this;
            +218             },
            +219 
            +220             /**
            +221              * Helper method to check whether this js object contains a given property and if it doesn't exist
            +222              * create and set it to def value.
            +223              * @param obj {object}
            +224              * @param prop {string}
            +225              * @param def {object}
            +226              */
            +227             check:function (obj, prop, def) {
            +228                 if (!obj[prop]) {
            +229                     obj[prop] = def;
            +230                 }
            +231             },
            +232 
            +233             /**
            +234              * Create an actor as a box2D body binding, create it on the given world and with
            +235              * the initialization data set in bodyData object.
            +236              * @param world {Box2D.Dynamics.b2World} a Box2D world instance
            +237              * @param bodyData {object} An object with body info.
            +238              */
            +239             createBody:function (world, bodyData) {
            +240 
            +241                 if (bodyData) {
            +242                     this.check(bodyData, 'density', 1);
            +243                     this.check(bodyData, 'friction', .5);
            +244                     this.check(bodyData, 'restitution', .2);
            +245                     this.check(bodyData, 'bodyType', Box2D.Dynamics.b2Body.b2_staticBody);
            +246                     this.check(bodyData, 'userData', {});
            +247                     this.check(bodyData, 'image', null);
            +248 
            +249                     this.density = bodyData.density;
            +250                     this.friction = bodyData.friction;
            +251                     this.restitution = bodyData.restitution;
            +252                     this.bodyType = bodyData.bodyType;
            +253                     this.image = bodyData.image;
            +254 
            +255                 }
            +256 
            +257                 this.world = world;
            +258 
            +259                 return this;
            +260             },
            +261 
            +262             /**
            +263              * Get this body's center on screen regardless of its shape.
            +264              * This method will return box2d body's centroid.
            +265              */
            +266             getCenter:function () {
            +267                 return this.worldBody.GetPosition();
            +268             },
            +269 
            +270             /**
            +271              * Get a distance joint's position on pixels.
            +272              */
            +273             getDistanceJointLocalAnchor:function () {
            +274                 return new Box2D.Common.Math.b2Vec2(0,0);
            +275             },
            +276 
            +277             /**
            +278              * Method override to get position and rotation angle from box2d body.
            +279              * @param director {CAAT.Director}
            +280              * @param time {number}
            +281              */
            +282             animate: function(director, time) {
            +283 
            +284                 var pos= this.worldBody.GetPosition();
            +285 
            +286                 CAAT.Foundation.Actor.prototype.setLocation.call(
            +287                         this,
            +288                         CAAT.PMR*pos.x,
            +289                         CAAT.PMR*pos.y);
            +290 
            +291                 this.setRotation( this.worldBody.GetAngle() );
            +292 
            +293                 return CAAT.Foundation.Box2D.B2DBodyActor.superclass.animate.call(this,director,time);
            +294             }
            +295         }
            +296     }
            +297 });
            +298 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DCircularBody.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DCircularBody.js.html new file mode 100644 index 0000000..25b4958 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DCircularBody.js.html @@ -0,0 +1,106 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name B2DCircularBody
            +  5      * @memberOf CAAT.Foundation.Box2D
            +  6      * @extends CAAT.Foundation.Box2D.B2DBodyActor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.Box2D.B2DCircularBody",
            + 11     depends : [
            + 12         "CAAT.Foundation.Box2D.B2DBodyActor"
            + 13     ],
            + 14     aliases : ["CAAT.B2DCircularBody"],
            + 15     extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor",
            + 16     constants : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Foundation.Box2D.B2DCircularBody
            + 20          */
            + 21 
            + 22         createCircularBody : function(world, bodyData) {
            + 23             if ( bodyData.radius )  this.radius= bodyData.radius;
            + 24 
            + 25             var fixDef=             new Box2D.Dynamics.b2FixtureDef();
            + 26             fixDef.density=         bodyData.density;
            + 27             fixDef.friction=        bodyData.friction;
            + 28             fixDef.restitution=     bodyData.restitution;
            + 29             fixDef.shape =          new Box2D.Collision.Shapes.b2CircleShape(bodyData.radius/CAAT.PMR);
            + 30 
            + 31             var bodyDef =           new Box2D.Dynamics.b2BodyDef();
            + 32             bodyDef.type =          bodyData.bodyType;
            + 33             bodyDef.position.Set( bodyData.x/CAAT.PMR, bodyData.y/CAAT.PMR );
            + 34 
            + 35             // link entre cuerpo fisico box2d y caat.
            + 36             fixDef.userData=        bodyData.userData;
            + 37             bodyDef.userData=       bodyData.userData;
            + 38 
            + 39             var worldBody=          world.CreateBody(bodyDef);
            + 40             var worldBodyFixture=   worldBody.CreateFixture(fixDef);
            + 41 
            + 42             if ( bodyData.isSensor ) {
            + 43                 worldBodyFixture.SetSensor(true);
            + 44             }
            + 45 
            + 46             return {
            + 47                 worldBody:          worldBody,
            + 48                 worldBodyFixture:   worldBodyFixture,
            + 49                 fixDef:             fixDef,
            + 50                 bodyDef:            bodyDef
            + 51             };
            + 52         }
            + 53     },
            + 54     extendsWith : {
            + 55 
            + 56         /**
            + 57          * @lends CAAT.Foundation.Box2D.B2DCircularBody.prototype
            + 58          */
            + 59 
            + 60 
            + 61         /**
            + 62          * Default radius.
            + 63          */
            + 64         radius: 1,
            + 65 
            + 66         /**
            + 67          * Create a box2d body and link it to this CAAT.Actor instance.
            + 68          * @param world {Box2D.Dynamics.b2World} a Box2D world instance
            + 69          * @param bodyData {object}
            + 70          */
            + 71         createBody : function(world, bodyData) {
            + 72 
            + 73             var scale= (bodyData.radius || 1);
            + 74             scale= scale+ (bodyData.bodyDefScaleTolerance || 0)*Math.random();
            + 75             bodyData.radius= scale;
            + 76 
            + 77             CAAT.Foundation.Box2D.B2DCircularBody.superclass.createBody.call(this,world,bodyData);
            + 78             var box2D_data= CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(world,bodyData);
            + 79 
            + 80             bodyData.userData.actor=         this;
            + 81 
            + 82             this.worldBody=         box2D_data.worldBody;
            + 83             this.worldBodyFixture=  box2D_data.worldBodyFixture;
            + 84             this.fixtureDef=        box2D_data.fixDef;
            + 85             this.bodyDef=           box2D_data.bodyDef;
            + 86             this.bodyData=          bodyData;
            + 87 
            + 88             this.setFillStyle(this.worldBodyFixture.IsSensor() ? 'red' : 'green').
            + 89                     setBackgroundImage(this.image).
            + 90                     setSize(2*bodyData.radius,2*bodyData.radius).
            + 91                     setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);
            + 92 
            + 93 
            + 94             return this;
            + 95         }
            + 96     }
            + 97 
            + 98 });
            + 99 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DPolygonBody.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DPolygonBody.js.html new file mode 100644 index 0000000..155f4b2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Box2D_B2DPolygonBody.js.html @@ -0,0 +1,186 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name B2DPolygonBody
            +  5      * @memberOf CAAT.Foundation.Box2D
            +  6      * @extends CAAT.Foundation.Box2D.B2DBodyActor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.Box2D.B2DPolygonBody",
            + 11     depends : [
            + 12         "CAAT.Foundation.Box2D.B2DBodyActor",
            + 13         "CAAT.Foundation.SpriteImage"
            + 14     ],
            + 15     aliases : ["CAAT.B2DPolygonBody"],
            + 16     constants: {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Foundation.Box2D.B2DPolygonBody
            + 20          */
            + 21 
            + 22         TYPE: {
            + 23             EDGE:   'edge',
            + 24             BOX:    'box',
            + 25             POLYGON:'polygon'
            + 26         },
            + 27 
            + 28         /**
            + 29          * Helper function to aid in box2d polygon shaped bodies.
            + 30          * @param world
            + 31          * @param bodyData
            + 32          */
            + 33         createPolygonBody : function(world, bodyData) {
            + 34             var fixDef = new Box2D.Dynamics.b2FixtureDef();
            + 35             fixDef.density = bodyData.density;
            + 36             fixDef.friction = bodyData.friction;
            + 37             fixDef.restitution = bodyData.restitution;
            + 38             fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape();
            + 39 
            + 40             var minx = Number.MAX_VALUE;
            + 41             var maxx = -Number.MAX_VALUE;
            + 42             var miny = Number.MAX_VALUE;
            + 43             var maxy = -Number.MAX_VALUE;
            + 44 
            + 45             var vec = [];
            + 46 
            + 47             var scale = (bodyData.bodyDefScale || 1);
            + 48             scale = scale + (bodyData.bodyDefScaleTolerance || 0) * Math.random();
            + 49 
            + 50             for (var i = 0; i < bodyData.bodyDef.length; i++) {
            + 51                 var x = bodyData.bodyDef[i].x * scale;
            + 52                 var y = bodyData.bodyDef[i].y * scale;
            + 53                 if (x < minx) {
            + 54                     minx = x;
            + 55                 }
            + 56                 if (x > maxx) {
            + 57                     maxx = x;
            + 58                 }
            + 59                 if (y < miny) {
            + 60                     miny = y;
            + 61                 }
            + 62                 if (y > maxy) {
            + 63                     maxy = y;
            + 64                 }
            + 65 /*
            + 66                 x += bodyData.x || 0;
            + 67                 y += bodyData.y || 0;
            + 68                 */
            + 69                 vec.push(new Box2D.Common.Math.b2Vec2(x / CAAT.PMR, y / CAAT.PMR));
            + 70             }
            + 71 
            + 72             var boundingBox = [
            + 73                 {x:minx, y:miny},
            + 74                 {x:maxx, y:maxy}
            + 75             ];
            + 76 
            + 77             var bodyDef = new Box2D.Dynamics.b2BodyDef();
            + 78             bodyDef.type = bodyData.bodyType;
            + 79             bodyDef.position.Set(
            + 80                 ((maxx - minx) / 2 + (bodyData.x || 0)) / CAAT.PMR,
            + 81                 ((maxy - miny) / 2 + (bodyData.y || 0)) / CAAT.PMR );
            + 82 
            + 83             if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) {
            + 84 
            + 85                 var v0= new Box2D.Common.Math.b2Vec2(vec[0].x, vec[0].y );
            + 86                 var v1= new Box2D.Common.Math.b2Vec2(vec[1].x-vec[0].x, vec[1].y-vec[0].y );
            + 87 
            + 88                 bodyDef.position.Set(v0.x, v0.y);
            + 89                 fixDef.shape.SetAsEdge(new Box2D.Common.Math.b2Vec2(0,0), v1);
            + 90 
            + 91 
            + 92             } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.BOX) {
            + 93 
            + 94                 fixDef.shape.SetAsBox(
            + 95                     (maxx - minx) / 2 / CAAT.PMR,
            + 96                     (maxy - miny) / 2 / CAAT.PMR);
            + 97 
            + 98             } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.POLYGON ) {
            + 99 
            +100                 fixDef.shape.SetAsArray(vec, vec.length);
            +101 
            +102             } else {
            +103                 throw 'Unkown bodyData polygonType: '+bodyData.polygonType;
            +104             }
            +105 
            +106             // link entre cuerpo fisico box2d y caat.
            +107             fixDef.userData = bodyData.userData;
            +108             bodyDef.userData = bodyData.userData;
            +109 
            +110             var worldBody = world.CreateBody(bodyDef);
            +111             var worldBodyFixture = worldBody.CreateFixture(fixDef);
            +112 
            +113 
            +114             if (bodyData.isSensor) {
            +115                 worldBodyFixture.SetSensor(true);
            +116             }
            +117 
            +118             return {
            +119                 worldBody:          worldBody,
            +120                 worldBodyFixture:   worldBodyFixture,
            +121                 fixDef:             fixDef,
            +122                 bodyDef:            bodyDef,
            +123                 boundingBox:        boundingBox
            +124             };
            +125         }
            +126     },
            +127     extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor",
            +128     extendsWith : {
            +129 
            +130         /**
            +131          * @lends CAAT.Foundation.Box2D.B2DPolygonBody.prototype
            +132          */
            +133 
            +134         /**
            +135          * Measured body's bounding box.
            +136          */
            +137         boundingBox: null,
            +138 
            +139         /**
            +140          * Get on-screen distance joint coordinate.
            +141          */
            +142         getDistanceJointLocalAnchor : function() {
            +143             var b= this.worldBody;
            +144             var poly= b.GetFixtureList().GetShape().GetLocalCenter();
            +145             return poly;
            +146         },
            +147 
            +148         /**
            +149          * Create a box2d body and link it to this CAAT.Actor.
            +150          * @param world {Box2D.Dynamics.b2World}
            +151          * @param bodyData {object}
            +152          */
            +153         createBody : function(world, bodyData) {
            +154             CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,world,bodyData);
            +155 
            +156             var box2D_data= CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(world,bodyData);
            +157 
            +158             bodyData.userData.actor = this;
            +159 
            +160             this.worldBody=         box2D_data.worldBody;
            +161             this.worldBodyFixture=  box2D_data.worldBodyFixture;
            +162             this.fixtureDef=        box2D_data.fixDef;
            +163             this.bodyDef=           box2D_data.bodyDef;
            +164             this.bodyData=          bodyData;
            +165             this.boundingBox=       box2D_data.boundingBox;
            +166 
            +167             this.setBackgroundImage( bodyData.image ).
            +168                 setSize(
            +169                     box2D_data.boundingBox[1].x-box2D_data.boundingBox[0].x+1,
            +170                     box2D_data.boundingBox[1].y-box2D_data.boundingBox[0].y+1 ).
            +171                 setFillStyle( box2D_data.worldBodyFixture.IsSensor() ? '#0f0' : '#f00').
            +172                 setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);
            +173 
            +174             return this;
            +175         }
            +176     }
            +177 
            +178 });
            +179 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Director.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Director.js.html new file mode 100644 index 0000000..1929ae1 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Director.js.html @@ -0,0 +1,3020 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8     /**
            +  9      * @name Director
            + 10      * @memberOf CAAT.Foundation
            + 11      * @extends CAAT.Foundation.ActorContainer
            + 12      *
            + 13      * @constructor
            + 14      */
            + 15 
            + 16     defines:"CAAT.Foundation.Director",
            + 17     aliases:["CAAT.Director"],
            + 18     extendsClass:"CAAT.Foundation.ActorContainer",
            + 19     depends:[
            + 20         "CAAT.Core.Class",
            + 21         "CAAT.Core.Constants",
            + 22 
            + 23         "CAAT.Foundation.ActorContainer",
            + 24         "CAAT.Module.Audio.AudioManager",
            + 25         "CAAT.Module.Runtime.BrowserInfo",
            + 26         "CAAT.Module.Debug.Debug",
            + 27         "CAAT.Math.Point",
            + 28         "CAAT.Math.Rectangle",
            + 29         "CAAT.Math.Matrix",
            + 30         "CAAT.Foundation.Timer.TimerManager",
            + 31         "CAAT.Foundation.Actor",
            + 32         "CAAT.Foundation.Scene",
            + 33         "CAAT.Event.AnimationLoop",
            + 34         "CAAT.Event.Input",
            + 35         "CAAT.Event.KeyEvent",
            + 36         "CAAT.Event.MouseEvent",
            + 37         "CAAT.Event.TouchEvent",
            + 38 
            + 39         "CAAT.WebGL.Program",
            + 40         "CAAT.WebGL.ColorProgram",
            + 41         "CAAT.WebGL.TextureProgram",
            + 42         "CAAT.WebGL.GLU",
            + 43 
            + 44         "CAAT.Module.TexturePacker.TexturePageManager"
            + 45     ],
            + 46     constants:{
            + 47         /**
            + 48          * @lends  CAAT.Foundation.Director
            + 49          */
            + 50 
            + 51         /** @const @type {number} */ RENDER_MODE_CONTINUOUS:1, // redraw every frame
            + 52         /** @const @type {number} */ RENDER_MODE_DIRTY:2, // suitable for evented CAAT.
            + 53 
            + 54         /** @const @type {number} */ CLEAR_DIRTY_RECTS:1,
            + 55         /** @const @type {number} */ CLEAR_ALL:true,
            + 56         /** @const @type {number} */ CLEAR_NONE:false,
            + 57 
            + 58         /** @const @type {number} */ RESIZE_NONE:1,
            + 59         /** @const @type {number} */ RESIZE_WIDTH:2,
            + 60         /** @const @type {number} */ RESIZE_HEIGHT:4,
            + 61         /** @const @type {number} */ RESIZE_BOTH:8,
            + 62         /** @const @type {number} */ RESIZE_PROPORTIONAL:16
            + 63     },
            + 64     extendsWith:function () {
            + 65         return {
            + 66 
            + 67             /**
            + 68              * @lends  CAAT.Foundation.Director.prototype
            + 69              */
            + 70 
            + 71             __init:function () {
            + 72                 this.__super();
            + 73 
            + 74                 this.browserInfo = CAAT.Module.Runtime.BrowserInfo;
            + 75                 this.audioManager = new CAAT.Module.Audio.AudioManager().initialize(8);
            + 76                 this.scenes = [];
            + 77                 this.imagesCache= [];
            + 78 
            + 79                 // input related variables initialization
            + 80                 this.mousePoint = new CAAT.Math.Point(0, 0, 0);
            + 81                 this.prevMousePoint = new CAAT.Math.Point(0, 0, 0);
            + 82                 this.screenMousePoint = new CAAT.Math.Point(0, 0, 0);
            + 83                 this.isMouseDown = false;
            + 84                 this.lastSelectedActor = null;
            + 85                 this.dragging = false;
            + 86 
            + 87                 this.cDirtyRects = [];
            + 88                 this.sDirtyRects = [];
            + 89                 this.dirtyRects = [];
            + 90                 for (var i = 0; i < 64; i++) {
            + 91                     this.dirtyRects.push(new CAAT.Math.Rectangle());
            + 92                 }
            + 93                 this.dirtyRectsIndex = 0;
            + 94                 this.touches = {};
            + 95 
            + 96                 this.timerManager = new CAAT.Foundation.Timer.TimerManager();
            + 97                 this.__map= {};
            + 98 
            + 99                 return this;
            +100             },
            +101 
            +102             /**
            +103              * flag indicating debug mode. It will draw affedted screen areas.
            +104              * @type {boolean}
            +105              */
            +106             debug:false,
            +107 
            +108             /**
            +109              * Set CAAT render mode. Right now, this takes no effect.
            +110              */
            +111             renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,
            +112 
            +113             /**
            +114              * This method will be called before rendering any director scene.
            +115              * Use this method to calculate your physics for example.
            +116              * @private
            +117              */
            +118             onRenderStart:null,
            +119 
            +120             /**
            +121              * This method will be called after rendering any director scene.
            +122              * Use this method to clean your physics forces for example.
            +123              * @private
            +124              */
            +125             onRenderEnd:null,
            +126 
            +127             // input related attributes
            +128             /**
            +129              * mouse coordinate related to canvas 0,0 coord.
            +130              * @private
            +131              */
            +132             mousePoint:null,
            +133 
            +134             /**
            +135              * previous mouse position cache. Needed for drag events.
            +136              * @private
            +137              */
            +138             prevMousePoint:null,
            +139 
            +140             /**
            +141              * screen mouse coordinates.
            +142              * @private
            +143              */
            +144             screenMousePoint:null,
            +145 
            +146             /**
            +147              * is the left mouse button pressed ?.
            +148              * Needed to handle dragging.
            +149              */
            +150             isMouseDown:false,
            +151 
            +152             /**
            +153              * director's last actor receiving input.
            +154              * Needed to set capture for dragging events.
            +155              */
            +156             lastSelectedActor:null,
            +157 
            +158             /**
            +159              * is input in drag mode ?
            +160              */
            +161             dragging:false,
            +162 
            +163             // other attributes
            +164 
            +165             /**
            +166              * This director scene collection.
            +167              * @type {Array.<CAAT.Foundation.Scene>}
            +168              */
            +169             scenes:null,
            +170 
            +171             /**
            +172              * The current Scene. This and only this will receive events.
            +173              */
            +174             currentScene:null,
            +175 
            +176             /**
            +177              * The canvas the Director draws on.
            +178              * @private
            +179              */
            +180             canvas:null,
            +181 
            +182             /**
            +183              * This director´s canvas rendering context.
            +184              */
            +185             ctx:null,
            +186 
            +187             /**
            +188              * director time.
            +189              * @private
            +190              */
            +191             time:0,
            +192 
            +193             /**
            +194              * global director timeline.
            +195              * @private
            +196              */
            +197             timeline:0,
            +198 
            +199             /**
            +200              * An array of JSON elements of the form { id:string, image:Image }
            +201              */
            +202             imagesCache:null,
            +203 
            +204             /**
            +205              * this director´s audio manager.
            +206              * @private
            +207              */
            +208             audioManager:null,
            +209 
            +210             /**
            +211              * Clear screen strategy:
            +212              * CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background.
            +213              * CAAT.Foundation.Director.CLEAR_DIRTY_RECTS : clear only affected actors screen area.
            +214              * CAAT.Foundation.Director.CLEAR_ALL : clear the whole canvas object.
            +215              */
            +216             clear: CAAT.Foundation.Director.CLEAR_ALL,
            +217 
            +218             /**
            +219              * if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene.
            +220              * @private
            +221              */
            +222             transitionScene:null,
            +223 
            +224             /**
            +225              * Some browser related information.
            +226              */
            +227             browserInfo:null,
            +228 
            +229             /**
            +230              * 3d context
            +231              * @private
            +232              */
            +233             gl:null,
            +234 
            +235             /**
            +236              * is WebGL enabled as renderer ?
            +237              * @private
            +238              */
            +239             glEnabled:false,
            +240 
            +241             /**
            +242              * if webGL is on, CAAT will texture pack all images transparently.
            +243              * @private
            +244              */
            +245             glTextureManager:null,
            +246 
            +247             /**
            +248              * The only GLSL program for webGL
            +249              * @private
            +250              */
            +251             glTtextureProgram:null,
            +252             glColorProgram:null,
            +253 
            +254             /**
            +255              * webGL projection matrix
            +256              * @private
            +257              */
            +258             pMatrix:null, // projection matrix
            +259 
            +260             /**
            +261              * webGL vertex array
            +262              * @private
            +263              */
            +264             coords:null, // Float32Array
            +265 
            +266             /**
            +267              * webGL vertex indices.
            +268              * @private
            +269              */
            +270             coordsIndex:0,
            +271 
            +272             /**
            +273              * webGL uv texture indices
            +274              * @private
            +275              */
            +276             uv:null,
            +277             uvIndex:0,
            +278 
            +279             /**
            +280              * draw tris front_to_back or back_to_front ?
            +281              * @private
            +282              */
            +283             front_to_back:false,
            +284 
            +285             /**
            +286              * statistics object
            +287              */
            +288             statistics:{
            +289                 size_total:0,
            +290                 size_active:0,
            +291                 size_dirtyRects:0,
            +292                 draws:0,
            +293                 size_discarded_by_dirty_rects:0
            +294             },
            +295 
            +296             /**
            +297              * webGL current texture page. This minimizes webGL context changes.
            +298              * @private
            +299              */
            +300             currentTexturePage:0,
            +301 
            +302             /**
            +303              * webGL current shader opacity.
            +304              * BUGBUG: change this by vertex colors.
            +305              * @private
            +306              */
            +307             currentOpacity:1,
            +308 
            +309             /**
            +310              * if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned
            +311              * id.
            +312              * @private
            +313              */
            +314             intervalId:null,
            +315 
            +316             /**
            +317              * Rendered frames counter.
            +318              */
            +319             frameCounter:0,
            +320 
            +321             /**
            +322              * Window resize strategy.
            +323              * see CAAT.Foundation.Director.RESIZE_* constants.
            +324              * @private
            +325              */
            +326             resize:1,
            +327 
            +328             /**
            +329              * Callback when the window is resized.
            +330              */
            +331             onResizeCallback:null,
            +332 
            +333             /**
            +334              * Calculated gesture event scale.
            +335              * @private
            +336              */
            +337             __gestureScale:0,
            +338 
            +339             /**
            +340              * Calculated gesture event rotation.
            +341              * @private
            +342              */
            +343             __gestureRotation:0,
            +344 
            +345             /**
            +346              * Dirty rects cache.
            +347              * An array of CAAT.Math.Rectangle object.
            +348              * @private
            +349              */
            +350             dirtyRects:null, // dirty rects cache.
            +351 
            +352             /**
            +353              * current dirty rects.
            +354              * @private
            +355              */
            +356             cDirtyRects:null, // dirty rects cache.
            +357 
            +358             /**
            +359              * Currently used dirty rects.
            +360              * @private
            +361              */
            +362             sDirtyRects:null, // scheduled dirty rects.
            +363 
            +364             /**
            +365              * Number of currently allocated dirty rects.
            +366              * @private
            +367              */
            +368             dirtyRectsIndex:0,
            +369 
            +370             /**
            +371              * Dirty rects enabled ??
            +372              * @private
            +373              */
            +374             dirtyRectsEnabled:false,
            +375 
            +376             /**
            +377              * Number of dirty rects.
            +378              * @private
            +379              */
            +380             nDirtyRects:0,
            +381 
            +382             /**
            +383              * Dirty rects count debug info.
            +384              * @private
            +385              */
            +386             drDiscarded:0, // discarded by dirty rects.
            +387 
            +388             /**
            +389              * Is this director stopped ?
            +390              */
            +391             stopped:false, // is stopped, this director will do nothing.
            +392 
            +393             /**
            +394              * currently unused.
            +395              * Intended to run caat in evented mode.
            +396              * @private
            +397              */
            +398             needsRepaint:false,
            +399 
            +400             /**
            +401              * Touches information. Associate touch.id with an actor and original touch info.
            +402              * @private
            +403              */
            +404             touches:null,
            +405 
            +406             /**
            +407              * Director´s timer manager.
            +408              * Each scene has a timerManager as well.
            +409              * The difference is the scope. Director´s timers will always be checked whereas scene´ timers
            +410              * will only be scheduled/checked when the scene is director´ current scene.
            +411              * @private
            +412              */
            +413             timerManager:null,
            +414 
            +415             /**
            +416              * Retina display deicePixels/backingStorePixels ratio
            +417              * @private
            +418              */
            +419             SCREEN_RATIO : 1,
            +420 
            +421             __map : null,
            +422 
            +423             clean:function () {
            +424                 this.scenes = null;
            +425                 this.currentScene = null;
            +426                 this.imagesCache = null;
            +427                 this.audioManager = null;
            +428                 this.isMouseDown = false;
            +429                 this.lastSelectedActor = null;
            +430                 this.dragging = false;
            +431                 this.__gestureScale = 0;
            +432                 this.__gestureRotation = 0;
            +433                 this.dirty = true;
            +434                 this.dirtyRects = null;
            +435                 this.cDirtyRects = null;
            +436                 this.dirtyRectsIndex = 0;
            +437                 this.dirtyRectsEnabled = false;
            +438                 this.nDirtyRects = 0;
            +439                 this.onResizeCallback = null;
            +440                 this.__map= {};
            +441                 return this;
            +442             },
            +443 
            +444             cancelPlay : function(id) {
            +445                 return this.audioManager.cancelPlay(id);
            +446             },
            +447 
            +448             cancelPlayByChannel : function(audioObject) {
            +449                 return this.audioManager.cancelPlayByChannel(audioObject);
            +450             },
            +451 
            +452             setAudioFormatExtensions : function( extensions ) {
            +453                 this.audioManager.setAudioFormatExtensions(extensions);
            +454                 return this;
            +455             },
            +456 
            +457             setValueForKey : function( key, value ) {
            +458                 this.__map[key]= value;
            +459                 return this;
            +460             },
            +461 
            +462             getValueForKey : function( key ) {
            +463                 return this.__map[key];
            +464                 return this;
            +465             },
            +466 
            +467             createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) {
            +468                 return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this);
            +469             },
            +470 
            +471             requestRepaint:function () {
            +472                 this.needsRepaint = true;
            +473             },
            +474 
            +475             getCurrentScene:function () {
            +476                 return this.currentScene;
            +477             },
            +478 
            +479             checkDebug:function () {
            +480                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +481                     var dd = new CAAT.Module.Debug.Debug().initialize(this.width, 60);
            +482                     this.debugInfo = dd.debugInfo.bind(dd);
            +483                 }
            +484             },
            +485             getRenderType:function () {
            +486                 return this.glEnabled ? 'WEBGL' : 'CANVAS';
            +487             },
            +488             windowResized:function (w, h) {
            +489                 var c = CAAT.Foundation.Director;
            +490                 switch (this.resize) {
            +491                     case c.RESIZE_WIDTH:
            +492                         this.setBounds(0, 0, w, this.height);
            +493                         break;
            +494                     case c.RESIZE_HEIGHT:
            +495                         this.setBounds(0, 0, this.width, h);
            +496                         break;
            +497                     case c.RESIZE_BOTH:
            +498                         this.setBounds(0, 0, w, h);
            +499                         break;
            +500                     case c.RESIZE_PROPORTIONAL:
            +501                         this.setScaleProportional(w, h);
            +502                         break;
            +503                 }
            +504 
            +505                 if (this.glEnabled) {
            +506                     this.glReset();
            +507                 }
            +508 
            +509                 if (this.onResizeCallback) {
            +510                     this.onResizeCallback(this, w, h);
            +511                 }
            +512 
            +513             },
            +514             setScaleProportional:function (w, h) {
            +515 
            +516                 var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight);
            +517 
            +518                 this.canvas.width = this.referenceWidth * factor;
            +519                 this.canvas.height = this.referenceHeight * factor;
            +520                 this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d');
            +521 
            +522                 this.__setupRetina();
            +523 
            +524                 this.setScaleAnchored(factor * this.scaleX, factor * this.scaleY, 0, 0);
            +525 //                this.setScaleAnchored(factor, factor, 0, 0);
            +526 
            +527                 if (this.glEnabled) {
            +528                     this.glReset();
            +529                 }
            +530             },
            +531             /**
            +532              * Enable window resize events and set redimension policy. A callback functio could be supplied
            +533              * to be notified on a Director redimension event. This is necessary in the case you set a redim
            +534              * policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their
            +535              * children scenes are resized to fit the new area. But scenes content is not resized, and have
            +536              * no option of knowing so uless an onResizeCallback function is supplied.
            +537              *
            +538              * @param mode {number}  RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE.
            +539              * @param onResizeCallback {function(director{CAAT.Director}, width{integer}, height{integer})} a callback
            +540              * to notify on canvas resize.
            +541              */
            +542             enableResizeEvents:function (mode, onResizeCallback) {
            +543                 var dd= CAAT.Foundation.Director;
            +544                 if (mode === dd.RESIZE_BOTH || mode === dd.RESIZE_WIDTH || mode === dd.RESIZE_HEIGHT || mode === dd.RESIZE_PROPORTIONAL) {
            +545                     this.referenceWidth = this.width;
            +546                     this.referenceHeight = this.height;
            +547                     this.resize = mode;
            +548                     CAAT.registerResizeListener(this);
            +549                     this.onResizeCallback = onResizeCallback;
            +550                     this.windowResized(window.innerWidth, window.innerHeight);
            +551                 } else {
            +552                     CAAT.unregisterResizeListener(this);
            +553                     this.onResizeCallback = null;
            +554                 }
            +555 
            +556                 return this;
            +557             },
            +558 
            +559             __setupRetina : function() {
            +560 
            +561                 if ( CAAT.RETINA_DISPLAY_ENABLED ) {
            +562 
            +563                     // The world is full of opensource awesomeness.
            +564                     //
            +565                     // Source: http://www.html5rocks.com/en/tutorials/canvas/hidpi/
            +566                     //
            +567                     var devicePixelRatio= CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio;
            +568                     var backingStoreRatio = this.ctx.webkitBackingStorePixelRatio ||
            +569                                             this.ctx.mozBackingStorePixelRatio ||
            +570                                             this.ctx.msBackingStorePixelRatio ||
            +571                                             this.ctx.oBackingStorePixelRatio ||
            +572                                             this.ctx.backingStorePixelRatio ||
            +573                                             1;
            +574 
            +575                     var ratio = devicePixelRatio / backingStoreRatio;
            +576 
            +577                     if (devicePixelRatio !== backingStoreRatio) {
            +578 
            +579                         var oldWidth = this.canvas.width;
            +580                         var oldHeight = this.canvas.height;
            +581 
            +582                         this.canvas.width = oldWidth * ratio;
            +583                         this.canvas.height = oldHeight * ratio;
            +584 
            +585                         this.canvas.style.width = oldWidth + 'px';
            +586                         this.canvas.style.height = oldHeight + 'px';
            +587 
            +588                         this.setScaleAnchored( ratio, ratio, 0, 0 );
            +589                     } else {
            +590                         this.setScaleAnchored( 1, 1, 0, 0 );
            +591                     }
            +592 
            +593                     this.SCREEN_RATIO= ratio;
            +594                 } else {
            +595                     this.setScaleAnchored( 1, 1, 0, 0 );
            +596                 }
            +597 
            +598                 for (var i = 0; i < this.scenes.length; i++) {
            +599                     this.scenes[i].setBounds(0, 0, this.width, this.height);
            +600                 }
            +601             },
            +602 
            +603             /**
            +604              * Set this director's bounds as well as its contained scenes.
            +605              * @param x {number} ignored, will be 0.
            +606              * @param y {number} ignored, will be 0.
            +607              * @param w {number} director width.
            +608              * @param h {number} director height.
            +609              *
            +610              * @return this
            +611              */
            +612             setBounds:function (x, y, w, h) {
            +613 
            +614                 CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h);
            +615 
            +616                 if ( this.canvas.width!==w ) {
            +617                     this.canvas.width = w;
            +618                 }
            +619 
            +620                 if ( this.canvas.height!==h ) {
            +621                     this.canvas.height = h;
            +622                 }
            +623 
            +624                 this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d');
            +625 
            +626                 this.__setupRetina();
            +627 
            +628                 if (this.glEnabled) {
            +629                     this.glReset();
            +630                 }
            +631 
            +632                 return this;
            +633             },
            +634             /**
            +635              * This method performs Director initialization. Must be called once.
            +636              * If the canvas parameter is not set, it will create a Canvas itself,
            +637              * and the developer must explicitly add the canvas to the desired DOM position.
            +638              * This method will also set the Canvas dimension to the specified values
            +639              * by width and height parameters.
            +640              *
            +641              * @param width {number} a canvas width
            +642              * @param height {number} a canvas height
            +643              * @param canvas {HTMLCanvasElement=} An optional Canvas object.
            +644              * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements
            +645              *              and want events delivered to the correct element.
            +646              *
            +647              * @return this
            +648              */
            +649             initialize:function (width, height, canvas, proxy) {
            +650                 if ( typeof canvas!=="undefined" ) {
            +651                     if ( isString(canvas) ) {
            +652                         canvas= document.getElementById(canvas);
            +653                     } else if ( !(canvas instanceof HTMLCanvasElement ) ) {
            +654                         console.log("Canvas is a: "+canvas+" ???");
            +655                     }
            +656                 }
            +657 
            +658                 if (!canvas) {
            +659                     canvas = document.createElement('canvas');
            +660                     document.body.appendChild(canvas);
            +661                 }
            +662 
            +663                 this.canvas = canvas;
            +664 
            +665                 if (typeof proxy === 'undefined') {
            +666                     proxy = canvas;
            +667                 }
            +668 
            +669                 this.setBounds(0, 0, width, height);
            +670                 this.enableEvents(proxy);
            +671 
            +672                 this.timeline = new Date().getTime();
            +673 
            +674                 // transition scene
            +675                 if (CAAT.CACHE_SCENE_ON_CHANGE) {
            +676                     this.transitionScene = new CAAT.Foundation.Scene().setBounds(0, 0, width, height);
            +677                     var transitionCanvas = document.createElement('canvas');
            +678                     transitionCanvas.width = width;
            +679                     transitionCanvas.height = height;
            +680                     var transitionImageActor = new CAAT.Foundation.Actor().setBackgroundImage(transitionCanvas);
            +681                     this.transitionScene.ctx = transitionCanvas.getContext('2d');
            +682                     this.transitionScene.addChildImmediately(transitionImageActor);
            +683                     this.transitionScene.setEaseListener(this);
            +684                 }
            +685 
            +686                 this.checkDebug();
            +687 
            +688                 return this;
            +689             },
            +690             glReset:function () {
            +691                 this.pMatrix = CAAT.WebGL.GLU.makeOrtho(0, this.referenceWidth, this.referenceHeight, 0, -1, 1);
            +692                 this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
            +693                 this.glColorProgram.setMatrixUniform(this.pMatrix);
            +694                 this.glTextureProgram.setMatrixUniform(this.pMatrix);
            +695                 this.gl.viewportWidth = this.canvas.width;
            +696                 this.gl.viewportHeight = this.canvas.height;
            +697             },
            +698             /**
            +699              * Experimental.
            +700              * Initialize a gl enabled director.
            +701              */
            +702             initializeGL:function (width, height, canvas, proxy) {
            +703 
            +704                 if (!canvas) {
            +705                     canvas = document.createElement('canvas');
            +706                     document.body.appendChild(canvas);
            +707                 }
            +708 
            +709                 canvas.width = width;
            +710                 canvas.height = height;
            +711 
            +712                 if (typeof proxy === 'undefined') {
            +713                     proxy = canvas;
            +714                 }
            +715 
            +716                 this.referenceWidth = width;
            +717                 this.referenceHeight = height;
            +718 
            +719                 var i;
            +720 
            +721                 try {
            +722                     this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/);
            +723                     this.gl.viewportWidth = width;
            +724                     this.gl.viewportHeight = height;
            +725                     CAAT.GLRENDER = true;
            +726                 } catch (e) {
            +727                 }
            +728 
            +729                 if (this.gl) {
            +730                     this.canvas = canvas;
            +731                     this.setBounds(0, 0, width, height);
            +732 
            +733                     this.enableEvents(canvas);
            +734                     this.timeline = new Date().getTime();
            +735 
            +736                     this.glColorProgram = new CAAT.WebGL.ColorProgram(this.gl).create().initialize();
            +737                     this.glTextureProgram = new CAAT.WebGL.TextureProgram(this.gl).create().initialize();
            +738                     this.glTextureProgram.useProgram();
            +739                     this.glReset();
            +740 
            +741                     var maxTris = 512;
            +742                     this.coords = new Float32Array(maxTris * 12);
            +743                     this.uv = new Float32Array(maxTris * 8);
            +744 
            +745                     this.gl.clearColor(0.0, 0.0, 0.0, 255);
            +746 
            +747                     if (this.front_to_back) {
            +748                         this.gl.clearDepth(1.0);
            +749                         this.gl.enable(this.gl.DEPTH_TEST);
            +750                         this.gl.depthFunc(this.gl.LESS);
            +751                     } else {
            +752                         this.gl.disable(this.gl.DEPTH_TEST);
            +753                     }
            +754 
            +755                     this.gl.enable(this.gl.BLEND);
            +756 // Fix FF                this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
            +757                     this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
            +758                     this.glEnabled = true;
            +759 
            +760                     this.checkDebug();
            +761                 } else {
            +762                     // fallback to non gl enabled canvas.
            +763                     return this.initialize(width, height, canvas);
            +764                 }
            +765 
            +766                 return this;
            +767             },
            +768             /**
            +769              * Creates an initializes a Scene object.
            +770              * @return {CAAT.Scene}
            +771              */
            +772             createScene:function () {
            +773                 var scene = new CAAT.Scene();
            +774                 this.addScene(scene);
            +775                 return scene;
            +776             },
            +777             setImagesCache:function (imagesCache, tpW, tpH) {
            +778 
            +779                 if (!imagesCache || !imagesCache.length ) {
            +780                     return this;
            +781                 }
            +782 
            +783                 var i;
            +784 
            +785                 if (null !== this.glTextureManager) {
            +786                     this.glTextureManager.deletePages();
            +787                     this.glTextureManager = null;
            +788                 }
            +789 
            +790                 // delete previous image identifiers
            +791                 if (this.imagesCache) {
            +792                     var ids = [];
            +793                     for (i = 0; i < this.imagesCache.length; i++) {
            +794                         ids.push(this.imagesCache[i].id);
            +795                     }
            +796 
            +797                     for (i = 0; i < ids.length; i++) {
            +798                         delete this.imagesCache[ ids[i] ];
            +799                     }
            +800                 }
            +801 
            +802                 this.imagesCache = imagesCache;
            +803 
            +804                 if (imagesCache) {
            +805                     for (i = 0; i < imagesCache.length; i++) {
            +806                         this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image;
            +807                     }
            +808                 }
            +809 
            +810                 this.tpW = tpW || 2048;
            +811                 this.tpH = tpH || 2048;
            +812 
            +813                 this.updateGLPages();
            +814 
            +815                 return this;
            +816             },
            +817             updateGLPages:function () {
            +818                 if (this.glEnabled) {
            +819 
            +820                     this.glTextureManager = new CAAT.Module.TexturePacker.TexturePageManager();
            +821                     this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache);
            +822 
            +823                     this.currentTexturePage = this.glTextureManager.pages[0];
            +824                     this.glTextureProgram.setTexture(this.currentTexturePage.texture);
            +825                 }
            +826             },
            +827             setGLTexturePage:function (tp) {
            +828                 this.currentTexturePage = tp;
            +829                 this.glTextureProgram.setTexture(tp.texture);
            +830                 return this;
            +831             },
            +832             /**
            +833              * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this
            +834              * function will try to recreate the whole GL texture pages.
            +835              * If many handcrafted images are to be added to the director, some performance can be achieved by calling
            +836              * <code>director.addImage(id,image,false)</code> many times and a final call with
            +837              * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages.
            +838              *
            +839              * @param id {string|object} an identitifier to retrieve the image with
            +840              * @param image {Image|HTMLCanvasElement} image to add to cache
            +841              * @param noUpdateGL {!boolean} unless otherwise stated, the director will
            +842              *  try to recreate the texture pages.
            +843              */
            +844             addImage:function (id, image, noUpdateGL) {
            +845                 if (this.getImage(id)) {
            +846 //                    for (var i = 0; i < this.imagesCache.length; i++) {
            +847                     for( var i in this.imagesCache ) {
            +848                         if (this.imagesCache[i].id === id) {
            +849                             this.imagesCache[i].image = image;
            +850                             break;
            +851                         }
            +852                     }
            +853                     this.imagesCache[ id ] = image;
            +854                 } else {
            +855                     this.imagesCache.push({ id:id, image:image });
            +856                     this.imagesCache[id] = image;
            +857                 }
            +858 
            +859                 if (!!!noUpdateGL) {
            +860                     this.updateGLPages();
            +861                 }
            +862             },
            +863             deleteImage:function (id, noUpdateGL) {
            +864                 for (var i = 0; i < this.imagesCache.length; i++) {
            +865                     if (this.imagesCache[i].id === id) {
            +866                         delete this.imagesCache[id];
            +867                         this.imagesCache.splice(i, 1);
            +868                         break;
            +869                     }
            +870                 }
            +871                 if (!!!noUpdateGL) {
            +872                     this.updateGLPages();
            +873                 }
            +874             },
            +875             setGLCurrentOpacity:function (opacity) {
            +876                 this.currentOpacity = opacity;
            +877                 this.glTextureProgram.setAlpha(opacity);
            +878             },
            +879             /**
            +880              * Render buffered elements.
            +881              * @param vertex
            +882              * @param coordsIndex
            +883              * @param uv
            +884              */
            +885             glRender:function (vertex, coordsIndex, uv) {
            +886 
            +887                 vertex = vertex || this.coords;
            +888                 uv = uv || this.uv;
            +889                 coordsIndex = coordsIndex || this.coordsIndex;
            +890 
            +891                 var gl = this.gl;
            +892 
            +893                 var numTris = coordsIndex / 12 * 2;
            +894                 var numVertices = coordsIndex / 3;
            +895 
            +896                 this.glTextureProgram.updateVertexBuffer(vertex);
            +897                 this.glTextureProgram.updateUVBuffer(uv);
            +898 
            +899                 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0);
            +900 
            +901             },
            +902             glFlush:function () {
            +903                 if (this.coordsIndex !== 0) {
            +904                     this.glRender(this.coords, this.coordsIndex, this.uv);
            +905                 }
            +906                 this.coordsIndex = 0;
            +907                 this.uvIndex = 0;
            +908 
            +909                 this.statistics.draws++;
            +910             },
            +911 
            +912             findActorAtPosition:function (point) {
            +913 
            +914                 // z-order
            +915                 var cl = this.childrenList;
            +916                 for (var i = cl.length - 1; i >= 0; i--) {
            +917                     var child = this.childrenList[i];
            +918 
            +919                     var np = new CAAT.Math.Point(point.x, point.y, 0);
            +920                     var contained = child.findActorAtPosition(np);
            +921                     if (null !== contained) {
            +922                         return contained;
            +923                     }
            +924                 }
            +925 
            +926                 return this;
            +927             },
            +928 
            +929             /**
            +930              *
            +931              * Reset statistics information.
            +932              *
            +933              * @private
            +934              */
            +935             resetStats:function () {
            +936                 this.statistics.size_total = 0;
            +937                 this.statistics.size_active = 0;
            +938                 this.statistics.draws = 0;
            +939                 this.statistics.size_discarded_by_dirty_rects = 0;
            +940             },
            +941 
            +942             /**
            +943              * This is the entry point for the animation system of the Director.
            +944              * The director is fed with the elapsed time value to maintain a virtual timeline.
            +945              * This virtual timeline will provide each Scene with its own virtual timeline, and will only
            +946              * feed time when the Scene is the current Scene, or is being switched.
            +947              *
            +948              * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be
            +949              * set up as a single clip area.
            +950              *
            +951              * @param time {number} integer indicating the elapsed time between two consecutive frames of the
            +952              * Director.
            +953              */
            +954             render:function (time) {
            +955 
            +956                 if (this.currentScene && this.currentScene.isPaused()) {
            +957                     return;
            +958                 }
            +959 
            +960                 this.time += time;
            +961 
            +962                 for (i = 0, l = this.childrenList.length; i < l; i++) {
            +963                     var c = this.childrenList[i];
            +964                     if (c.isInAnimationFrame(this.time) && !c.isPaused()) {
            +965                         var tt = c.time - c.start_time;
            +966                         c.timerManager.checkTimers(tt);
            +967                         c.timerManager.removeExpiredTimers();
            +968                     }
            +969                 }
            +970 
            +971 
            +972                 this.animate(this, this.time);
            +973 
            +974                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +975                     this.resetStats();
            +976                 }
            +977 
            +978                 /**
            +979                  * draw director active scenes.
            +980                  */
            +981                 var ne = this.childrenList.length;
            +982                 var i, tt, c;
            +983                 var ctx = this.ctx;
            +984 
            +985                 if (this.glEnabled) {
            +986 
            +987                     this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
            +988                     this.coordsIndex = 0;
            +989                     this.uvIndex = 0;
            +990 
            +991                     for (i = 0; i < ne; i++) {
            +992                         c = this.childrenList[i];
            +993                         if (c.isInAnimationFrame(this.time)) {
            +994                             tt = c.time - c.start_time;
            +995                             if (c.onRenderStart) {
            +996                                 c.onRenderStart(tt);
            +997                             }
            +998                             c.paintActorGL(this, tt);
            +999                             if (c.onRenderEnd) {
            +1000                                 c.onRenderEnd(tt);
            +1001                             }
            +1002 
            +1003                             if (!c.isPaused()) {
            +1004                                 c.time += time;
            +1005                             }
            +1006 
            +1007                             if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +1008                                 this.statistics.size_total += c.size_total;
            +1009                                 this.statistics.size_active += c.size_active;
            +1010                             }
            +1011 
            +1012                         }
            +1013                     }
            +1014 
            +1015                     this.glFlush();
            +1016 
            +1017                 } else {
            +1018                     ctx.globalAlpha = 1;
            +1019                     ctx.globalCompositeOperation = 'source-over';
            +1020 
            +1021                     ctx.save();
            +1022                     if (this.dirtyRectsEnabled) {
            +1023                         this.modelViewMatrix.transformRenderingContext(ctx);
            +1024 
            +1025                         if (!CAAT.DEBUG_DIRTYRECTS) {
            +1026                             ctx.beginPath();
            +1027                             this.nDirtyRects = 0;
            +1028                             var dr = this.cDirtyRects;
            +1029                             for (i = 0; i < dr.length; i++) {
            +1030                                 var drr = dr[i];
            +1031                                 if (!drr.isEmpty()) {
            +1032                                     ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0));
            +1033                                     this.nDirtyRects++;
            +1034                                 }
            +1035                             }
            +1036                             ctx.clip();
            +1037                         } else {
            +1038                             ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
            +1039                         }
            +1040 
            +1041                     } else if (this.clear === CAAT.Foundation.Director.CLEAR_ALL) {
            +1042                         ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
            +1043                     }
            +1044 
            +1045                     for (i = 0; i < ne; i++) {
            +1046                         c = this.childrenList[i];
            +1047 
            +1048                         if (c.isInAnimationFrame(this.time)) {
            +1049                             tt = c.time - c.start_time;
            +1050                             ctx.save();
            +1051 
            +1052                             if (c.onRenderStart) {
            +1053                                 c.onRenderStart(tt);
            +1054                             }
            +1055 
            +1056                             if (!CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled) {
            +1057                                 if (this.nDirtyRects) {
            +1058                                     c.paintActor(this, tt);
            +1059                                 }
            +1060                             } else {
            +1061                                 c.paintActor(this, tt);
            +1062                             }
            +1063 
            +1064                             if (c.onRenderEnd) {
            +1065                                 c.onRenderEnd(tt);
            +1066                             }
            +1067                             ctx.restore();
            +1068 
            +1069                             if (CAAT.DEBUGAABB) {
            +1070                                 ctx.globalAlpha = 1;
            +1071                                 ctx.globalCompositeOperation = 'source-over';
            +1072                                 this.modelViewMatrix.transformRenderingContextSet(ctx);
            +1073                                 c.drawScreenBoundingBox(this, tt);
            +1074                             }
            +1075 
            +1076                             if (!c.isPaused()) {
            +1077                                 c.time += time;
            +1078                             }
            +1079 
            +1080                             if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +1081                                 this.statistics.size_total += c.size_total;
            +1082                                 this.statistics.size_active += c.size_active;
            +1083                                 this.statistics.size_dirtyRects = this.nDirtyRects;
            +1084                             }
            +1085 
            +1086                         }
            +1087                     }
            +1088 
            +1089                     if (this.nDirtyRects > 0 && (!navigator.isCocoonJS && CAAT.DEBUG) && CAAT.DEBUG_DIRTYRECTS) {
            +1090                         ctx.beginPath();
            +1091                         this.nDirtyRects = 0;
            +1092                         var dr = this.cDirtyRects;
            +1093                         for (i = 0; i < dr.length; i++) {
            +1094                             var drr = dr[i];
            +1095                             if (!drr.isEmpty()) {
            +1096                                 ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0));
            +1097                                 this.nDirtyRects++;
            +1098                             }
            +1099                         }
            +1100 
            +1101                         ctx.clip();
            +1102                         ctx.fillStyle = 'rgba(160,255,150,.4)';
            +1103                         ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
            +1104                     }
            +1105 
            +1106                     ctx.restore();
            +1107                 }
            +1108 
            +1109                 this.frameCounter++;
            +1110             },
            +1111 
            +1112             inDirtyRect:function (actor) {
            +1113 
            +1114                 if (!this.dirtyRectsEnabled || CAAT.DEBUG_DIRTYRECTS) {
            +1115                     return true;
            +1116                 }
            +1117 
            +1118                 var dr = this.cDirtyRects;
            +1119                 var i;
            +1120                 var aabb = actor.AABB;
            +1121 
            +1122                 for (i = 0; i < dr.length; i++) {
            +1123                     if (dr[i].intersects(aabb)) {
            +1124                         return true;
            +1125                     }
            +1126                 }
            +1127 
            +1128                 this.statistics.size_discarded_by_dirty_rects += actor.size_total;
            +1129                 return false;
            +1130             },
            +1131 
            +1132             /**
            +1133              * A director is a very special kind of actor.
            +1134              * Its animation routine simple sets its modelViewMatrix in case some transformation's been
            +1135              * applied.
            +1136              * No behaviors are allowed for Director instances.
            +1137              * @param director {CAAT.Director} redundant reference to CAAT.Director itself
            +1138              * @param time {number} director time.
            +1139              */
            +1140             animate:function (director, time) {
            +1141 
            +1142                 this.timerManager.checkTimers(time);
            +1143 
            +1144                 this.setModelViewMatrix(this);
            +1145                 this.modelViewMatrixI = this.modelViewMatrix.getInverse();
            +1146                 this.setScreenBounds();
            +1147 
            +1148                 this.dirty = false;
            +1149                 this.invalid = false;
            +1150                 this.dirtyRectsIndex = -1;
            +1151                 this.cDirtyRects= [];
            +1152 
            +1153                 var cl = this.childrenList;
            +1154                 var cli;
            +1155                 var i, l;
            +1156 
            +1157 
            +1158                 if (this.dirtyRectsEnabled) {
            +1159                     var sdr = this.sDirtyRects;
            +1160                     if (sdr.length) {
            +1161                         for (i = 0, l = sdr.length; i < l; i++) {
            +1162                             this.addDirtyRect(sdr[i]);
            +1163                         }
            +1164                         this.sDirtyRects = [];
            +1165                     }
            +1166                 }
            +1167 
            +1168                 for (i = 0; i < cl.length; i++) {
            +1169                     cli = cl[i];
            +1170                     var tt = cli.time - cli.start_time;
            +1171                     cli.animate(this, tt);
            +1172                 }
            +1173 
            +1174                 this.timerManager.removeExpiredTimers();
            +1175 
            +1176                 return this;
            +1177             },
            +1178 
            +1179             /**
            +1180              * This method is used when asynchronous operations must produce some dirty rectangle painting.
            +1181              * This means that every operation out of the regular CAAT loop must add dirty rect operations
            +1182              * by calling this method.
            +1183              * For example setVisible() and remove.
            +1184              * @param rectangle
            +1185              */
            +1186             scheduleDirtyRect:function (rectangle) {
            +1187                 this.sDirtyRects.push(rectangle);
            +1188             },
            +1189             /**
            +1190              * Add a rectangle to the list of dirty screen areas which should be redrawn.
            +1191              * This is the opposite method to clear the whole screen and repaint everything again.
            +1192              * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this
            +1193              * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or
            +1194              * even lowers performance under others, so it is a developer choice to activate them via a call to
            +1195              * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ).
            +1196              *
            +1197              * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping
            +1198              * rectangles will be removed and intersecting ones will be unioned.
            +1199              *
            +1200              * Before calling this method, check if this.dirtyRectsEnabled is true.
            +1201              *
            +1202              * @param rectangle {CAAT.Rectangle}
            +1203              */
            +1204             addDirtyRect:function (rectangle) {
            +1205 
            +1206                 if (rectangle.isEmpty()) {
            +1207                     return;
            +1208                 }
            +1209 
            +1210                 var i, dr, j, drj;
            +1211                 var cdr = this.cDirtyRects;
            +1212 
            +1213                 for (i = 0; i < cdr.length; i++) {
            +1214                     dr = cdr[i];
            +1215                     if (!dr.isEmpty() && dr.intersects(rectangle)) {
            +1216                         var intersected = true;
            +1217                         while (intersected) {
            +1218                             dr.unionRectangle(rectangle);
            +1219 
            +1220                             for (j = 0; j < cdr.length; j++) {
            +1221                                 if (j !== i) {
            +1222                                     drj = cdr[j];
            +1223                                     if (!drj.isEmpty() && drj.intersects(dr)) {
            +1224                                         dr.unionRectangle(drj);
            +1225                                         drj.setEmpty();
            +1226                                         break;
            +1227                                     }
            +1228                                 }
            +1229                             }
            +1230 
            +1231                             if (j == cdr.length) {
            +1232                                 intersected = false;
            +1233                             }
            +1234                         }
            +1235 
            +1236                         for (j = 0; j < cdr.length; j++) {
            +1237                             if (cdr[j].isEmpty()) {
            +1238                                 cdr.splice(j, 1);
            +1239                             }
            +1240                         }
            +1241 
            +1242                         return;
            +1243                     }
            +1244                 }
            +1245 
            +1246                 this.dirtyRectsIndex++;
            +1247 
            +1248                 if (this.dirtyRectsIndex >= this.dirtyRects.length) {
            +1249                     for (i = 0; i < 32; i++) {
            +1250                         this.dirtyRects.push(new CAAT.Math.Rectangle());
            +1251                     }
            +1252                 }
            +1253 
            +1254                 var r = this.dirtyRects[ this.dirtyRectsIndex ];
            +1255 
            +1256                 r.x = rectangle.x;
            +1257                 r.y = rectangle.y;
            +1258                 r.x1 = rectangle.x1;
            +1259                 r.y1 = rectangle.y1;
            +1260                 r.width = rectangle.width;
            +1261                 r.height = rectangle.height;
            +1262 
            +1263                 this.cDirtyRects.push(r);
            +1264 
            +1265             },
            +1266             /**
            +1267              * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of
            +1268              * another Scene (transitionScene). So instead of drawing two scenes while transitioning from
            +1269              * one to another, first of all an scene is drawn to offscreen, and that image is translated.
            +1270              * <p>
            +1271              * Until the creation of this method, both scenes where drawn while transitioning with
            +1272              * its performance penalty since drawing two scenes could be twice as expensive than drawing
            +1273              * only one.
            +1274              * <p>
            +1275              * Though a high performance increase, we should keep an eye on memory consumption.
            +1276              *
            +1277              * @param ctx a <code>canvas.getContext('2d')</code> instnce.
            +1278              * @param scene {CAAT.Foundation.Scene} the scene to draw offscreen.
            +1279              */
            +1280             renderToContext:function (ctx, scene) {
            +1281                 /**
            +1282                  * draw actors on scene.
            +1283                  */
            +1284                 if (scene.isInAnimationFrame(this.time)) {
            +1285                     ctx.setTransform(1, 0, 0, 1, 0, 0);
            +1286 
            +1287                     ctx.globalAlpha = 1;
            +1288                     ctx.globalCompositeOperation = 'source-over';
            +1289                     ctx.clearRect(0, 0, this.width, this.height);
            +1290 
            +1291                     var octx = this.ctx;
            +1292 
            +1293                     this.ctx = ctx;
            +1294                     ctx.save();
            +1295 
            +1296                     /**
            +1297                      * to draw an scene to an offscreen canvas, we have to:
            +1298                      *   1.- save diector's world model view matrix
            +1299                      *   2.- set no transformation on director since we want the offscreen to
            +1300                      *       be drawn 1:1.
            +1301                      *   3.- set world dirty flag, so that the scene will recalculate its matrices
            +1302                      *   4.- animate the scene
            +1303                      *   5.- paint the scene
            +1304                      *   6.- restore world model view matrix.
            +1305                      */
            +1306                     var matmv = this.modelViewMatrix;
            +1307                     var matwmv = this.worldModelViewMatrix;
            +1308                     this.worldModelViewMatrix = new CAAT.Math.Matrix();
            +1309                     this.modelViewMatrix = this.worldModelViewMatrix;
            +1310                     this.wdirty = true;
            +1311                     scene.animate(this, scene.time);
            +1312                     if (scene.onRenderStart) {
            +1313                         scene.onRenderStart(scene.time);
            +1314                     }
            +1315                     scene.paintActor(this, scene.time);
            +1316                     if (scene.onRenderEnd) {
            +1317                         scene.onRenderEnd(scene.time);
            +1318                     }
            +1319                     this.worldModelViewMatrix = matwmv;
            +1320                     this.modelViewMatrix = matmv;
            +1321 
            +1322                     ctx.restore();
            +1323 
            +1324                     this.ctx = octx;
            +1325                 }
            +1326             },
            +1327             /**
            +1328              * Add a new Scene to Director's Scene list. By adding a Scene to the Director
            +1329              * does not mean it will be immediately visible, you should explicitly call either
            +1330              * <ul>
            +1331              *  <li>easeIn
            +1332              *  <li>easeInOut
            +1333              *  <li>easeInOutRandom
            +1334              *  <li>setScene
            +1335              *  <li>or any of the scene switching methods
            +1336              * </ul>
            +1337              *
            +1338              * @param scene {CAAT.Foundation.Scene}
            +1339              */
            +1340             addScene:function (scene) {
            +1341                 scene.setBounds(0, 0, this.width, this.height);
            +1342                 this.scenes.push(scene);
            +1343                 scene.setEaseListener(this);
            +1344                 if (null === this.currentScene) {
            +1345                     this.setScene(0);
            +1346                 }
            +1347             },
            +1348             /**
            +1349              * Get the number of scenes contained in the Director.
            +1350              * @return {number} the number of scenes contained in the Director.
            +1351              */
            +1352             getNumScenes:function () {
            +1353                 return this.scenes.length;
            +1354             },
            +1355             /**
            +1356              * This method offers full control over the process of switching between any given two Scenes.
            +1357              * To apply this method, you must specify the type of transition to apply for each Scene and
            +1358              * the anchor to keep the Scene pinned at.
            +1359              * <p>
            +1360              * The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype:
            +1361              * <ul>
            +1362              *  <li>EASE_ROTATION
            +1363              *  <li>EASE_SCALE
            +1364              *  <li>EASE_TRANSLATION
            +1365              * </ul>
            +1366              *
            +1367              * <p>
            +1368              * The anchor will be any of these values defined in CAAT.Foundation.Actor:
            +1369              * <ul>
            +1370              *  <li>ANCHOR_CENTER
            +1371              *  <li>ANCHOR_TOP
            +1372              *  <li>ANCHOR_BOTTOM
            +1373              *  <li>ANCHOR_LEFT
            +1374              *  <li>ANCHOR_RIGHT
            +1375              *  <li>ANCHOR_TOP_LEFT
            +1376              *  <li>ANCHOR_TOP_RIGHT
            +1377              *  <li>ANCHOR_BOTTOM_LEFT
            +1378              *  <li>ANCHOR_BOTTOM_RIGHT
            +1379              * </ul>
            +1380              *
            +1381              * <p>
            +1382              * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the
            +1383              * point by which the scene will scaled.
            +1384              *
            +1385              * @param inSceneIndex integer indicating the Scene index to bring in to the Director.
            +1386              * @param typein integer indicating the type of transition to apply to the bringing in Scene.
            +1387              * @param anchorin integer indicating the anchor of the bringing in Scene.
            +1388              * @param outSceneIndex integer indicating the Scene index to take away from the Director.
            +1389              * @param typeout integer indicating the type of transition to apply to the taking away in Scene.
            +1390              * @param anchorout integer indicating the anchor of the taking away Scene.
            +1391              * @param time inteter indicating the time to perform the process of switchihg between Scene object
            +1392              * in milliseconds.
            +1393              * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to
            +1394              * the scenes.
            +1395              * @param interpolatorIn CAAT.Behavior.Interpolator object to apply to entering scene.
            +1396              * @param interpolatorOut CAAT.Behavior.Interpolator object to apply to exiting scene.
            +1397              */
            +1398             easeInOut:function (inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) {
            +1399 
            +1400                 if (inSceneIndex === this.getCurrentSceneIndex()) {
            +1401                     return;
            +1402                 }
            +1403 
            +1404                 var ssin = this.scenes[ inSceneIndex ];
            +1405                 var sout = this.scenes[ outSceneIndex ];
            +1406 
            +1407                 if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) {
            +1408                     this.renderToContext(this.transitionScene.ctx, sout);
            +1409                     sout = this.transitionScene;
            +1410                 }
            +1411 
            +1412                 ssin.setExpired(false);
            +1413                 sout.setExpired(false);
            +1414 
            +1415                 ssin.mouseEnabled = false;
            +1416                 sout.mouseEnabled = false;
            +1417 
            +1418                 ssin.resetTransform();
            +1419                 sout.resetTransform();
            +1420 
            +1421                 ssin.setLocation(0, 0);
            +1422                 sout.setLocation(0, 0);
            +1423 
            +1424                 ssin.alpha = 1;
            +1425                 sout.alpha = 1;
            +1426 
            +1427                 if (typein === CAAT.Foundation.Scene.EASE_ROTATION) {
            +1428                     ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn);
            +1429                 } else if (typein === CAAT.Foundation.Scene.EASE_SCALE) {
            +1430                     ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn);
            +1431                 } else {
            +1432                     ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn);
            +1433                 }
            +1434 
            +1435                 if (typeout === CAAT.Foundation.Scene.EASE_ROTATION) {
            +1436                     sout.easeRotationOut(time, alpha, anchorout, interpolatorOut);
            +1437                 } else if (typeout === CAAT.Foundation.Scene.EASE_SCALE) {
            +1438                     sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut);
            +1439                 } else {
            +1440                     sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut);
            +1441                 }
            +1442 
            +1443                 this.childrenList = [];
            +1444 
            +1445                 sout.goOut(ssin);
            +1446                 ssin.getIn(sout);
            +1447 
            +1448                 this.addChild(sout);
            +1449                 this.addChild(ssin);
            +1450             },
            +1451             /**
            +1452              * This method will switch between two given Scene indexes (ie, take away scene number 2,
            +1453              * and bring in scene number 5).
            +1454              * <p>
            +1455              * It will randomly choose for each Scene the type of transition to apply and the anchor
            +1456              * point of each transition type.
            +1457              * <p>
            +1458              * It will also set for different kind of transitions the following interpolators:
            +1459              * <ul>
            +1460              * <li>EASE_ROTATION    -> ExponentialInOutInterpolator, exponent 4.
            +1461              * <li>EASE_SCALE       -> ElasticOutInterpolator, 1.1 and .4
            +1462              * <li>EASE_TRANSLATION -> BounceOutInterpolator
            +1463              * </ul>
            +1464              *
            +1465              * <p>
            +1466              * These are the default values, and could not be changed by now.
            +1467              * This method in final instance delegates the process to easeInOutMethod.
            +1468              *
            +1469              * @see easeInOutMethod.
            +1470              *
            +1471              * @param inIndex integer indicating the entering scene index.
            +1472              * @param outIndex integer indicating the exiting scene index.
            +1473              * @param time integer indicating the time to take for the process of Scene in/out in milliseconds.
            +1474              * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions.
            +1475              */
            +1476             easeInOutRandom:function (inIndex, outIndex, time, alpha) {
            +1477 
            +1478                 var pin = Math.random();
            +1479                 var pout = Math.random();
            +1480 
            +1481                 var typeIn;
            +1482                 var interpolatorIn;
            +1483 
            +1484                 if (pin < 0.33) {
            +1485                     typeIn = CAAT.Foundation.Scene.EASE_ROTATION;
            +1486                     interpolatorIn = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4);
            +1487                 } else if (pin < 0.66) {
            +1488                     typeIn = CAAT.Foundation.Scene.EASE_SCALE;
            +1489                     interpolatorIn = new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4);
            +1490                 } else {
            +1491                     typeIn = CAAT.Foundation.Scene.EASE_TRANSLATE;
            +1492                     interpolatorIn = new CAAT.Behavior.Interpolator().createBounceOutInterpolator();
            +1493                 }
            +1494 
            +1495                 var typeOut;
            +1496                 var interpolatorOut;
            +1497 
            +1498                 if (pout < 0.33) {
            +1499                     typeOut = CAAT.Foundation.Scene.EASE_ROTATION;
            +1500                     interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4);
            +1501                 } else if (pout < 0.66) {
            +1502                     typeOut = CAAT.Foundation.Scene.EASE_SCALE;
            +1503                     interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4);
            +1504                 } else {
            +1505                     typeOut = CAAT.Foundation.Scene.EASE_TRANSLATE;
            +1506                     interpolatorOut = new CAAT.Behavior.Interpolator().createBounceOutInterpolator();
            +1507                 }
            +1508 
            +1509                 this.easeInOut(
            +1510                     inIndex,
            +1511                     typeIn,
            +1512                     (Math.random() * 8.99) >> 0,
            +1513 
            +1514                     outIndex,
            +1515                     typeOut,
            +1516                     (Math.random() * 8.99) >> 0,
            +1517 
            +1518                     time,
            +1519                     alpha,
            +1520 
            +1521                     interpolatorIn,
            +1522                     interpolatorOut);
            +1523 
            +1524             },
            +1525             /**
            +1526              * This method changes Director's current Scene to the scene index indicated by
            +1527              * inSceneIndex parameter. The Scene running in the director won't be eased out.
            +1528              *
            +1529              * @see {CAAT.Interpolator}
            +1530              * @see {CAAT.Actor}
            +1531              * @see {CAAT.Scene}
            +1532              *
            +1533              * @param inSceneIndex integer indicating the new Scene to set as current.
            +1534              * @param type integer indicating the type of transition to apply to bring the new current
            +1535              * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION,
            +1536              * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION.
            +1537              * @param time integer indicating how much time in milliseconds the Scene entrance will take.
            +1538              * @param alpha boolean indicating whether alpha transparency fading will be applied to the
            +1539              * entereing Scene.
            +1540              * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of
            +1541              * CAAT.Actor.prototype.ANCHOR_* values.
            +1542              * @param interpolator an CAAT.Interpolator object indicating the interpolation function to
            +1543              * apply.
            +1544              */
            +1545             easeIn:function (inSceneIndex, type, time, alpha, anchor, interpolator) {
            +1546                 var sin = this.scenes[ inSceneIndex ];
            +1547                 if (type === CAAT.Foundation.Scene.EASE_ROTATION) {
            +1548                     sin.easeRotationIn(time, alpha, anchor, interpolator);
            +1549                 } else if (type === CAAT.Foundation.Scene.EASE_SCALE) {
            +1550                     sin.easeScaleIn(0, time, alpha, anchor, interpolator);
            +1551                 } else {
            +1552                     sin.easeTranslationIn(time, alpha, anchor, interpolator);
            +1553                 }
            +1554                 this.childrenList = [];
            +1555                 this.addChild(sin);
            +1556 
            +1557                 sin.resetTransform();
            +1558                 sin.setLocation(0, 0);
            +1559                 sin.alpha = 1;
            +1560                 sin.mouseEnabled = false;
            +1561                 sin.setExpired(false);
            +1562             },
            +1563             /**
            +1564              * Changes (or sets) the current Director scene to the index
            +1565              * parameter. There will be no transition on scene change.
            +1566              * @param sceneIndex {number} an integer indicating the index of the target Scene
            +1567              * to be shown.
            +1568              */
            +1569             setScene:function (sceneIndex) {
            +1570                 var sin = this.scenes[ sceneIndex ];
            +1571                 this.childrenList = [];
            +1572                 this.addChild(sin);
            +1573                 this.currentScene = sin;
            +1574 
            +1575                 sin.setExpired(false);
            +1576                 sin.mouseEnabled = true;
            +1577                 sin.resetTransform();
            +1578                 sin.setLocation(0, 0);
            +1579                 sin.alpha = 1;
            +1580 
            +1581                 sin.getIn();
            +1582                 sin.activated();
            +1583             },
            +1584             /**
            +1585              * This method will change the current Scene by the Scene indicated as parameter.
            +1586              * It will apply random values for anchor and transition type.
            +1587              * @see easeInOutRandom
            +1588              *
            +1589              * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director.
            +1590              * @param time {number} an integer indicating the time the Scene transition will take.
            +1591              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
            +1592              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
            +1593              */
            +1594             switchToScene:function (iNewSceneIndex, time, alpha, transition) {
            +1595                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
            +1596 
            +1597                 if (!transition) {
            +1598                     this.setScene(iNewSceneIndex);
            +1599                 }
            +1600                 else {
            +1601                     this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha);
            +1602                 }
            +1603             },
            +1604             /**
            +1605              * Sets the previous Scene in sequence as the current Scene.
            +1606              * @see switchToScene.
            +1607              *
            +1608              * @param time {number} integer indicating the time the Scene transition will take.
            +1609              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
            +1610              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
            +1611              */
            +1612             switchToPrevScene:function (time, alpha, transition) {
            +1613 
            +1614                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
            +1615 
            +1616                 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) {
            +1617                     return;
            +1618                 }
            +1619 
            +1620                 if (!transition) {
            +1621                     this.setScene(currentSceneIndex - 1);
            +1622                 }
            +1623                 else {
            +1624                     this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha);
            +1625                 }
            +1626             },
            +1627             /**
            +1628              * Sets the previous Scene in sequence as the current Scene.
            +1629              * @see switchToScene.
            +1630              *
            +1631              * @param time {number} integer indicating the time the Scene transition will take.
            +1632              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
            +1633              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
            +1634              */
            +1635             switchToNextScene:function (time, alpha, transition) {
            +1636 
            +1637                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
            +1638 
            +1639                 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) {
            +1640                     return;
            +1641                 }
            +1642 
            +1643                 if (!transition) {
            +1644                     this.setScene(currentSceneIndex + 1);
            +1645                 }
            +1646                 else {
            +1647                     this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha);
            +1648                 }
            +1649             },
            +1650             mouseEnter:function (mouseEvent) {
            +1651             },
            +1652             mouseExit:function (mouseEvent) {
            +1653             },
            +1654             mouseMove:function (mouseEvent) {
            +1655             },
            +1656             mouseDown:function (mouseEvent) {
            +1657             },
            +1658             mouseUp:function (mouseEvent) {
            +1659             },
            +1660             mouseDrag:function (mouseEvent) {
            +1661             },
            +1662             /**
            +1663              * Scene easing listener. Notifies scenes when they're about to be activated (set as current
            +1664              * director's scene).
            +1665              *
            +1666              * @param scene {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director.
            +1667              * @param b_easeIn {boolean} scene enters or exits ?
            +1668              */
            +1669             easeEnd:function (scene, b_easeIn) {
            +1670                 // scene is going out
            +1671                 if (!b_easeIn) {
            +1672 
            +1673                     scene.setExpired(true);
            +1674                 } else {
            +1675                     this.currentScene = scene;
            +1676                     this.currentScene.activated();
            +1677                 }
            +1678 
            +1679                 scene.mouseEnabled = true;
            +1680                 scene.emptyBehaviorList();
            +1681             },
            +1682             /**
            +1683              * Return the index for a given Scene object contained in the Director.
            +1684              * @param scene {CAAT.Foundation.Scene}
            +1685              */
            +1686             getSceneIndex:function (scene) {
            +1687                 for (var i = 0; i < this.scenes.length; i++) {
            +1688                     if (this.scenes[i] === scene) {
            +1689                         return i;
            +1690                     }
            +1691                 }
            +1692                 return -1;
            +1693             },
            +1694             /**
            +1695              * Get a concrete director's scene.
            +1696              * @param index {number} an integer indicating the scene index.
            +1697              * @return {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob.
            +1698              */
            +1699             getScene:function (index) {
            +1700                 return this.scenes[index];
            +1701             },
            +1702             getSceneById : function(id) {
            +1703                 for( var i=0; i<this.scenes.length; i++ ) {
            +1704                     if (this.scenes[i].id===id) {
            +1705                         return this.scenes[i];
            +1706                     }
            +1707                 }
            +1708                 return null;
            +1709             },
            +1710             /**
            +1711              * Return the index of the current scene in the Director's scene list.
            +1712              * @return {number} the current scene's index.
            +1713              */
            +1714             getCurrentSceneIndex:function () {
            +1715                 return this.getSceneIndex(this.currentScene);
            +1716             },
            +1717             /**
            +1718              * Return the running browser name.
            +1719              * @return {string} the browser name.
            +1720              */
            +1721             getBrowserName:function () {
            +1722                 return this.browserInfo.browser;
            +1723             },
            +1724             /**
            +1725              * Return the running browser version.
            +1726              * @return {string} the browser version.
            +1727              */
            +1728             getBrowserVersion:function () {
            +1729                 return this.browserInfo.version;
            +1730             },
            +1731             /**
            +1732              * Return the operating system name.
            +1733              * @return {string} the os name.
            +1734              */
            +1735             getOSName:function () {
            +1736                 return this.browserInfo.OS;
            +1737             },
            +1738             /**
            +1739              * Gets the resource with the specified resource name.
            +1740              * The Director holds a collection called <code>imagesCache</code>
            +1741              * where you can store a JSON of the form
            +1742              *  <code>[ { id: imageId, image: imageObject } ]</code>.
            +1743              * This structure will be used as a resources cache.
            +1744              * There's a CAAT.Module.ImagePreloader class to preload resources and
            +1745              * generate this structure on loading finalization.
            +1746              *
            +1747              * @param sId {object} an String identifying a resource.
            +1748              */
            +1749             getImage:function (sId) {
            +1750                 var ret = this.imagesCache[sId];
            +1751                 if (ret) {
            +1752                     return ret;
            +1753                 }
            +1754 
            +1755                 //for (var i = 0; i < this.imagesCache.length; i++) {
            +1756                 for( var i in this.imagesCache ) {
            +1757                     if (this.imagesCache[i].id === sId) {
            +1758                         return this.imagesCache[i].image;
            +1759                     }
            +1760                 }
            +1761 
            +1762                 return null;
            +1763             },
            +1764             musicPlay: function(id) {
            +1765                 return this.audioManager.playMusic(id);
            +1766             },
            +1767             musicStop : function() {
            +1768                 this.audioManager.stopMusic();
            +1769             },
            +1770             /**
            +1771              * Adds an audio to the cache.
            +1772              *
            +1773              * @see CAAT.Module.Audio.AudioManager.addAudio
            +1774              * @return this
            +1775              */
            +1776             addAudio:function (id, url) {
            +1777                 this.audioManager.addAudio(id, url);
            +1778                 return this;
            +1779             },
            +1780             /**
            +1781              * Plays the audio instance identified by the id.
            +1782              * @param id {object} the object used to store a sound in the audioCache.
            +1783              */
            +1784             audioPlay:function (id) {
            +1785                 return this.audioManager.play(id);
            +1786             },
            +1787             /**
            +1788              * Loops an audio instance identified by the id.
            +1789              * @param id {object} the object used to store a sound in the audioCache.
            +1790              *
            +1791              * @return {HTMLElement|null} the value from audioManager.loop
            +1792              */
            +1793             audioLoop:function (id) {
            +1794                 return this.audioManager.loop(id);
            +1795             },
            +1796             endSound:function () {
            +1797                 return this.audioManager.endSound();
            +1798             },
            +1799             setSoundEffectsEnabled:function (enabled) {
            +1800                 return this.audioManager.setSoundEffectsEnabled(enabled);
            +1801             },
            +1802             setMusicEnabled:function (enabled) {
            +1803                 return this.audioManager.setMusicEnabled(enabled);
            +1804             },
            +1805             isMusicEnabled:function () {
            +1806                 return this.audioManager.isMusicEnabled();
            +1807             },
            +1808             isSoundEffectsEnabled:function () {
            +1809                 return this.audioManager.isSoundEffectsEnabled();
            +1810             },
            +1811             setVolume:function (id, volume) {
            +1812                 return this.audioManager.setVolume(id, volume);
            +1813             },
            +1814             /**
            +1815              * Removes Director's scenes.
            +1816              */
            +1817             emptyScenes:function () {
            +1818                 this.scenes = [];
            +1819             },
            +1820             /**
            +1821              * Adds an scene to this Director.
            +1822              * @param scene {CAAT.Foundation.Scene} a scene object.
            +1823              */
            +1824             addChild:function (scene) {
            +1825                 scene.parent = this;
            +1826                 this.childrenList.push(scene);
            +1827             },
            +1828             /**
            +1829              * @Deprecated use CAAT.loop instead.
            +1830              * @param fps
            +1831              * @param callback
            +1832              * @param callback2
            +1833              */
            +1834             loop:function (fps, callback, callback2) {
            +1835                 if (callback2) {
            +1836                     this.onRenderStart = callback;
            +1837                     this.onRenderEnd = callback2;
            +1838                 } else if (callback) {
            +1839                     this.onRenderEnd = callback;
            +1840                 }
            +1841                 CAAT.loop();
            +1842             },
            +1843             /**
            +1844              * Starts the director animation.If no scene is explicitly selected, the current Scene will
            +1845              * be the first scene added to the Director.
            +1846              * <p>
            +1847              * The fps parameter will set the animation quality. Higher values,
            +1848              * means CAAT will try to render more frames in the same second (at the
            +1849              * expense of cpu power at least until hardware accelerated canvas rendering
            +1850              * context are available). A value of 60 is a high frame rate and should not be exceeded.
            +1851              *
            +1852              */
            +1853             renderFrame:function () {
            +1854 
            +1855                 CAAT.currentDirector = this;
            +1856 
            +1857                 if (this.stopped) {
            +1858                     return;
            +1859                 }
            +1860 
            +1861                 var t = new Date().getTime(),
            +1862                     delta = t - this.timeline;
            +1863 
            +1864                 /*
            +1865                  check for massive frame time. if for example the current browser tab is minified or taken out of
            +1866                  foreground, the system will account for a bit time interval. minify that impact by lowering down
            +1867                  the elapsed time (virtual timelines FTW)
            +1868                  */
            +1869                 if (delta > 500) {
            +1870                     delta = 500;
            +1871                 }
            +1872 
            +1873                 if (this.onRenderStart) {
            +1874                     this.onRenderStart(delta);
            +1875                 }
            +1876 
            +1877                 this.render(delta);
            +1878 
            +1879                 if (this.debugInfo) {
            +1880                     this.debugInfo(this.statistics);
            +1881                 }
            +1882 
            +1883                 this.timeline = t;
            +1884 
            +1885                 if (this.onRenderEnd) {
            +1886                     this.onRenderEnd(delta);
            +1887                 }
            +1888 
            +1889                 this.needsRepaint = false;
            +1890             },
            +1891 
            +1892             /**
            +1893              * If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement.
            +1894              */
            +1895             resetTimeline:function () {
            +1896                 this.timeline = new Date().getTime();
            +1897             },
            +1898 
            +1899             endLoop:function () {
            +1900             },
            +1901             /**
            +1902              * This method states whether the director must clear background before rendering
            +1903              * each frame.
            +1904              *
            +1905              * The clearing method could be:
            +1906              *  + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it.
            +1907              *  + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled
            +1908              *    will have their areas redrawn.
            +1909              *  + CAAT.Director.CLEAR_NONE. clears nothing.
            +1910              *
            +1911              * @param clear {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS}
            +1912              * @return this.
            +1913              */
            +1914             setClear:function (clear) {
            +1915                 this.clear = clear;
            +1916                 if (this.clear === CAAT.Foundation.Director.CLEAR_DIRTY_RECTS) {
            +1917                     this.dirtyRectsEnabled = true;
            +1918                 } else {
            +1919                     this.dirtyRectsEnabled= false;
            +1920                 }
            +1921                 return this;
            +1922             },
            +1923             /**
            +1924              * Get this Director's AudioManager instance.
            +1925              * @return {CAAT.AudioManager} the AudioManager instance.
            +1926              */
            +1927             getAudioManager:function () {
            +1928                 return this.audioManager;
            +1929             },
            +1930             /**
            +1931              * Acculumate dom elements position to properly offset on-screen mouse/touch events.
            +1932              * @param node
            +1933              */
            +1934             cumulateOffset:function (node, parent, prop) {
            +1935                 var left = prop + 'Left';
            +1936                 var top = prop + 'Top';
            +1937                 var x = 0, y = 0, style;
            +1938 
            +1939                 while (navigator.browser !== 'iOS' && node && node.style) {
            +1940                     if (node.currentStyle) {
            +1941                         style = node.currentStyle['position'];
            +1942                     } else {
            +1943                         style = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null);
            +1944                         style = style ? style.getPropertyValue('position') : null;
            +1945                     }
            +1946 
            +1947 //                if (!/^(relative|absolute|fixed)$/.test(style)) {
            +1948                     if (!/^(fixed)$/.test(style)) {
            +1949                         x += node[left];
            +1950                         y += node[top];
            +1951                         node = node[parent];
            +1952                     } else {
            +1953                         break;
            +1954                     }
            +1955                 }
            +1956 
            +1957                 return {
            +1958                     x:x,
            +1959                     y:y,
            +1960                     style:style
            +1961                 };
            +1962             },
            +1963             getOffset:function (node) {
            +1964                 var res = this.cumulateOffset(node, 'offsetParent', 'offset');
            +1965                 if (res.style === 'fixed') {
            +1966                     var res2 = this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll');
            +1967                     return {
            +1968                         x:res.x + res2.x,
            +1969                         y:res.y + res2.y
            +1970                     };
            +1971                 }
            +1972 
            +1973                 return {
            +1974                     x:res.x,
            +1975                     y:res.y
            +1976                 };
            +1977             },
            +1978             /**
            +1979              * Normalize input event coordinates to be related to (0,0) canvas position.
            +1980              * @param point {CAAT.Math.Point} canvas coordinate.
            +1981              * @param e {MouseEvent} a mouse event from an input event.
            +1982              */
            +1983             getCanvasCoord:function (point, e) {
            +1984 
            +1985                 var pt = new CAAT.Math.Point();
            +1986                 var posx = 0;
            +1987                 var posy = 0;
            +1988                 if (!e) e = window.event;
            +1989 
            +1990                 if (e.pageX || e.pageY) {
            +1991                     posx = e.pageX;
            +1992                     posy = e.pageY;
            +1993                 }
            +1994                 else if (e.clientX || e.clientY) {
            +1995                     posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            +1996                     posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
            +1997                 }
            +1998 
            +1999                 var offset = this.getOffset(this.canvas);
            +2000 
            +2001                 posx -= offset.x;
            +2002                 posy -= offset.y;
            +2003 
            +2004                 posx*= this.SCREEN_RATIO;
            +2005                 posy*= this.SCREEN_RATIO;
            +2006 
            +2007                 //////////////
            +2008                 // transformar coordenada inversamente con affine transform de director.
            +2009 
            +2010                 pt.x = posx;
            +2011                 pt.y = posy;
            +2012                 if (!this.modelViewMatrixI) {
            +2013                     this.modelViewMatrixI = this.modelViewMatrix.getInverse();
            +2014                 }
            +2015                 this.modelViewMatrixI.transformCoord(pt);
            +2016                 posx = pt.x;
            +2017                 posy = pt.y
            +2018 
            +2019                 point.set(posx, posy);
            +2020                 this.screenMousePoint.set(posx, posy);
            +2021 
            +2022             },
            +2023 
            +2024             __mouseDownHandler:function (e) {
            +2025 
            +2026                 /*
            +2027                  was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no
            +2028                  button was presses. Then, send a mouseUp for the previos actor, and return;
            +2029                  */
            +2030                 if (this.dragging && this.lastSelectedActor) {
            +2031                     this.__mouseUpHandler(e);
            +2032                     return;
            +2033                 }
            +2034 
            +2035                 this.getCanvasCoord(this.mousePoint, e);
            +2036                 this.isMouseDown = true;
            +2037                 var lactor = this.findActorAtPosition(this.mousePoint);
            +2038 
            +2039                 if (null !== lactor) {
            +2040 
            +2041                     var pos = lactor.viewToModel(
            +2042                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2043 
            +2044                     lactor.mouseDown(
            +2045                         new CAAT.Event.MouseEvent().init(
            +2046                             pos.x,
            +2047                             pos.y,
            +2048                             e,
            +2049                             lactor,
            +2050                             new CAAT.Math.Point(
            +2051                                 this.screenMousePoint.x,
            +2052                                 this.screenMousePoint.y)));
            +2053                 }
            +2054 
            +2055                 this.lastSelectedActor = lactor;
            +2056             },
            +2057 
            +2058             __mouseUpHandler:function (e) {
            +2059 
            +2060                 this.isMouseDown = false;
            +2061                 this.getCanvasCoord(this.mousePoint, e);
            +2062 
            +2063                 var pos = null;
            +2064                 var lactor = this.lastSelectedActor;
            +2065 
            +2066                 if (null !== lactor) {
            +2067                     pos = lactor.viewToModel(
            +2068                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2069                     if (lactor.actionPerformed && lactor.contains(pos.x, pos.y)) {
            +2070                         lactor.actionPerformed(e)
            +2071                     }
            +2072 
            +2073                     lactor.mouseUp(
            +2074                         new CAAT.Event.MouseEvent().init(
            +2075                             pos.x,
            +2076                             pos.y,
            +2077                             e,
            +2078                             lactor,
            +2079                             this.screenMousePoint,
            +2080                             this.currentScene.time));
            +2081                 }
            +2082 
            +2083                 if (!this.dragging && null !== lactor) {
            +2084                     if (lactor.contains(pos.x, pos.y)) {
            +2085                         lactor.mouseClick(
            +2086                             new CAAT.Event.MouseEvent().init(
            +2087                                 pos.x,
            +2088                                 pos.y,
            +2089                                 e,
            +2090                                 lactor,
            +2091                                 this.screenMousePoint,
            +2092                                 this.currentScene.time));
            +2093                     }
            +2094                 }
            +2095 
            +2096                 this.dragging = false;
            +2097                 this.in_ = false;
            +2098 //            CAAT.setCursor('default');
            +2099             },
            +2100 
            +2101             __mouseMoveHandler:function (e) {
            +2102                 //this.getCanvasCoord(this.mousePoint, e);
            +2103 
            +2104                 var lactor;
            +2105                 var pos;
            +2106 
            +2107                 var ct = this.currentScene ? this.currentScene.time : 0;
            +2108 
            +2109                 // drag
            +2110 
            +2111                 if (this.isMouseDown && null!==this.lastSelectedActor) {
            +2112 
            +2113                     lactor = this.lastSelectedActor;
            +2114                     pos = lactor.viewToModel(
            +2115                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2116 
            +2117                     // check for mouse move threshold.
            +2118                     if (!this.dragging) {
            +2119                         if (Math.abs(this.prevMousePoint.x - pos.x) < CAAT.DRAG_THRESHOLD_X &&
            +2120                             Math.abs(this.prevMousePoint.y - pos.y) < CAAT.DRAG_THRESHOLD_Y) {
            +2121                             return;
            +2122                         }
            +2123                     }
            +2124 
            +2125                     this.dragging = true;
            +2126 
            +2127                     var px = lactor.x;
            +2128                     var py = lactor.y;
            +2129                     lactor.mouseDrag(
            +2130                         new CAAT.Event.MouseEvent().init(
            +2131                             pos.x,
            +2132                             pos.y,
            +2133                             e,
            +2134                             lactor,
            +2135                             new CAAT.Math.Point(
            +2136                                 this.screenMousePoint.x,
            +2137                                 this.screenMousePoint.y),
            +2138                             ct));
            +2139 
            +2140                     this.prevMousePoint.x = pos.x;
            +2141                     this.prevMousePoint.y = pos.y;
            +2142 
            +2143                     /**
            +2144                      * Element has not moved after drag, so treat it as a button.
            +2145                      */
            +2146                     if (px === lactor.x && py === lactor.y) {
            +2147 
            +2148                         var contains = lactor.contains(pos.x, pos.y);
            +2149 
            +2150                         if (this.in_ && !contains) {
            +2151                             lactor.mouseExit(
            +2152                                 new CAAT.Event.MouseEvent().init(
            +2153                                     pos.x,
            +2154                                     pos.y,
            +2155                                     e,
            +2156                                     lactor,
            +2157                                     this.screenMousePoint,
            +2158                                     ct));
            +2159                             this.in_ = false;
            +2160                         }
            +2161 
            +2162                         if (!this.in_ && contains) {
            +2163                             lactor.mouseEnter(
            +2164                                 new CAAT.Event.MouseEvent().init(
            +2165                                     pos.x,
            +2166                                     pos.y,
            +2167                                     e,
            +2168                                     lactor,
            +2169                                     this.screenMousePoint,
            +2170                                     ct));
            +2171                             this.in_ = true;
            +2172                         }
            +2173                     }
            +2174 
            +2175                     return;
            +2176                 }
            +2177 
            +2178                 // mouse move.
            +2179                 this.in_ = true;
            +2180 
            +2181                 lactor = this.findActorAtPosition(this.mousePoint);
            +2182 
            +2183                 // cambiamos de actor.
            +2184                 if (lactor !== this.lastSelectedActor) {
            +2185                     if (null !== this.lastSelectedActor) {
            +2186 
            +2187                         pos = this.lastSelectedActor.viewToModel(
            +2188                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2189 
            +2190                         this.lastSelectedActor.mouseExit(
            +2191                             new CAAT.Event.MouseEvent().init(
            +2192                                 pos.x,
            +2193                                 pos.y,
            +2194                                 e,
            +2195                                 this.lastSelectedActor,
            +2196                                 this.screenMousePoint,
            +2197                                 ct));
            +2198                     }
            +2199 
            +2200                     if (null !== lactor) {
            +2201                         pos = lactor.viewToModel(
            +2202                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2203 
            +2204                         lactor.mouseEnter(
            +2205                             new CAAT.Event.MouseEvent().init(
            +2206                                 pos.x,
            +2207                                 pos.y,
            +2208                                 e,
            +2209                                 lactor,
            +2210                                 this.screenMousePoint,
            +2211                                 ct));
            +2212                     }
            +2213                 }
            +2214 
            +2215                 pos = lactor.viewToModel(
            +2216                     new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2217 
            +2218                 if (null !== lactor) {
            +2219 
            +2220                     lactor.mouseMove(
            +2221                         new CAAT.Event.MouseEvent().init(
            +2222                             pos.x,
            +2223                             pos.y,
            +2224                             e,
            +2225                             lactor,
            +2226                             this.screenMousePoint,
            +2227                             ct));
            +2228                 }
            +2229 
            +2230                 this.prevMousePoint.x = pos.x;
            +2231                 this.prevMousePoint.y = pos.y;
            +2232 
            +2233                 this.lastSelectedActor = lactor;
            +2234             },
            +2235 
            +2236             __mouseOutHandler:function (e) {
            +2237 
            +2238                 if (this.dragging) {
            +2239                     return;
            +2240                 }
            +2241 
            +2242                 if (null !== this.lastSelectedActor) {
            +2243 
            +2244                     this.getCanvasCoord(this.mousePoint, e);
            +2245                     var pos = new CAAT.Math.Point(this.mousePoint.x, this.mousePoint.y, 0);
            +2246                     this.lastSelectedActor.viewToModel(pos);
            +2247 
            +2248                     var ev = new CAAT.Event.MouseEvent().init(
            +2249                         pos.x,
            +2250                         pos.y,
            +2251                         e,
            +2252                         this.lastSelectedActor,
            +2253                         this.screenMousePoint,
            +2254                         this.currentScene.time);
            +2255 
            +2256                     this.lastSelectedActor.mouseExit(ev);
            +2257                     this.lastSelectedActor.mouseOut(ev);
            +2258                     if (!this.dragging) {
            +2259                         this.lastSelectedActor = null;
            +2260                     }
            +2261                 } else {
            +2262                     this.isMouseDown = false;
            +2263                     this.in_ = false;
            +2264 
            +2265                 }
            +2266 
            +2267             },
            +2268 
            +2269             __mouseOverHandler:function (e) {
            +2270 
            +2271                 if (this.dragging) {
            +2272                     return;
            +2273                 }
            +2274 
            +2275                 var lactor;
            +2276                 var pos, ev;
            +2277 
            +2278                 if (null == this.lastSelectedActor) {
            +2279                     lactor = this.findActorAtPosition(this.mousePoint);
            +2280 
            +2281                     if (null !== lactor) {
            +2282 
            +2283                         pos = lactor.viewToModel(
            +2284                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2285 
            +2286                         ev = new CAAT.Event.MouseEvent().init(
            +2287                             pos.x,
            +2288                             pos.y,
            +2289                             e,
            +2290                             lactor,
            +2291                             this.screenMousePoint,
            +2292                             this.currentScene ? this.currentScene.time : 0);
            +2293 
            +2294                         lactor.mouseOver(ev);
            +2295                         lactor.mouseEnter(ev);
            +2296                     }
            +2297 
            +2298                     this.lastSelectedActor = lactor;
            +2299                 } else {
            +2300                     lactor = this.lastSelectedActor;
            +2301                     pos = lactor.viewToModel(
            +2302                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2303 
            +2304                     ev = new CAAT.Event.MouseEvent().init(
            +2305                         pos.x,
            +2306                         pos.y,
            +2307                         e,
            +2308                         lactor,
            +2309                         this.screenMousePoint,
            +2310                         this.currentScene.time);
            +2311 
            +2312                     lactor.mouseOver(ev);
            +2313                     lactor.mouseEnter(ev);
            +2314 
            +2315                 }
            +2316             },
            +2317 
            +2318             __mouseDBLClickHandler:function (e) {
            +2319 
            +2320                 this.getCanvasCoord(this.mousePoint, e);
            +2321                 if (null !== this.lastSelectedActor) {
            +2322                     /*
            +2323                      var pos = this.lastSelectedActor.viewToModel(
            +2324                      new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
            +2325                      */
            +2326                     this.lastSelectedActor.mouseDblClick(
            +2327                         new CAAT.Event.MouseEvent().init(
            +2328                             this.mousePoint.x,
            +2329                             this.mousePoint.y,
            +2330                             e,
            +2331                             this.lastSelectedActor,
            +2332                             this.screenMousePoint,
            +2333                             this.currentScene.time));
            +2334                 }
            +2335             },
            +2336 
            +2337             /**
            +2338              * Same as mouseDown but not preventing event.
            +2339              * Will only take care of first touch.
            +2340              * @param e
            +2341              */
            +2342             __touchStartHandler:function (e) {
            +2343 
            +2344                 if (e.target === this.canvas) {
            +2345                     e.preventDefault();
            +2346                     e.returnValue = false;
            +2347 
            +2348                     e = e.targetTouches[0];
            +2349 
            +2350                     var mp = this.mousePoint;
            +2351                     this.getCanvasCoord(mp, e);
            +2352                     if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) {
            +2353                         return;
            +2354                     }
            +2355 
            +2356                     this.touching = true;
            +2357 
            +2358                     this.__mouseDownHandler(e);
            +2359                 }
            +2360             },
            +2361 
            +2362             __touchEndHandler:function (e) {
            +2363 
            +2364                 if (this.touching) {
            +2365                     e.preventDefault();
            +2366                     e.returnValue = false;
            +2367 
            +2368                     e = e.changedTouches[0];
            +2369                     var mp = this.mousePoint;
            +2370                     this.getCanvasCoord(mp, e);
            +2371 
            +2372                     this.touching = false;
            +2373 
            +2374                     this.__mouseUpHandler(e);
            +2375                 }
            +2376             },
            +2377 
            +2378             __touchMoveHandler:function (e) {
            +2379 
            +2380                 if (this.touching) {
            +2381                     e.preventDefault();
            +2382                     e.returnValue = false;
            +2383 
            +2384                     if (this.gesturing) {
            +2385                         return;
            +2386                     }
            +2387 
            +2388                     for (var i = 0; i < e.targetTouches.length; i++) {
            +2389                         var ee = e.targetTouches[i];
            +2390                         var mp = this.mousePoint;
            +2391                         this.getCanvasCoord(mp, ee);
            +2392                         this.__mouseMoveHandler(ee);
            +2393                     }
            +2394                 }
            +2395             },
            +2396 
            +2397             __gestureStart:function (scale, rotation) {
            +2398                 this.gesturing = true;
            +2399                 this.__gestureRotation = this.lastSelectedActor.rotationAngle;
            +2400                 this.__gestureSX = this.lastSelectedActor.scaleX - 1;
            +2401                 this.__gestureSY = this.lastSelectedActor.scaleY - 1;
            +2402             },
            +2403 
            +2404             __gestureChange:function (scale, rotation) {
            +2405                 if (typeof scale === 'undefined' || typeof rotation === 'undefined') {
            +2406                     return;
            +2407                 }
            +2408 
            +2409                 if (this.lastSelectedActor !== null && this.lastSelectedActor.isGestureEnabled()) {
            +2410                     this.lastSelectedActor.setRotation(rotation * Math.PI / 180 + this.__gestureRotation);
            +2411 
            +2412                     this.lastSelectedActor.setScale(
            +2413                         this.__gestureSX + scale,
            +2414                         this.__gestureSY + scale);
            +2415                 }
            +2416 
            +2417             },
            +2418 
            +2419             __gestureEnd:function (scale, rotation) {
            +2420                 this.gesturing = false;
            +2421                 this.__gestureRotation = 0;
            +2422                 this.__gestureScale = 0;
            +2423             },
            +2424 
            +2425             __touchEndHandlerMT:function (e) {
            +2426 
            +2427                 e.preventDefault();
            +2428                 e.returnValue = false;
            +2429 
            +2430                 var i, j;
            +2431                 var recent = [];
            +2432 
            +2433                 /**
            +2434                  * extrae actores afectados, y coordenadas relativas para ellos.
            +2435                  * crear una coleccion touch-id : { actor, touch-event }
            +2436                  */
            +2437                 for (i = 0; i < e.changedTouches.length; i++) {
            +2438                     var _touch = e.changedTouches[i];
            +2439                     var id = _touch.identifier;
            +2440                     recent.push(id);
            +2441                 }
            +2442 
            +2443 
            +2444                 /**
            +2445                  * para los touch identificados, extraer que actores se han afectado.
            +2446                  * crear eventos con la info de touch para cada uno.
            +2447                  */
            +2448 
            +2449                 var actors = {};
            +2450                 for (i = 0; i < recent.length; i++) {
            +2451                     var touchId = recent[ i ];
            +2452                     if (this.touches[ touchId ]) {
            +2453                         var actor = this.touches[ touchId ].actor;
            +2454 
            +2455                         if (!actors[actor.id]) {
            +2456                             actors[actor.id] = {
            +2457                                 actor:actor,
            +2458                                 touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
            +2459                             };
            +2460                         }
            +2461 
            +2462                         var ev = actors[ actor.id ].touch;
            +2463                         ev.addChangedTouch(this.touches[ touchId ].touch);
            +2464                     }
            +2465                 }
            +2466 
            +2467                 /**
            +2468                  * remove ended touch info.
            +2469                  */
            +2470                 for (i = 0; i < e.changedTouches.length; i++) {
            +2471                     var touch = e.changedTouches[i];
            +2472                     var id = touch.identifier;
            +2473                     delete this.touches[id];
            +2474                 }
            +2475 
            +2476                 /**
            +2477                  * notificar a todos los actores.
            +2478                  */
            +2479                 for (var pr in actors) {
            +2480                     var data = actors[pr];
            +2481                     var actor = data.actor;
            +2482                     var touch = data.touch;
            +2483 
            +2484                     for (var actorId in this.touches) {
            +2485                         var tt = this.touches[actorId]
            +2486                         if (tt.actor.id === actor.id) {
            +2487                             touch.addTouch(tt.touch);
            +2488                         }
            +2489                     }
            +2490 
            +2491                     actor.touchEnd(touch);
            +2492                 }
            +2493             },
            +2494 
            +2495             __touchMoveHandlerMT:function (e) {
            +2496 
            +2497                 e.preventDefault();
            +2498                 e.returnValue = false;
            +2499 
            +2500                 var i;
            +2501                 var recent = [];
            +2502 
            +2503                 /**
            +2504                  * extrae actores afectados, y coordenadas relativas para ellos.
            +2505                  * crear una coleccion touch-id : { actor, touch-event }
            +2506                  */
            +2507                 for (i = 0; i < e.changedTouches.length; i++) {
            +2508                     var touch = e.changedTouches[i];
            +2509                     var id = touch.identifier;
            +2510 
            +2511                     if (this.touches[ id ]) {
            +2512                         var mp = this.mousePoint;
            +2513                         this.getCanvasCoord(mp, touch);
            +2514 
            +2515                         var actor = this.touches[ id ].actor;
            +2516                         mp = actor.viewToModel(mp);
            +2517 
            +2518                         this.touches[ id ] = {
            +2519                             actor:actor,
            +2520                             touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor)
            +2521                         };
            +2522 
            +2523                         recent.push(id);
            +2524                     }
            +2525                 }
            +2526 
            +2527                 /**
            +2528                  * para los touch identificados, extraer que actores se han afectado.
            +2529                  * crear eventos con la info de touch para cada uno.
            +2530                  */
            +2531 
            +2532                 var actors = {};
            +2533                 for (i = 0; i < recent.length; i++) {
            +2534                     var touchId = recent[ i ];
            +2535                     var actor = this.touches[ touchId ].actor;
            +2536 
            +2537                     if (!actors[actor.id]) {
            +2538                         actors[actor.id] = {
            +2539                             actor:actor,
            +2540                             touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
            +2541                         };
            +2542                     }
            +2543 
            +2544                     var ev = actors[ actor.id ].touch;
            +2545                     ev.addTouch(this.touches[ touchId ].touch);
            +2546                     ev.addChangedTouch(this.touches[ touchId ].touch);
            +2547                 }
            +2548 
            +2549                 /**
            +2550                  * notificar a todos los actores.
            +2551                  */
            +2552                 for (var pr in actors) {
            +2553                     var data = actors[pr];
            +2554                     var actor = data.actor;
            +2555                     var touch = data.touch;
            +2556 
            +2557                     for (var actorId in this.touches) {
            +2558                         var tt = this.touches[actorId]
            +2559                         if (tt.actor.id === actor.id) {
            +2560                             touch.addTouch(tt.touch);
            +2561                         }
            +2562                     }
            +2563 
            +2564                     actor.touchMove(touch);
            +2565                 }
            +2566             },
            +2567 
            +2568             __touchCancelHandleMT:function (e) {
            +2569                 this.__touchEndHandlerMT(e);
            +2570             },
            +2571 
            +2572             __touchStartHandlerMT:function (e) {
            +2573                 e.preventDefault();
            +2574                 e.returnValue = false;
            +2575 
            +2576                 var i;
            +2577                 var recent = [];
            +2578                 var allInCanvas = true;
            +2579 
            +2580                 /**
            +2581                  * extrae actores afectados, y coordenadas relativas para ellos.
            +2582                  * crear una coleccion touch-id : { actor, touch-event }
            +2583                  */
            +2584                 for (i = 0; i < e.changedTouches.length; i++) {
            +2585                     var touch = e.changedTouches[i];
            +2586                     var id = touch.identifier;
            +2587                     var mp = this.mousePoint;
            +2588                     this.getCanvasCoord(mp, touch);
            +2589                     if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) {
            +2590                         allInCanvas = false;
            +2591                         continue;
            +2592                     }
            +2593 
            +2594                     var actor = this.findActorAtPosition(mp);
            +2595                     if (actor !== null) {
            +2596                         mp = actor.viewToModel(mp);
            +2597 
            +2598                         if (!this.touches[ id ]) {
            +2599 
            +2600                             this.touches[ id ] = {
            +2601                                 actor:actor,
            +2602                                 touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor)
            +2603                             };
            +2604 
            +2605                             recent.push(id);
            +2606                         }
            +2607 
            +2608                     }
            +2609                 }
            +2610 
            +2611                 /**
            +2612                  * para los touch identificados, extraer que actores se han afectado.
            +2613                  * crear eventos con la info de touch para cada uno.
            +2614                  */
            +2615 
            +2616                 var actors = {};
            +2617                 for (i = 0; i < recent.length; i++) {
            +2618                     var touchId = recent[ i ];
            +2619                     var actor = this.touches[ touchId ].actor;
            +2620 
            +2621                     if (!actors[actor.id]) {
            +2622                         actors[actor.id] = {
            +2623                             actor:actor,
            +2624                             touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
            +2625                         };
            +2626                     }
            +2627 
            +2628                     var ev = actors[ actor.id ].touch;
            +2629                     ev.addTouch(this.touches[ touchId ].touch);
            +2630                     ev.addChangedTouch(this.touches[ touchId ].touch);
            +2631                 }
            +2632 
            +2633                 /**
            +2634                  * notificar a todos los actores.
            +2635                  */
            +2636                 for (var pr in actors) {
            +2637                     var data = actors[pr];
            +2638                     var actor = data.actor;
            +2639                     var touch = data.touch;
            +2640 
            +2641                     for (var actorId in this.touches) {
            +2642                         var tt = this.touches[actorId]
            +2643                         if (tt.actor.id === actor.id) {
            +2644                             touch.addTouch(tt.touch);
            +2645                         }
            +2646                     }
            +2647 
            +2648                     actor.touchStart(touch);
            +2649                 }
            +2650 
            +2651             },
            +2652 
            +2653             __findTouchFirstActor:function () {
            +2654 
            +2655                 var t = Number.MAX_VALUE;
            +2656                 var actor = null;
            +2657                 for (var pr in this.touches) {
            +2658 
            +2659                     var touch = this.touches[pr];
            +2660 
            +2661                     if (touch.touch.time && touch.touch.time < t && touch.actor.isGestureEnabled()) {
            +2662                         actor = touch.actor;
            +2663                         t = touch.touch.time;
            +2664                     }
            +2665                 }
            +2666                 return actor;
            +2667             },
            +2668 
            +2669             __gesturedActor:null,
            +2670             __touchGestureStartHandleMT:function (e) {
            +2671                 var actor = this.__findTouchFirstActor();
            +2672 
            +2673                 if (actor !== null && actor.isGestureEnabled()) {
            +2674                     this.__gesturedActor = actor;
            +2675                     this.__gestureRotation = actor.rotationAngle;
            +2676                     this.__gestureSX = actor.scaleX - 1;
            +2677                     this.__gestureSY = actor.scaleY - 1;
            +2678 
            +2679 
            +2680                     actor.gestureStart(
            +2681                         e.rotation * Math.PI / 180,
            +2682                         e.scale + this.__gestureSX,
            +2683                         e.scale + this.__gestureSY);
            +2684                 }
            +2685             },
            +2686 
            +2687             __touchGestureEndHandleMT:function (e) {
            +2688 
            +2689                 if (null !== this.__gesturedActor && this.__gesturedActor.isGestureEnabled()) {
            +2690                     this.__gesturedActor.gestureEnd(
            +2691                         e.rotation * Math.PI / 180,
            +2692                         e.scale + this.__gestureSX,
            +2693                         e.scale + this.__gestureSY);
            +2694                 }
            +2695 
            +2696                 this.__gestureRotation = 0;
            +2697                 this.__gestureScale = 0;
            +2698 
            +2699 
            +2700             },
            +2701 
            +2702             __touchGestureChangeHandleMT:function (e) {
            +2703 
            +2704                 if (this.__gesturedActor !== null && this.__gesturedActor.isGestureEnabled()) {
            +2705                     this.__gesturedActor.gestureChange(
            +2706                         e.rotation * Math.PI / 180,
            +2707                         this.__gestureSX + e.scale,
            +2708                         this.__gestureSY + e.scale);
            +2709                 }
            +2710             },
            +2711 
            +2712 
            +2713             addHandlers:function (canvas) {
            +2714 
            +2715                 var me = this;
            +2716 
            +2717                 window.addEventListener('mouseup', function (e) {
            +2718                     if (me.touching) {
            +2719                         e.preventDefault();
            +2720                         e.cancelBubble = true;
            +2721                         if (e.stopPropagation) e.stopPropagation();
            +2722 
            +2723                         var mp = me.mousePoint;
            +2724                         me.getCanvasCoord(mp, e);
            +2725                         me.__mouseUpHandler(e);
            +2726 
            +2727                         me.touching = false;
            +2728                     }
            +2729                 }, false);
            +2730 
            +2731                 window.addEventListener('mousedown', function (e) {
            +2732                     if (e.target === canvas) {
            +2733                         e.preventDefault();
            +2734                         e.cancelBubble = true;
            +2735                         if (e.stopPropagation) e.stopPropagation();
            +2736 
            +2737                         var mp = me.mousePoint;
            +2738                         me.getCanvasCoord(mp, e);
            +2739                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
            +2740                             return;
            +2741                         }
            +2742                         me.touching = true;
            +2743 
            +2744                         me.__mouseDownHandler(e);
            +2745                     }
            +2746                 }, false);
            +2747 
            +2748                 window.addEventListener('mouseover', function (e) {
            +2749                     if (e.target === canvas && !me.dragging) {
            +2750                         e.preventDefault();
            +2751                         e.cancelBubble = true;
            +2752                         if (e.stopPropagation) e.stopPropagation();
            +2753 
            +2754                         var mp = me.mousePoint;
            +2755                         me.getCanvasCoord(mp, e);
            +2756                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
            +2757                             return;
            +2758                         }
            +2759 
            +2760                         me.__mouseOverHandler(e);
            +2761                     }
            +2762                 }, false);
            +2763 
            +2764                 window.addEventListener('mouseout', function (e) {
            +2765                     if (e.target === canvas && !me.dragging) {
            +2766                         e.preventDefault();
            +2767                         e.cancelBubble = true;
            +2768                         if (e.stopPropagation) e.stopPropagation();
            +2769 
            +2770                         var mp = me.mousePoint;
            +2771                         me.getCanvasCoord(mp, e);
            +2772                         me.__mouseOutHandler(e);
            +2773                     }
            +2774                 }, false);
            +2775 
            +2776                 window.addEventListener('mousemove', function (e) {
            +2777                     e.preventDefault();
            +2778                     e.cancelBubble = true;
            +2779                     if (e.stopPropagation) e.stopPropagation();
            +2780 
            +2781                     var mp = me.mousePoint;
            +2782                     me.getCanvasCoord(mp, e);
            +2783                     if (!me.dragging && ( mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height )) {
            +2784                         return;
            +2785                     }
            +2786                     me.__mouseMoveHandler(e);
            +2787                 }, false);
            +2788 
            +2789                 window.addEventListener("dblclick", function (e) {
            +2790                     if (e.target === canvas) {
            +2791                         e.preventDefault();
            +2792                         e.cancelBubble = true;
            +2793                         if (e.stopPropagation) e.stopPropagation();
            +2794                         var mp = me.mousePoint;
            +2795                         me.getCanvasCoord(mp, e);
            +2796                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
            +2797                             return;
            +2798                         }
            +2799 
            +2800                         me.__mouseDBLClickHandler(e);
            +2801                     }
            +2802                 }, false);
            +2803 
            +2804                 if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MOUSE) {
            +2805                     canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false);
            +2806                     canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false);
            +2807                     canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false);
            +2808                     canvas.addEventListener("gesturestart", function (e) {
            +2809                         if (e.target === canvas) {
            +2810                             e.preventDefault();
            +2811                             e.returnValue = false;
            +2812                             me.__gestureStart(e.scale, e.rotation);
            +2813                         }
            +2814                     }, false);
            +2815                     canvas.addEventListener("gestureend", function (e) {
            +2816                         if (e.target === canvas) {
            +2817                             e.preventDefault();
            +2818                             e.returnValue = false;
            +2819                             me.__gestureEnd(e.scale, e.rotation);
            +2820                         }
            +2821                     }, false);
            +2822                     canvas.addEventListener("gesturechange", function (e) {
            +2823                         if (e.target === canvas) {
            +2824                             e.preventDefault();
            +2825                             e.returnValue = false;
            +2826                             me.__gestureChange(e.scale, e.rotation);
            +2827                         }
            +2828                     }, false);
            +2829                 } else if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MULTITOUCH) {
            +2830                     canvas.addEventListener("touchstart", this.__touchStartHandlerMT.bind(this), false);
            +2831                     canvas.addEventListener("touchmove", this.__touchMoveHandlerMT.bind(this), false);
            +2832                     canvas.addEventListener("touchend", this.__touchEndHandlerMT.bind(this), false);
            +2833                     canvas.addEventListener("touchcancel", this.__touchCancelHandleMT.bind(this), false);
            +2834 
            +2835                     canvas.addEventListener("gesturestart", this.__touchGestureStartHandleMT.bind(this), false);
            +2836                     canvas.addEventListener("gestureend", this.__touchGestureEndHandleMT.bind(this), false);
            +2837                     canvas.addEventListener("gesturechange", this.__touchGestureChangeHandleMT.bind(this), false);
            +2838                 }
            +2839 
            +2840             },
            +2841 
            +2842             enableEvents:function (onElement) {
            +2843                 CAAT.RegisterDirector(this);
            +2844                 this.in_ = false;
            +2845                 this.createEventHandler(onElement);
            +2846             },
            +2847 
            +2848             createEventHandler:function (onElement) {
            +2849                 //var canvas= this.canvas;
            +2850                 this.in_ = false;
            +2851                 //this.addHandlers(canvas);
            +2852                 this.addHandlers(onElement);
            +2853             }
            +2854         }
            +2855     },
            +2856 
            +2857     onCreate:function () {
            +2858 
            +2859         if (typeof CAAT.__CSS__!=="undefined") {
            +2860 
            +2861             CAAT.Foundation.Director.prototype.clip = true;
            +2862             CAAT.Foundation.Director.prototype.glEnabled = false;
            +2863 
            +2864             CAAT.Foundation.Director.prototype.getRenderType = function () {
            +2865                 return 'CSS';
            +2866             };
            +2867 
            +2868             CAAT.Foundation.Director.prototype.setScaleProportional = function (w, h) {
            +2869 
            +2870                 var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight);
            +2871                 this.setScaleAnchored(factor, factor, 0, 0);
            +2872 
            +2873                 this.eventHandler.style.width = '' + this.referenceWidth + 'px';
            +2874                 this.eventHandler.style.height = '' + this.referenceHeight + 'px';
            +2875             };
            +2876 
            +2877             CAAT.Foundation.Director.prototype.setBounds = function (x, y, w, h) {
            +2878                 CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h);
            +2879                 for (var i = 0; i < this.scenes.length; i++) {
            +2880                     this.scenes[i].setBounds(0, 0, w, h);
            +2881                 }
            +2882                 this.eventHandler.style.width = w + 'px';
            +2883                 this.eventHandler.style.height = h + 'px';
            +2884 
            +2885                 return this;
            +2886             };
            +2887 
            +2888             /**
            +2889              * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most
            +2890              * div in the document hierarchy (z-index 999999).
            +2891              * @param width
            +2892              * @param height
            +2893              * @param domElement
            +2894              * @param proxy
            +2895              */
            +2896             CAAT.Foundation.Director.prototype.initialize = function (width, height, domElement, proxy) {
            +2897 
            +2898                 this.timeline = new Date().getTime();
            +2899                 this.domElement = domElement;
            +2900                 this.style('position', 'absolute');
            +2901                 this.style('width', '' + width + 'px');
            +2902                 this.style('height', '' + height + 'px');
            +2903                 this.style('overflow', 'hidden');
            +2904 
            +2905                 this.enableEvents(domElement);
            +2906 
            +2907                 this.setBounds(0, 0, width, height);
            +2908 
            +2909                 this.checkDebug();
            +2910                 return this;
            +2911             };
            +2912 
            +2913             CAAT.Foundation.Director.prototype.render = function (time) {
            +2914 
            +2915                 this.time += time;
            +2916                 this.animate(this, time);
            +2917 
            +2918                 /**
            +2919                  * draw director active scenes.
            +2920                  */
            +2921                 var i, l, tt;
            +2922 
            +2923                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +2924                     this.resetStats();
            +2925                 }
            +2926 
            +2927                 for (i = 0, l = this.childrenList.length; i < l; i++) {
            +2928                     var c = this.childrenList[i];
            +2929                     if (c.isInAnimationFrame(this.time) && !c.isPaused()) {
            +2930                         tt = c.time - c.start_time;
            +2931                         c.timerManager.checkTimers(tt);
            +2932                         c.timerManager.removeExpiredTimers();
            +2933                     }
            +2934                 }
            +2935 
            +2936                 for (i = 0, l = this.childrenList.length; i < l; i++) {
            +2937                     var c = this.childrenList[i];
            +2938                     if (c.isInAnimationFrame(this.time)) {
            +2939                         tt = c.time - c.start_time;
            +2940                         if (c.onRenderStart) {
            +2941                             c.onRenderStart(tt);
            +2942                         }
            +2943 
            +2944                         c.paintActor(this, tt);
            +2945 
            +2946                         if (c.onRenderEnd) {
            +2947                             c.onRenderEnd(tt);
            +2948                         }
            +2949 
            +2950                         if (!c.isPaused()) {
            +2951                             c.time += time;
            +2952                         }
            +2953 
            +2954                         if (!navigator.isCocoonJS && CAAT.DEBUG) {
            +2955                             this.statistics.size_discarded_by_dirtyRects += this.drDiscarded;
            +2956                             this.statistics.size_total += c.size_total;
            +2957                             this.statistics.size_active += c.size_active;
            +2958                             this.statistics.size_dirtyRects = this.nDirtyRects;
            +2959 
            +2960                         }
            +2961 
            +2962                     }
            +2963                 }
            +2964 
            +2965                 this.frameCounter++;
            +2966             };
            +2967 
            +2968             CAAT.Foundation.Director.prototype.addScene = function (scene) {
            +2969                 scene.setVisible(true);
            +2970                 scene.setBounds(0, 0, this.width, this.height);
            +2971                 this.scenes.push(scene);
            +2972                 scene.setEaseListener(this);
            +2973                 if (null === this.currentScene) {
            +2974                     this.setScene(0);
            +2975                 }
            +2976 
            +2977                 this.domElement.appendChild(scene.domElement);
            +2978             };
            +2979 
            +2980             CAAT.Foundation.Director.prototype.emptyScenes = function () {
            +2981                 this.scenes = [];
            +2982                 this.domElement.innerHTML = '';
            +2983                 this.createEventHandler();
            +2984             };
            +2985 
            +2986             CAAT.Foundation.Director.prototype.setClear = function (clear) {
            +2987                 return this;
            +2988             };
            +2989 
            +2990             CAAT.Foundation.Director.prototype.createEventHandler = function () {
            +2991                 this.eventHandler = document.createElement('div');
            +2992                 this.domElement.appendChild(this.eventHandler);
            +2993 
            +2994                 this.eventHandler.style.position = 'absolute';
            +2995                 this.eventHandler.style.left = '0';
            +2996                 this.eventHandler.style.top = '0';
            +2997                 this.eventHandler.style.zIndex = 999999;
            +2998                 this.eventHandler.style.width = '' + this.width + 'px';
            +2999                 this.eventHandler.style.height = '' + this.height + 'px';
            +3000 
            +3001                 this.canvas = this.eventHandler;
            +3002                 this.in_ = false;
            +3003 
            +3004                 this.addHandlers(this.canvas);
            +3005             };
            +3006 
            +3007             CAAT.Foundation.Director.prototype.inDirtyRect = function () {
            +3008                 return true;
            +3009             }
            +3010         }
            +3011     }
            +3012 });
            +3013 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Scene.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Scene.js.html new file mode 100644 index 0000000..8dceaf8 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Scene.js.html @@ -0,0 +1,606 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  */
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8     /**
            +  9      * @name Scene
            + 10      * @memberOf CAAT.Foundation
            + 11      * @extends CAAT.Foundation.ActorContainer
            + 12      *
            + 13      * @constructor
            + 14      *
            + 15      */
            + 16 
            + 17     defines:"CAAT.Foundation.Scene",
            + 18     depends: [
            + 19         "CAAT.Math.Point",
            + 20         "CAAT.Math.Matrix",
            + 21         "CAAT.PathUtil.Path",
            + 22         "CAAT.Behavior.GenericBehavior",
            + 23         "CAAT.Behavior.ContainerBehavior",
            + 24         "CAAT.Behavior.ScaleBehavior",
            + 25         "CAAT.Behavior.AlphaBehavior",
            + 26         "CAAT.Behavior.RotateBehavior",
            + 27         "CAAT.Behavior.PathBehavior",
            + 28         "CAAT.Foundation.ActorContainer",
            + 29         "CAAT.Foundation.Timer.TimerManager"
            + 30     ],
            + 31     aliases:["CAAT.Scene"],
            + 32     extendsClass:"CAAT.Foundation.ActorContainer",
            + 33     constants:{
            + 34         /**
            + 35          * @lends  CAAT.Foundation.Scene
            + 36          */
            + 37 
            + 38         /** @const @type {number} */ EASE_ROTATION:1, // Constant values to identify the type of Scene transition
            + 39         /** @const @type {number} */ EASE_SCALE:2, // to perform on Scene switching by the Director.
            + 40         /** @const @type {number} */ EASE_TRANSLATE:3
            + 41     },
            + 42     extendsWith:function () {
            + 43         return {
            + 44 
            + 45             /**
            + 46              * @lends  CAAT.Foundation.Scene.prototype
            + 47              */
            + 48 
            + 49             __init:function () {
            + 50                 this.__super();
            + 51                 this.timerManager = new CAAT.TimerManager();
            + 52                 this.fillStyle = null;
            + 53                 this.isGlobalAlpha = true;
            + 54                 return this;
            + 55             },
            + 56 
            + 57             /**
            + 58              * Behavior container used uniquely for Scene switching.
            + 59              * @type {CAAT.Behavior.ContainerBehavior}
            + 60              * @private
            + 61              */
            + 62             easeContainerBehaviour:null,
            + 63 
            + 64             /**
            + 65              * Array of container behaviour events observer.
            + 66              * @private
            + 67              */
            + 68             easeContainerBehaviourListener:null,
            + 69 
            + 70             /**
            + 71              * When Scene switching, this boolean identifies whether the Scene is being brought in, or taken away.
            + 72              * @type {boolean}
            + 73              * @private
            + 74              */
            + 75             easeIn:false,
            + 76 
            + 77 
            + 78             /**
            + 79              * is this scene paused ?
            + 80              * @type {boolean}
            + 81              * @private
            + 82              */
            + 83             paused:false,
            + 84 
            + 85             /**
            + 86              * This scene´s timer manager.
            + 87              * @type {CAAT.Foundation.Timer.TimerManager}
            + 88              * @private
            + 89              */
            + 90             timerManager:null,
            + 91 
            + 92             isPaused:function () {
            + 93                 return this.paused;
            + 94             },
            + 95 
            + 96             setPaused:function (paused) {
            + 97                 this.paused = paused;
            + 98             },
            + 99 
            +100             createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) {
            +101                 return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this);
            +102             },
            +103 
            +104             setTimeout:function (duration, callback_timeout, callback_tick, callback_cancel) {
            +105                 return this.timerManager.createTimer(this.time, duration, callback_timeout, callback_tick, callback_cancel, this);
            +106             },
            +107 
            +108             /**
            +109              * Helper method to manage alpha transparency fading on Scene switch by the Director.
            +110              * @param time {number} time in milliseconds then fading will taableIne.
            +111              * @param isIn {boolean} whether this Scene is being brought in.
            +112              *
            +113              * @private
            +114              */
            +115             createAlphaBehaviour:function (time, isIn) {
            +116                 var ab = new CAAT.Behavior.AlphaBehavior();
            +117                 ab.setFrameTime(0, time);
            +118                 ab.startAlpha = isIn ? 0 : 1;
            +119                 ab.endAlpha = isIn ? 1 : 0;
            +120                 this.easeContainerBehaviour.addBehavior(ab);
            +121             },
            +122             /**
            +123              * Called from CAAT.Director to bring in an Scene.
            +124              * A helper method for easeTranslation.
            +125              * @param time {number} time in milliseconds for the Scene to be brought in.
            +126              * @param alpha {boolean} whether fading will be applied to the Scene.
            +127              * @param anchor {number} Scene switch anchor.
            +128              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +129              */
            +130             easeTranslationIn:function (time, alpha, anchor, interpolator) {
            +131                 this.easeTranslation(time, alpha, anchor, true, interpolator);
            +132             },
            +133             /**
            +134              * Called from CAAT.Director to bring in an Scene.
            +135              * A helper method for easeTranslation.
            +136              * @param time {number} time in milliseconds for the Scene to be taken away.
            +137              * @param alpha {boolean} fading will be applied to the Scene.
            +138              * @param anchor {number} Scene switch anchor.
            +139              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +140              */
            +141             easeTranslationOut:function (time, alpha, anchor, interpolator) {
            +142                 this.easeTranslation(time, alpha, anchor, false, interpolator);
            +143             },
            +144             /**
            +145              * This method will setup Scene behaviours to switch an Scene via a translation.
            +146              * The anchor value can only be
            +147              *  <li>CAAT.Actor.ANCHOR_LEFT
            +148              *  <li>CAAT.Actor.ANCHOR_RIGHT
            +149              *  <li>CAAT.Actor.ANCHOR_TOP
            +150              *  <li>CAAT.Actor.ANCHOR_BOTTOM
            +151              * if any other value is specified, any of the previous ones will be applied.
            +152              *
            +153              * @param time {number} time in milliseconds for the Scene.
            +154              * @param alpha {boolean} whether fading will be applied to the Scene.
            +155              * @param anchor {numnber} Scene switch anchor.
            +156              * @param isIn {boolean} whether the scene will be brought in.
            +157              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +158              */
            +159             easeTranslation:function (time, alpha, anchor, isIn, interpolator) {
            +160 
            +161                 this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior();
            +162                 this.easeIn = isIn;
            +163 
            +164                 var pb = new CAAT.Behavior.PathBehavior();
            +165                 if (interpolator) {
            +166                     pb.setInterpolator(interpolator);
            +167                 }
            +168 
            +169                 pb.setFrameTime(0, time);
            +170 
            +171                 // BUGBUG anchors: 1..4
            +172                 if (anchor < 1) {
            +173                     anchor = 1;
            +174                 } else if (anchor > 4) {
            +175                     anchor = 4;
            +176                 }
            +177 
            +178 
            +179                 switch (anchor) {
            +180                     case CAAT.Foundation.Actor.ANCHOR_TOP:
            +181                         if (isIn) {
            +182                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, -this.height + 1, 0, 0));
            +183                             this.setPosition(0,-this.height+1);
            +184                         } else {
            +185                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, -this.height + 1));
            +186                             this.setPosition(0,0);
            +187                         }
            +188                         break;
            +189                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM:
            +190                         if (isIn) {
            +191                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, this.height - 1, 0, 0));
            +192                             this.setPosition(0,this.height-1);
            +193                         } else {
            +194                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, this.height - 1));
            +195                             this.setPosition(0,0);
            +196                         }
            +197                         break;
            +198                     case CAAT.Foundation.Actor.ANCHOR_LEFT:
            +199                         if (isIn) {
            +200                             pb.setPath(new CAAT.PathUtil.Path().setLinear(-this.width + 1, 0, 0, 0));
            +201                             this.setPosition(-this.width+1,0);
            +202                         } else {
            +203                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, -this.width + 1, 0));
            +204                             this.setPosition(0,0);
            +205                         }
            +206                         break;
            +207                     case CAAT.Foundation.Actor.ANCHOR_RIGHT:
            +208                         if (isIn) {
            +209                             pb.setPath(new CAAT.PathUtil.Path().setLinear(this.width - 1, 0, 0, 0));
            +210                             this.setPosition(this.width-1,0);
            +211                         } else {
            +212                             pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, this.width - 1, 0));
            +213                             this.setPosition(0,0);
            +214                         }
            +215                         break;
            +216                 }
            +217 
            +218                 if (alpha) {
            +219                     this.createAlphaBehaviour(time, isIn);
            +220                 }
            +221 
            +222                 this.easeContainerBehaviour.addBehavior(pb);
            +223 
            +224                 this.easeContainerBehaviour.setFrameTime(this.time, time);
            +225                 this.easeContainerBehaviour.addListener(this);
            +226 
            +227                 this.emptyBehaviorList();
            +228                 CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour);
            +229             },
            +230             /**
            +231              * Called from CAAT.Foundation.Director to bring in a Scene.
            +232              * A helper method for easeScale.
            +233              * @param time {number} time in milliseconds for the Scene to be brought in.
            +234              * @param alpha {boolean} whether fading will be applied to the Scene.
            +235              * @param anchor {number} Scene switch anchor.
            +236              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +237              * @param starttime {number} scene time milliseconds from which the behavior will be applied.
            +238              */
            +239             easeScaleIn:function (starttime, time, alpha, anchor, interpolator) {
            +240                 this.easeScale(starttime, time, alpha, anchor, true, interpolator);
            +241                 this.easeIn = true;
            +242             },
            +243             /**
            +244              * Called from CAAT.Foundation.Director to take away a Scene.
            +245              * A helper method for easeScale.
            +246              * @param time {number} time in milliseconds for the Scene to be brought in.
            +247              * @param alpha {boolean} whether fading will be applied to the Scene.
            +248              * @param anchor {number} Scene switch anchor.
            +249              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +250              * @param starttime {number} scene time milliseconds from which the behavior will be applied.
            +251              **/
            +252             easeScaleOut:function (starttime, time, alpha, anchor, interpolator) {
            +253                 this.easeScale(starttime, time, alpha, anchor, false, interpolator);
            +254                 this.easeIn = false;
            +255             },
            +256             /**
            +257              * Called from CAAT.Foundation.Director to bring in ot take away an Scene.
            +258              * @param time {number} time in milliseconds for the Scene to be brought in.
            +259              * @param alpha {boolean} whether fading will be applied to the Scene.
            +260              * @param anchor {number} Scene switch anchor.
            +261              * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition.
            +262              * @param starttime {number} scene time milliseconds from which the behavior will be applied.
            +263              * @param isIn boolean indicating whether the Scene is being brought in.
            +264              */
            +265             easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) {
            +266                 this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior();
            +267 
            +268                 var x = 0;
            +269                 var y = 0;
            +270                 var x2 = 0;
            +271                 var y2 = 0;
            +272 
            +273                 switch (anchor) {
            +274                     case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:
            +275                     case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:
            +276                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:
            +277                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:
            +278                     case CAAT.Foundation.Actor.ANCHOR_CENTER:
            +279                         x2 = 1;
            +280                         y2 = 1;
            +281                         break;
            +282                     case CAAT.Foundation.Actor.ANCHOR_TOP:
            +283                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM:
            +284                         x = 1;
            +285                         x2 = 1;
            +286                         y = 0;
            +287                         y2 = 1;
            +288                         break;
            +289                     case CAAT.Foundation.Actor.ANCHOR_LEFT:
            +290                     case CAAT.Foundation.Actor.ANCHOR_RIGHT:
            +291                         y = 1;
            +292                         y2 = 1;
            +293                         x = 0;
            +294                         x2 = 1;
            +295                         break;
            +296                     default:
            +297                         alert('scale anchor ?? ' + anchor);
            +298                 }
            +299 
            +300                 if (!isIn) {
            +301                     var tmp;
            +302                     tmp = x;
            +303                     x = x2;
            +304                     x2 = tmp;
            +305 
            +306                     tmp = y;
            +307                     y = y2;
            +308                     y2 = tmp;
            +309                 }
            +310 
            +311                 if (alpha) {
            +312                     this.createAlphaBehaviour(time, isIn);
            +313                 }
            +314 
            +315                 var anchorPercent = this.getAnchorPercent(anchor);
            +316                 var sb = new CAAT.Behavior.ScaleBehavior().
            +317                     setFrameTime(starttime, time).
            +318                     setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y);
            +319 
            +320                 if (interpolator) {
            +321                     sb.setInterpolator(interpolator);
            +322                 }
            +323 
            +324                 this.easeContainerBehaviour.addBehavior(sb);
            +325 
            +326                 this.easeContainerBehaviour.setFrameTime(this.time, time);
            +327                 this.easeContainerBehaviour.addListener(this);
            +328 
            +329                 this.emptyBehaviorList();
            +330                 CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour);
            +331             },
            +332             /**
            +333              * Overriden method to disallow default behavior.
            +334              * Do not use directly.
            +335              */
            +336             addBehavior:function (behaviour) {
            +337                 return this;
            +338             },
            +339             /**
            +340              * Called from CAAT.Director to use Rotations for bringing in.
            +341              * This method is a Helper for the method easeRotation.
            +342              * @param time integer indicating time in milliseconds for the Scene to be brought in.
            +343              * @param alpha boolean indicating whether fading will be applied to the Scene.
            +344              * @param anchor integer indicating the Scene switch anchor.
            +345              * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
            +346              */
            +347             easeRotationIn:function (time, alpha, anchor, interpolator) {
            +348                 this.easeRotation(time, alpha, anchor, true, interpolator);
            +349                 this.easeIn = true;
            +350             },
            +351             /**
            +352              * Called from CAAT.Director to use Rotations for taking Scenes away.
            +353              * This method is a Helper for the method easeRotation.
            +354              * @param time integer indicating time in milliseconds for the Scene to be taken away.
            +355              * @param alpha boolean indicating whether fading will be applied to the Scene.
            +356              * @param anchor integer indicating the Scene switch anchor.
            +357              * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
            +358              */
            +359             easeRotationOut:function (time, alpha, anchor, interpolator) {
            +360                 this.easeRotation(time, alpha, anchor, false, interpolator);
            +361                 this.easeIn = false;
            +362             },
            +363             /**
            +364              * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in.
            +365              * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in.
            +366              * @param alpha boolean indicating whether fading will be applied to the Scene.
            +367              * @param anchor integer indicating the Scene switch anchor.
            +368              * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition.
            +369              * @param isIn boolean indicating whehter the Scene is brought in.
            +370              */
            +371             easeRotation:function (time, alpha, anchor, isIn, interpolator) {
            +372                 this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior();
            +373 
            +374                 var start = 0;
            +375                 var end = 0;
            +376 
            +377                 if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) {
            +378                     anchor = CAAT.Foundation.Actor.ANCHOR_TOP;
            +379                 }
            +380 
            +381                 switch (anchor) {
            +382                     case CAAT.Foundation.Actor.ANCHOR_TOP:
            +383                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM:
            +384                     case CAAT.Foundation.Actor.ANCHOR_LEFT:
            +385                     case CAAT.Foundation.Actor.ANCHOR_RIGHT:
            +386                         start = Math.PI * (Math.random() < 0.5 ? 1 : -1);
            +387                         break;
            +388                     case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:
            +389                     case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:
            +390                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:
            +391                     case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:
            +392                         start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1);
            +393                         break;
            +394                     default:
            +395                         alert('rot anchor ?? ' + anchor);
            +396                 }
            +397 
            +398                 if (false === isIn) {
            +399                     var tmp = start;
            +400                     start = end;
            +401                     end = tmp;
            +402                 }
            +403 
            +404                 if (alpha) {
            +405                     this.createAlphaBehaviour(time, isIn);
            +406                 }
            +407 
            +408                 var anchorPercent = this.getAnchorPercent(anchor);
            +409                 var rb = new CAAT.Behavior.RotateBehavior().
            +410                     setFrameTime(0, time).
            +411                     setValues(start, end, anchorPercent.x, anchorPercent.y);
            +412 
            +413                 if (interpolator) {
            +414                     rb.setInterpolator(interpolator);
            +415                 }
            +416                 this.easeContainerBehaviour.addBehavior(rb);
            +417                 this.easeContainerBehaviour.setFrameTime(this.time, time);
            +418                 this.easeContainerBehaviour.addListener(this);
            +419 
            +420                 this.emptyBehaviorList();
            +421                 CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour);
            +422             },
            +423             /**
            +424              * Registers a listener for listen for transitions events.
            +425              * Al least, the Director registers himself as Scene easing transition listener.
            +426              * When the transition is done, it restores the Scene's capability of receiving events.
            +427              * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form <code>
            +428              * behaviorExpired( caat_behaviour, time, actor);
            +429              */
            +430             setEaseListener:function (listener) {
            +431                 this.easeContainerBehaviourListener = listener;
            +432             },
            +433             /**
            +434              * Private.
            +435              * listener for the Scene's easeContainerBehaviour.
            +436              * @param actor
            +437              */
            +438             behaviorExpired:function (actor) {
            +439                 this.easeContainerBehaviourListener.easeEnd(this, this.easeIn);
            +440             },
            +441             /**
            +442              * This method should be overriden in case the developer wants to do some special actions when
            +443              * the scene has just been brought in.
            +444              */
            +445             activated:function () {
            +446             },
            +447             /**
            +448              * Scenes, do not expire the same way Actors do.
            +449              * It simply will be set expired=true, but the frameTime won't be modified.
            +450              */
            +451             setExpired:function (bExpired) {
            +452                 this.expired = bExpired;
            +453             },
            +454             /**
            +455              * An scene by default does not paint anything because has not fillStyle set.
            +456              * @param director
            +457              * @param time
            +458              */
            +459             paint:function (director, time) {
            +460 
            +461                 if (this.fillStyle) {
            +462                     var ctx = director.ctx;
            +463                     ctx.fillStyle = this.fillStyle;
            +464                     ctx.fillRect(0, 0, this.width, this.height);
            +465                 }
            +466             },
            +467             /**
            +468              * Find a pointed actor at position point.
            +469              * This method tries lo find the correctly pointed actor in two different ways.
            +470              *  + first of all, if inputList is defined, it will look for an actor in it.
            +471              *  + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor.
            +472              * @param point <CAAT.Point>
            +473              */
            +474             findActorAtPosition:function (point) {
            +475                 var i, j;
            +476 
            +477                 var p = new CAAT.Math.Point();
            +478 
            +479                 if (this.inputList) {
            +480                     var il = this.inputList;
            +481                     for (i = 0; i < il.length; i++) {
            +482                         var ill = il[i];
            +483                         for (j = 0; j < ill.length; j++) {
            +484                             if ( ill[j].visible ) {
            +485                                 p.set(point.x, point.y);
            +486                                 var modelViewMatrixI = ill[j].worldModelViewMatrix.getInverse();
            +487                                 modelViewMatrixI.transformCoord(p);
            +488                                 if (ill[j].contains(p.x, p.y)) {
            +489                                     return ill[j];
            +490                                 }
            +491                             }
            +492                         }
            +493                     }
            +494                 }
            +495 
            +496                 p.set(point.x, point.y);
            +497                 return CAAT.Foundation.Scene.superclass.findActorAtPosition.call(this, p);
            +498             },
            +499 
            +500             /**
            +501              * Enable a number of input lists.
            +502              * These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed
            +503              * actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance.
            +504              * The system will traverse the whole lists in order trying to find a pointed actor.
            +505              *
            +506              * Elements are added to each list either in head or tail.
            +507              *
            +508              * @param size <number> number of lists.
            +509              */
            +510             enableInputList:function (size) {
            +511                 this.inputList = [];
            +512                 for (var i = 0; i < size; i++) {
            +513                     this.inputList.push([]);
            +514                 }
            +515 
            +516                 return this;
            +517             },
            +518 
            +519             /**
            +520              * Add an actor to a given inputList.
            +521              * @param actor <CAAT.Actor> an actor instance
            +522              * @param index <number> the inputList index to add the actor to. This value will be clamped to the number of
            +523              * available lists.
            +524              * @param position <number> the position on the selected inputList to add the actor at. This value will be
            +525              * clamped to the number of available lists.
            +526              */
            +527             addActorToInputList:function (actor, index, position) {
            +528                 if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1;
            +529                 var il = this.inputList[index];
            +530 
            +531                 if (typeof position === "undefined" || position >= il.length) {
            +532                     il.push(actor);
            +533                 } else if (position <= 0) {
            +534                     il.unshift(actor);
            +535                 } else {
            +536                     il.splice(position, 0, actor);
            +537                 }
            +538 
            +539                 return this;
            +540             },
            +541 
            +542             /**
            +543              * Remove all elements from an input list.
            +544              * @param index <number> the inputList index to add the actor to. This value will be clamped to the number of
            +545              * available lists so take care when emptying a non existant inputList index since you could end up emptying
            +546              * an undesired input list.
            +547              */
            +548             emptyInputList:function (index) {
            +549                 if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1;
            +550                 this.inputList[index] = [];
            +551                 return this;
            +552             },
            +553 
            +554             /**
            +555              * remove an actor from a given input list index.
            +556              * If no index is supplied, the actor will be removed from every input list.
            +557              * @param actor <CAAT.Actor>
            +558              * @param index <!number> an optional input list index. This value will be clamped to the number of
            +559              * available lists.
            +560              */
            +561             removeActorFromInputList:function (actor, index) {
            +562                 if (typeof index === "undefined") {
            +563                     var i, j;
            +564                     for (i = 0; i < this.inputList.length; i++) {
            +565                         var il = this.inputList[i];
            +566                         for (j = 0; j < il.length; j++) {
            +567                             if (il[j] == actor) {
            +568                                 il.splice(j, 1);
            +569                             }
            +570                         }
            +571                     }
            +572                     return this;
            +573                 }
            +574 
            +575                 if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1;
            +576                 var il = this.inputList[index];
            +577                 for (j = 0; j < il.length; j++) {
            +578                     if (il[j] == actor) {
            +579                         il.splice(j, 1);
            +580                     }
            +581                 }
            +582 
            +583                 return this;
            +584             },
            +585 
            +586             getIn : function( out_scene ) {
            +587 
            +588             },
            +589 
            +590             goOut : function( in_scene ) {
            +591 
            +592             }
            +593 
            +594         }
            +595     }
            +596 
            +597 
            +598 });
            +599 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImage.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImage.js.html new file mode 100644 index 0000000..4bdd1f1 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImage.js.html @@ -0,0 +1,1173 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * TODO: allow set of margins, spacing, etc. to define subimages.
            +  5  *
            +  6  **/
            +  7 
            +  8 CAAT.Module({
            +  9 
            + 10     /**
            + 11      * @name SpriteImage
            + 12      * @memberOf CAAT.Foundation
            + 13      * @constructor
            + 14      */
            + 15 
            + 16 
            + 17     defines : "CAAT.Foundation.SpriteImage",
            + 18     aliases : ["CAAT.SpriteImage"],
            + 19     depends : [
            + 20         "CAAT.Foundation.SpriteImageHelper",
            + 21         "CAAT.Foundation.SpriteImageAnimationHelper",
            + 22         "CAAT.Math.Rectangle"
            + 23     ],
            + 24     constants:{
            + 25         /**
            + 26          * @lends  CAAT.Foundation.SpriteImage
            + 27          */
            + 28 
            + 29         /** @const @type {number} */ TR_NONE:0, // constants used to determine how to draw the sprite image,
            + 30         /** @const @type {number} */ TR_FLIP_HORIZONTAL:1,
            + 31         /** @const @type {number} */ TR_FLIP_VERTICAL:2,
            + 32         /** @const @type {number} */ TR_FLIP_ALL:3,
            + 33         /** @const @type {number} */ TR_FIXED_TO_SIZE:4,
            + 34         /** @const @type {number} */ TR_FIXED_WIDTH_TO_SIZE:6,
            + 35         /** @const @type {number} */ TR_TILE:5
            + 36     },
            + 37     extendsWith:function () {
            + 38 
            + 39         return {
            + 40 
            + 41             /**
            + 42              * @lends  CAAT.Foundation.SpriteImage.prototype
            + 43              */
            + 44 
            + 45             __init:function () {
            + 46                 this.paint = this.paintN;
            + 47                 this.setAnimationImageIndex([0]);
            + 48                 this.mapInfo = {};
            + 49                 this.animationsMap= {};
            + 50 
            + 51                 if ( arguments.length===1 ) {
            + 52                     this.initialize.call(this, arguments[0], 1, 1);
            + 53                 } else if ( arguments.length===3 ) {
            + 54                     this.initialize.apply(this, arguments);
            + 55                 }
            + 56                 return this;
            + 57             },
            + 58 
            + 59             /**
            + 60              * an Array defining the sprite frame sequence
            + 61              */
            + 62             animationImageIndex:null,
            + 63 
            + 64             /**
            + 65              * Previous animation frame time.
            + 66              */
            + 67             prevAnimationTime:-1,
            + 68 
            + 69             /**
            + 70              * how much Scene time to take before changing an Sprite frame.
            + 71              */
            + 72             changeFPS:1000,
            + 73 
            + 74             /**
            + 75              * any of the TR_* constants.
            + 76              */
            + 77             transformation:0,
            + 78 
            + 79             /**
            + 80              * the current sprite frame
            + 81              */
            + 82             spriteIndex:0,
            + 83 
            + 84             /**
            + 85              * current index of sprite frames array.
            + 86              */
            + 87             prevIndex:0,    //
            + 88 
            + 89             /**
            + 90              * current animation name
            + 91              */
            + 92             currentAnimation: null,
            + 93 
            + 94             /**
            + 95              * Image to get frames from.
            + 96              */
            + 97             image:null,
            + 98 
            + 99             /**
            +100              * Number of rows
            +101              */
            +102             rows:1,
            +103 
            +104             /**
            +105              * Number of columns.
            +106              */
            +107             columns:1,
            +108 
            +109             /**
            +110              * This sprite image image´s width
            +111              */
            +112             width:0,
            +113 
            +114             /**
            +115              * This sprite image image´s width
            +116              */
            +117             height:0,
            +118 
            +119             /**
            +120              * For each element in the sprite image array, its size.
            +121              */
            +122             singleWidth:0,
            +123 
            +124             /**
            +125              * For each element in the sprite image array, its height.
            +126              */
            +127             singleHeight:0,
            +128 
            +129             scaleX:1,
            +130             scaleY:1,
            +131 
            +132             /**
            +133              * Displacement offset to get the sub image from. Useful to make images shift.
            +134              */
            +135             offsetX:0,
            +136 
            +137             /**
            +138              * Displacement offset to get the sub image from. Useful to make images shift.
            +139              */
            +140             offsetY:0,
            +141 
            +142             /**
            +143              * When nesting sprite images, this value is the star X position of this sprite image in the parent.
            +144              */
            +145             parentOffsetX:0,    // para especificar una subimagen dentro un textmap.
            +146 
            +147             /**
            +148              * When nesting sprite images, this value is the star Y position of this sprite image in the parent.
            +149              */
            +150             parentOffsetY:0,
            +151 
            +152             /**
            +153              * The actor this sprite image belongs to.
            +154              */
            +155             ownerActor:null,
            +156 
            +157             /**
            +158              * If the sprite image is defined out of a JSON object (sprite packer for example), this is
            +159              * the subimages calculated definition map.
            +160              */
            +161             mapInfo:null,
            +162 
            +163             /**
            +164              * If the sprite image is defined out of a JSON object (sprite packer for example), this is
            +165              * the subimages original definition map.
            +166              */
            +167             map:null,
            +168 
            +169             /**
            +170              * This property allows to have multiple different animations defined for one actor.
            +171              * see demo31 for a sample.
            +172              */
            +173             animationsMap : null,
            +174 
            +175             /**
            +176              * When an animation sequence ends, this callback function will be called.
            +177              */
            +178             callback : null,        // on end animation callback
            +179 
            +180             /**
            +181              * pending: refactor -> font scale to a font object.
            +182              */
            +183             fontScale : 1,
            +184 
            +185             getOwnerActor : function() {
            +186                 return this.ownerActor;
            +187             },
            +188 
            +189             /**
            +190              * Add an animation to this sprite image.
            +191              * An animation is defines by an array of pretend-to-be-played sprite sequence.
            +192              *
            +193              * @param name {string} animation name.
            +194              * @param array {Array<number|string>} the sprite animation sequence array. It can be defined
            +195              *              as number array for Grid-like sprite images or strings for a map-like sprite
            +196              *              image.
            +197              * @param time {number} change animation sequence every 'time' ms.
            +198              * @param callback {function({SpriteImage},{string}} a callback function to invoke when the sprite
            +199              *              animation sequence has ended.
            +200              */
            +201             addAnimation : function( name, array, time, callback ) {
            +202                 this.animationsMap[name]= new CAAT.Foundation.SpriteImageAnimationHelper(array,time,callback);
            +203                 return this;
            +204             },
            +205 
            +206             setAnimationEndCallback : function(f) {
            +207                 this.callback= f;
            +208             },
            +209 
            +210             /**
            +211              * Start playing a SpriteImage animation.
            +212              * If it does not exist, nothing happens.
            +213              * @param name
            +214              */
            +215             playAnimation : function(name) {
            +216                 if (name===this.currentAnimation) {
            +217                     return this;
            +218                 }
            +219 
            +220                 var animation= this.animationsMap[name];
            +221                 if ( !animation ) {
            +222                     return this;
            +223                 }
            +224 
            +225                 this.currentAnimation= name;
            +226 
            +227                 this.setAnimationImageIndex( animation.animation );
            +228                 this.changeFPS= animation.time;
            +229                 this.callback= animation.onEndPlayCallback;
            +230 
            +231                 return this;
            +232             },
            +233 
            +234             setOwner:function (actor) {
            +235                 this.ownerActor = actor;
            +236                 return this;
            +237             },
            +238             getRows:function () {
            +239                 return this.rows;
            +240             },
            +241             getColumns:function () {
            +242                 return this.columns;
            +243             },
            +244 
            +245             getWidth:function () {
            +246                 var el = this.mapInfo[this.spriteIndex];
            +247                 return el.width;
            +248             },
            +249 
            +250             getHeight:function () {
            +251                 var el = this.mapInfo[this.spriteIndex];
            +252                 return el.height;
            +253             },
            +254 
            +255             getWrappedImageWidth:function () {
            +256                 return this.image.width;
            +257             },
            +258 
            +259             getWrappedImageHeight:function () {
            +260                 return this.image.height;
            +261             },
            +262 
            +263             /**
            +264              * Get a reference to the same image information (rows, columns, image and uv cache) of this
            +265              * SpriteImage. This means that re-initializing this objects image info (that is, calling initialize
            +266              * method) will change all reference's image information at the same time.
            +267              */
            +268             getRef:function () {
            +269                 var ret = new CAAT.Foundation.SpriteImage();
            +270                 ret.image = this.image;
            +271                 ret.rows = this.rows;
            +272                 ret.columns = this.columns;
            +273                 ret.width = this.width;
            +274                 ret.height = this.height;
            +275                 ret.singleWidth = this.singleWidth;
            +276                 ret.singleHeight = this.singleHeight;
            +277                 ret.mapInfo = this.mapInfo;
            +278                 ret.offsetX = this.offsetX;
            +279                 ret.offsetY = this.offsetY;
            +280                 ret.scaleX = this.scaleX;
            +281                 ret.scaleY = this.scaleY;
            +282                 ret.animationsMap= this.animationsMap;
            +283                 ret.parentOffsetX= this.parentOffsetX;
            +284                 ret.parentOffsetY= this.parentOffsetY;
            +285 
            +286                 ret.scaleFont= this.scaleFont;
            +287 
            +288                 return ret;
            +289             },
            +290             /**
            +291              * Set horizontal displacement to draw image. Positive values means drawing the image more to the
            +292              * right.
            +293              * @param x {number}
            +294              * @return this
            +295              */
            +296             setOffsetX:function (x) {
            +297                 this.offsetX = x;
            +298                 return this;
            +299             },
            +300             /**
            +301              * Set vertical displacement to draw image. Positive values means drawing the image more to the
            +302              * bottom.
            +303              * @param y {number}
            +304              * @return this
            +305              */
            +306             setOffsetY:function (y) {
            +307                 this.offsetY = y;
            +308                 return this;
            +309             },
            +310             setOffset:function (x, y) {
            +311                 this.offsetX = x;
            +312                 this.offsetY = y;
            +313                 return this;
            +314             },
            +315             /**
            +316              * Initialize a grid of subimages out of a given image.
            +317              * @param image {HTMLImageElement|Image} an image object.
            +318              * @param rows {number} number of rows.
            +319              * @param columns {number} number of columns
            +320              *
            +321              * @return this
            +322              */
            +323             initialize:function (image, rows, columns) {
            +324 
            +325                 if (!image) {
            +326                     console.log("Null image for SpriteImage.");
            +327                 }
            +328 
            +329                 if ( isString(image) ) {
            +330                     image= CAAT.currentDirector.getImage(image);
            +331                 }
            +332 
            +333                 this.parentOffsetX= 0;
            +334                 this.parentOffsetY= 0;
            +335 
            +336                 this.rows = rows;
            +337                 this.columns = columns;
            +338 
            +339                 if ( image instanceof CAAT.Foundation.SpriteImage || image instanceof CAAT.SpriteImage ) {
            +340                     this.image =        image.image;
            +341                     var sihelper= image.mapInfo[0];
            +342                     this.width= sihelper.width;
            +343                     this.height= sihelper.height;
            +344 
            +345                     this.parentOffsetX= sihelper.x;
            +346                     this.parentOffsetY= sihelper.y;
            +347 
            +348                     this.width= image.mapInfo[0].width;
            +349                     this.height= image.mapInfo[0].height;
            +350 
            +351                 } else {
            +352                     this.image = image;
            +353                     this.width = image.width;
            +354                     this.height = image.height;
            +355                     this.mapInfo = {};
            +356 
            +357                 }
            +358 
            +359                 this.singleWidth = Math.floor(this.width / columns);
            +360                 this.singleHeight = Math.floor(this.height / rows);
            +361 
            +362                 var i, sx0, sy0;
            +363                 var helper;
            +364 
            +365                 if (image.__texturePage) {
            +366                     image.__du = this.singleWidth / image.__texturePage.width;
            +367                     image.__dv = this.singleHeight / image.__texturePage.height;
            +368 
            +369 
            +370                     var w = this.singleWidth;
            +371                     var h = this.singleHeight;
            +372                     var mod = this.columns;
            +373                     if (image.inverted) {
            +374                         var t = w;
            +375                         w = h;
            +376                         h = t;
            +377                         mod = this.rows;
            +378                     }
            +379 
            +380                     var xt = this.image.__tx;
            +381                     var yt = this.image.__ty;
            +382 
            +383                     var tp = this.image.__texturePage;
            +384 
            +385                     for (i = 0; i < rows * columns; i++) {
            +386 
            +387 
            +388                         var c = ((i % mod) >> 0);
            +389                         var r = ((i / mod) >> 0);
            +390 
            +391                         var u = xt + c * w;  // esquina izq x
            +392                         var v = yt + r * h;
            +393 
            +394                         var u1 = u + w;
            +395                         var v1 = v + h;
            +396 
            +397                         helper = new CAAT.Foundation.SpriteImageHelper(u, v, (u1 - u), (v1 - v), tp.width, tp.height).setGL(
            +398                             u / tp.width,
            +399                             v / tp.height,
            +400                             u1 / tp.width,
            +401                             v1 / tp.height);
            +402 
            +403                         this.mapInfo[i] = helper;
            +404                     }
            +405 
            +406                 } else {
            +407                     for (i = 0; i < rows * columns; i++) {
            +408                         sx0 = ((i % this.columns) | 0) * this.singleWidth + this.parentOffsetX;
            +409                         sy0 = ((i / this.columns) | 0) * this.singleHeight + this.parentOffsetY;
            +410 
            +411                         helper = new CAAT.Foundation.SpriteImageHelper(sx0, sy0, this.singleWidth, this.singleHeight, image.width, image.height);
            +412                         this.mapInfo[i] = helper;
            +413                     }
            +414                 }
            +415 
            +416                 return this;
            +417             },
            +418 
            +419             /**
            +420              * Create elements as director.getImage values.
            +421              * Create as much as elements defined in this sprite image.
            +422              * The elements will be named prefix+<the map info element name>
            +423              * @param prefix
            +424              */
            +425             addElementsAsImages : function( prefix ) {
            +426                 for( var i in this.mapInfo ) {
            +427                     var si= new CAAT.Foundation.SpriteImage().initialize( this.image, 1, 1 );
            +428                     si.addElement(0, this.mapInfo[i]);
            +429                     si.setSpriteIndex(0);
            +430                     CAAT.currentDirector.addImage( prefix+i, si );
            +431                 }
            +432             },
            +433 
            +434             copy : function( other ) {
            +435                 this.initialize(other,1,1);
            +436                 this.mapInfo= other.mapInfo;
            +437                 return this;
            +438             },
            +439 
            +440             /**
            +441              * Must be used to draw actor background and the actor should have setClip(true) so that the image tiles
            +442              * properly.
            +443              * @param director
            +444              * @param time
            +445              * @param x
            +446              * @param y
            +447              */
            +448             paintTiled:function (director, time, x, y) {
            +449 
            +450                 // PENDING: study using a pattern
            +451 
            +452                 var el = this.mapInfo[this.spriteIndex];
            +453 
            +454                 var r = new CAAT.Math.Rectangle();
            +455                 this.ownerActor.AABB.intersect(director.AABB, r);
            +456 
            +457                 var w = this.getWidth();
            +458                 var h = this.getHeight();
            +459                 var xoff = (this.offsetX - this.ownerActor.x) % w;
            +460                 if (xoff > 0) {
            +461                     xoff = xoff - w;
            +462                 }
            +463                 var yoff = (this.offsetY - this.ownerActor.y) % h;
            +464                 if (yoff > 0) {
            +465                     yoff = yoff - h;
            +466                 }
            +467 
            +468                 var nw = (((r.width - xoff) / w) >> 0) + 1;
            +469                 var nh = (((r.height - yoff) / h) >> 0) + 1;
            +470                 var i, j;
            +471                 var ctx = director.ctx;
            +472 
            +473                 for (i = 0; i < nh; i++) {
            +474                     for (j = 0; j < nw; j++) {
            +475                         ctx.drawImage(
            +476                             this.image,
            +477                             el.x, el.y,
            +478                             el.width, el.height,
            +479                             (r.x - this.ownerActor.x + xoff + j * el.width) >> 0, (r.y - this.ownerActor.y + yoff + i * el.height) >> 0,
            +480                             el.width, el.height);
            +481                     }
            +482                 }
            +483             },
            +484 
            +485             /**
            +486              * Draws the subimage pointed by imageIndex horizontally inverted.
            +487              * @param director {CAAT.Foundation.Director}
            +488              * @param time {number} scene time.
            +489              * @param x {number} x position in canvas to draw the image.
            +490              * @param y {number} y position in canvas to draw the image.
            +491              *
            +492              * @return this
            +493              */
            +494             paintInvertedH:function (director, time, x, y) {
            +495 
            +496                 var el = this.mapInfo[this.spriteIndex];
            +497 
            +498                 var ctx = director.ctx;
            +499                 ctx.save();
            +500                 //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0);
            +501                 ctx.translate((x | 0) + el.width, y | 0);
            +502                 ctx.scale(-1, 1);
            +503 
            +504 
            +505                 ctx.drawImage(
            +506                     this.image,
            +507                     el.x, el.y,
            +508                     el.width, el.height,
            +509                     this.offsetX >> 0, this.offsetY >> 0,
            +510                     el.width, el.height);
            +511 
            +512                 ctx.restore();
            +513 
            +514                 return this;
            +515             },
            +516             /**
            +517              * Draws the subimage pointed by imageIndex vertically inverted.
            +518              * @param director {CAAT.Foundation.Director}
            +519              * @param time {number} scene time.
            +520              * @param x {number} x position in canvas to draw the image.
            +521              * @param y {number} y position in canvas to draw the image.
            +522              *
            +523              * @return this
            +524              */
            +525             paintInvertedV:function (director, time, x, y) {
            +526 
            +527                 var el = this.mapInfo[this.spriteIndex];
            +528 
            +529                 var ctx = director.ctx;
            +530                 ctx.save();
            +531                 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0);
            +532                 ctx.translate(x | 0, (y + el.height) | 0);
            +533                 ctx.scale(1, -1);
            +534 
            +535                 ctx.drawImage(
            +536                     this.image,
            +537                     el.x, el.y,
            +538                     el.width, el.height,
            +539                     this.offsetX >> 0, this.offsetY >> 0,
            +540                     el.width, el.height);
            +541 
            +542                 ctx.restore();
            +543 
            +544                 return this;
            +545             },
            +546             /**
            +547              * Draws the subimage pointed by imageIndex both horizontal and vertically inverted.
            +548              * @param director {CAAT.Foundation.Director}
            +549              * @param time {number} scene time.
            +550              * @param x {number} x position in canvas to draw the image.
            +551              * @param y {number} y position in canvas to draw the image.
            +552              *
            +553              * @return this
            +554              */
            +555             paintInvertedHV:function (director, time, x, y) {
            +556 
            +557                 var el = this.mapInfo[this.spriteIndex];
            +558 
            +559                 var ctx = director.ctx;
            +560                 ctx.save();
            +561                 //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0);
            +562                 ctx.translate(x | 0, (y + el.height) | 0);
            +563                 ctx.scale(1, -1);
            +564                 ctx.translate(el.width, 0);
            +565                 ctx.scale(-1, 1);
            +566 
            +567                 ctx.drawImage(
            +568                     this.image,
            +569                     el.x, el.y,
            +570                     el.width, el.height,
            +571                     this.offsetX >> 0, this.offsetY >> 0,
            +572                     el.width, el.height);
            +573 
            +574                 ctx.restore();
            +575 
            +576                 return this;
            +577             },
            +578             /**
            +579              * Draws the subimage pointed by imageIndex.
            +580              * @param director {CAAT.Foundation.Director}
            +581              * @param time {number} scene time.
            +582              * @param x {number} x position in canvas to draw the image.
            +583              * @param y {number} y position in canvas to draw the image.
            +584              *
            +585              * @return this
            +586              */
            +587             paintN:function (director, time, x, y) {
            +588 
            +589                 var el = this.mapInfo[this.spriteIndex];
            +590 
            +591                 director.ctx.drawImage(
            +592                     this.image,
            +593                     el.x, el.y,
            +594                     el.width, el.height,
            +595                     (this.offsetX + x) >> 0, (this.offsetY + y) >> 0,
            +596                     el.width, el.height);
            +597 
            +598                 return this;
            +599             },
            +600             paintAtRect:function (director, time, x, y, w, h) {
            +601 
            +602                 var el = this.mapInfo[this.spriteIndex];
            +603 
            +604                 director.ctx.drawImage(
            +605                     this.image,
            +606                     el.x, el.y,
            +607                     el.width, el.height,
            +608                     (this.offsetX + x) >> 0, (this.offsetY + y) >> 0,
            +609                     w, h);
            +610 
            +611                 return this;
            +612             },
            +613             /**
            +614              * Draws the subimage pointed by imageIndex.
            +615              * @param director {CAAT.Foundation.Director}
            +616              * @param time {number} scene time.
            +617              * @param x {number} x position in canvas to draw the image.
            +618              * @param y {number} y position in canvas to draw the image.
            +619              *
            +620              * @return this
            +621              */
            +622             paintScaledWidth:function (director, time, x, y) {
            +623 
            +624                 var el = this.mapInfo[this.spriteIndex];
            +625 
            +626                 director.ctx.drawImage(
            +627                     this.image,
            +628                     el.x, el.y,
            +629                     el.width, el.height,
            +630                     (this.offsetX + x) >> 0, (this.offsetY + y) >> 0,
            +631                     this.ownerActor.width, el.height);
            +632 
            +633                 return this;
            +634             },
            +635             paintChunk:function (ctx, dx, dy, x, y, w, h) {
            +636                 ctx.drawImage(this.image, x, y, w, h, dx, dy, w, h);
            +637             },
            +638             paintTile:function (ctx, index, x, y) {
            +639                 var el = this.mapInfo[index];
            +640                 ctx.drawImage(
            +641                     this.image,
            +642                     el.x, el.y,
            +643                     el.width, el.height,
            +644                     (this.offsetX + x) >> 0, (this.offsetY + y) >> 0,
            +645                     el.width, el.height);
            +646 
            +647                 return this;
            +648             },
            +649             /**
            +650              * Draws the subimage pointed by imageIndex scaled to the size of w and h.
            +651              * @param director {CAAT.Foundation.Director}
            +652              * @param time {number} scene time.
            +653              * @param x {number} x position in canvas to draw the image.
            +654              * @param y {number} y position in canvas to draw the image.
            +655              *
            +656              * @return this
            +657              */
            +658             paintScaled:function (director, time, x, y) {
            +659 
            +660                 var el = this.mapInfo[this.spriteIndex];
            +661 
            +662                 director.ctx.drawImage(
            +663                     this.image,
            +664                     el.x, el.y,
            +665                     el.width, el.height,
            +666                     (this.offsetX + x) >> 0, (this.offsetY + y) >> 0,
            +667                     this.ownerActor.width, this.ownerActor.height);
            +668 
            +669                 return this;
            +670             },
            +671             getCurrentSpriteImageCSSPosition:function () {
            +672                 var el = this.mapInfo[this.spriteIndex];
            +673 
            +674                 var x = -(el.x + this.parentOffsetX - this.offsetX);
            +675                 var y = -(el.y + this.parentOffsetY - this.offsetY);
            +676 
            +677                 return '' + x + 'px ' +
            +678                     y + 'px ' +
            +679                     (this.ownerActor.transformation === CAAT.Foundation.SpriteImage.TR_TILE ? 'repeat' : 'no-repeat');
            +680             },
            +681             /**
            +682              * Get the number of subimages in this compoundImage
            +683              * @return {number}
            +684              */
            +685             getNumImages:function () {
            +686                 return this.rows * this.columns;
            +687             },
            +688 
            +689             setUV:function (uvBuffer, uvIndex) {
            +690                 var im = this.image;
            +691 
            +692                 if (!im.__texturePage) {
            +693                     return;
            +694                 }
            +695 
            +696                 var index = uvIndex;
            +697                 var sIndex = this.spriteIndex;
            +698                 var el = this.mapInfo[this.spriteIndex];
            +699 
            +700                 var u = el.u;
            +701                 var v = el.v;
            +702                 var u1 = el.u1;
            +703                 var v1 = el.v1;
            +704                 if (this.offsetX || this.offsetY) {
            +705                     var w = this.ownerActor.width;
            +706                     var h = this.ownerActor.height;
            +707 
            +708                     var tp = im.__texturePage;
            +709 
            +710                     var _u = -this.offsetX / tp.width;
            +711                     var _v = -this.offsetY / tp.height;
            +712                     var _u1 = (w - this.offsetX) / tp.width;
            +713                     var _v1 = (h - this.offsetY) / tp.height;
            +714 
            +715                     u = _u + im.__u;
            +716                     v = _v + im.__v;
            +717                     u1 = _u1 + im.__u;
            +718                     v1 = _v1 + im.__v;
            +719                 }
            +720 
            +721                 if (im.inverted) {
            +722                     uvBuffer[index++] = u1;
            +723                     uvBuffer[index++] = v;
            +724 
            +725                     uvBuffer[index++] = u1;
            +726                     uvBuffer[index++] = v1;
            +727 
            +728                     uvBuffer[index++] = u;
            +729                     uvBuffer[index++] = v1;
            +730 
            +731                     uvBuffer[index++] = u;
            +732                     uvBuffer[index++] = v;
            +733                 } else {
            +734                     uvBuffer[index++] = u;
            +735                     uvBuffer[index++] = v;
            +736 
            +737                     uvBuffer[index++] = u1;
            +738                     uvBuffer[index++] = v;
            +739 
            +740                     uvBuffer[index++] = u1;
            +741                     uvBuffer[index++] = v1;
            +742 
            +743                     uvBuffer[index++] = u;
            +744                     uvBuffer[index++] = v1;
            +745                 }
            +746             },
            +747             /**
            +748              * Set the elapsed time needed to change the image index.
            +749              * @param fps an integer indicating the time in milliseconds to change.
            +750              * @return this
            +751              */
            +752             setChangeFPS:function (fps) {
            +753                 this.changeFPS = fps;
            +754                 return this;
            +755             },
            +756             /**
            +757              * Set the transformation to apply to the Sprite image.
            +758              * Any value of
            +759              *  <li>TR_NONE
            +760              *  <li>TR_FLIP_HORIZONTAL
            +761              *  <li>TR_FLIP_VERTICAL
            +762              *  <li>TR_FLIP_ALL
            +763              *
            +764              * @param transformation an integer indicating one of the previous values.
            +765              * @return this
            +766              */
            +767             setSpriteTransformation:function (transformation) {
            +768                 this.transformation = transformation;
            +769                 var v = CAAT.Foundation.SpriteImage;
            +770                 switch (transformation) {
            +771                     case v.TR_FLIP_HORIZONTAL:
            +772                         this.paint = this.paintInvertedH;
            +773                         break;
            +774                     case v.TR_FLIP_VERTICAL:
            +775                         this.paint = this.paintInvertedV;
            +776                         break;
            +777                     case v.TR_FLIP_ALL:
            +778                         this.paint = this.paintInvertedHV;
            +779                         break;
            +780                     case v.TR_FIXED_TO_SIZE:
            +781                         this.paint = this.paintScaled;
            +782                         break;
            +783                     case v.TR_FIXED_WIDTH_TO_SIZE:
            +784                         this.paint = this.paintScaledWidth;
            +785                         break;
            +786                     case v.TR_TILE:
            +787                         this.paint = this.paintTiled;
            +788                         break;
            +789                     default:
            +790                         this.paint = this.paintN;
            +791                 }
            +792                 this.ownerActor.invalidate();
            +793                 return this;
            +794             },
            +795 
            +796             resetAnimationTime:function () {
            +797                 this.prevAnimationTime = -1;
            +798                 return this;
            +799             },
            +800 
            +801             /**
            +802              * Set the sprite animation images index. This method accepts an array of objects which define indexes to
            +803              * subimages inside this sprite image.
            +804              * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of
            +805              * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages
            +806              * with size rows*columns.
            +807              * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected
            +808              * to be an array of strings which are the names of the subobjects contained in the map object.
            +809              *
            +810              * @param aAnimationImageIndex an array indicating the Sprite's frames.
            +811              */
            +812             setAnimationImageIndex:function (aAnimationImageIndex) {
            +813                 this.animationImageIndex = aAnimationImageIndex;
            +814                 this.spriteIndex = aAnimationImageIndex[0];
            +815                 this.prevAnimationTime = -1;
            +816 
            +817                 return this;
            +818             },
            +819             setSpriteIndex:function (index) {
            +820                 this.spriteIndex = index;
            +821                 return this;
            +822             },
            +823 
            +824             /**
            +825              * Draws the sprite image calculated and stored in spriteIndex.
            +826              *
            +827              * @param time {number} Scene time when the bounding box is to be drawn.
            +828              */
            +829             setSpriteIndexAtTime:function (time) {
            +830 
            +831                 if (this.animationImageIndex.length > 1) {
            +832                     if (this.prevAnimationTime === -1) {
            +833                         this.prevAnimationTime = time;
            +834 
            +835                         //thanks Phloog and ghthor, well spotted.
            +836                         this.spriteIndex = this.animationImageIndex[0];
            +837                         this.prevIndex= 0;
            +838                         this.ownerActor.invalidate();
            +839                     }
            +840                     else {
            +841                         var ttime = time;
            +842                         ttime -= this.prevAnimationTime;
            +843                         ttime /= this.changeFPS;
            +844                         ttime %= this.animationImageIndex.length;
            +845                         var idx = Math.floor(ttime);
            +846 //                    if ( this.spriteIndex!==idx ) {
            +847 
            +848                         if ( idx<this.prevIndex ) {   // we are getting back in time, or ended playing the animation
            +849                             if ( this.callback ) {
            +850                                 this.callback( this, time );
            +851                             }
            +852                         }
            +853 
            +854                         this.prevIndex= idx;
            +855                         this.spriteIndex = this.animationImageIndex[idx];
            +856                         this.ownerActor.invalidate();
            +857 //                    }
            +858                     }
            +859                 }
            +860             },
            +861 
            +862             getMapInfo:function (index) {
            +863                 return this.mapInfo[ index ];
            +864             },
            +865 
            +866             initializeFromGlyphDesigner : function( text ) {
            +867                 for (var i = 0; i < text.length; i++) {
            +868                     if (0 === text[i].indexOf("char ")) {
            +869                         var str = text[i].substring(5);
            +870                         var pairs = str.split(' ');
            +871                         var obj = {
            +872                             x: 0,
            +873                             y: 0,
            +874                             width: 0,
            +875                             height: 0,
            +876                             xadvance: 0,
            +877                             xoffset: 0,
            +878                             yoffset: 0
            +879                         };
            +880 
            +881                         for (var j = 0; j < pairs.length; j++) {
            +882                             var pair = pairs[j];
            +883                             var pairData = pair.split("=");
            +884                             var key = pairData[0];
            +885                             var value = pairData[1];
            +886                             if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
            +887                                 value.substring(1, value.length - 1);
            +888                             }
            +889                             obj[ key ] = value;
            +890                         }
            +891 
            +892                         this.addElement(String.fromCharCode(obj.id), obj);
            +893                     }
            +894                 }
            +895 
            +896                 return this;
            +897             },
            +898 
            +899             /**
            +900              * This method takes the output generated from the tool at http://labs.hyperandroid.com/static/texture/spriter.html
            +901              * and creates a map into that image.
            +902              * @param image {Image|HTMLImageElement|Canvas} an image
            +903              * @param map {object} the map into the image to define subimages.
            +904              */
            +905             initializeFromMap:function (image, map) {
            +906                 this.initialize(image, 1, 1);
            +907 
            +908                 var key;
            +909                 var helper;
            +910                 var count = 0;
            +911 
            +912                 for (key in map) {
            +913                     var value = map[key];
            +914 
            +915                     helper = new CAAT.Foundation.SpriteImageHelper(
            +916                         parseFloat(value.x) + this.parentOffsetX,
            +917                         parseFloat(value.y) + this.parentOffsetY,
            +918                         parseFloat(value.width),
            +919                         parseFloat(value.height),
            +920                         image.width,
            +921                         image.height
            +922                     );
            +923 
            +924                     this.mapInfo[key] = helper;
            +925 
            +926                     // set a default spriteIndex
            +927                     if (!count) {
            +928                         this.setAnimationImageIndex([key]);
            +929                     }
            +930 
            +931                     count++;
            +932                 }
            +933 
            +934                 return this;
            +935             },
            +936 
            +937             initializeFromTexturePackerJSON : function( image, obj ) {
            +938 
            +939                 for( var img in obj.frames ) {
            +940                     var imgData= obj.frames[img];
            +941 
            +942                     var si_obj= {
            +943                         x: imgData.frame.x,
            +944                         y: imgData.frame.y,
            +945                         width: imgData.spriteSourceSize.w,
            +946                         height: imgData.spriteSourceSize.h,
            +947                         id: '0'
            +948                     };
            +949 
            +950                     var si= new CAAT.Foundation.SpriteImage().initialize( image, 1, 1 );
            +951                     si.addElement(0,si_obj);
            +952                     CAAT.currentDirector.addImage( img.substring(0,img.indexOf('.')), si );
            +953                 }
            +954             },
            +955 
            +956             /**
            +957              * Add one element to the spriteImage.
            +958              * @param key {string|number} index or sprite identifier.
            +959              * @param value object{
            +960              *      x: {number},
            +961              *      y: {number},
            +962              *      width: {number},
            +963              *      height: {number},
            +964              *      xoffset: {number=},
            +965              *      yoffset: {number=},
            +966              *      xadvance: {number=}
            +967              *      }
            +968              * @return {*}
            +969              */
            +970             addElement : function( key, value ) {
            +971                 var helper = new CAAT.Foundation.SpriteImageHelper(
            +972                     parseFloat(value.x) + this.parentOffsetX,
            +973                     parseFloat(value.y) + this.parentOffsetY,
            +974                     parseFloat(value.width),
            +975                     parseFloat(value.height),
            +976                     this.image.width,
            +977                     this.image.height );
            +978 
            +979                 helper.xoffset = typeof value.xoffset === 'undefined' ? 0 : parseFloat(value.xoffset);
            +980                 helper.yoffset = typeof value.yoffset === 'undefined' ? 0 : parseFloat(value.yoffset);
            +981                 helper.xadvance = typeof value.xadvance === 'undefined' ? value.width : parseFloat(value.xadvance);
            +982 
            +983                 this.mapInfo[key] = helper;
            +984 
            +985                 return this;
            +986             },
            +987 
            +988             /**
            +989              *
            +990              * @param image {Image|HTMLImageElement|Canvas}
            +991              * @param map object with pairs "<a char>" : {
            +992              *              id      : {number},
            +993              *              height  : {number},
            +994              *              xoffset : {number},
            +995              *              letter  : {string},
            +996              *              yoffset : {number},
            +997              *              width   : {number},
            +998              *              xadvance: {number},
            +999              *              y       : {number},
            +1000              *              x       : {number}
            +1001              *          }
            +1002              */
            +1003             initializeAsGlyphDesigner:function (image, map) {
            +1004                 this.initialize(image, 1, 1);
            +1005 
            +1006                 var key;
            +1007                 var helper;
            +1008                 var count = 0;
            +1009 
            +1010                 for (key in map) {
            +1011                     var value = map[key];
            +1012 
            +1013                     helper = new CAAT.Foundation.SpriteImageHelper(
            +1014                         parseFloat(value.x) + this.parentOffsetX,
            +1015                         parseFloat(value.y) + this.parentOffsetX,
            +1016                         parseFloat(value.width),
            +1017                         parseFloat(value.height),
            +1018                         image.width,
            +1019                         image.height
            +1020                     );
            +1021 
            +1022                     helper.xoffset = typeof value.xoffset === 'undefined' ? 0 : value.xoffset;
            +1023                     helper.yoffset = typeof value.yoffset === 'undefined' ? 0 : value.yoffset;
            +1024                     helper.xadvance = typeof value.xadvance === 'undefined' ? value.width : value.xadvance;
            +1025 
            +1026                     this.mapInfo[key] = helper;
            +1027 
            +1028                     // set a default spriteIndex
            +1029                     if (!count) {
            +1030                         this.setAnimationImageIndex([key]);
            +1031                     }
            +1032 
            +1033                     count++;
            +1034                 }
            +1035 
            +1036                 return this;
            +1037 
            +1038             },
            +1039 
            +1040 
            +1041             initializeAsFontMap:function (image, chars) {
            +1042                 this.initialize(image, 1, 1);
            +1043 
            +1044                 var helper;
            +1045                 var x = 0;
            +1046 
            +1047                 for (var i = 0; i < chars.length; i++) {
            +1048                     var value = chars[i];
            +1049 
            +1050                     helper = new CAAT.Foundation.SpriteImageHelper(
            +1051                         parseFloat(x) + this.parentOffsetX,
            +1052                         0 + this.parentOffsetY,
            +1053                         parseFloat(value.width),
            +1054                         image.height,
            +1055                         image.width,
            +1056                         image.height
            +1057                     );
            +1058 
            +1059                     helper.xoffset = 0;
            +1060                     helper.yoffset = 0;
            +1061                     helper.xadvance = value.width;
            +1062 
            +1063 
            +1064                     x += value.width;
            +1065 
            +1066                     this.mapInfo[chars[i].c] = helper;
            +1067 
            +1068                     // set a default spriteIndex
            +1069                     if (!i) {
            +1070                         this.setAnimationImageIndex([chars[i].c]);
            +1071                     }
            +1072                 }
            +1073 
            +1074                 return this;
            +1075             },
            +1076 
            +1077             /**
            +1078              * This method creates a font sprite image based on a proportional font
            +1079              * It assumes the font is evenly spaced in the image
            +1080              * Example:
            +1081              * var font =   new CAAT.SpriteImage().initializeAsMonoTypeFontMap(
            +1082              *  director.getImage('numbers'),
            +1083              *  "0123456789"
            +1084              * );
            +1085              */
            +1086 
            +1087             initializeAsMonoTypeFontMap:function (image, chars) {
            +1088                 var map = [];
            +1089                 var charArr = chars.split("");
            +1090 
            +1091                 var w = image.width / charArr.length >> 0;
            +1092 
            +1093                 for (var i = 0; i < charArr.length; i++) {
            +1094                     map.push({c:charArr[i], width:w });
            +1095                 }
            +1096 
            +1097                 return this.initializeAsFontMap(image, map);
            +1098             },
            +1099 
            +1100             stringWidth:function (str) {
            +1101                 var i, l, w = 0, charInfo;
            +1102 
            +1103                 for (i = 0, l = str.length; i < l; i++) {
            +1104                     charInfo = this.mapInfo[ str.charAt(i) ];
            +1105                     if (charInfo) {
            +1106                         w += charInfo.xadvance * this.fontScale;
            +1107                     }
            +1108                 }
            +1109 
            +1110                 return w;
            +1111             },
            +1112 
            +1113             stringHeight:function () {
            +1114                 if (this.fontHeight) {
            +1115                     return this.fontHeight * this.fontScale;
            +1116                 }
            +1117 
            +1118                 var y = 0;
            +1119                 for (var i in this.mapInfo) {
            +1120                     var mi = this.mapInfo[i];
            +1121 
            +1122                     var h = mi.height + mi.yoffset;
            +1123                     if (h > y) {
            +1124                         y = h;
            +1125                     }
            +1126                 }
            +1127 
            +1128                 this.fontHeight = y;
            +1129                 return this.fontHeight * this.fontScale;
            +1130             },
            +1131 
            +1132             drawText:function (str, ctx, x, y) {
            +1133                 var i, l, charInfo, w;
            +1134 
            +1135                 for (i = 0; i < str.length; i++) {
            +1136                     charInfo = this.mapInfo[ str.charAt(i) ];
            +1137                     if (charInfo) {
            +1138                         w = charInfo.width;
            +1139                         if ( w>0 && charInfo.height>0 ) {
            +1140                             ctx.drawImage(
            +1141                                 this.image,
            +1142                                 charInfo.x, charInfo.y,
            +1143                                 w, charInfo.height,
            +1144 
            +1145                                 x + charInfo.xoffset* this.fontScale, y + charInfo.yoffset* this.fontScale,
            +1146                                 w* this.fontScale, charInfo.height* this.fontScale);
            +1147                         }
            +1148                         x += charInfo.xadvance* this.fontScale;
            +1149                     }
            +1150                 }
            +1151             },
            +1152 
            +1153             getFontData : function() {
            +1154                 var as= (this.stringHeight() *.8)>>0;
            +1155                 return {
            +1156                     height : this.stringHeight(),
            +1157                     ascent : as,
            +1158                     descent: this.stringHeight() - as
            +1159                 };
            +1160 
            +1161             }
            +1162 
            +1163         }
            +1164     }
            +1165 });
            +1166 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageAnimationHelper.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageAnimationHelper.js.html new file mode 100644 index 0000000..acb1376 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageAnimationHelper.js.html @@ -0,0 +1,54 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      *
            +  5      * Define an animation frame sequence, name it and supply with a callback which be called when the
            +  6      * sequence ends playing.
            +  7      *
            +  8      * @name SpriteImageAnimationHelper
            +  9      * @memberOf CAAT.Foundation
            + 10      * @constructor
            + 11      */
            + 12 
            + 13     defines : "CAAT.Foundation.SpriteImageAnimationHelper",
            + 14     extendsWith : function() {
            + 15         return {
            + 16 
            + 17             /**
            + 18              * @lends  CAAT.Foundation.SpriteImageAnimationHelper.prototype
            + 19              */
            + 20 
            + 21             __init : function( animation, time, onEndPlayCallback ) {
            + 22                 this.animation= animation;
            + 23                 this.time= time;
            + 24                 this.onEndPlayCallback= onEndPlayCallback;
            + 25                 return this;
            + 26             },
            + 27 
            + 28             /**
            + 29              * A sequence of integer values defining a frame animation.
            + 30              * For example [1,2,3,4,3,2,3,4,3,2]
            + 31              * Array.<number>
            + 32              */
            + 33             animation :         null,
            + 34 
            + 35             /**
            + 36              * Time between any two animation frames.
            + 37              */
            + 38             time :              0,
            + 39 
            + 40             /**
            + 41              * Call this callback function when the sequence ends.
            + 42              */
            + 43             onEndPlayCallback : null
            + 44 
            + 45         }
            + 46     }
            + 47 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageHelper.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageHelper.js.html new file mode 100644 index 0000000..f63eacc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_SpriteImageHelper.js.html @@ -0,0 +1,58 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * Define a drawable sub-image inside a bigger image as an independant drawable item.
            +  5      *
            +  6      * @name SpriteImageHelper
            +  7      * @memberOf CAAT.Foundation
            +  8      * @constructor
            +  9      *
            + 10      *
            + 11      *
            + 12      */
            + 13 
            + 14 
            + 15     defines : "CAAT.Foundation.SpriteImageHelper",
            + 16 
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends  CAAT.Foundation.SpriteImageHelper.prototype
            + 21          */
            + 22 
            + 23         __init : function (x, y, w, h, iw, ih) {
            + 24             this.x = parseFloat(x);
            + 25             this.y = parseFloat(y);
            + 26             this.width = parseFloat(w);
            + 27             this.height = parseFloat(h);
            + 28 
            + 29             this.setGL(x / iw, y / ih, (x + w - 1) / iw, (y + h - 1) / ih);
            + 30             return this;
            + 31         },
            + 32 
            + 33         x:0,
            + 34         y:0,
            + 35         width:0,
            + 36         height:0,
            + 37         u:0,
            + 38         v:0,
            + 39         u1:0,
            + 40         v1:0,
            + 41 
            + 42         setGL:function (u, v, u1, v1) {
            + 43             this.u = u;
            + 44             this.v = v;
            + 45             this.u1 = u1;
            + 46             this.v1 = v1;
            + 47             return this;
            + 48         }
            + 49     }
            + 50 });
            + 51 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerManager.js.html new file mode 100644 index 0000000..e1a58f4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerManager.js.html @@ -0,0 +1,141 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  */
            +  4 CAAT.Module({
            +  5 
            +  6     /**
            +  7      * @name Timer
            +  8      * @memberOf CAAT.Foundation
            +  9      * @namespace
            + 10      */
            + 11 
            + 12     /**
            + 13      * @name TimerManager
            + 14      * @memberOf CAAT.Foundation.Timer
            + 15      * @constructor
            + 16      */
            + 17 
            + 18     defines : "CAAT.Foundation.Timer.TimerManager",
            + 19     aliases : ["CAAT.TimerManager"],
            + 20     depends : [
            + 21         "CAAT.Foundation.Timer.TimerTask"
            + 22     ],
            + 23     extendsWith :   {
            + 24 
            + 25         /**
            + 26          * @lends CAAT.Foundation.Timer.TimerManager.prototype
            + 27          */
            + 28 
            + 29         __init:function () {
            + 30             this.timerList = [];
            + 31             return this;
            + 32         },
            + 33 
            + 34         /**
            + 35          * Collection of registered timers.
            + 36          * @type {CAAT.Foundation.Timer.TimerManager}
            + 37          * @private
            + 38          */
            + 39         timerList:null,
            + 40 
            + 41         /**
            + 42          * Index sequence to idenfity registered timers.
            + 43          * @private
            + 44          */
            + 45         timerSequence:0,
            + 46 
            + 47         /**
            + 48          * Check and apply timers in frame time.
            + 49          * @param time {number} the current Scene time.
            + 50          */
            + 51         checkTimers:function (time) {
            + 52             var tl = this.timerList;
            + 53             var i = tl.length - 1;
            + 54             while (i >= 0) {
            + 55                 if (!tl[i].remove) {
            + 56                     tl[i].checkTask(time);
            + 57                 }
            + 58                 i--;
            + 59             }
            + 60         },
            + 61         /**
            + 62          * Make sure the timertask is contained in the timer task list by adding it to the list in case it
            + 63          * is not contained.
            + 64          * @param timertask {CAAT.Foundation.Timer.TimerTask}.
            + 65          * @return this
            + 66          */
            + 67         ensureTimerTask:function (timertask) {
            + 68             if (!this.hasTimer(timertask)) {
            + 69                 this.timerList.push(timertask);
            + 70             }
            + 71             return this;
            + 72         },
            + 73         /**
            + 74          * Check whether the timertask is in this scene's timer task list.
            + 75          * @param timertask {CAAT.Foundation.Timer.TimerTask}.
            + 76          * @return {boolean} a boolean indicating whether the timertask is in this scene or not.
            + 77          */
            + 78         hasTimer:function (timertask) {
            + 79             var tl = this.timerList;
            + 80             var i = tl.length - 1;
            + 81             while (i >= 0) {
            + 82                 if (tl[i] === timertask) {
            + 83                     return true;
            + 84                 }
            + 85                 i--;
            + 86             }
            + 87 
            + 88             return false;
            + 89         },
            + 90         /**
            + 91          * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene
            + 92          * is taken out of the Director the timer task is paused, and resumed on Scene restoration.
            + 93          *
            + 94          * @param startTime {number} an integer indicating the scene time this task must start executing at.
            + 95          * @param duration {number} an integer indicating the timerTask duration.
            + 96          * @param callback_timeout {function} timer on timeout callback function.
            + 97          * @param callback_tick {function} timer on tick callback function.
            + 98          * @param callback_cancel {function} timer on cancel callback function.
            + 99          *
            +100          * @return {CAAT.TimerTask} a CAAT.TimerTask class instance.
            +101          */
            +102         createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) {
            +103 
            +104             var tt = new CAAT.Foundation.Timer.TimerTask().create(
            +105                 startTime,
            +106                 duration,
            +107                 callback_timeout,
            +108                 callback_tick,
            +109                 callback_cancel);
            +110 
            +111             tt.taskId = this.timerSequence++;
            +112             tt.sceneTime = scene.time;
            +113             tt.owner = this;
            +114             tt.scene = scene;
            +115 
            +116             this.timerList.push(tt);
            +117 
            +118             return tt;
            +119         },
            +120         /**
            +121          * Removes expired timers. This method must not be called directly.
            +122          */
            +123         removeExpiredTimers:function () {
            +124             var i;
            +125             var tl = this.timerList;
            +126             for (i = 0; i < tl.length; i++) {
            +127                 if (tl[i].remove) {
            +128                     tl.splice(i, 1);
            +129                 }
            +130             }
            +131         }
            +132     }
            +133 });
            +134 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerTask.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerTask.js.html new file mode 100644 index 0000000..f49bc1c --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_Timer_TimerTask.js.html @@ -0,0 +1,145 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TimerTask
            +  5      * @memberOf CAAT.Foundation.Timer
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Foundation.Timer.TimerTask",
            + 10     aliases : ["CAAT.TimerTask"],
            + 11     extendsWith : {
            + 12 
            + 13         /**
            + 14          * @lends CAAT.Foundation.Timer.TimerTask.prototype
            + 15          */
            + 16 
            + 17         /**
            + 18          * Timer start time. Relative to Scene or Director time, depending who owns this TimerTask.
            + 19          */
            + 20         startTime:          0,
            + 21 
            + 22         /**
            + 23          * Timer duration.
            + 24          */
            + 25         duration:           0,
            + 26 
            + 27         /**
            + 28          * This callback will be called only once, when the timer expires.
            + 29          */
            + 30         callback_timeout:   null,
            + 31 
            + 32         /**
            + 33          * This callback will be called whenever the timer is checked in time.
            + 34          */
            + 35         callback_tick:      null,
            + 36 
            + 37         /**
            + 38          * This callback will be called when the timer is cancelled.
            + 39          */
            + 40         callback_cancel:    null,
            + 41 
            + 42         /**
            + 43          * What TimerManager instance owns this task.
            + 44          */
            + 45         owner:              null,
            + 46 
            + 47         /**
            + 48          * Scene or director instance that owns this TimerTask owner.
            + 49          */
            + 50         scene:              null,   // scene or director instance
            + 51 
            + 52         /**
            + 53          * An arbitrry id.
            + 54          */
            + 55         taskId:             0,
            + 56 
            + 57         /**
            + 58          * Remove this timer task on expiration/cancellation ?
            + 59          */
            + 60         remove:             false,
            + 61 
            + 62         /**
            + 63          * Create a TimerTask.
            + 64          * The taskId will be set by the scene.
            + 65          * @param startTime {number} an integer indicating TimerTask enable time.
            + 66          * @param duration {number} an integer indicating TimerTask duration.
            + 67          * @param callback_timeout {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on timeout callback function.
            + 68          * @param callback_tick {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on tick callback function.
            + 69          * @param callback_cancel {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on cancel callback function.
            + 70          *
            + 71          * @return this
            + 72          */
            + 73         create: function( startTime, duration, callback_timeout, callback_tick, callback_cancel ) {
            + 74             this.startTime=         startTime;
            + 75             this.duration=          duration;
            + 76             this.callback_timeout=  callback_timeout;
            + 77             this.callback_tick=     callback_tick;
            + 78             this.callback_cancel=   callback_cancel;
            + 79             return this;
            + 80         },
            + 81         /**
            + 82          * Performs TimerTask operation. The task will check whether it is in frame time, and will
            + 83          * either notify callback_timeout or callback_tick.
            + 84          *
            + 85          * @param time {number} an integer indicating scene time.
            + 86          * @return this
            + 87          *
            + 88          * @protected
            + 89          *
            + 90          */
            + 91         checkTask : function(time) {
            + 92             var ttime= time;
            + 93             ttime-= this.startTime;
            + 94             if ( ttime>=this.duration ) {
            + 95                 this.remove= true;
            + 96                 if( this.callback_timeout ) {
            + 97                     this.callback_timeout( time, ttime, this );
            + 98                 }
            + 99             } else {
            +100                 if ( this.callback_tick ) {
            +101                     this.callback_tick( time, ttime, this );
            +102                 }
            +103             }
            +104             return this;
            +105         },
            +106         remainingTime : function() {
            +107             return this.duration - (this.scene.time-this.startTime);
            +108         },
            +109         /**
            +110          * Reschedules this TimerTask by changing its startTime to current scene's time.
            +111          * @param time {number} an integer indicating scene time.
            +112          * @return this
            +113          */
            +114         reset : function( time ) {
            +115             this.remove= false;
            +116             this.startTime=  time;
            +117             this.owner.ensureTimerTask(this);
            +118             return this;
            +119         },
            +120         /**
            +121          * Cancels this timer by removing it on scene's next frame. The function callback_cancel will
            +122          * be called.
            +123          * @return this
            +124          */
            +125         cancel : function() {
            +126             this.remove= true;
            +127             if ( null!=this.callback_cancel ) {
            +128                 this.callback_cancel( this.scene.time, this.scene.time-this.startTime, this );
            +129             }
            +130             return this;
            +131         },
            +132         addTime : function( time ) {
            +133             this.duration+= time;
            +134             return this;
            +135         }
            +136     }
            +137 });
            +138 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Dock.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Dock.js.html new file mode 100644 index 0000000..352a9a2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Dock.js.html @@ -0,0 +1,390 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * In this file we'll be adding every useful Actor that is specific for certain purpose.
            +  5  *
            +  6  * + CAAT.Dock: a docking container that zooms in/out its actors.
            +  7  *
            +  8  */
            +  9 
            + 10 CAAT.Module( {
            + 11 
            + 12     /**
            + 13      * @name UI
            + 14      * @memberOf CAAT.Foundation
            + 15      * @namespace
            + 16      */
            + 17 
            + 18     /**
            + 19      * @name Dock
            + 20      * @memberOf CAAT.Foundation.UI
            + 21      * @extends CAAT.Foundation.ActorContainer
            + 22      * @constructor
            + 23      */
            + 24 
            + 25     defines : "CAAT.Foundation.UI.Dock",
            + 26     aliases : ["CAAT.Dock"],
            + 27     extendsClass : "CAAT.Foundation.ActorContainer",
            + 28     depends : [
            + 29         "CAAT.Foundation.ActorContainer",
            + 30         "CAAT.Behavior.GenericBehavior"
            + 31     ],
            + 32     constants : {
            + 33 
            + 34         /**
            + 35          * @lends CAAT.Foundation.UI.Dock
            + 36          */
            + 37 
            + 38         /**
            + 39          * @const
            + 40          */
            + 41         OP_LAYOUT_BOTTOM:   0,
            + 42         /**
            + 43          * @const
            + 44          */
            + 45         OP_LAYOUT_TOP:      1,
            + 46         /**
            + 47          * @const
            + 48          */
            + 49         OP_LAYOUT_LEFT:     2,
            + 50         /**
            + 51          * @const
            + 52          */
            + 53         OP_LAYOUT_RIGHT:    3
            + 54     },
            + 55     extendsWith : {
            + 56 
            + 57         /**
            + 58          * @lends CAAT.Foundation.UI.Dock.prototype
            + 59          */
            + 60 
            + 61         /**
            + 62          * scene the actor is in.
            + 63          */
            + 64         scene:              null,
            + 65 
            + 66         /**
            + 67          * resetting dimension timer task.
            + 68          */
            + 69         ttask:              null,
            + 70 
            + 71         /**
            + 72          * min contained actor size.
            + 73          */
            + 74         minSize:            0,
            + 75 
            + 76         /**
            + 77          * max contained actor size
            + 78          */
            + 79         maxSize:            0,
            + 80 
            + 81         /**
            + 82          * aproximated number of elements affected.
            + 83          */
            + 84         range:              2,
            + 85 
            + 86         /**
            + 87          * Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_*
            + 88          */
            + 89         layoutOp:           0,
            + 90 
            + 91         initialize : function(scene) {
            + 92             this.scene= scene;
            + 93             return this;
            + 94         },
            + 95         /**
            + 96          * Set the number of elements that will be affected (zoomed) when the mouse is inside the component.
            + 97          * @param range {number} a number. Defaults to 2.
            + 98          */
            + 99         setApplicationRange : function( range ) {
            +100             this.range= range;
            +101             return this;
            +102         },
            +103         /**
            +104          * Set layout orientation. Choose from
            +105          * <ul>
            +106          *  <li>CAAT.Dock.OP_LAYOUT_BOTTOM
            +107          *  <li>CAAT.Dock.OP_LAYOUT_TOP
            +108          *  <li>CAAT.Dock.OP_LAYOUT_BOTTOM
            +109          *  <li>CAAT.Dock.OP_LAYOUT_RIGHT
            +110          * </ul>
            +111          * By default, the layou operation is OP_LAYOUT_BOTTOM, that is, elements zoom bottom anchored.
            +112          *
            +113          * @param lo {number} one of CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_TOP,
            +114          * CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_RIGHT.
            +115          *
            +116          * @return this
            +117          */
            +118         setLayoutOp : function( lo ) {
            +119             this.layoutOp= lo;
            +120             return this;
            +121         },
            +122         /**
            +123          *
            +124          * Set maximum and minimum size of docked elements. By default, every contained actor will be
            +125          * of 'min' size, and will be scaled up to 'max' size.
            +126          *
            +127          * @param min {number}
            +128          * @param max {number}
            +129          * @return this
            +130          */
            +131         setSizes : function( min, max ) {
            +132             this.minSize= min;
            +133             this.maxSize= max;
            +134 
            +135             for( var i=0; i<this.childrenList.length; i++ ) {
            +136                 this.childrenList[i].width= min;
            +137                 this.childrenList[i].height= min;
            +138             }
            +139 
            +140             return this;
            +141         },
            +142         /**
            +143          * Lay out the docking elements. The lay out will be a row with the orientation set by calling
            +144          * the method <code>setLayoutOp</code>.
            +145          *
            +146          * @private
            +147          */
            +148         layout : function() {
            +149             var i,actor;
            +150 
            +151             var c= CAAT.Foundation.UI.Dock;
            +152 
            +153             if ( this.layoutOp===c.OP_LAYOUT_BOTTOM || this.layoutOp===c.OP_LAYOUT_TOP ) {
            +154 
            +155                 var currentWidth=0, currentX=0;
            +156 
            +157                 for( i=0; i<this.getNumChildren(); i++ ) {
            +158                     currentWidth+= this.getChildAt(i).width;
            +159                 }
            +160 
            +161                 currentX= (this.width-currentWidth)/2;
            +162 
            +163                 for( i=0; i<this.getNumChildren(); i++ ) {
            +164                     actor= this.getChildAt(i);
            +165                     actor.x= currentX;
            +166                     currentX+= actor.width;
            +167 
            +168                     if ( this.layoutOp===c.OP_LAYOUT_BOTTOM ) {
            +169                         actor.y= this.maxSize- actor.height;
            +170                     } else {
            +171                         actor.y= 0;
            +172                     }
            +173                 }
            +174             } else {
            +175 
            +176                 var currentHeight=0, currentY=0;
            +177 
            +178                 for( i=0; i<this.getNumChildren(); i++ ) {
            +179                     currentHeight+= this.getChildAt(i).height;
            +180                 }
            +181 
            +182                 currentY= (this.height-currentHeight)/2;
            +183 
            +184                 for( i=0; i<this.getNumChildren(); i++ ) {
            +185                     actor= this.getChildAt(i);
            +186                     actor.y= currentY;
            +187                     currentY+= actor.height;
            +188 
            +189                     if ( this.layoutOp===c.OP_LAYOUT_LEFT ) {
            +190                         actor.x= 0;
            +191                     } else {
            +192                         actor.x= this.width - actor.width;
            +193                     }
            +194                 }
            +195 
            +196             }
            +197 
            +198         },
            +199         mouseMove : function(mouseEvent) {
            +200             this.actorNotPointed();
            +201         },
            +202         mouseExit : function(mouseEvent) {
            +203             this.actorNotPointed();
            +204         },
            +205         /**
            +206          * Performs operation when the mouse is not in the dock element.
            +207          *
            +208          * @private
            +209          */
            +210         actorNotPointed : function() {
            +211 
            +212             var i;
            +213             var me= this;
            +214 
            +215             for( i=0; i<this.getNumChildren(); i++ ) {
            +216                 var actor= this.getChildAt(i);
            +217                 actor.emptyBehaviorList();
            +218                 actor.addBehavior(
            +219                         new CAAT.Behavior.GenericBehavior().
            +220                             setValues( actor.width, this.minSize, actor, 'width' ).
            +221                             setFrameTime( this.scene.time, 250 ) ).
            +222                     addBehavior(
            +223                         new CAAT.Behavior.GenericBehavior().
            +224                             setValues( actor.height, this.minSize, actor, 'height' ).
            +225                             setFrameTime( this.scene.time, 250 ) );
            +226 
            +227                 if ( i===this.getNumChildren()-1 ) {
            +228                     actor.behaviorList[0].addListener(
            +229                     {
            +230                         behaviorApplied : function(behavior,time,normalizedTime,targetActor,value) {
            +231                             targetActor.parent.layout();
            +232                         },
            +233                         behaviorExpired : function(behavior,time,targetActor) {
            +234                             for( i=0; i<me.getNumChildren(); i++ ) {
            +235                                 actor= me.getChildAt(i);
            +236                                 actor.width  = me.minSize;
            +237                                 actor.height = me.minSize;
            +238                             }
            +239                             targetActor.parent.layout();
            +240                         }
            +241                     });
            +242                 }
            +243             }
            +244         },
            +245         /**
            +246          *
            +247          * Perform the process of pointing a docking actor.
            +248          *
            +249          * @param x {number}
            +250          * @param y {number}
            +251          * @param pointedActor {CAAT.Actor}
            +252          *
            +253          * @private
            +254          */
            +255         actorPointed : function(x, y, pointedActor) {
            +256 
            +257             var index= this.findChild(pointedActor);
            +258             var c= CAAT.Foundation.UI.Dock;
            +259 
            +260             var across= 0;
            +261             if ( this.layoutOp===c.OP_LAYOUT_BOTTOM || this.layoutOp===c.OP_LAYOUT_TOP ) {
            +262                 across= x / pointedActor.width;
            +263             } else {
            +264                 across= y / pointedActor.height;
            +265             }
            +266             var i;
            +267 
            +268             for( i=0; i<this.childrenList.length; i++ ) {
            +269                 var actor= this.childrenList[i];
            +270                 actor.emptyBehaviorList();
            +271 
            +272                 var wwidth=0;
            +273                 if (i < index - this.range || i > index + this.range) {
            +274                     wwidth = this.minSize;
            +275                 } else if (i === index) {
            +276                     wwidth = this.maxSize;
            +277                 } else if (i < index) {
            +278                     wwidth=
            +279                         this.minSize +
            +280                         (this.maxSize-this.minSize) *
            +281                         (Math.cos((i - index - across + 1) / this.range * Math.PI) + 1) /
            +282                         2;
            +283                 } else {
            +284                     wwidth=
            +285                         this.minSize +
            +286                         (this.maxSize-this.minSize)*
            +287                         (Math.cos( (i - index - across) / this.range * Math.PI) + 1) /
            +288                         2;
            +289                 }
            +290 
            +291                 actor.height= wwidth;
            +292                 actor.width= wwidth;
            +293             }
            +294 
            +295             this.layout();
            +296         },
            +297         /**
            +298          * Perform the process of exiting the docking element, that is, animate elements to the minimum
            +299          * size.
            +300          *
            +301          * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object.
            +302          *
            +303          * @private
            +304          */
            +305         actorMouseExit : function(mouseEvent) {
            +306             if ( null!==this.ttask ) {
            +307                 this.ttask.cancel();
            +308             }
            +309 
            +310             var me= this;
            +311             this.ttask= this.scene.createTimer(
            +312                     this.scene.time,
            +313                     100,
            +314                     function timeout(sceneTime, time, timerTask) {
            +315                         me.actorNotPointed();
            +316                     },
            +317                     null,
            +318                     null);
            +319         },
            +320         /**
            +321          * Perform the beginning of docking elements.
            +322          * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object.
            +323          *
            +324          * @private
            +325          */
            +326         actorMouseEnter : function(mouseEvent) {
            +327             if ( null!==this.ttask ) {
            +328                 this.ttask.cancel();
            +329                 this.ttask= null;
            +330             }
            +331         },
            +332         /**
            +333          * Adds an actor to Dock.
            +334          * <p>
            +335          * Be aware that actor mouse functions must be set prior to calling this method. The Dock actor
            +336          * needs set his own actor input events functions for mouseEnter, mouseExit and mouseMove and
            +337          * will then chain to the original methods set by the developer.
            +338          *
            +339          * @param actor {CAAT.Actor} a CAAT.Actor instance.
            +340          *
            +341          * @return this
            +342          */
            +343         addChild : function(actor) {
            +344             var me= this;
            +345 
            +346             actor.__Dock_mouseEnter= actor.mouseEnter;
            +347             actor.__Dock_mouseExit=  actor.mouseExit;
            +348             actor.__Dock_mouseMove=  actor.mouseMove;
            +349 
            +350             /**
            +351              * @ignore
            +352              * @param mouseEvent
            +353              */
            +354             actor.mouseEnter= function(mouseEvent) {
            +355                 me.actorMouseEnter(mouseEvent);
            +356                 this.__Dock_mouseEnter(mouseEvent);
            +357             };
            +358             /**
            +359              * @ignore
            +360              * @param mouseEvent
            +361              */
            +362             actor.mouseExit= function(mouseEvent) {
            +363                 me.actorMouseExit(mouseEvent);
            +364                 this.__Dock_mouseExit(mouseEvent);
            +365             };
            +366             /**
            +367              * @ignore
            +368              * @param mouseEvent
            +369              */
            +370             actor.mouseMove= function(mouseEvent) {
            +371                 me.actorPointed( mouseEvent.point.x, mouseEvent.point.y, mouseEvent.source );
            +372                 this.__Dock_mouseMove(mouseEvent);
            +373             };
            +374 
            +375             actor.width= this.minSize;
            +376             actor.height= this.minSize;
            +377 
            +378             return CAAT.Foundation.UI.Dock.superclass.addChild.call(this,actor);
            +379         }
            +380     }
            +381 
            +382 });
            +383 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_IMActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_IMActor.js.html new file mode 100644 index 0000000..76813a3 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_IMActor.js.html @@ -0,0 +1,74 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name IMActor
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @extends CAAT.Foundation.Actor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.IMActor",
            + 11     depends : [
            + 12         "CAAT.Foundation.Actor",
            + 13         "CAAT.Module.ImageProcessor.ImageProcessor"
            + 14     ],
            + 15     extendsClass : "CAAT.Foundation.Actor",
            + 16     extendsWith : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Foundation.UI.IMActor.prototype
            + 20          */
            + 21 
            + 22         /**
            + 23          * Image processing interface.
            + 24          * @type { }
            + 25          */
            + 26         imageProcessor:         null,
            + 27 
            + 28         /**
            + 29          * Calculate another image processing frame every this milliseconds.
            + 30          */
            + 31         changeTime:             100,
            + 32 
            + 33         /**
            + 34          * Last scene time this actor calculated a frame.
            + 35          */
            + 36         lastApplicationTime:    -1,
            + 37 
            + 38         /**
            + 39          * Set the image processor.
            + 40          *
            + 41          * @param im {CAAT.ImageProcessor} a CAAT.ImageProcessor instance.
            + 42          */
            + 43         setImageProcessor : function(im) {
            + 44             this.imageProcessor= im;
            + 45             return this;
            + 46         },
            + 47         /**
            + 48          * Call image processor to update image every time milliseconds.
            + 49          * @param time an integer indicating milliseconds to elapse before updating the frame.
            + 50          */
            + 51         setImageProcessingTime : function( time ) {
            + 52             this.changeTime= time;
            + 53             return this;
            + 54         },
            + 55         paint : function( director, time ) {
            + 56             if ( time-this.lastApplicationTime>this.changeTime ) {
            + 57                 this.imageProcessor.apply( director, time );
            + 58                 this.lastApplicationTime= time;
            + 59             }
            + 60 
            + 61             var ctx= director.ctx;
            + 62             this.imageProcessor.paint( director, time );
            + 63         }
            + 64     }
            + 65 
            + 66 });
            + 67 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_InterpolatorActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_InterpolatorActor.js.html new file mode 100644 index 0000000..3b8c74f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_InterpolatorActor.js.html @@ -0,0 +1,126 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module( {
            +  7 
            +  8     /**
            +  9      * @name InterpolatorActor
            + 10      * @memberOf CAAT.Foundation.UI
            + 11      * @extends CAAT.Foundation.Actor
            + 12      * @constructor
            + 13      */
            + 14 
            + 15     defines : "CAAT.Foundation.UI.InterpolatorActor",
            + 16     aliases : ["CAAT.InterpolatorActor"],
            + 17     depends : [
            + 18         "CAAT.Foundation.Actor"
            + 19     ],
            + 20     extendsClass : "CAAT.Foundation.Actor",
            + 21     extendsWith : {
            + 22 
            + 23         /**
            + 24          * @lends CAAT.Foundation.UI.InterpolatorActor.prototype
            + 25          */
            + 26 
            + 27         /**
            + 28          * The interpolator instance to draw.
            + 29          * @type {CAAT.Behavior.Interpolator}
            + 30          */
            + 31         interpolator:   null,
            + 32 
            + 33         /**
            + 34          * This interpolator´s contour.
            + 35          * @type {Array.<CAAT.Math.Point>}
            + 36          */
            + 37         contour:        null,   // interpolator contour cache
            + 38 
            + 39         /**
            + 40          * Number of samples to calculate a contour.
            + 41          */
            + 42         S:              50,     // contour samples.
            + 43 
            + 44         /**
            + 45          * padding when drawing the interpolator.
            + 46          */
            + 47         gap:            5,      // border size in pixels.
            + 48 
            + 49         /**
            + 50          * Sets a padding border size. By default is 5 pixels.
            + 51          * @param gap {number} border size in pixels.
            + 52          * @return this
            + 53          */
            + 54         setGap : function( gap ) {
            + 55             this.gap= gap;
            + 56             return this;
            + 57         },
            + 58         /**
            + 59          * Sets the CAAT.Interpolator instance to draw.
            + 60          *
            + 61          * @param interpolator a CAAT.Interpolator instance.
            + 62          * @param size an integer indicating the number of polyline segments so draw to show the CAAT.Interpolator
            + 63          * instance.
            + 64          *
            + 65          * @return this
            + 66          */
            + 67         setInterpolator : function( interpolator, size ) {
            + 68             this.interpolator= interpolator;
            + 69             this.contour= interpolator.getContour(size || this.S);
            + 70 
            + 71             return this;
            + 72         },
            + 73         /**
            + 74          * Paint this actor.
            + 75          * @param director {CAAT.Director}
            + 76          * @param time {number} scene time.
            + 77          */
            + 78         paint : function( director, time ) {
            + 79 
            + 80             CAAT.InterpolatorActor.superclass.paint.call(this,director,time);
            + 81 
            + 82             if ( this.backgroundImage ) {
            + 83                 return this;
            + 84             }
            + 85 
            + 86             if ( this.interpolator ) {
            + 87 
            + 88                 var canvas= director.ctx;
            + 89 
            + 90                 var xs= (this.width-2*this.gap);
            + 91                 var ys= (this.height-2*this.gap);
            + 92 
            + 93                 canvas.beginPath();
            + 94                 canvas.moveTo(
            + 95                         this.gap +  xs*this.contour[0].x,
            + 96                         -this.gap + this.height - ys*this.contour[0].y);
            + 97 
            + 98                 for( var i=1; i<this.contour.length; i++ ) {
            + 99                     canvas.lineTo(
            +100                              this.gap + xs*this.contour[i].x,
            +101                             -this.gap + this.height - ys*this.contour[i].y);
            +102                 }
            +103 
            +104                 canvas.strokeStyle= this.strokeStyle;
            +105                 canvas.stroke();
            +106             }
            +107         },
            +108         /**
            +109          * Return the represented interpolator.
            +110          * @return {CAAT.Interpolator}
            +111          */
            +112         getInterpolator : function() {
            +113             return this.interpolator;
            +114         }
            +115     }
            +116 
            +117 
            +118 });
            +119 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Label.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Label.js.html new file mode 100644 index 0000000..3d2e648 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Label.js.html @@ -0,0 +1,1225 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name Label
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @extends CAAT.Foundation.Actor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.Label",
            + 11     depends : [
            + 12         "CAAT.Foundation.Actor",
            + 13         "CAAT.Foundation.SpriteImage",
            + 14         "CAAT.Module.Font.Font",
            + 15         "CAAT.Foundation.UI.Layout.LayoutManager"
            + 16     ],
            + 17     aliases : ["CAAT.UI.Label"],
            + 18     extendsClass : "CAAT.Foundation.Actor",
            + 19     extendsWith : function() {
            + 20 
            + 21         var DEBUG=0;
            + 22         var JUSTIFY_RATIO= .6;
            + 23 
            + 24         /**
            + 25          *
            + 26          * Current applied rendering context information.
            + 27          */
            + 28         var renderContextStyle= function(ctx) {
            + 29             this.ctx= ctx;
            + 30             return this;
            + 31         };
            + 32 
            + 33         renderContextStyle.prototype= {
            + 34 
            + 35             ctx         : null,
            + 36 
            + 37             defaultFS   : null,
            + 38             font        : null,
            + 39             fontSize    : null,
            + 40             fill        : null,
            + 41             stroke      : null,
            + 42             filled      : null,
            + 43             stroked     : null,
            + 44             strokeSize  : null,
            + 45             italic      : null,
            + 46             bold        : null,
            + 47             alignment   : null,
            + 48             tabSize     : null,
            + 49             shadow      : null,
            + 50             shadowBlur  : null,
            + 51             shadowColor : null,
            + 52 
            + 53             sfont       : null,
            + 54 
            + 55             chain       : null,
            + 56 
            + 57             setDefault : function( defaultStyles ) {
            + 58                 this.defaultFS  =   24;
            + 59                 this.font       =   "Arial";
            + 60                 this.fontSize   =   this.defaultFS;
            + 61                 this.fill       =   '#000';
            + 62                 this.stroke     =   '#f00';
            + 63                 this.filled     =   true;
            + 64                 this.stroked    =   false;
            + 65                 this.strokeSize =   1;
            + 66                 this.italic     =   false;
            + 67                 this.bold       =   false;
            + 68                 this.alignment  =   "left";
            + 69                 this.tabSize    =   75;
            + 70                 this.shadow     =   false;
            + 71                 this.shadowBlur =   0;
            + 72                 this.shadowColor=   "#000";
            + 73 
            + 74                 for( var style in defaultStyles ) {
            + 75                     if ( defaultStyles.hasOwnProperty(style) ) {
            + 76                         this[style]= defaultStyles[style];
            + 77                     }
            + 78                 }
            + 79 
            + 80                 this.__setFont();
            + 81 
            + 82                 return this;
            + 83             },
            + 84 
            + 85             setStyle : function( styles ) {
            + 86                 if ( typeof styles!=="undefined" ) {
            + 87                     for( var style in styles ) {
            + 88                         this[style]= styles[style];
            + 89                     }
            + 90                 }
            + 91                 return this;
            + 92             },
            + 93 
            + 94             applyStyle : function() {
            + 95                 this.__setFont();
            + 96 
            + 97                 return this;
            + 98             },
            + 99 
            +100             clone : function( ) {
            +101                 var c= new renderContextStyle( this.ctx );
            +102                 var pr;
            +103                 for( pr in this ) {
            +104                     if ( this.hasOwnProperty(pr) ) {
            +105                         c[pr]= this[pr];
            +106                     }
            +107                 }
            +108                 /*
            +109                 c.defaultFS  =   this.defaultFS;
            +110                 c.font       =   this.font;
            +111                 c.fontSize   =   this.fontSize;
            +112                 c.fill       =   this.fill;
            +113                 c.stroke     =   this.stroke;
            +114                 c.filled     =   this.filled;
            +115                 c.stroked    =   this.stroked;
            +116                 c.strokeSize =   this.strokeSize;
            +117                 c.italic     =   this.italic;
            +118                 c.bold       =   this.bold;
            +119                 c.alignment  =   this.alignment;
            +120                 c.tabSize    =   this.tabSize;
            +121                 */
            +122 
            +123                 var me= this;
            +124                 while( me.chain ) {
            +125                     me= me.chain;
            +126                     for( pr in me ) {
            +127                         if ( c[pr]===null  && me.hasOwnProperty(pr) ) {
            +128                             c[pr]= me[pr];
            +129                         }
            +130                     }
            +131                 }
            +132 
            +133                 c.__setFont();
            +134 
            +135                 return c;
            +136             },
            +137 
            +138             __getProperty : function( prop ) {
            +139                 var me= this;
            +140                 var res;
            +141                 do {
            +142                     res= me[prop];
            +143                     if ( res!==null ) {
            +144                         return res;
            +145                     }
            +146                     me= me.chain;
            +147                 } while( me );
            +148 
            +149                 return null;
            +150             },
            +151 
            +152             image : function( ctx ) {
            +153                 this.__setShadow( ctx );
            +154             },
            +155 
            +156             text : function( ctx, text, x, y ) {
            +157 
            +158                 this.__setShadow( ctx );
            +159 
            +160                 ctx.font= this.__getProperty("sfont");
            +161 
            +162                 if ( this.filled ) {
            +163                     this.__fillText( ctx,text,x,y );
            +164                 }
            +165                 if ( this.stroked ) {
            +166                     this.__strokeText( ctx,text,x,y );
            +167                 }
            +168             },
            +169 
            +170             __setShadow : function( ctx ) {
            +171                 if ( this.__getProperty("shadow" ) ) {
            +172                     ctx.shadowBlur= this.__getProperty("shadowBlur");
            +173                     ctx.shadowColor= this.__getProperty("shadowColor");
            +174                 }
            +175             },
            +176 
            +177             __fillText : function( ctx, text, x, y ) {
            +178                 ctx.fillStyle= this.__getProperty("fill");
            +179                 ctx.fillText( text, x, y );
            +180             },
            +181 
            +182             __strokeText : function( ctx, text, x, y ) {
            +183                 ctx.strokeStyle= this.__getProperty("stroke");
            +184                 ctx.lineWidth= this.__getProperty("strokeSize");
            +185                 ctx.beginPath();
            +186                 ctx.strokeText( text, x, y );
            +187             },
            +188 
            +189             __setFont : function() {
            +190                 var italic= this.__getProperty("italic");
            +191                 var bold= this.__getProperty("bold");
            +192                 var fontSize= this.__getProperty("fontSize");
            +193                 var font= this.__getProperty("font");
            +194 
            +195                 this.sfont= (italic ? "italic " : "") +
            +196                     (bold ? "bold " : "") +
            +197                     fontSize + "px " +
            +198                     font;
            +199 
            +200                 this.ctx.font= this.__getProperty("sfont");
            +201             },
            +202 
            +203             setBold : function( bool ) {
            +204                 if ( bool!=this.bold ) {
            +205                     this.bold= bool;
            +206                     this.__setFont();
            +207                 }
            +208             },
            +209 
            +210             setItalic : function( bool ) {
            +211                 if ( bool!=this.italic ) {
            +212                     this.italic= bool;
            +213                     this.__setFont();
            +214                 }
            +215             },
            +216 
            +217             setStroked : function( bool ) {
            +218                 this.stroked= bool;
            +219             },
            +220 
            +221             setFilled : function( bool ) {
            +222                 this.filled= bool;
            +223             },
            +224 
            +225             getTabPos : function( x ) {
            +226                 var ts= this.__getProperty("tabSize");
            +227                 return (((x/ts)>>0)+1)*ts;
            +228             },
            +229 
            +230             setFillStyle : function( style ) {
            +231                 this.fill= style;
            +232             },
            +233 
            +234             setStrokeStyle : function( style ) {
            +235                 this.stroke= style;
            +236             },
            +237 
            +238             setStrokeSize : function( size ) {
            +239                 this.strokeSize= size;
            +240             },
            +241 
            +242             setAlignment : function( alignment ) {
            +243                 this.alignment= alignment;
            +244             },
            +245 
            +246             setFontSize : function( size ) {
            +247                 if ( size!==this.fontSize ) {
            +248                     this.fontSize= size;
            +249                     this.__setFont();
            +250                 }
            +251             }
            +252         };
            +253 
            +254         /**
            +255          * This class keeps track of styles, images, and the current applied style.
            +256          */
            +257         var renderContext= function() {
            +258             this.text= "";
            +259             return this;
            +260         };
            +261 
            +262         renderContext.prototype= {
            +263 
            +264             x           :   0,
            +265             y           :   0,
            +266             width       :   0,
            +267             text        :   null,
            +268 
            +269             crcs        :   null,   // current rendering context style
            +270             rcs         :   null,   // rendering content styles stack
            +271 
            +272             styles      :   null,
            +273             images      :   null,
            +274 
            +275             lines       :   null,
            +276 
            +277             documentHeight  : 0,
            +278 
            +279             anchorStack     : null,
            +280 
            +281             __nextLine : function() {
            +282                 this.x= 0;
            +283                 this.currentLine= new DocumentLine(
            +284                     CAAT.Module.Font.Font.getFontMetrics( this.crcs.sfont)  );
            +285                 this.lines.push( this.currentLine );
            +286             },
            +287 
            +288             /**
            +289              *
            +290              * @param image {CAAT.SpriteImage}
            +291              * @param r {number=}
            +292              * @param c {number=}
            +293              * @private
            +294              */
            +295             __image : function( image, r, c ) {
            +296 
            +297 
            +298                 var image_width;
            +299 
            +300                 if ( typeof r!=="undefined" && typeof c!=="undefined" ) {
            +301                     image_width= image.getWidth();
            +302                 } else {
            +303                     image_width= ( image instanceof CAAT.Foundation.SpriteImage ) ? image.getWidth() : image.getWrappedImageWidth();
            +304                 }
            +305 
            +306                 // la imagen cabe en este sitio.
            +307                 if ( this.width ) {
            +308                     if ( image_width + this.x > this.width && this.x>0 ) {
            +309                         this.__nextLine();
            +310                     }
            +311                 }
            +312 
            +313                 this.currentLine.addElementImage( new DocumentElementImage(
            +314                     this.x,
            +315                     image,
            +316                     r,
            +317                     c,
            +318                     this.crcs.clone(),
            +319                     this.__getCurrentAnchor() ) );
            +320 
            +321                 this.x+= image_width;
            +322             },
            +323 
            +324             __text : function() {
            +325 
            +326                 if ( this.text.length===0 ) {
            +327                     return;
            +328                 }
            +329 
            +330                 var text_width= this.ctx.measureText(this.text).width;
            +331 
            +332                 // la palabra cabe en este sitio.
            +333                 if ( this.width ) {
            +334                     if ( text_width + this.x > this.width && this.x>0 ) {
            +335                         this.__nextLine();
            +336                     }
            +337                 }
            +338 
            +339                 //this.crcs.text( this.text, this.x, this.y );
            +340                 this.currentLine.addElement( new DocumentElementText(
            +341                     this.text,
            +342                     this.x,
            +343                     text_width,
            +344                     0, //this.crcs.__getProperty("fontSize"), calculated later
            +345                     this.crcs.clone(),
            +346                     this.__getCurrentAnchor() ) ) ;
            +347 
            +348                 this.x+= text_width;
            +349 
            +350                 this.text="";
            +351             },
            +352 
            +353             fchar : function( _char ) {
            +354 
            +355                 if ( _char===' ' ) {
            +356 
            +357                     this.__text();
            +358 
            +359                     this.x+= this.ctx.measureText(_char).width;
            +360                     if ( this.width ) {
            +361                         if ( this.x > this.width ) {
            +362                             this.__nextLine();
            +363                         }
            +364                     }
            +365                 } else {
            +366                     this.text+= _char;
            +367                 }
            +368             },
            +369 
            +370             end : function() {
            +371                 if ( this.text.length>0 ) {
            +372                     this.__text();
            +373                 }
            +374 
            +375                 var y=0;
            +376                 var lastLineEstimatedDescent= 0;
            +377                 for( var i=0; i<this.lines.length; i++ ) {
            +378                     var inc= this.lines[i].getHeight();
            +379 
            +380                     if ( inc===0 ) {
            +381                         // lineas vacias al menos tienen tamaño del estilo por defecto
            +382                         inc= this.styles["default"].fontSize;
            +383                     }
            +384                     y+= inc;
            +385 
            +386                     /**
            +387                      * add the estimated descent of the last text line to document height's.
            +388                      * the descent is estimated to be a 20% of font's height.
            +389                      */
            +390                     if ( i===this.lines.length-1 ) {
            +391                         lastLineEstimatedDescent= (inc*.25)>>0;
            +392                     }
            +393 
            +394                     this.lines[i].setY(y);
            +395                 }
            +396 
            +397                 this.documentHeight= y + lastLineEstimatedDescent;
            +398             },
            +399 
            +400             getDocumentHeight : function() {
            +401                 return this.documentHeight;
            +402             },
            +403 
            +404             __getCurrentAnchor : function() {
            +405                 if ( this.anchorStack.length ) {
            +406                     return this.anchorStack[ this.anchorStack.length-1 ];
            +407                 }
            +408 
            +409                 return null;
            +410             },
            +411 
            +412             __resetAppliedStyles : function() {
            +413                 this.rcs= [];
            +414                 this.__pushDefaultStyles();
            +415             },
            +416 
            +417             __pushDefaultStyles : function() {
            +418                 this.crcs= new renderContextStyle(this.ctx).setDefault( this.styles["default"] );
            +419                 this.rcs.push( this.crcs );
            +420             },
            +421 
            +422             __pushStyle : function( style ) {
            +423                 var pcrcs= this.crcs;
            +424                 this.crcs= new renderContextStyle(this.ctx);
            +425                 this.crcs.chain= pcrcs;
            +426                 this.crcs.setStyle( style );
            +427                 this.crcs.applyStyle( );
            +428 
            +429                 this.rcs.push( this.crcs );
            +430             },
            +431 
            +432             __popStyle : function() {
            +433                 // make sure you don't remove default style.
            +434                 if ( this.rcs.length>1 ) {
            +435                     this.rcs.pop();
            +436                     this.crcs= this.rcs[ this.rcs.length-1 ];
            +437                     this.crcs.applyStyle();
            +438                 }
            +439             },
            +440 
            +441             __popAnchor : function() {
            +442                 if ( this.anchorStack.length> 0 ) {
            +443                     this.anchorStack.pop();
            +444                 }
            +445             },
            +446 
            +447             __pushAnchor : function( anchor ) {
            +448                 this.anchorStack.push( anchor );
            +449             },
            +450 
            +451             start : function( ctx, styles, images, width ) {
            +452                 this.x=0;
            +453                 this.y=0;
            +454                 this.width= typeof width!=="undefined" ? width : 0;
            +455                 this.ctx= ctx;
            +456                 this.lines= [];
            +457                 this.styles= styles;
            +458                 this.images= images;
            +459                 this.anchorStack= [];
            +460 
            +461                 this.__resetAppliedStyles();
            +462                 this.__nextLine();
            +463 
            +464             },
            +465 
            +466             setTag  : function( tag ) {
            +467 
            +468                 var pairs, style;
            +469 
            +470                 this.__text();
            +471 
            +472                 tag= tag.toLowerCase();
            +473                 if ( tag==='b' ) {
            +474                     this.crcs.setBold( true );
            +475                 } else if ( tag==='/b' ) {
            +476                     this.crcs.setBold( false );
            +477                 } else if ( tag==='i' ) {
            +478                     this.crcs.setItalic( true );
            +479                 } else if ( tag==='/i' ) {
            +480                     this.crcs.setItalic( false );
            +481                 } else if ( tag==='stroked' ) {
            +482                     this.crcs.setStroked( true );
            +483                 } else if ( tag==='/stroked' ) {
            +484                     this.crcs.setStroked( false );
            +485                 } else if ( tag==='filled' ) {
            +486                     this.crcs.setFilled( true );
            +487                 } else if ( tag==='/filled' ) {
            +488                     this.crcs.setFilled( false );
            +489                 } else if ( tag==='tab' ) {
            +490                     this.x= this.crcs.getTabPos( this.x );
            +491                 } else if ( tag==='br' ) {
            +492                     this.__nextLine();
            +493                 } else if ( tag==='/a' ) {
            +494                     this.__popAnchor();
            +495                 } else if ( tag==='/style' ) {
            +496                     if ( this.rcs.length>1 ) {
            +497                         this.__popStyle();
            +498                     } else {
            +499                         /**
            +500                          * underflow pop de estilos. eres un cachondo.
            +501                          */
            +502                     }
            +503                 } else {
            +504                     if ( tag.indexOf("fillcolor")===0 ) {
            +505                         pairs= tag.split("=");
            +506                         this.crcs.setFillStyle( pairs[1] );
            +507                     } else if ( tag.indexOf("strokecolor")===0 ) {
            +508                         pairs= tag.split("=");
            +509                         this.crcs.setStrokeStyle( pairs[1] );
            +510                     } else if ( tag.indexOf("strokesize")===0 ) {
            +511                         pairs= tag.split("=");
            +512                         this.crcs.setStrokeSize( pairs[1]|0 );
            +513                     } else if ( tag.indexOf("fontsize")===0 ) {
            +514                         pairs= tag.split("=");
            +515                         this.crcs.setFontSize( pairs[1]|0 );
            +516                     } else if ( tag.indexOf("style")===0 ) {
            +517                         pairs= tag.split("=");
            +518                         style= this.styles[ pairs[1] ];
            +519                         if ( style ) {
            +520                             this.__pushStyle( style );
            +521                         }
            +522                     } else if ( tag.indexOf("image")===0) {
            +523                         pairs= tag.split("=")[1].split(",");
            +524                         var image= pairs[0];
            +525                         if ( this.images[image] ) {
            +526                             var r= 0, c=0;
            +527                             if ( pairs.length>=3 ) {
            +528                                 r= pairs[1]|0;
            +529                                 c= pairs[2]|0;
            +530                             }
            +531                             this.__image( this.images[image], r, c );
            +532                         } else if (CAAT.currentDirector.getImage(image) ) {
            +533                             this.__image( CAAT.currentDirector.getImage(image) );
            +534                         }
            +535                     } else if ( tag.indexOf("a=")===0 ) {
            +536                         pairs= tag.split("=");
            +537                         this.__pushAnchor( pairs[1] );
            +538                     }
            +539                 }
            +540             }
            +541         };
            +542 
            +543         /**
            +544          * Abstract document element.
            +545          * The document contains a collection of DocumentElementText and DocumentElementImage.
            +546          * @param anchor
            +547          * @param style
            +548          */
            +549         var DocumentElement= function( anchor, style ) {
            +550             this.link= anchor;
            +551             this.style= style;
            +552             return this;
            +553         };
            +554 
            +555         DocumentElement.prototype= {
            +556             x       : null,
            +557             y       : null,
            +558             width   : null,
            +559             height  : null,
            +560 
            +561             style   : null,
            +562 
            +563             link    : null,
            +564 
            +565             isLink : function() {
            +566                 return this.link;
            +567             },
            +568 
            +569             setLink : function( link ) {
            +570                 this.link= link;
            +571                 return this;
            +572             },
            +573 
            +574             getLink : function() {
            +575                 return this.link;
            +576             },
            +577 
            +578             contains : function(x,y) {
            +579                 return false;
            +580             }
            +581 
            +582         };
            +583 
            +584         /**
            +585          * This class represents an image in the document.
            +586          * @param x
            +587          * @param image
            +588          * @param r
            +589          * @param c
            +590          * @param style
            +591          * @param anchor
            +592          */
            +593         var DocumentElementImage= function( x, image, r, c, style, anchor ) {
            +594 
            +595             DocumentElementImage.superclass.constructor.call(this, anchor, style);
            +596 
            +597             this.x= x;
            +598             this.image= image;
            +599             this.row= r;
            +600             this.column= c;
            +601             this.width= image.getWidth();
            +602             this.height= image.getHeight();
            +603 
            +604             if ( this.image instanceof CAAT.SpriteImage || this.image instanceof CAAT.Foundation.SpriteImage ) {
            +605 
            +606                 if ( typeof r==="undefined" || typeof c==="undefined" ) {
            +607                     this.spriteIndex= 0;
            +608                 } else {
            +609                     this.spriteIndex= r*image.columns+c;
            +610                 }
            +611                 this.paint= this.paintSI;
            +612             }
            +613 
            +614             return this;
            +615         };
            +616 
            +617         DocumentElementImage.prototype= {
            +618             image   : null,
            +619             row     : null,
            +620             column  : null,
            +621             spriteIndex : null,
            +622 
            +623             paint : function( ctx ) {
            +624                 this.style.image( ctx );
            +625                 ctx.drawImage( this.image, this.x, -this.height+1);
            +626                 if ( DEBUG ) {
            +627                     ctx.strokeRect( this.x, -this.height+1, this.width, this.height );
            +628                 }
            +629             },
            +630 
            +631             paintSI : function( ctx ) {
            +632                 this.style.image( ctx );
            +633                 this.image.setSpriteIndex( this.spriteIndex );
            +634                 this.image.paint( { ctx: ctx }, 0, this.x,  -this.height+1 );
            +635                 if ( DEBUG ) {
            +636                     ctx.strokeRect( this.x, -this.height+1, this.width, this.height );
            +637                 }
            +638             },
            +639 
            +640             getHeight : function() {
            +641                 return this.image instanceof CAAT.Foundation.SpriteImage ? this.image.getHeight() : this.image.height;
            +642             },
            +643 
            +644             getFontMetrics : function() {
            +645                 return null;
            +646             },
            +647 
            +648             contains : function(x,y) {
            +649                 return x>=this.x && x<=this.x+this.width && y>=this.y && y<this.y + this.height;
            +650             },
            +651 
            +652             setYPosition : function( baseline ) {
            +653                 this.y= baseline - this.height + 1;
            +654             }
            +655 
            +656         };
            +657 
            +658         /**
            +659          * This class represents a text in the document. The text will have applied the styles selected
            +660          * when it was defined.
            +661          * @param text
            +662          * @param x
            +663          * @param width
            +664          * @param height
            +665          * @param style
            +666          * @param anchor
            +667          */
            +668         var DocumentElementText= function( text,x,width,height,style, anchor) {
            +669 
            +670             DocumentElementText.superclass.constructor.call(this, anchor, style);
            +671 
            +672             this.x=         x;
            +673             this.y=         0;
            +674             this.width=     width;
            +675             this.text=      text;
            +676             this.style=     style;
            +677             this.fm=        CAAT.Module.Font.Font.getFontMetrics( style.sfont );
            +678             this.height=    this.fm.height;
            +679 
            +680             return this;
            +681         };
            +682 
            +683         DocumentElementText.prototype= {
            +684 
            +685             text    : null,
            +686             style   : null,
            +687             fm      : null,
            +688 
            +689             bl      : null,     // where baseline was set. current 0 in ctx.
            +690 
            +691             paint : function( ctx ) {
            +692                 this.style.text( ctx, this.text, this.x, 0 );
            +693                 if ( DEBUG ) {
            +694                     ctx.strokeRect( this.x, -this.fm.ascent, this.width, this.height);
            +695                 }
            +696             },
            +697 
            +698             getHeight : function() {
            +699                 return this.fm.height;
            +700             },
            +701 
            +702             getFontMetrics : function() {
            +703                 return this.fm; //CAAT.Font.getFontMetrics( this.style.sfont);
            +704             },
            +705 
            +706             contains : function( x, y ) {
            +707                 return x>= this.x && x<=this.x+this.width &&
            +708                     y>= this.y && y<= this.y+this.height;
            +709             },
            +710 
            +711             setYPosition : function( baseline ) {
            +712                 this.bl= baseline;
            +713                 this.y= baseline - this.fm.ascent;
            +714             }
            +715         };
            +716 
            +717         extend( DocumentElementImage, DocumentElement );
            +718         extend( DocumentElementText, DocumentElement );
            +719 
            +720         /**
            +721          * This class represents a document line.
            +722          * It contains a collection of DocumentElement objects.
            +723          */
            +724         var DocumentLine= function( defaultFontMetrics ) {
            +725             this.elements= [];
            +726             this.defaultFontMetrics= defaultFontMetrics;
            +727             return this;
            +728         };
            +729 
            +730         DocumentLine.prototype= {
            +731             elements    : null,
            +732             width       : 0,
            +733             height      : 0,
            +734             defaultHeight : 0,  // default line height in case it is empty.
            +735             y           : 0,
            +736             x           : 0,
            +737             alignment   : null,
            +738 
            +739             baselinePos : 0,
            +740 
            +741             addElement : function( element ) {
            +742                 this.width= Math.max( this.width, element.x + element.width );
            +743                 this.height= Math.max( this.height, element.height );
            +744                 this.elements.push( element );
            +745                 this.alignment= element.style.__getProperty("alignment");
            +746             },
            +747 
            +748             addElementImage : function( element ) {
            +749                 this.width= Math.max( this.width, element.x + element.width );
            +750                 this.height= Math.max( this.height, element.height );
            +751                 this.elements.push( element );
            +752             },
            +753 
            +754             getHeight : function() {
            +755                 return this.height;
            +756             },
            +757 
            +758             setY : function( y ) {
            +759                 this.y= y;
            +760             },
            +761 
            +762             getY : function() {
            +763                 return this.y;
            +764             },
            +765 
            +766             paint : function( ctx ) {
            +767                 ctx.save();
            +768                 ctx.translate(this.x,this.y + this.baselinePos );
            +769 
            +770                 for( var i=0; i<this.elements.length; i++ ) {
            +771                     this.elements[i].paint(ctx);
            +772                 }
            +773 
            +774                 ctx.restore();
            +775 
            +776             },
            +777 
            +778             setAlignment : function( width ) {
            +779                 var j;
            +780 
            +781                 if ( this.alignment==="center" ) {
            +782                     this.x= (width - this.width)/2;
            +783                 } else if ( this.alignment==="right" ) {
            +784                     this.x= width - this.width;
            +785                 } else if ( this.alignment==="justify" ) {
            +786 
            +787                     // justify: only when text overflows further than document's 80% width
            +788                     if ( this.width / width >= JUSTIFY_RATIO && this.elements.length>1 ) {
            +789                         var remaining= width - this.width;
            +790 
            +791                         var forEachElement= (remaining/(this.elements.length-1))|0;
            +792                         for( j=1; j<this.elements.length ; j++ ) {
            +793                             this.elements[j].x+= j*forEachElement;
            +794                         }
            +795 
            +796                         remaining= width - this.width - forEachElement*(this.elements.length-1);
            +797                         for( j=0; j<remaining; j++ ) {
            +798                             this.elements[this.elements.length-1-j].x+= remaining-j;
            +799                         }
            +800                     }
            +801                 }
            +802             },
            +803 
            +804             adjustHeight : function() {
            +805                 var biggestFont=null;
            +806                 var biggestImage=null;
            +807                 var i;
            +808 
            +809                 for( i=0; i<this.elements.length; i+=1 ) {
            +810                     var elem= this.elements[i];
            +811 
            +812                     var fm= elem.getFontMetrics();
            +813                     if ( null!=fm ) {           // gest a fontMetrics, is a DocumentElementText (text)
            +814                         if ( !biggestFont ) {
            +815                             biggestFont= fm;
            +816                         } else {
            +817                             if ( fm.ascent > biggestFont.ascent ) {
            +818                                 biggestFont= fm;
            +819                             }
            +820                         }
            +821                     } else {                    // no FontMetrics, it is an image.
            +822                         if (!biggestImage) {
            +823                             biggestImage= elem;
            +824                         } else {
            +825                             if ( elem.getHeight() > elem.getHeight() ) {
            +826                                 biggestImage= elem;
            +827                             }
            +828                         }
            +829                     }
            +830                 }
            +831 
            +832                 this.baselinePos= Math.max(
            +833                     biggestFont ? biggestFont.ascent : this.defaultFontMetrics.ascent,
            +834                     biggestImage ? biggestImage.getHeight() : this.defaultFontMetrics.ascent );
            +835                 this.height= this.baselinePos + (biggestFont!=null ? biggestFont.descent : this.defaultFontMetrics.descent );
            +836 
            +837                 for( i=0; i<this.elements.length; i++ ) {
            +838                     this.elements[i].setYPosition( this.baselinePos );
            +839                 }
            +840 
            +841                 return this.height;
            +842             },
            +843 
            +844             /**
            +845              * Every element is positioned at line's baseline.
            +846              * @param x
            +847              * @param y
            +848              * @private
            +849              */
            +850             __getElementAt : function( x, y ) {
            +851                 for( var i=0; i<this.elements.length; i++ ) {
            +852                     var elem= this.elements[i];
            +853                     if ( elem.contains(x,y) ) {
            +854                         return elem;
            +855                     }
            +856                 }
            +857 
            +858                 return null;
            +859             }
            +860         };
            +861 
            +862         return {
            +863 
            +864             /**
            +865              * @lends CAAT.Foundation.UI.Label.prototype
            +866              */
            +867 
            +868 
            +869             __init : function() {
            +870                 this.__super();
            +871 
            +872                 this.rc= new renderContext();
            +873                 this.lines= [];
            +874                 this.styles= {};
            +875                 this.images= {};
            +876 
            +877                 return this;
            +878             },
            +879 
            +880             /**
            +881              * This Label document´s horizontal alignment.
            +882              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
            +883              * @private
            +884              */
            +885             halignment  :   CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT,
            +886 
            +887             /**
            +888              * This Label document´s vertical alignment.
            +889              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
            +890              * @private
            +891              */
            +892             valignment  :   CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP,
            +893 
            +894             /**
            +895              * This label text.
            +896              * @type {string}
            +897              * @private
            +898              */
            +899             text        :   null,
            +900 
            +901             /**
            +902              * This label document´s render context
            +903              * @type {RenderContext}
            +904              * @private
            +905              */
            +906             rc          :   null,
            +907 
            +908             /**
            +909              * Styles object.
            +910              * @private
            +911              */
            +912             styles      :   null,
            +913 
            +914             /**
            +915              * Calculated document width.
            +916              * @private
            +917              */
            +918             documentWidth   : 0,
            +919 
            +920             /**
            +921              * Calculated document Height.
            +922              * @private
            +923              */
            +924             documentHeight  : 0,
            +925 
            +926             /**
            +927              * Document x position.
            +928              * @private
            +929              */
            +930             documentX       : 0,
            +931 
            +932             /**
            +933              * Document y position.
            +934              * @private
            +935              */
            +936             documentY       : 0,
            +937 
            +938             /**
            +939              * Does this label document flow ?
            +940              * @private
            +941              */
            +942             reflow      :   true,
            +943 
            +944             /**
            +945              * Collection of text lines calculated for the label.
            +946              * @private
            +947              */
            +948             lines       :   null,   // calculated elements lines...
            +949 
            +950             /**
            +951              * Collection of image objects in this label´s document.
            +952              * @private
            +953              */
            +954             images      :   null,
            +955 
            +956             /**
            +957              * Registered callback to notify on anchor click event.
            +958              * @private
            +959              */
            +960             clickCallback   : null,
            +961 
            +962             matchTextSize : true,
            +963 
            +964             /**
            +965              * Make the label actor the size the label document has been calculated for.
            +966              * @param match {boolean}
            +967              */
            +968             setMatchTextSize : function( match ) {
            +969                 this.matchTextSize= match;
            +970                 if ( match ) {
            +971                     this.width= this.preferredSize.width;
            +972                     this.height= this.preferredSize.height;
            +973                 }
            +974             },
            +975 
            +976             setStyle : function( name, styleData ) {
            +977                 this.styles[ name ]= styleData;
            +978                 return this;
            +979             },
            +980 
            +981             addImage : function( name, spriteImage ) {
            +982                 this.images[ name ]= spriteImage;
            +983                 return this;
            +984             },
            +985 
            +986             setSize : function(w,h) {
            +987                 CAAT.Foundation.UI.Label.superclass.setSize.call( this, w, h );
            +988                 this.setText( this.text, this.width );
            +989                 return this;
            +990             },
            +991 
            +992             setBounds : function( x,y,w,h ) {
            +993                 CAAT.Foundation.UI.Label.superclass.setBounds.call( this,x,y,w,h );
            +994                 this.setText( this.text, this.width );
            +995                 return this;
            +996             },
            +997 
            +998             setText : function( _text, width ) {
            +999 
            +1000                 if ( null===_text ) {
            +1001                    return;
            +1002                 }
            +1003 
            +1004                 var cached= this.cached;
            +1005                 if ( cached ) {
            +1006                     this.stopCacheAsBitmap();
            +1007                 }
            +1008 
            +1009                 this.documentWidth= 0;
            +1010                 this.documentHeight= 0;
            +1011 
            +1012                 this.text= _text;
            +1013 
            +1014                 var i, l, text;
            +1015                 var tag_closes_at_pos, tag;
            +1016                 var _char;
            +1017                 var ctx= CAAT.currentDirector.ctx;
            +1018                 ctx.save();
            +1019 
            +1020                 text= this.text;
            +1021 
            +1022                 i=0;
            +1023                 l=text.length;
            +1024 
            +1025                 this.rc.start( ctx, this.styles, this.images, width );
            +1026 
            +1027                 while( i<l ) {
            +1028                     _char= text.charAt(i);
            +1029 
            +1030                     if ( _char==='\\' ) {
            +1031                         i+=1;
            +1032                         this.rc.fchar( text.charAt(i) );
            +1033                         i+=1;
            +1034 
            +1035                     } else if ( _char==='<' ) {   // try an enhancement.
            +1036 
            +1037                         // try finding another '>' and see whether it matches a tag
            +1038                         tag_closes_at_pos= text.indexOf('>', i+1);
            +1039                         if ( -1!==tag_closes_at_pos ) {
            +1040                             tag= text.substr( i+1, tag_closes_at_pos-i-1 );
            +1041                             if ( tag.indexOf("<")!==-1 ) {
            +1042                                 this.rc.fchar( _char );
            +1043                                 i+=1;
            +1044                             } else {
            +1045                                 this.rc.setTag( tag );
            +1046                                 i= tag_closes_at_pos+1;
            +1047                             }
            +1048                         }
            +1049                     } else {
            +1050                         this.rc.fchar( _char );
            +1051                         i+= 1;
            +1052                     }
            +1053                 }
            +1054 
            +1055                 this.rc.end();
            +1056                 this.lines= this.rc.lines;
            +1057 
            +1058                 this.__calculateDocumentDimension( typeof width==="undefined" ? 0 : width );
            +1059                 this.setLinesAlignment();
            +1060 
            +1061                 ctx.restore();
            +1062 
            +1063                 this.setPreferredSize( this.documentWidth, this.documentHeight );
            +1064                 this.invalidateLayout();
            +1065 
            +1066                 this.setDocumentPosition();
            +1067 
            +1068                 if ( cached ) {
            +1069                     this.cacheAsBitmap(0,cached);
            +1070                 }
            +1071 
            +1072                 if ( this.matchTextSize ) {
            +1073                     this.width= this.preferredSize.width;
            +1074                     this.height= this.preferredSize.height;
            +1075                 }
            +1076 
            +1077                 return this;
            +1078             },
            +1079 
            +1080             setVerticalAlignment : function( align ) {
            +1081                 this.valignment= align;
            +1082                 this.setDocumentPosition();
            +1083                 return this;
            +1084             },
            +1085 
            +1086             setHorizontalAlignment : function( align ) {
            +1087                 this.halignment= align;
            +1088                 this.setDocumentPosition();
            +1089                 return this;
            +1090             },
            +1091 
            +1092             setDocumentPosition : function( halign, valign ) {
            +1093 
            +1094                 if ( typeof halign!=="undefined" ) {
            +1095                     this.setHorizontalAlignment(halign);
            +1096                 }
            +1097                 if ( typeof valign!=="undefined" ) {
            +1098                     this.setVerticalAlignment(valign);
            +1099                 }
            +1100 
            +1101                 var xo=0, yo=0;
            +1102 
            +1103                 if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) {
            +1104                     yo= (this.height - this.documentHeight )/2;
            +1105                 } else if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM ) {
            +1106                     yo= this.height - this.documentHeight;
            +1107                 }
            +1108 
            +1109                 if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) {
            +1110                     xo= (this.width - this.documentWidth )/2;
            +1111                 } else if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT ) {
            +1112                     xo= this.width - this.documentWidth;
            +1113                 }
            +1114 
            +1115                 this.documentX= xo;
            +1116                 this.documentY= yo;
            +1117             },
            +1118 
            +1119             __calculateDocumentDimension : function( suggestedWidth ) {
            +1120                 var i;
            +1121                 var y= 0;
            +1122 
            +1123                 this.documentWidth= 0;
            +1124                 this.documentHeight= 0;
            +1125                 for( i=0; i<this.lines.length; i++ ) {
            +1126                     this.lines[i].y =y;
            +1127                     this.documentWidth= Math.max( this.documentWidth, this.lines[i].width );
            +1128                     this.documentHeight+= this.lines[i].adjustHeight();
            +1129                     y+= this.lines[i].getHeight();
            +1130                 }
            +1131 
            +1132                 this.documentWidth= Math.max( this.documentWidth, suggestedWidth );
            +1133 
            +1134                 return this;
            +1135             },
            +1136 
            +1137             setLinesAlignment : function() {
            +1138 
            +1139                 for( var i=0; i<this.lines.length; i++ ) {
            +1140                     this.lines[i].setAlignment( this.documentWidth )
            +1141                 }
            +1142             },
            +1143 
            +1144             paint : function( director, time ) {
            +1145 
            +1146                 if ( this.cached===CAAT.Foundation.Actor.CACHE_NONE ) {
            +1147                     var ctx= director.ctx;
            +1148 
            +1149                     ctx.save();
            +1150 
            +1151                     ctx.textBaseline="alphabetic";
            +1152                     ctx.translate( this.documentX, this.documentY );
            +1153 
            +1154                     for( var i=0; i<this.lines.length; i++ ) {
            +1155                         var line= this.lines[i];
            +1156                         line.paint( director.ctx );
            +1157 
            +1158                         if ( DEBUG ) {
            +1159                             ctx.strokeRect( line.x, line.y, line.width, line.height );
            +1160                         }
            +1161                     }
            +1162 
            +1163                     ctx.restore();
            +1164                 } else {
            +1165                     if ( this.backgroundImage ) {
            +1166                         this.backgroundImage.paint(director,time,0,0);
            +1167                     }
            +1168                 }
            +1169             },
            +1170 
            +1171             __getDocumentElementAt : function( x, y ) {
            +1172 
            +1173                 x-= this.documentX;
            +1174                 y-= this.documentY;
            +1175 
            +1176                 for( var i=0; i<this.lines.length; i++ ) {
            +1177                     var line= this.lines[i];
            +1178 
            +1179                     if ( line.x<=x && line.y<=y && line.x+line.width>=x && line.y+line.height>=y ) {
            +1180                         return line.__getElementAt( x - line.x, y - line.y );
            +1181                     }
            +1182                 }
            +1183 
            +1184                 return null;
            +1185             },
            +1186 
            +1187             mouseExit : function(e) {
            +1188                 CAAT.setCursor( "default");
            +1189             },
            +1190 
            +1191             mouseMove : function(e) {
            +1192                 var elem= this.__getDocumentElementAt(e.x, e.y);
            +1193                 if ( elem && elem.getLink() ) {
            +1194                     CAAT.setCursor( "pointer");
            +1195                 } else {
            +1196                     CAAT.setCursor( "default");
            +1197                 }
            +1198             },
            +1199 
            +1200             mouseClick : function(e) {
            +1201                 if ( this.clickCallback ) {
            +1202                     var elem= this.__getDocumentElementAt(e.x, e.y);
            +1203                     if ( elem.getLink() ) {
            +1204                         this.clickCallback( elem.getLink() );
            +1205                     }
            +1206                 }
            +1207             },
            +1208 
            +1209             setClickCallback : function( callback ) {
            +1210                 this.clickCallback= callback;
            +1211                 return this;
            +1212             }
            +1213         }
            +1214 
            +1215     }
            +1216 
            +1217 });
            +1218 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BorderLayout.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BorderLayout.js.html new file mode 100644 index 0000000..612c419 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BorderLayout.js.html @@ -0,0 +1,226 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name BorderLayout
            +  5      * @memberOf CAAT.Foundation.UI.Layout
            +  6      * @extends CAAT.Foundation.UI.Layout.LayoutManager
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.Layout.BorderLayout",
            + 11     aliases : ["CAAT.UI.BorderLayout"],
            + 12     depends : [
            + 13         "CAAT.Foundation.UI.Layout.LayoutManager",
            + 14         "CAAT.Math.Dimension"
            + 15     ],
            + 16     extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager",
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Foundation.UI.Layout.BorderLayout.prototype
            + 21          */
            + 22 
            + 23 
            + 24         __init : function() {
            + 25             this.__super();
            + 26             return this;
            + 27         },
            + 28 
            + 29         /**
            + 30          * An actor to position left.
            + 31          */
            + 32         left    : null,
            + 33 
            + 34         /**
            + 35          * An actor to position right.
            + 36          */
            + 37         right   : null,
            + 38 
            + 39         /**
            + 40          * An actor to position top.
            + 41          */
            + 42         top     : null,
            + 43 
            + 44         /**
            + 45          * An actor to position botton.
            + 46          */
            + 47         bottom  : null,
            + 48 
            + 49         /**
            + 50          * An actor to position center.
            + 51          */
            + 52         center  : null,
            + 53 
            + 54         addChild : function( child, constraint ) {
            + 55 
            + 56             if ( typeof constraint==="undefined" ) {
            + 57                 constraint="center";
            + 58             }
            + 59 
            + 60             CAAT.Foundation.UI.Layout.BorderLayout.superclass.addChild.call( this, child, constraint );
            + 61 
            + 62             if ( constraint==="left" ) {
            + 63                 this.left= child;
            + 64             } else if ( constraint==="right" ) {
            + 65                 this.right= child;
            + 66             } else if ( constraint==="top" ) {
            + 67                 this.top= child;
            + 68             } else if ( constraint==="bottom" ) {
            + 69                 this.bottom= child;
            + 70             } else {
            + 71                 //"center"
            + 72                 this.center= child;
            + 73             }
            + 74         },
            + 75 
            + 76         removeChild : function( child ) {
            + 77             if ( this.center===child ) {
            + 78                 this.center=null;
            + 79             } else if ( this.left===child ) {
            + 80                 this.left= null;
            + 81             } else if ( this.right===child ) {
            + 82                 this.right= null;
            + 83             } else if ( this.top===child ) {
            + 84                 this.top= null;
            + 85             } else if ( this.bottom===child ) {
            + 86                 this.bottom= null;
            + 87             }
            + 88         },
            + 89 
            + 90         __getChild : function( constraint ) {
            + 91             if ( constraint==="center" ) {
            + 92                 return this.center;
            + 93             } else if ( constraint==="left" ) {
            + 94                 return this.left;
            + 95             } else if ( constraint==="right" ) {
            + 96                 return this.right;
            + 97             } else if ( constraint==="top" ) {
            + 98                 return this.top;
            + 99             } else if ( constraint==="bottom" ) {
            +100                 return this.bottom;
            +101             }
            +102         },
            +103 
            +104         getMinimumLayoutSize : function( container ) {
            +105             var c, d;
            +106             var dim= new CAAT.Math.Dimension();
            +107 
            +108             if ((c=this.__getChild("right")) != null) {
            +109                 d = c.getMinimumSize();
            +110                 dim.width += d.width + this.hgap;
            +111                 dim.height = Math.max(d.height, dim.height);
            +112             }
            +113             if ((c=this.__getChild("left")) != null) {
            +114                 d = c.getMinimumSize();
            +115                 dim.width += d.width + this.hgap;
            +116                 dim.height = Math.max(d.height, dim.height);
            +117             }
            +118             if ((c=this.__getChild("center")) != null) {
            +119                 d = c.getMinimumSize();
            +120                 dim.width += d.width;
            +121                 dim.height = Math.max(d.height, dim.height);
            +122             }
            +123             if ((c=this.__getChild("top")) != null) {
            +124                 d = c.getMinimumSize();
            +125                 dim.width = Math.max(d.width, dim.width);
            +126                 dim.height += d.height + this.vgap;
            +127             }
            +128             if ((c=this.__getChild("bottom")) != null) {
            +129                 d = c.getMinimumSize();
            +130                 dim.width = Math.max(d.width, dim.width);
            +131                 dim.height += d.height + this.vgap;
            +132             }
            +133 
            +134             dim.width += this.padding.left + this.padding.right;
            +135             dim.height += this.padding.top + this.padding.bottom;
            +136 
            +137             return dim;
            +138         },
            +139 
            +140         getPreferredLayoutSize : function( container ) {
            +141             var c, d;
            +142             var dim= new CAAT.Dimension();
            +143 
            +144             if ((c=this.__getChild("left")) != null) {
            +145                 d = c.getPreferredSize();
            +146                 dim.width += d.width + this.hgap;
            +147                 dim.height = Math.max(d.height, dim.height);
            +148             }
            +149             if ((c=this.__getChild("right")) != null) {
            +150                 d = c.getPreferredSize();
            +151                 dim.width += d.width + this.hgap;
            +152                 dim.height = Math.max(d.height, dim.height);
            +153             }
            +154             if ((c=this.__getChild("center")) != null) {
            +155                 d = c.getPreferredSize();
            +156                 dim.width += d.width;
            +157                 dim.height = Math.max(d.height, dim.height);
            +158             }
            +159             if ((c=this.__getChild("top")) != null) {
            +160                 d = c.getPreferredSize();
            +161                 dim.width = Math.max(d.width, dim.width);
            +162                 dim.height += d.height + this.vgap;
            +163             }
            +164             if ((c=this.__getChild("bottom")) != null) {
            +165                 d = c.getPreferredSize();
            +166                 dim.width = Math.max(d.width, dim.width);
            +167                 dim.height += d.height + this.vgap;
            +168             }
            +169 
            +170             dim.width += this.padding.left + this.padding.right;
            +171             dim.height += this.padding.top + this.padding.bottom;
            +172 
            +173             return dim;
            +174         },
            +175 
            +176         doLayout : function( container ) {
            +177 
            +178             var top = this.padding.top;
            +179             var bottom = container.height - this.padding.bottom;
            +180             var left = this.padding.left;
            +181             var right = container.width - this.padding.right;
            +182             var c, d;
            +183 
            +184             if ((c=this.__getChild("top")) != null) {
            +185                 c.setSize(right - left, c.height);
            +186                 d = c.getPreferredSize();
            +187                 c.setBounds(left, top, right - left, d.height);
            +188                 top += d.height + this.vgap;
            +189             }
            +190             if ((c=this.__getChild("bottom")) != null) {
            +191                 c.setSize(right - left, c.height);
            +192                 d = c.getPreferredSize();
            +193                 c.setBounds(left, bottom - d.height, right - left, d.height);
            +194                 bottom -= d.height + this.vgap;
            +195             }
            +196             if ((c=this.__getChild("right")) != null) {
            +197                 c.setSize(c.width, bottom - top);
            +198                 d = c.getPreferredSize();
            +199                 c.setBounds(right - d.width, top, d.width, bottom - top);
            +200                 right -= d.width + this.hgap;
            +201             }
            +202             if ((c=this.__getChild("left")) != null) {
            +203                 c.setSize(c.width, bottom - top);
            +204                 d = c.getPreferredSize();
            +205                 c.setBounds(left, top, d.width, bottom - top);
            +206                 left += d.width + this.hgap;
            +207             }
            +208             if ((c=this.__getChild("center")) != null) {
            +209                 c.setBounds(left, top, right - left, bottom - top);
            +210             }
            +211 
            +212             CAAT.Foundation.UI.Layout.BorderLayout.superclass.doLayout.call(this, container);
            +213         }
            +214 
            +215 
            +216     }
            +217 
            +218 });
            +219 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BoxLayout.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BoxLayout.js.html new file mode 100644 index 0000000..4f49cbf --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_BoxLayout.js.html @@ -0,0 +1,255 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name BoxLayout
            +  5      * @memberOf CAAT.Foundation.UI.Layout
            +  6      * @extends CAAT.Foundation.UI.Layout.LayoutManager
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Foundation.UI.Layout.BoxLayout",
            + 11     aliases:["CAAT.UI.BoxLayout"],
            + 12     depends:[
            + 13         "CAAT.Foundation.UI.Layout.LayoutManager",
            + 14         "CAAT.Math.Dimension"
            + 15     ],
            + 16     extendsClass:"CAAT.Foundation.UI.Layout.LayoutManager",
            + 17     extendsWith:function () {
            + 18 
            + 19         return {
            + 20 
            + 21             /**
            + 22              * @lends CAAT.Foundation.UI.Layout.BoxLayout.prototype
            + 23              */
            + 24 
            + 25             /**
            + 26              * Stack elements in this axis.
            + 27              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
            + 28              */
            + 29             axis:CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y,
            + 30 
            + 31             /**
            + 32              * Vertical alignment.
            + 33              * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT}
            + 34              */
            + 35             valign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER,
            + 36 
            + 37             /**
            + 38              * Horizontal alignment.
            + 39              * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT}
            + 40              */
            + 41             halign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER,
            + 42 
            + 43             setAxis:function (axis) {
            + 44                 this.axis = axis;
            + 45                 this.invalidateLayout();
            + 46                 return this;
            + 47             },
            + 48 
            + 49             setHorizontalAlignment:function (align) {
            + 50                 this.halign = align;
            + 51                 this.invalidateLayout();
            + 52                 return this;
            + 53             },
            + 54 
            + 55             setVerticalAlignment:function (align) {
            + 56                 this.valign = align;
            + 57                 this.invalidateLayout();
            + 58                 return this;
            + 59             },
            + 60 
            + 61             doLayout:function (container) {
            + 62 
            + 63                 if (this.axis === CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y) {
            + 64                     this.doLayoutVertical(container);
            + 65                 } else {
            + 66                     this.doLayoutHorizontal(container);
            + 67                 }
            + 68 
            + 69                 CAAT.Foundation.UI.Layout.BoxLayout.superclass.doLayout.call(this, container);
            + 70             },
            + 71 
            + 72             doLayoutHorizontal:function (container) {
            + 73 
            + 74                 var computedW = 0, computedH = 0;
            + 75                 var yoffset = 0, xoffset;
            + 76                 var i, l, actor;
            + 77 
            + 78                 // calculamos ancho y alto de los elementos.
            + 79                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            + 80 
            + 81                     actor = container.getChildAt(i);
            + 82                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            + 83                         if (computedH < actor.height) {
            + 84                             computedH = actor.height;
            + 85                         }
            + 86 
            + 87                         computedW += actor.width;
            + 88                         if (i > 0) {
            + 89                             computedW += this.hgap;
            + 90                         }
            + 91                     }
            + 92                 }
            + 93 
            + 94                 switch (this.halign) {
            + 95                     case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT:
            + 96                         xoffset = this.padding.left;
            + 97                         break;
            + 98                     case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT:
            + 99                         xoffset = container.width - computedW - this.padding.right;
            +100                         break;
            +101                     default:
            +102                         xoffset = (container.width - computedW) / 2;
            +103                 }
            +104 
            +105                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            +106                     actor = container.getChildAt(i);
            +107                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            +108                         switch (this.valign) {
            +109                             case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP:
            +110                                 yoffset = this.padding.top;
            +111                                 break;
            +112                             case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM:
            +113                                 yoffset = container.height - this.padding.bottom - actor.height;
            +114                                 break;
            +115                             default:
            +116                                 yoffset = (container.height - actor.height) / 2;
            +117                         }
            +118 
            +119                         this.__setActorPosition(actor, xoffset, yoffset);
            +120 
            +121                         xoffset += actor.width + this.hgap;
            +122                     }
            +123                 }
            +124 
            +125             },
            +126 
            +127             __setActorPosition:function (actor, xoffset, yoffset) {
            +128                 if (this.animated) {
            +129                     if (this.newChildren.indexOf(actor) !== -1) {
            +130                         actor.setPosition(xoffset, yoffset);
            +131                         actor.setScale(0, 0);
            +132                         actor.scaleTo(1, 1, 500, 0, .5, .5, this.newElementInterpolator);
            +133                     } else {
            +134                         actor.moveTo(xoffset, yoffset, 500, 0, this.moveElementInterpolator);
            +135                     }
            +136                 } else {
            +137                     actor.setPosition(xoffset, yoffset);
            +138                 }
            +139             },
            +140 
            +141             doLayoutVertical:function (container) {
            +142 
            +143                 var computedW = 0, computedH = 0;
            +144                 var yoffset, xoffset;
            +145                 var i, l, actor;
            +146 
            +147                 // calculamos ancho y alto de los elementos.
            +148                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            +149 
            +150                     actor = container.getChildAt(i);
            +151                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            +152                         if (computedW < actor.width) {
            +153                             computedW = actor.width;
            +154                         }
            +155 
            +156                         computedH += actor.height;
            +157                         if (i > 0) {
            +158                             computedH += this.vgap;
            +159                         }
            +160                     }
            +161                 }
            +162 
            +163                 switch (this.valign) {
            +164                     case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP:
            +165                         yoffset = this.padding.top;
            +166                         break;
            +167                     case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM:
            +168                         yoffset = container.height - computedH - this.padding.bottom;
            +169                         break;
            +170                     default:
            +171                         yoffset = (container.height - computedH) / 2;
            +172                 }
            +173 
            +174                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            +175                     actor = container.getChildAt(i);
            +176                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            +177                         switch (this.halign) {
            +178                             case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT:
            +179                                 xoffset = this.padding.left;
            +180                                 break;
            +181                             case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT:
            +182                                 xoffset = container.width - this.padding.right - actor.width;
            +183                                 break;
            +184                             default:
            +185                                 xoffset = (container.width - actor.width) / 2;
            +186                         }
            +187 
            +188                         this.__setActorPosition(actor, xoffset, yoffset);
            +189 
            +190                         yoffset += actor.height + this.vgap;
            +191                     }
            +192                 }
            +193             },
            +194 
            +195             getPreferredLayoutSize:function (container) {
            +196 
            +197                 var dim = new CAAT.Math.Dimension();
            +198                 var computedW = 0, computedH = 0;
            +199                 var i, l;
            +200 
            +201                 // calculamos ancho y alto de los elementos.
            +202                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            +203 
            +204                     var actor = container.getChildAt(i);
            +205                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            +206                         var ps = actor.getPreferredSize();
            +207 
            +208                         if (computedH < ps.height) {
            +209                             computedH = ps.height;
            +210                         }
            +211                         computedW += ps.width;
            +212                     }
            +213                 }
            +214 
            +215                 dim.width = computedW;
            +216                 dim.height = computedH;
            +217 
            +218                 return dim;
            +219             },
            +220 
            +221             getMinimumLayoutSize:function (container) {
            +222                 var dim = new CAAT.Math.Dimension();
            +223                 var computedW = 0, computedH = 0;
            +224                 var i, l;
            +225 
            +226                 // calculamos ancho y alto de los elementos.
            +227                 for (i = 0, l = container.getNumChildren(); i < l; i += 1) {
            +228 
            +229                     var actor = container.getChildAt(i);
            +230                     if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) {
            +231                         var ps = actor.getMinimumSize();
            +232 
            +233                         if (computedH < ps.height) {
            +234                             computedH = ps.height;
            +235                         }
            +236                         computedW += ps.width;
            +237                     }
            +238                 }
            +239 
            +240                 dim.width = computedW;
            +241                 dim.height = computedH;
            +242 
            +243                 return dim;
            +244             }
            +245         }
            +246     }
            +247 });
            +248 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_GridLayout.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_GridLayout.js.html new file mode 100644 index 0000000..fafe6f2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_GridLayout.js.html @@ -0,0 +1,186 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name GridLayout
            +  5      * @memberOf CAAT.Foundation.UI.Layout
            +  6      * @extends CAAT.Foundation.UI.Layout.LayoutManager
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.Layout.GridLayout",
            + 11     aliases : ["CAAT.UI.GridLayout"],
            + 12     depends : [
            + 13         "CAAT.Foundation.UI.Layout.LayoutManager",
            + 14         "CAAT.Math.Dimension"
            + 15     ],
            + 16     extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager",
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Foundation.UI.Layout.GridLayout.prototype
            + 21          */
            + 22 
            + 23         __init : function( rows, columns ) {
            + 24             this.__super();
            + 25             this.rows= rows;
            + 26             this.columns= columns;
            + 27 
            + 28             return this;
            + 29         },
            + 30 
            + 31         /**
            + 32          * Layout elements using this number of rows.
            + 33          */
            + 34         rows    : 0,
            + 35 
            + 36         /**
            + 37          * Layout elements using this number of columns.
            + 38          */
            + 39         columns : 2,
            + 40 
            + 41         doLayout : function( container ) {
            + 42 
            + 43             var actors= [];
            + 44             for( var i=0; i<container.getNumChildren(); i++ ) {
            + 45                 var child= container.getChildAt(i);
            + 46                 if (!child.preventLayout && child.isVisible() && child.isInAnimationFrame( CAAT.getCurrentSceneTime()) ) {
            + 47                     actors.push(child);
            + 48                 }
            + 49             }
            + 50             var nactors= actors.length;
            + 51 
            + 52             if (nactors.length=== 0) {
            + 53                 return;
            + 54             }
            + 55 
            + 56             var nrows = this.rows;
            + 57             var ncols = this.columns;
            + 58 
            + 59             if (nrows > 0) {
            + 60                 ncols = Math.floor( (nactors + nrows - 1) / nrows );
            + 61             } else {
            + 62                 nrows = Math.floor( (nactors + ncols - 1) / ncols );
            + 63             }
            + 64 
            + 65             var totalGapsWidth = (ncols - 1) * this.hgap;
            + 66             var widthWOInsets = container.width - (this.padding.left + this.padding.right);
            + 67             var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols );
            + 68             var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 );
            + 69 
            + 70             var totalGapsHeight = (nrows - 1) * this.vgap;
            + 71             var heightWOInsets = container.height - (this.padding.top + this.padding.bottom);
            + 72             var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows );
            + 73             var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 );
            + 74 
            + 75             for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) {
            + 76                 for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) {
            + 77                     var i = r * ncols + c;
            + 78                     if (i < actors.length) {
            + 79                         var child= actors[i];
            + 80                         if ( !child.preventLayout && child.isVisible() && child.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) {
            + 81                             if ( !this.animated ) {
            + 82                                 child.setBounds(
            + 83                                     x + (widthOnComponent-child.width)/2,
            + 84                                     y,
            + 85                                     widthOnComponent,
            + 86                                     heightOnComponent);
            + 87                             } else {
            + 88                                 if ( child.width!==widthOnComponent || child.height!==heightOnComponent ) {
            + 89                                     child.setSize(widthOnComponent, heightOnComponent);
            + 90                                     if ( this.newChildren.indexOf( child ) !==-1 ) {
            + 91                                         child.setPosition(
            + 92                                             x + (widthOnComponent-child.width)/2,
            + 93                                             y );
            + 94                                         child.setScale(0.01,0.01);
            + 95                                         child.scaleTo( 1,1, 500, 0,.5,.5, this.newElementInterpolator );
            + 96                                     } else {
            + 97                                         child.moveTo(
            + 98                                             x + (widthOnComponent-child.width)/2,
            + 99                                             y,
            +100                                             500,
            +101                                             0,
            +102                                             this.moveElementInterpolator );
            +103                                     }
            +104                                 }
            +105                             }
            +106                         }
            +107                     }
            +108                 }
            +109             }
            +110 
            +111             CAAT.Foundation.UI.Layout.GridLayout.superclass.doLayout.call(this, container);
            +112         },
            +113 
            +114         getMinimumLayoutSize : function( container ) {
            +115             var nrows = this.rows;
            +116             var ncols = this.columns;
            +117             var nchildren= container.getNumChildren();
            +118             var w=0, h=0, i;
            +119 
            +120             if (nrows > 0) {
            +121                 ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
            +122             } else {
            +123                 nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
            +124             }
            +125 
            +126             for ( i= 0; i < nchildren; i+=1 ) {
            +127                 var actor= container.getChildAt(i);
            +128                 if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) {
            +129                     var d = actor.getMinimumSize();
            +130                     if (w < d.width) {
            +131                         w = d.width;
            +132                     }
            +133                     if (h < d.height) {
            +134                         h = d.height;
            +135                     }
            +136                 }
            +137             }
            +138 
            +139             return new CAAT.Math.Dimension(
            +140                 this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
            +141                 this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
            +142             );
            +143         },
            +144 
            +145         getPreferredLayoutSize : function( container ) {
            +146 
            +147             var nrows = this.rows;
            +148             var ncols = this.columns;
            +149             var nchildren= container.getNumChildren();
            +150             var w=0, h=0, i;
            +151 
            +152             if (nrows > 0) {
            +153                 ncols = Math.ceil( (nchildren + nrows - 1) / nrows );
            +154             } else {
            +155                 nrows = Math.ceil( (nchildren + ncols - 1) / ncols );
            +156             }
            +157 
            +158             for ( i= 0; i < nchildren; i+=1 ) {
            +159                 var actor= container.getChildAt(i);
            +160                 if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) {
            +161                     var d = actor.getPreferredSize();
            +162                     if (w < d.width) {
            +163                         w = d.width;
            +164                     }
            +165                     if (h < d.height) {
            +166                         h = d.height;
            +167                     }
            +168                 }
            +169             }
            +170 
            +171             return new CAAT.Math.Dimension(
            +172                 this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap,
            +173                 this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap
            +174             );
            +175         }
            +176 
            +177     }
            +178 });
            +179 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_LayoutManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_LayoutManager.js.html new file mode 100644 index 0000000..8ccaf7d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_Layout_LayoutManager.js.html @@ -0,0 +1,187 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name Layout
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name LayoutManager
            + 11      * @memberOf CAAT.Foundation.UI.Layout
            + 12      * @constructor
            + 13      */
            + 14 
            + 15     defines : "CAAT.Foundation.UI.Layout.LayoutManager",
            + 16     aliases : ["CAAT.UI.LayoutManager"],
            + 17     depends : [
            + 18         "CAAT.Behavior.Interpolator"
            + 19     ],
            + 20     constants : {
            + 21 
            + 22         /**
            + 23          * @lends CAAT.Foundation.UI.Layout.LayoutManager
            + 24          */
            + 25 
            + 26         /**
            + 27          * @enum {number}
            + 28          */
            + 29         AXIS: {
            + 30             X : 0,
            + 31             Y : 1
            + 32         },
            + 33 
            + 34         /**
            + 35          * @enum {number}
            + 36          */
            + 37         ALIGNMENT : {
            + 38             LEFT :  0,
            + 39             RIGHT:  1,
            + 40             CENTER: 2,
            + 41             TOP:    3,
            + 42             BOTTOM: 4,
            + 43             JUSTIFY:5
            + 44         }
            + 45 
            + 46     },
            + 47     extendsWith : function() {
            + 48 
            + 49         return {
            + 50 
            + 51             /**
            + 52              * @lends CAAT.Foundation.UI.Layout.LayoutManager.prototype
            + 53              */
            + 54 
            + 55 
            + 56             __init : function( ) {
            + 57 
            + 58                 this.newChildren= [];
            + 59                 this.padding= {
            + 60                     left:   2,
            + 61                     right:  2,
            + 62                     top:    2,
            + 63                     bottom: 2
            + 64                 };
            + 65 
            + 66                 return this;
            + 67             },
            + 68 
            + 69             /**
            + 70              * If animation enabled, new element interpolator.
            + 71              */
            + 72             newElementInterpolator : new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1,.7),
            + 73 
            + 74             /**
            + 75              * If animation enabled, relayout elements interpolator.
            + 76              */
            + 77             moveElementInterpolator : new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2),
            + 78 
            + 79             /**
            + 80              * Defines insets:
            + 81              * @type {{ left, right, top, botton }}
            + 82              */
            + 83             padding : null,
            + 84 
            + 85             /**
            + 86              * Needs relayout ??
            + 87              */
            + 88             invalid : true,
            + 89 
            + 90             /**
            + 91              * Horizontal gap between children.
            + 92              */
            + 93             hgap        : 2,
            + 94 
            + 95             /**
            + 96              * Vertical gap between children.
            + 97              */
            + 98             vgap        : 2,
            + 99 
            +100             /**
            +101              * Animate on adding/removing elements.
            +102              */
            +103             animated    : false,
            +104 
            +105             /**
            +106              * pending to be laid-out actors.
            +107              */
            +108             newChildren : null,
            +109 
            +110             setAnimated : function( animate ) {
            +111                 this.animated= animate;
            +112                 return this;
            +113             },
            +114 
            +115             setHGap : function( gap ) {
            +116                 this.hgap= gap;
            +117                 this.invalidateLayout();
            +118                 return this;
            +119             },
            +120 
            +121             setVGap : function( gap ) {
            +122                 this.vgap= gap;
            +123                 this.invalidateLayout();
            +124                 return this;
            +125             },
            +126 
            +127             setAllPadding : function( s ) {
            +128                 this.padding.left= s;
            +129                 this.padding.right= s;
            +130                 this.padding.top= s;
            +131                 this.padding.bottom= s;
            +132                 this.invalidateLayout();
            +133                 return this;
            +134             },
            +135 
            +136             setPadding : function( l,r, t,b ) {
            +137                 this.padding.left= l;
            +138                 this.padding.right= r;
            +139                 this.padding.top= t;
            +140                 this.padding.bottom= b;
            +141                 this.invalidateLayout();
            +142                 return this;
            +143             },
            +144 
            +145             addChild : function( child, constraints ) {
            +146                 this.newChildren.push( child );
            +147             },
            +148 
            +149             removeChild : function( child ) {
            +150 
            +151             },
            +152 
            +153             doLayout : function( container ) {
            +154                 this.newChildren= [];
            +155                 this.invalid= false;
            +156             },
            +157 
            +158             invalidateLayout : function( container ) {
            +159                 this.invalid= true;
            +160             },
            +161 
            +162             getMinimumLayoutSize : function( container ) {
            +163 
            +164             },
            +165 
            +166             getPreferredLayoutSize : function(container ) {
            +167 
            +168             },
            +169 
            +170             isValid : function() {
            +171                 return !this.invalid;
            +172             },
            +173 
            +174             isInvalidated : function() {
            +175                 return this.invalid;
            +176             }
            +177         }
            +178     }
            +179 });
            +180 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_PathActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_PathActor.js.html new file mode 100644 index 0000000..c1f9dfd --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_PathActor.js.html @@ -0,0 +1,167 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * An actor to show the path and its handles in the scene graph. 
            +  5  *
            +  6  **/
            +  7 CAAT.Module( {
            +  8 
            +  9     /**
            + 10      * @name PathActor
            + 11      * @memberOf CAAT.Foundation.UI
            + 12      * @extends CAAT.Foundation.Actor
            + 13      * @constructor
            + 14      */
            + 15 
            + 16     defines : "CAAT.Foundation.UI.PathActor",
            + 17     aliases : ["CAAT.PathActor"],
            + 18     depends : [
            + 19         "CAAT.Foundation.Actor"
            + 20     ],
            + 21     extendsClass : "CAAT.Foundation.Actor",
            + 22     extendsWith : {
            + 23 
            + 24         /**
            + 25          * @lends CAAT.Foundation.UI.PathActor.prototype
            + 26          */
            + 27 
            + 28         /**
            + 29          * Path to draw.
            + 30          * @type {CAAT.PathUtil.Path}
            + 31          */
            + 32 		path                    : null,
            + 33 
            + 34         /**
            + 35          * Calculated path´s bounding box.
            + 36          */
            + 37 		pathBoundingRectangle   : null,
            + 38 
            + 39         /**
            + 40          * draw the bounding rectangle too ?
            + 41          */
            + 42 		bOutline                : false,
            + 43 
            + 44         /**
            + 45          * Outline the path in this color.
            + 46          */
            + 47         outlineColor            : 'black',
            + 48 
            + 49         /**
            + 50          * If the path is interactive, some handlers are shown to modify the path.
            + 51          * This callback function will be called when the path is interactively changed.
            + 52          */
            + 53         onUpdateCallback        : null,
            + 54 
            + 55         /**
            + 56          * Set this path as interactive.
            + 57          */
            + 58         interactive             : false,
            + 59 
            + 60         /**
            + 61          * Return the contained path.
            + 62          * @return {CAAT.Path}
            + 63          */
            + 64         getPath : function() {
            + 65             return this.path;
            + 66         },
            + 67 
            + 68         /**
            + 69          * Sets the path to manage.
            + 70          * @param path {CAAT.PathUtil.PathSegment}
            + 71          * @return this
            + 72          */
            + 73 		setPath : function(path) {
            + 74 			this.path= path;
            + 75             if ( path!=null ) {
            + 76 			    this.pathBoundingRectangle= path.getBoundingBox();
            + 77                 this.setInteractive( this.interactive );
            + 78             }
            + 79             return this;
            + 80 		},
            + 81         /**
            + 82          * Paint this actor.
            + 83          * @param director {CAAT.Foundation.Director}
            + 84          * @param time {number}. Scene time.
            + 85          */
            + 86 		paint : function(director, time) {
            + 87 
            + 88             CAAT.Foundation.UI.PathActor.superclass.paint.call( this, director, time );
            + 89 
            + 90             if ( !this.path ) {
            + 91                 return;
            + 92             }
            + 93 
            + 94             var ctx= director.ctx;
            + 95 
            + 96             ctx.strokeStyle='#000';
            + 97 			this.path.paint(director, this.interactive);
            + 98 
            + 99             if ( this.bOutline ) {
            +100                 ctx.strokeStyle= this.outlineColor;
            +101                 ctx.strokeRect(
            +102                     this.pathBoundingRectangle.x,
            +103                     this.pathBoundingRectangle.y,
            +104                     this.pathBoundingRectangle.width,
            +105                     this.pathBoundingRectangle.height
            +106                 );
            +107             }
            +108 		},
            +109         /**
            +110          * Enables/disables drawing of the contained path's bounding box.
            +111          * @param show {boolean} whether to show the bounding box
            +112          * @param color {=string} optional parameter defining the path's bounding box stroke style.
            +113          */
            +114         showBoundingBox : function(show, color) {
            +115             this.bOutline= show;
            +116             if ( show && color ) {
            +117                 this.outlineColor= color;
            +118             }
            +119             return this;
            +120         },
            +121         /**
            +122          * Set the contained path as interactive. This means it can be changed on the fly by manipulation
            +123          * of its control points.
            +124          * @param interactive
            +125          */
            +126         setInteractive : function(interactive) {
            +127             this.interactive= interactive;
            +128             if ( this.path ) {
            +129                 this.path.setInteractive(interactive);
            +130             }
            +131             return this;
            +132         },
            +133         setOnUpdateCallback : function( fn ) {
            +134             this.onUpdateCallback= fn;
            +135             return this;
            +136         },
            +137         /**
            +138          * Route mouse dragging functionality to the contained path.
            +139          * @param mouseEvent {CAAT.Event.MouseEvent}
            +140          */
            +141 		mouseDrag : function(mouseEvent) {
            +142 			this.path.drag(mouseEvent.point.x, mouseEvent.point.y, this.onUpdateCallback);
            +143 		},
            +144         /**
            +145          * Route mouse down functionality to the contained path.
            +146          * @param mouseEvent {CAAT.Event.MouseEvent}
            +147          */
            +148 		mouseDown : function(mouseEvent) {
            +149 			this.path.press(mouseEvent.point.x, mouseEvent.point.y);
            +150 		},
            +151         /**
            +152          * Route mouse up functionality to the contained path.
            +153          * @param mouseEvent {CAAT.Event.MouseEvent}
            +154          */
            +155 		mouseUp : function(mouseEvent) {
            +156 			this.path.release();
            +157 		}
            +158 	}
            +159 });
            +160 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_ShapeActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_ShapeActor.js.html new file mode 100644 index 0000000..4147595 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_ShapeActor.js.html @@ -0,0 +1,235 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name ShapeActor
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @extends CAAT.Foundation.ActorContainer
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.ShapeActor",
            + 11     aliases : ["CAAT.ShapeActor"],
            + 12     extendsClass : "CAAT.Foundation.ActorContainer",
            + 13     depends : [
            + 14         "CAAT.Foundation.ActorContainer"
            + 15     ],
            + 16     constants : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Foundation.UI.ShapeActor
            + 20          */
            + 21 
            + 22         /** @const */ SHAPE_CIRCLE:   0,      // Constants to describe different shapes.
            + 23         /** @const */ SHAPE_RECTANGLE:1
            + 24     },
            + 25     extendsWith : {
            + 26 
            + 27         /**
            + 28          * @lends CAAT.Foundation.UI.ShapeActor.prototype
            + 29          */
            + 30 
            + 31         __init : function() {
            + 32             this.__super();
            + 33             this.compositeOp= 'source-over';
            + 34 
            + 35             /**
            + 36              * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default,
            + 37              * so if no explicit call to setShape was made, nothing would be drawn.
            + 38              */
            + 39             this.setShape( CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE );
            + 40             return this;
            + 41         },
            + 42 
            + 43         /**
            + 44          * Define this actor shape: rectangle or circle
            + 45          */
            + 46         shape:          0,      // shape type. One of the constant SHAPE_* values
            + 47 
            + 48         /**
            + 49          * Set this shape composite operation when drawing it.
            + 50          */
            + 51         compositeOp:    null,   // a valid canvas rendering context string describing compositeOps.
            + 52 
            + 53         /**
            + 54          * Stroke the shape with this line width.
            + 55          */
            + 56         lineWidth:      1,
            + 57 
            + 58         /**
            + 59          * Stroke the shape with this line cap.
            + 60          */
            + 61         lineCap:        null,
            + 62 
            + 63         /**
            + 64          * Stroke the shape with this line Join.
            + 65          */
            + 66         lineJoin:       null,
            + 67 
            + 68         /**
            + 69          * Stroke the shape with this line mitter limit.
            + 70          */
            + 71         miterLimit:     null,
            + 72 
            + 73         /**
            + 74          * 
            + 75          * @param l {number>0}
            + 76          */
            + 77         setLineWidth : function(l)  {
            + 78             this.lineWidth= l;
            + 79             return this;
            + 80         },
            + 81         /**
            + 82          *
            + 83          * @param lc {string{butt|round|square}}
            + 84          */
            + 85         setLineCap : function(lc)   {
            + 86             this.lineCap= lc;
            + 87             return this;
            + 88         },
            + 89         /**
            + 90          *
            + 91          * @param lj {string{bevel|round|miter}}
            + 92          */
            + 93         setLineJoin : function(lj)  {
            + 94             this.lineJoin= lj;
            + 95             return this;
            + 96         },
            + 97         /**
            + 98          *
            + 99          * @param ml {integer>0}
            +100          */
            +101         setMiterLimit : function(ml)    {
            +102             this.miterLimit= ml;
            +103             return this;
            +104         },
            +105         getLineCap : function() {
            +106             return this.lineCap;
            +107         },
            +108         getLineJoin : function()    {
            +109             return this.lineJoin;
            +110         },
            +111         getMiterLimit : function()  {
            +112             return this.miterLimit;
            +113         },
            +114         getLineWidth : function()   {
            +115             return this.lineWidth;
            +116         },
            +117         /**
            +118          * Sets shape type.
            +119          * No check for parameter validity is performed.
            +120          * Set paint method according to the shape.
            +121          * @param iShape an integer with any of the SHAPE_* constants.
            +122          * @return this
            +123          */
            +124         setShape : function(iShape) {
            +125             this.shape= iShape;
            +126             this.paint= this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ?
            +127                     this.paintCircle :
            +128                     this.paintRectangle;
            +129             return this;
            +130         },
            +131         /**
            +132          * Sets the composite operation to apply on shape drawing.
            +133          * @param compositeOp an string with a valid canvas rendering context string describing compositeOps.
            +134          * @return this
            +135          */
            +136         setCompositeOp : function(compositeOp){
            +137             this.compositeOp= compositeOp;
            +138             return this;
            +139         },
            +140         /**
            +141          * Draws the shape.
            +142          * Applies the values of fillStype, strokeStyle, compositeOp, etc.
            +143          *
            +144          * @param director a valid CAAT.Director instance.
            +145          * @param time an integer with the Scene time the Actor is being drawn.
            +146          */
            +147         paint : function(director,time) {
            +148         },
            +149         /**
            +150          * @private
            +151          * Draws a circle.
            +152          * @param director a valid CAAT.Director instance.
            +153          * @param time an integer with the Scene time the Actor is being drawn.
            +154          */
            +155         paintCircle : function(director,time) {
            +156 
            +157             if ( this.cached ) {
            +158                 CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time );
            +159                 return;
            +160             }
            +161 
            +162             var ctx= director.ctx;
            +163 
            +164             ctx.lineWidth= this.lineWidth;
            +165 
            +166             ctx.globalCompositeOperation= this.compositeOp;
            +167             if ( null!==this.fillStyle ) {
            +168                 ctx.fillStyle= this.fillStyle;
            +169                 ctx.beginPath();
            +170                 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false );
            +171                 ctx.fill();
            +172             }
            +173 
            +174             if ( null!==this.strokeStyle ) {
            +175                 ctx.strokeStyle= this.strokeStyle;
            +176                 ctx.beginPath();
            +177                 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false );
            +178                 ctx.stroke();
            +179             }
            +180         },
            +181         /**
            +182          *
            +183          * Private
            +184          * Draws a Rectangle.
            +185          *
            +186          * @param director a valid CAAT.Director instance.
            +187          * @param time an integer with the Scene time the Actor is being drawn.
            +188          */
            +189         paintRectangle : function(director,time) {
            +190 
            +191             if ( this.cached ) {
            +192                 CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time );
            +193                 return;
            +194             }
            +195 
            +196             var ctx= director.ctx;
            +197 
            +198             ctx.lineWidth= this.lineWidth;
            +199 
            +200             if ( this.lineCap ) {
            +201                 ctx.lineCap= this.lineCap;
            +202             }
            +203             if ( this.lineJoin )    {
            +204                 ctx.lineJoin= this.lineJoin;
            +205             }
            +206             if ( this.miterLimit )  {
            +207                 ctx.miterLimit= this.miterLimit;
            +208             }
            +209 
            +210             ctx.globalCompositeOperation= this.compositeOp;
            +211             if ( null!==this.fillStyle ) {
            +212                 ctx.fillStyle= this.fillStyle;
            +213                 ctx.beginPath();
            +214                 ctx.fillRect(0,0,this.width,this.height);
            +215                 ctx.fill();
            +216             }
            +217 
            +218             if ( null!==this.strokeStyle ) {
            +219                 ctx.strokeStyle= this.strokeStyle;
            +220                 ctx.beginPath();
            +221                 ctx.strokeRect(0,0,this.width,this.height);
            +222                 ctx.stroke();
            +223             }
            +224         }
            +225     }
            +226 
            +227 });
            +228 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_StarActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_StarActor.js.html new file mode 100644 index 0000000..4aaa420 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_StarActor.js.html @@ -0,0 +1,237 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name StarActor
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @extends CAAT.Foundation.ActorContainer
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.StarActor",
            + 11     aliases : ["CAAT.StarActor"],
            + 12     depends : [
            + 13         "CAAT.Foundation.ActorContainer"
            + 14     ],
            + 15     extendsClass : "CAAT.Foundation.ActorContainer",
            + 16     extendsWith : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Foundation.UI.StarActor.prototype
            + 20          */
            + 21 
            + 22         __init : function() {
            + 23             this.__super();
            + 24             this.compositeOp= 'source-over';
            + 25             return this;
            + 26         },
            + 27 
            + 28         /**
            + 29          * Number of star peaks.
            + 30          */
            + 31         nPeaks:         0,
            + 32 
            + 33         /**
            + 34          * Maximum radius.
            + 35          */
            + 36         maxRadius:      0,
            + 37 
            + 38         /**
            + 39          * Minimum radius.
            + 40          */
            + 41         minRadius:      0,
            + 42 
            + 43         /**
            + 44          * Staring angle in radians.
            + 45          */
            + 46         initialAngle:   0,
            + 47 
            + 48         /**
            + 49          * Draw the star with this composite operation.
            + 50          */
            + 51         compositeOp:    null,
            + 52 
            + 53         /**
            + 54          *
            + 55          */
            + 56         lineWidth:      1,
            + 57 
            + 58         /**
            + 59          *
            + 60          */
            + 61         lineCap:        null,
            + 62 
            + 63         /**
            + 64          *
            + 65          */
            + 66         lineJoin:       null,
            + 67 
            + 68         /**
            + 69          *
            + 70          */
            + 71         miterLimit:     null,
            + 72 
            + 73         /**
            + 74          *
            + 75          * @param l {number>0}
            + 76          */
            + 77         setLineWidth : function(l)  {
            + 78             this.lineWidth= l;
            + 79             return this;
            + 80         },
            + 81         /**
            + 82          *
            + 83          * @param lc {string{butt|round|square}}
            + 84          */
            + 85         setLineCap : function(lc)   {
            + 86             this.lineCap= lc;
            + 87             return this;
            + 88         },
            + 89         /**
            + 90          *
            + 91          * @param lj {string{bevel|round|miter}}
            + 92          */
            + 93         setLineJoin : function(lj)  {
            + 94             this.lineJoin= lj;
            + 95             return this;
            + 96         },
            + 97         /**
            + 98          *
            + 99          * @param ml {integer>0}
            +100          */
            +101         setMiterLimit : function(ml)    {
            +102             this.miterLimit= ml;
            +103             return this;
            +104         },
            +105         getLineCap : function() {
            +106             return this.lineCap;
            +107         },
            +108         getLineJoin : function()    {
            +109             return this.lineJoin;
            +110         },
            +111         getMiterLimit : function()  {
            +112             return this.miterLimit;
            +113         },
            +114         getLineWidth : function()   {
            +115             return this.lineWidth;
            +116         },
            +117         /**
            +118          * Sets whether the star will be color filled.
            +119          * @param filled {boolean}
            +120          * @deprecated
            +121          */
            +122         setFilled : function( filled ) {
            +123             return this;
            +124         },
            +125         /**
            +126          * Sets whether the star will be outlined.
            +127          * @param outlined {boolean}
            +128          * @deprecated
            +129          */
            +130         setOutlined : function( outlined ) {
            +131             return this;
            +132         },
            +133         /**
            +134          * Sets the composite operation to apply on shape drawing.
            +135          * @param compositeOp an string with a valid canvas rendering context string describing compositeOps.
            +136          * @return this
            +137          */
            +138         setCompositeOp : function(compositeOp){
            +139             this.compositeOp= compositeOp;
            +140             return this;
            +141         },
            +142         /**
            +143          * 
            +144          * @param angle {number} number in radians.
            +145          */
            +146         setInitialAngle : function(angle) {
            +147             this.initialAngle= angle;
            +148             return this;
            +149         },
            +150         /**
            +151          * Initialize the star values.
            +152          * <p>
            +153          * The star actor will be of size 2*maxRadius.
            +154          *
            +155          * @param nPeaks {number} number of star points.
            +156          * @param maxRadius {number} maximum star radius
            +157          * @param minRadius {number} minimum star radius
            +158          *
            +159          * @return this
            +160          */
            +161         initialize : function(nPeaks, maxRadius, minRadius) {
            +162             this.setSize( 2*maxRadius, 2*maxRadius );
            +163 
            +164             this.nPeaks= nPeaks;
            +165             this.maxRadius= maxRadius;
            +166             this.minRadius= minRadius;
            +167 
            +168             return this;
            +169         },
            +170         /**
            +171          * Paint the star.
            +172          *
            +173          * @param director {CAAT.Director}
            +174          * @param timer {number}
            +175          */
            +176         paint : function(director, timer) {
            +177 
            +178             var ctx=        director.ctx;
            +179             var centerX=    this.width/2;
            +180             var centerY=    this.height/2;
            +181             var r1=         this.maxRadius;
            +182             var r2=         this.minRadius;
            +183             var ix=         centerX + r1*Math.cos(this.initialAngle);
            +184             var iy=         centerY + r1*Math.sin(this.initialAngle);
            +185 
            +186             ctx.lineWidth= this.lineWidth;
            +187             if ( this.lineCap ) {
            +188                 ctx.lineCap= this.lineCap;
            +189             }
            +190             if ( this.lineJoin )    {
            +191                 ctx.lineJoin= this.lineJoin;
            +192             }
            +193             if ( this.miterLimit )  {
            +194                 ctx.miterLimit= this.miterLimit;
            +195             }
            +196 
            +197             ctx.globalCompositeOperation= this.compositeOp;
            +198 
            +199             ctx.beginPath();
            +200             ctx.moveTo(ix,iy);
            +201 
            +202             for( var i=1; i<this.nPeaks*2; i++ )   {
            +203                 var angleStar= Math.PI/this.nPeaks * i + this.initialAngle;
            +204                var rr= (i%2===0) ? r1 : r2;
            +205                 var x= centerX + rr*Math.cos(angleStar);
            +206                 var y= centerY + rr*Math.sin(angleStar);
            +207                 ctx.lineTo(x,y);
            +208             }
            +209 
            +210             ctx.lineTo(
            +211                 centerX + r1*Math.cos(this.initialAngle),
            +212                 centerY + r1*Math.sin(this.initialAngle) );
            +213 
            +214             ctx.closePath();
            +215             
            +216             if ( this.fillStyle ) {
            +217                 ctx.fillStyle= this.fillStyle;
            +218                 ctx.fill();
            +219             }
            +220 
            +221             if ( this.strokeStyle ) {
            +222                 ctx.strokeStyle= this.strokeStyle;
            +223                 ctx.stroke();
            +224             }
            +225 
            +226         }
            +227     }
            +228 
            +229 });
            +230 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_TextActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_TextActor.js.html new file mode 100644 index 0000000..54f2545 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Foundation_UI_TextActor.js.html @@ -0,0 +1,615 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TextActor
            +  5      * @memberOf CAAT.Foundation.UI
            +  6      * @extends CAAT.Foundation.Actor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Foundation.UI.TextActor",
            + 11     aliases : ["CAAT.TextActor"],
            + 12     extendsClass : "CAAT.Foundation.Actor",
            + 13     constants : {
            + 14         TRAVERSE_PATH_FORWARD: 1,
            + 15         TRAVERSE_PATH_BACKWARD: -1
            + 16     },
            + 17     depends : [
            + 18         "CAAT.Foundation.Actor",
            + 19         "CAAT.Foundation.SpriteImage",
            + 20         "CAAT.Module.Font.Font",
            + 21         "CAAT.Math.Point",
            + 22         "CAAT.Behavior.Interpolator"
            + 23     ],
            + 24     extendsWith : {
            + 25 
            + 26         /**
            + 27          * @lends CAAT.Foundation.UI.TextActor.prototype
            + 28          */
            + 29 
            + 30         __init : function() {
            + 31             this.__super();
            + 32             this.font= "10px sans-serif";
            + 33             this.textAlign= "left";
            + 34             this.outlineColor= "black";
            + 35             this.clip= false;
            + 36             this.__calcFontData();
            + 37 
            + 38             return this;
            + 39         },
            + 40 
            + 41         /**
            + 42          * a valid canvas rendering context font description. Default font will be "10px sans-serif".
            + 43          */
            + 44 		font:			    null,
            + 45 
            + 46         /**
            + 47          * Font info. Calculated in CAAT.
            + 48          */
            + 49         fontData:           null,
            + 50 
            + 51         /**
            + 52          * a valid canvas rendering context textAlign string. Any of:
            + 53          *   start, end, left, right, center.
            + 54          * defaults to "left".
            + 55          */
            + 56 		textAlign:		    null,
            + 57 
            + 58         /**
            + 59          * a valid canvas rendering context textBaseLine string. Any of:
            + 60          *   top, hanging, middle, alphabetic, ideographic, bottom.
            + 61          * defaults to "top".
            + 62          */
            + 63 		textBaseline:	    "top",
            + 64 
            + 65         /**
            + 66          * a boolean indicating whether the text should be filled.
            + 67          */
            + 68 		fill:			    true,
            + 69 
            + 70         /**
            + 71          * text fill color
            + 72          */
            + 73         textFillStyle   :   '#eee',
            + 74 
            + 75         /**
            + 76          * a string with the text to draw.
            + 77          */
            + 78 		text:			    null,
            + 79 
            + 80         /**
            + 81          * calculated text width in pixels.
            + 82          */
            + 83 		textWidth:		    0,
            + 84 
            + 85         /**
            + 86          * calculated text height in pixels.
            + 87          */
            + 88         textHeight:         0,
            + 89 
            + 90         /**
            + 91          * a boolean indicating whether the text should be outlined. not all browsers support it.
            + 92          */
            + 93 		outline:		    false,
            + 94 
            + 95         /**
            + 96          * a valid color description string.
            + 97          */
            + 98 		outlineColor:	    null,
            + 99 
            +100         /**
            +101          * text's stroke line width.
            +102          */
            +103         lineWidth:          1,
            +104 
            +105         /**
            +106          * a CAAT.PathUtil.Path which will be traversed by the text.
            +107          */
            +108 		path:			    null,
            +109 
            +110         /**
            +111          * A CAAT.Behavior.Interpolator to apply to the path traversal.
            +112          */
            +113         pathInterpolator:	null,
            +114 
            +115         /**
            +116          * time to be taken to traverse the path. ms.
            +117          */
            +118         pathDuration:       10000,
            +119 
            +120         /**
            +121          * traverse the path forward (1) or backwards (-1).
            +122          */
            +123 		sign:			    1,      //
            +124 
            +125         lx:                 0,
            +126         ly:                 0,
            +127 
            +128         /**
            +129          * Set the text to be filled. The default Filling style will be set by calling setFillStyle method.
            +130          * Default value is true.
            +131          * @param fill {boolean} a boolean indicating whether the text will be filled.
            +132          * @return this;
            +133          */
            +134         setFill : function( fill ) {
            +135             this.stopCacheAsBitmap();
            +136             this.fill= fill;
            +137             return this;
            +138         },
            +139         setLineWidth : function( lw ) {
            +140             this.stopCacheAsBitmap();
            +141             this.lineWidth= lw;
            +142             return this;
            +143         },
            +144         setTextFillStyle : function( style ) {
            +145             this.stopCacheAsBitmap();
            +146             this.textFillStyle= style;
            +147             return this;
            +148         },
            +149         /**
            +150          * Sets whether the text will be outlined.
            +151          * @param outline {boolean} a boolean indicating whether the text will be outlined.
            +152          * @return this;
            +153          */
            +154         setOutline : function( outline ) {
            +155             this.stopCacheAsBitmap();
            +156             this.outline= outline;
            +157             return this;
            +158         },
            +159         setPathTraverseDirection : function(direction) {
            +160             this.sign= direction;
            +161             return this;
            +162         },
            +163         /**
            +164          * Defines text's outline color.
            +165          *
            +166          * @param color {string} sets a valid canvas context color.
            +167          * @return this.
            +168          */
            +169         setOutlineColor : function( color ) {
            +170             this.stopCacheAsBitmap();
            +171             this.outlineColor= color;
            +172             return this;
            +173         },
            +174         /**
            +175          * Set the text to be shown by the actor.
            +176          * @param sText a string with the text to be shwon.
            +177          * @return this
            +178          */
            +179 		setText : function( sText ) {
            +180             this.stopCacheAsBitmap();
            +181 			this.text= sText;
            +182             if ( null===this.text || this.text==="" ) {
            +183                 this.width= this.height= 0;
            +184             }
            +185             this.calcTextSize( CAAT.currentDirector );
            +186 
            +187             this.invalidate();
            +188 
            +189             return this;
            +190         },
            +191         setTextAlign : function( align ) {
            +192             this.textAlign= align;
            +193             this.__setLocation();
            +194             return this;
            +195         },
            +196         /**
            +197          * Sets text alignment
            +198          * @param align
            +199          * @deprecated use setTextAlign
            +200          */
            +201         setAlign : function( align ) {
            +202             return this.setTextAlign(align);
            +203         },
            +204         /**
            +205          * Set text baseline.
            +206          * @param baseline
            +207          */
            +208         setTextBaseline : function( baseline ) {
            +209             this.stopCacheAsBitmap();
            +210             this.textBaseline= baseline;
            +211             return this;
            +212 
            +213         },
            +214         setBaseline : function( baseline ) {
            +215             this.stopCacheAsBitmap();
            +216             return this.setTextBaseline(baseline);
            +217         },
            +218         /**
            +219          * Sets the font to be applied for the text.
            +220          * @param font a string with a valid canvas rendering context font description.
            +221          * @return this
            +222          */
            +223         setFont : function(font) {
            +224 
            +225             this.stopCacheAsBitmap();
            +226 
            +227             if ( !font ) {
            +228                 font= "10px sans-serif";
            +229             }
            +230 
            +231             if ( font instanceof CAAT.Module.Font.Font ) {
            +232                 font.setAsSpriteImage();
            +233             } else if (font instanceof CAAT.Foundation.SpriteImage ) {
            +234                 //CAAT.log("WARN: setFont will no more accept a CAAT.SpriteImage as argument.");
            +235             }
            +236             this.font= font;
            +237 
            +238             this.__calcFontData();
            +239             this.calcTextSize( CAAT.director[0] );
            +240 
            +241             return this;
            +242 		},
            +243 
            +244         setLocation : function( x,y) {
            +245             this.lx= x;
            +246             this.ly= y;
            +247             this.__setLocation();
            +248             return this;
            +249         },
            +250 
            +251         setPosition : function( x,y ) {
            +252             this.lx= x;
            +253             this.ly= y;
            +254             this.__setLocation();
            +255             return this;
            +256         },
            +257 
            +258         setBounds : function( x,y,w,h ) {
            +259             this.lx= x;
            +260             this.ly= y;
            +261             this.setSize(w,h);
            +262             this.__setLocation();
            +263             return this;
            +264         },
            +265 
            +266         setSize : function( w, h ) {
            +267             CAAT.Foundation.UI.TextActor.superclass.setSize.call(this,w,h);
            +268             this.__setLocation();
            +269             return this;
            +270         },
            +271 
            +272         /**
            +273          * @private
            +274          */
            +275         __setLocation : function() {
            +276 
            +277             var nx, ny;
            +278 
            +279             if ( this.textAlign==="center" ) {
            +280                 nx= this.lx - this.width/2;
            +281             } else if ( this.textAlign==="right" || this.textAlign==="end" ) {
            +282                 nx= this.lx - this.width;
            +283             } else {
            +284                 nx= this.lx;
            +285             }
            +286 
            +287             if ( this.textBaseline==="bottom" ) {
            +288                 ny= this.ly - this.height;
            +289             } else if ( this.textBaseline==="middle" ) {
            +290                 ny= this.ly - this.height/2;
            +291             } else if ( this.textBaseline==="alphabetic" ) {
            +292                 ny= this.ly - this.fontData.ascent;
            +293             } else {
            +294                 ny= this.ly;
            +295             }
            +296 
            +297             CAAT.Foundation.UI.TextActor.superclass.setLocation.call( this, nx, ny );
            +298         },
            +299 
            +300         centerAt : function(x,y) {
            +301             this.textAlign="left";
            +302             this.textBaseline="top";
            +303             return CAAT.Foundation.UI.TextActor.superclass.centerAt.call( this, x, y );
            +304         },
            +305 
            +306         /**
            +307          * Calculates the text dimension in pixels and stores the values in textWidth and textHeight
            +308          * attributes.
            +309          * If Actor's width and height were not set, the Actor's dimension will be set to these values.
            +310          * @param director a CAAT.Director instance.
            +311          * @return this
            +312          */
            +313         calcTextSize : function(director) {
            +314 
            +315             if ( typeof this.text==='undefined' || null===this.text || ""===this.text ) {
            +316                 this.textWidth= 0;
            +317                 this.textHeight= 0;
            +318                 return this;
            +319             }
            +320 
            +321             if ( director.glEnabled ) {
            +322                 return this;
            +323             }
            +324 
            +325             if ( this.font instanceof CAAT.Foundation.SpriteImage ) {
            +326                 this.textWidth= this.font.stringWidth( this.text );
            +327                 this.textHeight=this.font.stringHeight();
            +328                 this.width= this.textWidth;
            +329                 this.height= this.textHeight;
            +330                 this.fontData= this.font.getFontData();
            +331 /*
            +332                 var as= (this.font.singleHeight *.8)>>0;
            +333                 this.fontData= {
            +334                     height : this.font.singleHeight,
            +335                     ascent : as,
            +336                     descent: this.font.singleHeight - as
            +337                 };
            +338 */
            +339                 return this;
            +340             }
            +341 
            +342             if ( this.font instanceof CAAT.Module.Font.Font ) {
            +343                 this.textWidth= this.font.stringWidth( this.text );
            +344                 this.textHeight=this.font.stringHeight();
            +345                 this.width= this.textWidth;
            +346                 this.height= this.textHeight;
            +347                 this.fontData= this.font.getFontData();
            +348                 return this;
            +349             }
            +350 
            +351             var ctx= director.ctx;
            +352 
            +353             ctx.save();
            +354             ctx.font= this.font;
            +355 
            +356             this.textWidth= ctx.measureText( this.text ).width;
            +357             if (this.width===0) {
            +358                 this.width= this.textWidth;
            +359             }
            +360 /*
            +361             var pos= this.font.indexOf("px");
            +362             if (-1===pos) {
            +363                 pos= this.font.indexOf("pt");
            +364             }
            +365             if ( -1===pos ) {
            +366                 // no pt or px, so guess a size: 32. why not ?
            +367                 this.textHeight= 32;
            +368             } else {
            +369                 var s =  this.font.substring(0, pos );
            +370                 this.textHeight= parseInt(s,10);
            +371             }
            +372 */
            +373 
            +374             this.textHeight= this.fontData.height;
            +375             this.setSize( this.textWidth, this.textHeight );
            +376 
            +377             ctx.restore();
            +378 
            +379             return this;
            +380         },
            +381 
            +382         __calcFontData : function() {
            +383             this.fontData= CAAT.Module.Font.Font.getFontMetrics( this.font );
            +384         },
            +385 
            +386         /**
            +387          * Custom paint method for TextActor instances.
            +388          * If the path attribute is set, the text will be drawn traversing the path.
            +389          *
            +390          * @param director a valid CAAT.Director instance.
            +391          * @param time an integer with the Scene time the Actor is being drawn.
            +392          */
            +393 		paint : function(director, time) {
            +394 
            +395             if (!this.text) {
            +396                 return;
            +397             }
            +398 
            +399             CAAT.Foundation.UI.TextActor.superclass.paint.call(this, director, time );
            +400 
            +401             if ( this.cached ) {
            +402                 // cacheAsBitmap sets this actor's background image as a representation of itself.
            +403                 // So if after drawing the background it was cached, we're done.
            +404                 return;
            +405             }
            +406 
            +407 			if ( null===this.text) {
            +408 				return;
            +409 			}
            +410 
            +411             if ( this.textWidth===0 || this.textHeight===0 ) {
            +412                 this.calcTextSize(director);
            +413             }
            +414 
            +415 			var ctx= director.ctx;
            +416 			
            +417 			if ( this.font instanceof CAAT.Module.Font.Font || this.font instanceof CAAT.Foundation.SpriteImage ) {
            +418 				this.drawSpriteText(director,time);
            +419                 return;
            +420 			}
            +421 
            +422 			if( null!==this.font ) {
            +423 				ctx.font= this.font;
            +424 			}
            +425 
            +426             /**
            +427              * always draw text with middle or bottom, top is buggy in FF.
            +428              * @type {String}
            +429              */
            +430             ctx.textBaseline="alphabetic";
            +431 
            +432 			if (null===this.path) {
            +433 
            +434                 if ( null!==this.textAlign ) {
            +435                     ctx.textAlign= this.textAlign;
            +436                 }
            +437 
            +438                 var tx=0;
            +439                 if ( this.textAlign==='center') {
            +440                     tx= (this.width/2)|0;
            +441                 } else if ( this.textAlign==='right' ) {
            +442                     tx= this.width;
            +443                 }
            +444 
            +445 				if ( this.fill ) {
            +446                     if ( null!==this.textFillStyle ) {
            +447                         ctx.fillStyle= this.textFillStyle;
            +448                     }
            +449 					ctx.fillText( this.text, tx, this.fontData.ascent  );
            +450 				}
            +451 
            +452                 if ( this.outline ) {
            +453                     if (null!==this.outlineColor ) {
            +454                         ctx.strokeStyle= this.outlineColor;
            +455                     }
            +456 
            +457                     ctx.lineWidth= this.lineWidth;
            +458                     ctx.beginPath();
            +459 					ctx.strokeText( this.text, tx, this.fontData.ascent );
            +460 				}
            +461 			}
            +462 			else {
            +463 				this.drawOnPath(director,time);
            +464 			}
            +465 		},
            +466         /**
            +467          * Private.
            +468          * Draw the text traversing a path.
            +469          * @param director a valid CAAT.Director instance.
            +470          * @param time an integer with the Scene time the Actor is being drawn.
            +471          */
            +472 		drawOnPath : function(director, time) {
            +473 
            +474 			var ctx= director.ctx;
            +475 
            +476             if ( this.fill && null!==this.textFillStyle ) {
            +477                 ctx.fillStyle= this.textFillStyle;
            +478             }
            +479 
            +480             if ( this.outline && null!==this.outlineColor ) {
            +481                 ctx.strokeStyle= this.outlineColor;
            +482             }
            +483 
            +484 			var textWidth=this.sign * this.pathInterpolator.getPosition(
            +485                     (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ;
            +486 			var p0= new CAAT.Math.Point(0,0,0);
            +487 			var p1= new CAAT.Math.Point(0,0,0);
            +488 
            +489 			for( var i=0; i<this.text.length; i++ ) {
            +490 				var caracter= this.text[i].toString();
            +491 				var charWidth= ctx.measureText( caracter ).width;
            +492 
            +493                 // guonjien: remove "+charWidth/2" since it destroys the kerning. and he's right!!!. thanks.
            +494 				var currentCurveLength= textWidth;
            +495 
            +496 				p0= this.path.getPositionFromLength(currentCurveLength).clone();
            +497 				p1= this.path.getPositionFromLength(currentCurveLength-0.1).clone();
            +498 
            +499 				var angle= Math.atan2( p0.y-p1.y, p0.x-p1.x );
            +500 
            +501 				ctx.save();
            +502 
            +503                     if ( CAAT.CLAMP ) {
            +504 					    ctx.translate( p0.x>>0, p0.y>>0 );
            +505                     } else {
            +506                         ctx.translate( p0.x, p0.y );
            +507                     }
            +508 					ctx.rotate( angle );
            +509                     if ( this.fill ) {
            +510 					    ctx.fillText(caracter,0,0);
            +511                     }
            +512                     if ( this.outline ) {
            +513                         ctx.beginPath();
            +514                         ctx.lineWidth= this.lineWidth;
            +515                         ctx.strokeText(caracter,0,0);
            +516                     }
            +517 
            +518 				ctx.restore();
            +519 
            +520 				textWidth+= charWidth;
            +521 			}
            +522 		},
            +523 		
            +524 		/**
            +525          * Private.
            +526          * Draw the text using a sprited font instead of a canvas font.
            +527          * @param director a valid CAAT.Director instance.
            +528          * @param time an integer with the Scene time the Actor is being drawn.
            +529          */
            +530 		drawSpriteText: function(director, time) {
            +531 			if (null===this.path) {
            +532 				this.font.drawText( this.text, director.ctx, 0, 0);
            +533 			} else {
            +534 				this.drawSpriteTextOnPath(director, time);
            +535 			}
            +536 		},
            +537 		
            +538 		/**
            +539          * Private.
            +540          * Draw the text traversing a path using a sprited font.
            +541          * @param director a valid CAAT.Director instance.
            +542          * @param time an integer with the Scene time the Actor is being drawn.
            +543          */
            +544 		drawSpriteTextOnPath: function(director, time) {
            +545 			var context= director.ctx;
            +546 
            +547 			var textWidth=this.sign * this.pathInterpolator.getPosition(
            +548                     (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ;
            +549 			var p0= new CAAT.Math.Point(0,0,0);
            +550 			var p1= new CAAT.Math.Point(0,0,0);
            +551 
            +552 			for( var i=0; i<this.text.length; i++ ) {
            +553 				var character= this.text[i].toString();
            +554 				var charWidth= this.font.stringWidth(character);
            +555 
            +556 				//var pathLength= this.path.getLength();
            +557 
            +558 				var currentCurveLength= charWidth/2 + textWidth;
            +559 
            +560 				p0= this.path.getPositionFromLength(currentCurveLength).clone();
            +561 				p1= this.path.getPositionFromLength(currentCurveLength-0.1).clone();
            +562 
            +563 				var angle= Math.atan2( p0.y-p1.y, p0.x-p1.x );
            +564 
            +565 				context.save();
            +566 
            +567                 if ( CAAT.CLAMP ) {
            +568 				    context.translate( p0.x|0, p0.y|0 );
            +569                 } else {
            +570                     context.translate( p0.x, p0.y );
            +571                 }
            +572 				context.rotate( angle );
            +573 				
            +574 				var y = this.textBaseline === "bottom" ? 0 - this.font.getHeight() : 0;
            +575 				
            +576 				this.font.drawText(character, context, 0, y);
            +577 
            +578 				context.restore();
            +579 
            +580 				textWidth+= charWidth;
            +581 			}
            +582 		},
            +583 		
            +584         /**
            +585          * Set the path, interpolator and duration to draw the text on.
            +586          * @param path a valid CAAT.Path instance.
            +587          * @param interpolator a CAAT.Interpolator object. If not set, a Linear Interpolator will be used.
            +588          * @param duration an integer indicating the time to take to traverse the path. Optional. 10000 ms
            +589          * by default.
            +590          */
            +591 		setPath : function( path, interpolator, duration ) {
            +592 			this.path= path;
            +593             this.pathInterpolator= interpolator || new CAAT.Behavior.Interpolator().createLinearInterpolator();
            +594             this.pathDuration= duration || 10000;
            +595 
            +596             /*
            +597                 parent could not be set by the time this method is called.
            +598                 so the actors bounds set is removed.
            +599                 the developer must ensure to call setbounds properly on actor.
            +600              */
            +601 			this.mouseEnabled= false;
            +602 
            +603             return this;
            +604 		}
            +605 	}
            +606 
            +607 });
            +608 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_CatmullRom.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_CatmullRom.js.html new file mode 100644 index 0000000..ff8bb30 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_CatmullRom.js.html @@ -0,0 +1,130 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name CatmullRom
            +  5      * @memberOf CAAT.Math
            +  6      * @extends CAAT.Math.Curve
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.Math.CatmullRom",
            + 11     depends:["CAAT.Math.Curve"],
            + 12     extendsClass:"CAAT.Math.Curve",
            + 13     aliases:["CAAT.CatmullRom"],
            + 14     extendsWith:function () {
            + 15         return {
            + 16 
            + 17             /**
            + 18              * @lends CAAT.Math.CatmullRom.prototype
            + 19              */
            + 20 
            + 21             /**
            + 22              * Set curve control points.
            + 23              * @param p0 <CAAT.Point>
            + 24              * @param p1 <CAAT.Point>
            + 25              * @param p2 <CAAT.Point>
            + 26              * @param p3 <CAAT.Point>
            + 27              */
            + 28             setCurve:function (p0, p1, p2, p3) {
            + 29 
            + 30                 this.coordlist = [];
            + 31                 this.coordlist.push(p0);
            + 32                 this.coordlist.push(p1);
            + 33                 this.coordlist.push(p2);
            + 34                 this.coordlist.push(p3);
            + 35 
            + 36                 this.update();
            + 37 
            + 38                 return this;
            + 39             },
            + 40             /**
            + 41              * Paint the contour by solving again the entire curve.
            + 42              * @param director {CAAT.Director}
            + 43              */
            + 44             paint:function (director) {
            + 45 
            + 46                 var x1, y1;
            + 47 
            + 48                 // Catmull rom solves from point 1 !!!
            + 49 
            + 50                 x1 = this.coordlist[1].x;
            + 51                 y1 = this.coordlist[1].y;
            + 52 
            + 53                 var ctx = director.ctx;
            + 54 
            + 55                 ctx.save();
            + 56                 ctx.beginPath();
            + 57                 ctx.moveTo(x1, y1);
            + 58 
            + 59                 var point = new CAAT.Point();
            + 60 
            + 61                 for (var t = this.k; t <= 1 + this.k; t += this.k) {
            + 62                     this.solve(point, t);
            + 63                     ctx.lineTo(point.x, point.y);
            + 64                 }
            + 65 
            + 66                 ctx.stroke();
            + 67                 ctx.restore();
            + 68 
            + 69                 CAAT.Math.CatmullRom.superclass.paint.call(this, director);
            + 70             },
            + 71             /**
            + 72              * Solves the curve for any given parameter t.
            + 73              * @param point {CAAT.Point} the point to store the solved value on the curve.
            + 74              * @param t {number} a number in the range 0..1
            + 75              */
            + 76             solve:function (point, t) {
            + 77                 var c = this.coordlist;
            + 78 
            + 79                 // Handy from CAKE. Thanks.
            + 80                 var af = ((-t + 2) * t - 1) * t * 0.5
            + 81                 var bf = (((3 * t - 5) * t) * t + 2) * 0.5
            + 82                 var cf = ((-3 * t + 4) * t + 1) * t * 0.5
            + 83                 var df = ((t - 1) * t * t) * 0.5
            + 84 
            + 85                 point.x = c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df;
            + 86                 point.y = c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df;
            + 87 
            + 88                 return point;
            + 89 
            + 90             },
            + 91 
            + 92             applyAsPath:function (director) {
            + 93 
            + 94                 var ctx = director.ctx;
            + 95 
            + 96                 var point = new CAAT.Math.Point();
            + 97 
            + 98                 for (var t = this.k; t <= 1 + this.k; t += this.k) {
            + 99                     this.solve(point, t);
            +100                     ctx.lineTo(point.x, point.y);
            +101                 }
            +102 
            +103                 return this;
            +104             },
            +105 
            +106             /**
            +107              * Return the first curve control point.
            +108              * @return {CAAT.Point}
            +109              */
            +110             endCurvePosition:function () {
            +111                 return this.coordlist[ this.coordlist.length - 2 ];
            +112             },
            +113             /**
            +114              * Return the last curve control point.
            +115              * @return {CAAT.Point}
            +116              */
            +117             startCurvePosition:function () {
            +118                 return this.coordlist[ 1 ];
            +119             }
            +120         }
            +121     }
            +122 });
            +123 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Curve.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Curve.js.html new file mode 100644 index 0000000..ace184d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Curve.js.html @@ -0,0 +1,210 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8     /**
            +  9      * @name Curve
            + 10      * @memberOf CAAT.Math
            + 11      * @constructor
            + 12      */
            + 13 
            + 14     defines:"CAAT.Math.Curve",
            + 15     depends:["CAAT.Math.Point"],
            + 16     extendsWith:function () {
            + 17 
            + 18         return {
            + 19 
            + 20             /**
            + 21              * @lends CAAT.Math.Curve.prototype
            + 22              */
            + 23 
            + 24             /**
            + 25              * A collection of CAAT.Math.Point objects.
            + 26              */
            + 27             coordlist:null,
            + 28 
            + 29             /**
            + 30              * Minimun solver step.
            + 31              */
            + 32             k:0.05,
            + 33 
            + 34             /**
            + 35              * Curve length.
            + 36              */
            + 37             length:-1,
            + 38 
            + 39             /**
            + 40              * If this segments belongs to an interactive path, the handlers will be this size.
            + 41              */
            + 42             HANDLE_SIZE:20,
            + 43 
            + 44             /**
            + 45              * Draw interactive handlers ?
            + 46              */
            + 47             drawHandles:true,
            + 48 
            + 49             /**
            + 50              * Paint the curve control points.
            + 51              * @param director {CAAT.Director}
            + 52              */
            + 53             paint:function (director) {
            + 54                 if (false === this.drawHandles) {
            + 55                     return;
            + 56                 }
            + 57 
            + 58                 var cl = this.coordlist;
            + 59                 var ctx = director.ctx;
            + 60 
            + 61                 // control points
            + 62                 ctx.save();
            + 63                 ctx.beginPath();
            + 64 
            + 65                 ctx.strokeStyle = '#a0a0a0';
            + 66                 ctx.moveTo(cl[0].x, cl[0].y);
            + 67                 ctx.lineTo(cl[1].x, cl[1].y);
            + 68                 ctx.stroke();
            + 69                 if (this.cubic) {
            + 70                     ctx.moveTo(cl[2].x, cl[2].y);
            + 71                     ctx.lineTo(cl[3].x, cl[3].y);
            + 72                     ctx.stroke();
            + 73                 }
            + 74 
            + 75 
            + 76                 ctx.globalAlpha = 0.5;
            + 77                 for (var i = 0; i < this.coordlist.length; i++) {
            + 78                     ctx.fillStyle = '#7f7f00';
            + 79                     var w = this.HANDLE_SIZE / 2;
            + 80                     ctx.beginPath();
            + 81                     ctx.arc(cl[i].x, cl[i].y, w, 0, 2 * Math.PI, false);
            + 82                     ctx.fill();
            + 83                 }
            + 84 
            + 85                 ctx.restore();
            + 86             },
            + 87             /**
            + 88              * Signal the curve has been modified and recalculate curve length.
            + 89              */
            + 90             update:function () {
            + 91                 this.calcLength();
            + 92             },
            + 93             /**
            + 94              * This method must be overriden by subclasses. It is called whenever the curve must be solved for some time=t.
            + 95              * The t parameter must be in the range 0..1
            + 96              * @param point {CAAT.Point} to store curve solution for t.
            + 97              * @param t {number}
            + 98              * @return {CAAT.Point} the point parameter.
            + 99              */
            +100             solve:function (point, t) {
            +101             },
            +102             /**
            +103              * Get an array of points defining the curve contour.
            +104              * @param numSamples {number} number of segments to get.
            +105              */
            +106             getContour:function (numSamples) {
            +107                 var contour = [], i;
            +108 
            +109                 for (i = 0; i <= numSamples; i++) {
            +110                     var point = new CAAT.Math.Point();
            +111                     this.solve(point, i / numSamples);
            +112                     contour.push(point);
            +113                 }
            +114 
            +115                 return contour;
            +116             },
            +117             /**
            +118              * Calculates a curve bounding box.
            +119              *
            +120              * @param rectangle {CAAT.Rectangle} a rectangle to hold the bounding box.
            +121              * @return {CAAT.Rectangle} the rectangle parameter.
            +122              */
            +123             getBoundingBox:function (rectangle) {
            +124                 if (!rectangle) {
            +125                     rectangle = new CAAT.Math.Rectangle();
            +126                 }
            +127 
            +128                 // thanks yodesoft.com for spotting the first point is out of the BB
            +129                 rectangle.setEmpty();
            +130                 rectangle.union(this.coordlist[0].x, this.coordlist[0].y);
            +131 
            +132                 var pt = new CAAT.Math.Point();
            +133                 for (var t = this.k; t <= 1 + this.k; t += this.k) {
            +134                     this.solve(pt, t);
            +135                     rectangle.union(pt.x, pt.y);
            +136                 }
            +137 
            +138                 return rectangle;
            +139             },
            +140             /**
            +141              * Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k. This value defaults
            +142              * to .05 so at least 20 iterations will be performed.
            +143              *
            +144              * @return {number} the approximate curve length.
            +145              */
            +146             calcLength:function () {
            +147                 var x1, y1;
            +148                 x1 = this.coordlist[0].x;
            +149                 y1 = this.coordlist[0].y;
            +150                 var llength = 0;
            +151                 var pt = new CAAT.Math.Point();
            +152                 for (var t = this.k; t <= 1 + this.k; t += this.k) {
            +153                     this.solve(pt, t);
            +154                     llength += Math.sqrt((pt.x - x1) * (pt.x - x1) + (pt.y - y1) * (pt.y - y1));
            +155                     x1 = pt.x;
            +156                     y1 = pt.y;
            +157                 }
            +158 
            +159                 this.length = llength;
            +160                 return llength;
            +161             },
            +162             /**
            +163              * Return the cached curve length.
            +164              * @return {number} the cached curve length.
            +165              */
            +166             getLength:function () {
            +167                 return this.length;
            +168             },
            +169             /**
            +170              * Return the first curve control point.
            +171              * @return {CAAT.Point}
            +172              */
            +173             endCurvePosition:function () {
            +174                 return this.coordlist[ this.coordlist.length - 1 ];
            +175             },
            +176             /**
            +177              * Return the last curve control point.
            +178              * @return {CAAT.Point}
            +179              */
            +180             startCurvePosition:function () {
            +181                 return this.coordlist[ 0 ];
            +182             },
            +183 
            +184             setPoints:function (points) {
            +185             },
            +186 
            +187             setPoint:function (point, index) {
            +188                 if (index >= 0 && index < this.coordlist.length) {
            +189                     this.coordlist[index] = point;
            +190                 }
            +191             },
            +192             /**
            +193              *
            +194              * @param director <=CAAT.Director>
            +195              */
            +196             applyAsPath:function (director) {
            +197             }
            +198         }
            +199     }
            +200 
            +201 });
            +202 
            +203 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix.js.html new file mode 100644 index 0000000..d49e821 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix.js.html @@ -0,0 +1,431 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 
            +  7 CAAT.Module({
            +  8 
            +  9     /**
            + 10      * @name Matrix
            + 11      * @memberOf CAAT.Math
            + 12      * @constructor
            + 13      */
            + 14 
            + 15 
            + 16     defines:"CAAT.Math.Matrix",
            + 17     depends:["CAAT.Math.Point"],
            + 18     aliases:["CAAT.Matrix"],
            + 19     onCreate : function() {
            + 20         CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Math.Matrix.prototype.transformRenderingContext_NoClamp;
            + 21         CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Math.Matrix.prototype.transformRenderingContextSet_NoClamp;
            + 22     },
            + 23     constants : {
            + 24 
            + 25         /**
            + 26          * @lends CAAT.Math.Matrix.prototype
            + 27          */
            + 28 
            + 29         setCoordinateClamping : function( clamp ) {
            + 30             if ( clamp ) {
            + 31                 CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp;
            + 32                 CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp;
            + 33                 CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp;
            + 34                 CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp;
            + 35             } else {
            + 36                 CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp;
            + 37                 CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp;
            + 38                 CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp;
            + 39                 CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp;
            + 40             }
            + 41         },
            + 42         /**
            + 43          * Create a scale matrix.
            + 44          * @param scalex {number} x scale magnitude.
            + 45          * @param scaley {number} y scale magnitude.
            + 46          *
            + 47          * @return {CAAT.Matrix} a matrix object.
            + 48          *
            + 49          * @static
            + 50          */
            + 51         scale:function (scalex, scaley) {
            + 52             var m = new CAAT.Math.Matrix();
            + 53 
            + 54             m.matrix[0] = scalex;
            + 55             m.matrix[4] = scaley;
            + 56 
            + 57             return m;
            + 58         },
            + 59         /**
            + 60          * Create a new rotation matrix and set it up for the specified angle in radians.
            + 61          * @param angle {number}
            + 62          * @return {CAAT.Matrix} a matrix object.
            + 63          *
            + 64          * @static
            + 65          */
            + 66         rotate:function (angle) {
            + 67             var m = new CAAT.Math.Matrix();
            + 68             m.setRotation(angle);
            + 69             return m;
            + 70         },
            + 71         /**
            + 72          * Create a translation matrix.
            + 73          * @param x {number} x translation magnitude.
            + 74          * @param y {number} y translation magnitude.
            + 75          *
            + 76          * @return {CAAT.Matrix} a matrix object.
            + 77          * @static
            + 78          *
            + 79          */
            + 80         translate:function (x, y) {
            + 81             var m = new CAAT.Math.Matrix();
            + 82 
            + 83             m.matrix[2] = x;
            + 84             m.matrix[5] = y;
            + 85 
            + 86             return m;
            + 87         }
            + 88     },
            + 89     extendsWith:function () {
            + 90         return {
            + 91 
            + 92             /**
            + 93              * @lends CAAT.Math.Matrix.prototype
            + 94              */
            + 95 
            + 96             /**
            + 97              * An array of 9 numbers.
            + 98              */
            + 99             matrix:null,
            +100 
            +101             __init:function () {
            +102                 this.matrix = [
            +103                     1.0, 0.0, 0.0,
            +104                     0.0, 1.0, 0.0, 0.0, 0.0, 1.0 ];
            +105 
            +106                 if (typeof Float32Array !== "undefined") {
            +107                     this.matrix = new Float32Array(this.matrix);
            +108                 }
            +109 
            +110                 return this;
            +111             },
            +112 
            +113             /**
            +114              * Transform a point by this matrix. The parameter point will be modified with the transformation values.
            +115              * @param point {CAAT.Point}.
            +116              * @return {CAAT.Point} the parameter point.
            +117              */
            +118             transformCoord:function (point) {
            +119                 var x = point.x;
            +120                 var y = point.y;
            +121 
            +122                 var tm = this.matrix;
            +123 
            +124                 point.x = x * tm[0] + y * tm[1] + tm[2];
            +125                 point.y = x * tm[3] + y * tm[4] + tm[5];
            +126 
            +127                 return point;
            +128             },
            +129 
            +130             setRotation:function (angle) {
            +131 
            +132                 this.identity();
            +133 
            +134                 var tm = this.matrix;
            +135                 var c = Math.cos(angle);
            +136                 var s = Math.sin(angle);
            +137                 tm[0] = c;
            +138                 tm[1] = -s;
            +139                 tm[3] = s;
            +140                 tm[4] = c;
            +141 
            +142                 return this;
            +143             },
            +144 
            +145             setScale:function (scalex, scaley) {
            +146                 this.identity();
            +147 
            +148                 this.matrix[0] = scalex;
            +149                 this.matrix[4] = scaley;
            +150 
            +151                 return this;
            +152             },
            +153 
            +154             /**
            +155              * Sets this matrix as a translation matrix.
            +156              * @param x
            +157              * @param y
            +158              */
            +159             setTranslate:function (x, y) {
            +160                 this.identity();
            +161 
            +162                 this.matrix[2] = x;
            +163                 this.matrix[5] = y;
            +164 
            +165                 return this;
            +166             },
            +167             /**
            +168              * Copy into this matrix the given matrix values.
            +169              * @param matrix {CAAT.Matrix}
            +170              * @return this
            +171              */
            +172             copy:function (matrix) {
            +173                 matrix = matrix.matrix;
            +174 
            +175                 var tmatrix = this.matrix;
            +176                 tmatrix[0] = matrix[0];
            +177                 tmatrix[1] = matrix[1];
            +178                 tmatrix[2] = matrix[2];
            +179                 tmatrix[3] = matrix[3];
            +180                 tmatrix[4] = matrix[4];
            +181                 tmatrix[5] = matrix[5];
            +182                 tmatrix[6] = matrix[6];
            +183                 tmatrix[7] = matrix[7];
            +184                 tmatrix[8] = matrix[8];
            +185 
            +186                 return this;
            +187             },
            +188             /**
            +189              * Set this matrix to the identity matrix.
            +190              * @return this
            +191              */
            +192             identity:function () {
            +193 
            +194                 var m = this.matrix;
            +195                 m[0] = 1.0;
            +196                 m[1] = 0.0;
            +197                 m[2] = 0.0;
            +198 
            +199                 m[3] = 0.0;
            +200                 m[4] = 1.0;
            +201                 m[5] = 0.0;
            +202 
            +203                 m[6] = 0.0;
            +204                 m[7] = 0.0;
            +205                 m[8] = 1.0;
            +206 
            +207                 return this;
            +208             },
            +209             /**
            +210              * Multiply this matrix by a given matrix.
            +211              * @param m {CAAT.Matrix}
            +212              * @return this
            +213              */
            +214             multiply:function (m) {
            +215 
            +216                 var tm = this.matrix;
            +217                 var mm = m.matrix;
            +218 
            +219                 var tm0 = tm[0];
            +220                 var tm1 = tm[1];
            +221                 var tm2 = tm[2];
            +222                 var tm3 = tm[3];
            +223                 var tm4 = tm[4];
            +224                 var tm5 = tm[5];
            +225                 var tm6 = tm[6];
            +226                 var tm7 = tm[7];
            +227                 var tm8 = tm[8];
            +228 
            +229                 var mm0 = mm[0];
            +230                 var mm1 = mm[1];
            +231                 var mm2 = mm[2];
            +232                 var mm3 = mm[3];
            +233                 var mm4 = mm[4];
            +234                 var mm5 = mm[5];
            +235                 var mm6 = mm[6];
            +236                 var mm7 = mm[7];
            +237                 var mm8 = mm[8];
            +238 
            +239                 tm[0] = tm0 * mm0 + tm1 * mm3 + tm2 * mm6;
            +240                 tm[1] = tm0 * mm1 + tm1 * mm4 + tm2 * mm7;
            +241                 tm[2] = tm0 * mm2 + tm1 * mm5 + tm2 * mm8;
            +242                 tm[3] = tm3 * mm0 + tm4 * mm3 + tm5 * mm6;
            +243                 tm[4] = tm3 * mm1 + tm4 * mm4 + tm5 * mm7;
            +244                 tm[5] = tm3 * mm2 + tm4 * mm5 + tm5 * mm8;
            +245                 tm[6] = tm6 * mm0 + tm7 * mm3 + tm8 * mm6;
            +246                 tm[7] = tm6 * mm1 + tm7 * mm4 + tm8 * mm7;
            +247                 tm[8] = tm6 * mm2 + tm7 * mm5 + tm8 * mm8;
            +248 
            +249                 return this;
            +250             },
            +251             /**
            +252              * Premultiply this matrix by a given matrix.
            +253              * @param m {CAAT.Matrix}
            +254              * @return this
            +255              */
            +256             premultiply:function (m) {
            +257 
            +258                 var m00 = m.matrix[0] * this.matrix[0] + m.matrix[1] * this.matrix[3] + m.matrix[2] * this.matrix[6];
            +259                 var m01 = m.matrix[0] * this.matrix[1] + m.matrix[1] * this.matrix[4] + m.matrix[2] * this.matrix[7];
            +260                 var m02 = m.matrix[0] * this.matrix[2] + m.matrix[1] * this.matrix[5] + m.matrix[2] * this.matrix[8];
            +261 
            +262                 var m10 = m.matrix[3] * this.matrix[0] + m.matrix[4] * this.matrix[3] + m.matrix[5] * this.matrix[6];
            +263                 var m11 = m.matrix[3] * this.matrix[1] + m.matrix[4] * this.matrix[4] + m.matrix[5] * this.matrix[7];
            +264                 var m12 = m.matrix[3] * this.matrix[2] + m.matrix[4] * this.matrix[5] + m.matrix[5] * this.matrix[8];
            +265 
            +266                 var m20 = m.matrix[6] * this.matrix[0] + m.matrix[7] * this.matrix[3] + m.matrix[8] * this.matrix[6];
            +267                 var m21 = m.matrix[6] * this.matrix[1] + m.matrix[7] * this.matrix[4] + m.matrix[8] * this.matrix[7];
            +268                 var m22 = m.matrix[6] * this.matrix[2] + m.matrix[7] * this.matrix[5] + m.matrix[8] * this.matrix[8];
            +269 
            +270                 this.matrix[0] = m00;
            +271                 this.matrix[1] = m01;
            +272                 this.matrix[2] = m02;
            +273 
            +274                 this.matrix[3] = m10;
            +275                 this.matrix[4] = m11;
            +276                 this.matrix[5] = m12;
            +277 
            +278                 this.matrix[6] = m20;
            +279                 this.matrix[7] = m21;
            +280                 this.matrix[8] = m22;
            +281 
            +282 
            +283                 return this;
            +284             },
            +285             /**
            +286              * Creates a new inverse matrix from this matrix.
            +287              * @return {CAAT.Matrix} an inverse matrix.
            +288              */
            +289             getInverse:function () {
            +290                 var tm = this.matrix;
            +291 
            +292                 var m00 = tm[0];
            +293                 var m01 = tm[1];
            +294                 var m02 = tm[2];
            +295                 var m10 = tm[3];
            +296                 var m11 = tm[4];
            +297                 var m12 = tm[5];
            +298                 var m20 = tm[6];
            +299                 var m21 = tm[7];
            +300                 var m22 = tm[8];
            +301 
            +302                 var newMatrix = new CAAT.Math.Matrix();
            +303 
            +304                 var determinant = m00 * (m11 * m22 - m21 * m12) - m10 * (m01 * m22 - m21 * m02) + m20 * (m01 * m12 - m11 * m02);
            +305                 if (determinant === 0) {
            +306                     return null;
            +307                 }
            +308 
            +309                 var m = newMatrix.matrix;
            +310 
            +311                 m[0] = m11 * m22 - m12 * m21;
            +312                 m[1] = m02 * m21 - m01 * m22;
            +313                 m[2] = m01 * m12 - m02 * m11;
            +314 
            +315                 m[3] = m12 * m20 - m10 * m22;
            +316                 m[4] = m00 * m22 - m02 * m20;
            +317                 m[5] = m02 * m10 - m00 * m12;
            +318 
            +319                 m[6] = m10 * m21 - m11 * m20;
            +320                 m[7] = m01 * m20 - m00 * m21;
            +321                 m[8] = m00 * m11 - m01 * m10;
            +322 
            +323                 newMatrix.multiplyScalar(1 / determinant);
            +324 
            +325                 return newMatrix;
            +326             },
            +327             /**
            +328              * Multiply this matrix by a scalar.
            +329              * @param scalar {number} scalar value
            +330              *
            +331              * @return this
            +332              */
            +333             multiplyScalar:function (scalar) {
            +334                 var i;
            +335 
            +336                 for (i = 0; i < 9; i++) {
            +337                     this.matrix[i] *= scalar;
            +338                 }
            +339 
            +340                 return this;
            +341             },
            +342 
            +343             /**
            +344              *
            +345              * @param ctx
            +346              */
            +347             transformRenderingContextSet_NoClamp:function (ctx) {
            +348                 var m = this.matrix;
            +349                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5]);
            +350                 return this;
            +351             },
            +352 
            +353             /**
            +354              *
            +355              * @param ctx
            +356              */
            +357             transformRenderingContext_NoClamp:function (ctx) {
            +358                 var m = this.matrix;
            +359                 ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]);
            +360                 return this;
            +361             },
            +362 
            +363             /**
            +364              *
            +365              * @param ctx
            +366              */
            +367             transformRenderingContextSet_Clamp:function (ctx) {
            +368                 var m = this.matrix;
            +369                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0);
            +370                 return this;
            +371             },
            +372 
            +373             /**
            +374              *
            +375              * @param ctx
            +376              */
            +377             transformRenderingContext_Clamp:function (ctx) {
            +378                 var m = this.matrix;
            +379                 ctx.transform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0);
            +380                 return this;
            +381             },
            +382 
            +383             setModelViewMatrix:function ( x, y, sx, sy, r  ) {
            +384                 var c, s, _m00, _m01, _m10, _m11;
            +385                 var mm0, mm1, mm2, mm3, mm4, mm5;
            +386                 var mm;
            +387 
            +388                 mm = this.matrix;
            +389 
            +390                 mm0 = 1;
            +391                 mm1 = 0;
            +392                 mm3 = 0;
            +393                 mm4 = 1;
            +394 
            +395                 mm2 = x;
            +396                 mm5 = y;
            +397 
            +398                 c = Math.cos(r);
            +399                 s = Math.sin(r);
            +400                 _m00 = mm0;
            +401                 _m01 = mm1;
            +402                 _m10 = mm3;
            +403                 _m11 = mm4;
            +404                 mm0 = _m00 * c + _m01 * s;
            +405                 mm1 = -_m00 * s + _m01 * c;
            +406                 mm3 = _m10 * c + _m11 * s;
            +407                 mm4 = -_m10 * s + _m11 * c;
            +408 
            +409                 mm0 = mm0 * this.scaleX;
            +410                 mm1 = mm1 * this.scaleY;
            +411                 mm3 = mm3 * this.scaleX;
            +412                 mm4 = mm4 * this.scaleY;
            +413 
            +414                 mm[0] = mm0;
            +415                 mm[1] = mm1;
            +416                 mm[2] = mm2;
            +417                 mm[3] = mm3;
            +418                 mm[4] = mm4;
            +419                 mm[5] = mm5;
            +420             }
            +421         }
            +422     }
            +423 });
            +424 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix3.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix3.js.html new file mode 100644 index 0000000..a066b4f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Matrix3.js.html @@ -0,0 +1,553 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8     /**
            +  9      * @name Matrix3
            + 10      * @memberOf CAAT.Math
            + 11      * @constructor
            + 12      */
            + 13 
            + 14     defines:"CAAT.Math.Matrix3",
            + 15     aliases:["CAAT.Matrix3"],
            + 16     extendsWith:function () {
            + 17         return {
            + 18 
            + 19             /**
            + 20              * @lends CAAT.Math.Matrix3.prototype
            + 21              */
            + 22 
            + 23             /**
            + 24              * An Array of 4 Array of 4 numbers.
            + 25              */
            + 26             matrix:null,
            + 27 
            + 28             /**
            + 29              * An array of 16 numbers.
            + 30              */
            + 31             fmatrix:null,
            + 32 
            + 33             __init:function () {
            + 34                 this.matrix = [
            + 35                     [1, 0, 0, 0],
            + 36                     [0, 1, 0, 0],
            + 37                     [0, 0, 1, 0],
            + 38                     [0, 0, 0, 1]
            + 39                 ];
            + 40 
            + 41                 this.fmatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
            + 42 
            + 43                 return this;
            + 44             },
            + 45 
            + 46             transformCoord:function (point) {
            + 47                 var x = point.x;
            + 48                 var y = point.y;
            + 49                 var z = point.z;
            + 50 
            + 51                 point.x = x * this.matrix[0][0] + y * this.matrix[0][1] + z * this.matrix[0][2] + this.matrix[0][3];
            + 52                 point.y = x * this.matrix[1][0] + y * this.matrix[1][1] + z * this.matrix[1][2] + this.matrix[1][3];
            + 53                 point.z = x * this.matrix[2][0] + y * this.matrix[2][1] + z * this.matrix[2][2] + this.matrix[2][3];
            + 54 
            + 55                 return point;
            + 56             },
            + 57             initialize:function (x0, y0, z0, x1, y1, z1, x2, y2, z2) {
            + 58                 this.identity();
            + 59                 this.matrix[0][0] = x0;
            + 60                 this.matrix[0][1] = y0;
            + 61                 this.matrix[0][2] = z0;
            + 62 
            + 63                 this.matrix[1][0] = x1;
            + 64                 this.matrix[1][1] = y1;
            + 65                 this.matrix[1][2] = z1;
            + 66 
            + 67                 this.matrix[2][0] = x2;
            + 68                 this.matrix[2][1] = y2;
            + 69                 this.matrix[2][2] = z2;
            + 70 
            + 71                 return this;
            + 72             },
            + 73             initWithMatrix:function (matrixData) {
            + 74                 this.matrix = matrixData;
            + 75                 return this;
            + 76             },
            + 77             flatten:function () {
            + 78                 var d = this.fmatrix;
            + 79                 var s = this.matrix;
            + 80                 d[ 0] = s[0][0];
            + 81                 d[ 1] = s[1][0];
            + 82                 d[ 2] = s[2][0];
            + 83                 d[ 3] = s[3][0];
            + 84 
            + 85                 d[ 4] = s[0][1];
            + 86                 d[ 5] = s[1][1];
            + 87                 d[ 6] = s[2][1];
            + 88                 d[ 7] = s[2][1];
            + 89 
            + 90                 d[ 8] = s[0][2];
            + 91                 d[ 9] = s[1][2];
            + 92                 d[10] = s[2][2];
            + 93                 d[11] = s[3][2];
            + 94 
            + 95                 d[12] = s[0][3];
            + 96                 d[13] = s[1][3];
            + 97                 d[14] = s[2][3];
            + 98                 d[15] = s[3][3];
            + 99 
            +100                 return this.fmatrix;
            +101             },
            +102 
            +103             /**
            +104              * Set this matrix to identity matrix.
            +105              * @return this
            +106              */
            +107             identity:function () {
            +108                 for (var i = 0; i < 4; i++) {
            +109                     for (var j = 0; j < 4; j++) {
            +110                         this.matrix[i][j] = (i === j) ? 1.0 : 0.0;
            +111                     }
            +112                 }
            +113 
            +114                 return this;
            +115             },
            +116             /**
            +117              * Get this matri'x internal representation data. The bakced structure is a 4x4 array of number.
            +118              */
            +119             getMatrix:function () {
            +120                 return this.matrix;
            +121             },
            +122             /**
            +123              * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around
            +124              * xy axis.
            +125              *
            +126              * @param xy {Number} radians to rotate.
            +127              *
            +128              * @return this
            +129              */
            +130             rotateXY:function (xy) {
            +131                 return this.rotate(xy, 0, 0);
            +132             },
            +133             /**
            +134              * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around
            +135              * xz axis.
            +136              *
            +137              * @param xz {Number} radians to rotate.
            +138              *
            +139              * @return this
            +140              */
            +141             rotateXZ:function (xz) {
            +142                 return this.rotate(0, xz, 0);
            +143             },
            +144             /**
            +145              * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate aroind
            +146              * yz axis.
            +147              *
            +148              * @param yz {Number} radians to rotate.
            +149              *
            +150              * @return this
            +151              */
            +152             rotateYZ:function (yz) {
            +153                 return this.rotate(0, 0, yz);
            +154             },
            +155             /**
            +156              *
            +157              * @param xy
            +158              * @param xz
            +159              * @param yz
            +160              */
            +161             setRotate:function (xy, xz, yz) {
            +162                 var m = this.rotate(xy, xz, yz);
            +163                 this.copy(m);
            +164                 return this;
            +165             },
            +166             /**
            +167              * Creates a matrix to represent arbitrary rotations around the given planes.
            +168              * @param xy {number} radians to rotate around xy plane.
            +169              * @param xz {number} radians to rotate around xz plane.
            +170              * @param yz {number} radians to rotate around yz plane.
            +171              *
            +172              * @return {CAAT.Matrix3} a newly allocated matrix.
            +173              * @static
            +174              */
            +175             rotate:function (xy, xz, yz) {
            +176                 var res = new CAAT.Math.Matrix3();
            +177                 var s, c, m;
            +178 
            +179                 if (xy !== 0) {
            +180                     m = new CAAT.Math.Math.Matrix3();
            +181                     s = Math.sin(xy);
            +182                     c = Math.cos(xy);
            +183                     m.matrix[1][1] = c;
            +184                     m.matrix[1][2] = -s;
            +185                     m.matrix[2][1] = s;
            +186                     m.matrix[2][2] = c;
            +187                     res.multiply(m);
            +188                 }
            +189 
            +190                 if (xz !== 0) {
            +191                     m = new CAAT.Math.Matrix3();
            +192                     s = Math.sin(xz);
            +193                     c = Math.cos(xz);
            +194                     m.matrix[0][0] = c;
            +195                     m.matrix[0][2] = -s;
            +196                     m.matrix[2][0] = s;
            +197                     m.matrix[2][2] = c;
            +198                     res.multiply(m);
            +199                 }
            +200 
            +201                 if (yz !== 0) {
            +202                     m = new CAAT.Math.Matrix3();
            +203                     s = Math.sin(yz);
            +204                     c = Math.cos(yz);
            +205                     m.matrix[0][0] = c;
            +206                     m.matrix[0][1] = -s;
            +207                     m.matrix[1][0] = s;
            +208                     m.matrix[1][1] = c;
            +209                     res.multiply(m);
            +210                 }
            +211 
            +212                 return res;
            +213             },
            +214             /**
            +215              * Creates a new matrix being a copy of this matrix.
            +216              * @return {CAAT.Matrix3} a newly allocated matrix object.
            +217              */
            +218             getClone:function () {
            +219                 var m = new CAAT.Math.Matrix3();
            +220                 m.copy(this);
            +221                 return m;
            +222             },
            +223             /**
            +224              * Multiplies this matrix by another matrix.
            +225              *
            +226              * @param n {CAAT.Matrix3} a CAAT.Matrix3 object.
            +227              * @return this
            +228              */
            +229             multiply:function (m) {
            +230                 var n = this.getClone();
            +231 
            +232                 var nm = n.matrix;
            +233                 var n00 = nm[0][0];
            +234                 var n01 = nm[0][1];
            +235                 var n02 = nm[0][2];
            +236                 var n03 = nm[0][3];
            +237 
            +238                 var n10 = nm[1][0];
            +239                 var n11 = nm[1][1];
            +240                 var n12 = nm[1][2];
            +241                 var n13 = nm[1][3];
            +242 
            +243                 var n20 = nm[2][0];
            +244                 var n21 = nm[2][1];
            +245                 var n22 = nm[2][2];
            +246                 var n23 = nm[2][3];
            +247 
            +248                 var n30 = nm[3][0];
            +249                 var n31 = nm[3][1];
            +250                 var n32 = nm[3][2];
            +251                 var n33 = nm[3][3];
            +252 
            +253                 var mm = m.matrix;
            +254                 var m00 = mm[0][0];
            +255                 var m01 = mm[0][1];
            +256                 var m02 = mm[0][2];
            +257                 var m03 = mm[0][3];
            +258 
            +259                 var m10 = mm[1][0];
            +260                 var m11 = mm[1][1];
            +261                 var m12 = mm[1][2];
            +262                 var m13 = mm[1][3];
            +263 
            +264                 var m20 = mm[2][0];
            +265                 var m21 = mm[2][1];
            +266                 var m22 = mm[2][2];
            +267                 var m23 = mm[2][3];
            +268 
            +269                 var m30 = mm[3][0];
            +270                 var m31 = mm[3][1];
            +271                 var m32 = mm[3][2];
            +272                 var m33 = mm[3][3];
            +273 
            +274                 this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20 + n03 * m30;
            +275                 this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21 + n03 * m31;
            +276                 this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22 + n03 * m32;
            +277                 this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03 * m33;
            +278 
            +279                 this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20 + n13 * m30;
            +280                 this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21 + n13 * m31;
            +281                 this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22 + n13 * m32;
            +282                 this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13 * m33;
            +283 
            +284                 this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20 + n23 * m30;
            +285                 this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21 + n23 * m31;
            +286                 this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22 + n23 * m32;
            +287                 this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23 * m33;
            +288 
            +289                 return this;
            +290             },
            +291             /**
            +292              * Pre multiplies this matrix by a given matrix.
            +293              *
            +294              * @param m {CAAT.Matrix3} a CAAT.Matrix3 object.
            +295              *
            +296              * @return this
            +297              */
            +298             premultiply:function (m) {
            +299                 var n = this.getClone();
            +300 
            +301                 var nm = n.matrix;
            +302                 var n00 = nm[0][0];
            +303                 var n01 = nm[0][1];
            +304                 var n02 = nm[0][2];
            +305                 var n03 = nm[0][3];
            +306 
            +307                 var n10 = nm[1][0];
            +308                 var n11 = nm[1][1];
            +309                 var n12 = nm[1][2];
            +310                 var n13 = nm[1][3];
            +311 
            +312                 var n20 = nm[2][0];
            +313                 var n21 = nm[2][1];
            +314                 var n22 = nm[2][2];
            +315                 var n23 = nm[2][3];
            +316 
            +317                 var n30 = nm[3][0];
            +318                 var n31 = nm[3][1];
            +319                 var n32 = nm[3][2];
            +320                 var n33 = nm[3][3];
            +321 
            +322                 var mm = m.matrix;
            +323                 var m00 = mm[0][0];
            +324                 var m01 = mm[0][1];
            +325                 var m02 = mm[0][2];
            +326                 var m03 = mm[0][3];
            +327 
            +328                 var m10 = mm[1][0];
            +329                 var m11 = mm[1][1];
            +330                 var m12 = mm[1][2];
            +331                 var m13 = mm[1][3];
            +332 
            +333                 var m20 = mm[2][0];
            +334                 var m21 = mm[2][1];
            +335                 var m22 = mm[2][2];
            +336                 var m23 = mm[2][3];
            +337 
            +338                 var m30 = mm[3][0];
            +339                 var m31 = mm[3][1];
            +340                 var m32 = mm[3][2];
            +341                 var m33 = mm[3][3];
            +342 
            +343                 this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20;
            +344                 this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21;
            +345                 this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22;
            +346                 this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03;
            +347                 this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20;
            +348                 this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21;
            +349                 this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22;
            +350                 this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13;
            +351                 this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20;
            +352                 this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21;
            +353                 this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22;
            +354                 this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23;
            +355 
            +356                 return this;
            +357             },
            +358             /**
            +359              * Set this matrix translation values to be the given parameters.
            +360              *
            +361              * @param x {number} x component of translation point.
            +362              * @param y {number} y component of translation point.
            +363              * @param z {number} z component of translation point.
            +364              *
            +365              * @return this
            +366              */
            +367             setTranslate:function (x, y, z) {
            +368                 this.identity();
            +369                 this.matrix[0][3] = x;
            +370                 this.matrix[1][3] = y;
            +371                 this.matrix[2][3] = z;
            +372                 return this;
            +373             },
            +374             /**
            +375              * Create a translation matrix.
            +376              * @param x {number}
            +377              * @param y {number}
            +378              * @param z {number}
            +379              * @return {CAAT.Matrix3} a new matrix.
            +380              */
            +381             translate:function (x, y, z) {
            +382                 var m = new CAAT.Math.Matrix3();
            +383                 m.setTranslate(x, y, z);
            +384                 return m;
            +385             },
            +386             setScale:function (sx, sy, sz) {
            +387                 this.identity();
            +388                 this.matrix[0][0] = sx;
            +389                 this.matrix[1][1] = sy;
            +390                 this.matrix[2][2] = sz;
            +391                 return this;
            +392             },
            +393             scale:function (sx, sy, sz) {
            +394                 var m = new CAAT.Math.Matrix3();
            +395                 m.setScale(sx, sy, sz);
            +396                 return m;
            +397             },
            +398             /**
            +399              * Set this matrix as the rotation matrix around the given axes.
            +400              * @param xy {number} radians of rotation around z axis.
            +401              * @param xz {number} radians of rotation around y axis.
            +402              * @param yz {number} radians of rotation around x axis.
            +403              *
            +404              * @return this
            +405              */
            +406             rotateModelView:function (xy, xz, yz) {
            +407                 var sxy = Math.sin(xy);
            +408                 var sxz = Math.sin(xz);
            +409                 var syz = Math.sin(yz);
            +410                 var cxy = Math.cos(xy);
            +411                 var cxz = Math.cos(xz);
            +412                 var cyz = Math.cos(yz);
            +413 
            +414                 this.matrix[0][0] = cxz * cxy;
            +415                 this.matrix[0][1] = -cxz * sxy;
            +416                 this.matrix[0][2] = sxz;
            +417                 this.matrix[0][3] = 0;
            +418                 this.matrix[1][0] = syz * sxz * cxy + sxy * cyz;
            +419                 this.matrix[1][1] = cyz * cxy - syz * sxz * sxy;
            +420                 this.matrix[1][2] = -syz * cxz;
            +421                 this.matrix[1][3] = 0;
            +422                 this.matrix[2][0] = syz * sxy - cyz * sxz * cxy;
            +423                 this.matrix[2][1] = cyz * sxz * sxy + syz * cxy;
            +424                 this.matrix[2][2] = cyz * cxz;
            +425                 this.matrix[2][3] = 0;
            +426                 this.matrix[3][0] = 0;
            +427                 this.matrix[3][1] = 0;
            +428                 this.matrix[3][2] = 0;
            +429                 this.matrix[3][3] = 1;
            +430 
            +431                 return this;
            +432             },
            +433             /**
            +434              * Copy a given matrix values into this one's.
            +435              * @param m {CAAT.Matrix} a matrix
            +436              *
            +437              * @return this
            +438              */
            +439             copy:function (m) {
            +440                 for (var i = 0; i < 4; i++) {
            +441                     for (var j = 0; j < 4; j++) {
            +442                         this.matrix[i][j] = m.matrix[i][j];
            +443                     }
            +444                 }
            +445 
            +446                 return this;
            +447             },
            +448             /**
            +449              * Calculate this matrix's determinant.
            +450              * @return {number} matrix determinant.
            +451              */
            +452             calculateDeterminant:function () {
            +453 
            +454                 var mm = this.matrix;
            +455                 var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3],
            +456                     m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3],
            +457                     m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3],
            +458                     m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3];
            +459 
            +460                 return  m14 * m22 * m33 * m41 +
            +461                     m12 * m24 * m33 * m41 +
            +462                     m14 * m23 * m31 * m42 +
            +463                     m13 * m24 * m31 * m42 +
            +464 
            +465                     m13 * m21 * m34 * m42 +
            +466                     m11 * m23 * m34 * m42 +
            +467                     m14 * m21 * m32 * m43 +
            +468                     m11 * m24 * m32 * m43 +
            +469 
            +470                     m13 * m22 * m31 * m44 +
            +471                     m12 * m23 * m31 * m44 +
            +472                     m12 * m21 * m33 * m44 +
            +473                     m11 * m22 * m33 * m44 +
            +474 
            +475                     m14 * m23 * m32 * m41 -
            +476                     m13 * m24 * m32 * m41 -
            +477                     m13 * m22 * m34 * m41 -
            +478                     m12 * m23 * m34 * m41 -
            +479 
            +480                     m14 * m21 * m33 * m42 -
            +481                     m11 * m24 * m33 * m42 -
            +482                     m14 * m22 * m31 * m43 -
            +483                     m12 * m24 * m31 * m43 -
            +484 
            +485                     m12 * m21 * m34 * m43 -
            +486                     m11 * m22 * m34 * m43 -
            +487                     m13 * m21 * m32 * m44 -
            +488                     m11 * m23 * m32 * m44;
            +489             },
            +490             /**
            +491              * Return a new matrix which is this matrix's inverse matrix.
            +492              * @return {CAAT.Matrix3} a new matrix.
            +493              */
            +494             getInverse:function () {
            +495                 var mm = this.matrix;
            +496                 var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3],
            +497                     m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3],
            +498                     m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3],
            +499                     m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3];
            +500 
            +501                 var m2 = new CAAT.Math.Matrix3();
            +502                 m2.matrix[0][0] = m23 * m34 * m42 + m24 * m32 * m43 + m22 * m33 * m44 - m24 * m33 * m42 - m22 * m34 * m43 - m23 * m32 * m44;
            +503                 m2.matrix[0][1] = m14 * m33 * m42 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44 - m13 * m34 * m42 - m14 * m32 * m43;
            +504                 m2.matrix[0][2] = m13 * m24 * m42 + m12 * m23 * m44 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 - m14 * m23 * m42;
            +505                 m2.matrix[0][3] = m14 * m23 * m32 + m12 * m24 * m33 + m13 * m22 * m34 - m13 * m24 * m32 - m14 * m22 * m33 - m12 * m23 * m34;
            +506 
            +507                 m2.matrix[1][0] = m24 * m33 * m41 + m21 * m34 * m43 + m23 * m31 * m44 - m23 * m34 * m41 - m24 * m31 * m43 - m21 * m33 * m44;
            +508                 m2.matrix[1][1] = m13 * m34 * m41 + m14 * m31 * m43 + m11 * m33 * m44 - m14 * m33 * m41 - m11 * m34 * m43 - m13 * m31 * m44;
            +509                 m2.matrix[1][2] = m14 * m23 * m41 + m11 * m24 * m43 + m13 * m21 * m44 - m13 * m24 * m41 - m14 * m21 * m43 - m11 * m23 * m44;
            +510                 m2.matrix[1][3] = m13 * m24 * m31 + m14 * m21 * m33 + m11 * m23 * m34 - m14 * m23 * m31 - m11 * m24 * m33 - m13 * m21 * m34;
            +511 
            +512                 m2.matrix[2][0] = m22 * m34 * m41 + m24 * m31 * m42 + m21 * m32 * m44 - m24 * m32 * m41 - m21 * m34 * m42 - m22 * m31 * m44;
            +513                 m2.matrix[2][1] = m14 * m32 * m41 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44 - m12 * m34 * m41 - m14 * m31 * m42;
            +514                 m2.matrix[2][2] = m13 * m24 * m41 + m14 * m21 * m42 + m11 * m22 * m44 - m14 * m22 * m41 - m11 * m24 * m42 - m12 * m21 * m44;
            +515                 m2.matrix[2][3] = m14 * m22 * m31 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34 - m12 * m24 * m31 - m14 * m21 * m32;
            +516 
            +517                 m2.matrix[3][0] = m23 * m32 * m41 + m21 * m33 * m42 + m22 * m31 * m43 - m22 * m33 * m41 - m23 * m31 * m42 - m21 * m32 * m43;
            +518                 m2.matrix[3][1] = m12 * m33 * m41 + m13 * m31 * m42 + m11 * m32 * m43 - m13 * m32 * m41 - m11 * m33 * m42 - m12 * m31 * m43;
            +519                 m2.matrix[3][2] = m13 * m22 * m41 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43 - m12 * m23 * m41 - m13 * m21 * m42;
            +520                 m2.matrix[3][3] = m12 * m23 * m31 + m13 * m21 * m32 + m11 * m22 * m33 - m13 * m22 * m31 - m11 * m23 * m32 - m12 * m21 * m33;
            +521 
            +522                 return m2.multiplyScalar(1 / this.calculateDeterminant());
            +523             },
            +524             /**
            +525              * Multiply this matrix by a scalar.
            +526              * @param scalar {number} scalar value
            +527              *
            +528              * @return this
            +529              */
            +530             multiplyScalar:function (scalar) {
            +531                 var i, j;
            +532 
            +533                 for (i = 0; i < 4; i++) {
            +534                     for (j = 0; j < 4; j++) {
            +535                         this.matrix[i][j] *= scalar;
            +536                     }
            +537                 }
            +538 
            +539                 return this;
            +540             }
            +541 
            +542         }
            +543     }
            +544 
            +545 });
            +546 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Rectangle.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Rectangle.js.html new file mode 100644 index 0000000..5056c20 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Math_Rectangle.js.html @@ -0,0 +1,226 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  */
            +  5 
            +  6 
            +  7 CAAT.Module( {
            +  8 
            +  9     /**
            + 10      * @name Rectangle
            + 11      * @memberOf CAAT.Math
            + 12      * @constructor
            + 13      */
            + 14 
            + 15 
            + 16     defines:        "CAAT.Math.Rectangle",
            + 17     aliases:        ["CAAT.Rectangle"],
            + 18     extendsWith:    function() {
            + 19         return {
            + 20 
            + 21             /**
            + 22              * @lends CAAT.Math.Rectangle.prototype
            + 23              */
            + 24 
            + 25             __init : function( x,y,w,h ) {
            + 26                 if ( arguments.length!==4 ) {
            + 27                     this.setEmpty();
            + 28                 } else {
            + 29                     this.setLocation(x,y);
            + 30                     this.setDimension(w,h);
            + 31                 }
            + 32             },
            + 33 
            + 34             /**
            + 35              * Rectangle x position.
            + 36              */
            + 37             x:		0,
            + 38 
            + 39             /**
            + 40              * Rectangle y position.
            + 41              */
            + 42             y:		0,
            + 43 
            + 44             /**
            + 45              * Rectangle x1 position.
            + 46              */
            + 47             x1:		0,
            + 48 
            + 49             /**
            + 50              * Rectangle y1 position.
            + 51              */
            + 52             y1:		0,
            + 53 
            + 54             /**
            + 55              * Rectangle width.
            + 56              */
            + 57             width:	-1,
            + 58 
            + 59             /**
            + 60              * Rectangle height.
            + 61              */
            + 62             height:	-1,
            + 63 
            + 64             setEmpty : function() {
            + 65                 this.width=     -1;
            + 66                 this.height=    -1;
            + 67                 this.x=         0;
            + 68                 this.y=         0;
            + 69                 this.x1=        0;
            + 70                 this.y1=        0;
            + 71                 return this;
            + 72             },
            + 73             /**
            + 74              * Set this rectangle's location.
            + 75              * @param x {number}
            + 76              * @param y {number}
            + 77              */
            + 78             setLocation: function( x,y ) {
            + 79                 this.x= x;
            + 80                 this.y= y;
            + 81                 this.x1= this.x+this.width;
            + 82                 this.y1= this.y+this.height;
            + 83                 return this;
            + 84             },
            + 85             /**
            + 86              * Set this rectangle's dimension.
            + 87              * @param w {number}
            + 88              * @param h {number}
            + 89              */
            + 90             setDimension : function( w,h ) {
            + 91                 this.width= w;
            + 92                 this.height= h;
            + 93                 this.x1= this.x+this.width;
            + 94                 this.y1= this.y+this.height;
            + 95                 return this;
            + 96             },
            + 97             setBounds : function( x,y,w,h ) {
            + 98                 this.setLocation( x, y );
            + 99                 this.setDimension( w, h );
            +100                 return this;
            +101             },
            +102             /**
            +103              * Return whether the coordinate is inside this rectangle.
            +104              * @param px {number}
            +105              * @param py {number}
            +106              *
            +107              * @return {boolean}
            +108              */
            +109             contains : function(px,py) {
            +110                 //return px>=0 && px<this.width && py>=0 && py<this.height;
            +111                 return px>=this.x && px<this.x1 && py>=this.y && py<this.y1;
            +112             },
            +113             /**
            +114              * Return whether this rectangle is empty, that is, has zero dimension.
            +115              * @return {boolean}
            +116              */
            +117             isEmpty : function() {
            +118                 return this.width===-1 && this.height===-1;
            +119             },
            +120             /**
            +121              * Set this rectangle as the union of this rectangle and the given point.
            +122              * @param px {number}
            +123              * @param py {number}
            +124              */
            +125             union : function(px,py) {
            +126 
            +127                 if ( this.isEmpty() ) {
            +128                     this.x= px;
            +129                     this.x1= px;
            +130                     this.y= py;
            +131                     this.y1= py;
            +132                     this.width=0;
            +133                     this.height=0;
            +134                     return;
            +135                 }
            +136 
            +137                 this.x1= this.x+this.width;
            +138                 this.y1= this.y+this.height;
            +139 
            +140                 if ( py<this.y ) {
            +141                     this.y= py;
            +142                 }
            +143                 if ( px<this.x ) {
            +144                     this.x= px;
            +145                 }
            +146                 if ( py>this.y1 ) {
            +147                     this.y1= py;
            +148                 }
            +149                 if ( px>this.x1 ){
            +150                     this.x1= px;
            +151                 }
            +152 
            +153                 this.width= this.x1-this.x;
            +154                 this.height= this.y1-this.y;
            +155             },
            +156             unionRectangle : function( rectangle ) {
            +157                 this.union( rectangle.x , rectangle.y  );
            +158                 this.union( rectangle.x1, rectangle.y  );
            +159                 this.union( rectangle.x,  rectangle.y1 );
            +160                 this.union( rectangle.x1, rectangle.y1 );
            +161                 return this;
            +162             },
            +163             intersects : function( r ) {
            +164                 if ( r.isEmpty() || this.isEmpty() ) {
            +165                     return false;
            +166                 }
            +167 
            +168                 if ( r.x1<= this.x ) {
            +169                     return false;
            +170                 }
            +171                 if ( r.x >= this.x1 ) {
            +172                     return false;
            +173                 }
            +174                 if ( r.y1<= this.y ) {
            +175                     return false;
            +176                 }
            +177 
            +178                 return r.y < this.y1;
            +179             },
            +180 
            +181             intersectsRect : function( x,y,w,h ) {
            +182                 if ( -1===w || -1===h ) {
            +183                     return false;
            +184                 }
            +185 
            +186                 var x1= x+w-1;
            +187                 var y1= y+h-1;
            +188 
            +189                 if ( x1< this.x ) {
            +190                     return false;
            +191                 }
            +192                 if ( x > this.x1 ) {
            +193                     return false;
            +194                 }
            +195                 if ( y1< this.y ) {
            +196                     return false;
            +197                 }
            +198                 return y <= this.y1;
            +199 
            +200             },
            +201 
            +202             intersect : function( i, r ) {
            +203                 if ( typeof r==='undefined' ) {
            +204                     r= new CAAT.Math.Rectangle();
            +205                 }
            +206 
            +207                 r.x= Math.max( this.x, i.x );
            +208                 r.y= Math.max( this.y, i.y );
            +209                 r.x1=Math.min( this.x1, i.x1 );
            +210                 r.y1=Math.min( this.y1, i.y1 );
            +211                 r.width= r.x1-r.x;
            +212                 r.height=r.y1-r.y;
            +213 
            +214                 return r;
            +215             }
            +216         }
            +217 	}
            +218 });
            +219 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Audio_AudioManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Audio_AudioManager.js.html new file mode 100644 index 0000000..706bd09 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Audio_AudioManager.js.html @@ -0,0 +1,570 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Sound implementation.
            +  5  */
            +  6 
            +  7 CAAT.Module({
            +  8 
            +  9     /**
            + 10      * @name Module
            + 11      * @memberOf CAAT
            + 12      * @namespace
            + 13      */
            + 14 
            + 15     /**
            + 16      * @name Audio
            + 17      * @memberOf CAAT.Module
            + 18      * @namespace
            + 19      */
            + 20 
            + 21     /**
            + 22      * @name AudioManager
            + 23      * @memberOf CAAT.Module.Audio
            + 24      * @constructor
            + 25      */
            + 26 
            + 27     defines:"CAAT.Module.Audio.AudioManager",
            + 28     extendsWith:function () {
            + 29         return {
            + 30 
            + 31             /**
            + 32              * @lends CAAT.Module.Audio.AudioManager.prototype
            + 33              */
            + 34 
            + 35             __init:function () {
            + 36                 this.isFirefox= navigator.userAgent.match(/Firefox/g)!==null;
            + 37                 return this;
            + 38             },
            + 39 
            + 40             isFirefox : false,
            + 41 
            + 42             /**
            + 43              * The only background music audio channel.
            + 44              */
            + 45             musicChannel: null,
            + 46 
            + 47             /**
            + 48              * Is music enabled ?
            + 49              */
            + 50             musicEnabled:true,
            + 51 
            + 52             /**
            + 53              * Are FX sounds enabled ?
            + 54              */
            + 55             fxEnabled:true,
            + 56 
            + 57             /**
            + 58              * A collection of Audio objects.
            + 59              */
            + 60             audioCache:null,
            + 61 
            + 62             /**
            + 63              * A cache of empty Audio objects.
            + 64              */
            + 65             channels:null,
            + 66 
            + 67             /**
            + 68              * Currently used Audio objects.
            + 69              */
            + 70             workingChannels:null,
            + 71 
            + 72             /**
            + 73              * Currently looping Audio objects.
            + 74              */
            + 75             loopingChannels:[],
            + 76 
            + 77             /**
            + 78              * available formats for audio elements.
            + 79              * the system will load audio files with the extensions in this preferred order.
            + 80              */
            + 81             audioFormatExtensions : [
            + 82                 'ogg',
            + 83                 'wav',
            + 84                 'x-wav',
            + 85                 'mp3'
            + 86             ],
            + 87 
            + 88             currentAudioFormatExtension : 'ogg',
            + 89 
            + 90             /**
            + 91              * Audio formats.
            + 92              * @dict
            + 93              */
            + 94             audioTypes:{               // supported audio formats. Don't remember where i took them from :S
            + 95                 'ogg':  'audio/ogg',
            + 96                 'mp3':  'audio/mpeg;',
            + 97                 'wav':  'audio/wav',
            + 98                 'x-wav':'audio/x-wav',
            + 99                 'mp4':  'audio/mp4"'
            +100             },
            +101 
            +102             /**
            +103              * Initializes the sound subsystem by creating a fixed number of Audio channels.
            +104              * Every channel registers a handler for sound playing finalization. If a callback is set, the
            +105              * callback function will be called with the associated sound id in the cache.
            +106              *
            +107              * @param numChannels {number} number of channels to pre-create. 8 by default.
            +108              *
            +109              * @return this.
            +110              */
            +111             initialize:function (numChannels ) {
            +112 
            +113                 this.setAudioFormatExtensions( this.audioFormatExtensions );
            +114 
            +115                 this.audioCache = [];
            +116                 this.channels = [];
            +117                 this.workingChannels = [];
            +118 
            +119                 for (var i = 0; i <= numChannels; i++) {
            +120                     var channel = document.createElement('audio');
            +121 
            +122                     if (null !== channel) {
            +123                         channel.finished = -1;
            +124                         this.channels.push(channel);
            +125                         var me = this;
            +126                         channel.addEventListener(
            +127                             'ended',
            +128                             // on sound end, set channel to available channels list.
            +129                             function (audioEvent) {
            +130                                 var target = audioEvent.target;
            +131                                 var i;
            +132 
            +133                                 // remove from workingChannels
            +134                                 for (i = 0; i < me.workingChannels.length; i++) {
            +135                                     if (me.workingChannels[i] === target) {
            +136                                         me.workingChannels.splice(i, 1);
            +137                                         break;
            +138                                     }
            +139                                 }
            +140 
            +141                                 if (target.caat_callback) {
            +142                                     target.caat_callback(target.caat_id);
            +143                                 }
            +144 
            +145                                 // set back to channels.
            +146                                 me.channels.push(target);
            +147                             },
            +148                             false
            +149                         );
            +150                     }
            +151                 }
            +152 
            +153                 this.musicChannel= this.channels.pop();
            +154 
            +155                 return this;
            +156             },
            +157 
            +158             setAudioFormatExtensions : function( formats ) {
            +159                 this.audioFormatExtensions= formats;
            +160                 this.__setCurrentAudioFormatExtension();
            +161                 return this;
            +162             },
            +163 
            +164             __setCurrentAudioFormatExtension : function( ) {
            +165 
            +166                 var audio= new Audio();
            +167 
            +168                 for( var i= 0, l=this.audioFormatExtensions.length; i<l; i+=1 ) {
            +169                     var res= audio.canPlayType( this.audioTypes[this.audioFormatExtensions[i]]).toLowerCase();
            +170                     if ( res!=="no" && res!=="" ) {
            +171                         this.currentAudioFormatExtension= this.audioFormatExtensions[i];
            +172                         console.log("Audio type set to: "+this.currentAudioFormatExtension);
            +173                         return;
            +174                     }
            +175                 }
            +176 
            +177                 this.currentAudioFormatExtension= null;
            +178             },
            +179 
            +180             __getAudioUrl : function( url ) {
            +181 
            +182                 if ( this.currentAudioFormatExtension===null ) {
            +183                     return url;
            +184                 }
            +185 
            +186                 var lio= url.lastIndexOf( "." );
            +187                 if ( lio<0 ) {
            +188                     console.log("Audio w/o extension: "+url);
            +189                     lio= url.length()-1;
            +190                 }
            +191 
            +192                 var uri= url.substring( 0, lio+1 ) + this.currentAudioFormatExtension;
            +193                 return uri;
            +194             },
            +195 
            +196             /**
            +197              * Tries to add an audio tag to the available list of valid audios. The audio is described by a url.
            +198              * @param id {object} an object to associate the audio element (if suitable to be played).
            +199              * @param url {string} a string describing an url.
            +200              * @param endplaying_callback {function} callback to be called upon sound end.
            +201              *
            +202              * @return {boolean} a boolean indicating whether the browser can play this resource.
            +203              *
            +204              * @private
            +205              */
            +206             addAudioFromURL:function (id, url, endplaying_callback) {
            +207                 var audio = document.createElement('audio');
            +208 
            +209                 if (null !== audio) {
            +210 
            +211                     audio.src = this.__getAudioUrl(url);
            +212                     console.log("Loading audio: "+audio.src);
            +213                     audio.preload = "auto";
            +214                     audio.load();
            +215                     if (endplaying_callback) {
            +216                         audio.caat_callback = endplaying_callback;
            +217                         audio.caat_id = id;
            +218                     }
            +219                     this.audioCache.push({ id:id, audio:audio });
            +220 
            +221                     return true;
            +222                 }
            +223 
            +224                 return false;
            +225             },
            +226             /**
            +227              * Tries to add an audio tag to the available list of valid audios. The audio element comes from
            +228              * an HTMLAudioElement.
            +229              * @param id {object} an object to associate the audio element (if suitable to be played).
            +230              * @param audio {HTMLAudioElement} a DOM audio node.
            +231              * @param endplaying_callback {function} callback to be called upon sound end.
            +232              *
            +233              * @return {boolean} a boolean indicating whether the browser can play this resource.
            +234              *
            +235              * @private
            +236              */
            +237             addAudioFromDomNode:function (id, audio, endplaying_callback) {
            +238 
            +239                 var extension = audio.src.substr(audio.src.lastIndexOf('.') + 1);
            +240                 if (audio.canPlayType(this.audioTypes[extension])) {
            +241                     if (endplaying_callback) {
            +242                         audio.caat_callback = endplaying_callback;
            +243                         audio.caat_id = id;
            +244                     }
            +245                     this.audioCache.push({ id:id, audio:audio });
            +246 
            +247                     return true;
            +248                 }
            +249 
            +250                 return false;
            +251             },
            +252             /**
            +253              * Adds an elements to the audio cache.
            +254              * @param id {object} an object to associate the audio element (if suitable to be played).
            +255              * @param element {URL|HTMLElement} an url or html audio tag.
            +256              * @param endplaying_callback {function} callback to be called upon sound end.
            +257              *
            +258              * @return {boolean} a boolean indicating whether the browser can play this resource.
            +259              *
            +260              * @private
            +261              */
            +262             addAudioElement:function (id, element, endplaying_callback) {
            +263                 if (typeof element === "string") {
            +264                     return this.addAudioFromURL(id, element, endplaying_callback);
            +265                 } else {
            +266                     try {
            +267                         if (element instanceof HTMLAudioElement) {
            +268                             return this.addAudioFromDomNode(id, element, endplaying_callback);
            +269                         }
            +270                     }
            +271                     catch (e) {
            +272                     }
            +273                 }
            +274 
            +275                 return false;
            +276             },
            +277             /**
            +278              * creates an Audio object and adds it to the audio cache.
            +279              * This function expects audio data described by two elements, an id and an object which will
            +280              * describe an audio element to be associated with the id. The object will be of the form
            +281              * array, dom node or a url string.
            +282              *
            +283              * <p>
            +284              * The audio element can be one of the two forms:
            +285              *
            +286              * <ol>
            +287              *  <li>Either an HTMLAudioElement/Audio object or a string url.
            +288              *  <li>An array of elements of the previous form.
            +289              * </ol>
            +290              *
            +291              * <p>
            +292              * When the audio attribute is an array, this function will iterate throught the array elements
            +293              * until a suitable audio element to be played is found. When this is the case, the other array
            +294              * elements won't be taken into account. The valid form of using this addAudio method will be:
            +295              *
            +296              * <p>
            +297              * 1.<br>
            +298              * addAudio( id, url } ). In this case, if the resource pointed by url is
            +299              * not suitable to be played (i.e. a call to the Audio element's canPlayType method return 'no')
            +300              * no resource will be added under such id, so no sound will be played when invoking the play(id)
            +301              * method.
            +302              * <p>
            +303              * 2.<br>
            +304              * addAudio( id, dom_audio_tag ). In this case, the same logic than previous case is applied, but
            +305              * this time, the parameter url is expected to be an audio tag present in the html file.
            +306              * <p>
            +307              * 3.<br>
            +308              * addAudio( id, [array_of_url_or_domaudiotag] ). In this case, the function tries to locate a valid
            +309              * resource to be played in any of the elements contained in the array. The array element's can
            +310              * be any type of case 1 and 2. As soon as a valid resource is found, it will be associated to the
            +311              * id in the valid audio resources to be played list.
            +312              *
            +313              * @return this
            +314              */
            +315             addAudio:function (id, array_of_url_or_domnodes, endplaying_callback) {
            +316 
            +317                 if (array_of_url_or_domnodes instanceof Array) {
            +318                     /*
            +319                      iterate throught array elements until we can safely add an audio element.
            +320                      */
            +321                     for (var i = 0; i < array_of_url_or_domnodes.length; i++) {
            +322                         if (this.addAudioElement(id, array_of_url_or_domnodes[i], endplaying_callback)) {
            +323                             break;
            +324                         }
            +325                     }
            +326                 } else {
            +327                     this.addAudioElement(id, array_of_url_or_domnodes, endplaying_callback);
            +328                 }
            +329 
            +330                 return this;
            +331             },
            +332             /**
            +333              * Returns an audio object.
            +334              * @param aId {object} the id associated to the target Audio object.
            +335              * @return {object} the HTMLAudioElement addociated to the given id.
            +336              */
            +337             getAudio:function (aId) {
            +338                 for (var i = 0; i < this.audioCache.length; i++) {
            +339                     if (this.audioCache[i].id === aId) {
            +340                         return this.audioCache[i].audio;
            +341                     }
            +342                 }
            +343 
            +344                 return null;
            +345             },
            +346 
            +347             stopMusic : function() {
            +348                 this.musicChannel.pause();
            +349             },
            +350 
            +351             playMusic : function(id) {
            +352                 if (!this.musicEnabled) {
            +353                     return null;
            +354                 }
            +355 
            +356                 var audio_in_cache = this.getAudio(id);
            +357                 // existe el audio, y ademas hay un canal de audio disponible.
            +358                 if (null !== audio_in_cache) {
            +359                     var audio =this.musicChannel;
            +360                     if (null !== audio) {
            +361                         audio.src = audio_in_cache.src;
            +362                         audio.preload = "auto";
            +363 
            +364                         if (this.isFirefox) {
            +365                             audio.addEventListener(
            +366                                 'ended',
            +367                                 // on sound end, restart music.
            +368                                 function (audioEvent) {
            +369                                     var target = audioEvent.target;
            +370                                     target.currentTime = 0;
            +371                                 },
            +372                                 false
            +373                             );
            +374                         } else {
            +375                             audio.loop = true;
            +376                         }
            +377                         audio.load();
            +378                         audio.play();
            +379                         return audio;
            +380                     }
            +381                 }
            +382 
            +383                 return null;
            +384             },
            +385 
            +386             /**
            +387              * Set an audio object volume.
            +388              * @param id {object} an audio Id
            +389              * @param volume {number} volume to set. The volume value is not checked.
            +390              *
            +391              * @return this
            +392              */
            +393             setVolume:function (id, volume) {
            +394                 var audio = this.getAudio(id);
            +395                 if (null != audio) {
            +396                     audio.volume = volume;
            +397                 }
            +398 
            +399                 return this;
            +400             },
            +401 
            +402             /**
            +403              * Plays an audio file from the cache if any sound channel is available.
            +404              * The playing sound will occupy a sound channel and when ends playing will leave
            +405              * the channel free for any other sound to be played in.
            +406              * @param id {object} an object identifying a sound in the sound cache.
            +407              * @return { id: {Object}, audio: {(Audio|HTMLAudioElement)} }
            +408              */
            +409             play:function (id) {
            +410                 if (!this.fxEnabled) {
            +411                     return null;
            +412                 }
            +413 
            +414                 var audio = this.getAudio(id);
            +415                 // existe el audio, y ademas hay un canal de audio disponible.
            +416                 if (null !== audio && this.channels.length > 0) {
            +417                     var channel = this.channels.shift();
            +418                     channel.src = audio.src;
            +419 //                    channel.load();
            +420                     channel.volume = audio.volume;
            +421                     channel.play();
            +422                     this.workingChannels.push(channel);
            +423                 } else {
            +424                     console.log("Can't play audio: "+id);
            +425                 }
            +426 
            +427                 return audio;
            +428             },
            +429 
            +430             /**
            +431              * cancel all instances of a sound identified by id. This id is the value set
            +432              * to identify a sound.
            +433              * @param id
            +434              * @return {*}
            +435              */
            +436             cancelPlay : function(id) {
            +437 
            +438                 for( var i=0 ; this.workingChannels.length; i++ ) {
            +439                     var audio= this.workingChannels[i];
            +440                     if ( audio.caat_id===id ) {
            +441                         audio.pause();
            +442                         this.channels.push(audio);
            +443                         this.workingChannels.splice(i,1);
            +444                     }
            +445                 }
            +446 
            +447                 return this;
            +448             },
            +449 
            +450             /**
            +451              * cancel a channel sound
            +452              * @param audioObject
            +453              * @return {*}
            +454              */
            +455             cancelPlayByChannel : function(audioObject) {
            +456 
            +457                 for( var i=0 ; this.workingChannels.length; i++ ) {
            +458                     if ( this.workingChannels[i]===audioObject ) {
            +459                         this.channels.push(audioObject);
            +460                         this.workingChannels.splice(i,1);
            +461                         return this;
            +462                     }
            +463                 }
            +464 
            +465                 return this;
            +466             },
            +467 
            +468             /**
            +469              * This method creates a new AudioChannel to loop the sound with.
            +470              * It returns an Audio object so that the developer can cancel the sound loop at will.
            +471              * The user must call <code>pause()</code> method to stop playing a loop.
            +472              * <p>
            +473              * Firefox does not honor the loop property, so looping is performed by attending end playing
            +474              * event on audio elements.
            +475              *
            +476              * @return {HTMLElement} an Audio instance if a valid sound id is supplied. Null otherwise
            +477              */
            +478             loop:function (id) {
            +479 
            +480                 if (!this.musicEnabled) {
            +481                     return null;
            +482                 }
            +483 
            +484                 var audio_in_cache = this.getAudio(id);
            +485                 // existe el audio, y ademas hay un canal de audio disponible.
            +486                 if (null !== audio_in_cache) {
            +487                     var audio = document.createElement('audio');
            +488                     if (null !== audio) {
            +489                         audio.src = audio_in_cache.src;
            +490                         audio.preload = "auto";
            +491 
            +492                         if (this.isFirefox) {
            +493                             audio.addEventListener(
            +494                                 'ended',
            +495                                 // on sound end, set channel to available channels list.
            +496                                 function (audioEvent) {
            +497                                     var target = audioEvent.target;
            +498                                     target.currentTime = 0;
            +499                                 },
            +500                                 false
            +501                             );
            +502                         } else {
            +503                             audio.loop = true;
            +504                         }
            +505                         audio.load();
            +506                         audio.play();
            +507                         this.loopingChannels.push(audio);
            +508                         return audio;
            +509                     }
            +510                 }
            +511 
            +512                 return null;
            +513             },
            +514             /**
            +515              * Cancel all playing audio channels
            +516              * Get back the playing channels to available channel list.
            +517              *
            +518              * @return this
            +519              */
            +520             endSound:function () {
            +521                 var i;
            +522                 for (i = 0; i < this.workingChannels.length; i++) {
            +523                     this.workingChannels[i].pause();
            +524                     this.channels.push(this.workingChannels[i]);
            +525                 }
            +526 
            +527                 for (i = 0; i < this.loopingChannels.length; i++) {
            +528                     this.loopingChannels[i].pause();
            +529                 }
            +530 
            +531                 this.workingChannels= [];
            +532                 this.loopingChannels= [];
            +533 
            +534                 this.stopMusic();
            +535 
            +536                 return this;
            +537             },
            +538             setSoundEffectsEnabled:function (enable) {
            +539                 this.fxEnabled = enable;
            +540                 for (var i = 0; i < this.loopingChannels.length; i++) {
            +541                     if (enable) {
            +542                         this.loopingChannels[i].play();
            +543                     } else {
            +544                         this.loopingChannels[i].pause();
            +545                     }
            +546                 }
            +547                 return this;
            +548             },
            +549             isSoundEffectsEnabled:function () {
            +550                 return this.fxEnabled;
            +551             },
            +552             setMusicEnabled:function (enable) {
            +553                 this.musicEnabled = enable;
            +554                 this.stopMusic();
            +555                 return this;
            +556             },
            +557             isMusicEnabled:function () {
            +558                 return this.musicEnabled;
            +559             }
            +560         }
            +561     }
            +562 });
            +563 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_CSS_csskeyframehelper.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_CSS_csskeyframehelper.js.html new file mode 100644 index 0000000..b5ae464 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_CSS_csskeyframehelper.js.html @@ -0,0 +1,185 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * This object manages CSS3 transitions reflecting applying behaviors.
            +  5  *
            +  6  **/
            +  7 
            +  8 (function() {
            +  9 
            + 10     /**
            + 11      * @name CSS
            + 12      * @memberOf CAAT
            + 13      * @namespace
            + 14      */
            + 15 
            + 16     CAAT.CSS= {};
            + 17 
            + 18     /**
            + 19      * @lends CAAT.CSS
            + 20      */
            + 21 
            + 22 
            + 23     /**
            + 24      * Guess a browser custom prefix.
            + 25      * @type {*}
            + 26      */
            + 27     CAAT.CSS.PREFIX= (function() {
            + 28 
            + 29         var prefix = "";
            + 30         var prefixes = ['WebKit', 'Moz', 'O'];
            + 31         var keyframes= "";
            + 32 
            + 33         // guess this browser vendor prefix.
            + 34         for (var i = 0; i < prefixes.length; i++) {
            + 35             if (window[prefixes[i] + 'CSSKeyframeRule']) {
            + 36                 prefix = prefixes[i].toLowerCase();
            + 37                 break;
            + 38             }
            + 39         }
            + 40 
            + 41         CAAT.CSS.PROP_ANIMATION= '-'+prefix+'-animation';
            + 42 
            + 43         return prefix;
            + 44     })();
            + 45 
            + 46     /**
            + 47      * Apply a given @key-frames animation to a DOM element.
            + 48      * @param domElement {DOMElement}
            + 49      * @param name {string} animation name
            + 50      * @param duration_millis {number}
            + 51      * @param delay_millis {number}
            + 52      * @param forever {boolean}
            + 53      */
            + 54     CAAT.CSS.applyKeyframe= function( domElement, name, duration_millis, delay_millis, forever ) {
            + 55         domElement.style[CAAT.CSS.PROP_ANIMATION]= name+' '+(duration_millis/1000)+'s '+(delay_millis/1000)+'s linear both '+(forever ? 'infinite' : '') ;
            + 56     };
            + 57 
            + 58     /**
            + 59      * Remove a @key-frames animation from the stylesheet.
            + 60      * @param name
            + 61      */
            + 62     CAAT.CSS.unregisterKeyframes= function( name ) {
            + 63         var index= CAAT.CSS.getCSSKeyframesIndex(name);
            + 64         if ( null!==index ) {
            + 65             document.styleSheets[ index.sheetIndex ].deleteRule( index.index );
            + 66         }
            + 67     };
            + 68 
            + 69     /**
            + 70      *
            + 71      * @param kfDescriptor {object}
            + 72      *      {
            + 73      *          name{string},
            + 74      *          behavior{CAAT.Behavior},
            + 75      *          size{!number},
            + 76      *          overwrite{boolean}
            + 77      *      }
            + 78      *  }
            + 79      */
            + 80     CAAT.CSS.registerKeyframes= function( kfDescriptor ) {
            + 81 
            + 82         var name=       kfDescriptor.name;
            + 83         var behavior=   kfDescriptor.behavior;
            + 84         var size=       kfDescriptor.size;
            + 85         var overwrite=  kfDescriptor.overwrite;
            + 86 
            + 87         if ( typeof name==='undefined' || typeof behavior==='undefined' ) {
            + 88             throw 'Keyframes must be defined by a name and a CAAT.Behavior instance.';
            + 89         }
            + 90 
            + 91         if ( typeof size==='undefined' ) {
            + 92             size= 100;
            + 93         }
            + 94         if ( typeof overwrite==='undefined' ) {
            + 95             overwrite= false;
            + 96         }
            + 97 
            + 98         // find if keyframes has already a name set.
            + 99         var cssRulesIndex= CAAT.CSS.getCSSKeyframesIndex(name);
            +100         if (null!==cssRulesIndex && !overwrite) {
            +101             return;
            +102         }
            +103 
            +104         var keyframesRule= behavior.calculateKeyFramesData(CAAT.CSS.PREFIX, name, size, kfDescriptor.anchorX, kfDescriptor.anchorY );
            +105 
            +106         if (document.styleSheets) {
            +107             if ( !document.styleSheets.length) {
            +108                 var s = document.createElement('style');
            +109                 s.type="text/css";
            +110 
            +111                 document.getElementsByTagName('head')[ 0 ].appendChild(s);
            +112             }
            +113 
            +114             if ( null!==cssRulesIndex ) {
            +115                 document.styleSheets[ cssRulesIndex.sheetIndex ].deleteRule( cssRulesIndex.index );
            +116             }
            +117 
            +118             var index= cssRulesIndex ? cssRulesIndex.sheetIndex : 0;
            +119             document.styleSheets[ index ].insertRule( keyframesRule, 0 );
            +120         }
            +121 
            +122         return keyframesRule;
            +123     };
            +124 
            +125     CAAT.CSS.getCSSKeyframesIndex= function(name) {
            +126         var ss = document.styleSheets;
            +127         for (var i = ss.length - 1; i >= 0; i--) {
            +128             try {
            +129                 var s = ss[i],
            +130                     rs = s.cssRules ? s.cssRules :
            +131                          s.rules ? s.rules :
            +132                          [];
            +133 
            +134                 for (var j = rs.length - 1; j >= 0; j--) {
            +135                     if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE ||
            +136                            rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) {
            +137 
            +138                         return {
            +139                             sheetIndex : i,
            +140                             index: j
            +141                         };
            +142                     }
            +143                 }
            +144             } catch(e) {
            +145             }
            +146         }
            +147 
            +148         return null;
            +149     };
            +150 
            +151     CAAT.CSS.getCSSKeyframes= function(name) {
            +152 
            +153         var ss = document.styleSheets;
            +154         for (var i = ss.length - 1; i >= 0; i--) {
            +155             try {
            +156                 var s = ss[i],
            +157                     rs = s.cssRules ? s.cssRules :
            +158                          s.rules ? s.rules :
            +159                          [];
            +160 
            +161                 for (var j = rs.length - 1; j >= 0; j--) {
            +162                     if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE ||
            +163                            rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) {
            +164 
            +165                         return rs[j];
            +166                     }
            +167                 }
            +168             }
            +169             catch(e) {
            +170             }
            +171         }
            +172         return null;
            +173     };
            +174 
            +175 
            +176 
            +177 })();
            +178 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_Quadtree.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_Quadtree.js.html new file mode 100644 index 0000000..caa5c24 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_Quadtree.js.html @@ -0,0 +1,138 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * This file contains the definition for objects QuadTree and HashMap.
            +  5  * Quadtree offers an exact list of collisioning areas, while HashMap offers a list of potentially colliding
            +  6  * elements.
            +  7  * Specially suited for static content.
            +  8  *
            +  9  **/
            + 10 
            + 11 CAAT.Module({
            + 12 
            + 13     /**
            + 14      * @name Collision
            + 15      * @memberOf CAAT.Module
            + 16      * @namespace
            + 17      */
            + 18 
            + 19     /**
            + 20      * @name QuadTree
            + 21      * @memberOf CAAT.Module.Collision
            + 22      * @constructor
            + 23      */
            + 24 
            + 25     defines:"CAAT.Module.Collision.QuadTree",
            + 26     depends:[
            + 27         "CAAT.Math.Rectangle"
            + 28     ],
            + 29     extendsClass:"CAAT.Math.Rectangle",
            + 30     extendsWith:function () {
            + 31 
            + 32         var QT_MAX_ELEMENTS = 1;
            + 33         var QT_MIN_WIDTH = 32;
            + 34 
            + 35         return {
            + 36 
            + 37             /**
            + 38              * @lends CAAT.Module.Collision.QuadTree.prototype
            + 39              */
            + 40 
            + 41             /**
            + 42              * For each quadtree level this keeps the list of overlapping elements.
            + 43              */
            + 44             bgActors:null,
            + 45 
            + 46             /**
            + 47              * For each quadtree, this quadData keeps another 4 quadtrees up to the  maximum recursion level.
            + 48              */
            + 49             quadData:null,
            + 50 
            + 51             create:function (l, t, r, b, backgroundElements, minWidth, maxElements) {
            + 52 
            + 53                 if (typeof minWidth === 'undefined') {
            + 54                     minWidth = QT_MIN_WIDTH;
            + 55                 }
            + 56                 if (typeof maxElements === 'undefined') {
            + 57                     maxElements = QT_MAX_ELEMENTS;
            + 58                 }
            + 59 
            + 60                 var cx = (l + r) / 2;
            + 61                 var cy = (t + b) / 2;
            + 62 
            + 63                 this.x = l;
            + 64                 this.y = t;
            + 65                 this.x1 = r;
            + 66                 this.y1 = b;
            + 67                 this.width = r - l;
            + 68                 this.height = b - t;
            + 69 
            + 70                 this.bgActors = this.__getOverlappingActorList(backgroundElements);
            + 71 
            + 72                 if (this.bgActors.length <= maxElements || this.width <= minWidth) {
            + 73                     return this;
            + 74                 }
            + 75 
            + 76                 this.quadData = new Array(4);
            + 77                 this.quadData[0] = new CAAT.Module.Collision.QuadTree().create(l, t, cx, cy, this.bgActors);  // TL
            + 78                 this.quadData[1] = new CAAT.Module.Collision.QuadTree().create(cx, t, r, cy, this.bgActors);  // TR
            + 79                 this.quadData[2] = new CAAT.Module.Collision.QuadTree().create(l, cy, cx, b, this.bgActors);  // BL
            + 80                 this.quadData[3] = new CAAT.Module.Collision.QuadTree().create(cx, cy, r, b, this.bgActors);
            + 81 
            + 82                 return this;
            + 83             },
            + 84 
            + 85             __getOverlappingActorList:function (actorList) {
            + 86                 var tmpList = [];
            + 87                 for (var i = 0, l = actorList.length; i < l; i++) {
            + 88                     var actor = actorList[i];
            + 89                     if (this.intersects(actor.AABB)) {
            + 90                         tmpList.push(actor);
            + 91                     }
            + 92                 }
            + 93                 return tmpList;
            + 94             },
            + 95 
            + 96             /**
            + 97              * Call this method to thet the list of colliding elements with the parameter rectangle.
            + 98              * @param rectangle
            + 99              * @return {Array}
            +100              */
            +101             getOverlappingActors:function (rectangle) {
            +102                 var i, j, l;
            +103                 var overlappingActors = [];
            +104                 var qoverlappingActors;
            +105                 var actors = this.bgActors;
            +106                 var actor;
            +107 
            +108                 if (this.quadData) {
            +109                     for (i = 0; i < 4; i++) {
            +110                         if (this.quadData[i].intersects(rectangle)) {
            +111                             qoverlappingActors = this.quadData[i].getOverlappingActors(rectangle);
            +112                             for (j = 0, l = qoverlappingActors.length; j < l; j++) {
            +113                                 overlappingActors.push(qoverlappingActors[j]);
            +114                             }
            +115                         }
            +116                     }
            +117                 } else {
            +118                     for (i = 0, l = actors.length; i < l; i++) {
            +119                         actor = actors[i];
            +120                         if (rectangle.intersects(actor.AABB)) {
            +121                             overlappingActors.push(actor);
            +122                         }
            +123                     }
            +124                 }
            +125 
            +126                 return overlappingActors;
            +127             }
            +128         }
            +129     }
            +130 });
            +131 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_SpatialHash.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_SpatialHash.js.html new file mode 100644 index 0000000..14a0e52 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Collision_SpatialHash.js.html @@ -0,0 +1,247 @@ +
              1 CAAT.Module( {
            +  2 
            +  3 
            +  4     /**
            +  5      * @name SpatialHash
            +  6      * @memberOf CAAT.Module.Collision
            +  7      * @constructor
            +  8      */
            +  9 
            + 10 
            + 11     defines : "CAAT.Module.Collision.SpatialHash",
            + 12     aliases : ["CAAT.SpatialHash"],
            + 13     depends : [
            + 14         "CAAT.Math.Rectangle"
            + 15     ],
            + 16     extendsWith : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.Module.Collision.SpatialHash.prototype
            + 20          */
            + 21 
            + 22         /**
            + 23          * A collection ob objects to test collision among them.
            + 24          */
            + 25         elements    :   null,
            + 26 
            + 27         /**
            + 28          * Space width
            + 29          */
            + 30         width       :   null,
            + 31 
            + 32         /**
            + 33          * Space height
            + 34          */
            + 35         height      :   null,
            + 36 
            + 37         /**
            + 38          * Rows to partition the space.
            + 39          */
            + 40         rows        :   null,
            + 41 
            + 42         /**
            + 43          * Columns to partition the space.
            + 44          */
            + 45         columns     :   null,
            + 46 
            + 47         xcache      :   null,
            + 48         ycache      :   null,
            + 49         xycache     :   null,
            + 50 
            + 51         rectangle   :   null,
            + 52 
            + 53         /**
            + 54          * Spare rectangle to hold temporary calculations.
            + 55          */
            + 56         r0          :   null,
            + 57 
            + 58         /**
            + 59          * Spare rectangle to hold temporary calculations.
            + 60          */
            + 61         r1          :   null,
            + 62 
            + 63         initialize : function( w,h, rows,columns ) {
            + 64 
            + 65             var i, j;
            + 66 
            + 67             this.elements= [];
            + 68             for( i=0; i<rows*columns; i++ ) {
            + 69                 this.elements.push( [] );
            + 70             }
            + 71 
            + 72             this.width=     w;
            + 73             this.height=    h;
            + 74 
            + 75             this.rows=      rows;
            + 76             this.columns=   columns;
            + 77 
            + 78             this.xcache= [];
            + 79             for( i=0; i<w; i++ ) {
            + 80                 this.xcache.push( (i/(w/columns))>>0 );
            + 81             }
            + 82 
            + 83             this.ycache= [];
            + 84             for( i=0; i<h; i++ ) {
            + 85                 this.ycache.push( (i/(h/rows))>>0 );
            + 86             }
            + 87 
            + 88             this.xycache=[];
            + 89             for( i=0; i<this.rows; i++ ) {
            + 90 
            + 91                 this.xycache.push( [] );
            + 92                 for( j=0; j<this.columns; j++ ) {
            + 93                     this.xycache[i].push( j + i*columns  );
            + 94                 }
            + 95             }
            + 96 
            + 97             this.rectangle= new CAAT.Math.Rectangle().setBounds( 0, 0, w, h );
            + 98             this.r0=        new CAAT.Math.Rectangle();
            + 99             this.r1=        new CAAT.Math.Rectangle();
            +100 
            +101             return this;
            +102         },
            +103 
            +104         clearObject : function() {
            +105             var i;
            +106 
            +107             for( i=0; i<this.rows*this.columns; i++ ) {
            +108                 this.elements[i]= [];
            +109             }
            +110 
            +111             return this;
            +112         },
            +113 
            +114         /**
            +115          * Add an element of the form { id, x,y,width,height, rectangular }
            +116          */
            +117         addObject : function( obj  ) {
            +118             var x= obj.x|0;
            +119             var y= obj.y|0;
            +120             var width= obj.width|0;
            +121             var height= obj.height|0;
            +122 
            +123             var cells= this.__getCells( x,y,width,height );
            +124             for( var i=0; i<cells.length; i++ ) {
            +125                 this.elements[ cells[i] ].push( obj );
            +126             }
            +127         },
            +128 
            +129         __getCells : function( x,y,width,height ) {
            +130 
            +131             var cells= [];
            +132             var i;
            +133 
            +134             if ( this.rectangle.contains(x,y) ) {
            +135                 cells.push( this.xycache[ this.ycache[y] ][ this.xcache[x] ] );
            +136             }
            +137 
            +138             /**
            +139              * if both squares lay inside the same cell, it is not crossing a boundary.
            +140              */
            +141             if ( this.rectangle.contains(x+width-1,y+height-1) ) {
            +142                 var c= this.xycache[ this.ycache[y+height-1] ][ this.xcache[x+width-1] ];
            +143                 if ( c===cells[0] ) {
            +144                     return cells;
            +145                 }
            +146                 cells.push( c );
            +147             }
            +148 
            +149             /**
            +150              * the other two AABB points lie inside the screen as well.
            +151              */
            +152             if ( this.rectangle.contains(x+width-1,y) ) {
            +153                 var c= this.xycache[ this.ycache[y] ][ this.xcache[x+width-1] ];
            +154                 if ( c===cells[0] || c===cells[1] ) {
            +155                     return cells;
            +156                 }
            +157                 cells.push(c);
            +158             }
            +159 
            +160             // worst case, touching 4 screen cells.
            +161             if ( this.rectangle.contains(x+width-1,y+height-1) ) {
            +162                 var c= this.xycache[ this.ycache[y+height-1] ][ this.xcache[x] ];
            +163                 cells.push(c);
            +164             }
            +165 
            +166             return cells;
            +167         },
            +168 
            +169         solveCollision : function( callback ) {
            +170             var i,j,k;
            +171 
            +172             for( i=0; i<this.elements.length; i++ ) {
            +173                 var cell= this.elements[i];
            +174 
            +175                 if ( cell.length>1 ) {  // at least 2 elements could collide
            +176                     this._solveCollisionCell( cell, callback );
            +177                 }
            +178             }
            +179         },
            +180 
            +181         _solveCollisionCell : function( cell, callback ) {
            +182             var i,j;
            +183 
            +184             for( i=0; i<cell.length; i++ ) {
            +185 
            +186                 var pivot= cell[i];
            +187                 this.r0.setBounds( pivot.x, pivot.y, pivot.width, pivot.height );
            +188 
            +189                 for( j=i+1; j<cell.length; j++ ) {
            +190                     var c= cell[j];
            +191 
            +192                     if ( this.r0.intersects( this.r1.setBounds( c.x, c.y, c.width, c.height ) ) ) {
            +193                         callback( pivot, c );
            +194                     }
            +195                 }
            +196             }
            +197         },
            +198 
            +199         /**
            +200          *
            +201          * @param x
            +202          * @param y
            +203          * @param w
            +204          * @param h
            +205          * @param oncollide function that returns boolean. if returns true, stop testing collision.
            +206          */
            +207         collide : function( x,y,w,h, oncollide ) {
            +208             x|=0;
            +209             y|=0;
            +210             w|=0;
            +211             h|=0;
            +212 
            +213             var cells= this.__getCells( x,y,w,h );
            +214             var i,j,l;
            +215             var el= this.elements;
            +216 
            +217             this.r0.setBounds( x,y,w,h );
            +218 
            +219             for( i=0; i<cells.length; i++ ) {
            +220                 var cell= cells[i];
            +221 
            +222                 var elcell= el[cell];
            +223                 for( j=0, l=elcell.length; j<l; j++ ) {
            +224                     var obj= elcell[j];
            +225 
            +226                     this.r1.setBounds( obj.x, obj.y, obj.width, obj.height );
            +227 
            +228                     // collides
            +229                     if ( this.r0.intersects( this.r1 ) ) {
            +230                         if ( oncollide(obj) ) {
            +231                             return;
            +232                         }
            +233                     }
            +234                 }
            +235             }
            +236         }
            +237 
            +238     }
            +239 });
            +240 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_ColorUtil_Color.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_ColorUtil_Color.js.html new file mode 100644 index 0000000..3cb5b8f --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_ColorUtil_Color.js.html @@ -0,0 +1,301 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * @author: Mario Gonzalez (@onedayitwilltake) and Ibon Tolosana (@hyperandroid)
            +  5  *
            +  6  * Helper classes for color manipulation.
            +  7  *
            +  8  **/
            +  9 
            + 10 CAAT.Module({
            + 11 
            + 12     /**
            + 13      * @name ColorUtil
            + 14      * @memberOf CAAT.Module
            + 15      * @namespace
            + 16      */
            + 17 
            + 18     /**
            + 19      * @name Color
            + 20      * @memberOf CAAT.Module.ColorUtil
            + 21      * @namespace
            + 22      */
            + 23 
            + 24 
            + 25     defines:"CAAT.Module.ColorUtil.Color",
            + 26     depends:[
            + 27     ],
            + 28     constants:{
            + 29 
            + 30         /**
            + 31          * @lends CAAT.Module.ColorUtil.Color
            + 32          */
            + 33 
            + 34         /**
            + 35          * Enumeration to define types of color ramps.
            + 36          * @enum {number}
            + 37          */
            + 38         RampEnumeration:{
            + 39             RAMP_RGBA:0,
            + 40             RAMP_RGB:1,
            + 41             RAMP_CHANNEL_RGB:2,
            + 42             RAMP_CHANNEL_RGBA:3,
            + 43             RAMP_CHANNEL_RGB_ARRAY:4,
            + 44             RAMP_CHANNEL_RGBA_ARRAY:5
            + 45         },
            + 46 
            + 47         /**
            + 48          * HSV to RGB color conversion
            + 49          * <p>
            + 50          * H runs from 0 to 360 degrees<br>
            + 51          * S and V run from 0 to 100
            + 52          * <p>
            + 53          * Ported from the excellent java algorithm by Eugene Vishnevsky at:
            + 54          * http://www.cs.rit.edu/~ncs/color/t_convert.html
            + 55          *
            + 56          * @static
            + 57          */
            + 58         hsvToRgb:function (h, s, v) {
            + 59             var r, g, b, i, f, p, q, t;
            + 60 
            + 61             // Make sure our arguments stay in-range
            + 62             h = Math.max(0, Math.min(360, h));
            + 63             s = Math.max(0, Math.min(100, s));
            + 64             v = Math.max(0, Math.min(100, v));
            + 65 
            + 66             // We accept saturation and value arguments from 0 to 100 because that's
            + 67             // how Photoshop represents those values. Internally, however, the
            + 68             // saturation and value are calculated from a range of 0 to 1. We make
            + 69             // That conversion here.
            + 70             s /= 100;
            + 71             v /= 100;
            + 72 
            + 73             if (s === 0) {
            + 74                 // Achromatic (grey)
            + 75                 r = g = b = v;
            + 76                 return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
            + 77             }
            + 78 
            + 79             h /= 60; // sector 0 to 5
            + 80             i = Math.floor(h);
            + 81             f = h - i; // factorial part of h
            + 82             p = v * (1 - s);
            + 83             q = v * (1 - s * f);
            + 84             t = v * (1 - s * (1 - f));
            + 85 
            + 86             switch (i) {
            + 87                 case 0:
            + 88                     r = v;
            + 89                     g = t;
            + 90                     b = p;
            + 91                     break;
            + 92 
            + 93                 case 1:
            + 94                     r = q;
            + 95                     g = v;
            + 96                     b = p;
            + 97                     break;
            + 98 
            + 99                 case 2:
            +100                     r = p;
            +101                     g = v;
            +102                     b = t;
            +103                     break;
            +104 
            +105                 case 3:
            +106                     r = p;
            +107                     g = q;
            +108                     b = v;
            +109                     break;
            +110 
            +111                 case 4:
            +112                     r = t;
            +113                     g = p;
            +114                     b = v;
            +115                     break;
            +116 
            +117                 default: // case 5:
            +118                     r = v;
            +119                     g = p;
            +120                     b = q;
            +121             }
            +122 
            +123             return new CAAT.Module.ColorUtil.Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255));
            +124         },
            +125 
            +126         /**
            +127          * Interpolate the color between two given colors. The return value will be a calculated color
            +128          * among the two given initial colors which corresponds to the 'step'th color of the 'nsteps'
            +129          * calculated colors.
            +130          * @param r0 {number} initial color red component.
            +131          * @param g0 {number} initial color green component.
            +132          * @param b0 {number} initial color blue component.
            +133          * @param r1 {number} final color red component.
            +134          * @param g1 {number} final color green component.
            +135          * @param b1 {number} final color blue component.
            +136          * @param nsteps {number} number of colors to calculate including the two given colors. If 16 is passed as value,
            +137          * 14 colors plus the two initial ones will be calculated.
            +138          * @param step {number} return this color index of all the calculated colors.
            +139          *
            +140          * @return { {r{number}, g{number}, b{number}} } return an object with the new calculated color components.
            +141          * @static
            +142          */
            +143         interpolate:function (r0, g0, b0, r1, g1, b1, nsteps, step) {
            +144 
            +145             var r, g, b;
            +146 
            +147             if (step <= 0) {
            +148                 return {
            +149                     r:r0,
            +150                     g:g0,
            +151                     b:b0
            +152                 };
            +153             } else if (step >= nsteps) {
            +154                 return {
            +155                     r:r1,
            +156                     g:g1,
            +157                     b:b1
            +158                 };
            +159             }
            +160 
            +161             r = (r0 + (r1 - r0) / nsteps * step) >> 0;
            +162             g = (g0 + (g1 - g0) / nsteps * step) >> 0;
            +163             b = (b0 + (b1 - b0) / nsteps * step) >> 0;
            +164 
            +165             if (r > 255) {
            +166                 r = 255;
            +167             } else if (r < 0) {
            +168                 r = 0;
            +169             }
            +170             if (g > 255) {
            +171                 g = 255;
            +172             } else if (g < 0) {
            +173                 g = 0;
            +174             }
            +175             if (b > 255) {
            +176                 b = 255;
            +177             } else if (b < 0) {
            +178                 b = 0;
            +179             }
            +180 
            +181             return {
            +182                 r:r,
            +183                 g:g,
            +184                 b:b
            +185             };
            +186         },
            +187 
            +188         /**
            +189          * Generate a ramp of colors from an array of given colors.
            +190          * @param fromColorsArray {[number]} an array of colors. each color is defined by an integer number from which
            +191          * color components will be extracted. Be aware of the alpha component since it will also be interpolated for
            +192          * new colors.
            +193          * @param rampSize {number} number of colors to produce.
            +194          * @param returnType {CAAT.ColorUtils.RampEnumeration} a value of CAAT.ColorUtils.RampEnumeration enumeration.
            +195          *
            +196          * @return { [{number},{number},{number},{number}] } an array of integers each of which represents a color of
            +197          * the calculated color ramp.
            +198          *
            +199          * @static
            +200          */
            +201         makeRGBColorRamp:function (fromColorsArray, rampSize, returnType) {
            +202 
            +203             var ramp = [], nc = fromColorsArray.length - 1, chunk = rampSize / nc, i, j,
            +204                 na, nr, ng, nb,
            +205                 c, a0, r0, g0, b0,
            +206                 c1, a1, r1, g1, b1,
            +207                 da, dr, dg, db;
            +208 
            +209             for (i = 0; i < nc; i += 1) {
            +210                 c = fromColorsArray[i];
            +211                 a0 = (c >> 24) & 0xff;
            +212                 r0 = (c & 0xff0000) >> 16;
            +213                 g0 = (c & 0xff00) >> 8;
            +214                 b0 = c & 0xff;
            +215 
            +216                 c1 = fromColorsArray[i + 1];
            +217                 a1 = (c1 >> 24) & 0xff;
            +218                 r1 = (c1 & 0xff0000) >> 16;
            +219                 g1 = (c1 & 0xff00) >> 8;
            +220                 b1 = c1 & 0xff;
            +221 
            +222                 da = (a1 - a0) / chunk;
            +223                 dr = (r1 - r0) / chunk;
            +224                 dg = (g1 - g0) / chunk;
            +225                 db = (b1 - b0) / chunk;
            +226 
            +227                 for (j = 0; j < chunk; j += 1) {
            +228                     na = (a0 + da * j) >> 0;
            +229                     nr = (r0 + dr * j) >> 0;
            +230                     ng = (g0 + dg * j) >> 0;
            +231                     nb = (b0 + db * j) >> 0;
            +232 
            +233                     var re = CAAT.Module.ColorUtil.Color.RampEnumeration;
            +234 
            +235                     switch (returnType) {
            +236                         case re.RAMP_RGBA:
            +237                             ramp.push('argb(' + na + ',' + nr + ',' + ng + ',' + nb + ')');
            +238                             break;
            +239                         case re.RAMP_RGB:
            +240                             ramp.push('rgb(' + nr + ',' + ng + ',' + nb + ')');
            +241                             break;
            +242                         case re.RAMP_CHANNEL_RGB:
            +243                             ramp.push(0xff000000 | nr << 16 | ng << 8 | nb);
            +244                             break;
            +245                         case re.RAMP_CHANNEL_RGBA:
            +246                             ramp.push(na << 24 | nr << 16 | ng << 8 | nb);
            +247                             break;
            +248                         case re.RAMP_CHANNEL_RGBA_ARRAY:
            +249                             ramp.push([ nr, ng, nb, na ]);
            +250                             break;
            +251                         case re.RAMP_CHANNEL_RGB_ARRAY:
            +252                             ramp.push([ nr, ng, nb ]);
            +253                             break;
            +254                     }
            +255                 }
            +256             }
            +257 
            +258             return ramp;
            +259 
            +260         },
            +261 
            +262         random:function () {
            +263             var a = '0123456789abcdef';
            +264             var c = '#';
            +265             for (var i = 0; i < 3; i++) {
            +266                 c += a[ (Math.random() * a.length) >> 0 ];
            +267             }
            +268             return c;
            +269         }
            +270     },
            +271 
            +272     extendsWith:{
            +273         __init:function (r, g, b) {
            +274             this.r = r || 255;
            +275             this.g = g || 255;
            +276             this.b = b || 255;
            +277             return this;
            +278         },
            +279 
            +280         r:255,
            +281         g:255,
            +282         b:255,
            +283 
            +284         /**
            +285          * Get color hexadecimal representation.
            +286          * @return {string} a string with color hexadecimal representation.
            +287          */
            +288         toHex:function () {
            +289             // See: http://jsperf.com/rgb-decimal-to-hex/5
            +290             return ('000000' + ((this.r << 16) + (this.g << 8) + this.b).toString(16)).slice(-6);
            +291         }
            +292     }
            +293 });
            +294 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Debug_Debug.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Debug_Debug.js.html new file mode 100644 index 0000000..8ea2dc4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Debug_Debug.js.html @@ -0,0 +1,473 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Get realtime Debug information of CAAT's activity.
            +  5  * Set CAAT.DEBUG=1 before any CAAT.Director object creation.
            +  6  * This class creates a DOM node called 'caat-debug' and associated styles
            +  7  * The debug panel is minimized by default and shows short information. It can be expanded and minimized again by clicking on it
            +  8  *
            +  9  */
            + 10 
            + 11 CAAT.Module( {
            + 12 
            + 13     /**
            + 14      * @name Debug
            + 15      * @memberOf CAAT.Module
            + 16      * @namespace
            + 17      */
            + 18 
            + 19     /**
            + 20      * @name Debug
            + 21      * @memberOf CAAT.Module.Debug
            + 22      * @constructor
            + 23      */
            + 24 
            + 25     defines : "CAAT.Module.Debug.Debug",
            + 26     depends : [
            + 27         "CAAT.Event.AnimationLoop"
            + 28     ],
            + 29     extendsWith : {
            + 30 
            + 31         /**
            + 32          * @lends CAAT.Module.Debug.Debug.prototype
            + 33          */
            + 34 
            + 35         width:              0,
            + 36         height:             0,
            + 37         canvas:             null,
            + 38         ctx:                null,
            + 39         statistics:         null,
            + 40         framerate:          null,
            + 41         textContainer:      null,
            + 42         textFPS:            null,
            + 43         textEntitiesTotal:  null,
            + 44         textEntitiesActive: null,
            + 45         textDraws:          null,
            + 46         textDrawTime:       null,
            + 47         textRAFTime:        null,
            + 48         textDirtyRects:     null,
            + 49         textDiscardDR:      null,
            + 50 
            + 51         frameTimeAcc :      0,
            + 52         frameRAFAcc :       0,
            + 53 
            + 54         canDebug:           false,
            + 55 
            + 56         SCALE:  60,
            + 57 
            + 58         debugTpl: 
            + 59             "    <style type=\"text/css\">"+
            + 60             "        #caat-debug {"+
            + 61             "            z-index: 10000;"+
            + 62             "            position:fixed;"+
            + 63             "            bottom:0;"+
            + 64             "            left:0;"+
            + 65             "            width:100%;"+
            + 66             "            background-color: rgba(0,0,0,0.8);"+
            + 67             "        }"+
            + 68             "        #caat-debug.caat_debug_max {"+
            + 69             "            margin-bottom: 0px;"+
            + 70             "        }"+
            + 71             "        .caat_debug_bullet {"+
            + 72             "            display:inline-block;"+
            + 73             "            background-color:#f00;"+
            + 74             "            width:8px;"+
            + 75             "            height:8px;"+
            + 76             "            border-radius: 4px;"+
            + 77             "            margin-left:10px;"+
            + 78             "            margin-right:2px;"+
            + 79             "        }"+
            + 80             "        .caat_debug_description {"+
            + 81             "            font-size:11px;"+
            + 82             "            font-family: helvetica, arial;"+
            + 83             "            color: #aaa;"+
            + 84             "            display: inline-block;"+
            + 85             "        }"+
            + 86             "        .caat_debug_value {"+
            + 87             "            font-size:11px;"+
            + 88             "            font-family: helvetica, arial;"+
            + 89             "            color: #fff;"+
            + 90             "            width:25px;"+
            + 91             "            text-align: right;"+
            + 92             "            display: inline-block;"+
            + 93             "            margin-right: .3em;"+
            + 94             "        }"+
            + 95             "        .caat_debug_indicator {"+
            + 96             "            float: right;"+
            + 97             "        }"+
            + 98             "        #debug_tabs {"+
            + 99             "            border-top: 1px solid #888;"+
            +100             "            height:25px;"+
            +101             "        }"+
            +102             "        .tab_max_min {"+
            +103             "            font-family: helvetica, arial;"+
            +104             "            font-size: 12px;"+
            +105             "            font-weight: bold;"+
            +106             "            color: #888;"+
            +107             "            border-right: 1px solid #888;"+
            +108             "            float: left;"+
            +109             "            cursor: pointer;"+
            +110             "            padding-left: 5px;"+
            +111             "            padding-right: 5px;"+
            +112             "            padding-top: 5px;"+
            +113             "            height: 20px;"+
            +114             "        }"+
            +115             "        .debug_tabs_content_hidden {"+
            +116             "            display: none;"+
            +117             "            width: 100%;"+
            +118             "        }"+
            +119             "        .debug_tabs_content_visible {"+
            +120             "            display: block;"+
            +121             "            width: 100%;"+
            +122             "        }"+
            +123             "        .checkbox_enabled {"+
            +124             "            display:inline-block;"+
            +125             "            background-color:#eee;"+
            +126             "            border: 1px solid #eee;"+
            +127             "            width:6px;"+
            +128             "            height:8px;"+
            +129             "            margin-left:12px;"+
            +130             "            margin-right:2px;"+
            +131             "            cursor: pointer;"+
            +132             "        }"+
            +133             "        .checkbox_disabled {"+
            +134             "            display:inline-block;"+
            +135             "            width:6px;"+
            +136             "            height:8px;"+
            +137             "            background-color: #333;"+
            +138             "            border: 1px solid #eee;"+
            +139             "            margin-left:12px;"+
            +140             "            margin-right:2px;"+
            +141             "            cursor: pointer;"+
            +142             "        }"+
            +143             "        .checkbox_description {"+
            +144             "            font-size:11px;"+
            +145             "            font-family: helvetica, arial;"+
            +146             "            color: #fff;"+
            +147             "        }"+
            +148             "        .debug_tab {"+
            +149             "            font-family: helvetica, arial;"+
            +150             "            font-size: 12px;"+
            +151             "            color: #fff;"+
            +152             "            border-right: 1px solid #888;"+
            +153             "            float: left;"+
            +154             "            padding-left: 5px;"+
            +155             "            padding-right: 5px;"+
            +156             "            height: 20px;"+
            +157             "            padding-top: 5px;"+
            +158             "            cursor: default;"+
            +159             "        }"+
            +160             "        .debug_tab_selected {"+
            +161             "            background-color: #444;"+
            +162             "            cursor: default;"+
            +163             "        }"+
            +164             "        .debug_tab_not_selected {"+
            +165             "            background-color: #000;"+
            +166             "            cursor: pointer;"+
            +167             "        }"+
            +168             "    </style>"+
            +169             "    <div id=\"caat-debug\">"+
            +170             "        <div id=\"debug_tabs\">"+
            +171             "            <span class=\"tab_max_min\" onCLick=\"javascript: var debug = document.getElementById('debug_tabs_content');if (debug.className === 'debug_tabs_content_visible') {debug.className = 'debug_tabs_content_hidden'} else {debug.className = 'debug_tabs_content_visible'}\"> CAAT Debug panel </span>"+
            +172             "            <span id=\"caat-debug-tab0\" class=\"debug_tab debug_tab_selected\">Performance</span>"+
            +173             "            <span id=\"caat-debug-tab1\" class=\"debug_tab debug_tab_not_selected\">Controls</span>"+
            +174             "            <span class=\"caat_debug_indicator\">"+
            +175             "                <span class=\"caat_debug_bullet\" style=\"background-color:#0f0;\"></span>"+
            +176             "                <span class=\"caat_debug_description\">Draw Time: </span>"+
            +177             "                <span class=\"caat_debug_value\" id=\"textDrawTime\">5.46</span>"+
            +178             "                <span class=\"caat_debug_description\">ms.</span>"+
            +179             "            </span>"+
            +180             "            <span class=\"caat_debug_indicator\">"+
            +181             "                <span class=\"caat_debug_bullet\" style=\"background-color:#f00;\"></span>"+
            +182             "                <span class=\"caat_debug_description\">FPS: </span>"+
            +183             "                <span class=\"caat_debug_value\" id=\"textFPS\">48</span>"+
            +184             "            </span>"+
            +185             "        </div>"+
            +186             "        <div id=\"debug_tabs_content\" class=\"debug_tabs_content_hidden\">"+
            +187             "            <div id=\"caat-debug-tab0-content\">"+
            +188             "                <canvas id=\"caat-debug-canvas\" height=\"60\"></canvas>"+
            +189             "                <div>"+
            +190             "                    <span>"+
            +191             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#0f0;\"></span>"+
            +192             "                        <span class=\"caat_debug_description\">RAF Time:</span>"+
            +193             "                        <span class=\"caat_debug_value\" id=\"textRAFTime\">20.76</span>"+
            +194             "                        <span class=\"caat_debug_description\">ms.</span>"+
            +195             "                    </span>"+
            +196             "                    <span>"+
            +197             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#0ff;\"></span>"+
            +198             "                        <span class=\"caat_debug_description\">Entities Total: </span>"+
            +199             "                        <span class=\"caat_debug_value\" id=\"textEntitiesTotal\">41</span>"+
            +200             "                    </span>"+
            +201             "                    <span>"+
            +202             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#0ff;\"></span>"+
            +203             "                        <span class=\"caat_debug_description\">Entities Active: </span>"+
            +204             "                        <span class=\"caat_debug_value\" id=\"textEntitiesActive\">37</span>"+
            +205             "                    </span>"+
            +206             "                    <span>"+
            +207             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#00f;\"></span>"+
            +208             "                        <span class=\"caat_debug_description\">Draws: </span>"+
            +209             "                        <span class=\"caat_debug_value\" id=\"textDraws\">0</span>"+
            +210             "                    </span>"+
            +211             "                    <span>"+
            +212             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#00f;\"></span>"+
            +213             "                        <span class=\"caat_debug_description\">DirtyRects: </span>"+
            +214             "                        <span class=\"caat_debug_value\" id=\"textDirtyRects\">0</span>"+
            +215             "                    </span>"+
            +216             "                    <span>"+
            +217             "                        <span class=\"caat_debug_bullet\" style=\"background-color:#00f;\"></span>"+
            +218             "                        <span class=\"caat_debug_description\">Discard DR: </span>"+
            +219             "                        <span class=\"caat_debug_value\" id=\"textDiscardDR\">0</span>"+
            +220             "                    </span>"+
            +221             "                </div>"+
            +222             "            </div>"+
            +223             "            <div id=\"caat-debug-tab1-content\">"+
            +224             "                <div>"+
            +225             "                    <div>"+
            +226             "                        <span id=\"control-sound\"></span>"+
            +227             "                        <span class=\"checkbox_description\">Sound</span>"+
            +228             "                    </div>"+
            +229             "                    <div>"+
            +230             "                        <span id=\"control-music\"></span>"+
            +231             "                        <span class=\"checkbox_description\">Music</span>"+
            +232             "                    </div>"+
            +233             "                    <div>"+
            +234             "                        <span id=\"control-aabb\"></span>"+
            +235             "                        <span class=\"checkbox_description\">AA Bounding Boxes</span>"+
            +236             "                    </div>"+
            +237             "                    <div>"+
            +238             "                        <span id=\"control-bb\"></span>"+
            +239             "                        <span class=\"checkbox_description\">Bounding Boxes</span>"+
            +240             "                    </div>"+
            +241             "                    <div>"+
            +242             "                        <span id=\"control-dr\"></span>"+
            +243             "                        <span class=\"checkbox_description\">Dirty Rects</span>"+
            +244             "                    </div>"+
            +245             "                </div>"+
            +246             "            </div>"+
            +247             "        </div>"+
            +248             "    </div>",
            +249 
            +250 
            +251         setScale : function(s) {
            +252             this.scale= s;
            +253             return this;
            +254         },
            +255 
            +256         initialize: function(w,h) {
            +257             w= window.innerWidth;
            +258 
            +259             this.width= w;
            +260             this.height= h;
            +261 
            +262             this.framerate = {
            +263                 refreshInterval: CAAT.FPS_REFRESH || 500,   // refresh every ? ms, updating too quickly gives too large rounding errors
            +264                 frames: 0,                                  // number offrames since last refresh
            +265                 timeLastRefresh: 0,                         // When was the framerate counter refreshed last
            +266                 fps: 0,                                     // current framerate
            +267                 prevFps: -1,                                // previously drawn FPS
            +268                 fpsMin: 1000,                               // minimum measured framerate
            +269                 fpsMax: 0                                   // maximum measured framerate
            +270             };
            +271 
            +272             var debugContainer= document.getElementById('caat-debug');
            +273             if (!debugContainer) {
            +274                 var wrap = document.createElement('div');
            +275                 wrap.innerHTML=this.debugTpl;
            +276                 document.body.appendChild(wrap);
            +277 
            +278                 eval( ""+
            +279                     " var __x= CAAT;" +
            +280                     "        function initCheck( name, bool, callback ) {"+
            +281                     "            var elem= document.getElementById(name);"+
            +282                     "            if ( elem ) {"+
            +283                     "                elem.className= (bool) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+
            +284                     "                if ( callback ) {"+
            +285                     "                    elem.addEventListener( \"click\", (function(elem, callback) {"+
            +286                     "                        return function(e) {"+
            +287                     "                            elem.__value= !elem.__value;"+
            +288                     "                            elem.className= (elem.__value) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+
            +289                     "                            callback(e,elem.__value);"+
            +290                     "                        }"+
            +291                     "                    })(elem, callback), false );"+
            +292                     "                }"+
            +293                     "                elem.__value= bool;"+
            +294                     "            }"+
            +295                     "        }"+
            +296                     "        function setupTabs() {"+
            +297                     "            var numTabs=0;"+
            +298                     "            var elem;"+
            +299                     "            var elemContent;"+
            +300                     "            do {"+
            +301                     "                elem= document.getElementById(\"caat-debug-tab\"+numTabs);"+
            +302                     "                if ( elem ) {"+
            +303                     "                    elemContent= document.getElementById(\"caat-debug-tab\"+numTabs+\"-content\");"+
            +304                     "                    if ( elemContent ) {"+
            +305                     "                        elemContent.style.display= numTabs===0 ? 'block' : 'none';"+
            +306                     "                        elem.className= numTabs===0 ? \"debug_tab debug_tab_selected\" : \"debug_tab debug_tab_not_selected\";"+
            +307                     "                        elem.addEventListener( \"click\", (function(tabIndex) {"+
            +308                     "                            return function(e) {"+
            +309                     "                                for( var i=0; i<numTabs; i++ ) {"+
            +310                     "                                    var _elem= document.getElementById(\"caat-debug-tab\"+i);"+
            +311                     "                                    var _elemContent= document.getElementById(\"caat-debug-tab\"+i+\"-content\");"+
            +312                     "                                    _elemContent.style.display= i===tabIndex ? 'block' : 'none';"+
            +313                     "                                    _elem.className= i===tabIndex ? \"debug_tab debug_tab_selected\" : \"debug_tab debug_tab_not_selected\";"+
            +314                     "                                }"+
            +315                     "                            }"+
            +316                     "                        })(numTabs), false );"+
            +317                     "                    }"+
            +318                     "                    numTabs++;"+
            +319                     "                }"+
            +320                     "            } while( elem );"+
            +321                     "        }"+
            +322                     "        initCheck( \"control-sound\", __x.director[0].isSoundEffectsEnabled(), function(e, bool) {"+
            +323                     "            __x.director[0].setSoundEffectsEnabled(bool);"+
            +324                     "        } );"+
            +325                     "        initCheck( \"control-music\", __x.director[0].isMusicEnabled(), function(e, bool) {"+
            +326                     "            __x.director[0].setMusicEnabled(bool);"+
            +327                     "        } );"+
            +328                     "        initCheck( \"control-aabb\", CAAT.DEBUGBB, function(e,bool) {"+
            +329                     "            CAAT.DEBUGAABB= bool;"+
            +330                     "            __x.director[0].currentScene.dirty= true;"+
            +331                     "        } );"+
            +332                     "        initCheck( \"control-bb\", CAAT.DEBUGBB, function(e,bool) {"+
            +333                     "            CAAT.DEBUGBB= bool;"+
            +334                     "            if ( bool ) {"+
            +335                     "                CAAT.DEBUGAABB= true;"+
            +336                     "            }"+
            +337                     "            __x.director[0].currentScene.dirty= true;"+
            +338                     "        } );"+
            +339                     "        initCheck( \"control-dr\", CAAT.DEBUG_DIRTYRECTS , function( e,bool ) {"+
            +340                     "            CAAT.DEBUG_DIRTYRECTS= bool;"+
            +341                     "        });"+
            +342                     "        setupTabs();" );
            +343 
            +344             }
            +345 
            +346             this.canvas= document.getElementById('caat-debug-canvas');
            +347             if ( null===this.canvas ) {
            +348                 this.canDebug= false;
            +349                 return;
            +350             }
            +351 
            +352             this.canvas.width= w;
            +353             this.canvas.height=h;
            +354             this.ctx= this.canvas.getContext('2d');
            +355 
            +356             this.ctx.fillStyle= '#000';
            +357             this.ctx.fillRect(0,0,this.width,this.height);
            +358 
            +359             this.textFPS= document.getElementById("textFPS");
            +360             this.textDrawTime= document.getElementById("textDrawTime");
            +361             this.textRAFTime= document.getElementById("textRAFTime");
            +362             this.textEntitiesTotal= document.getElementById("textEntitiesTotal");
            +363             this.textEntitiesActive= document.getElementById("textEntitiesActive");
            +364             this.textDraws= document.getElementById("textDraws");
            +365             this.textDirtyRects= document.getElementById("textDirtyRects");
            +366             this.textDiscardDR= document.getElementById("textDiscardDR");
            +367 
            +368 
            +369             this.canDebug= true;
            +370 
            +371             return this;
            +372         },
            +373 
            +374         debugInfo : function( statistics ) {
            +375             this.statistics= statistics;
            +376 
            +377             var cc= CAAT;
            +378 
            +379             this.frameTimeAcc+= cc.FRAME_TIME;
            +380             this.frameRAFAcc+= cc.REQUEST_ANIMATION_FRAME_TIME;
            +381 
            +382             /* Update the framerate counter */
            +383             this.framerate.frames++;
            +384             var tt= new Date().getTime() ;
            +385             if ( tt> this.framerate.timeLastRefresh + this.framerate.refreshInterval ) {
            +386                 this.framerate.fps = ( ( this.framerate.frames * 1000 ) / ( tt - this.framerate.timeLastRefresh ) ) | 0;
            +387                 this.framerate.fpsMin = this.framerate.frames > 0 ? Math.min( this.framerate.fpsMin, this.framerate.fps ) : this.framerate.fpsMin;
            +388                 this.framerate.fpsMax = Math.max( this.framerate.fpsMax, this.framerate.fps );
            +389 
            +390                 this.textFPS.innerHTML= this.framerate.fps;
            +391 
            +392                 var value= ((this.frameTimeAcc*100/this.framerate.frames)|0)/100;
            +393                 this.frameTimeAcc=0;
            +394                 this.textDrawTime.innerHTML= value;
            +395 
            +396                 var value2= ((this.frameRAFAcc*100/this.framerate.frames)|0)/100;
            +397                 this.frameRAFAcc=0;
            +398                 this.textRAFTime.innerHTML= value2;
            +399 
            +400                 this.framerate.timeLastRefresh = tt;
            +401                 this.framerate.frames = 0;
            +402 
            +403                 this.paint(value2);
            +404             }
            +405 
            +406             this.textEntitiesTotal.innerHTML= this.statistics.size_total;
            +407             this.textEntitiesActive.innerHTML= this.statistics.size_active;
            +408             this.textDirtyRects.innerHTML= this.statistics.size_dirtyRects;
            +409             this.textDraws.innerHTML= this.statistics.draws;
            +410             this.textDiscardDR.innerHTML= this.statistics.size_discarded_by_dirty_rects;
            +411         },
            +412 
            +413         paint : function( rafValue ) {
            +414             var ctx= this.ctx;
            +415             var t=0;
            +416 
            +417             ctx.drawImage(
            +418                 this.canvas,
            +419                 1, 0, this.width-1, this.height,
            +420                 0, 0, this.width-1, this.height );
            +421 
            +422             ctx.strokeStyle= 'black';
            +423             ctx.beginPath();
            +424             ctx.moveTo( this.width-.5, 0 );
            +425             ctx.lineTo( this.width-.5, this.height );
            +426             ctx.stroke();
            +427 
            +428             ctx.strokeStyle= '#a22';
            +429             ctx.beginPath();
            +430             t= this.height-((20/this.SCALE*this.height)>>0)-.5;
            +431             ctx.moveTo( .5, t );
            +432             ctx.lineTo( this.width+.5, t );
            +433             ctx.stroke();
            +434 
            +435             ctx.strokeStyle= '#aa2';
            +436             ctx.beginPath();
            +437             t= this.height-((30/this.SCALE*this.height)>>0)-.5;
            +438             ctx.moveTo( .5, t );
            +439             ctx.lineTo( this.width+.5, t );
            +440             ctx.stroke();
            +441 
            +442             var fps = Math.min( this.height-(this.framerate.fps/this.SCALE*this.height), 59 );
            +443             if (-1===this.framerate.prevFps) {
            +444                 this.framerate.prevFps= fps|0;
            +445             }
            +446 
            +447             ctx.strokeStyle= '#0ff';//this.framerate.fps<15 ? 'red' : this.framerate.fps<30 ? 'yellow' : 'green';
            +448             ctx.beginPath();
            +449             ctx.moveTo( this.width, (fps|0)-.5 );
            +450             ctx.lineTo( this.width, this.framerate.prevFps-.5 );
            +451             ctx.stroke();
            +452 
            +453             this.framerate.prevFps= fps;
            +454 
            +455 
            +456             var t1= ((this.height-(rafValue/this.SCALE*this.height))>>0)-.5;
            +457             ctx.strokeStyle= '#ff0';
            +458             ctx.beginPath();
            +459             ctx.moveTo( this.width, t1 );
            +460             ctx.lineTo( this.width, t1 );
            +461             ctx.stroke();
            +462         }
            +463     }
            +464 
            +465 });
            +466 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Font_Font.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Font_Font.js.html new file mode 100644 index 0000000..6cda377 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Font_Font.js.html @@ -0,0 +1,387 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module({
            +  7 
            +  8     /**
            +  9      * @name Font
            + 10      * @memberOf CAAT.Module
            + 11      * @namespace
            + 12      */
            + 13 
            + 14     /**
            + 15      * @name Font
            + 16      * @memberOf CAAT.Module.Font
            + 17      * @constructor
            + 18      */
            + 19 
            + 20     defines : "CAAT.Module.Font.Font",
            + 21     aliases : "CAAT.Font",
            + 22     depends : [
            + 23         "CAAT.Foundation.SpriteImage"
            + 24     ],
            + 25     constants: {
            + 26 
            + 27         /**
            + 28          * @lends CAAT.Module.Font.Font
            + 29          */
            + 30 
            + 31         getFontMetrics:function (font) {
            + 32             var ret;
            + 33             if (CAAT.CSS_TEXT_METRICS) {
            + 34                 try {
            + 35                     ret = CAAT.Module.Font.Font.getFontMetricsCSS(font);
            + 36                     return ret;
            + 37                 } catch (e) {
            + 38 
            + 39                 }
            + 40             }
            + 41 
            + 42             return CAAT.Module.Font.Font.getFontMetricsNoCSS(font);
            + 43         },
            + 44 
            + 45         getFontMetricsNoCSS:function (font) {
            + 46 
            + 47             var re = /(\d+)p[x|t]\s*/i;
            + 48             var res = re.exec(font);
            + 49 
            + 50             var height;
            + 51 
            + 52             if (!res) {
            + 53                 height = 32;     // no px or pt value in font. assume 32.)
            + 54             } else {
            + 55                 height = res[1] | 0;
            + 56             }
            + 57 
            + 58             var ascent = height - 1;
            + 59             var h = (height + height * .2) | 0;
            + 60             return {
            + 61                 height:h,
            + 62                 ascent:ascent,
            + 63                 descent:h - ascent
            + 64             }
            + 65 
            + 66         },
            + 67 
            + 68         /**
            + 69          * Totally ripped from:
            + 70          *
            + 71          * jQuery (offset function)
            + 72          * Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas
            + 73          *
            + 74          * @param font
            + 75          * @return {*}
            + 76          */
            + 77         getFontMetricsCSS:function (font) {
            + 78 
            + 79             function offset(elem) {
            + 80 
            + 81                 var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left;
            + 82                 var doc = elem && elem.ownerDocument;
            + 83                 docElem = doc.documentElement;
            + 84 
            + 85                 box = elem.getBoundingClientRect();
            + 86                 //win = getWindow( doc );
            + 87 
            + 88                 body = document.body;
            + 89                 win = doc.nodeType === 9 ? doc.defaultView || doc.parentWindow : false;
            + 90 
            + 91                 clientTop = docElem.clientTop || body.clientTop || 0;
            + 92                 clientLeft = docElem.clientLeft || body.clientLeft || 0;
            + 93                 scrollTop = win.pageYOffset || docElem.scrollTop;
            + 94                 scrollLeft = win.pageXOffset || docElem.scrollLeft;
            + 95                 top = box.top + scrollTop - clientTop;
            + 96                 left = box.left + scrollLeft - clientLeft;
            + 97 
            + 98                 return { top:top, left:left };
            + 99             }
            +100 
            +101             try {
            +102                 var text = document.createElement("span");
            +103                 text.style.font = font;
            +104                 text.innerHTML = "Hg";
            +105 
            +106                 var block = document.createElement("div");
            +107                 block.style.display = "inline-block";
            +108                 block.style.width = "1px";
            +109                 block.style.heigh = "0px";
            +110 
            +111                 var div = document.createElement("div");
            +112                 div.appendChild(text);
            +113                 div.appendChild(block);
            +114 
            +115 
            +116                 var body = document.body;
            +117                 body.appendChild(div);
            +118 
            +119                 try {
            +120 
            +121                     var result = {};
            +122 
            +123                     block.style.verticalAlign = 'baseline';
            +124                     result.ascent = offset(block).top - offset(text).top;
            +125 
            +126                     block.style.verticalAlign = 'bottom';
            +127                     result.height = offset(block).top - offset(text).top;
            +128 
            +129                     result.ascent = Math.ceil(result.ascent);
            +130                     result.height = Math.ceil(result.height);
            +131 
            +132                     result.descent = result.height - result.ascent;
            +133 
            +134                     return result;
            +135 
            +136                 } finally {
            +137                     body.removeChild(div);
            +138                 }
            +139             } catch (e) {
            +140                 return null;
            +141             }
            +142         }
            +143     },
            +144     extendsWith:function () {
            +145 
            +146         var UNKNOWN_CHAR_WIDTH = 10;
            +147 
            +148         return {
            +149 
            +150             /**
            +151              * @lends CAAT.Module.Font.Font.prototype
            +152              */
            +153 
            +154             fontSize:10,
            +155             fontSizeUnit:"px",
            +156             font:'Sans-Serif',
            +157             fontStyle:'',
            +158             fillStyle:'#fff',
            +159             strokeStyle:null,
            +160             strokeSize:1,
            +161             padding:0,
            +162             image:null,
            +163             charMap:null,
            +164 
            +165             height:0,
            +166             ascent:0,
            +167             descent:0,
            +168 
            +169             setPadding:function (padding) {
            +170                 this.padding = padding;
            +171                 return this;
            +172             },
            +173 
            +174             setFontStyle:function (style) {
            +175                 this.fontStyle = style;
            +176                 return this;
            +177             },
            +178 
            +179             setStrokeSize:function (size) {
            +180                 this.strokeSize = size;
            +181                 return this;
            +182             },
            +183 
            +184             setFontSize:function (fontSize) {
            +185                 this.fontSize = fontSize;
            +186                 this.fontSizeUnit = 'px';
            +187                 return this;
            +188             },
            +189 
            +190             setFont:function (font) {
            +191                 this.font = font;
            +192                 return this;
            +193             },
            +194 
            +195             setFillStyle:function (style) {
            +196                 this.fillStyle = style;
            +197                 return this;
            +198             },
            +199 
            +200             setStrokeStyle:function (style) {
            +201                 this.strokeStyle = style;
            +202                 return this;
            +203             },
            +204 
            +205             createDefault:function (padding) {
            +206                 var str = "";
            +207                 for (var i = 32; i < 128; i++) {
            +208                     str = str + String.fromCharCode(i);
            +209                 }
            +210 
            +211                 return this.create(str, padding);
            +212             },
            +213 
            +214             create:function (chars, padding) {
            +215 
            +216                 padding = padding | 0;
            +217                 this.padding = padding;
            +218 
            +219                 var canvas = document.createElement('canvas');
            +220                 var ctx = canvas.getContext('2d');
            +221 
            +222                 ctx.textBaseline = 'bottom';
            +223                 ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font;
            +224 
            +225                 var textWidth = 0;
            +226                 var charWidth = [];
            +227                 var i;
            +228                 var x;
            +229                 var cchar;
            +230 
            +231                 for (i = 0; i < chars.length; i++) {
            +232                     var cw = Math.max(1, (ctx.measureText(chars.charAt(i)).width >> 0) + 1) + 2 * padding;
            +233                     charWidth.push(cw);
            +234                     textWidth += cw;
            +235                 }
            +236 
            +237 
            +238                 var fontMetrics = CAAT.Font.getFontMetrics(ctx.font);
            +239                 var baseline = "alphabetic", yoffset, canvasheight;
            +240 
            +241                 canvasheight = fontMetrics.height;
            +242                 this.ascent = fontMetrics.ascent;
            +243                 this.descent = fontMetrics.descent;
            +244                 this.height = fontMetrics.height;
            +245                 yoffset = fontMetrics.ascent;
            +246 
            +247                 canvas.width = textWidth;
            +248                 canvas.height = canvasheight;
            +249                 ctx = canvas.getContext('2d');
            +250 
            +251                 //ctx.textBaseline= 'bottom';
            +252                 ctx.textBaseline = baseline;
            +253                 ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font;
            +254                 ctx.fillStyle = this.fillStyle;
            +255                 ctx.strokeStyle = this.strokeStyle;
            +256 
            +257                 this.charMap = {};
            +258 
            +259                 x = 0;
            +260                 for (i = 0; i < chars.length; i++) {
            +261                     cchar = chars.charAt(i);
            +262                     ctx.fillText(cchar, x + padding, yoffset);
            +263                     if (this.strokeStyle) {
            +264                         ctx.beginPath();
            +265                         ctx.lineWidth = this.strokeSize;
            +266                         ctx.strokeText(cchar, x + padding, yoffset);
            +267                     }
            +268                     this.charMap[cchar] = {
            +269                         x:x + padding,
            +270                         width:charWidth[i] - 2 * padding,
            +271                         height: this.height
            +272                     };
            +273                     x += charWidth[i];
            +274                 }
            +275 
            +276                 this.image = canvas;
            +277 
            +278                 return this;
            +279             },
            +280 
            +281             setAsSpriteImage:function () {
            +282                 var cm = [];
            +283                 var _index = 0;
            +284                 for (var i in this.charMap) {
            +285                     var _char = i;
            +286                     var charData = this.charMap[i];
            +287 
            +288                     cm[i] = {
            +289                         id:_index++,
            +290                         height:this.height,
            +291                         xoffset:0,
            +292                         letter:_char,
            +293                         yoffset:0,
            +294                         width:charData.width,
            +295                         xadvance:charData.width,
            +296                         x:charData.x,
            +297                         y:0
            +298                     };
            +299                 }
            +300 
            +301                 this.spriteImage = new CAAT.Foundation.SpriteImage().initializeAsGlyphDesigner(this.image, cm);
            +302                 return this;
            +303             },
            +304 
            +305             getAscent:function () {
            +306                 return this.ascent;
            +307             },
            +308 
            +309             getDescent:function () {
            +310                 return this.descent;
            +311             },
            +312 
            +313             stringHeight:function () {
            +314                 return this.height;
            +315             },
            +316 
            +317             getFontData:function () {
            +318                 return {
            +319                     height:this.height,
            +320                     ascent:this.ascent,
            +321                     descent:this.descent
            +322                 };
            +323             },
            +324 
            +325             stringWidth:function (str) {
            +326                 var i, l, w = 0, c;
            +327 
            +328                 for (i = 0, l = str.length; i < l; i++) {
            +329                     c = this.charMap[ str.charAt(i) ];
            +330                     if (c) {
            +331                         w += c.width;
            +332                     } else {
            +333                         w += UNKNOWN_CHAR_WIDTH;
            +334                     }
            +335                 }
            +336 
            +337                 return w;
            +338             },
            +339 
            +340             drawText:function (str, ctx, x, y) {
            +341                 var i, l, charInfo, w;
            +342                 var height = this.image.height;
            +343 
            +344                 for (i = 0, l = str.length; i < l; i++) {
            +345                     charInfo = this.charMap[ str.charAt(i) ];
            +346                     if (charInfo) {
            +347                         w = charInfo.width;
            +348                         if ( w>0 && charInfo.height>0 ) {
            +349                             ctx.drawImage(
            +350                                 this.image,
            +351                                 charInfo.x, 0,
            +352                                 w, height,
            +353                                 x, y,
            +354                                 w, height);
            +355                         }
            +356                         x += w;
            +357                     } else {
            +358                         ctx.strokeStyle = '#f00';
            +359                         ctx.strokeRect(x, y, UNKNOWN_CHAR_WIDTH, height);
            +360                         x += UNKNOWN_CHAR_WIDTH;
            +361                     }
            +362                 }
            +363             },
            +364 
            +365             save:function () {
            +366                 var str = "image/png";
            +367                 var strData = this.image.toDataURL(str);
            +368                 document.location.href = strData.replace(str, "image/octet-stream");
            +369             },
            +370 
            +371             drawSpriteText:function (director, time) {
            +372                 this.spriteImage.drawSpriteText(director, time);
            +373             }
            +374 
            +375         }
            +376     }
            +377 
            +378 });
            +379 
            +380 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMBumpMapping.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMBumpMapping.js.html new file mode 100644 index 0000000..feee121 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMBumpMapping.js.html @@ -0,0 +1,275 @@ +
              1 CAAT.Module({
            +  2 
            +  3 
            +  4     /**
            +  5      * @name IMBumpMapping
            +  6      * @memberOf CAAT.Module.Image.ImageProcessor
            +  7      * @extends CAAT.Module.Image.ImageProcessor.ImageProcessor
            +  8      * @constructor
            +  9      */
            + 10 
            + 11 
            + 12     defines : "CAAT.Module.Image.ImageProcess.IMBumpMapping",
            + 13     depends : [
            + 14         "CAAT.Module.Image.ImageProcess.ImageProcessor"
            + 15     ],
            + 16     extendsClass : "CAAT.Module.Image.ImageProcess.ImageProcessor",
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Module.Image.ImageProcessor.IMBumpMapping.prototype
            + 21          */
            + 22 
            + 23         // bump
            + 24         m_avgX:         null,
            + 25         m_avgY:         null,
            + 26         m_tt:           null,
            + 27         phong:          null,
            + 28 
            + 29         m_radius:       75,
            + 30 
            + 31         m_lightcolor:   null,
            + 32         bcolor:         false,
            + 33         lightPosition:  [],
            + 34 
            + 35         /**
            + 36          * Initializes internal bump effect data.
            + 37          *
            + 38          * @param image {HTMLImageElement}
            + 39          * @param radius {number} lights radius.
            + 40          *
            + 41          * @private
            + 42          */
            + 43         prepareBump : function(image, radius) {
            + 44             var i,j;
            + 45 
            + 46             this.m_radius= (radius ? radius : 75);
            + 47 
            + 48             var imageData= this.grabPixels(image);
            + 49 
            + 50             this.m_tt= this.makeArray(this.height,0);
            + 51             for( i=0; i<this.height; i++ ){
            + 52                 this.m_tt[ i ]=this.width*i;
            + 53             }
            + 54 
            + 55             this.m_avgX= this.makeArray2D(this.height,this.width,0);
            + 56             this.m_avgY= this.makeArray2D(this.height,this.width,0);
            + 57 
            + 58             var bump=this.makeArray2D(this.height,this.width,0);
            + 59 
            + 60             if ( null===imageData ) {
            + 61                 return;
            + 62             }
            + 63             
            + 64             var sourceImagePixels= imageData.data;
            + 65 
            + 66             for (i=0;i<this.height;i++) {
            + 67                 for (j=0;j<this.width;j++) {
            + 68                     var pos= (i*this.width+j)*4;
            + 69                     bump[i][j]=
            + 70                         sourceImagePixels[pos  ]+
            + 71                         sourceImagePixels[pos+1]+
            + 72                         sourceImagePixels[pos+2];
            + 73                 }
            + 74             }
            + 75 
            + 76             bump= this.soften( bump );
            + 77 
            + 78             for (var x=1;x<this.width-1;x++)    {
            + 79                 for (var y=1;y<this.height-1;y++)   {
            + 80                     this.m_avgX[y][x]=Math.floor(bump[y][x+1]-bump[y][x-1]);
            + 81                     this.m_avgY[y][x]=Math.floor(bump[y+1][x]-bump[y-1][x]);
            + 82                 }
            + 83             }
            + 84 
            + 85             bump=null;
            + 86         },
            + 87         /**
            + 88          * Soften source images extracted data on prepareBump method.
            + 89          * @param bump bidimensional array of black and white source image version.
            + 90          * @return bidimensional array with softened version of source image's b&w representation.
            + 91          */
            + 92         soften : function( bump ) {
            + 93             var temp;
            + 94             var sbump=this.makeArray2D( this.height,this.width, 0);
            + 95 
            + 96             for (var j=0;j<this.width;j++) {
            + 97                 for (var i=0;i<this.height;i++) {
            + 98                     temp=(bump[i][j]);
            + 99                     temp+=(bump[(i+1)%this.height][j]);
            +100                     temp+=(bump[(i+this.height-1)%this.height][j]);
            +101                     temp+=(bump[i][(j+1)%this.width]);
            +102                     temp+=(bump[i][(j+this.width-1)%this.width]);
            +103                     temp+=(bump[(i+1)%this.height][(j+1)%this.width]);
            +104                     temp+=(bump[(i+this.height-1)%this.height][(j+this.width-1)%this.width]);
            +105                     temp+=(bump[(i+this.height-1)%this.height][(j+1)%this.width]);
            +106                     temp+=(bump[(i+1)%this.height][(j+this.width-1)%this.width]);
            +107                     temp/=9;
            +108                     sbump[i][j]=temp/3;
            +109                 }
            +110             }
            +111 
            +112             return sbump;
            +113         },
            +114         /**
            +115          * Create a phong image to apply bump effect.
            +116          * @private
            +117          */
            +118         calculatePhong : function( ) {
            +119             this.phong= this.makeArray2D(this.m_radius,this.m_radius,0);
            +120 
            +121             var i,j,z;
            +122             for( i=0; i<this.m_radius; i++ ) {
            +123                 for( j=0; j<this.m_radius; j++ ) {
            +124                     var x= j/this.m_radius;
            +125                     var y= i/this.m_radius;
            +126                     z= (1-Math.sqrt(x*x+y*y))*0.8;
            +127                     if ( z<0 ) {
            +128                         z=0;
            +129                     }
            +130                     this.phong[ i ][ j ]= Math.floor(z*255);
            +131                 }
            +132             }
            +133         },
            +134         /**
            +135          * Generates a bump image.
            +136          * @param dstPixels {ImageData.data} destinarion pixel array to store the calculated image.
            +137          */
            +138         drawColored : function(dstPixels)	{
            +139             var i,j,k;
            +140             for( i=0; i<this.height; i++ ) {
            +141                 for( j=0; j<this.width; j++ ){
            +142 
            +143                     var rrr=0;
            +144                     var ggg=0;
            +145                     var bbb=0;
            +146 
            +147                     for( k=0; k<this.m_lightcolor.length; k++ ) {
            +148 
            +149                         var lx= this.lightPosition[k].x;
            +150                         var ly= this.lightPosition[k].y;
            +151 
            +152                         var dx=Math.floor(Math.abs(this.m_avgX[i][j]-j+lx));
            +153                         var dy=Math.floor(Math.abs(this.m_avgY[i][j]-i+ly));
            +154 
            +155                         if (dx>=this.m_radius) {
            +156                             dx=this.m_radius-1;
            +157                         }
            +158                         if (dy>=this.m_radius) {
            +159                             dy=this.m_radius-1;
            +160                         }
            +161 
            +162                         var c= this.phong[ dx ] [ dy ];
            +163                         var r=0;
            +164                         var g=0;
            +165                         var b=0;
            +166 
            +167                         if ( c>=0 ) {// oscurecer
            +168                             r= (this.m_lightcolor[k][0]*c/128);
            +169                             g= (this.m_lightcolor[k][1]*c/128);
            +170                             b= (this.m_lightcolor[k][2]*c/128);
            +171                         }
            +172                         else {			// blanquear.
            +173                             c=128+c;
            +174                             var rr= (this.m_lightcolor[k][0]);
            +175                             var gg= (this.m_lightcolor[k][1]);
            +176                             var bb= (this.m_lightcolor[k][2]);
            +177 
            +178                             r= Math.floor(rr+ (255-rr)*c/128);
            +179                             g= Math.floor(gg+ (255-gg)*c/128);
            +180                             b= Math.floor(bb+ (255-bb)*c/128);
            +181                         }
            +182 
            +183                         rrr+=r;
            +184                         ggg+=g;
            +185                         bbb+=b;
            +186                     }
            +187 
            +188                     if ( rrr>255 ) {
            +189                         rrr=255;
            +190                     }
            +191                     if ( ggg>255 ) {
            +192                         ggg=255;
            +193                     }
            +194                     if ( bbb>255 ) {
            +195                         bbb=255;
            +196                     }
            +197 
            +198                     var pos= (j+this.m_tt[i])*4;
            +199                     dstPixels[pos  ]= rrr;
            +200                     dstPixels[pos+1]= ggg;
            +201                     dstPixels[pos+2]= bbb;
            +202                     dstPixels[pos+3]= 255;
            +203                 }
            +204             }
            +205         },
            +206         /**
            +207          * Sets lights color.
            +208          * @param colors_rgb_array an array of arrays. Each internal array has three integers defining an RGB color.
            +209          * ie:
            +210          *  [
            +211          *     [ 255,0,0 ],
            +212          *     [ 0,255,0 ]
            +213          *  ]
            +214          * @return this
            +215          */
            +216         setLightColors : function( colors_rgb_array ) {
            +217             this.m_lightcolor= colors_rgb_array;
            +218             this.lightPosition= [];
            +219             for( var i=0; i<this.m_lightcolor.length; i++ ) {
            +220                 var x= this.width*Math.random();
            +221                 var y= this.height*Math.random();
            +222                 this.lightPosition.push( new CAAT.Math.Point().set(x,y) );
            +223             }
            +224             return this;
            +225         },
            +226         /**
            +227          * Initialize the bump image processor.
            +228          * @param image {HTMLImageElement} source image to bump.
            +229          * @param radius {number} light radius.
            +230          */
            +231         initialize : function(image,radius) {
            +232             CAAT.Module.Image.ImageProcess.IMBumpMapping.superclass.initialize.call(this,image.width,image.height);
            +233 
            +234             this.setLightColors(
            +235                     [
            +236                         [255,128,0],
            +237                         [0,0,255]
            +238                     ]);
            +239 
            +240             this.prepareBump(image,radius);
            +241             this.calculatePhong();
            +242 
            +243             return this;
            +244         },
            +245         /**
            +246          * Set a light position.
            +247          * @param lightIndex {number} light index to position.
            +248          * @param x {number} light x coordinate.
            +249          * @param y {number} light y coordinate.
            +250          * @return this
            +251          */
            +252         setLightPosition : function( lightIndex, x, y ) {
            +253             this.lightPosition[lightIndex].set(x,y);
            +254             return this;
            +255         },
            +256         /**
            +257          * Applies the bump effect and makes it visible on the canvas surface.
            +258          * @param director {CAAT.Director}
            +259          * @param time {number}
            +260          */
            +261         applyIM : function(director,time) {
            +262             this.drawColored(this.bufferImage);
            +263             return CAAT.Module.Image.ImageProcess.IMBumpMapping.superclass.applyIM.call(this,director,time);
            +264         }
            +265     }
            +266 
            +267 });
            +268 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMPlasma.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMPlasma.js.html new file mode 100644 index 0000000..b4f6d49 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMPlasma.js.html @@ -0,0 +1,181 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name IMPlasma
            +  5      * @memberOf CAAT.Module.Image.ImageProcessor
            +  6      * @extends CAAT.Module.Image.ImageProcessor.ImageProcessor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10 
            + 11     defines : "CAAT.Module.Image.ImageProcess.IMPlasma",
            + 12     depends : [
            + 13         "CAAT.Module.Image.ImageProcess.ImageProcessor",
            + 14         "CAAT.Module.ColorUtil.Color"
            + 15     ],
            + 16     extendsClass : "CAAT.Module.Image.ImageProcess.ImageProcessor",
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Module.Image.ImageProcessor.IMPlasma.prototype
            + 21          */
            + 22 
            + 23         wavetable: null,
            + 24         m_colorMap: null,
            + 25         spd1: 1,
            + 26         spd2: 2,
            + 27         spd3: 3,
            + 28         spd4: 4,
            + 29         pos1: 0,
            + 30         pos2: 0,
            + 31         pos3: 0,
            + 32         pos4: 0,
            + 33         tpos1: 0,
            + 34         tpos2: 0,
            + 35         tpos3: 0,
            + 36         tpos4: 0,
            + 37         m_colorMapSize: 256,
            + 38         i1: 0,
            + 39         i2: 0,
            + 40         i3: 0,
            + 41         i4: 0,
            + 42         b1: false,
            + 43         b2: false,
            + 44         b3: false,
            + 45         b4: false,
            + 46 
            + 47         color: [0xffffffff, 0xffff00ff, 0xffffff00, 0xff00ff00, 0xffff0000, 0xff0000ff, 0xff000000],
            + 48 
            + 49         /**
            + 50          * Initialize the plasma image processor.
            + 51          * <p>
            + 52          * This image processor creates a color ramp of 256 elements from the colors of the parameter 'colors'.
            + 53          * Be aware of color definition since the alpha values count to create the ramp.
            + 54          *
            + 55          * @param width {number}
            + 56          * @param height {number}
            + 57          * @param colors {Array.<number>} an array of color values.
            + 58          *
            + 59          * @return this
            + 60          */
            + 61         initialize : function(width,height,colors) {
            + 62             CAAT.IMPlasma.superclass.initialize.call(this,width,height);
            + 63 
            + 64             this.wavetable= [];
            + 65             for (var x=0; x<256; x++)   {
            + 66                 this.wavetable.push( Math.floor(32 * (1 + Math.cos(x*2 * Math.PI / 256))) );
            + 67             }
            + 68 
            + 69             this.pos1=Math.floor(255*Math.random());
            + 70             this.pos2=Math.floor(255*Math.random());
            + 71             this.pos3=Math.floor(255*Math.random());
            + 72             this.pos4=Math.floor(255*Math.random());
            + 73 
            + 74             this.m_colorMap= CAAT.Module.ColorUtil.Color.makeRGBColorRamp(
            + 75                     colors!==null ? colors : this.color,
            + 76                     256,
            + 77                     CAAT.Module.ColorUtil.Color.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY );
            + 78 
            + 79             this.setB();
            + 80 
            + 81             return this;
            + 82         },
            + 83         /**
            + 84          * Initialize internal plasma structures. Calling repeatedly this method will make the plasma
            + 85          * look different.
            + 86          */
            + 87         setB : function() {
            + 88 
            + 89             this.b1= Math.random()>0.5;
            + 90             this.b2= Math.random()>0.5;
            + 91             this.b3= Math.random()>0.5;
            + 92             this.b4= Math.random()>0.5;
            + 93 
            + 94             this.spd1= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));
            + 95             this.spd2= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));
            + 96             this.spd3= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));
            + 97             this.spd4= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));
            + 98 
            + 99             this.i1= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));
            +100             this.i2= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));
            +101             this.i3= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));
            +102             this.i4= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));
            +103         },
            +104         /**
            +105          * Apply image processing to create the plasma and call superclass's apply to make the result
            +106          * visible.
            +107          * @param director {CAAT.Director}
            +108          * @param time {number}
            +109          *
            +110          * @return this
            +111          */
            +112         apply : function(director,time) {
            +113 
            +114             var v = 0;
            +115 	        this.tpos1 = this.pos1;
            +116 	        this.tpos2 = this.pos2;
            +117 
            +118             var bi= this.bufferImage;
            +119             var cm= this.m_colorMap;
            +120             var wt= this.wavetable;
            +121             var z;
            +122             var cmz;
            +123 
            +124 	        for (var x=0; x<this.height; x++) {
            +125                 this.tpos3 = this.pos3;
            +126                 this.tpos4 = this.pos4;
            +127 
            +128                 for(var y=0; y<this.width; y++) {
            +129                     // mix at will, or at your own risk.
            +130                     var o1= this.tpos1+this.tpos2+this.tpos3;
            +131                     var o2= this.tpos2+this.tpos3-this.tpos1;
            +132                     var o3= this.tpos3+this.tpos4-this.tpos2;
            +133                     var o4= this.tpos4+this.tpos1-this.tpos2;
            +134 
            +135                     // set different directions. again, change at will.
            +136                     if ( this.b1 ) o1= -o1;
            +137                     if ( this.b2 ) o2= -o2;
            +138                     if ( this.b3 ) o3= -o3;
            +139                     if ( this.b4 ) o4= -o4;
            +140 
            +141                     z = Math.floor( wt[o1&255] + wt[o2&255] + wt[o3&255] + wt[o4&255] );
            +142                     cmz= cm[z];
            +143 
            +144                     bi[ v++ ]= cmz[0];
            +145                     bi[ v++ ]= cmz[1];
            +146                     bi[ v++ ]= cmz[2];
            +147                     bi[ v++ ]= cmz[3];
            +148 
            +149                     this.tpos3 += this.i1;
            +150                     this.tpos3&=255;
            +151                     this.tpos4 += this.i2;
            +152                     this.tpos4&=255;
            +153                 }
            +154 
            +155                 this.tpos1 += this.i3;
            +156                 this.tpos1&=255;
            +157                 this.tpos2 += this.i4;
            +158                 this.tpos2&=255;
            +159             }
            +160 
            +161             this.pos1 += this.spd1;
            +162             this.pos2 -= this.spd2;
            +163             this.pos3 += this.spd3;
            +164             this.pos4 -= this.spd4;
            +165             this.pos1&=255;
            +166             this.pos3&=255;
            +167             this.pos2&=255;
            +168             this.pos4&=255;
            +169 
            +170             return CAAT.Module.Image.ImageProcess.IMPlasma.superclass.applyIM.call(this,director,time);
            +171         }
            +172     }
            +173 });
            +174 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMRotoZoom.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMRotoZoom.js.html new file mode 100644 index 0000000..6484bc5 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_IMRotoZoom.js.html @@ -0,0 +1,210 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name IMRotoZoom
            +  5      * @memberOf CAAT.Module.Image.ImageProcessor
            +  6      * @extends CAAT.Module.Image.ImageProcessor.ImageProcessor
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Module.Image.ImageProcess.IMRotoZoom",
            + 11     depends : [
            + 12         "CAAT.Module.Image.ImageProcess.ImageProcessor"
            + 13     ],
            + 14     extendsClass : "CAAT.Module.Image.ImageProcess.ImageProcessor",
            + 15     extendsWith : {
            + 16 
            + 17         /**
            + 18          * @lends CAAT.Module.Image.ImageProcessor.IMRotoZoom.prototype
            + 19          */
            + 20 
            + 21         m_alignv:       1,
            + 22         m_alignh:       1,
            + 23         distortion:     2,
            + 24         mask:           0,
            + 25         shift:          0,
            + 26         sourceImageData:null,   // pattern to fill area with.
            + 27 
            + 28         /**
            + 29          * Initialize the rotozoom.
            + 30          * @param width {number}
            + 31          * @param height {number}
            + 32          * @param patternImage {HTMLImageElement} image to tile with.
            + 33          *
            + 34          * @return this
            + 35          */
            + 36         initialize : function( width, height, patternImage ) {
            + 37             CAAT.Module.Image.ImageProcess.IMRotoZoom.superclass.initialize.call(this,width,height);
            + 38 
            + 39             this.clear( 255,128,0, 255 );
            + 40 
            + 41             this.sourceImageData= this.grabPixels(patternImage);
            + 42 
            + 43             if ( null!==this.sourceImageData ) {
            + 44                 // patternImage must be 2^n sized.
            + 45                 switch( this.sourceImageData.width ) {
            + 46                     case 1024:
            + 47                         this.mask=1023;
            + 48                         this.shift=10;
            + 49                         break;
            + 50                     case 512:
            + 51                         this.mask=511;
            + 52                         this.shift=9;
            + 53                         break;
            + 54                     case 256:
            + 55                         this.mask=255;
            + 56                         this.shift=8;
            + 57                         break;
            + 58                     case 128:
            + 59                         this.mask=127;
            + 60                         this.shift=7;
            + 61                         break;
            + 62                     case 64:
            + 63                         this.mask=63;
            + 64                         this.shift=6;
            + 65                         break;
            + 66                     case 32:
            + 67                         this.mask=31;
            + 68                         this.shift=5;
            + 69                         break;
            + 70                     case 16:
            + 71                         this.mask=15;
            + 72                         this.shift=4;
            + 73                         break;
            + 74                     case 8:
            + 75                         this.mask=7;
            + 76                         this.shift=3;
            + 77                         break;
            + 78                 }
            + 79             }
            + 80 
            + 81             this.setCenter();
            + 82 
            + 83             return this;
            + 84         },
            + 85         /**
            + 86          * Performs the process of tiling rotozoom.
            + 87          * @param director {CAAT.Director}
            + 88          * @param time {number}
            + 89          *
            + 90          * @private
            + 91          */
            + 92         rotoZoom: function(director,time)  {
            + 93 
            + 94             var timer = new Date().getTime();
            + 95 
            + 96             var angle=Math.PI*2 * Math.cos(timer * 0.0001);
            + 97             var distance= 600+ 550*Math.sin(timer*0.0002);
            + 98 
            + 99             var dist= this.distortion;
            +100 
            +101             var off=0;
            +102             var ddx=Math.floor(Math.cos(angle)*distance);
            +103             var ddy=Math.floor(Math.sin(angle)*distance);
            +104 
            +105             var hh=0, ww=0;
            +106 
            +107             switch( this.m_alignh )	{
            +108                 case 0:
            +109                     hh = 0;
            +110                     break;
            +111                 case 1:
            +112                     hh = (this.height >> 1);
            +113                     break;
            +114                 case 2:
            +115                     hh = this.height - 1;
            +116                     break;
            +117             }
            +118 
            +119             switch (this.m_alignv) {
            +120                 case 0:
            +121                     ww = 0;
            +122                     break;
            +123                 case 1:
            +124                     ww = (this.width >> 1);
            +125                     break;
            +126                 case 2:
            +127                     ww = this.width - 1;
            +128                     break;
            +129             }
            +130 
            +131             var i = (((this.width >> 1) << 8)  - ddx * ww + ddy * hh)&0xffff;
            +132             var j = (((this.height >> 1) << 8) - ddy * ww - ddx * hh) & 0xffff;
            +133 
            +134             var srcwidth=   this.sourceImageData.width;
            +135             var srcheight=  this.sourceImageData.height;
            +136             var srcdata=    this.sourceImageData.data;
            +137             var bi=         this.bufferImage;
            +138             var dstoff;
            +139             var addx;
            +140             var addy;
            +141 
            +142             while (off < this.width * this.height * 4) {
            +143                 addx = i;
            +144                 addy = j;
            +145 
            +146                 for (var m = 0; m < this.width; m++) {
            +147                     dstoff = ((addy >> this.shift) & this.mask) * srcwidth + ((addx >> this.shift) & this.mask);
            +148                     dstoff <<= 2;
            +149 
            +150                     bi[ off++ ] = srcdata[ dstoff++ ];
            +151                     bi[ off++ ] = srcdata[ dstoff++ ];
            +152                     bi[ off++ ] = srcdata[ dstoff++ ];
            +153                     bi[ off++ ] = srcdata[ dstoff++ ];
            +154 
            +155                     addx += ddx;
            +156                     addy += ddy;
            +157 
            +158                 }
            +159 
            +160                 dist += this.distortion;
            +161                 i -= ddy;
            +162                 j += ddx - dist;
            +163             }
            +164         },
            +165         /**
            +166          * Perform and apply the rotozoom effect.
            +167          * @param director {CAAT.Director}
            +168          * @param time {number}
            +169          * @return this
            +170          */
            +171         applyIM : function(director,time) {
            +172             if ( null!==this.sourceImageData ) {
            +173                 this.rotoZoom(director,time);
            +174             }
            +175             return CAAT.Module.Image.ImageProcess.IMRotoZoom.superclass.applyIM.call(this,director,time);
            +176         },
            +177         /**
            +178          * Change the effect's rotation anchor. Call this method repeatedly to make the effect look
            +179          * different.
            +180          */
            +181         setCenter: function() {
            +182             var d = Math.random();
            +183             if (d < 0.33) {
            +184                 this.m_alignv = 0;
            +185             } else if (d < 0.66) {
            +186                 this.m_alignv = 1;
            +187             } else {
            +188                 this.m_alignv = 2;
            +189             }
            +190 
            +191             d = Math.random();
            +192             if (d < 0.33) {
            +193                 this.m_alignh = 0;
            +194             } else if (d < 0.66) {
            +195                 this.m_alignh = 1;
            +196             } else {
            +197                 this.m_alignh = 2;
            +198             }
            +199         }
            +200 
            +201     }
            +202 });
            +203 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_ImageProcessor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_ImageProcessor.js.html new file mode 100644 index 0000000..1411bdd --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_ImageProcess_ImageProcessor.js.html @@ -0,0 +1,207 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name Image
            +  5      * @memberOf CAAT.Module
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name ImageProcessor
            + 11      * @memberOf CAAT.Module.Image
            + 12      * @namespace
            + 13      */
            + 14 
            + 15     /**
            + 16      * @name ImageProcessor
            + 17      * @memberOf CAAT.Module.Image.ImageProcessor
            + 18      * @constructor
            + 19      */
            + 20 
            + 21 
            + 22     defines : "CAAT.Module.Image.ImageProcessor.ImageProcessor",
            + 23     extendsWith : {
            + 24 
            + 25         /**
            + 26          * @lends CAAT.Module.Image.ImageProcessor.ImageProcessor.prototype
            + 27          */
            + 28 
            + 29         canvas:     null,
            + 30         ctx:        null,
            + 31         width:      0,
            + 32         height:     0,
            + 33         imageData:  null,
            + 34         bufferImage:null,
            + 35 
            + 36         /**
            + 37          * Grabs an image pixels.
            + 38          *
            + 39          * @param image {HTMLImageElement}
            + 40          * @return {ImageData} returns an ImageData object with the image representation or null in
            + 41          * case the pixels can not be grabbed.
            + 42          *
            + 43          * @static
            + 44          */
            + 45         grabPixels : function(image) {
            + 46             var canvas= document.createElement('canvas');
            + 47             if ( canvas!==null ) {
            + 48                 canvas.width= image.width;
            + 49                 canvas.height= image.height;
            + 50                 var ctx= canvas.getContext('2d');
            + 51                 ctx.drawImage(image,0,0);
            + 52                 try {
            + 53                     var imageData= ctx.getImageData(0,0,canvas.width,canvas.height);
            + 54                     return imageData;
            + 55                 }
            + 56                 catch(e) {
            + 57                     CAAT.log('error pixelgrabbing.', image);
            + 58                     return null;
            + 59                 }
            + 60             }
            + 61             return null;
            + 62         },
            + 63         /**
            + 64          * Helper method to create an array.
            + 65          *
            + 66          * @param size {number} integer number of elements in the array.
            + 67          * @param initValue {number} initial array values.
            + 68          *
            + 69          * @return {[]} an array of 'initialValue' elements.
            + 70          *
            + 71          * @static
            + 72          */
            + 73         makeArray : function(size, initValue) {
            + 74             var a= [];
            + 75 
            + 76             for(var i=0; i<size; i++ )  {
            + 77                 a.push( initValue );
            + 78             }
            + 79 
            + 80             return a;
            + 81         },
            + 82         /**
            + 83          * Helper method to create a bidimensional array.
            + 84          *
            + 85          * @param size {number} number of array rows.
            + 86          * @param size2 {number} number of array columns.
            + 87          * @param initvalue array initial values.
            + 88          *
            + 89          * @return {[]} a bidimensional array of 'initvalue' elements.
            + 90          *
            + 91          * @static
            + 92          *
            + 93          */
            + 94         makeArray2D : function (size, size2, initvalue)  {
            + 95             var a= [];
            + 96 
            + 97             for( var i=0; i<size; i++ ) {
            + 98                 a.push( this.makeArray(size2,initvalue) );
            + 99             }
            +100 
            +101             return a;
            +102         },
            +103         /**
            +104          * Initializes and creates an offscreen Canvas object. It also creates an ImageData object and
            +105          * initializes the internal bufferImage attribute to imageData's data.
            +106          * @param width {number} canvas width.
            +107          * @param height {number} canvas height.
            +108          * @return this
            +109          */
            +110         initialize : function(width,height) {
            +111 
            +112             this.width=  width;
            +113             this.height= height;
            +114 
            +115             this.canvas= document.createElement('canvas');
            +116             if ( this.canvas!==null ) {
            +117                 this.canvas.width= width;
            +118                 this.canvas.height= height;
            +119                 this.ctx= this.canvas.getContext('2d');
            +120                 this.imageData= this.ctx.getImageData(0,0,width,height);
            +121                 this.bufferImage= this.imageData.data;
            +122             }
            +123 
            +124             return this;
            +125         },
            +126         /**
            +127          * Clear this ImageData object to the given color components.
            +128          * @param r {number} red color component 0..255.
            +129          * @param g {number} green color component 0..255.
            +130          * @param b {number} blue color component 0..255.
            +131          * @param a {number} alpha color component 0..255.
            +132          * @return this
            +133          */
            +134         clear : function( r,g,b,a ) {
            +135             if ( null===this.imageData ) {
            +136                 return this;
            +137             }
            +138             var data= this.imageData.data;
            +139             for( var i=0; i<this.width*this.height; i++ ) {
            +140                 data[i*4+0]= r;
            +141                 data[i*4+1]= g;
            +142                 data[i*4+2]= b;
            +143                 data[i*4+3]= a;
            +144             }
            +145             this.imageData.data= data;
            +146 
            +147             return this;
            +148         },
            +149         /**
            +150          * Get this ImageData.
            +151          * @return {ImageData}
            +152          */
            +153         getImageData : function() {
            +154             return this.ctx.getImageData(0,0,this.width,this.height);
            +155         },
            +156         /**
            +157          * Sets canvas pixels to be the applied effect. After process pixels, this method must be called
            +158          * to show the result of such processing.
            +159          * @param director {CAAT.Director}
            +160          * @param time {number}
            +161          * @return this
            +162          */
            +163         applyIM : function(director, time) {
            +164             if ( null!==this.imageData ) {
            +165                 this.imageData.data= this.bufferImage;
            +166                 this.ctx.putImageData(this.imageData, 0, 0);
            +167             }
            +168             return this;
            +169         },
            +170         /**
            +171          * Returns the offscreen canvas.
            +172          * @return {HTMLCanvasElement}
            +173          */
            +174         getCanvas : function() {
            +175             return this.canvas;
            +176         },
            +177         /**
            +178          * Creates a pattern that will make this ImageProcessor object suitable as a fillStyle value.
            +179          * This effect can be drawn too as an image by calling: canvas_context.drawImage methods.
            +180          * @param type {string} the pattern type. if no value is supplied 'repeat' will be used.
            +181          * @return CanvasPattern.
            +182          */
            +183         createPattern : function( type ) {
            +184             return this.ctx.createPattern(this.canvas,type ? type : 'repeat');
            +185         },
            +186         /**
            +187          * Paint this ImageProcessor object result.
            +188          * @param director {CAAT.Director}.
            +189          * @param time {number} scene time.
            +190          */
            +191         paint : function( director, time ) {
            +192             if ( null!==this.canvas ) {
            +193                 var ctx= director.ctx;
            +194                 ctx.drawImage( this.getCanvas(), 0, 0 );
            +195             }
            +196         }
            +197     }
            +198 
            +199 });
            +200 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_ImagePreloader.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_ImagePreloader.js.html new file mode 100644 index 0000000..ec8d6d0 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_ImagePreloader.js.html @@ -0,0 +1,108 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Image/Resource preloader.
            +  5  *
            +  6  *
            +  7  **/
            +  8 
            +  9 CAAT.Module( {
            + 10 
            + 11 
            + 12     /**
            + 13      * @name Preloader
            + 14      * @memberOf CAAT.Module
            + 15      * @namespace
            + 16      */
            + 17 
            + 18     /**
            + 19      * @name ImagePreloader
            + 20      * @memberOf CAAT.Module.Preloader
            + 21      * @constructor
            + 22      */
            + 23 
            + 24     defines : "CAAT.Module.Preloader.ImagePreloader",
            + 25     aliases : ["CAAT.ImagePreloader"],
            + 26     extendsWith : {
            + 27 
            + 28         /**
            + 29          * @lends CAAT.Module.Preloader.ImagePreloader.prototype
            + 30          */
            + 31 
            + 32         __init : function()   {
            + 33             this.images = [];
            + 34             return this;
            + 35         },
            + 36 
            + 37         /**
            + 38          * a list of elements to load.
            + 39          * @type {Array.<{ id, image }>}
            + 40          */
            + 41         images:                 null,
            + 42 
            + 43         /**
            + 44          * notification callback invoked for each image loaded.
            + 45          */
            + 46         notificationCallback:   null,
            + 47 
            + 48         /**
            + 49          * elements counter.
            + 50          */
            + 51         imageCounter:           0,
            + 52 
            + 53         /**
            + 54          * Start images loading asynchronous process. This method will notify every image loaded event
            + 55          * and is responsibility of the caller to count the number of loaded images to see if it fits his
            + 56          * needs.
            + 57          * 
            + 58          * @param aImages {{ id:{url}, id2:{url}, ...} an object with id/url pairs.
            + 59          * @param callback_loaded_one_image {function( imageloader {CAAT.ImagePreloader}, counter {number}, images {{ id:{string}, image: {Image}}} )}
            + 60          * function to call on every image load.
            + 61          */
            + 62         loadImages: function( aImages, callback_loaded_one_image, callback_error ) {
            + 63 
            + 64             if (!aImages) {
            + 65                 if (callback_loaded_one_image ) {
            + 66                     callback_loaded_one_image(0,[]);
            + 67                 }
            + 68             }
            + 69 
            + 70             var me= this, i;
            + 71             this.notificationCallback = callback_loaded_one_image;
            + 72             this.images= [];
            + 73             for( i=0; i<aImages.length; i++ ) {
            + 74                 this.images.push( {id:aImages[i].id, image: new Image() } );
            + 75             }
            + 76 
            + 77             for( i=0; i<aImages.length; i++ ) {
            + 78                 this.images[i].image.onload = function imageLoaded() {
            + 79                     me.imageCounter++;
            + 80                     me.notificationCallback(me.imageCounter, me.images);
            + 81                 };
            + 82 
            + 83                 this.images[i].image.onerror= (function(index) {
            + 84                         return function(e) {
            + 85                             if ( callback_error ) {
            + 86                                 callback_error( e, index );
            + 87                             }
            + 88                         }
            + 89                     })(i);
            + 90 
            + 91                 this.images[i].image.src= aImages[i].url;
            + 92             }
            + 93 
            + 94             if ( aImages.length===0 ) {
            + 95                 callback_loaded_one_image(0,[]);
            + 96             }
            + 97         }
            + 98 
            + 99     }
            +100 });
            +101 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_Preloader.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_Preloader.js.html new file mode 100644 index 0000000..38cbfb8 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Preloader_Preloader.js.html @@ -0,0 +1,169 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * Image/Resource preloader.
            +  5  *
            +  6  *
            +  7  **/
            +  8 
            +  9 CAAT.Module( {
            + 10 
            + 11 
            + 12     /**
            + 13      * @name Preloader
            + 14      * @memberOf CAAT.Module.Preloader
            + 15      * @constructor
            + 16      */
            + 17 
            + 18     defines : "CAAT.Module.Preloader.Preloader",
            + 19     extendsWith : function() {
            + 20 
            + 21         var descriptor= function(id, path, loader) {
            + 22 
            + 23             var me= this;
            + 24 
            + 25             this.id=    id;
            + 26             this.path=  path;
            + 27             this.image= new Image();
            + 28             this.loader= loader;
            + 29 
            + 30             this.image.onload= this.onload.bind(this);
            + 31             this.image.onerror= this.onerror.bind(this);
            + 32 
            + 33             return this;
            + 34         };
            + 35 
            + 36         descriptor.prototype= {
            + 37             id : null,
            + 38             path : null,
            + 39             image : null,
            + 40             loader : null,
            + 41 
            + 42             onload : function(e) {
            + 43                 this.loader.__onload(this);
            + 44                 this.image.onload= null;
            + 45                 this.image.onerror= null;
            + 46             },
            + 47 
            + 48             onerror : function(e) {
            + 49                 this.loader.__onerror(this);
            + 50             },
            + 51 
            + 52             load : function() {
            + 53                 this.image.src= this.path;
            + 54             },
            + 55 
            + 56             clear : function() {
            + 57                 this.loader= null;
            + 58 
            + 59             }
            + 60         };
            + 61 
            + 62         return {
            + 63 
            + 64             /**
            + 65              * @lends CAAT.Module.Preloader.Preloader.prototype
            + 66              */
            + 67 
            + 68             __init : function()   {
            + 69                 this.elements= [];
            + 70                 this.baseURL= "";
            + 71                 return this;
            + 72             },
            + 73 
            + 74             currentGroup : null,
            + 75 
            + 76             /**
            + 77              * a list of elements to load.
            + 78              * @type {Array.<{ id, image }>}
            + 79              */
            + 80             elements:       null,
            + 81 
            + 82             /**
            + 83              * elements counter.
            + 84              */
            + 85             imageCounter:   0,
            + 86 
            + 87             /**
            + 88              * Callback finished loading.
            + 89              */
            + 90             cfinished:      null,
            + 91 
            + 92             /**
            + 93              * Callback element loaded.
            + 94              */
            + 95             cloaded:        null,
            + 96 
            + 97             /**
            + 98              * Callback error loading.
            + 99              */
            +100             cerrored:       null,
            +101 
            +102             /**
            +103              * loaded elements count.
            +104              */
            +105             loadedCount:    0,
            +106 
            +107             baseURL : null,
            +108 
            +109             addElement : function( id, path ) {
            +110                 this.elements.push( new descriptor(id,this.baseURL+path,this) );
            +111                 return this;
            +112             },
            +113 
            +114             clear : function() {
            +115                 for( var i=0; i<this.elements.length; i++ ) {
            +116                     this.elements[i].clear();
            +117                 }
            +118                 this.elements= null;
            +119             },
            +120 
            +121             __onload : function( d ) {
            +122                 if ( this.cloaded ) {
            +123                     this.cloaded(d.id);
            +124                 }
            +125 
            +126                 this.loadedCount++;
            +127                 if ( this.loadedCount===this.elements.length ) {
            +128                     if ( this.cfinished ) {
            +129                         this.cfinished( this.elements );
            +130                     }
            +131                 }
            +132             },
            +133 
            +134             __onerror : function( d ) {
            +135                 if ( this.cerrored ) {
            +136                     this.cerrored(d.id);
            +137                 }
            +138             },
            +139 
            +140             setBaseURL : function( base ) {
            +141                 this.baseURL= base;
            +142                 return this;
            +143             },
            +144 
            +145             load: function( onfinished, onload_one, onerror ) {
            +146 
            +147                 this.cfinished= onfinished;
            +148                 this.cloaded= onload_one;
            +149                 this.cerroed= onerror;
            +150 
            +151                 var i;
            +152 
            +153                 for( i=0; i<this.elements.length; i++ ) {
            +154                     this.elements[i].load();
            +155                 }
            +156 
            +157                 return this;
            +158             }
            +159         }
            +160     }
            +161 });
            +162 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Util_ImageUtil.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Util_ImageUtil.js.html new file mode 100644 index 0000000..e14cccc --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Image_Util_ImageUtil.js.html @@ -0,0 +1,234 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  */
            +  4 CAAT.Module({
            +  5 
            +  6     /**
            +  7      * @name ImageUtil
            +  8      * @memberOf CAAT.Module.Image
            +  9      * @namespace
            + 10      */
            + 11 
            + 12     defines:"CAAT.Module.Image.ImageUtil",
            + 13     depends : [
            + 14         "CAAT.Math.Matrix"
            + 15     ],
            + 16     extendsWith:{
            + 17 
            + 18     },
            + 19     constants:{
            + 20 
            + 21         /**
            + 22          * @lends CAAT.Module.Image.ImageUtil
            + 23          */
            + 24 
            + 25         createAlphaSpriteSheet:function (maxAlpha, minAlpha, sheetSize, image, bg_fill_style) {
            + 26 
            + 27             if (maxAlpha < minAlpha) {
            + 28                 var t = maxAlpha;
            + 29                 maxAlpha = minAlpha;
            + 30                 minAlpha = t;
            + 31             }
            + 32 
            + 33             var canvas = document.createElement('canvas');
            + 34             canvas.width = image.width;
            + 35             canvas.height = image.height * sheetSize;
            + 36             var ctx = canvas.getContext('2d');
            + 37             ctx.fillStyle = bg_fill_style ? bg_fill_style : 'rgba(255,255,255,0)';
            + 38             ctx.fillRect(0, 0, image.width, image.height * sheetSize);
            + 39 
            + 40             var i;
            + 41             for (i = 0; i < sheetSize; i++) {
            + 42                 ctx.globalAlpha = 1 - (maxAlpha - minAlpha) / sheetSize * (i + 1);
            + 43                 ctx.drawImage(image, 0, i * image.height);
            + 44             }
            + 45 
            + 46             return canvas;
            + 47         },
            + 48 
            + 49         /**
            + 50          * Creates a rotated canvas image element.
            + 51          */
            + 52         rotate:function (image, angle) {
            + 53 
            + 54             angle = angle || 0;
            + 55             if (!angle) {
            + 56                 return image;
            + 57             }
            + 58 
            + 59             var canvas = document.createElement("canvas");
            + 60             canvas.width = image.height;
            + 61             canvas.height = image.width;
            + 62             var ctx = canvas.getContext('2d');
            + 63             ctx.globalAlpha = 1;
            + 64             ctx.fillStyle = 'rgba(0,0,0,0)';
            + 65             ctx.clearRect(0, 0, canvas.width, canvas.height);
            + 66 
            + 67             var m = new CAAT.Math.Matrix();
            + 68             m.multiply(new CAAT.Math.Matrix().setTranslate(canvas.width / 2, canvas.width / 2));
            + 69             m.multiply(new CAAT.Math.Matrix().setRotation(angle * Math.PI / 180));
            + 70             m.multiply(new CAAT.Math.Matrix().setTranslate(-canvas.width / 2, -canvas.width / 2));
            + 71             m.transformRenderingContext(ctx);
            + 72             ctx.drawImage(image, 0, 0);
            + 73 
            + 74             return canvas;
            + 75         },
            + 76 
            + 77         /**
            + 78          * Remove an image's padding transparent border.
            + 79          * Transparent means that every scan pixel is alpha=0.
            + 80          */
            + 81         optimize:function (image, threshold, areas) {
            + 82             threshold >>= 0;
            + 83 
            + 84             var atop = true;
            + 85             var abottom = true;
            + 86             var aleft = true;
            + 87             var aright = true;
            + 88             if (typeof areas !== 'undefined') {
            + 89                 if (typeof areas.top !== 'undefined') {
            + 90                     atop = areas.top;
            + 91                 }
            + 92                 if (typeof areas.bottom !== 'undefined') {
            + 93                     abottom = areas.bottom;
            + 94                 }
            + 95                 if (typeof areas.left !== 'undefined') {
            + 96                     aleft = areas.left;
            + 97                 }
            + 98                 if (typeof areas.right !== 'undefined') {
            + 99                     aright = areas.right;
            +100                 }
            +101             }
            +102 
            +103 
            +104             var canvas = document.createElement('canvas');
            +105             canvas.width = image.width;
            +106             canvas.height = image.height;
            +107             var ctx = canvas.getContext('2d');
            +108 
            +109             ctx.fillStyle = 'rgba(0,0,0,0)';
            +110             ctx.fillRect(0, 0, image.width, image.height);
            +111             ctx.drawImage(image, 0, 0);
            +112 
            +113             var imageData = ctx.getImageData(0, 0, image.width, image.height);
            +114             var data = imageData.data;
            +115 
            +116             var i, j;
            +117             var miny = 0, maxy = canvas.height - 1;
            +118             var minx = 0, maxx = canvas.width - 1;
            +119 
            +120             var alpha = false;
            +121 
            +122             if (atop) {
            +123                 for (i = 0; i < canvas.height; i++) {
            +124                     for (j = 0; j < canvas.width; j++) {
            +125                         if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) {
            +126                             alpha = true;
            +127                             break;
            +128                         }
            +129                     }
            +130 
            +131                     if (alpha) {
            +132                         break;
            +133                     }
            +134                 }
            +135                 // i contiene el indice del ultimo scan que no es transparente total.
            +136                 miny = i;
            +137             }
            +138 
            +139             if (abottom) {
            +140                 alpha = false;
            +141                 for (i = canvas.height - 1; i >= miny; i--) {
            +142                     for (j = 0; j < canvas.width; j++) {
            +143                         if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) {
            +144                             alpha = true;
            +145                             break;
            +146                         }
            +147                     }
            +148 
            +149                     if (alpha) {
            +150                         break;
            +151                     }
            +152                 }
            +153                 maxy = i;
            +154             }
            +155 
            +156             if (aleft) {
            +157                 alpha = false;
            +158                 for (j = 0; j < canvas.width; j++) {
            +159                     for (i = miny; i <= maxy; i++) {
            +160                         if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) {
            +161                             alpha = true;
            +162                             break;
            +163                         }
            +164                     }
            +165                     if (alpha) {
            +166                         break;
            +167                     }
            +168                 }
            +169                 minx = j;
            +170             }
            +171 
            +172             if (aright) {
            +173                 alpha = false;
            +174                 for (j = canvas.width - 1; j >= minx; j--) {
            +175                     for (i = miny; i <= maxy; i++) {
            +176                         if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) {
            +177                             alpha = true;
            +178                             break;
            +179                         }
            +180                     }
            +181                     if (alpha) {
            +182                         break;
            +183                     }
            +184                 }
            +185                 maxx = j;
            +186             }
            +187 
            +188             if (0 === minx && 0 === miny && canvas.width - 1 === maxx && canvas.height - 1 === maxy) {
            +189                 return canvas;
            +190             }
            +191 
            +192             var width = maxx - minx + 1;
            +193             var height = maxy - miny + 1;
            +194             var id2 = ctx.getImageData(minx, miny, width, height);
            +195 
            +196             canvas.width = width;
            +197             canvas.height = height;
            +198             ctx = canvas.getContext('2d');
            +199             ctx.putImageData(id2, 0, 0);
            +200 
            +201             return canvas;
            +202         },
            +203 
            +204 
            +205         createThumb:function (image, w, h, best_fit) {
            +206             w = w || 24;
            +207             h = h || 24;
            +208             var canvas = document.createElement('canvas');
            +209             canvas.width = w;
            +210             canvas.height = h;
            +211             var ctx = canvas.getContext('2d');
            +212 
            +213             if (best_fit) {
            +214                 var max = Math.max(image.width, image.height);
            +215                 var ww = image.width / max * w;
            +216                 var hh = image.height / max * h;
            +217                 ctx.drawImage(image, (w - ww) / 2, (h - hh) / 2, ww, hh);
            +218             } else {
            +219                 ctx.drawImage(image, 0, 0, w, h);
            +220             }
            +221 
            +222             return canvas;
            +223         }
            +224     }
            +225 
            +226 })
            +227 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_Template.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_Template.js.html new file mode 100644 index 0000000..cc76c5b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_Template.js.html @@ -0,0 +1,98 @@ +
              1 CAAT.Module({
            +  2     defines : "CAAT.Module.Initialization.Template",
            +  3     depends : [
            +  4         "CAAT.Foundation.Director",
            +  5         "CAAT.Module.Preloader.ImagePreloader"
            +  6     ],
            +  7     constants: {
            +  8         init : function( width, height, runHere, imagesURL, onEndLoading )   {
            +  9 
            + 10             var canvascontainer= document.getElementById(runHere);
            + 11             var director;
            + 12 
            + 13             if ( CAAT.__CSS__ ) {   // css renderer
            + 14                 if ( canvascontainer ) {
            + 15                     if ( false===canvascontainer instanceof HTMLDivElement ) {
            + 16                         canvascontainer= null;
            + 17                     }
            + 18                 }
            + 19 
            + 20                 if ( canvascontainer===null ) {
            + 21                     canvascontainer= document.createElement('div'); // create a new DIV
            + 22                     document.body.appendChild(canvascontainer);
            + 23                 }
            + 24 
            + 25                 director= new CAAT.Foundation.Director().
            + 26                     initialize(
            + 27                         width||800,
            + 28                         height||600,
            + 29                         canvascontainer);
            + 30 
            + 31             } else {
            + 32 
            + 33                 if ( canvascontainer ) {
            + 34                     if ( canvascontainer instanceof HTMLDivElement ) {
            + 35                         var ncanvascontainer= document.createElement("canvas");
            + 36                         canvascontainer.appendChild(ncanvascontainer);
            + 37                         canvascontainer= ncanvascontainer;
            + 38                     } else if ( false==canvascontainer instanceof HTMLCanvasElement ) {
            + 39                         var ncanvascontainer= document.createElement("canvas");
            + 40                         document.body.appendChild(ncanvascontainer);
            + 41                         canvascontainer= ncanvascontainer;
            + 42                     }
            + 43                 } else {
            + 44                     canvascontainer= document.createElement('canvas');
            + 45                     document.body.appendChild(canvascontainer);
            + 46                 }
            + 47 
            + 48                 director= new CAAT.Foundation.Director().
            + 49                         initialize(
            + 50                             width||800,
            + 51                             height||600,
            + 52                             canvascontainer);
            + 53             }
            + 54 
            + 55             /**
            + 56              * Load splash images. It is supossed the splash has some images.
            + 57              */
            + 58             new CAAT.Module.Preloader.ImagePreloader().loadImages(
            + 59                 imagesURL,
            + 60                 function on_load( counter, images ) {
            + 61 
            + 62                     if ( counter===images.length ) {
            + 63 
            + 64                         director.emptyScenes();
            + 65                         director.setImagesCache(images);
            + 66 
            + 67                         onEndLoading(director);
            + 68 
            + 69                         /**
            + 70                          * Change this sentence's parameters to play with different entering-scene
            + 71                          * curtains.
            + 72                          * just perform a director.setScene(0) to play first director's scene.
            + 73                          */
            + 74                         director.easeIn(
            + 75                                 0,
            + 76                                 CAAT.Foundation.Scene.EASE_SCALE,
            + 77                                 2000,
            + 78                                 false,
            + 79                                 CAAT.Foundation.Actor.ANCHOR_CENTER,
            + 80                                 new CAAT.Behavior.Interpolator().createElasticOutInterpolator(2.5, .4) );
            + 81 
            + 82                         CAAT.loop(60);
            + 83 
            + 84                     }
            + 85                 }
            + 86             );
            + 87 
            + 88         }
            + 89     }
            + 90 });
            + 91 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_TemplateWithSplash.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_TemplateWithSplash.js.html new file mode 100644 index 0000000..1633a96 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Initialization_TemplateWithSplash.js.html @@ -0,0 +1,189 @@ +
              1 CAAT.Module({
            +  2     defines : "CAAT.Module.Initialization.TemplateWithSplash",
            +  3     depends : [
            +  4         "CAAT.Foundation.Director",
            +  5         "CAAT.Module.Preloader.ImagePreloader"
            +  6     ],
            +  7     constants: {
            +  8 
            +  9         init : function( width, height, runHere, minTime, imagesURL, onEndSplash, splash_path, spinner_path )   {
            + 10 
            + 11             function createSplashScene(director, showTime, sceneCreationCallback) {
            + 12 
            + 13                 var spinnerImg= director.getImage('spinner');
            + 14                 var splashImg=  director.getImage('splash');
            + 15                 var scene=      director.createScene();
            + 16                 var TIME=       showTime;
            + 17                 var time=       new Date().getTime();
            + 18 
            + 19                 if ( splashImg ) {
            + 20                     scene.addChild(
            + 21                             new CAAT.Foundation.Actor().
            + 22                                 setBackgroundImage(splashImg, false).
            + 23                                 setBounds(0,0,director.width,director.height).
            + 24                                 setImageTransformation( CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE )
            + 25                             );
            + 26                 }
            + 27 
            + 28                 if ( spinnerImg ) {
            + 29                     scene.addChild(
            + 30                             new CAAT.Foundation.Actor().
            + 31                                 setBackgroundImage(spinnerImg).
            + 32                                 centerAt( scene.width/2, scene.height/2).
            + 33                                 addBehavior(
            + 34                                     new CAAT.Behavior.RotateBehavior().
            + 35                                             setValues(0,2*Math.PI).
            + 36                                             setFrameTime(0,1000).
            + 37                                             setCycle(true)
            + 38                                     )
            + 39                             );
            + 40                 }
            + 41 
            + 42                 scene.loadedImage = function(count, images) {
            + 43 
            + 44                     if ( !images || count===images.length ) {
            + 45 
            + 46                         var difftime= new Date().getTime()-time;
            + 47                         if ( difftime<TIME ){
            + 48                             difftime= Math.abs(TIME-difftime);
            + 49                             if ( difftime>TIME ) {
            + 50                                 difftime= TIME;
            + 51                             }
            + 52 
            + 53                             setTimeout(
            + 54                                     function() {
            + 55                                         endSplash(director, images, sceneCreationCallback);
            + 56                                     },
            + 57                                     difftime );
            + 58 
            + 59                         } else {
            + 60                             endSplash(director, images, sceneCreationCallback);
            + 61                         }
            + 62 
            + 63                     }
            + 64                 };
            + 65 
            + 66                 return scene;
            + 67             }
            + 68             /**
            + 69              * Finish splash process by either timeout or resources allocation end.
            + 70              */
            + 71             function endSplash(director, images, onEndSplashCallback) {
            + 72 
            + 73                 director.emptyScenes();
            + 74                 director.setImagesCache(images);
            + 75                 director.setClear( true );
            + 76 
            + 77                 onEndSplashCallback(director);
            + 78 
            + 79                 /**
            + 80                  * Change this sentence's parameters to play with different entering-scene
            + 81                  * curtains.
            + 82                  * just perform a director.setScene(0) to play first director's scene.
            + 83                  */
            + 84 
            + 85                 director.setClear( CAAT.Foundation.Director.CLEAR_ALL );
            + 86                 director.easeIn(
            + 87                         0,
            + 88                         CAAT.Foundation.Scene.EASE_SCALE,
            + 89                         2000,
            + 90                         false,
            + 91                         CAAT.Foundation.Actor.ANCHOR_CENTER,
            + 92                         new CAAT.Behavior.Interpolator().createElasticOutInterpolator(2.5, .4) );
            + 93 
            + 94             }
            + 95 
            + 96             var canvascontainer= document.getElementById(runHere);
            + 97             var director;
            + 98 
            + 99             if ( CAAT.__CSS__ ) {   // css renderer
            +100                 if ( canvascontainer ) {
            +101                     if ( false===canvascontainer instanceof HTMLDivElement ) {
            +102                         canvascontainer= null;
            +103                     }
            +104                 }
            +105 
            +106                 if ( canvascontainer===null ) {
            +107                     canvascontainer= document.createElement('div'); // create a new DIV
            +108                     document.body.appendChild(canvascontainer);
            +109                 }
            +110 
            +111                 director= new CAAT.Foundation.Director().
            +112                     initialize(
            +113                         width||800,
            +114                         height||600,
            +115                         canvascontainer);
            +116 
            +117             } else {
            +118 
            +119                 if ( canvascontainer ) {
            +120                     if ( canvascontainer instanceof HTMLDivElement ) {
            +121                         var ncanvascontainer= document.createElement("canvas");
            +122                         canvascontainer.appendChild(ncanvascontainer);
            +123                         canvascontainer= ncanvascontainer;
            +124                     } else if ( false==canvascontainer instanceof HTMLCanvasElement ) {
            +125                         var ncanvascontainer= document.createElement("canvas");
            +126                         document.body.appendChild(ncanvascontainer);
            +127                         canvascontainer= ncanvascontainer;
            +128                     }
            +129                 } else {
            +130                     canvascontainer= document.createElement('canvas');
            +131                     document.body.appendChild(canvascontainer);
            +132                 }
            +133 
            +134                 director= new CAAT.Foundation.Director().
            +135                         initialize(
            +136                             width||800,
            +137                             height||600,
            +138                             canvascontainer);
            +139             }
            +140 
            +141 
            +142             /**
            +143              * Load splash images. It is supossed the splash has some images.
            +144              */
            +145             var imgs= [];
            +146             if ( splash_path ) {
            +147                 imgs.push( {id:'splash',   url: splash_path } );
            +148             }
            +149             if ( spinner_path ) {
            +150                 imgs.push( {id:'spinner',  url: spinner_path } );
            +151             }
            +152 
            +153             director.setClear( CAAT.Foundation.Director.CLEAR_DIRTY_RECTS );
            +154 
            +155             new CAAT.Module.Preloader.ImagePreloader().loadImages(
            +156                 imgs,
            +157                 function on_load( counter, images ) {
            +158 
            +159                     if ( counter===images.length ) {
            +160 
            +161                         director.setImagesCache(images);
            +162                         var splashScene= createSplashScene(director, minTime || 5000, onEndSplash);
            +163                         CAAT.loop(60);
            +164 
            +165                         if ( imagesURL && imagesURL.length>0 ) {
            +166                             /**
            +167                              * Load resources for non splash screen
            +168                              */
            +169                             new CAAT.Module.Preloader.ImagePreloader().loadImages(
            +170                                     imagesURL,
            +171                                     splashScene.loadedImage
            +172                             );
            +173                         } else {
            +174                             splashScene.loadedImage(0,null);
            +175                         }
            +176                     }
            +177                 }
            +178             );
            +179         }
            +180 
            +181     }
            +182 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_LayoutUtils_RowLayout.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_LayoutUtils_RowLayout.js.html new file mode 100644 index 0000000..0c7e92b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_LayoutUtils_RowLayout.js.html @@ -0,0 +1,68 @@ +
              1 CAAT.Module({
            +  2     defines:"CAAT.Module.LayoutUtils.RowLayout",
            +  3     constants:{
            +  4         Row:function (dst, what_to_layout_array, constraint_object) {
            +  5 
            +  6             var width = dst.width;
            +  7             var x = 0, y = 0, i = 0, l = 0;
            +  8             var actor_max_h = -Number.MAX_VALUE, actor_max_w = Number.MAX_VALUE;
            +  9 
            + 10             // compute max/min actor list size.
            + 11             for (i = what_to_layout_array.length - 1; i; i -= 1) {
            + 12                 if (actor_max_w < what_to_layout_array[i].width) {
            + 13                     actor_max_w = what_to_layout_array[i].width;
            + 14                 }
            + 15                 if (actor_max_h < what_to_layout_array[i].height) {
            + 16                     actor_max_h = what_to_layout_array[i].height;
            + 17                 }
            + 18             }
            + 19 
            + 20             if (constraint_object.padding_left) {
            + 21                 x = constraint_object.padding_left;
            + 22                 width -= x;
            + 23             }
            + 24             if (constraint_object.padding_right) {
            + 25                 width -= constraint_object.padding_right;
            + 26             }
            + 27 
            + 28             if (constraint_object.top) {
            + 29                 var top = parseInt(constraint_object.top, 10);
            + 30                 if (!isNaN(top)) {
            + 31                     y = top;
            + 32                 } else {
            + 33                     // not number
            + 34                     switch (constraint_object.top) {
            + 35                         case 'center':
            + 36                             y = (dst.height - actor_max_h) / 2;
            + 37                             break;
            + 38                         case 'top':
            + 39                             y = 0;
            + 40                             break;
            + 41                         case 'bottom':
            + 42                             y = dst.height - actor_max_h;
            + 43                             break;
            + 44                         default:
            + 45                             y = 0;
            + 46                     }
            + 47                 }
            + 48             }
            + 49 
            + 50             // space for each actor
            + 51             var actor_area = width / what_to_layout_array.length;
            + 52 
            + 53             for (i = 0, l = what_to_layout_array.length; i < l; i++) {
            + 54                 what_to_layout_array[i].setLocation(
            + 55                     x + i * actor_area + (actor_area - what_to_layout_array[i].width) / 2,
            + 56                     y);
            + 57             }
            + 58 
            + 59         }
            + 60     }
            + 61 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Locale_ResourceBundle.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Locale_ResourceBundle.js.html new file mode 100644 index 0000000..4bf1d5d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Locale_ResourceBundle.js.html @@ -0,0 +1,242 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name Locale
            +  5      * @memberOf CAAT.Module
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name ResourceBundle
            + 11      * @memberOf CAAT.Module.Locale
            + 12      * @constructor
            + 13      */
            + 14 
            + 15     defines:"CAAT.Module.Locale.ResourceBundle",
            + 16     extendsWith:function () {
            + 17 
            + 18         return {
            + 19 
            + 20             /**
            + 21              * @lends CAAT.Module.Locale.ResourceBundle.prototype
            + 22              */
            + 23 
            + 24 
            + 25             /**
            + 26              * Is this bundle valid ?
            + 27              */
            + 28             valid : false,
            + 29 
            + 30             /**
            + 31              * Original file contents.
            + 32              */
            + 33             localeInfo : null,      // content from resourceFile
            + 34 
            + 35             /**
            + 36              * Current set locale.
            + 37              */
            + 38             __currentLocale : null, // default locale data
            + 39 
            + 40             /**
            + 41              * Default locale info.
            + 42              */
            + 43             __defaultLocale : null,
            + 44 
            + 45             /**
            + 46              * <p>
            + 47              * Load a bundle file.
            + 48              * The expected file format is as follows:
            + 49              *
            + 50              * <code>
            + 51              * {
            + 52              *  "defaultLocale" : "en-US",
            + 53              *  "en-US" : {
            + 54              *          "key1", "value1",
            + 55              *          "key2", "value2",
            + 56              *          ...
            + 57              *      },
            + 58              *  "en-UK" : {
            + 59              *          "key1", "value1",
            + 60              *          "key2", "value2",
            + 61              *          ...
            + 62              *      }
            + 63              * }
            + 64              * </code>
            + 65              *
            + 66              * <p>
            + 67              * defaultLocale is compulsory.
            + 68              *
            + 69              * <p>
            + 70              * The function getString solves as follows:
            + 71              *
            + 72              * <li>a ResouceBundle object will honor browser/system locale by searching for these strings in
            + 73              *   the navigator object to define the value of currentLocale:
            + 74              *
            + 75              *   <ul>navigator.language
            + 76              *   <ul>navigator.browserLanguage
            + 77              *   <ul>navigator.systemLanguage
            + 78              *   <ul>navigator.userLanguage
            + 79              *
            + 80              * <li>the ResouceBundle class will also get defaultLocale value, and set the corresponding key
            + 81              *   as default Locale.
            + 82              *
            + 83              * <li>a call to getString(id,defaultValue) will work as follows:
            + 84              *
            + 85              * <pre>
            + 86              *   1)     will get the value associated in currentLocale[id]
            + 87              *   2)     if the value is set, it is returned.
            + 88              *   2.1)       else if it is not set, will get the value from defaultLocale[id] (sort of fallback)
            + 89              *   3)     if the value of defaultLocale is set, it is returned.
            + 90              *   3.1)       else defaultValue is returned.
            + 91              * </pre>
            + 92              *
            + 93              * @param resourceFile
            + 94              * @param asynch
            + 95              * @param onSuccess
            + 96              * @param onError
            + 97              * @return {*}
            + 98              * @private
            + 99              */
            +100             __init : function( resourceFile, asynch, onSuccess, onError ) {
            +101 
            +102                 this.loadDoc( resourceFile, asynch, onSuccess, onError );
            +103                 if ( this.valid ) {
            +104                     try {
            +105                         var locale= navigator.language || navigator.browserLanguage || navigator.systemLanguage  || navigator.userLanguage;
            +106                         this.__currentLocale= this.localeInfo[locale];
            +107                         this.__defaultLocale= this.localeInfo["defaultLocale"];
            +108 
            +109                         if ( typeof this.__currentLocale==='undefined' ) {
            +110                             this.__currentLocale= this.__defaultLocale;
            +111                         }
            +112 
            +113                         if ( !this.__currentLocale ) {
            +114                             onError("No available default or system defined locale('"+locale+"'");
            +115                         }
            +116 
            +117                         this.valid= false;
            +118 
            +119                     } catch(e) {
            +120                         onError("No default locale");
            +121                         this.valid= false;
            +122                     }
            +123                 }
            +124 
            +125                 return this;
            +126             },
            +127 
            +128             /**
            +129              * A formated string is a regular string that has embedded holder for string values.
            +130              * for example a string like:
            +131              *
            +132              * "hi this is a $2 $1"
            +133              *
            +134              * will be after calling __formatString( str, ["string","parameterized"] );
            +135              *
            +136              * "hi this is a parameterized string"
            +137              *
            +138              * IMPORTANT: Holder values start in 1.
            +139              *
            +140              * @param string {string} a parameterized string
            +141              * @param args {object} object whose keys are used to find holders and replace them in string parameter
            +142              * @return {string}
            +143              * @private
            +144              */
            +145             __formatString : function( string, args ) {
            +146 
            +147                 if ( !args ) {
            +148                     return string;
            +149                 }
            +150 
            +151                 for( var key in args ) {
            +152                     string= string.replace("$"+key, args[key]);
            +153                 }
            +154 
            +155                 return string;
            +156 
            +157             },
            +158 
            +159             /**
            +160              *
            +161              * @param id {string} a key from the bundle file.
            +162              * @param defaultValue {string} default value in case
            +163              * @param args {Array.<string>=} optional arguments array in case the returned string is a
            +164              *          parameterized string.
            +165              *
            +166              * @return {string}
            +167              */
            +168             getString : function(id, defaultValue, args) {
            +169 
            +170                 if ( this.valid ) {
            +171                     var str= this.__currentLocale[id];
            +172                     if ( str ) {
            +173                         return this.__formatString(str,args);
            +174                     } else {
            +175 
            +176                         if ( this.__currentLocale!==this.__defaultLocale ) {
            +177                             str= this.__defaultLocale[id];
            +178                             if ( str ) {
            +179                                 return this.__formatString(str,args);
            +180                             }
            +181                         }
            +182                     }
            +183                 }
            +184 
            +185                 return this.__formatString(defaultValue,args);
            +186             },
            +187 
            +188             loadDoc : function(resourceFile, asynch, onSuccess, onError ) {
            +189                 var me= this;
            +190 
            +191                 var req;
            +192                 if (window.XMLHttpRequest && !(window.ActiveXObject)) {
            +193                     try {
            +194                         req = new XMLHttpRequest();
            +195                     } catch (e) {
            +196                         req = null;
            +197                         onError(e);
            +198                     }
            +199                 } else if (window.ActiveXObject) {
            +200                     try {
            +201                         req = new ActiveXObject("Msxml2.XMLHTTP");
            +202                     } catch (e) {
            +203                         try {
            +204                             req = new ActiveXObject("Microsoft.XMLHTTP");
            +205                         } catch (e) {
            +206                             req = null;
            +207                             onError(e);
            +208                         }
            +209                     }
            +210                 }
            +211 
            +212                 if (req) {
            +213                     req.onreadystatechange = function () {
            +214                         if (req.readyState == 4) {
            +215                             if (req.status == 200) {
            +216                                 try {
            +217                                     me.localeInfo= JSON.parse(req.responseText);
            +218                                     me.valid= true;
            +219                                     onSuccess(me.localeInfo);
            +220                                 } catch(e) {
            +221                                     onError(e);
            +222                                 }
            +223                             } else {
            +224                                 onError("onReadyStateChange status="+req.status);
            +225                             }
            +226                         }
            +227                     };
            +228 
            +229                     req.open("GET", resourceFile, false);
            +230                     req.send("");
            +231                 }
            +232             }
            +233         }
            +234     }
            +235 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Runtime_BrowserInfo.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Runtime_BrowserInfo.js.html new file mode 100644 index 0000000..4f90f6a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Runtime_BrowserInfo.js.html @@ -0,0 +1,170 @@ +
              1 /**
            +  2  *
            +  3  * taken from: http://www.quirksmode.org/js/detect.html
            +  4  *
            +  5  * 20101008 Hyperandroid. IE9 seems to identify himself as Explorer and stopped calling himself MSIE.
            +  6  *          Added Explorer description to browser list. Thanks @alteredq for this tip.
            +  7  *
            +  8  */
            +  9 CAAT.Module({
            + 10 
            + 11     /**
            + 12      * @name Runtime
            + 13      * @memberOf CAAT.Module
            + 14      * @namespace
            + 15      */
            + 16 
            + 17     /**
            + 18      * @name BrowserInfo
            + 19      * @memberOf CAAT.Module.Runtime
            + 20      * @namespace
            + 21      */
            + 22 
            + 23     defines:"CAAT.Module.Runtime.BrowserInfo",
            + 24 
            + 25     constants: function() {
            + 26 
            + 27         /**
            + 28          * @lends CAAT.Module.Runtime.BrowserInfo
            + 29          */
            + 30 
            + 31         function searchString(data) {
            + 32             for (var i = 0; i < data.length; i++) {
            + 33                 var dataString = data[i].string;
            + 34                 var dataProp = data[i].prop;
            + 35                 this.versionSearchString = data[i].versionSearch || data[i].identity;
            + 36                 if (dataString) {
            + 37                     if (dataString.indexOf(data[i].subString) !== -1)
            + 38                         return data[i].identity;
            + 39                 }
            + 40                 else if (dataProp)
            + 41                     return data[i].identity;
            + 42             }
            + 43         }
            + 44 
            + 45         function searchVersion(dataString) {
            + 46             var index = dataString.indexOf(this.versionSearchString);
            + 47             if (index === -1) return;
            + 48             return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
            + 49         }
            + 50 
            + 51         var dataBrowser= [
            + 52             {
            + 53                 string:navigator.userAgent,
            + 54                 subString:"Chrome",
            + 55                 identity:"Chrome"
            + 56             },
            + 57             {   string:navigator.userAgent,
            + 58                 subString:"OmniWeb",
            + 59                 versionSearch:"OmniWeb/",
            + 60                 identity:"OmniWeb"
            + 61             },
            + 62             {
            + 63                 string:navigator.vendor,
            + 64                 subString:"Apple",
            + 65                 identity:"Safari",
            + 66                 versionSearch:"Version"
            + 67             },
            + 68             {
            + 69                 prop:window.opera,
            + 70                 identity:"Opera"
            + 71             },
            + 72             {
            + 73                 string:navigator.vendor,
            + 74                 subString:"iCab",
            + 75                 identity:"iCab"
            + 76             },
            + 77             {
            + 78                 string:navigator.vendor,
            + 79                 subString:"KDE",
            + 80                 identity:"Konqueror"
            + 81             },
            + 82             {
            + 83                 string:navigator.userAgent,
            + 84                 subString:"Firefox",
            + 85                 identity:"Firefox"
            + 86             },
            + 87             {
            + 88                 string:navigator.vendor,
            + 89                 subString:"Camino",
            + 90                 identity:"Camino"
            + 91             },
            + 92             {        // for newer Netscapes (6+)
            + 93                 string:navigator.userAgent,
            + 94                 subString:"Netscape",
            + 95                 identity:"Netscape"
            + 96             },
            + 97             {
            + 98                 string:navigator.userAgent,
            + 99                 subString:"MSIE",
            +100                 identity:"Explorer",
            +101                 versionSearch:"MSIE"
            +102             },
            +103             {
            +104                 string:navigator.userAgent,
            +105                 subString:"Explorer",
            +106                 identity:"Explorer",
            +107                 versionSearch:"Explorer"
            +108             },
            +109             {
            +110                 string:navigator.userAgent,
            +111                 subString:"Gecko",
            +112                 identity:"Mozilla",
            +113                 versionSearch:"rv"
            +114             },
            +115             { // for older Netscapes (4-)
            +116                 string:navigator.userAgent,
            +117                 subString:"Mozilla",
            +118                 identity:"Netscape",
            +119                 versionSearch:"Mozilla"
            +120             }
            +121         ];
            +122 
            +123         var dataOS=[
            +124             {
            +125                 string:navigator.platform,
            +126                 subString:"Win",
            +127                 identity:"Windows"
            +128             },
            +129             {
            +130                 string:navigator.platform,
            +131                 subString:"Mac",
            +132                 identity:"Mac"
            +133             },
            +134             {
            +135                 string:navigator.userAgent,
            +136                 subString:"iPhone",
            +137                 identity:"iPhone/iPod"
            +138             },
            +139             {
            +140                 string:navigator.platform,
            +141                 subString:"Linux",
            +142                 identity:"Linux"
            +143             }
            +144         ];
            +145 
            +146         var browser = searchString(dataBrowser) || "An unknown browser";
            +147         var version = searchVersion(navigator.userAgent) ||
            +148                       searchVersion(navigator.appVersion) ||
            +149                       "an unknown version";
            +150         var OS = searchString(dataOS) || "an unknown OS";
            +151 
            +152         var DevicePixelRatio = window.devicePixelRatio || 1;
            +153 
            +154         return {
            +155             browser: browser,
            +156             version: version,
            +157             OS: OS,
            +158             DevicePixelRatio : DevicePixelRatio
            +159         }
            +160 
            +161     }
            +162 });
            +163 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Bone.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Bone.js.html new file mode 100644 index 0000000..6894ed9 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Bone.js.html @@ -0,0 +1,514 @@ +
              1 /**
            +  2  * Created with JetBrains WebStorm.
            +  3  * User: ibon
            +  4  * Date: 3/21/13
            +  5  * Time: 7:51 PM
            +  6  * To change this template use File | Settings | File Templates.
            +  7  */
            +  8 CAAT.Module({
            +  9 
            + 10     /**
            + 11      * @name Skeleton
            + 12      * @memberof CAAT.Module
            + 13      * @namespace
            + 14      */
            + 15 
            + 16     /**
            + 17      * @name Bone
            + 18      * @memberof CAAT.Module.Skeleton
            + 19      * @constructor
            + 20      */
            + 21 
            + 22     defines : "CAAT.Module.Skeleton.Bone",
            + 23     depends : [
            + 24         "CAAT.Behavior.Interpolator",
            + 25         "CAAT.Behavior.RotateBehavior",
            + 26         "CAAT.Behavior.PathBehavior",
            + 27         "CAAT.Behavior.ScaleBehavior",
            + 28         "CAAT.Behavior.ContainerBehavior"
            + 29     ],
            + 30     extendsWith : function() {
            + 31 
            + 32 
            + 33         /**
            + 34          * @lends CAAT.Module.Skeleton.Bone.prototype
            + 35          */
            + 36 
            + 37         var defPoint = { x: 0, y: 0 };
            + 38         var defScale = { scaleX: 1, scaleY: 1 };
            + 39         var defAngle = 0;
            + 40 
            + 41         var cangle;
            + 42         var cscale;
            + 43         var cpoint;
            + 44 
            + 45         function fntr(behavior, orgtime, time, actor, value) {
            + 46             cpoint= value;
            + 47         }
            + 48 
            + 49         function fnsc(behavior, orgtime, time, actor, value) {
            + 50             cscale= value;
            + 51         }
            + 52 
            + 53         function fnrt(behavior, orgtime, time, actor, value) {
            + 54             cangle= value;
            + 55         }
            + 56 
            + 57         return {
            + 58             id : null,
            + 59 
            + 60             wx : 0,
            + 61             wy : 0,
            + 62             wrotationAngle : 0,
            + 63             wscaleX : 0,
            + 64             wscaleY : 0,
            + 65 
            + 66             /**
            + 67              * Bone x position relative parent
            + 68              * @type number
            + 69              */
            + 70             x : 0,
            + 71 
            + 72             /**
            + 73              * Bone y position relative parent
            + 74              * @type {number}
            + 75              */
            + 76             y : 0,
            + 77 
            + 78             positionAnchorX : 0,
            + 79             positionAnchorY : 0,
            + 80 
            + 81             /**
            + 82              * Bone rotation angle
            + 83              * @type {number}
            + 84              */
            + 85             rotationAngle : 0,
            + 86             rotationAnchorX : 0,
            + 87             rotationAnchorY : 0.5,
            + 88 
            + 89             scaleX : 1,
            + 90             scaleY : 1,
            + 91             scaleAnchorX : .5,
            + 92             scaleAnchorY : .5,
            + 93 
            + 94             /**
            + 95              * Bone size.
            + 96              * @type number
            + 97              */
            + 98             size : 0,
            + 99 
            +100             /**
            +101              * @type CAAT.Math.Matrix
            +102              */
            +103             matrix : null,
            +104 
            +105             /**
            +106              * @type CAAT.Math.Matrix
            +107              */
            +108             wmatrix : null,
            +109 
            +110             /**
            +111              * @type CAAT.Skeleton.Bone
            +112              */
            +113             parent : null,
            +114 
            +115             /**
            +116              * @type CAAT.Behavior.ContainerBehavior
            +117              */
            +118             keyframesTranslate : null,
            +119 
            +120             /**
            +121              * @type CAAT.PathUtil.Path
            +122              */
            +123             keyframesTranslatePath : null,
            +124 
            +125             /**
            +126              * @type CAAT.Behavior.ContainerBehavior
            +127              */
            +128             keyframesScale : null,
            +129 
            +130             /**
            +131              * @type CAAT.Behavior.ContainerBehavior
            +132              */
            +133             keyframesRotate : null,
            +134 
            +135             /**
            +136              * @type object
            +137              */
            +138             keyframesByAnimation : null,
            +139 
            +140             currentAnimation : null,
            +141 
            +142             /**
            +143              * @type Array.<CAAT.Skeleton.Bone>
            +144              */
            +145             children : null,
            +146 
            +147             behaviorApplicationTime : -1,
            +148 
            +149             __init : function(id) {
            +150                 this.id= id;
            +151                 this.matrix= new CAAT.Math.Matrix();
            +152                 this.wmatrix= new CAAT.Math.Matrix();
            +153                 this.parent= null;
            +154                 this.children= [];
            +155 
            +156                 this.keyframesByAnimation = {};
            +157 
            +158                 return this;
            +159             },
            +160 
            +161             setBehaviorApplicationTime : function(t) {
            +162                 this.behaviorApplicationTime= t;
            +163                 return this;
            +164             },
            +165 
            +166             __createAnimation : function(name) {
            +167 
            +168                 var keyframesTranslate= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_tr");
            +169                 var keyframesScale= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_sc");
            +170                 var keyframesRotate= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_rt");
            +171 
            +172                 keyframesTranslate.addListener( { behaviorApplied : fntr });
            +173                 keyframesScale.addListener( { behaviorApplied : fnsc });
            +174                 keyframesRotate.addListener( { behaviorApplied : fnrt });
            +175 
            +176                 var animData= {
            +177                     keyframesTranslate  : keyframesTranslate,
            +178                     keyframesScale      : keyframesScale,
            +179                     keyframesRotate     : keyframesRotate
            +180                 };
            +181 
            +182                 this.keyframesByAnimation[name]= animData;
            +183 
            +184                 return animData;
            +185             },
            +186 
            +187             __getAnimation : function(name) {
            +188                 var animation= this.keyframesByAnimation[ name ];
            +189                 if (!animation) {
            +190                     animation= this.__createAnimation(name);
            +191                 }
            +192 
            +193                 return animation;
            +194             },
            +195 
            +196             /**
            +197              *
            +198              * @param parent {CAAT.Skeleton.Bone}
            +199              * @returns {*}
            +200              */
            +201             __setParent : function( parent ) {
            +202                 this.parent= parent;
            +203                 return this;
            +204             },
            +205 
            +206             addBone : function( bone ) {
            +207                 this.children.push(bone);
            +208                 bone.__setParent(this);
            +209                 return this;
            +210             },
            +211 
            +212             __noValue : function( keyframes ) {
            +213                 keyframes.doValueApplication= false;
            +214                 if ( keyframes instanceof CAAT.Behavior.ContainerBehavior ) {
            +215                     this.__noValue( keyframes );
            +216                 }
            +217             },
            +218 
            +219             __setInterpolator : function(behavior, curve) {
            +220                 if (curve && curve!=="stepped") {
            +221                     behavior.setInterpolator(
            +222                             new CAAT.Behavior.Interpolator().createQuadricBezierInterpolator(
            +223                                     new CAAT.Math.Point(0,0),
            +224                                     new CAAT.Math.Point(curve[0], curve[1]),
            +225                                     new CAAT.Math.Point(curve[2], curve[3])
            +226                             )
            +227                     );
            +228                 }
            +229             },
            +230 
            +231             /**
            +232              *
            +233              * @param name {string} keyframe animation name
            +234              * @param angleStart {number} rotation start angle
            +235              * @param angleEnd {number} rotation end angle
            +236              * @param timeStart {number} keyframe start time
            +237              * @param timeEnd {number} keyframe end time
            +238              * @param curve {Array.<number>=} 4 numbers definint a quadric bezier info. two first points
            +239              *  assumed to be 0,0.
            +240              */
            +241             addRotationKeyframe : function( name, angleStart, angleEnd, timeStart, timeEnd, curve ) {
            +242 
            +243                 var as= 2*Math.PI*angleStart/360;
            +244                 var ae= 2*Math.PI*angleEnd/360;
            +245 
            +246                 // minimum distant between two angles.
            +247 
            +248                 if ( as<-Math.PI ) {
            +249                     if (Math.abs(as+this.rotationAngle)>2*Math.PI) {
            +250                         as= -(as+Math.PI);
            +251                     } else {
            +252                         as= (as+Math.PI);
            +253                     }
            +254                 } else if (as > Math.PI) {
            +255                     as -= 2 * Math.PI;
            +256                 }
            +257 
            +258                 if ( ae<-Math.PI ) {
            +259 
            +260                     if (Math.abs(ae+this.rotationAngle)>2*Math.PI) {
            +261                         ae= -(ae+Math.PI);
            +262                     } else {
            +263                         ae= (ae+Math.PI);
            +264                     }
            +265                 } else if ( ae>Math.PI ) {
            +266                     ae-=2*Math.PI;
            +267                 }
            +268 
            +269                 angleStart= -as;
            +270                 angleEnd= -ae;
            +271 
            +272                 var behavior= new CAAT.Behavior.RotateBehavior().
            +273                         setFrameTime( timeStart, timeEnd-timeStart+1).
            +274                         setValues( angleStart, angleEnd, 0, .5).
            +275                         setValueApplication(false);
            +276 
            +277                 this.__setInterpolator( behavior, curve );
            +278 
            +279                 var animation= this.__getAnimation(name);
            +280                 animation.keyframesRotate.addBehavior(behavior);
            +281             },
            +282 
            +283             endRotationKeyframes : function(name) {
            +284 
            +285             },
            +286 
            +287             addTranslationKeyframe : function( name, startX, startY, endX, endY, timeStart, timeEnd, curve ) {
            +288                 var behavior= new CAAT.Behavior.PathBehavior().
            +289                     setFrameTime( timeStart, timeEnd-timeStart+1).
            +290                     setValues( new CAAT.PathUtil.Path().
            +291                         setLinear( startX, startY, endX, endY )
            +292                     ).
            +293                     setValueApplication(false);
            +294 
            +295                 this.__setInterpolator( behavior, curve );
            +296 
            +297                 var animation= this.__getAnimation(name);
            +298                 animation.keyframesTranslate.addBehavior( behavior );
            +299             },
            +300 
            +301             addScaleKeyframe : function( name, scaleX, endScaleX, scaleY, endScaleY, timeStart, timeEnd, curve ) {
            +302                 var behavior= new CAAT.Behavior.ScaleBehavior().
            +303                     setFrameTime( timeStart, timeEnd-timeStart+1).
            +304                     setValues( scaleX, endScaleX, scaleY, endScaleY ).
            +305                     setValueApplication(false);
            +306 
            +307                 this.__setInterpolator( behavior, curve );
            +308 
            +309                 var animation= this.__getAnimation(name);
            +310                 animation.keyframesScale.addBehavior( behavior );
            +311             },
            +312 
            +313             endTranslationKeyframes : function(name) {
            +314 
            +315             },
            +316 
            +317             setSize : function(s) {
            +318                 this.width= s;
            +319                 this.height= 0;
            +320             },
            +321 
            +322             endScaleKeyframes : function(name) {
            +323 
            +324             },
            +325 
            +326             setPosition : function( x, y ) {
            +327                 this.x= x;
            +328                 this.y= -y;
            +329                 return this;
            +330             } ,
            +331 
            +332             /**
            +333              * default anchor values are for spine tool.
            +334              * @param angle {number}
            +335              * @param anchorX {number=}
            +336              * @param anchorY {number=}
            +337              * @returns {*}
            +338              */
            +339             setRotateTransform : function( angle, anchorX, anchorY ) {
            +340                 this.rotationAngle= -angle*2*Math.PI/360;
            +341                 this.rotationAnchorX= typeof anchorX!=="undefined" ? anchorX : 0;
            +342                 this.rotationAnchorY= typeof anchorY!=="undefined" ? anchorY : .5;
            +343                 return this;
            +344             },
            +345 
            +346             /**
            +347              *
            +348              * @param sx {number}
            +349              * @param sy {number}
            +350              * @param anchorX {number=} anchorX: .5 by default
            +351              * @param anchorY {number=} anchorY. .5 by default
            +352              * @returns {*}
            +353              */
            +354             setScaleTransform : function( sx, sy, anchorX, anchorY ) {
            +355                 this.scaleX= sx;
            +356                 this.scaleY= sy;
            +357                 this.scaleAnchorX= typeof anchorX!=="undefined" ? anchorX : .5;
            +358                 this.scaleAnchorY= typeof anchorY!=="undefined" ? anchorY : .5;
            +359                 return this;
            +360             },
            +361 
            +362 
            +363             __setModelViewMatrix : function() {
            +364                 var c, s, _m00, _m01, _m10, _m11;
            +365                 var mm0, mm1, mm2, mm3, mm4, mm5;
            +366                 var mm;
            +367 
            +368                 var mm = this.matrix.matrix;
            +369 
            +370                 mm0 = 1;
            +371                 mm1 = 0;
            +372                 mm3 = 0;
            +373                 mm4 = 1;
            +374 
            +375                 mm2 = this.wx - this.positionAnchorX * this.width;
            +376                 mm5 = this.wy - this.positionAnchorY * this.height;
            +377 
            +378                 if (this.wrotationAngle) {
            +379 
            +380                     var rx = this.rotationAnchorX * this.width;
            +381                     var ry = this.rotationAnchorY * this.height;
            +382 
            +383                     mm2 += mm0 * rx + mm1 * ry;
            +384                     mm5 += mm3 * rx + mm4 * ry;
            +385 
            +386                     c = Math.cos(this.wrotationAngle);
            +387                     s = Math.sin(this.wrotationAngle);
            +388                     _m00 = mm0;
            +389                     _m01 = mm1;
            +390                     _m10 = mm3;
            +391                     _m11 = mm4;
            +392                     mm0 = _m00 * c + _m01 * s;
            +393                     mm1 = -_m00 * s + _m01 * c;
            +394                     mm3 = _m10 * c + _m11 * s;
            +395                     mm4 = -_m10 * s + _m11 * c;
            +396 
            +397                     mm2 += -mm0 * rx - mm1 * ry;
            +398                     mm5 += -mm3 * rx - mm4 * ry;
            +399                 }
            +400                 if (this.wscaleX != 1 || this.wscaleY != 1) {
            +401 
            +402                     var sx = this.scaleAnchorX * this.width;
            +403                     var sy = this.scaleAnchorY * this.height;
            +404 
            +405                     mm2 += mm0 * sx + mm1 * sy;
            +406                     mm5 += mm3 * sx + mm4 * sy;
            +407 
            +408                     mm0 = mm0 * this.wscaleX;
            +409                     mm1 = mm1 * this.wscaleY;
            +410                     mm3 = mm3 * this.wscaleX;
            +411                     mm4 = mm4 * this.wscaleY;
            +412 
            +413                     mm2 += -mm0 * sx - mm1 * sy;
            +414                     mm5 += -mm3 * sx - mm4 * sy;
            +415                 }
            +416 
            +417                 mm[0] = mm0;
            +418                 mm[1] = mm1;
            +419                 mm[2] = mm2;
            +420                 mm[3] = mm3;
            +421                 mm[4] = mm4;
            +422                 mm[5] = mm5;
            +423 
            +424                 if (this.parent) {
            +425                     this.wmatrix.copy(this.parent.wmatrix);
            +426                     this.wmatrix.multiply(this.matrix);
            +427                 } else {
            +428                     this.wmatrix.identity();
            +429                 }
            +430             },
            +431 
            +432             setAnimation : function(name) {
            +433                 var animation= this.keyframesByAnimation[name];
            +434                 if (animation) {
            +435                     this.keyframesRotate= animation.keyframesRotate;
            +436                     this.keyframesScale= animation.keyframesScale;
            +437                     this.keyframesTranslate= animation.keyframesTranslate;
            +438                 }
            +439 
            +440                 for( var i= 0, l=this.children.length; i<l; i+=1 ) {
            +441                     this.children[i].setAnimation(name);
            +442                 }
            +443             },
            +444 
            +445             /**
            +446              * @param time {number}
            +447              */
            +448             apply : function( time, animationTime ) {
            +449 
            +450                 cpoint= defPoint;
            +451                 cangle= defAngle;
            +452                 cscale= defScale;
            +453 
            +454                 if (this.keyframesTranslate) {
            +455                     this.keyframesTranslate.apply(time);
            +456                 }
            +457 
            +458                 if ( this.keyframesRotate ) {
            +459                     this.keyframesRotate.apply(time);
            +460                 }
            +461 
            +462                 if ( this.keyframesScale ) {
            +463                     this.keyframesScale.apply(time);
            +464                 }
            +465 
            +466                 this.wx= cpoint.x + this.x;
            +467                 this.wy= cpoint.y + this.y;
            +468 
            +469                 this.wrotationAngle = cangle + this.rotationAngle;
            +470 
            +471                 this.wscaleX= cscale.scaleX * this.scaleX;
            +472                 this.wscaleY= cscale.scaleY * this.scaleY;
            +473 
            +474                 this.__setModelViewMatrix();
            +475 
            +476                 for( var i=0; i<this.children.length; i++ ) {
            +477                     this.children[i].apply(time);
            +478                 }
            +479             },
            +480 
            +481             transformContext : function(ctx) {
            +482                 var m= this.wmatrix.matrix;
            +483                 ctx.transform( m[0], m[3], m[1], m[4], m[2], m[5] );
            +484             },
            +485 
            +486             paint : function( actorMatrix, ctx ) {
            +487                 ctx.save();
            +488                     this.transformContext(ctx);
            +489 
            +490                     ctx.strokeStyle= 'blue';
            +491                     ctx.beginPath();
            +492                     ctx.moveTo(0,-2);
            +493                     ctx.lineTo(this.width,this.height);
            +494                     ctx.lineTo(0,2);
            +495                     ctx.lineTo(0,-2);
            +496                     ctx.stroke();
            +497                 ctx.restore();
            +498 
            +499                 for( var i=0; i<this.children.length; i++ ) {
            +500                     this.children[i].paint(actorMatrix, ctx);
            +501                 }
            +502 
            +503 
            +504             }
            +505         }
            +506     }
            +507 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_BoneActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_BoneActor.js.html new file mode 100644 index 0000000..c67f389 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_BoneActor.js.html @@ -0,0 +1,265 @@ +
              1 CAAT.Module({
            +  2 
            +  3 
            +  4     /**
            +  5      * @name BoneActor
            +  6      * @memberof CAAT.Module.Skeleton
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.Module.Skeleton.BoneActor",
            + 11     depends : [
            + 12         "CAAT.Module.Skeleton.BoneActorAttachment"
            + 13     ],
            + 14     extendsWith : function() {
            + 15 
            + 16         return {
            + 17 
            + 18             /**
            + 19              * @lends CAAT.Module.Skeleton.BoneActor.prototype
            + 20              */
            + 21 
            + 22             bone    : null,
            + 23             skinInfo : null,
            + 24             skinInfoByName : null,
            + 25             currentSkinInfo : null,
            + 26             skinDataKeyframes : null,
            + 27             parent : null,
            + 28             worldModelViewMatrix : null,
            + 29             skinMatrix : null,  // compositon of bone + skin info
            + 30             AABB : null,
            + 31 
            + 32             /**
            + 33              * @type {object}
            + 34              * @map {string}, { x:{number}, y: {number} }
            + 35              */
            + 36             attachments : null,
            + 37 
            + 38             __init : function() {
            + 39                 this.skinInfo= [];
            + 40                 this.worldModelViewMatrix= new CAAT.Math.Matrix();
            + 41                 this.skinMatrix= new CAAT.Math.Matrix();
            + 42                 this.skinInfoByName= {};
            + 43                 this.skinDataKeyframes= [];
            + 44                 this.attachments= [];
            + 45                 this.AABB= new CAAT.Math.Rectangle();
            + 46             },
            + 47 
            + 48             addAttachment : function( id, normalized_x, normalized_y, callback ) {
            + 49 
            + 50                 this.attachments.push( new CAAT.Module.Skeleton.BoneActorAttachment(id, normalized_x, normalized_y, callback) );
            + 51             },
            + 52 
            + 53             addAttachmentListener : function( al ) {
            + 54 
            + 55             },
            + 56 
            + 57             setBone : function(bone) {
            + 58                 this.bone= bone;
            + 59                 return this;
            + 60             },
            + 61 
            + 62             addSkinInfo : function( si ) {
            + 63                 if (null===this.currentSkinInfo) {
            + 64                     this.currentSkinInfo= si;
            + 65                 }
            + 66                 this.skinInfo.push( si );
            + 67                 this.skinInfoByName[ si.name ]= si;
            + 68                 return this;
            + 69             },
            + 70 
            + 71             setDefaultSkinInfoByName : function( name ) {
            + 72                 var v= this.skinInfoByName[name];
            + 73                 if (v) {
            + 74                     this.currentSkinInfo= v;
            + 75                 }
            + 76 
            + 77                 return this;
            + 78             },
            + 79 
            + 80             emptySkinDataKeyframe : function() {
            + 81                 this.skinDataKeyframes= [];
            + 82             },
            + 83 
            + 84             addSkinDataKeyframe : function( name, start, duration ) {
            + 85                 this.skinDataKeyframes.push( {
            + 86                     name : name,
            + 87                     start : start,
            + 88                     duration : duration
            + 89                 });
            + 90             },
            + 91 
            + 92             __getCurrentSkinInfo : function(time) {
            + 93                 if ( this.skinDataKeyframes.length ) {
            + 94                     time=(time%1000)/1000;
            + 95 
            + 96                     for( var i=0, l=this.skinDataKeyframes.length; i<l; i+=1 ) {
            + 97                         var sdkf= this.skinDataKeyframes[i];
            + 98                         if ( time>=sdkf.start && time<=sdkf.start+sdkf.duration ) {
            + 99                             return this.currentSkinInfo= this.skinInfoByName[ sdkf.name ];
            +100                         }
            +101                     }
            +102 
            +103                     return null;
            +104                 }
            +105 
            +106                 return this.currentSkinInfo;
            +107             },
            +108 
            +109             paint : function( ctx, time ) {
            +110 
            +111                 var skinInfo= this.__getCurrentSkinInfo(time);
            +112 
            +113                 if (!skinInfo || !skinInfo.image) {
            +114                     return;
            +115                 }
            +116 
            +117                 /*
            +118                     var w= skinInfo.width*.5;
            +119                     var h= skinInfo.height*.5;
            +120 
            +121                     ctx.translate(skinInfo.x, skinInfo.y );
            +122                     ctx.rotate(skinInfo.angle);
            +123                     ctx.scale(skinInfo.scaleX, skinInfo.scaleY);
            +124                     ctx.translate( -w, -h);
            +125                 */
            +126 
            +127                 this.worldModelViewMatrix.transformRenderingContextSet(ctx);
            +128                 skinInfo.matrix.transformRenderingContext( ctx );
            +129                 ctx.drawImage( skinInfo.image, 0, 0, skinInfo.image.width, skinInfo.image.height );
            +130 
            +131             },
            +132 
            +133             setupAnimation : function(time) {
            +134                 this.setModelViewMatrix();
            +135                 this.prepareAABB(time);
            +136                 this.__setupAttachments();
            +137             },
            +138 
            +139             prepareAABB : function(time) {
            +140                 var skinInfo= this.__getCurrentSkinInfo(time);
            +141                 var x=0, y=0, w, h;
            +142 
            +143                 if ( skinInfo ) {
            +144                     w= skinInfo.width;
            +145                     h= skinInfo.height;
            +146                 } else {
            +147                     w= h= 1;
            +148                 }
            +149 
            +150                 var vv= [
            +151                     new CAAT.Math.Point(x,y),
            +152                     new CAAT.Math.Point(x+w,0),
            +153                     new CAAT.Math.Point(x+w, y+h),
            +154                     new CAAT.Math.Point(x, y + h)
            +155                 ];
            +156 
            +157                 var AABB= this.AABB;
            +158                 var vvv;
            +159 
            +160                 /**
            +161                  * cache the bone+skin matrix for later usage in attachment calculations.
            +162                  */
            +163                 var amatrix= this.skinMatrix;
            +164                 amatrix.copy( this.worldModelViewMatrix );
            +165                 amatrix.multiply( this.currentSkinInfo.matrix );
            +166 
            +167                 for( var i=0; i<vv.length; i++ ) {
            +168                     vv[i]= amatrix.transformCoord(vv[i]);
            +169                 }
            +170 
            +171                 var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE;
            +172                 var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE;
            +173 
            +174                 vvv = vv[0];
            +175                 if (vvv.x < xmin) {
            +176                     xmin = vvv.x;
            +177                 }
            +178                 if (vvv.x > xmax) {
            +179                     xmax = vvv.x;
            +180                 }
            +181                 if (vvv.y < ymin) {
            +182                     ymin = vvv.y;
            +183                 }
            +184                 if (vvv.y > ymax) {
            +185                     ymax = vvv.y;
            +186                 }
            +187                 vvv = vv[1];
            +188                 if (vvv.x < xmin) {
            +189                     xmin = vvv.x;
            +190                 }
            +191                 if (vvv.x > xmax) {
            +192                     xmax = vvv.x;
            +193                 }
            +194                 if (vvv.y < ymin) {
            +195                     ymin = vvv.y;
            +196                 }
            +197                 if (vvv.y > ymax) {
            +198                     ymax = vvv.y;
            +199                 }
            +200                 vvv = vv[2];
            +201                 if (vvv.x < xmin) {
            +202                     xmin = vvv.x;
            +203                 }
            +204                 if (vvv.x > xmax) {
            +205                     xmax = vvv.x;
            +206                 }
            +207                 if (vvv.y < ymin) {
            +208                     ymin = vvv.y;
            +209                 }
            +210                 if (vvv.y > ymax) {
            +211                     ymax = vvv.y;
            +212                 }
            +213                 vvv = vv[3];
            +214                 if (vvv.x < xmin) {
            +215                     xmin = vvv.x;
            +216                 }
            +217                 if (vvv.x > xmax) {
            +218                     xmax = vvv.x;
            +219                 }
            +220                 if (vvv.y < ymin) {
            +221                     ymin = vvv.y;
            +222                 }
            +223                 if (vvv.y > ymax) {
            +224                     ymax = vvv.y;
            +225                 }
            +226 
            +227                 AABB.x = xmin;
            +228                 AABB.y = ymin;
            +229                 AABB.x1 = xmax;
            +230                 AABB.y1 = ymax;
            +231                 AABB.width = (xmax - xmin);
            +232                 AABB.height = (ymax - ymin);
            +233             },
            +234 
            +235             setModelViewMatrix : function() {
            +236 
            +237                 if (this.parent) {
            +238                     this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix);
            +239                     this.worldModelViewMatrix.multiply(this.bone.wmatrix);
            +240 
            +241                 } else {
            +242                     this.worldModelViewMatrix.identity();
            +243                 }
            +244             },
            +245 
            +246             __setupAttachments : function( ) {
            +247                 for( var i= 0, l=this.attachments.length; i<l; i+=1 ) {
            +248                     var attachment= this.attachments[ i ];
            +249                     attachment.transform( this.skinMatrix, this.currentSkinInfo.width, this.currentSkinInfo.height );
            +250                 }
            +251             },
            +252 
            +253             getAttachment : function( id ) {
            +254                 return this.attachments[id];
            +255             }
            +256         }
            +257     }
            +258 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Skeleton.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Skeleton.js.html new file mode 100644 index 0000000..099388a --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_Skeleton.js.html @@ -0,0 +1,290 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name Skeleton
            +  5      * @memberof CAAT.Module.Skeleton
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Module.Skeleton.Skeleton",
            + 10     depends : [
            + 11         "CAAT.Module.Skeleton.Bone"
            + 12     ],
            + 13     extendsWith : {
            + 14 
            + 15         /**
            + 16          * @lends CAAT.Module.Skeleton.Skeleton.prototype
            + 17          */
            + 18 
            + 19         bones : null,
            + 20         bonesArray : null,
            + 21         animation : null,
            + 22         root  : null,
            + 23         currentAnimationName : null,
            + 24         skeletonDataFromFile : null,
            + 25 
            + 26         __init : function(skeletonDataFromFile) {
            + 27             this.bones= {};
            + 28             this.bonesArray= [];
            + 29             this.animations= {};
            + 30 
            + 31             // bones
            + 32             if (skeletonDataFromFile) {
            + 33                 this.__setSkeleton( skeletonDataFromFile );
            + 34             }
            + 35         },
            + 36 
            + 37         getSkeletonDataFromFile : function() {
            + 38             return this.skeletonDataFromFile;
            + 39         },
            + 40 
            + 41         __setSkeleton : function( skeletonDataFromFile ) {
            + 42             this.skeletonDataFromFile= skeletonDataFromFile;
            + 43             for ( var i=0; i<skeletonDataFromFile.bones.length; i++ ) {
            + 44                 var boneInfo= skeletonDataFromFile.bones[i];
            + 45                 this.addBone(boneInfo);
            + 46             }
            + 47         },
            + 48 
            + 49         setSkeletonFromFile : function(url) {
            + 50             var me= this;
            + 51             new CAAT.Module.Preloader.XHR().load(
            + 52                     function( result, content ) {
            + 53                         if (result==="ok" ) {
            + 54                             me.__setSkeleton( JSON.parse(content) );
            + 55                         }
            + 56                     },
            + 57                     url,
            + 58                     false,
            + 59                     "GET"
            + 60             );
            + 61 
            + 62             return this;
            + 63         },
            + 64 
            + 65         addAnimationFromFile : function(name, url) {
            + 66             var me= this;
            + 67             new CAAT.Module.Preloader.XHR().load(
            + 68                     function( result, content ) {
            + 69                         if (result==="ok" ) {
            + 70                             me.addAnimation( name, JSON.parse(content) );
            + 71                         }
            + 72                     },
            + 73                     url,
            + 74                     false,
            + 75                     "GET"
            + 76             );
            + 77 
            + 78             return this;
            + 79         },
            + 80 
            + 81         addAnimation : function(name, animation) {
            + 82 
            + 83             // bones animation
            + 84             for( var bonename in animation.bones ) {
            + 85 
            + 86                 var boneanimation= animation.bones[bonename];
            + 87 
            + 88                 if ( boneanimation.rotate ) {
            + 89 
            + 90                     for( var i=0; i<boneanimation.rotate.length-1; i++ ) {
            + 91                         this.addRotationKeyframe(
            + 92                             name,
            + 93                             {
            + 94                                 boneId : bonename,
            + 95                                 angleStart : boneanimation.rotate[i].angle,
            + 96                                 angleEnd : boneanimation.rotate[i+1].angle,
            + 97                                 timeStart : boneanimation.rotate[i].time*1000,
            + 98                                 timeEnd : boneanimation.rotate[i+1].time*1000,
            + 99                                 curve : boneanimation.rotate[i].curve
            +100                             } );
            +101                     }
            +102                 }
            +103 
            +104                 if (boneanimation.translate) {
            +105 
            +106                     for( var i=0; i<boneanimation.translate.length-1; i++ ) {
            +107 
            +108                         this.addTranslationKeyframe(
            +109                             name,
            +110                             {
            +111                                 boneId      : bonename,
            +112                                 startX      : boneanimation.translate[i].x,
            +113                                 startY      : -boneanimation.translate[i].y,
            +114                                 endX        : boneanimation.translate[i+1].x,
            +115                                 endY        : -boneanimation.translate[i+1].y,
            +116                                 timeStart   : boneanimation.translate[i].time * 1000,
            +117                                 timeEnd     : boneanimation.translate[i+1].time * 1000,
            +118                                 curve       : "stepped" //boneanimation.translate[i].curve
            +119 
            +120                             });
            +121                     }
            +122                 }
            +123 
            +124                 if ( boneanimation.scale ) {
            +125                     for( var i=0; i<boneanimation.scale.length-1; i++ ) {
            +126                         this.addScaleKeyframe(
            +127                             name,
            +128                             {
            +129                                 boneId : bonename,
            +130                                 startScaleX : boneanimation.rotate[i].x,
            +131                                 endScaleX : boneanimation.rotate[i+1].x,
            +132                                 startScaleY : boneanimation.rotate[i].y,
            +133                                 endScaleY : boneanimation.rotate[i+1].y,
            +134                                 timeStart : boneanimation.rotate[i].time*1000,
            +135                                 timeEnd : boneanimation.rotate[i+1].time*1000,
            +136                                 curve : boneanimation.rotate[i].curve
            +137                             } );
            +138                     }
            +139                 }
            +140 
            +141                 this.endKeyframes( name, bonename );
            +142 
            +143             }
            +144 
            +145             if ( null===this.currentAnimationName ) {
            +146                 this.animations[name]= animation;
            +147                 this.setAnimation(name);
            +148             }
            +149 
            +150             return this;
            +151         },
            +152 
            +153         setAnimation : function(name) {
            +154             this.root.setAnimation( name );
            +155             this.currentAnimationName= name;
            +156         },
            +157 
            +158         getCurrentAnimationData : function() {
            +159             return this.animations[ this.currentAnimationName ];
            +160         },
            +161 
            +162         getAnimationDataByName : function(name) {
            +163             return this.animations[name];
            +164         },
            +165 
            +166         getNumBones : function() {
            +167             return this.bonesArray.length;
            +168         },
            +169 
            +170         getRoot : function() {
            +171             return this.root;
            +172         },
            +173 
            +174         calculate : function(time, animationTime) {
            +175             this.root.apply(time, animationTime);
            +176         },
            +177 
            +178         getBoneById : function(id) {
            +179             return this.bones[id];
            +180         },
            +181 
            +182         getBoneByIndex : function(index) {
            +183             return this.bonesArray[ index ];
            +184         },
            +185 
            +186         addBone : function( boneInfo ) {
            +187             var bone= new CAAT.Module.Skeleton.Bone(boneInfo.name);
            +188 
            +189             bone.setPosition(
            +190                 typeof boneInfo.x!=="undefined" ? boneInfo.x : 0,
            +191                 typeof boneInfo.y!=="undefined" ? boneInfo.y : 0 );
            +192             bone.setRotateTransform( boneInfo.rotation ? boneInfo.rotation : 0 );
            +193             bone.setSize( boneInfo.length ? boneInfo.length : 0, 0 );
            +194 
            +195             this.bones[boneInfo.name]= bone;
            +196 
            +197             if (boneInfo.parent) {
            +198 
            +199                 var parent= this.bones[boneInfo.parent];
            +200                 if ( parent ) {
            +201                     parent.addBone(bone);
            +202                 } else {
            +203                     console.log("Referenced parent Bone '"+boneInfo.parent+"' which does not exist");
            +204                 }
            +205             }
            +206 
            +207             this.bonesArray.push(bone);
            +208 
            +209             // BUGBUG should be an explicit root bone identification.
            +210             if (!this.root) {
            +211                 this.root= bone;
            +212             }
            +213         },
            +214 
            +215         addRotationKeyframe : function( name, keyframeInfo ) {
            +216             var bone= this.bones[ keyframeInfo.boneId ];
            +217             if ( bone ) {
            +218                 bone.addRotationKeyframe(
            +219                     name,
            +220                     keyframeInfo.angleStart,
            +221                     keyframeInfo.angleEnd,
            +222                     keyframeInfo.timeStart,
            +223                     keyframeInfo.timeEnd,
            +224                     keyframeInfo.curve
            +225                 )
            +226             } else {
            +227                 console.log("Rotation Keyframe for non-existant bone: '"+keyframeInfo.boneId+"'" );
            +228             }
            +229         },
            +230 
            +231         addScaleKeyframe : function( name, keyframeInfo ) {
            +232             var bone= this.bones[ keyframeInfo.boneId ];
            +233             if ( bone ) {
            +234                 bone.addRotationKeyframe(
            +235                     name,
            +236                     keyframeInfo.startScaleX,
            +237                     keyframeInfo.endScaleX,
            +238                     keyframeInfo.startScaleY,
            +239                     keyframeInfo.endScaleY,
            +240                     keyframeInfo.timeStart,
            +241                     keyframeInfo.timeEnd,
            +242                     keyframeInfo.curve
            +243                 )
            +244             } else {
            +245                 console.log("Scale Keyframe for non-existant bone: '"+keyframeInfo.boneId+"'" );
            +246             }
            +247         },
            +248 
            +249         addTranslationKeyframe : function( name, keyframeInfo ) {
            +250 
            +251             var bone= this.bones[ keyframeInfo.boneId ];
            +252             if ( bone ) {
            +253 
            +254                 bone.addTranslationKeyframe(
            +255                     name,
            +256                     keyframeInfo.startX,
            +257                     keyframeInfo.startY,
            +258                     keyframeInfo.endX,
            +259                     keyframeInfo.endY,
            +260                     keyframeInfo.timeStart,
            +261                     keyframeInfo.timeEnd,
            +262                     keyframeInfo.curve
            +263                 )
            +264             } else {
            +265                 console.log("Translation Keyframe for non-existant bone: '"+keyframeInfo.boneId+"'" );
            +266             }
            +267         },
            +268 
            +269         endKeyframes : function( name, boneId ) {
            +270             var bone= this.bones[boneId];
            +271             if (bone) {
            +272                 bone.endTranslationKeyframes(name);
            +273                 bone.endRotationKeyframes(name);
            +274                 bone.endScaleKeyframes(name);
            +275             }
            +276         },
            +277 
            +278         paint : function( actorMatrix, ctx ) {
            +279             this.root.paint(actorMatrix,ctx);
            +280         }
            +281 
            +282     }
            +283 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_SkeletonActor.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_SkeletonActor.js.html new file mode 100644 index 0000000..947f767 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Skeleton_SkeletonActor.js.html @@ -0,0 +1,389 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name SkeletonActor
            +  5      * @memberof CAAT.Module.Skeleton.prototype
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines: "CAAT.Module.Skeleton.SkeletonActor",
            + 10     extendsClass: "CAAT.Foundation.Actor",
            + 11     depends: [
            + 12         "CAAT.Module.Skeleton.Skeleton",
            + 13         "CAAT.Module.Skeleton.BoneActor",
            + 14         "CAAT.Foundation.Actor"
            + 15     ],
            + 16     extendsWith: function () {
            + 17 
            + 18 
            + 19 
            + 20         /**
            + 21          * Holder to keep animation slots information.
            + 22          */
            + 23         function SlotInfoData( sortId, attachment, name, bone ) {
            + 24 
            + 25             this.sortId= sortId;
            + 26             this.attachment= attachment;
            + 27             this.name= name;
            + 28             this.bone= bone;
            + 29 
            + 30             return this;
            + 31         }
            + 32 
            + 33         return {
            + 34 
            + 35             /**
            + 36              * @lends CAAT.Module.Skeleton.SkeletonActor
            + 37              */
            + 38 
            + 39             skeleton: null,
            + 40 
            + 41             /**
            + 42              * @type object
            + 43              * @map < boneId{string}, SlotInfoData >
            + 44              */
            + 45             slotInfo: null,
            + 46 
            + 47             /**
            + 48              * @type Array.<SlotInfoData>
            + 49              */
            + 50             slotInfoArray: null,
            + 51 
            + 52             /**
            + 53              * @type object
            + 54              * @map
            + 55              */
            + 56             skinByName: null,
            + 57 
            + 58             /**
            + 59              * @type CAAT.Foundation.Director
            + 60              */
            + 61             director: null,
            + 62 
            + 63             /**
            + 64              * @type boolean
            + 65              */
            + 66             _showBones: false,
            + 67 
            + 68             /**
            + 69              * Currently selected animation play time.
            + 70              * Zero to make it last for its default value.
            + 71              * @type number
            + 72              */
            + 73             animationDuration : 0,
            + 74 
            + 75             showAABB : false,
            + 76             bonesActor : null,
            + 77 
            + 78             __init: function (director, skeleton) {
            + 79                 this.__super();
            + 80 
            + 81                 this.director = director;
            + 82                 this.skeleton = skeleton;
            + 83                 this.slotInfo = {};
            + 84                 this.slotInfoArray = [];
            + 85                 this.bonesActor= [];
            + 86                 this.skinByName = {};
            + 87 
            + 88                 this.setSkin();
            + 89                 this.setAnimation("default");
            + 90 
            + 91                 return this;
            + 92             },
            + 93 
            + 94             showBones: function (show) {
            + 95                 this._showBones = show;
            + 96                 return this;
            + 97             },
            + 98 
            + 99             /**
            +100              * build an sprite-sheet composed of numSprites elements and organized in rows x columns
            +101              * @param numSprites {number}
            +102              * @param rows {number=}
            +103              * @param columns {number=}
            +104              */
            +105             buildSheet : function( numSprites, rows, columns ) {
            +106 
            +107                 var i, j,l;
            +108                 var AABBs= [];
            +109                 var maxTime= 1000;  // BUGBUG search for animation time.
            +110                 var ssItemWidth, ssItemHeight;  // sprite sheet item width and height
            +111                 var ssItemMinX= Number.MAX_VALUE, ssItemMinY= Number.MAX_VALUE;
            +112                 var ssItemMaxOffsetY, ssItemMaxOffsetX;
            +113 
            +114                 // prepare this actor's world model view matrix, but with no position.
            +115                 var px= this.x;
            +116                 var py= this.y;
            +117                 this.x= this.y= 0;
            +118                 this.setModelViewMatrix();
            +119 
            +120 
            +121                 rows= rows || 1;
            +122                 columns= columns || 1;
            +123 
            +124                 // calculate all sprite sheet frames aabb.
            +125                 for( j=0; j<numSprites; j++ ) {
            +126                     var aabb= new CAAT.Math.Rectangle();
            +127                     var time= maxTime/numSprites*j;
            +128                     AABBs.push( aabb );
            +129                     this.skeleton.calculate( time, this.animationDuration );
            +130 
            +131                     for( i= 0, l= this.bonesActor.length; i<l; i+=1 ) {
            +132                         var bone= this.bonesActor[i];
            +133                         var boneAABB;
            +134                         bone.setupAnimation(time);
            +135                         boneAABB= bone.AABB;
            +136                         aabb.unionRectangle(boneAABB);
            +137                         if ( boneAABB.x < ssItemMinX ) {
            +138                             ssItemMinX= boneAABB.x;
            +139                         }
            +140                     }
            +141                 }
            +142 
            +143                 // calculate offsets for each aabb and sprite-sheet element size.
            +144                 ssItemWidth= 0;
            +145                 ssItemHeight= 0;
            +146                 ssItemMinX= Number.MAX_VALUE;
            +147                 ssItemMinY= Number.MAX_VALUE;
            +148                 for( i=0; i<AABBs.length; i++ ) {
            +149                     if ( AABBs[i].x < ssItemMinX ) {
            +150                         ssItemMinX= AABBs[i].x;
            +151                     }
            +152                     if ( AABBs[i].y < ssItemMinY ) {
            +153                         ssItemMinY= AABBs[i].y;
            +154                     }
            +155                     if ( AABBs[i].width>ssItemWidth ) {
            +156                         ssItemWidth= AABBs[i].width;
            +157                     }
            +158                     if ( AABBs[i].height>ssItemHeight ) {
            +159                         ssItemHeight= AABBs[i].height;
            +160                     }
            +161                 }
            +162                 ssItemWidth= (ssItemWidth|0)+1;
            +163                 ssItemHeight= (ssItemHeight|0)+1;
            +164 
            +165                 // calculate every animation offset against biggest animation size.
            +166                 ssItemMaxOffsetY= -Number.MAX_VALUE;
            +167                 ssItemMaxOffsetX= -Number.MAX_VALUE;
            +168                 var offsetMinX=Number.MAX_VALUE, offsetMaxX=-Number.MAX_VALUE;
            +169                 for( i=0; i<AABBs.length; i++ ) {
            +170                     var offsetX= (ssItemWidth - AABBs[i].width)/2;
            +171                     var offsetY= (ssItemHeight - AABBs[i].height)/2;
            +172 
            +173                     if ( offsetY>ssItemMaxOffsetY ) {
            +174                         ssItemMaxOffsetY= offsetY;
            +175                     }
            +176 
            +177                     if ( offsetX>ssItemMaxOffsetX ) {
            +178                         ssItemMaxOffsetX= offsetX;
            +179                     }
            +180                 }
            +181 
            +182 
            +183                 // create a canvas of the neccessary size
            +184                 var canvas= document.createElement("canvas");
            +185                 canvas.width= ssItemWidth * numSprites;
            +186                 canvas.height= ssItemHeight;
            +187                 var ctx= canvas.getContext("2d");
            +188 
            +189                 // draw animation into canvas.
            +190                 for( j=0; j<numSprites; j++ ) {
            +191 
            +192                     //this.x= j*ssItemWidth + offsetMaxX - ssItemMaxOffsetX ;
            +193                     this.x= j*ssItemWidth - ssItemMinX;
            +194                     this.y= ssItemHeight - ssItemMaxOffsetY/2 - 1;
            +195 
            +196                     this.setModelViewMatrix();
            +197 
            +198                     var time= maxTime/numSprites*j;
            +199                     this.skeleton.calculate( time, this.animationDuration );
            +200 
            +201                     // prepare bones
            +202                     for( i= 0, l= this.bonesActor.length; i<l; i+=1 ) {
            +203                         this.bonesActor[i].setupAnimation(time);
            +204                         this.bonesActor[i].paint( ctx, time );
            +205                     }
            +206 
            +207                     ctx.restore();
            +208                 }
            +209 
            +210                 this.x= px;
            +211                 this.y= py;
            +212 
            +213                 return canvas;
            +214             },
            +215 
            +216             animate: function (director, time) {
            +217                 var i,l;
            +218 
            +219                 var ret= CAAT.Module.Skeleton.SkeletonActor.superclass.animate.call( this, director, time );
            +220 
            +221                 this.skeleton.calculate( time, this.animationDuration );
            +222 
            +223                 for( i= 0, l= this.bonesActor.length; i<l; i+=1 ) {
            +224                     this.bonesActor[i].setupAnimation(time);
            +225                 }
            +226 
            +227                 this.AABB.setEmpty();
            +228                 for( i= 0, l= this.bonesActor.length; i<l; i+=1 ) {
            +229                     this.AABB.unionRectangle(this.bonesActor[i].AABB);
            +230                 }
            +231 
            +232                 return ret;
            +233             },
            +234 
            +235             paint : function( director, time ) {
            +236                 CAAT.Module.Skeleton.SkeletonActor.superclass.paint.call(this,director,time);
            +237                 for( var i= 0, l=this.bonesActor.length; i<l; i+=1 ) {
            +238                     this.bonesActor[i].paint( director.ctx, time );
            +239                 }
            +240 
            +241 
            +242                 if (this._showBones && this.skeleton) {
            +243                     this.worldModelViewMatrix.transformRenderingContextSet(director.ctx);
            +244                     this.skeleton.paint(this.worldModelViewMatrix, director.ctx);
            +245                 }
            +246             },
            +247 
            +248             __addBoneActor : function( boneActor ) {
            +249                 this.bonesActor.push( boneActor );
            +250                 boneActor.parent= this;
            +251                 return this;
            +252             },
            +253 
            +254             setSkin: function (skin) {
            +255 
            +256                 this.bonesActor= [];
            +257                 this.slotInfoArray = [];
            +258                 this.slotInfo = {};
            +259 
            +260                 var skeletonData = this.skeleton.getSkeletonDataFromFile();
            +261 
            +262                 // slots info
            +263                 for (var slot = 0; slot < skeletonData.slots.length; slot++) {
            +264                     var slotInfo = skeletonData.slots[slot];
            +265                     var bone = this.skeleton.getBoneById(slotInfo.bone);
            +266                     if (bone) {
            +267                         var slotInfoData = new SlotInfoData(
            +268                                 slot,
            +269                                 slotInfo.attachment,
            +270                                 slotInfo.name,
            +271                                 slotInfo.bone );
            +272 
            +273                         this.slotInfo[ bone.id ] = slotInfoData;
            +274                         this.slotInfoArray.push(slotInfoData);
            +275 
            +276 
            +277                         var skinData = null;
            +278                         if (skin) {
            +279                             skinData = skeletonData.skins[skin][slotInfo.name];
            +280                         }
            +281                         if (!skinData) {
            +282                             skinData = skeletonData.skins["default"][slotInfo.name];
            +283                         }
            +284                         if (skinData) {
            +285 
            +286                             //create an actor for each slot data found.
            +287                             var boneActorSkin = new CAAT.Module.Skeleton.BoneActor();
            +288                             boneActorSkin.id = slotInfo.name;
            +289                             boneActorSkin.setBone(bone);
            +290 
            +291                             this.__addBoneActor(boneActorSkin);
            +292                             this.skinByName[slotInfo.name] = boneActorSkin;
            +293 
            +294                             // add skining info for each slot data.
            +295                             for (var skinDef in skinData) {
            +296                                 var skinInfo = skinData[skinDef];
            +297                                 var angle= -(skinInfo.rotation || 0) * 2 * Math.PI / 360;
            +298                                 var x= skinInfo.x|0;
            +299                                 var y= -skinInfo.y|0;
            +300                                 var w= skinInfo.width|0;
            +301                                 var h= skinInfo.height|0;
            +302                                 var scaleX= skinInfo.scaleX|1;
            +303                                 var scaleY= skinInfo.scaleY|1;
            +304 
            +305                                 var matrix= CAAT.Math.Matrix.translate( -skinInfo.width/2, -skinInfo.height/2 );
            +306                                 matrix.premultiply( CAAT.Math.Matrix.rotate( angle ) );
            +307                                 matrix.premultiply( CAAT.Math.Matrix.scale( scaleX, scaleY ) );
            +308                                 matrix.premultiply( CAAT.Math.Matrix.translate( x, y ) );
            +309 
            +310                                 /*
            +311                                 only needed values are:
            +312                                   + image
            +313                                   + matrix
            +314                                   + name
            +315 
            +316                                   all the rest are just to keep original values.
            +317                                  */
            +318                                 boneActorSkin.addSkinInfo({
            +319                                     angle: angle,
            +320                                     x: x,
            +321                                     y: y,
            +322                                     width: w,
            +323                                     height: h,
            +324                                     image: this.director.getImage(skinData[skinDef].name ? skinData[skinDef].name : skinDef),
            +325                                     matrix : matrix,
            +326                                     scaleX : scaleX,
            +327                                     scaleY : scaleY,
            +328                                     name: skinDef
            +329                                 });
            +330                             }
            +331 
            +332                             boneActorSkin.setDefaultSkinInfoByName(slotInfo.attachment);
            +333                         }
            +334                     } else {
            +335                         console.log("Unknown bone to apply skin: " + slotInfo.bone);
            +336                     }
            +337                 }
            +338 
            +339                 return this;
            +340             },
            +341 
            +342             setAnimation: function (name, animationDuration ) {
            +343 
            +344                 this.animationDuration= animationDuration||0;
            +345 
            +346                 var animationInfo = this.skeleton.getAnimationDataByName(name);
            +347                 if (!animationInfo) {
            +348                     return;
            +349                 }
            +350 
            +351                 var animationSlots = animationInfo.slots;
            +352                 for (var animationSlot in animationSlots) {
            +353                     var attachments = animationSlots[animationSlot].attachment;
            +354                     var boneActor = this.skinByName[ animationSlot ];
            +355                     if (boneActor) {
            +356                         boneActor.emptySkinDataKeyframe();
            +357                         for (var i = 0, l = attachments.length - 1; i < l; i += 1) {
            +358                             var start = attachments[i].time;
            +359                             var len = attachments[i + 1].time - attachments[i].time;
            +360                             boneActor.addSkinDataKeyframe(attachments[i].name, start, len);
            +361                         }
            +362                     } else {
            +363                         console.log("Adding skinDataKeyframe to unkown boneActor: " + animationSlot);
            +364                     }
            +365                 }
            +366 
            +367                 return this;
            +368             },
            +369 
            +370             getBoneActorById : function( id ) {
            +371                 return this.skinByName[id];
            +372             },
            +373 
            +374             addAttachment : function( slotId, normalized_x, normalized_y, callback ) {
            +375                 var slotBoneActor= this.getBoneActorById(slotId);
            +376                 if ( slotBoneActor ) {
            +377                     slotBoneActor.addAttachment(slotId,normalized_x,normalized_y,callback);
            +378                 }
            +379             }
            +380         }
            +381     }
            +382 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Storage_LocalStorage.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Storage_LocalStorage.js.html new file mode 100644 index 0000000..26c2f31 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_Storage_LocalStorage.js.html @@ -0,0 +1,87 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 CAAT.Module({
            +  6 
            +  7     /**
            +  8      * @name Storage
            +  9      * @memberOf CAAT.Module
            + 10      * @namespace
            + 11      */
            + 12 
            + 13     /**
            + 14      * @name LocalStorage
            + 15      * @memberOf CAAT.Module.Storage
            + 16      * @namespace
            + 17      */
            + 18 
            + 19     defines : "CAAT.Module.Storage.LocalStorage",
            + 20     constants : {
            + 21 
            + 22         /**
            + 23          * @lends CAAT.Module.Storage.LocalStorage
            + 24          */
            + 25 
            + 26         /**
            + 27          * Stores an object in local storage. The data will be saved as JSON.stringify.
            + 28          * @param key {string} key to store data under.
            + 29          * @param data {object} an object.
            + 30          * @return this
            + 31          *
            + 32          * @static
            + 33          */
            + 34         save : function( key, data ) {
            + 35             try {
            + 36                 localStorage.setItem( key, JSON.stringify(data) );
            + 37             } catch(e) {
            + 38                 // eat it
            + 39             }
            + 40             return this;
            + 41         },
            + 42         /**
            + 43          * Retrieve a value from local storage.
            + 44          * @param key {string} the key to retrieve.
            + 45          * @return {object} object stored under the key parameter.
            + 46          *
            + 47          * @static
            + 48          */
            + 49         load : function( key, defValue ) {
            + 50             try {
            + 51                 var v= localStorage.getItem( key );
            + 52 
            + 53                 return null===v ? defValue : JSON.parse(v);
            + 54             } catch(e) {
            + 55                 return null;
            + 56             }
            + 57         },
            + 58 
            + 59         /**
            + 60          * Removes a value stored in local storage.
            + 61          * @param key {string}
            + 62          * @return this
            + 63          *
            + 64          * @static
            + 65          */
            + 66         remove : function( key ) {
            + 67             try {
            + 68                 localStorage.removeItem(key);
            + 69             } catch(e) {
            + 70                 // eat it
            + 71             }
            + 72             return this;
            + 73         }
            + 74     },
            + 75     extendsWith : {
            + 76 
            + 77     }
            + 78 
            + 79 });
            + 80 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureElement.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureElement.js.html new file mode 100644 index 0000000..3b34d0b --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureElement.js.html @@ -0,0 +1,56 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name TexturePacker
            +  5      * @memberOf CAAT.Module
            +  6      * @namespace
            +  7      */
            +  8 
            +  9     /**
            + 10      * @name TextureElement
            + 11      * @memberOf CAAT.Module.TexturePacker
            + 12      * @constructor
            + 13      */
            + 14 
            + 15 
            + 16     defines : "CAAT.Module.TexturePacker.TextureElement",
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Module.TexturePacker.TextureElement.prototype
            + 21          */
            + 22 
            + 23         /**
            + 24          *
            + 25          */
            + 26         inverted:   false,
            + 27 
            + 28         /**
            + 29          *
            + 30          */
            + 31         image:      null,
            + 32 
            + 33         /**
            + 34          *
            + 35          */
            + 36         u:          0,
            + 37 
            + 38         /**
            + 39          *
            + 40          */
            + 41         v:          0,
            + 42 
            + 43         /**
            + 44          *
            + 45          */
            + 46         glTexture:  null
            + 47     }
            + 48 });
            + 49 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePage.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePage.js.html new file mode 100644 index 0000000..6b9f482 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePage.js.html @@ -0,0 +1,303 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TexturePage
            +  5      * @memberOf CAAT.Module.TexturePacker
            +  6      * @constructor
            +  7      */
            +  8 
            +  9 
            + 10     defines : "CAAT.Module.TexturePacker.TexturePage",
            + 11     depends : [
            + 12         "CAAT.Module.TexturePacker.TextureScanMap"
            + 13     ],
            + 14     extendsWith : {
            + 15 
            + 16         /**
            + 17          * @lends CAAT.Module.TexturePacker.TexturePage.prototype
            + 18          */
            + 19 
            + 20         __init : function(w,h) {
            + 21             this.width=         w || 1024;
            + 22             this.height=        h || 1024;
            + 23             this.images=        [];
            + 24 
            + 25             return this;
            + 26         },
            + 27 
            + 28         /**
            + 29          *
            + 30          */
            + 31         width:                  1024,
            + 32 
            + 33         /**
            + 34          *
            + 35          */
            + 36         height:                 1024,
            + 37 
            + 38         /**
            + 39          *
            + 40          */
            + 41         gl:                     null,
            + 42 
            + 43         /**
            + 44          *
            + 45          */
            + 46         texture:                null,
            + 47 
            + 48         /**
            + 49          *
            + 50          */
            + 51         allowImagesInvertion:   false,
            + 52 
            + 53         /**
            + 54          *
            + 55          */
            + 56         padding:                4,
            + 57 
            + 58         /**
            + 59          *
            + 60          */
            + 61         scan:                   null,
            + 62 
            + 63         /**
            + 64          *
            + 65          */
            + 66         images:                 null,
            + 67 
            + 68         /**
            + 69          *
            + 70          */
            + 71         criteria:               'area',
            + 72 
            + 73         initialize : function(gl) {
            + 74             this.gl= gl;
            + 75 
            + 76             // Fix firefox.
            + 77             gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
            + 78 
            + 79             this.texture = gl.createTexture();
            + 80 
            + 81             gl.bindTexture(gl.TEXTURE_2D, this.texture);
            + 82             gl.enable( gl.BLEND );
            + 83             gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
            + 84 
            + 85             var uarr= new Uint8Array(this.width*this.height*4);
            + 86             for (var jj = 0; jj < 4*this.width*this.height; ) {
            + 87                 uarr[jj++]=0;
            + 88                 uarr[jj++]=0;
            + 89                 uarr[jj++]=0;
            + 90                 uarr[jj++]=0;
            + 91             }
            + 92             gl.texImage2D(
            + 93                     gl.TEXTURE_2D,
            + 94                     0,
            + 95                     gl.RGBA,
            + 96                     this.width,
            + 97                     this.height,
            + 98                     0,
            + 99                     gl.RGBA,
            +100                     gl.UNSIGNED_BYTE,
            +101                     uarr);
            +102 
            +103             gl.enable( gl.BLEND );
            +104 
            +105             for( var i=0; i<this.images.length; i++ ) {
            +106 
            +107                 var img= this.images[i];
            +108                 if ( img.inverted ) {
            +109                     img= CAAT.Module.Image.ImageUtil.rotate( img, -90 );
            +110                 }
            +111 
            +112                 gl.texSubImage2D(
            +113                         gl.TEXTURE_2D,
            +114                         0,
            +115                         this.images[i].__tx, this.images[i].__ty,
            +116                         gl.RGBA,
            +117                         gl.UNSIGNED_BYTE,
            +118                         img );
            +119             }
            +120 
            +121         },
            +122         create: function(imagesCache) {
            +123 
            +124             var images= [];
            +125             for( var i=0; i<imagesCache.length; i++ ) {
            +126                 var img= imagesCache[i].image;
            +127                 if ( !img.__texturePage ) {
            +128                     images.push( img );
            +129                 }
            +130             }
            +131 
            +132             this.createFromImages(images);
            +133         },
            +134         clear : function() {
            +135             this.createFromImages([]);
            +136         },
            +137         update : function(invert,padding,width,height) {
            +138             this.allowImagesInvertion= invert;
            +139             this.padding= padding;
            +140 
            +141             if ( width<100 ) {
            +142                 width= 100;
            +143             }
            +144             if ( height<100 ) {
            +145                 height= 100;
            +146             }
            +147 
            +148             this.width=  width;
            +149             this.height= height;
            +150             
            +151             this.createFromImages(this.images);
            +152         },
            +153         createFromImages : function( images ) {
            +154 
            +155             var i;
            +156 
            +157             this.scan=   new CAAT.Module.TexturePacker.TextureScanMap( this.width, this.height );
            +158             this.images= [];
            +159 
            +160             if ( this.allowImagesInvertion ) {
            +161                 for( i=0; i<images.length; i++ ) {
            +162                     images[i].inverted= this.allowImagesInvertion && images[i].height<images[i].width;
            +163                 }
            +164             }
            +165 
            +166             var me= this;
            +167 
            +168             images.sort( function(a,b) {
            +169 
            +170                 var aarea= a.width*a.height;
            +171                 var barea= b.width*b.height;
            +172 
            +173                 if ( me.criteria==='width' ) {
            +174                     return a.width<b.width ? 1 : a.width>b.width ? -1 : 0;
            +175                 } else if ( me.criteria==='height' ) {
            +176                     return a.height<b.height ? 1 : a.height>b.height ? -1 : 0;
            +177                 }
            +178                 return aarea<barea ? 1 : aarea>barea ? -1 : 0;
            +179             });
            +180 
            +181             for( i=0; i<images.length; i++ ) {
            +182                 var img=  images[i];
            +183                 this.packImage(img);
            +184             }
            +185         },
            +186         addImage : function( image, invert, padding ) {
            +187             this.allowImagesInvertion= invert;
            +188             this.padding= padding;
            +189             this.images.push(image);
            +190             this.createFromImages(Array.prototype.slice.call(this.images));
            +191         },
            +192         endCreation : function() {
            +193             var gl= this.gl;
            +194             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
            +195             gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST);
            +196             gl.generateMipmap(gl.TEXTURE_2D);
            +197         },
            +198         deletePage : function() {
            +199             for( var i=0; i<this.images.length; i++ ) {
            +200                 delete this.images[i].__texturePage;
            +201                 delete this.images[i].__u;
            +202                 delete this.images[i].__v;
            +203             }
            +204 
            +205             this.gl.deleteTexture( this.texture );
            +206         },
            +207         toCanvas : function(canvass, outline) {
            +208 
            +209             canvass= canvass || document.createElement('canvas');
            +210             canvass.width= this.width;
            +211             canvass.height= this.height;
            +212             var ctxx= canvass.getContext('2d');
            +213             ctxx.fillStyle= 'rgba(0,0,0,0)';
            +214             ctxx.fillRect(0,0,this.width,this.height);
            +215 
            +216             for( var i=0; i<this.images.length; i++ ) {
            +217                 ctxx.drawImage(
            +218                         !this.images[i].inverted ?
            +219                                 this.images[i] :
            +220                                 CAAT.Modules.Image.ImageUtil.rotate( this.images[i], 90 ),
            +221                         this.images[i].__tx,
            +222                         this.images[i].__ty );
            +223                 if ( outline ) {
            +224                     ctxx.strokeStyle= 'red';
            +225                     ctxx.strokeRect(
            +226                             this.images[i].__tx,
            +227                             this.images[i].__ty,
            +228                             this.images[i].__w,
            +229                             this.images[i].__h );
            +230                 }
            +231             }
            +232 
            +233 
            +234             if (outline) {
            +235                 ctxx.strokeStyle= 'red';
            +236                 ctxx.strokeRect(0,0,this.width,this.height);
            +237             }
            +238 
            +239             return canvass;
            +240         },
            +241         packImage : function(img) {
            +242             var newWidth, newHeight;
            +243             if ( img.inverted ) {
            +244                 newWidth= img.height;
            +245                 newHeight= img.width;
            +246             } else {
            +247                 newWidth= img.width;
            +248                 newHeight= img.height;
            +249             }
            +250 
            +251             var w= newWidth;
            +252             var h= newHeight;
            +253 
            +254             var mod;
            +255 
            +256             // dejamos un poco de espacio para que las texturas no se pisen.
            +257             // coordenadas normalizadas 0..1 dan problemas cuando las texturas no estan
            +258             // alineadas a posicion mod 4,8...
            +259             if ( w && this.padding ) {
            +260                 mod= this.padding;
            +261                 if ( w+mod<=this.width ) {
            +262                     w+=mod;
            +263                 }
            +264             }
            +265             if ( h && this.padding ) {
            +266                 mod= this.padding;
            +267                 if ( h+mod<=this.height ) {
            +268                     h+=mod;
            +269                 }
            +270             }
            +271             
            +272             var where=  this.scan.whereFitsChunk( w, h );
            +273             if ( null!==where ) {
            +274                 this.images.push( img );
            +275 
            +276                 img.__tx= where.x;
            +277                 img.__ty= where.y;
            +278                 img.__u=  where.x / this.width;
            +279                 img.__v=  where.y / this.height;
            +280                 img.__u1= (where.x+newWidth) / this.width;
            +281                 img.__v1= (where.y+newHeight) / this.height;
            +282                 img.__texturePage= this;
            +283                 img.__w= newWidth;
            +284                 img.__h= newHeight;
            +285 
            +286                 this.scan.substract(where.x,where.y,w,h);
            +287             } else {
            +288                 CAAT.log('Imagen ',img.src,' de tamano ',img.width,img.height,' no cabe.');
            +289             }
            +290         },
            +291         changeHeuristic : function(criteria) {
            +292             this.criteria= criteria;
            +293         }
            +294     }
            +295 });
            +296 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePageManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePageManager.js.html new file mode 100644 index 0000000..8c77c93 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TexturePageManager.js.html @@ -0,0 +1,72 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  */
            +  4 
            +  5 CAAT.Module({
            +  6 
            +  7     /**
            +  8      * @name TexturePageManager
            +  9      * @memberOf CAAT.Module.TexturePacker
            + 10      * @constructor
            + 11      */
            + 12 
            + 13     defines : "CAAT.Module.TexturePacker.TexturePageManager",
            + 14     depends : [
            + 15         "CAAT.Module.TexturePacker.TexturePage"
            + 16     ],
            + 17     extendsWith : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.Module.TexturePacker.TexturePageManager.prototype
            + 21          */
            + 22 
            + 23         __init : function() {
            + 24             this.pages= [];
            + 25             return this;
            + 26         },
            + 27 
            + 28         /**
            + 29          *
            + 30          */
            + 31         pages:  null,
            + 32 
            + 33         createPages:    function(gl,width,height,imagesCache) {
            + 34 
            + 35             var end= false;
            + 36             while( !end ) {
            + 37                 var page= new CAAT.Module.TexturePacker.TexturePage(width,height);
            + 38                 page.create(imagesCache);
            + 39                 page.initialize(gl);
            + 40                 page.endCreation();
            + 41                 this.pages.push(page);
            + 42 
            + 43                 end= true;
            + 44                 for( var i=0; i<imagesCache.length; i++ ) {
            + 45                     // imagen sin asociacion de textura
            + 46                     if ( !imagesCache[i].image.__texturePage ) {
            + 47                         // cabe en la pagina ?? continua con otras paginas.
            + 48                         if ( imagesCache[i].image.width<=width && imagesCache[i].image.height<=height ) {
            + 49                             end= false;
            + 50                         }
            + 51                         break;
            + 52                     }
            + 53                 }
            + 54             }
            + 55         },
            + 56         deletePages : function() {
            + 57             for( var i=0; i<this.pages.length; i++ ) {
            + 58                 this.pages[i].deletePage();
            + 59             }
            + 60             this.pages= null;
            + 61         }
            + 62     }
            + 63 
            + 64 });
            + 65 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScan.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScan.js.html new file mode 100644 index 0000000..6327190 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScan.js.html @@ -0,0 +1,116 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name TextureScan
            +  5      * @memberOf CAAT.Module.TexturePacker
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Module.TexturePacker.TextureScan",
            + 10     depends : [
            + 11         "CAAT.Module.TexturePacker.TextureElement"
            + 12     ],
            + 13     extendsWith : {
            + 14 
            + 15         /**
            + 16          * @lends CAAT.Module.TexturePacker.TextureScan.prototype
            + 17          */
            + 18 
            + 19         __init : function(w) {
            + 20             this.freeChunks=[ {position:0, size:w||1024} ];
            + 21             return this;
            + 22         },
            + 23 
            + 24         /**
            + 25          *
            + 26          */
            + 27         freeChunks: null,
            + 28 
            + 29         /**
            + 30          * return an array of values where a chunk of width size fits in this scan.
            + 31          * @param width
            + 32          */
            + 33         findWhereFits : function( width ) {
            + 34             if ( this.freeChunks.length===0 ) {
            + 35                 return [];
            + 36             }
            + 37 
            + 38             var fitsOnPosition= [];
            + 39             var i;
            + 40 
            + 41             for( i=0; i<this.freeChunks.length; i++ ) {
            + 42                 var pos= 0;
            + 43                 while( pos+width<= this.freeChunks[i].size ) {
            + 44                     fitsOnPosition.push( pos+this.freeChunks[i].position );
            + 45                     pos+= width;
            + 46                 }
            + 47             }
            + 48 
            + 49             return fitsOnPosition;
            + 50         },
            + 51         fits : function( position, size ) {
            + 52             var i=0;
            + 53 
            + 54             for( i=0; i<this.freeChunks.length; i++ ) {
            + 55                 var fc= this.freeChunks[i];
            + 56                 if ( fc.position<=position && position+size<=fc.position+fc.size ) {
            + 57                     return true;
            + 58                 }
            + 59             }
            + 60 
            + 61             return false;
            + 62         },
            + 63         substract : function( position, size ) {
            + 64             var i=0;
            + 65 
            + 66             for( i=0; i<this.freeChunks.length; i++ ) {
            + 67                 var fc= this.freeChunks[i];
            + 68                 if ( fc.position<=position && position+size<=fc.position+fc.size ) {
            + 69                     var lp=0;
            + 70                     var ls=0;
            + 71                     var rp=0;
            + 72                     var rs=0;
            + 73 
            + 74                     lp= fc.position;
            + 75                     ls= position-fc.position;
            + 76 
            + 77                     rp= position+size;
            + 78                     rs= fc.position+fc.size - rp;
            + 79 
            + 80                     this.freeChunks.splice(i,1);
            + 81 
            + 82                     if ( ls>0 ) {
            + 83                         this.freeChunks.splice( i++,0,{position: lp, size:ls} );
            + 84                     }
            + 85                     if ( rs>0 ) {
            + 86                         this.freeChunks.splice( i,0,{position: rp, size:rs} );
            + 87                     }
            + 88 
            + 89                     return true;
            + 90                 }
            + 91             }
            + 92 
            + 93             return false;
            + 94         },
            + 95         log : function(index) {
            + 96             if ( 0===this.freeChunks.length ) {
            + 97                 CAAT.log('index '+index+' empty');
            + 98             } else {
            + 99                 var str='index '+index;
            +100                 for( var i=0; i<this.freeChunks.length; i++ ) {
            +101                     var fc= this.freeChunks[i];
            +102                     str+='['+fc.position+","+fc.size+"]";
            +103                 }
            +104                 CAAT.log(str);
            +105             }
            +106         }
            +107     }
            +108 });
            +109 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScanMap.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScanMap.js.html new file mode 100644 index 0000000..fb1936e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_Modules_TexturePacker_TextureScanMap.js.html @@ -0,0 +1,137 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name TextureScanMap
            +  5      * @memberOf CAAT.Module.TexturePacker
            +  6      * @constructor
            +  7      */
            +  8 
            +  9     defines : "CAAT.Module.TexturePacker.TextureScanMap",
            + 10     depends : [
            + 11         "CAAT.Module.TexturePacker.TextureScan"
            + 12     ],
            + 13     extendsWith : {
            + 14 
            + 15         /**
            + 16          * @lends CAAT.Module.TexturePacker.TextureScanMap.prototype
            + 17          */
            + 18 
            + 19         __init : function(w,h) {
            + 20             this.scanMapHeight= h;
            + 21             this.scanMapWidth= w;
            + 22 
            + 23             this.scanMap= [];
            + 24             for( var i=0; i<this.scanMapHeight; i++ ) {
            + 25                 this.scanMap.push( new CAAT.Module.TexturePacker.TextureScan(this.scanMapWidth) );
            + 26             }
            + 27 
            + 28             return this;
            + 29         },
            + 30 
            + 31         /**
            + 32          *
            + 33          */
            + 34         scanMap:        null,
            + 35 
            + 36         /**
            + 37          *
            + 38          */
            + 39         scanMapWidth:   0,
            + 40 
            + 41         /**
            + 42          *
            + 43          */
            + 44         scanMapHeight:  0,
            + 45 
            + 46         /**
            + 47          * Always try to fit a chunk of size width*height pixels from left-top.
            + 48          * @param width
            + 49          * @param height
            + 50          */
            + 51         whereFitsChunk : function( width, height ) {
            + 52 
            + 53             // trivial rejection:
            + 54             if ( width>this.width||height>this.height) {
            + 55                 return null;
            + 56             }
            + 57 
            + 58             // find first fitting point
            + 59             var i,j,initialPosition= 0;
            + 60 
            + 61             while( initialPosition<=this.scanMapHeight-height) {
            + 62 
            + 63                 // para buscar sitio se buscara un sitio hasta el tamano de alto del trozo.
            + 64                 // mas abajo no va a caber.
            + 65 
            + 66                 // fitHorizontalPosition es un array con todas las posiciones de este scan donde
            + 67                 // cabe un chunk de tamano width.
            + 68                 var fitHorizontalPositions= null;
            + 69                 var foundPositionOnScan=    false;
            + 70 
            + 71                 for( ; initialPosition<=this.scanMapHeight-height; initialPosition++ ) {
            + 72                     fitHorizontalPositions= this.scanMap[ initialPosition ].findWhereFits( width );
            + 73 
            + 74                     // si no es nulo el array de resultados, quiere decir que en alguno de los puntos
            + 75                     // nos cabe un trozo de tamano width.
            + 76                     if ( null!==fitHorizontalPositions && fitHorizontalPositions.length>0 ) {
            + 77                         foundPositionOnScan= true;
            + 78                         break;
            + 79                     }
            + 80                 }
            + 81 
            + 82                 if ( foundPositionOnScan ) {
            + 83                     // j es el scan donde cabe un trozo de tamano width.
            + 84                     // comprobamos desde este scan que en todos los scan verticales cabe el trozo.
            + 85                     // se comprueba que cabe en alguno de los tamanos que la rutina de busqueda horizontal
            + 86                     // nos ha devuelto antes.
            + 87 
            + 88                     var minInitialPosition=Number.MAX_VALUE;
            + 89                     for( j=0; j<fitHorizontalPositions.length; j++ ) {
            + 90                         var fits= true;
            + 91                         for( i=initialPosition; i<initialPosition+height; i++ ) {
            + 92                             // hay un trozo que no cabe
            + 93                             if ( !this.scanMap[i].fits( fitHorizontalPositions[j], width ) ) {
            + 94                                 fits= false;
            + 95                                 break;
            + 96                             }
            + 97                         }
            + 98 
            + 99                         // se ha encontrado un trozo donde la imagen entra.
            +100                         // d.p.m. incluirla en posicion, y seguir con otra.
            +101                         if ( fits ) {
            +102                             return { x: fitHorizontalPositions[j], y: initialPosition };
            +103                         } 
            +104                     }
            +105 
            +106                     initialPosition++;
            +107                 } else {
            +108                     // no hay sitio en ningun scan.
            +109                     return null;
            +110                 }
            +111             }
            +112 
            +113             // no se ha podido encontrar un area en la textura para un trozo de tamano width*height
            +114             return null;
            +115         },
            +116         substract : function( x,y, width, height ) {
            +117             for( var i=0; i<height; i++ ) {
            +118                 if ( !this.scanMap[i+y].substract(x,width) ) {
            +119                     CAAT.log('Error: removing chunk ',width,height,' at ',x,y);
            +120                 }
            +121             }
            +122         },
            +123         log : function() {
            +124             for( var i=0; i<this.scanMapHeight; i++ ) {
            +125                 this.scanMap[i].log(i);
            +126             }
            +127         }
            +128     }
            +129 });
            +130 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_ArcPath.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_ArcPath.js.html new file mode 100644 index 0000000..09594db --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_ArcPath.js.html @@ -0,0 +1,323 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name ArcPath
            +  5      * @memberOf CAAT.PathUtil
            +  6      * @extends CAAT.PathUtil.PathSegment
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.PathUtil.ArcPath",
            + 11     depends:[
            + 12         "CAAT.PathUtil.PathSegment",
            + 13         "CAAT.Math.Point",
            + 14         "CAAT.Math.Rectangle"
            + 15     ],
            + 16     aliases:["CAAT.ArcPath"],
            + 17     extendsClass:"CAAT.PathUtil.PathSegment",
            + 18     extendsWith:function () {
            + 19 
            + 20         return {
            + 21 
            + 22             /**
            + 23              * @lends CAAT.PathUtil.ArcPath.prototype
            + 24              */
            + 25 
            + 26             __init:function () {
            + 27                 this.__super();
            + 28 
            + 29                 this.points = [];
            + 30                 this.points.push(new CAAT.Math.Point());
            + 31                 this.points.push(new CAAT.Math.Point());
            + 32 
            + 33                 this.newPosition = new CAAT.Math.Point();
            + 34 
            + 35                 return this;
            + 36             },
            + 37 
            + 38             /**
            + 39              * A collection of CAAT.Math.Point objects which defines the arc (center, start, end)
            + 40              */
            + 41             points:null,
            + 42 
            + 43             /**
            + 44              * Defined clockwise or counterclockwise ?
            + 45              */
            + 46             cw:true,
            + 47 
            + 48             /**
            + 49              * spare point for calculations
            + 50              */
            + 51             newPosition:null,
            + 52 
            + 53             /**
            + 54              * Arc radius.
            + 55              */
            + 56             radius:0,
            + 57 
            + 58             /**
            + 59              * Arc start angle.
            + 60              */
            + 61             startAngle:0,
            + 62 
            + 63             /**
            + 64              * Arc end angle.
            + 65              */
            + 66             angle:2 * Math.PI,
            + 67 
            + 68             /**
            + 69              * is a relative or absolute arc ?
            + 70              */
            + 71             arcTo:false,
            + 72 
            + 73             setRadius:function (r) {
            + 74                 this.radius = r;
            + 75                 return this;
            + 76             },
            + 77 
            + 78             isArcTo:function () {
            + 79                 return this.arcTo;
            + 80             },
            + 81 
            + 82             setArcTo:function (b) {
            + 83                 this.arcTo = b;
            + 84                 return this;
            + 85             },
            + 86 
            + 87             initialize:function (x, y, r, angle) {
            + 88                 this.setInitialPosition(x, y);
            + 89                 this.setFinalPosition(x + r, y);
            + 90                 this.angle = angle || 2 * Math.PI;
            + 91                 return this;
            + 92             },
            + 93 
            + 94             applyAsPath:function (director) {
            + 95                 var ctx = director.ctx;
            + 96                 if (!this.arcTo) {
            + 97                     ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.angle + this.startAngle, this.cw);
            + 98                 } else {
            + 99                     ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius);
            +100                 }
            +101                 return this;
            +102             },
            +103             setPoint:function (point, index) {
            +104                 if (index >= 0 && index < this.points.length) {
            +105                     this.points[index] = point;
            +106                 }
            +107             },
            +108             /**
            +109              * An array of {CAAT.Point} composed of two points.
            +110              * @param points {Array<CAAT.Point>}
            +111              */
            +112             setPoints:function (points) {
            +113                 this.points = [];
            +114                 this.points[0] = points[0];
            +115                 this.points[1] = points[1];
            +116                 this.updatePath();
            +117 
            +118                 return this;
            +119             },
            +120             setClockWise:function (cw) {
            +121                 this.cw = cw !== undefined ? cw : true;
            +122                 return this;
            +123             },
            +124             isClockWise:function () {
            +125                 return this.cw;
            +126             },
            +127             /**
            +128              * Set this path segment's starting position.
            +129              * This method should not be called again after setFinalPosition has been called.
            +130              * @param x {number}
            +131              * @param y {number}
            +132              */
            +133             setInitialPosition:function (x, y) {
            +134                 for (var i = 0, l = this.points.length; i < l; i++) {
            +135                     this.points[0].x = x;
            +136                     this.points[0].y = y;
            +137                 }
            +138 
            +139                 return this;
            +140             },
            +141             /**
            +142              * Set a rectangle from points[0] to (finalX, finalY)
            +143              * @param finalX {number}
            +144              * @param finalY {number}
            +145              */
            +146             setFinalPosition:function (finalX, finalY) {
            +147                 this.points[1].x = finalX;
            +148                 this.points[1].y = finalY;
            +149 
            +150                 this.updatePath(this.points[1]);
            +151                 return this;
            +152             },
            +153             /**
            +154              * An arc starts and ends in the same point.
            +155              */
            +156             endCurvePosition:function () {
            +157                 return this.points[0];
            +158             },
            +159             /**
            +160              * @inheritsDoc
            +161              */
            +162             startCurvePosition:function () {
            +163                 return this.points[0];
            +164             },
            +165             /**
            +166              * @inheritsDoc
            +167              */
            +168             getPosition:function (time) {
            +169 
            +170                 if (time > 1 || time < 0) {
            +171                     time %= 1;
            +172                 }
            +173                 if (time < 0) {
            +174                     time = 1 + time;
            +175                 }
            +176 
            +177                 if (-1 === this.length) {
            +178                     this.newPosition.set(this.points[0].x, this.points[0].y);
            +179                 } else {
            +180 
            +181                     var angle = this.angle * time * (this.cw ? 1 : -1) + this.startAngle;
            +182 
            +183                     this.newPosition.set(
            +184                         this.points[0].x + this.radius * Math.cos(angle),
            +185                         this.points[0].y + this.radius * Math.sin(angle)
            +186                     );
            +187                 }
            +188 
            +189                 return this.newPosition;
            +190             },
            +191             /**
            +192              * Returns initial path segment point's x coordinate.
            +193              * @return {number}
            +194              */
            +195             initialPositionX:function () {
            +196                 return this.points[0].x;
            +197             },
            +198             /**
            +199              * Returns final path segment point's x coordinate.
            +200              * @return {number}
            +201              */
            +202             finalPositionX:function () {
            +203                 return this.points[1].x;
            +204             },
            +205             /**
            +206              * Draws this path segment on screen. Optionally it can draw handles for every control point, in
            +207              * this case, start and ending path segment points.
            +208              * @param director {CAAT.Director}
            +209              * @param bDrawHandles {boolean}
            +210              */
            +211             paint:function (director, bDrawHandles) {
            +212 
            +213                 var ctx = director.ctx;
            +214 
            +215                 ctx.save();
            +216 
            +217                 ctx.strokeStyle = this.color;
            +218                 ctx.beginPath();
            +219                 if (!this.arcTo) {
            +220                     ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.startAngle + this.angle, this.cw);
            +221                 } else {
            +222                     ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius);
            +223                 }
            +224                 ctx.stroke();
            +225 
            +226                 if (bDrawHandles) {
            +227                     ctx.globalAlpha = 0.5;
            +228                     ctx.fillStyle = '#7f7f00';
            +229 
            +230                     for (var i = 0; i < this.points.length; i++) {
            +231                         this.drawHandle(ctx, this.points[i].x, this.points[i].y);
            +232                     }
            +233                 }
            +234 
            +235                 ctx.restore();
            +236             },
            +237             /**
            +238              * Get the number of control points. For this type of path segment, start and
            +239              * ending path segment points. Defaults to 2.
            +240              * @return {number}
            +241              */
            +242             numControlPoints:function () {
            +243                 return this.points.length;
            +244             },
            +245             /**
            +246              * @inheritsDoc
            +247              */
            +248             getControlPoint:function (index) {
            +249                 return this.points[index];
            +250             },
            +251             /**
            +252              * @inheritsDoc
            +253              */
            +254             getContour:function (iSize) {
            +255                 var contour = [];
            +256 
            +257                 for (var i = 0; i < iSize; i++) {
            +258                     contour.push(
            +259                         {
            +260                             x:this.points[0].x + this.radius * Math.cos(i * Math.PI / (iSize / 2)),
            +261                             y:this.points[0].y + this.radius * Math.sin(i * Math.PI / (iSize / 2))
            +262                         }
            +263                     );
            +264                 }
            +265 
            +266                 return contour;
            +267             },
            +268 
            +269             getPositionFromLength:function (iLength) {
            +270                 var ratio = iLength / this.length * (this.cw ? 1 : -1);
            +271                 return this.getPosition(ratio);
            +272                 /*
            +273                  this.newPosition.set(
            +274                  this.points[0].x + this.radius * Math.cos( 2*Math.PI * ratio ),
            +275                  this.points[0].y + this.radius * Math.sin( 2*Math.PI * ratio )
            +276                  );
            +277                  return this.newPosition;*/
            +278             },
            +279 
            +280             updatePath:function (point) {
            +281 
            +282                 // just move the circle, not modify radius.
            +283                 if (this.points[1] === point) {
            +284 
            +285                     if (!this.arcTo) {
            +286                         this.radius = Math.sqrt(
            +287                             ( this.points[0].x - this.points[1].x ) * ( this.points[0].x - this.points[1].x ) +
            +288                                 ( this.points[0].y - this.points[1].y ) * ( this.points[0].y - this.points[1].y )
            +289                         );
            +290                     }
            +291 
            +292                     this.length = this.angle * this.radius;
            +293                     this.startAngle = Math.atan2((this.points[1].y - this.points[0].y), (this.points[1].x - this.points[0].x));
            +294 
            +295                 } else if (this.points[0] === point) {
            +296                     this.points[1].set(
            +297                         this.points[0].x + this.radius * Math.cos(this.startAngle),
            +298                         this.points[0].y + this.radius * Math.sin(this.startAngle)
            +299                     );
            +300                 }
            +301 
            +302                 this.bbox.setEmpty();
            +303                 this.bbox.x = this.points[0].x - this.radius;
            +304                 this.bbox.y = this.points[0].y - this.radius;
            +305                 this.bbox.x1 = this.points[0].x + this.radius;
            +306                 this.bbox.y1 = this.points[0].y + this.radius;
            +307                 this.bbox.width = 2 * this.radius;
            +308                 this.bbox.height = 2 * this.radius;
            +309 
            +310                 return this;
            +311             }
            +312         }
            +313     }
            +314 
            +315 });
            +316 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_CurvePath.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_CurvePath.js.html new file mode 100644 index 0000000..8a20e01 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_CurvePath.js.html @@ -0,0 +1,213 @@ +
              1 /**
            +  2  * CAAT.CurvePath
            +  3  */
            +  4 CAAT.Module({
            +  5 
            +  6     /**
            +  7      * @name CurvePath
            +  8      * @memberOf CAAT.PathUtil
            +  9      * @extends CAAT.PathUtil.PathSegment
            + 10      * @constructor
            + 11      */
            + 12 
            + 13     defines:"CAAT.PathUtil.CurvePath",
            + 14     depends:[
            + 15         "CAAT.PathUtil.PathSegment",
            + 16         "CAAT.Math.Point",
            + 17         "CAAT.Math.Bezier"
            + 18     ],
            + 19     aliases:["CAAT.CurvePath"],
            + 20     extendsClass:"CAAT.PathUtil.PathSegment",
            + 21     extendsWith:function () {
            + 22         return {
            + 23 
            + 24             /**
            + 25              * @lends CAAT.PathUtil.CurvePath.prototype
            + 26              */
            + 27 
            + 28 
            + 29             __init:function () {
            + 30                 this.__super();
            + 31                 this.newPosition = new CAAT.Math.Point(0, 0, 0);
            + 32                 return this;
            + 33             },
            + 34 
            + 35             /**
            + 36              * A CAAT.Math.Curve instance.
            + 37              */
            + 38             curve:null,
            + 39 
            + 40             /**
            + 41              * spare holder for getPosition coordinate return.
            + 42              * @type {CAAT.Math.Point}
            + 43              */
            + 44             newPosition:null,
            + 45 
            + 46             applyAsPath:function (director) {
            + 47                 this.curve.applyAsPath(director);
            + 48                 return this;
            + 49             },
            + 50             setPoint:function (point, index) {
            + 51                 if (this.curve) {
            + 52                     this.curve.setPoint(point, index);
            + 53                 }
            + 54             },
            + 55             /**
            + 56              * Set this curve segment's points.
            + 57              * @param points {Array<CAAT.Point>}
            + 58              */
            + 59             setPoints:function (points) {
            + 60                 var curve = new CAAT.Math.Bezier();
            + 61                 curve.setPoints(points);
            + 62                 this.curve = curve;
            + 63                 return this;
            + 64             },
            + 65             /**
            + 66              * Set the pathSegment as a CAAT.Bezier quadric instance.
            + 67              * Parameters are quadric coordinates control points.
            + 68              *
            + 69              * @param p0x {number}
            + 70              * @param p0y {number}
            + 71              * @param p1x {number}
            + 72              * @param p1y {number}
            + 73              * @param p2x {number}
            + 74              * @param p2y {number}
            + 75              * @return this
            + 76              */
            + 77             setQuadric:function (p0x, p0y, p1x, p1y, p2x, p2y) {
            + 78                 var curve = new CAAT.Math.Bezier();
            + 79                 curve.setQuadric(p0x, p0y, p1x, p1y, p2x, p2y);
            + 80                 this.curve = curve;
            + 81                 this.updatePath();
            + 82 
            + 83                 return this;
            + 84             },
            + 85             /**
            + 86              * Set the pathSegment as a CAAT.Bezier cubic instance.
            + 87              * Parameters are cubic coordinates control points.
            + 88              * @param p0x {number}
            + 89              * @param p0y {number}
            + 90              * @param p1x {number}
            + 91              * @param p1y {number}
            + 92              * @param p2x {number}
            + 93              * @param p2y {number}
            + 94              * @param p3x {number}
            + 95              * @param p3y {number}
            + 96              * @return this
            + 97              */
            + 98             setCubic:function (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) {
            + 99                 var curve = new CAAT.Math.Bezier();
            +100                 curve.setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y);
            +101                 this.curve = curve;
            +102                 this.updatePath();
            +103 
            +104                 return this;
            +105             },
            +106             /**
            +107              * @inheritDoc
            +108              */
            +109             updatePath:function (point) {
            +110                 this.curve.update();
            +111                 this.length = this.curve.getLength();
            +112                 this.curve.getBoundingBox(this.bbox);
            +113                 return this;
            +114             },
            +115             /**
            +116              * @inheritDoc
            +117              */
            +118             getPosition:function (time) {
            +119 
            +120                 if (time > 1 || time < 0) {
            +121                     time %= 1;
            +122                 }
            +123                 if (time < 0) {
            +124                     time = 1 + time;
            +125                 }
            +126 
            +127                 this.curve.solve(this.newPosition, time);
            +128 
            +129                 return this.newPosition;
            +130             },
            +131             /**
            +132              * Gets the coordinate on the path relative to the path length.
            +133              * @param iLength {number} the length at which the coordinate will be taken from.
            +134              * @return {CAAT.Point} a CAAT.Point instance with the coordinate on the path corresponding to the
            +135              * iLenght parameter relative to segment's length.
            +136              */
            +137             getPositionFromLength:function (iLength) {
            +138                 this.curve.solve(this.newPosition, iLength / this.length);
            +139                 return this.newPosition;
            +140             },
            +141             /**
            +142              * Get path segment's first point's x coordinate.
            +143              * @return {number}
            +144              */
            +145             initialPositionX:function () {
            +146                 return this.curve.coordlist[0].x;
            +147             },
            +148             /**
            +149              * Get path segment's last point's y coordinate.
            +150              * @return {number}
            +151              */
            +152             finalPositionX:function () {
            +153                 return this.curve.coordlist[this.curve.coordlist.length - 1].x;
            +154             },
            +155             /**
            +156              * @inheritDoc
            +157              * @param director {CAAT.Director}
            +158              * @param bDrawHandles {boolean}
            +159              */
            +160             paint:function (director, bDrawHandles) {
            +161                 this.curve.drawHandles = bDrawHandles;
            +162                 director.ctx.strokeStyle = this.color;
            +163                 this.curve.paint(director, bDrawHandles);
            +164             },
            +165             /**
            +166              * @inheritDoc
            +167              */
            +168             numControlPoints:function () {
            +169                 return this.curve.coordlist.length;
            +170             },
            +171             /**
            +172              * @inheritDoc
            +173              * @param index
            +174              */
            +175             getControlPoint:function (index) {
            +176                 return this.curve.coordlist[index];
            +177             },
            +178             /**
            +179              * @inheritDoc
            +180              */
            +181             endCurvePosition:function () {
            +182                 return this.curve.endCurvePosition();
            +183             },
            +184             /**
            +185              * @inheritDoc
            +186              */
            +187             startCurvePosition:function () {
            +188                 return this.curve.startCurvePosition();
            +189             },
            +190             /**
            +191              * @inheritDoc
            +192              * @param iSize
            +193              */
            +194             getContour:function (iSize) {
            +195                 var contour = [];
            +196                 for (var i = 0; i <= iSize; i++) {
            +197                     contour.push({x:i / iSize, y:this.getPosition(i / iSize).y});
            +198                 }
            +199 
            +200                 return contour;
            +201             }
            +202         }
            +203     }
            +204 
            +205 });
            +206 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_LinearPath.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_LinearPath.js.html new file mode 100644 index 0000000..9ec5ce2 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_LinearPath.js.html @@ -0,0 +1,218 @@ +
              1 /**
            +  2  * CAAT.LinearPath
            +  3  */
            +  4 CAAT.Module({
            +  5 
            +  6 
            +  7     /**
            +  8      * @name LinearPath
            +  9      * @memberOf CAAT.PathUtil
            + 10      * @extends CAAT.PathUtil.PathSegment
            + 11      * @constructor
            + 12      */
            + 13 
            + 14     defines:"CAAT.PathUtil.LinearPath",
            + 15     depends:[
            + 16         "CAAT.PathUtil.PathSegment",
            + 17         "CAAT.Math.Point"
            + 18     ],
            + 19     aliases:["CAAT.LinearPath"],
            + 20     extendsClass:"CAAT.PathUtil.PathSegment",
            + 21     extendsWith:function () {
            + 22 
            + 23         return  {
            + 24 
            + 25             /**
            + 26              * @lends CAAT.PathUtil.LinearPath.prototype
            + 27              */
            + 28 
            + 29             __init:function () {
            + 30                 this.__super();
            + 31 
            + 32                 this.points = [];
            + 33                 this.points.push(new CAAT.Math.Point());
            + 34                 this.points.push(new CAAT.Math.Point());
            + 35 
            + 36                 this.newPosition = new CAAT.Math.Point(0, 0, 0);
            + 37                 return this;
            + 38             },
            + 39 
            + 40             /**
            + 41              * A collection of points.
            + 42              * @type {Array.<CAAT.Math.Point>}
            + 43              */
            + 44             points:null,
            + 45 
            + 46             /**
            + 47              * spare holder for getPosition coordinate return.
            + 48              */
            + 49             newPosition:null,
            + 50 
            + 51             applyAsPath:function (director) {
            + 52                 // Fixed: Thanks https://github.com/roed
            + 53                 director.ctx.lineTo(this.points[1].x, this.points[1].y);
            + 54             },
            + 55             setPoint:function (point, index) {
            + 56                 if (index === 0) {
            + 57                     this.points[0] = point;
            + 58                 } else if (index === 1) {
            + 59                     this.points[1] = point;
            + 60                 }
            + 61             },
            + 62             /**
            + 63              * Update this segments length and bounding box info.
            + 64              */
            + 65             updatePath:function (point) {
            + 66                 var x = this.points[1].x - this.points[0].x;
            + 67                 var y = this.points[1].y - this.points[0].y;
            + 68                 this.length = Math.sqrt(x * x + y * y);
            + 69 
            + 70                 this.bbox.setEmpty();
            + 71                 this.bbox.union(this.points[0].x, this.points[0].y);
            + 72                 this.bbox.union(this.points[1].x, this.points[1].y);
            + 73 
            + 74                 return this;
            + 75             },
            + 76             setPoints:function (points) {
            + 77                 this.points[0] = points[0];
            + 78                 this.points[1] = points[1];
            + 79                 this.updatePath();
            + 80                 return this;
            + 81             },
            + 82             /**
            + 83              * Set this path segment's starting position.
            + 84              * @param x {number}
            + 85              * @param y {number}
            + 86              */
            + 87             setInitialPosition:function (x, y) {
            + 88                 this.points[0].x = x;
            + 89                 this.points[0].y = y;
            + 90                 this.newPosition.set(x, y);
            + 91                 return this;
            + 92             },
            + 93             /**
            + 94              * Set this path segment's ending position.
            + 95              * @param finalX {number}
            + 96              * @param finalY {number}
            + 97              */
            + 98             setFinalPosition:function (finalX, finalY) {
            + 99                 this.points[1].x = finalX;
            +100                 this.points[1].y = finalY;
            +101                 return this;
            +102             },
            +103             /**
            +104              * @inheritDoc
            +105              */
            +106             endCurvePosition:function () {
            +107                 return this.points[1];
            +108             },
            +109             /**
            +110              * @inheritsDoc
            +111              */
            +112             startCurvePosition:function () {
            +113                 return this.points[0];
            +114             },
            +115             /**
            +116              * @inheritsDoc
            +117              */
            +118             getPosition:function (time) {
            +119 
            +120                 if (time > 1 || time < 0) {
            +121                     time %= 1;
            +122                 }
            +123                 if (time < 0) {
            +124                     time = 1 + time;
            +125                 }
            +126 
            +127                 this.newPosition.set(
            +128                     (this.points[0].x + (this.points[1].x - this.points[0].x) * time),
            +129                     (this.points[0].y + (this.points[1].y - this.points[0].y) * time));
            +130 
            +131                 return this.newPosition;
            +132             },
            +133             getPositionFromLength:function (len) {
            +134                 return this.getPosition(len / this.length);
            +135             },
            +136             /**
            +137              * Returns initial path segment point's x coordinate.
            +138              * @return {number}
            +139              */
            +140             initialPositionX:function () {
            +141                 return this.points[0].x;
            +142             },
            +143             /**
            +144              * Returns final path segment point's x coordinate.
            +145              * @return {number}
            +146              */
            +147             finalPositionX:function () {
            +148                 return this.points[1].x;
            +149             },
            +150             /**
            +151              * Draws this path segment on screen. Optionally it can draw handles for every control point, in
            +152              * this case, start and ending path segment points.
            +153              * @param director {CAAT.Director}
            +154              * @param bDrawHandles {boolean}
            +155              */
            +156             paint:function (director, bDrawHandles) {
            +157 
            +158                 var ctx = director.ctx;
            +159 
            +160                 ctx.save();
            +161 
            +162                 ctx.strokeStyle = this.color;
            +163                 ctx.beginPath();
            +164                 ctx.moveTo(this.points[0].x, this.points[0].y);
            +165                 ctx.lineTo(this.points[1].x, this.points[1].y);
            +166                 ctx.stroke();
            +167 
            +168                 if (bDrawHandles) {
            +169                     ctx.globalAlpha = 0.5;
            +170                     ctx.fillStyle = '#7f7f00';
            +171                     ctx.beginPath();
            +172                     this.drawHandle(ctx, this.points[0].x, this.points[0].y);
            +173                     this.drawHandle(ctx, this.points[1].x, this.points[1].y);
            +174 
            +175                 }
            +176 
            +177                 ctx.restore();
            +178             },
            +179             /**
            +180              * Get the number of control points. For this type of path segment, start and
            +181              * ending path segment points. Defaults to 2.
            +182              * @return {number}
            +183              */
            +184             numControlPoints:function () {
            +185                 return 2;
            +186             },
            +187             /**
            +188              * @inheritsDoc
            +189              */
            +190             getControlPoint:function (index) {
            +191                 if (0 === index) {
            +192                     return this.points[0];
            +193                 } else if (1 === index) {
            +194                     return this.points[1];
            +195                 }
            +196             },
            +197             /**
            +198              * @inheritsDoc
            +199              */
            +200             getContour:function (iSize) {
            +201                 var contour = [];
            +202 
            +203                 contour.push(this.getPosition(0).clone());
            +204                 contour.push(this.getPosition(1).clone());
            +205 
            +206                 return contour;
            +207             }
            +208         }
            +209     }
            +210 });
            +211 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_Path.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_Path.js.html new file mode 100644 index 0000000..6c7cb2e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_Path.js.html @@ -0,0 +1,1172 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name Path
            +  5      * @memberOf CAAT.PathUtil
            +  6      * @extends CAAT.PathUtil.PathSegment
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.PathUtil.Path",
            + 11     aliases : ["CAAT.Path"],
            + 12     depends : [
            + 13         "CAAT.PathUtil.PathSegment",
            + 14         "CAAT.PathUtil.ArcPath",
            + 15         "CAAT.PathUtil.CurvePath",
            + 16         "CAAT.PathUtil.LinearPath",
            + 17         "CAAT.PathUtil.RectPath",
            + 18         "CAAT.Math.Bezier",
            + 19         "CAAT.Math.CatmullRom",
            + 20         "CAAT.Math.Point",
            + 21         "CAAT.Math.Matrix"
            + 22     ],
            + 23     extendsClass : "CAAT.PathUtil.PathSegment",
            + 24     extendsWith : {
            + 25 
            + 26         /**
            + 27          * @lends CAAT.PathUtil.Path.prototype
            + 28          */
            + 29 
            + 30 
            + 31         __init : function()	{
            + 32                 this.__super();
            + 33 
            + 34                 this.newPosition=   new CAAT.Math.Point(0,0,0);
            + 35                 this.pathSegments=  [];
            + 36 
            + 37                 this.behaviorList=  [];
            + 38                 this.matrix=        new CAAT.Math.Matrix();
            + 39                 this.tmpMatrix=     new CAAT.Math.Matrix();
            + 40 
            + 41                 return this;
            + 42         },
            + 43 
            + 44         /**
            + 45          * A collection of PathSegments.
            + 46          * @type {Array.<CAAT.PathUtil.PathSegment>}
            + 47          */
            + 48 		pathSegments:	            null,   // a collection of CAAT.PathSegment instances.
            + 49 
            + 50         /**
            + 51          * For each path segment in this path, the normalized calculated duration.
            + 52          * precomputed segment duration relative to segment legnth/path length
            + 53          */
            + 54 		pathSegmentDurationTime:	null,
            + 55 
            + 56         /**
            + 57          * For each path segment in this path, the normalized calculated start time.
            + 58          * precomputed segment start time relative to segment legnth/path length and duration.
            + 59          */
            + 60 		pathSegmentStartTime:		null,
            + 61 
            + 62         /**
            + 63          * spare CAAT.Math.Point to return calculated values in the path.
            + 64          */
            + 65 		newPosition:	            null,
            + 66 
            + 67         /**
            + 68          * path length (sum of every segment length)
            + 69          */
            + 70 		pathLength:		            -1,
            + 71 
            + 72         /**
            + 73          * starting path x position
            + 74          */
            + 75 		beginPathX:		            -1,
            + 76 
            + 77         /**
            + 78          * starting path y position
            + 79          */
            + 80 		beginPathY:                 -1,
            + 81 
            + 82         /*
            + 83             last path coordinates position (using when building the path).
            + 84          */
            + 85 		trackPathX:		            -1,
            + 86 		trackPathY:		            -1,
            + 87 
            + 88         /*
            + 89             needed to drag control points.
            + 90           */
            + 91 		ax:                         -1,
            + 92 		ay:                         -1,
            + 93 		point:                      [],
            + 94 
            + 95         /**
            + 96          * Is this path interactive ?. If so, controls points can be moved with a CAAT.Foundation.UI.PathActor.
            + 97          */
            + 98         interactive:                true,
            + 99 
            +100         /**
            +101          * A list of behaviors to apply to this path.
            +102          * A path can be affine transformed to create a different path.
            +103          */
            +104         behaviorList:               null,
            +105 
            +106         /* rotation behavior info **/
            +107 
            +108         /**
            +109          * Path rotation angle.
            +110          */
            +111         rb_angle:                   0,
            +112 
            +113         /**
            +114          * Path rotation x anchor.
            +115          */
            +116         rb_rotateAnchorX:           .5,
            +117 
            +118         /**
            +119          * Path rotation x anchor.
            +120          */
            +121         rb_rotateAnchorY:           .5,
            +122 
            +123         /* scale behavior info **/
            +124 
            +125         /**
            +126          * Path X scale.
            +127          */
            +128         sb_scaleX:                  1,
            +129 
            +130         /**
            +131          * Path Y scale.
            +132          */
            +133         sb_scaleY:                  1,
            +134 
            +135         /**
            +136          * Path scale X anchor.
            +137          */
            +138         sb_scaleAnchorX:            .5,
            +139 
            +140         /**
            +141          * Path scale Y anchor.
            +142          */
            +143         sb_scaleAnchorY:            .5,
            +144 
            +145         /**
            +146          * Path translation anchor X.
            +147          */
            +148         tAnchorX:                   0,
            +149 
            +150         /**
            +151          * Path translation anchor Y.
            +152          */
            +153         tAnchorY:                   0,
            +154 
            +155         /* translate behavior info **/
            +156 
            +157         /**
            +158          * Path translation X.
            +159          */
            +160         tb_x:                       0,
            +161 
            +162         /**
            +163          * Path translation Y.
            +164          */
            +165         tb_y:                       0,
            +166 
            +167         /* behavior affine transformation matrix **/
            +168 
            +169         /**
            +170          * Path behaviors matrix.
            +171          */
            +172         matrix:                     null,
            +173 
            +174         /**
            +175          * Spare calculation matrix.
            +176          */
            +177         tmpMatrix:                  null,
            +178 
            +179         /**
            +180          * Original Path´s path segments points.
            +181          */
            +182         pathPoints:                 null,
            +183 
            +184         /**
            +185          * Path bounding box width.
            +186          */
            +187         width:                      0,
            +188 
            +189         /**
            +190          * Path bounding box height.
            +191          */
            +192         height:                     0,
            +193 
            +194         /**
            +195          * Path bounding box X position.
            +196          */
            +197         clipOffsetX             :   0,
            +198 
            +199         /**
            +200          * Path bounding box Y position.
            +201          */
            +202         clipOffsetY             :   0,
            +203 
            +204         /**
            +205          * Is this path closed ?
            +206          */
            +207         closed                  :   false,
            +208 
            +209         /**
            +210          * Apply this path as a Canvas context path.
            +211          * You must explicitly call context.beginPath
            +212          * @param director
            +213          * @return {*}
            +214          */
            +215         applyAsPath : function(director) {
            +216             var ctx= director.ctx;
            +217 
            +218             director.modelViewMatrix.transformRenderingContext( ctx );
            +219             ctx.globalCompositeOperation= 'source-out';
            +220             ctx.moveTo(
            +221                 this.getFirstPathSegment().startCurvePosition().x,
            +222                 this.getFirstPathSegment().startCurvePosition().y
            +223             );
            +224             for( var i=0; i<this.pathSegments.length; i++ ) {
            +225                 this.pathSegments[i].applyAsPath(director);
            +226             }
            +227             ctx.globalCompositeOperation= 'source-over';
            +228             return this;
            +229         },
            +230         /**
            +231          * Set whether this path should paint handles for every control point.
            +232          * @param interactive {boolean}.
            +233          */
            +234         setInteractive : function(interactive) {
            +235             this.interactive= interactive;
            +236             return this;
            +237         },
            +238         getFirstPathSegment : function() {
            +239             return this.pathSegments.length ?
            +240                 this.pathSegments[0] :
            +241                 null;
            +242         },
            +243         getLastPathSegment : function() {
            +244             return this.pathSegments.length ?
            +245                 this.pathSegments[ this.pathSegments.length-1 ] :
            +246                 null;
            +247         },
            +248         /**
            +249          * Return the last point of the last path segment of this compound path.
            +250          * @return {CAAT.Point}
            +251          */
            +252         endCurvePosition : function() {
            +253             if ( this.pathSegments.length ) {
            +254                 return this.pathSegments[ this.pathSegments.length-1 ].endCurvePosition();
            +255             } else {
            +256                 return new CAAT.Math.Point().set( this.beginPathX, this.beginPathY );
            +257             }
            +258         },
            +259         /**
            +260          * Return the first point of the first path segment of this compound path.
            +261          * @return {CAAT.Point}
            +262          */
            +263         startCurvePosition : function() {
            +264             return this.pathSegments[ 0 ].startCurvePosition();
            +265         },
            +266         /**
            +267          * Return the last path segment added to this path.
            +268          * @return {CAAT.PathSegment}
            +269          */
            +270         getCurrentPathSegment : function() {
            +271             return this.pathSegments[ this.pathSegments.length-1 ];
            +272         },
            +273         /**
            +274          * Set the path to be composed by a single LinearPath segment.
            +275          * @param x0 {number}
            +276          * @param y0 {number}
            +277          * @param x1 {number}
            +278          * @param y1 {number}
            +279          * @return this
            +280          */
            +281         setLinear : function(x0,y0,x1,y1) {
            +282             this.pathSegments= [];
            +283             this.beginPath(x0,y0);
            +284             this.addLineTo(x1,y1);
            +285             this.endPath();
            +286 
            +287             return this;
            +288         },
            +289         /**
            +290          * Set this path to be composed by a single Quadric Bezier path segment.
            +291          * @param x0 {number}
            +292          * @param y0 {number}
            +293          * @param x1 {number}
            +294          * @param y1 {number}
            +295          * @param x2 {number}
            +296          * @param y2 {number}
            +297          * @return this
            +298          */
            +299         setQuadric : function(x0,y0,x1,y1,x2,y2) {
            +300             this.beginPath(x0,y0);
            +301             this.addQuadricTo(x1,y1,x2,y2);
            +302             this.endPath();
            +303 
            +304             return this;
            +305         },
            +306         /**
            +307          * Sets this path to be composed by a single Cubic Bezier path segment.
            +308          * @param x0 {number}
            +309          * @param y0 {number}
            +310          * @param x1 {number}
            +311          * @param y1 {number}
            +312          * @param x2 {number}
            +313          * @param y2 {number}
            +314          * @param x3 {number}
            +315          * @param y3 {number}
            +316          *
            +317          * @return this
            +318          */
            +319         setCubic : function(x0,y0,x1,y1,x2,y2,x3,y3) {
            +320             this.beginPath(x0,y0);
            +321             this.addCubicTo(x1,y1,x2,y2,x3,y3);
            +322             this.endPath();
            +323 
            +324             return this;
            +325         },
            +326         setRectangle : function(x0,y0, x1,y1) {
            +327             this.beginPath(x0,y0);
            +328             this.addRectangleTo(x1,y1);
            +329             this.endPath();
            +330 
            +331             return this;
            +332         },
            +333         setCatmullRom : function( points, closed ) {
            +334             if ( closed ) {
            +335                 points = points.slice(0)
            +336                 points.unshift(points[points.length-1])
            +337                 points.push(points[1])
            +338                 points.push(points[2])
            +339             }
            +340 
            +341             for( var i=1; i<points.length-2; i++ ) {
            +342 
            +343                 var segment= new CAAT.PathUtil.CurvePath().setColor("#000").setParent(this);
            +344                 var cm= new CAAT.Math.CatmullRom().setCurve(
            +345                     points[ i-1 ],
            +346                     points[ i ],
            +347                     points[ i+1 ],
            +348                     points[ i+2 ]
            +349                 );
            +350                 segment.curve= cm;
            +351                 this.pathSegments.push(segment);
            +352             }
            +353             return this;
            +354         },
            +355         /**
            +356          * Add a CAAT.PathSegment instance to this path.
            +357          * @param pathSegment {CAAT.PathSegment}
            +358          * @return this
            +359          *
            +360          */
            +361 		addSegment : function(pathSegment) {
            +362             pathSegment.setParent(this);
            +363 			this.pathSegments.push(pathSegment);
            +364             return this;
            +365 		},
            +366         addArcTo : function( x1,y1, x2,y2, radius, cw, color ) {
            +367             var r= new CAAT.PathUtil.ArcPath();
            +368             r.setArcTo(true);
            +369             r.setRadius( radius );
            +370             r.setInitialPosition( x1,y1).
            +371                 setFinalPosition( x2,y2 );
            +372 
            +373 
            +374             r.setParent( this );
            +375             r.setColor( color );
            +376 
            +377             this.pathSegments.push(r);
            +378 
            +379             return this;
            +380         },
            +381         addRectangleTo : function( x1,y1, cw, color ) {
            +382             var r= new CAAT.PathUtil.RectPath();
            +383             r.setPoints([
            +384                     this.endCurvePosition(),
            +385                     new CAAT.Math.Point().set(x1,y1)
            +386                 ]);
            +387 
            +388             r.setClockWise(cw);
            +389             r.setColor(color);
            +390             r.setParent(this);
            +391 
            +392             this.pathSegments.push(r);
            +393 
            +394             return this;
            +395         },
            +396         /**
            +397          * Add a Quadric Bezier path segment to this path.
            +398          * The segment starts in the current last path coordinate.
            +399          * @param px1 {number}
            +400          * @param py1 {number}
            +401          * @param px2 {number}
            +402          * @param py2 {number}
            +403          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
            +404          *         being drawn by a CAAT.PathActor).
            +405          *
            +406          * @return this
            +407          */
            +408 		addQuadricTo : function( px1,py1, px2,py2, color ) {
            +409 			var bezier= new CAAT.Math.Bezier();
            +410 
            +411             bezier.setPoints(
            +412                 [
            +413                     this.endCurvePosition(),
            +414                     new CAAT.Math.Point().set(px1,py1),
            +415                     new CAAT.Math.Point().set(px2,py2)
            +416                 ]);
            +417 
            +418 			this.trackPathX= px2;
            +419 			this.trackPathY= py2;
            +420 			
            +421 			var segment= new CAAT.PathUtil.CurvePath().setColor(color).setParent(this);
            +422 			segment.curve= bezier;
            +423 
            +424 			this.pathSegments.push(segment);
            +425 
            +426             return this;
            +427 		},
            +428         /**
            +429          * Add a Cubic Bezier segment to this path.
            +430          * The segment starts in the current last path coordinate.
            +431          * @param px1 {number}
            +432          * @param py1 {number}
            +433          * @param px2 {number}
            +434          * @param py2 {number}
            +435          * @param px3 {number}
            +436          * @param py3 {number}
            +437          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
            +438          *         being drawn by a CAAT.PathActor).
            +439          *
            +440          * @return this
            +441          */
            +442 		addCubicTo : function( px1,py1, px2,py2, px3,py3, color ) {
            +443 			var bezier= new CAAT.Math.Bezier();
            +444 
            +445             bezier.setPoints(
            +446                 [
            +447                     this.endCurvePosition(),
            +448                     new CAAT.Math.Point().set(px1,py1),
            +449                     new CAAT.Math.Point().set(px2,py2),
            +450                     new CAAT.Math.Point().set(px3,py3)
            +451                 ]);
            +452 
            +453 			this.trackPathX= px3;
            +454 			this.trackPathY= py3;
            +455 			
            +456 			var segment= new CAAT.PathUtil.CurvePath().setColor(color).setParent(this);
            +457 			segment.curve= bezier;
            +458 
            +459 			this.pathSegments.push(segment);
            +460             return this;
            +461 		},
            +462         /**
            +463          * Add a Catmull-Rom segment to this path.
            +464          * The segment starts in the current last path coordinate.
            +465          * @param px1 {number}
            +466          * @param py1 {number}
            +467          * @param px2 {number}
            +468          * @param py2 {number}
            +469          * @param px3 {number}
            +470          * @param py3 {number}
            +471          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
            +472          *         being drawn by a CAAT.PathActor).
            +473          *
            +474          * @return this
            +475          */
            +476 		addCatmullTo : function( px1,py1, px2,py2, px3,py3, color ) {
            +477 			var curve= new CAAT.Math.CatmullRom().setColor(color);
            +478 			curve.setCurve(this.trackPathX,this.trackPathY, px1,py1, px2,py2, px3,py3);
            +479 			this.trackPathX= px3;
            +480 			this.trackPathY= py3;
            +481 			
            +482 			var segment= new CAAT.PathUtil.CurvePath().setParent(this);
            +483 			segment.curve= curve;
            +484 
            +485 			this.pathSegments.push(segment);
            +486             return this;
            +487 		},
            +488         /**
            +489          * Adds a line segment to this path.
            +490          * The segment starts in the current last path coordinate.
            +491          * @param px1 {number}
            +492          * @param py1 {number}
            +493          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
            +494          *         being drawn by a CAAT.PathActor).
            +495          *
            +496          * @return this
            +497          */
            +498 		addLineTo : function( px1,py1, color ) {
            +499 			var segment= new CAAT.PathUtil.LinearPath().setColor(color);
            +500             segment.setPoints( [
            +501                     this.endCurvePosition(),
            +502                     new CAAT.Math.Point().set(px1,py1)
            +503                 ]);
            +504 
            +505             segment.setParent(this);
            +506 
            +507 			this.trackPathX= px1;
            +508 			this.trackPathY= py1;
            +509 			
            +510 			this.pathSegments.push(segment);
            +511             return this;
            +512 		},
            +513         /**
            +514          * Set the path's starting point. The method startCurvePosition will return this coordinate.
            +515          * <p>
            +516          * If a call to any method of the form <code>add<Segment>To</code> is called before this calling
            +517          * this method, they will assume to start at -1,-1 and probably you'll get the wrong path.
            +518          * @param px0 {number}
            +519          * @param py0 {number}
            +520          *
            +521          * @return this
            +522          */
            +523 		beginPath : function( px0, py0 ) {
            +524 			this.trackPathX= px0;
            +525 			this.trackPathY= py0;
            +526 			this.beginPathX= px0;
            +527 			this.beginPathY= py0;
            +528             return this;
            +529 		},
            +530         /**
            +531          * <del>Close the path by adding a line path segment from the current last path
            +532          * coordinate to startCurvePosition coordinate</del>.
            +533          * <p>
            +534          * This method closes a path by setting its last path segment's last control point
            +535          * to be the first path segment's first control point.
            +536          * <p>
            +537          *     This method also sets the path as finished, and calculates all path's information
            +538          *     such as length and bounding box.
            +539          *
            +540          * @return this
            +541          */
            +542 		closePath : function()	{
            +543 
            +544             this.getLastPathSegment().setPoint(
            +545                 this.getFirstPathSegment().startCurvePosition(),
            +546                 this.getLastPathSegment().numControlPoints()-1 );
            +547 
            +548 
            +549 			this.trackPathX= this.beginPathX;
            +550 			this.trackPathY= this.beginPathY;
            +551 
            +552             this.closed= true;
            +553 
            +554 			this.endPath();
            +555             return this;
            +556 		},
            +557         /**
            +558          * Finishes the process of building the path. It involves calculating each path segments length
            +559          * and proportional length related to a normalized path length of 1.
            +560          * It also sets current paths length.
            +561          * These calculi are needed to traverse the path appropriately.
            +562          * <p>
            +563          * This method must be called explicitly, except when closing a path (that is, calling the
            +564          * method closePath) which calls this method as well.
            +565          *
            +566          * @return this
            +567          */
            +568 		endPath : function() {
            +569 
            +570 			this.pathSegmentStartTime=[];
            +571 			this.pathSegmentDurationTime= [];
            +572 
            +573             this.updatePath();
            +574 
            +575             return this;
            +576 		},
            +577         /**
            +578          * This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path.
            +579          * The returned coordinate is the corresponding to normalizing the path's length to 1,
            +580          * and then finding what path segment and what coordinate in that path segment corresponds
            +581          * for the input time parameter.
            +582          * <p>
            +583          * The parameter time must be a value ranging 0..1.
            +584          * If not constrained to these values, the parameter will be modulus 1, and then, if less
            +585          * than 0, be normalized to 1+time, so that the value always ranges from 0 to 1.
            +586          * <p>
            +587          * This method is needed when traversing the path throughout a CAAT.Interpolator instance.
            +588          *
            +589          *
            +590          * @param time {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate.
            +591          * 1 will return path's end coordinate.
            +592          * @param open_contour {boolean=} treat this path as an open contour. It is intended for
            +593          * open paths, and interpolators which give values above 1. see tutorial 7.1.
            +594          * @link{../../documentation/tutorials/t7-1.html}
            +595          *
            +596          * @return {CAAT.Foundation.Point}
            +597          */
            +598 		getPosition : function(time, open_contour) {
            +599 
            +600             if (open_contour && (time>=1 || time<=0) ) {
            +601 
            +602                 var p0,p1,ratio, angle;
            +603 
            +604                 if ( time>=1 ) {
            +605                     // these values could be cached.
            +606                     p0= this.__getPositionImpl( .999 );
            +607                     p1= this.endCurvePosition();
            +608 
            +609                     angle= Math.atan2( p1.y - p0.y, p1.x - p0.x );
            +610                     ratio= time%1;
            +611 
            +612 
            +613                 } else {
            +614                     // these values could be cached.
            +615                     p0= this.__getPositionImpl( .001 );
            +616                     p1= this.startCurvePosition();
            +617 
            +618                     angle= Math.atan2( p1.y - p0.y, p1.x - p0.x );
            +619                     ratio= -time;
            +620                 }
            +621 
            +622                 var np= this.newPosition;
            +623                 var length= this.getLength();
            +624 
            +625                 np.x = p1.x + (ratio * length)*Math.cos(angle);
            +626                 np.y = p1.y + (ratio * length)*Math.sin(angle);
            +627 
            +628 
            +629                 return np;
            +630             }
            +631 
            +632             return this.__getPositionImpl(time);
            +633         },
            +634 
            +635         __getPositionImpl : function(time) {
            +636 
            +637             if ( time>1 || time<0 ) {
            +638                 time%=1;
            +639             }
            +640             if ( time<0 ) {
            +641                 time= 1+time;
            +642             }
            +643 
            +644             var ps= this.pathSegments;
            +645             var psst= this.pathSegmentStartTime;
            +646             var psdt= this.pathSegmentDurationTime;
            +647             var l=  0;
            +648             var r=  ps.length;
            +649             var m;
            +650             var np= this.newPosition;
            +651             var psstv;
            +652             while( l!==r ) {
            +653 
            +654                 m= ((r+l)/2)|0;
            +655                 psstv= psst[m];
            +656                 if ( psstv<=time && time<=psstv+psdt[m]) {
            +657                     time= psdt[m] ?
            +658                             (time-psstv)/psdt[m] :
            +659                             0;
            +660 
            +661                     // Clamp this segment's time to a maximum since it is relative to the path.
            +662                     // thanks https://github.com/donaldducky for spotting.
            +663                     if (time>1) {
            +664                         time=1;
            +665                     } else if (time<0 ) {
            +666                         time= 0;
            +667                     }
            +668 
            +669                     var pointInPath= ps[m].getPosition(time);
            +670                     np.x= pointInPath.x;
            +671                     np.y= pointInPath.y;
            +672                     return np;
            +673                 } else if ( time<psstv ) {
            +674                     r= m;
            +675                 } else /*if ( time>=psstv )*/ {
            +676                     l= m+1;
            +677                 }
            +678             }
            +679             return this.endCurvePosition();
            +680 
            +681 
            +682 		},
            +683         /**
            +684          * Analogously to the method getPosition, this method returns a CAAT.Point instance with
            +685          * the coordinate on the path that corresponds to the given length. The input length is
            +686          * related to path's length.
            +687          *
            +688          * @param iLength {number} a float with the target length.
            +689          * @return {CAAT.Point}
            +690          */
            +691 		getPositionFromLength : function(iLength) {
            +692 			
            +693 			iLength%=this.getLength();
            +694 			if (iLength<0 ) {
            +695 				iLength+= this.getLength();
            +696 			}
            +697 			
            +698 			var accLength=0;
            +699 			
            +700 			for( var i=0; i<this.pathSegments.length; i++ ) {
            +701 				if (accLength<=iLength && iLength<=this.pathSegments[i].getLength()+accLength) {
            +702 					iLength-= accLength;
            +703 					var pointInPath= this.pathSegments[i].getPositionFromLength(iLength);
            +704 					this.newPosition.x= pointInPath.x;
            +705 					this.newPosition.y= pointInPath.y;
            +706 					break;
            +707 				}
            +708 				accLength+= this.pathSegments[i].getLength();
            +709 			}
            +710 			
            +711 			return this.newPosition;
            +712 		},
            +713         /**
            +714          * Paints the path.
            +715          * This method is called by CAAT.PathActor instances.
            +716          * If the path is set as interactive (by default) path segment will draw curve modification
            +717          * handles as well.
            +718          *
            +719          * @param director {CAAT.Director} a CAAT.Director instance.
            +720          */
            +721 		paint : function( director ) {
            +722 			for( var i=0; i<this.pathSegments.length; i++ ) {
            +723 				this.pathSegments[i].paint(director,this.interactive);
            +724 			}
            +725 		},
            +726         /**
            +727          * Method invoked when a CAAT.PathActor stops dragging a control point.
            +728          */
            +729 		release : function() {
            +730 			this.ax= -1;
            +731 			this.ay= -1;
            +732 		},
            +733         isEmpty : function() {
            +734             return !this.pathSegments.length;
            +735         },
            +736         /**
            +737          * Returns an integer with the number of path segments that conform this path.
            +738          * @return {number}
            +739          */
            +740         getNumSegments : function() {
            +741             return this.pathSegments.length;
            +742         },
            +743         /**
            +744          * Gets a CAAT.PathSegment instance.
            +745          * @param index {number} the index of the desired CAAT.PathSegment.
            +746          * @return CAAT.PathSegment
            +747          */
            +748 		getSegment : function(index) {
            +749 			return this.pathSegments[index];
            +750 		},
            +751 
            +752         numControlPoints : function() {
            +753             return this.points.length;
            +754         },
            +755 
            +756         getControlPoint : function(index) {
            +757             return this.points[index];
            +758         },
            +759 
            +760         /**
            +761          * Indicates that some path control point has changed, and that the path must recalculate
            +762          * its internal data, ie: length and bbox.
            +763          */
            +764 		updatePath : function(point, callback) {
            +765             var i,j;
            +766 
            +767             this.length=0;
            +768             this.bbox.setEmpty();
            +769             this.points= [];
            +770 
            +771             var xmin= Number.MAX_VALUE, ymin= Number.MAX_VALUE;
            +772 			for( i=0; i<this.pathSegments.length; i++ ) {
            +773 				this.pathSegments[i].updatePath(point);
            +774                 this.length+= this.pathSegments[i].getLength();
            +775                 this.bbox.unionRectangle( this.pathSegments[i].bbox );
            +776 
            +777                 for( j=0; j<this.pathSegments[i].numControlPoints(); j++ ) {
            +778                     var pt= this.pathSegments[i].getControlPoint( j );
            +779                     this.points.push( pt );
            +780                     if ( pt.x < xmin ) {
            +781                         xmin= pt.x;
            +782                     }
            +783                     if ( pt.y < ymin ) {
            +784                         ymin= pt.y;
            +785                     }
            +786                 }
            +787 			}
            +788 
            +789             this.clipOffsetX= -xmin;
            +790             this.clipOffsetY= -ymin;
            +791 
            +792             this.width= this.bbox.width;
            +793             this.height= this.bbox.height;
            +794             this.setLocation( this.bbox.x, this.bbox.y );
            +795 
            +796             this.pathSegmentStartTime=      [];
            +797             this.pathSegmentDurationTime=   [];
            +798             
            +799             var i;
            +800             for( i=0; i<this.pathSegments.length; i++) {
            +801                 this.pathSegmentStartTime.push(0);
            +802                 this.pathSegmentDurationTime.push(0);
            +803             }
            +804 
            +805             for( i=0; i<this.pathSegments.length; i++) {
            +806                 this.pathSegmentDurationTime[i]= this.getLength() ? this.pathSegments[i].getLength()/this.getLength() : 0;
            +807                 if ( i>0 ) {
            +808                     this.pathSegmentStartTime[i]= this.pathSegmentStartTime[i-1]+this.pathSegmentDurationTime[i-1];
            +809                 } else {
            +810                     this.pathSegmentStartTime[0]= 0;
            +811                 }
            +812 
            +813                 this.pathSegments[i].endPath();
            +814             }
            +815 
            +816             this.extractPathPoints();
            +817 
            +818             if ( callback ) {
            +819                 callback(this);
            +820             }
            +821 
            +822             return this;
            +823 
            +824 		},
            +825         /**
            +826          * Sent by a CAAT.PathActor instance object to try to drag a path's control point.
            +827          * @param x {number}
            +828          * @param y {number}
            +829          */
            +830 		press: function(x,y) {
            +831             if (!this.interactive) {
            +832                 return;
            +833             }
            +834 
            +835             var HS= CAAT.Math.Curve.prototype.HANDLE_SIZE/2;
            +836 			for( var i=0; i<this.pathSegments.length; i++ ) {
            +837 				for( var j=0; j<this.pathSegments[i].numControlPoints(); j++ ) {
            +838 					var point= this.pathSegments[i].getControlPoint(j);
            +839 					if ( x>=point.x-HS &&
            +840 						 y>=point.y-HS &&
            +841 						 x<point.x+HS &&
            +842 						 y<point.y+HS ) {
            +843 						
            +844 						this.point= point;
            +845 						return;
            +846 					}
            +847 				}
            +848 			}
            +849 			this.point= null;
            +850 		},
            +851         /**
            +852          * Drags a path's control point.
            +853          * If the method press has not set needed internal data to drag a control point, this
            +854          * method will do nothing, regardless the user is dragging on the CAAT.PathActor delegate.
            +855          * @param x {number}
            +856          * @param y {number}
            +857          */
            +858 		drag : function(x,y,callback) {
            +859             if (!this.interactive) {
            +860                 return;
            +861             }
            +862 
            +863 			if ( null===this.point ) {
            +864 				return;
            +865 			}
            +866 			
            +867 			if ( -1===this.ax || -1===this.ay ) {
            +868 				this.ax= x;
            +869 				this.ay= y;
            +870 			}
            +871 			
            +872             this.point.x+= x-this.ax;
            +873             this.point.y+= y-this.ay;
            +874 
            +875 			this.ax= x;
            +876 			this.ay= y;
            +877 
            +878 			this.updatePath(this.point,callback);
            +879 		},
            +880         /**
            +881          * Returns a collection of CAAT.Point objects which conform a path's contour.
            +882          * @param iSize {number}. Number of samples for each path segment.
            +883          * @return {[CAAT.Point]}
            +884          */
            +885         getContour : function(iSize) {
            +886             var contour=[];
            +887             for( var i=0; i<=iSize; i++ ) {
            +888                 contour.push( new CAAT.Math.Point().set( i/iSize, this.getPosition(i/iSize).y, 0 ) );
            +889             }
            +890 
            +891             return contour;
            +892         },
            +893 
            +894         /**
            +895          * Reposition this path points.
            +896          * This operation will only take place if the supplied points array equals in size to
            +897          * this path's already set points.
            +898          * @param points {Array<CAAT.Point>}
            +899          */
            +900         setPoints : function( points ) {
            +901             if ( this.points.length===points.length ) {
            +902                 for( var i=0; i<points.length; i++ ) {
            +903                     this.points[i].x= points[i].x;
            +904                     this.points[i].y= points[i].y;
            +905                 }
            +906             }
            +907             return this;
            +908         },
            +909 
            +910         /**
            +911          * Set a point from this path.
            +912          * @param point {CAAT.Point}
            +913          * @param index {integer} a point index.
            +914          */
            +915         setPoint : function( point, index ) {
            +916             if ( index>=0 && index<this.points.length ) {
            +917                 this.points[index].x= point.x;
            +918                 this.points[index].y= point.y;
            +919             }
            +920             return this;
            +921         },
            +922 
            +923 
            +924         /**
            +925          * Removes all behaviors from an Actor.
            +926          * @return this
            +927          */
            +928 		emptyBehaviorList : function() {
            +929 			this.behaviorList=[];
            +930             return this;
            +931 		},
            +932 
            +933         extractPathPoints : function() {
            +934             if ( !this.pathPoints ) {
            +935                 var i;
            +936                 this.pathPoints= [];
            +937                 for ( i=0; i<this.numControlPoints(); i++ ) {
            +938                     this.pathPoints.push( this.getControlPoint(i).clone() );
            +939                 }
            +940             }
            +941 
            +942             return this;
            +943         },
            +944 
            +945         /**
            +946          * Add a Behavior to the Actor.
            +947          * An Actor accepts an undefined number of Behaviors.
            +948          *
            +949          * @param behavior {CAAT.Behavior} a CAAT.Behavior instance
            +950          * @return this
            +951          */
            +952 		addBehavior : function( behavior )	{
            +953 			this.behaviorList.push(behavior);
            +954 //            this.extractPathPoints();
            +955             return this;
            +956 		},
            +957         /**
            +958          * Remove a Behavior from the Actor.
            +959          * If the Behavior is not present at the actor behavior collection nothing happends.
            +960          *
            +961          * @param behavior {CAAT.Behavior} a CAAT.Behavior instance.
            +962          */
            +963         removeBehaviour : function( behavior ) {
            +964             var n= this.behaviorList.length-1;
            +965             while(n) {
            +966                 if ( this.behaviorList[n]===behavior ) {
            +967                     this.behaviorList.splice(n,1);
            +968                     return this;
            +969                 }
            +970             }
            +971 
            +972             return this;
            +973         },
            +974         /**
            +975          * Remove a Behavior with id param as behavior identifier from this actor.
            +976          * This function will remove ALL behavior instances with the given id.
            +977          *
            +978          * @param id {number} an integer.
            +979          * return this;
            +980          */
            +981         removeBehaviorById : function( id ) {
            +982             for( var n=0; n<this.behaviorList.length; n++ ) {
            +983                 if ( this.behaviorList[n].id===id) {
            +984                     this.behaviorList.splice(n,1);
            +985                 }
            +986             }
            +987 
            +988             return this;
            +989 
            +990         },
            +991 
            +992         applyBehaviors : function(time) {
            +993 //            if (this.behaviorList.length) {
            +994                 for( var i=0; i<this.behaviorList.length; i++ )	{
            +995                     this.behaviorList[i].apply(time,this);
            +996                 }
            +997 
            +998                 /** calculate behavior affine transform matrix **/
            +999                 this.setATMatrix();
            +1000 
            +1001                 for (i = 0; i < this.numControlPoints(); i++) {
            +1002                     this.setPoint(
            +1003                         this.matrix.transformCoord(
            +1004                             this.pathPoints[i].clone().translate( this.clipOffsetX, this.clipOffsetY )), i);
            +1005                 }
            +1006 //            }
            +1007 
            +1008             return this;
            +1009         },
            +1010 
            +1011         setATMatrix : function() {
            +1012             this.matrix.identity();
            +1013 
            +1014             var m= this.tmpMatrix.identity();
            +1015             var mm= this.matrix.matrix;
            +1016             var c,s,_m00,_m01,_m10,_m11;
            +1017             var mm0, mm1, mm2, mm3, mm4, mm5;
            +1018 
            +1019             var bbox= this.bbox;
            +1020             var bbw= bbox.width  ;
            +1021             var bbh= bbox.height ;
            +1022             var bbx= bbox.x;
            +1023             var bby= bbox.y
            +1024 
            +1025             mm0= 1;
            +1026             mm1= 0;
            +1027             mm3= 0;
            +1028             mm4= 1;
            +1029 
            +1030             mm2= this.tb_x - bbx - this.tAnchorX * bbw;
            +1031             mm5= this.tb_y - bby - this.tAnchorY * bbh;
            +1032 
            +1033             if ( this.rb_angle ) {
            +1034 
            +1035                 var rbx= (this.rb_rotateAnchorX*bbw + bbx);
            +1036                 var rby= (this.rb_rotateAnchorY*bbh + bby);
            +1037 
            +1038                 mm2+= mm0*rbx + mm1*rby;
            +1039                 mm5+= mm3*rbx + mm4*rby;
            +1040 
            +1041                 c= Math.cos( this.rb_angle );
            +1042                 s= Math.sin( this.rb_angle);
            +1043                 _m00= mm0;
            +1044                 _m01= mm1;
            +1045                 _m10= mm3;
            +1046                 _m11= mm4;
            +1047                 mm0=  _m00*c + _m01*s;
            +1048                 mm1= -_m00*s + _m01*c;
            +1049                 mm3=  _m10*c + _m11*s;
            +1050                 mm4= -_m10*s + _m11*c;
            +1051 
            +1052                 mm2+= -mm0*rbx - mm1*rby;
            +1053                 mm5+= -mm3*rbx - mm4*rby;
            +1054             }
            +1055 
            +1056             if ( this.sb_scaleX!=1 || this.sb_scaleY!=1 ) {
            +1057 
            +1058                 var sbx= (this.sb_scaleAnchorX*bbw + bbx);
            +1059                 var sby= (this.sb_scaleAnchorY*bbh + bby);
            +1060 
            +1061                 mm2+= mm0*sbx + mm1*sby;
            +1062                 mm5+= mm3*sbx + mm4*sby;
            +1063 
            +1064                 mm0= mm0*this.sb_scaleX;
            +1065                 mm1= mm1*this.sb_scaleY;
            +1066                 mm3= mm3*this.sb_scaleX;
            +1067                 mm4= mm4*this.sb_scaleY;
            +1068 
            +1069                 mm2+= -mm0*sbx - mm1*sby;
            +1070                 mm5+= -mm3*sbx - mm4*sby;
            +1071             }
            +1072 
            +1073             mm[0]= mm0;
            +1074             mm[1]= mm1;
            +1075             mm[2]= mm2;
            +1076             mm[3]= mm3;
            +1077             mm[4]= mm4;
            +1078             mm[5]= mm5;
            +1079 
            +1080             return this;
            +1081 
            +1082         },
            +1083 
            +1084         setRotationAnchored : function( angle, rx, ry ) {
            +1085             this.rb_angle=          angle;
            +1086             this.rb_rotateAnchorX=  rx;
            +1087             this.rb_rotateAnchorY=  ry;
            +1088             return this;
            +1089         },
            +1090 
            +1091         setRotationAnchor : function( ax, ay ) {
            +1092             this.rb_rotateAnchorX= ax;
            +1093             this.rb_rotateAnchorY= ay;
            +1094         },
            +1095 
            +1096         setRotation : function( angle ) {
            +1097             this.rb_angle= angle;
            +1098         },
            +1099 
            +1100         setScaleAnchored : function( scaleX, scaleY, sx, sy ) {
            +1101             this.sb_scaleX= scaleX;
            +1102             this.sb_scaleAnchorX= sx;
            +1103             this.sb_scaleY= scaleY;
            +1104             this.sb_scaleAnchorY= sy;
            +1105             return this;
            +1106         },
            +1107 
            +1108         setScale : function( sx, sy ) {
            +1109             this.sb_scaleX= sx;
            +1110             this.sb_scaleY= sy;
            +1111             return this;
            +1112         },
            +1113 
            +1114         setScaleAnchor : function( ax, ay ) {
            +1115             this.sb_scaleAnchorX= ax;
            +1116             this.sb_scaleAnchorY= ay;
            +1117             return this;
            +1118         },
            +1119 
            +1120         setPositionAnchor : function( ax, ay ) {
            +1121             this.tAnchorX= ax;
            +1122             this.tAnchorY= ay;
            +1123             return this;
            +1124         },
            +1125 
            +1126         setPositionAnchored : function( x,y,ax,ay ) {
            +1127             this.tb_x= x;
            +1128             this.tb_y= y;
            +1129             this.tAnchorX= ax;
            +1130             this.tAnchorY= ay;
            +1131             return this;
            +1132         },
            +1133 
            +1134         setPosition : function( x,y ) {
            +1135             this.tb_x= x;
            +1136             this.tb_y= y;
            +1137             return this;
            +1138         },
            +1139 
            +1140         setLocation : function( x, y ) {
            +1141             this.tb_x= x;
            +1142             this.tb_y= y;
            +1143             return this;
            +1144         },
            +1145 
            +1146         flatten : function( npatches, closed ) {
            +1147             var point= this.getPositionFromLength(0);
            +1148             var path= new CAAT.PathUtil.Path().beginPath( point.x, point.y );
            +1149             for( var i=0; i<npatches; i++ ) {
            +1150                 point= this.getPositionFromLength(i/npatches*this.length);
            +1151                 path.addLineTo( point.x, point.y  );
            +1152             }
            +1153             if ( closed) {
            +1154                 path.closePath();
            +1155             } else {
            +1156                 path.endPath();
            +1157             }
            +1158 
            +1159             return path;
            +1160         }
            +1161 
            +1162     }
            +1163 	
            +1164 });
            +1165 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_PathSegment.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_PathSegment.js.html new file mode 100644 index 0000000..631e91d --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_PathSegment.js.html @@ -0,0 +1,220 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  * These classes encapsulate different kinds of paths.
            +  5  * LinearPath, defines an straight line path, just 2 points.
            +  6  * CurvePath, defines a path based on a Curve. Curves can be bezier quadric/cubic and catmull-rom.
            +  7  * Path, is a general purpose class, which composes a path of different path segments (Linear or Curve paths).
            +  8  *
            +  9  * A path, has an interpolator which stablish the way the path is traversed (accelerating, by
            + 10  * easing functions, etc.). Normally, interpolators will be defined by CAAT.Behavior.Interpolator instances, but
            + 11  * general Paths could be used as well.
            + 12  *
            + 13  **/
            + 14 
            + 15 
            + 16 CAAT.Module({
            + 17 
            + 18     /**
            + 19      * @name PathUtil
            + 20      * @memberOf CAAT
            + 21      * @namespace
            + 22      */
            + 23 
            + 24     /**
            + 25      * @name PathSegment
            + 26      * @memberOf CAAT.PathUtil
            + 27      * @constructor
            + 28      */
            + 29 
            + 30     defines:"CAAT.PathUtil.PathSegment",
            + 31     depends:[
            + 32         "CAAT.Math.Rectangle",
            + 33         "CAAT.Math.Point",
            + 34         "CAAT.Math.Matrix",
            + 35         "CAAT.Math.Curve"
            + 36     ],
            + 37     extendsWith:function () {
            + 38         return {
            + 39 
            + 40             /**
            + 41              * @lends CAAT.PathUtil.PathSegment.prototype
            + 42              */
            + 43 
            + 44 
            + 45             __init:function () {
            + 46                 this.bbox = new CAAT.Math.Rectangle();
            + 47                 return this;
            + 48             },
            + 49 
            + 50             /**
            + 51              * Color to draw the segment.
            + 52              */
            + 53             color:'#000',
            + 54 
            + 55             /**
            + 56              * Segment length.
            + 57              */
            + 58             length:0,
            + 59 
            + 60             /**
            + 61              * Segment bounding box.
            + 62              */
            + 63             bbox:null,
            + 64 
            + 65             /**
            + 66              * Path this segment belongs to.
            + 67              */
            + 68             parent:null,
            + 69 
            + 70             /**
            + 71              * Set a PathSegment's parent
            + 72              * @param parent
            + 73              */
            + 74             setParent:function (parent) {
            + 75                 this.parent = parent;
            + 76                 return this;
            + 77             },
            + 78             setColor:function (color) {
            + 79                 if (color) {
            + 80                     this.color = color;
            + 81                 }
            + 82                 return this;
            + 83             },
            + 84             /**
            + 85              * Get path's last coordinate.
            + 86              * @return {CAAT.Point}
            + 87              */
            + 88             endCurvePosition:function () {
            + 89             },
            + 90 
            + 91             /**
            + 92              * Get path's starting coordinate.
            + 93              * @return {CAAT.Point}
            + 94              */
            + 95             startCurvePosition:function () {
            + 96             },
            + 97 
            + 98             /**
            + 99              * Set this path segment's points information.
            +100              * @param points {Array<CAAT.Point>}
            +101              */
            +102             setPoints:function (points) {
            +103             },
            +104 
            +105             /**
            +106              * Set a point from this path segment.
            +107              * @param point {CAAT.Point}
            +108              * @param index {integer} a point index.
            +109              */
            +110             setPoint:function (point, index) {
            +111             },
            +112 
            +113             /**
            +114              * Get a coordinate on path.
            +115              * The parameter time is normalized, that is, its values range from zero to one.
            +116              * zero will mean <code>startCurvePosition</code> and one will be <code>endCurvePosition</code>. Other values
            +117              * will be a position on the path relative to the path length. if the value is greater that 1, if will be set
            +118              * to modulus 1.
            +119              * @param time a float with a value between zero and 1 inclusive both.
            +120              *
            +121              * @return {CAAT.Point}
            +122              */
            +123             getPosition:function (time) {
            +124             },
            +125 
            +126             /**
            +127              * Gets Path length.
            +128              * @return {number}
            +129              */
            +130             getLength:function () {
            +131                 return this.length;
            +132             },
            +133 
            +134             /**
            +135              * Gets the path bounding box (or the rectangle that contains the whole path).
            +136              * @param rectangle a CAAT.Rectangle instance with the bounding box.
            +137              * @return {CAAT.Rectangle}
            +138              */
            +139             getBoundingBox:function () {
            +140                 return this.bbox;
            +141             },
            +142 
            +143             /**
            +144              * Gets the number of control points needed to create the path.
            +145              * Each PathSegment type can have different control points.
            +146              * @return {number} an integer with the number of control points.
            +147              */
            +148             numControlPoints:function () {
            +149             },
            +150 
            +151             /**
            +152              * Gets CAAT.Point instance with the 2d position of a control point.
            +153              * @param index an integer indicating the desired control point coordinate.
            +154              * @return {CAAT.Point}
            +155              */
            +156             getControlPoint:function (index) {
            +157             },
            +158 
            +159             /**
            +160              * Instruments the path has finished building, and that no more segments will be added to it.
            +161              * You could later add more PathSegments and <code>endPath</code> must be called again.
            +162              */
            +163             endPath:function () {
            +164             },
            +165 
            +166             /**
            +167              * Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments.
            +168              * @param iSize an integer indicating the number of segments of the contour polyline.
            +169              *
            +170              * @return {[CAAT.Point]}
            +171              */
            +172             getContour:function (iSize) {
            +173             },
            +174 
            +175             /**
            +176              * Recalculate internal path structures.
            +177              */
            +178             updatePath:function (point) {
            +179             },
            +180 
            +181             /**
            +182              * Draw this path using RenderingContext2D drawing primitives.
            +183              * The intention is to set a path or pathsegment as a clipping region.
            +184              *
            +185              * @param ctx {RenderingContext2D}
            +186              */
            +187             applyAsPath:function (director) {
            +188             },
            +189 
            +190             /**
            +191              * Transform this path with the given affinetransform matrix.
            +192              * @param matrix
            +193              */
            +194             transform:function (matrix) {
            +195             },
            +196 
            +197             drawHandle:function (ctx, x, y) {
            +198 
            +199                 ctx.beginPath();
            +200                 ctx.arc(
            +201                     x,
            +202                     y,
            +203                     CAAT.Math.Curve.prototype.HANDLE_SIZE / 2,
            +204                     0,
            +205                     2 * Math.PI,
            +206                     false);
            +207                 ctx.fill();
            +208             }
            +209         }
            +210     }
            +211 
            +212 });
            +213 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_RectPath.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_RectPath.js.html new file mode 100644 index 0000000..5b08db4 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_RectPath.js.html @@ -0,0 +1,328 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name RectPath
            +  5      * @memberOf CAAT.PathUtil
            +  6      * @extends CAAT.PathUtil.PathSegment
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines:"CAAT.PathUtil.RectPath",
            + 11     depends:[
            + 12         "CAAT.PathUtil.PathSegment",
            + 13         "CAAT.Math.Point",
            + 14         "CAAT.Math.Rectangle"
            + 15     ],
            + 16     aliases:["CAAT.RectPath", "CAAT.ShapePath"],
            + 17     extendsClass:"CAAT.PathUtil.PathSegment",
            + 18     extendsWith:function () {
            + 19 
            + 20         return {
            + 21 
            + 22             /**
            + 23              * @lends CAAT.PathUtil.RectPath.prototype
            + 24              */
            + 25 
            + 26             __init:function () {
            + 27                 this.__super();
            + 28 
            + 29                 this.points = [];
            + 30                 this.points.push(new CAAT.Math.Point());
            + 31                 this.points.push(new CAAT.Math.Point());
            + 32                 this.points.push(new CAAT.Math.Point());
            + 33                 this.points.push(new CAAT.Math.Point());
            + 34                 this.points.push(new CAAT.Math.Point());
            + 35 
            + 36                 this.newPosition = new CAAT.Math.Point();
            + 37 
            + 38                 return this;
            + 39             },
            + 40 
            + 41             /**
            + 42              * A collection of Points.
            + 43              * @type {Array.<CAAT.Math.Point>}
            + 44              */
            + 45             points:null,
            + 46 
            + 47             /**
            + 48              * Traverse this path clockwise or counterclockwise (false).
            + 49              */
            + 50             cw:true,
            + 51 
            + 52             /**
            + 53              * spare point for calculations
            + 54              */
            + 55             newPosition:null,
            + 56 
            + 57             applyAsPath:function (director) {
            + 58                 var ctx = director.ctx;
            + 59 
            + 60                 if (this.cw) {
            + 61                     ctx.lineTo(this.points[0].x, this.points[0].y);
            + 62                     ctx.lineTo(this.points[1].x, this.points[1].y);
            + 63                     ctx.lineTo(this.points[2].x, this.points[2].y);
            + 64                     ctx.lineTo(this.points[3].x, this.points[3].y);
            + 65                     ctx.lineTo(this.points[4].x, this.points[4].y);
            + 66                 } else {
            + 67                     ctx.lineTo(this.points[4].x, this.points[4].y);
            + 68                     ctx.lineTo(this.points[3].x, this.points[3].y);
            + 69                     ctx.lineTo(this.points[2].x, this.points[2].y);
            + 70                     ctx.lineTo(this.points[1].x, this.points[1].y);
            + 71                     ctx.lineTo(this.points[0].x, this.points[0].y);
            + 72                 }
            + 73                 return this;
            + 74             },
            + 75             setPoint:function (point, index) {
            + 76                 if (index >= 0 && index < this.points.length) {
            + 77                     this.points[index] = point;
            + 78                 }
            + 79             },
            + 80             /**
            + 81              * An array of {CAAT.Point} composed of two points.
            + 82              * @param points {Array<CAAT.Point>}
            + 83              */
            + 84             setPoints:function (points) {
            + 85                 this.points = [];
            + 86                 this.points.push(points[0]);
            + 87                 this.points.push(new CAAT.Math.Point().set(points[1].x, points[0].y));
            + 88                 this.points.push(points[1]);
            + 89                 this.points.push(new CAAT.Math.Point().set(points[0].x, points[1].y));
            + 90                 this.points.push(points[0].clone());
            + 91                 this.updatePath();
            + 92 
            + 93                 return this;
            + 94             },
            + 95             setClockWise:function (cw) {
            + 96                 this.cw = cw !== undefined ? cw : true;
            + 97                 return this;
            + 98             },
            + 99             isClockWise:function () {
            +100                 return this.cw;
            +101             },
            +102             /**
            +103              * Set this path segment's starting position.
            +104              * This method should not be called again after setFinalPosition has been called.
            +105              * @param x {number}
            +106              * @param y {number}
            +107              */
            +108             setInitialPosition:function (x, y) {
            +109                 for (var i = 0, l = this.points.length; i < l; i++) {
            +110                     this.points[i].x = x;
            +111                     this.points[i].y = y;
            +112                 }
            +113                 return this;
            +114             },
            +115             /**
            +116              * Set a rectangle from points[0] to (finalX, finalY)
            +117              * @param finalX {number}
            +118              * @param finalY {number}
            +119              */
            +120             setFinalPosition:function (finalX, finalY) {
            +121                 this.points[2].x = finalX;
            +122                 this.points[2].y = finalY;
            +123 
            +124                 this.points[1].x = finalX;
            +125                 this.points[1].y = this.points[0].y;
            +126 
            +127                 this.points[3].x = this.points[0].x;
            +128                 this.points[3].y = finalY;
            +129 
            +130                 this.points[4].x = this.points[0].x;
            +131                 this.points[4].y = this.points[0].y;
            +132 
            +133                 this.updatePath();
            +134                 return this;
            +135             },
            +136             /**
            +137              * @inheritDoc
            +138              */
            +139             endCurvePosition:function () {
            +140                 return this.points[4];
            +141             },
            +142             /**
            +143              * @inheritsDoc
            +144              */
            +145             startCurvePosition:function () {
            +146                 return this.points[0];
            +147             },
            +148             /**
            +149              * @inheritsDoc
            +150              */
            +151             getPosition:function (time) {
            +152 
            +153                 if (time > 1 || time < 0) {
            +154                     time %= 1;
            +155                 }
            +156                 if (time < 0) {
            +157                     time = 1 + time;
            +158                 }
            +159 
            +160                 if (-1 === this.length) {
            +161                     this.newPosition.set(0, 0);
            +162                 } else {
            +163                     var w = this.bbox.width / this.length;
            +164                     var h = this.bbox.height / this.length;
            +165                     var accTime = 0;
            +166                     var times;
            +167                     var segments;
            +168                     var index = 0;
            +169 
            +170                     if (this.cw) {
            +171                         segments = [0, 1, 2, 3, 4];
            +172                         times = [w, h, w, h];
            +173                     } else {
            +174                         segments = [4, 3, 2, 1, 0];
            +175                         times = [h, w, h, w];
            +176                     }
            +177 
            +178                     while (index < times.length) {
            +179                         if (accTime + times[index] < time) {
            +180                             accTime += times[index];
            +181                             index++;
            +182                         } else {
            +183                             break;
            +184                         }
            +185                     }
            +186                     time -= accTime;
            +187 
            +188                     var p0 = segments[index];
            +189                     var p1 = segments[index + 1];
            +190 
            +191                     // index tiene el indice del segmento en tiempo.
            +192                     this.newPosition.set(
            +193                         (this.points[p0].x + (this.points[p1].x - this.points[p0].x) * time / times[index]),
            +194                         (this.points[p0].y + (this.points[p1].y - this.points[p0].y) * time / times[index]));
            +195                 }
            +196 
            +197                 return this.newPosition;
            +198             },
            +199             /**
            +200              * Returns initial path segment point's x coordinate.
            +201              * @return {number}
            +202              */
            +203             initialPositionX:function () {
            +204                 return this.points[0].x;
            +205             },
            +206             /**
            +207              * Returns final path segment point's x coordinate.
            +208              * @return {number}
            +209              */
            +210             finalPositionX:function () {
            +211                 return this.points[2].x;
            +212             },
            +213             /**
            +214              * Draws this path segment on screen. Optionally it can draw handles for every control point, in
            +215              * this case, start and ending path segment points.
            +216              * @param director {CAAT.Director}
            +217              * @param bDrawHandles {boolean}
            +218              */
            +219             paint:function (director, bDrawHandles) {
            +220 
            +221                 var ctx = director.ctx;
            +222 
            +223                 ctx.save();
            +224 
            +225                 ctx.strokeStyle = this.color;
            +226                 ctx.beginPath();
            +227                 ctx.strokeRect(
            +228                     this.bbox.x, this.bbox.y,
            +229                     this.bbox.width, this.bbox.height);
            +230 
            +231                 if (bDrawHandles) {
            +232                     ctx.globalAlpha = 0.5;
            +233                     ctx.fillStyle = '#7f7f00';
            +234 
            +235                     for (var i = 0; i < this.points.length; i++) {
            +236                         this.drawHandle(ctx, this.points[i].x, this.points[i].y);
            +237                     }
            +238 
            +239                 }
            +240 
            +241                 ctx.restore();
            +242             },
            +243             /**
            +244              * Get the number of control points. For this type of path segment, start and
            +245              * ending path segment points. Defaults to 2.
            +246              * @return {number}
            +247              */
            +248             numControlPoints:function () {
            +249                 return this.points.length;
            +250             },
            +251             /**
            +252              * @inheritsDoc
            +253              */
            +254             getControlPoint:function (index) {
            +255                 return this.points[index];
            +256             },
            +257             /**
            +258              * @inheritsDoc
            +259              */
            +260             getContour:function (/*iSize*/) {
            +261                 var contour = [];
            +262 
            +263                 for (var i = 0; i < this.points.length; i++) {
            +264                     contour.push(this.points[i]);
            +265                 }
            +266 
            +267                 return contour;
            +268             },
            +269             updatePath:function (point) {
            +270 
            +271                 if (point) {
            +272                     if (point === this.points[0]) {
            +273                         this.points[1].y = point.y;
            +274                         this.points[3].x = point.x;
            +275                     } else if (point === this.points[1]) {
            +276                         this.points[0].y = point.y;
            +277                         this.points[2].x = point.x;
            +278                     } else if (point === this.points[2]) {
            +279                         this.points[3].y = point.y;
            +280                         this.points[1].x = point.x;
            +281                     } else if (point === this.points[3]) {
            +282                         this.points[0].x = point.x;
            +283                         this.points[2].y = point.y;
            +284                     }
            +285                     this.points[4].x = this.points[0].x;
            +286                     this.points[4].y = this.points[0].y;
            +287                 }
            +288 
            +289                 this.bbox.setEmpty();
            +290 
            +291                 for (var i = 0; i < 4; i++) {
            +292                     this.bbox.union(this.points[i].x, this.points[i].y);
            +293                 }
            +294 
            +295                 this.length = 2 * this.bbox.width + 2 * this.bbox.height;
            +296 
            +297                 this.points[0].x = this.bbox.x;
            +298                 this.points[0].y = this.bbox.y;
            +299 
            +300                 this.points[1].x = this.bbox.x + this.bbox.width;
            +301                 this.points[1].y = this.bbox.y;
            +302 
            +303                 this.points[2].x = this.bbox.x + this.bbox.width;
            +304                 this.points[2].y = this.bbox.y + this.bbox.height;
            +305 
            +306                 this.points[3].x = this.bbox.x;
            +307                 this.points[3].y = this.bbox.y + this.bbox.height;
            +308 
            +309                 this.points[4].x = this.bbox.x;
            +310                 this.points[4].y = this.bbox.y;
            +311 
            +312                 return this;
            +313             },
            +314 
            +315             getPositionFromLength:function (iLength) {
            +316                 return this.getPosition(iLength / (this.bbox.width * 2 + this.bbox.height * 2));
            +317             }
            +318         }
            +319     }
            +320 });
            +321 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_SVGPath.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_SVGPath.js.html new file mode 100644 index 0000000..e385380 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_PathUtil_SVGPath.js.html @@ -0,0 +1,493 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * <p>
            +  5      * This class is a SVG Path parser.
            +  6      * By calling the method parsePath( svgpath ) an instance of CAAT.PathUtil.Path will be built by parsing
            +  7      * its contents.
            +  8      *
            +  9      * <p>
            + 10      * See <a href="../../demos/demo32/svgpath.html">demo32</a>
            + 11      *
            + 12      * @name SVGPath
            + 13      * @memberOf CAAT.PathUtil
            + 14      * @constructor
            + 15      */
            + 16 
            + 17     defines:"CAAT.PathUtil.SVGPath",
            + 18     depends:[
            + 19         "CAAT.PathUtil.Path"
            + 20     ],
            + 21     extendsWith:function () {
            + 22 
            + 23         var OK = 0;
            + 24         var EOF = 1;
            + 25         var NAN = 2;
            + 26 
            + 27         function error(pathInfo, c) {
            + 28             var cpos = c;
            + 29             if (cpos < 0) {
            + 30                 cpos = 0;
            + 31             }
            + 32             console.log("parse error near ..." + pathInfo.substr(cpos, 20));
            + 33         }
            + 34 
            + 35         return {
            + 36 
            + 37             /**
            + 38              * @lends CAAT.PathUtil.SVGPath.prototype
            + 39              */
            + 40 
            + 41 
            + 42             __init:function () {
            + 43 
            + 44             },
            + 45 
            + 46             /**
            + 47              * @private
            + 48              */
            + 49             c:0,
            + 50 
            + 51             /**
            + 52              * @private
            + 53              */
            + 54             bezierInfo:null,
            + 55 
            + 56             __skipBlank:function (pathInfo, c) {
            + 57                 var p = pathInfo.charAt(c);
            + 58                 while (c < pathInfo.length && (p == ' ' || p == '\n' || p == '\t' || p == ',')) {
            + 59                     ++c;
            + 60                     var p = pathInfo.charAt(c);
            + 61                 }
            + 62 
            + 63                 return c;
            + 64             },
            + 65 
            + 66             __maybeNumber:function (pathInfo, c) {
            + 67 
            + 68                 if (c < pathInfo.length - 2) {
            + 69 
            + 70                     var p = pathInfo.charAt(c);
            + 71                     var p1 = pathInfo.charAt(c + 1);
            + 72 
            + 73                     return  p == '-' ||
            + 74                         this.__isDigit(p) ||
            + 75                         (p === "." && this.__isDigit(p1) );
            + 76                 }
            + 77 
            + 78                 return false;
            + 79             },
            + 80 
            + 81             __isDigit:function (c) {
            + 82                 return c >= "0" && c <= "9";
            + 83             },
            + 84 
            + 85 
            + 86             __getNumber:function (pathInfo, c, v, error) {
            + 87                 c = this.__skipBlank(pathInfo, c);
            + 88                 if (c < pathInfo.length) {
            + 89                     var nc = this.__findNumber(pathInfo, c);
            + 90                     if (nc !== -1) {
            + 91                         v.push(parseFloat(pathInfo.substr(c, nc)));
            + 92                         c = this.__skipBlank(pathInfo, nc);
            + 93                         error.pos = c;
            + 94                         error.result = OK;
            + 95                         return;
            + 96                     } else {
            + 97                         error.result = NAN;
            + 98                         return;
            + 99                     }
            +100                 }
            +101 
            +102                 error.result = EOF;
            +103             },
            +104 
            +105             ____getNumbers:function (pathInfo, c, v, n, error) {
            +106 
            +107                 for (var i = 0; i < n; i++) {
            +108                     this.__getNumber(pathInfo, c, v, error);
            +109                     if (error.result != OK) {
            +110                         break;
            +111                     } else {
            +112                         c = error.pos;
            +113                     }
            +114                 }
            +115 
            +116                 return c;
            +117             },
            +118 
            +119 
            +120             __findNumber:function (pathInfo, c) {
            +121 
            +122                 var p;
            +123 
            +124                 if ((p = pathInfo.charAt(c)) == '-') {
            +125                     ++c;
            +126                 }
            +127 
            +128                 if (!this.__isDigit((p = pathInfo.charAt(c)))) {
            +129                     if ((p = pathInfo.charAt(c)) != '.' || !this.__isDigit(pathInfo.charAt(c + 1))) {
            +130                         return -1;
            +131                     }
            +132                 }
            +133 
            +134                 while (this.__isDigit((p = pathInfo.charAt(c)))) {
            +135                     ++c;
            +136                 }
            +137 
            +138                 if ((p = pathInfo.charAt(c)) == '.') {
            +139                     ++c;
            +140                     if (!this.__isDigit((p = pathInfo.charAt(c)))) {   // asumo un numero [d+]\. como valido.
            +141                         return c;
            +142                     }
            +143                     while (this.__isDigit((p = pathInfo.charAt(c)))) {
            +144                         ++c;
            +145                     }
            +146                 }
            +147 
            +148                 return c;
            +149             },
            +150 
            +151             __parseMoveTo:function (pathInfo, c, absolute, path, error) {
            +152 
            +153                 var numbers = [];
            +154 
            +155                 c = this.____getNumbers(pathInfo, c, numbers, 2, error);
            +156 
            +157                 if (error.result === OK) {
            +158                     if (!absolute) {
            +159                         numbers[0] += path.trackPathX;
            +160                         numbers[1] += path.trackPathY;
            +161                     }
            +162                     path.beginPath(numbers[0], numbers[1]);
            +163                 } else {
            +164                     return;
            +165                 }
            +166 
            +167                 if (this.__maybeNumber(pathInfo, c)) {
            +168                     c = this.parseLine(pathInfo, c, absolute, path, error);
            +169                 }
            +170 
            +171                 error.pos = c;
            +172             },
            +173 
            +174             __parseLine:function (pathInfo, c, absolute, path, error) {
            +175 
            +176                 var numbers = [];
            +177 
            +178                 do {
            +179                     c = this.____getNumbers(pathInfo, c, numbers, 2, error);
            +180                     if (!absolute) {
            +181                         numbers[0] += path.trackPathX;
            +182                         numbers[1] += path.trackPathY;
            +183                     }
            +184                     path.addLineTo(numbers[0], numbers[1]);
            +185 
            +186                 } while (this.__maybeNumber(pathInfo, c));
            +187 
            +188                 error.pos = c;
            +189             },
            +190 
            +191 
            +192             __parseLineH:function (pathInfo, c, absolute, path, error) {
            +193 
            +194                 var numbers = [];
            +195 
            +196                 do {
            +197                     c = this.____getNumbers(pathInfo, c, numbers, 1, error);
            +198 
            +199                     if (!absolute) {
            +200                         numbers[0] += path.trackPathX;
            +201                     }
            +202                     numbers[1].push(path.trackPathY);
            +203 
            +204                     path.addLineTo(numbers[0], numbers[1]);
            +205 
            +206                 } while (this.__maybeNumber(pathInfo, c));
            +207 
            +208                 error.pos = c;
            +209             },
            +210 
            +211             __parseLineV:function (pathInfo, c, absolute, path, error) {
            +212 
            +213                 var numbers = [ path.trackPathX ];
            +214 
            +215                 do {
            +216                     c = this.____getNumbers(pathInfo, c, numbers, 1, error);
            +217 
            +218                     if (!absolute) {
            +219                         numbers[1] += path.trackPathY;
            +220                     }
            +221 
            +222                     path.addLineTo(numbers[0], numbers[1]);
            +223 
            +224                 } while (this.__maybeNumber(pathInfo, c));
            +225 
            +226                 error.pos = c;
            +227             },
            +228 
            +229             __parseCubic:function (pathInfo, c, absolute, path, error) {
            +230 
            +231                 var v = [];
            +232 
            +233                 do {
            +234                     c = this.____getNumbers(pathInfo, c, v, 6, error);
            +235                     if (error.result === OK) {
            +236                         if (!absolute) {
            +237                             v[0] += path.trackPathX;
            +238                             v[1] += path.trackPathY;
            +239                             v[2] += path.trackPathX;
            +240                             v[3] += path.trackPathY;
            +241                             v[4] += path.trackPathX;
            +242                             v[5] += path.trackPathY;
            +243                         }
            +244 
            +245                         path.addCubicTo(v[0], v[1], v[2], v[3], v[4], v[5]);
            +246 
            +247 
            +248                         v.shift();
            +249                         v.shift();
            +250                         this.bezierInfo = v;
            +251 
            +252                     } else {
            +253                         return;
            +254                     }
            +255                 } while (this.__maybeNumber(pathInfo, c));
            +256 
            +257                 error.pos = c;
            +258             },
            +259 
            +260             __parseCubicS:function (pathInfo, c, absolute, path, error) {
            +261 
            +262                 var v = [];
            +263 
            +264                 do {
            +265                     c = this.____getNumbers(pathInfo, c, v, 4, error);
            +266                     if (error.result == OK) {
            +267                         if (!absolute) {
            +268 
            +269                             v[0] += path.trackPathX;
            +270                             v[1] += path.trackPathY;
            +271                             v[2] += path.trackPathX;
            +272                             v[3] += path.trackPathY;
            +273                         }
            +274 
            +275                         var x, y;
            +276 
            +277                         x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]);
            +278                         y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]);
            +279 
            +280                         path.addCubicTo(x, y, v[0], v[1], v[2], v[3]);
            +281 
            +282                         this.bezierInfo = v;
            +283 
            +284                     } else {
            +285                         return;
            +286                     }
            +287                 } while (this.__maybeNumber(c));
            +288 
            +289                 error.pos = c;
            +290             },
            +291 
            +292             __parseQuadricS:function (pathInfo, c, absolute, path, error) {
            +293 
            +294                 var v = [];
            +295 
            +296                 do {
            +297                     c = this.____getNumbers(pathInfo, c, v, 4, error);
            +298                     if (error.result === OK) {
            +299 
            +300                         if (!absolute) {
            +301 
            +302                             v[0] += path.trackPathX;
            +303                             v[1] += path.trackPathY;
            +304                         }
            +305 
            +306                         var x, y;
            +307 
            +308                         x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]);
            +309                         y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]);
            +310 
            +311                         path.addQuadricTo(x, y, v[0], v[1]);
            +312 
            +313                         this.bezierInfo = [];
            +314                         bezierInfo.push(x);
            +315                         bezierInfo.push(y);
            +316                         bezierInfo.push(v[0]);
            +317                         bezierInfo.push(v[1]);
            +318 
            +319 
            +320                     } else {
            +321                         return;
            +322                     }
            +323                 } while (this.__maybeNumber(c));
            +324 
            +325                 error.pos = c;
            +326             },
            +327 
            +328 
            +329             __parseQuadric:function (pathInfo, c, absolute, path, error) {
            +330 
            +331                 var v = [];
            +332 
            +333                 do {
            +334                     c = this.____getNumbers(pathInfo, c, v, 4, error);
            +335                     if (error.result === OK) {
            +336                         if (!absolute) {
            +337 
            +338                             v[0] += path.trackPathX;
            +339                             v[1] += path.trackPathY;
            +340                             v[2] += path.trackPathX;
            +341                             v[3] += path.trackPathY;
            +342                         }
            +343 
            +344                         path.addQuadricTo(v[0], v[1], v[2], v[3]);
            +345 
            +346                         this.bezierInfo = v;
            +347                     } else {
            +348                         return;
            +349                     }
            +350                 } while (this.__maybeNumber(c));
            +351 
            +352                 error.pos = c;
            +353             },
            +354 
            +355             __parseClosePath:function (pathInfo, c, path, error) {
            +356 
            +357                 path.closePath();
            +358                 error.pos= c;
            +359 
            +360             },
            +361 
            +362             /**
            +363              * This method will create a CAAT.PathUtil.Path object with as many contours as needed.
            +364              * @param pathInfo {string} a SVG path
            +365              * @return Array.<CAAT.PathUtil.Path>
            +366              */
            +367             parsePath:function (pathInfo) {
            +368 
            +369                 this.c = 0;
            +370                 this.contours= [];
            +371 
            +372                 var path = new CAAT.PathUtil.Path();
            +373                 this.contours.push( path );
            +374 
            +375                 this.c = this.__skipBlank(pathInfo, this.c);
            +376                 if (this.c === pathInfo.length) {
            +377                     return path;
            +378                 }
            +379 
            +380                 var ret = {
            +381                     pos:0,
            +382                     result:0
            +383                 }
            +384 
            +385                 while (this.c != pathInfo.length) {
            +386                     var segment = pathInfo.charAt(this.c);
            +387                     switch (segment) {
            +388                         case 'm':
            +389                             this.__parseMoveTo(pathInfo, this.c + 1, false, path, ret);
            +390                             break;
            +391                         case 'M':
            +392                             this.__parseMoveTo(pathInfo, this.c + 1, true, path, ret);
            +393                             break;
            +394                         case 'c':
            +395                             this.__parseCubic(pathInfo, this.c + 1, false, path, ret);
            +396                             break;
            +397                         case 'C':
            +398                             this.__parseCubic(pathInfo, this.c + 1, true, path, ret);
            +399                             break;
            +400                         case 's':
            +401                             this.__parseCubicS(pathInfo, this.c + 1, false, path, ret);
            +402                             break;
            +403                         case 'S':
            +404                             this.__parseCubicS(pathInfo, this.c + 1, true, path, ret);
            +405                             break;
            +406                         case 'q':
            +407                             this.__parseQuadric(pathInfo, this.c + 1, false, path, ret);
            +408                             break;
            +409                         case 'Q':
            +410                             this.__parseQuadricS(pathInfo, this.c + 1, true, path, ret);
            +411                             break;
            +412                         case 't':
            +413                             this.__parseQuadricS(pathInfo, this.c + 1, false, path, ret);
            +414                             break;
            +415                         case 'T':
            +416                             this.__parseQuadric(pathInfo, this.c + 1, true, path, ret);
            +417                             break;
            +418                         case 'l':
            +419                             this.__parseLine(pathInfo, this.c + 1, false, path, ret);
            +420                             break;
            +421                         case 'L':
            +422                             this.__parseLine(pathInfo, this.c + 1, true, path, ret);
            +423                             break;
            +424                         case 'h':
            +425                             this.__parseLineH(pathInfo, this.c + 1, false, path, ret);
            +426                             break;
            +427                         case 'H':
            +428                             this.__parseLineH(pathInfo, this.c + 1, true, path, ret);
            +429                             break;
            +430                         case 'v':
            +431                             this.__parseLineV(pathInfo, this.c + 1, false, path, ret);
            +432                             break;
            +433                         case 'V':
            +434                             this.__parseLineV(pathInfo, this.c + 1, true, path, ret);
            +435                             break;
            +436                         case 'z':
            +437                         case 'Z':
            +438                             this.__parseClosePath(pathInfo, this.c + 1, path, ret);
            +439                             path= new CAAT.PathUtil.Path();
            +440                             this.contours.push( path );
            +441                             break;
            +442                         case 0:
            +443                             break;
            +444                         default:
            +445                             error(pathInfo, this.c);
            +446                             break;
            +447                     }
            +448 
            +449                     if (ret.result != OK) {
            +450                         error(pathInfo, this.c);
            +451                         break;
            +452                     } else {
            +453                         this.c = ret.pos;
            +454                     }
            +455 
            +456                 } // while
            +457 
            +458                 var count= 0;
            +459                 var fpath= null;
            +460                 for( var i=0; i<this.contours.length; i++ ) {
            +461                     if ( !this.contours[i].isEmpty() ) {
            +462                         fpath= this.contours[i];
            +463                         if ( !fpath.closed ) {
            +464                             fpath.endPath();
            +465                         }
            +466                         count++;
            +467                     }
            +468                 }
            +469 
            +470                 if ( count===1 ) {
            +471                     return fpath;
            +472                 }
            +473 
            +474                 path= new CAAT.PathUtil.Path();
            +475                 for( var i=0; i<this.contours.length; i++ ) {
            +476                     if ( !this.contours[i].isEmpty() ) {
            +477                         path.addSegment( this.contours[i] );
            +478                     }
            +479                 }
            +480                 return path.endPath();
            +481 
            +482             }
            +483 
            +484         }
            +485     }
            +486 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_ColorProgram.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_ColorProgram.js.html new file mode 100644 index 0000000..a56daec --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_ColorProgram.js.html @@ -0,0 +1,121 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name ColorProgram
            +  5      * @memberOf CAAT.WebGL
            +  6      * @extends CAAT.WebGL.Program
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.WebGL.ColorProgram",
            + 11     aliases : ["CAAT.ColorProgram"],
            + 12     extendsClass : "CAAT.WebGL.Program",
            + 13     depends : [
            + 14         "CAAT.WebGL.Program"
            + 15     ],
            + 16     extendsWith : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.WebGL.ColorProgram.prototype
            + 20          */
            + 21 
            + 22 
            + 23         __init : function(gl) {
            + 24             this.__super(gl);
            + 25             return this;
            + 26         },
            + 27 
            + 28         /**
            + 29          * int32 Array for color Buffer
            + 30          */
            + 31         colorBuffer:    null,
            + 32 
            + 33         /**
            + 34          * GLBuffer for vertex buffer.
            + 35          */
            + 36         vertexPositionBuffer:   null,
            + 37 
            + 38         /**
            + 39          * Float32 Array for vertex buffer.
            + 40          */
            + 41         vertexPositionArray:    null,
            + 42 
            + 43         getFragmentShader : function() {
            + 44             return this.getShader(this.gl, "x-shader/x-fragment",
            + 45                     "#ifdef GL_ES \n"+
            + 46                     "precision highp float; \n"+
            + 47                     "#endif \n"+
            + 48 
            + 49                     "varying vec4 color; \n"+
            + 50                             
            + 51                     "void main(void) { \n"+
            + 52                     "  gl_FragColor = color;\n"+
            + 53                     "}\n"
            + 54                     );
            + 55 
            + 56         },
            + 57         getVertexShader : function() {
            + 58             return this.getShader(this.gl, "x-shader/x-vertex",
            + 59                     "attribute vec3 aVertexPosition; \n"+
            + 60                     "attribute vec4 aColor; \n"+
            + 61                     "uniform mat4 uPMatrix; \n"+
            + 62                     "varying vec4 color; \n"+
            + 63 
            + 64                     "void main(void) { \n"+
            + 65                     "gl_Position = uPMatrix * vec4(aVertexPosition, 1.0); \n"+
            + 66                     "color= aColor; \n"+
            + 67                     "}\n"
            + 68                     );
            + 69         },
            + 70         initialize : function() {
            + 71             this.shaderProgram.vertexPositionAttribute =
            + 72                     this.gl.getAttribLocation(this.shaderProgram, "aVertexPosition");
            + 73             this.gl.enableVertexAttribArray(
            + 74                     this.shaderProgram.vertexPositionAttribute);
            + 75 
            + 76             this.shaderProgram.vertexColorAttribute =
            + 77                     this.gl.getAttribLocation(this.shaderProgram, "aColor");
            + 78             this.gl.enableVertexAttribArray(
            + 79                     this.shaderProgram.vertexColorAttribute);
            + 80 
            + 81             this.shaderProgram.pMatrixUniform =
            + 82                     this.gl.getUniformLocation(this.shaderProgram, "uPMatrix");
            + 83 
            + 84             this.useProgram();
            + 85 
            + 86             this.colorBuffer= this.gl.createBuffer();
            + 87             this.setColor( [1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1] );
            + 88 
            + 89             var maxTris=512, i;
            + 90             /// set vertex data
            + 91             this.vertexPositionBuffer = this.gl.createBuffer();
            + 92             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexPositionBuffer );
            + 93             this.vertexPositionArray= new Float32Array(maxTris*12);
            + 94             this.gl.bufferData(this.gl.ARRAY_BUFFER, this.vertexPositionArray, this.gl.DYNAMIC_DRAW);
            + 95             this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute, 3, this.gl.FLOAT, false, 0, 0);
            + 96 
            + 97             return CAAT.ColorProgram.superclass.initialize.call(this);
            + 98         },
            + 99         setColor : function( colorArray ) {
            +100             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.colorBuffer );
            +101             this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array(colorArray), this.gl.STATIC_DRAW);
            +102 
            +103             this.gl.vertexAttribPointer(
            +104                     this.shaderProgram.vertexColorAttribute,
            +105                     this.colorBuffer,
            +106                     this.gl.FLOAT,
            +107                     false,
            +108                     0,
            +109                     0);
            +110         }
            +111     }
            +112 
            +113 });
            +114 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_Program.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_Program.js.html new file mode 100644 index 0000000..b454061 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_Program.js.html @@ -0,0 +1,144 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  */
            +  4 
            +  5 CAAT.Module( {
            +  6 
            +  7 
            +  8     /**
            +  9      * @name WebGL
            + 10      * @memberOf CAAT
            + 11      * @namespace
            + 12      */
            + 13 
            + 14     /**
            + 15      * @name Program
            + 16      * @memberOf CAAT.WebGL
            + 17      * @constructor
            + 18      */
            + 19 
            + 20 
            + 21     defines : "CAAT.WebGL.Program",
            + 22     extendsWith : {
            + 23 
            + 24         /**
            + 25          * @lends CAAT.WebGL.Program.prototype
            + 26          */
            + 27 
            + 28         __init : function(gl) {
            + 29             this.gl= gl;
            + 30             return this;
            + 31         },
            + 32 
            + 33         /**
            + 34          *
            + 35          */
            + 36         shaderProgram:  null,
            + 37 
            + 38         /**
            + 39          * Canvas 3D context.
            + 40          */
            + 41         gl:             null,
            + 42 
            + 43         /**
            + 44          * Set fragment shader's alpha composite value.
            + 45          * @param alpha {number} float value 0..1.
            + 46          */
            + 47         setAlpha : function( alpha ) {
            + 48 
            + 49         },
            + 50         getShader : function (gl,type,str) {
            + 51             var shader;
            + 52             if (type === "x-shader/x-fragment") {
            + 53                 shader = gl.createShader(gl.FRAGMENT_SHADER);
            + 54             } else if (type === "x-shader/x-vertex") {
            + 55                 shader = gl.createShader(gl.VERTEX_SHADER);
            + 56             } else {
            + 57                 return null;
            + 58             }
            + 59 
            + 60             gl.shaderSource(shader, str);
            + 61             gl.compileShader(shader);
            + 62 
            + 63             if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
            + 64                 alert(gl.getShaderInfoLog(shader));
            + 65                 return null;
            + 66             }
            + 67 
            + 68             return shader;
            + 69 
            + 70         },
            + 71         getDomShader : function(gl, id) {
            + 72             var shaderScript = document.getElementById(id);
            + 73             if (!shaderScript) {
            + 74                 return null;
            + 75             }
            + 76 
            + 77             var str = "";
            + 78             var k = shaderScript.firstChild;
            + 79             while (k) {
            + 80                 if (k.nodeType === 3) {
            + 81                     str += k.textContent;
            + 82                 }
            + 83                 k = k.nextSibling;
            + 84             }
            + 85 
            + 86             var shader;
            + 87             if (shaderScript.type === "x-shader/x-fragment") {
            + 88                 shader = gl.createShader(gl.FRAGMENT_SHADER);
            + 89             } else if (shaderScript.type === "x-shader/x-vertex") {
            + 90                 shader = gl.createShader(gl.VERTEX_SHADER);
            + 91             } else {
            + 92                 return null;
            + 93             }
            + 94 
            + 95             gl.shaderSource(shader, str);
            + 96             gl.compileShader(shader);
            + 97 
            + 98             if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
            + 99                 alert(gl.getShaderInfoLog(shader));
            +100                 return null;
            +101             }
            +102 
            +103             return shader;
            +104         },
            +105         initialize : function() {
            +106             return this;
            +107         },
            +108         getFragmentShader : function() {
            +109             return null;
            +110         },
            +111         getVertexShader : function() {
            +112             return null;
            +113         },
            +114         create : function() {
            +115             var gl= this.gl;
            +116 
            +117             this.shaderProgram = gl.createProgram();
            +118             gl.attachShader(this.shaderProgram, this.getVertexShader());
            +119             gl.attachShader(this.shaderProgram, this.getFragmentShader());
            +120             gl.linkProgram(this.shaderProgram);
            +121             gl.useProgram(this.shaderProgram);
            +122             return this;
            +123         },
            +124         setMatrixUniform : function( caatMatrix4 ) {
            +125             this.gl.uniformMatrix4fv(
            +126                     this.shaderProgram.pMatrixUniform,
            +127                     false,
            +128                     new Float32Array(caatMatrix4.flatten()));
            +129 
            +130         },
            +131         useProgram : function() {
            +132             this.gl.useProgram(this.shaderProgram);
            +133             return this;
            +134         }
            +135     }
            +136 });
            +137 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_TextureProgram.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_TextureProgram.js.html new file mode 100644 index 0000000..d1fed22 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_WebGL_TextureProgram.js.html @@ -0,0 +1,309 @@ +
              1 CAAT.Module( {
            +  2 
            +  3     /**
            +  4      * @name TextureProgram
            +  5      * @memberOf CAAT.WebGL
            +  6      * @extends CAAT.WebGL.Program
            +  7      * @constructor
            +  8      */
            +  9 
            + 10     defines : "CAAT.WebGL.TextureProgram",
            + 11     aliases : ["CAAT.TextureProgram"],
            + 12     extendsClass : "CAAT.WebGL.Program",
            + 13     depends : [
            + 14         "CAAT.WebGL.Program"
            + 15     ],
            + 16     extendsWith : {
            + 17 
            + 18         /**
            + 19          * @lends CAAT.WebGL.TextureProgram.prototype
            + 20          */
            + 21 
            + 22         __init : function(gl) {
            + 23             this.__super(gl);
            + 24             return this;
            + 25         },
            + 26 
            + 27         /**
            + 28          * VertextBuffer GLBuffer
            + 29          */
            + 30         vertexPositionBuffer:   null,
            + 31 
            + 32         /**
            + 33          * VertextBuffer Float32 Array
            + 34          */
            + 35         vertexPositionArray:    null,
            + 36 
            + 37         /**
            + 38          * UVBuffer GLBuffer
            + 39          */
            + 40         vertexUVBuffer:         null,
            + 41 
            + 42         /**
            + 43          * VertexBuffer Float32 Array
            + 44          */
            + 45         vertexUVArray:          null,
            + 46 
            + 47         /**
            + 48          * VertexIndex GLBuffer.
            + 49          */
            + 50         vertexIndexBuffer:      null,
            + 51 
            + 52         /**
            + 53          * Lines GLBuffer
            + 54          */
            + 55         linesBuffer:            null,
            + 56 
            + 57         /**
            + 58          *
            + 59          */
            + 60         prevAlpha:              -1,
            + 61 
            + 62         /**
            + 63          *
            + 64          */
            + 65         prevR:                  -1,
            + 66 
            + 67         /**
            + 68          *
            + 69          */
            + 70         prevG:                  -1,
            + 71 
            + 72         /**
            + 73          *
            + 74          */
            + 75         prevB:                  -1,
            + 76 
            + 77         /**
            + 78          *
            + 79          */
            + 80         prevA:                  -1,
            + 81 
            + 82         /**
            + 83          *
            + 84          */
            + 85         prevTexture:            null,
            + 86 
            + 87         getFragmentShader : function() {
            + 88             return this.getShader( this.gl, "x-shader/x-fragment",
            + 89                     "#ifdef GL_ES \n"+
            + 90                     "precision highp float; \n"+
            + 91                     "#endif \n"+
            + 92 
            + 93                     "varying vec2 vTextureCoord; \n"+
            + 94                     "uniform sampler2D uSampler; \n"+
            + 95                     "uniform float alpha; \n"+
            + 96                     "uniform bool uUseColor;\n"+
            + 97                     "uniform vec4 uColor;\n"+
            + 98 
            + 99                     "void main(void) { \n"+
            +100 
            +101                     "if ( uUseColor ) {\n"+
            +102                     "  gl_FragColor= vec4(uColor.r*alpha, uColor.g*alpha, uColor.b*alpha, uColor.a*alpha);\n"+
            +103                     "} else { \n"+
            +104                     "  vec4 textureColor= texture2D(uSampler, vec2(vTextureCoord)); \n"+
            +105 // Fix FF   "  gl_FragColor = vec4(textureColor.rgb, textureColor.a * alpha); \n"+
            +106                     "  gl_FragColor = vec4(textureColor.r*alpha, textureColor.g*alpha, textureColor.b*alpha, textureColor.a * alpha ); \n"+
            +107                     "}\n"+
            +108 
            +109                     "}\n"
            +110                     );
            +111         },
            +112         getVertexShader : function() {
            +113             return this.getShader(this.gl, "x-shader/x-vertex",
            +114                     "attribute vec3 aVertexPosition; \n"+
            +115                     "attribute vec2 aTextureCoord; \n"+
            +116 
            +117                     "uniform mat4 uPMatrix; \n"+
            +118 
            +119                     "varying vec2 vTextureCoord; \n"+
            +120 
            +121                     "void main(void) { \n"+
            +122                     "gl_Position = uPMatrix * vec4(aVertexPosition, 1.0); \n"+
            +123                     "vTextureCoord = aTextureCoord;\n"+
            +124                     "}\n"
            +125                     );
            +126         },
            +127         useProgram : function() {
            +128             CAAT.TextureProgram.superclass.useProgram.call(this);
            +129 
            +130             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexPositionBuffer );
            +131             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexUVBuffer);
            +132             this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.vertexIndexBuffer);
            +133         },
            +134         initialize : function() {
            +135 
            +136             var i;
            +137 
            +138             this.linesBuffer= this.gl.createBuffer();
            +139             this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.linesBuffer );
            +140             var arr= [];
            +141             for( i=0; i<1024; i++ ) {
            +142                 arr[i]= i;
            +143             }
            +144             this.linesBufferArray= new Uint16Array(arr);
            +145             this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, this.linesBufferArray, this.gl.DYNAMIC_DRAW);
            +146 
            +147 
            +148             this.shaderProgram.vertexPositionAttribute =
            +149                     this.gl.getAttribLocation(this.shaderProgram, "aVertexPosition");
            +150             this.gl.enableVertexAttribArray(
            +151                     this.shaderProgram.vertexPositionAttribute);
            +152 
            +153             this.shaderProgram.textureCoordAttribute =
            +154                     this.gl.getAttribLocation(this.shaderProgram, "aTextureCoord");
            +155             this.gl.enableVertexAttribArray(
            +156                     this.shaderProgram.textureCoordAttribute);
            +157 
            +158             this.shaderProgram.pMatrixUniform =
            +159                     this.gl.getUniformLocation(this.shaderProgram, "uPMatrix");
            +160             this.shaderProgram.samplerUniform =
            +161                     this.gl.getUniformLocation(this.shaderProgram, "uSampler");
            +162             this.shaderProgram.alphaUniform   =
            +163                     this.gl.getUniformLocation(this.shaderProgram, "alpha");
            +164             this.shaderProgram.useColor =
            +165                     this.gl.getUniformLocation(this.shaderProgram, "uUseColor");
            +166             this.shaderProgram.color =
            +167                     this.gl.getUniformLocation(this.shaderProgram, "uColor");
            +168 
            +169             this.setAlpha(1);
            +170             this.setUseColor(false);
            +171 
            +172             var maxTris=4096;
            +173             /// set vertex data
            +174             this.vertexPositionBuffer = this.gl.createBuffer();
            +175             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexPositionBuffer );
            +176             this.vertexPositionArray= new Float32Array(maxTris*12);
            +177             this.gl.bufferData(this.gl.ARRAY_BUFFER, this.vertexPositionArray, this.gl.DYNAMIC_DRAW);
            +178             this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute, 3, this.gl.FLOAT, false, 0, 0);
            +179 
            +180             // uv info
            +181             this.vertexUVBuffer= this.gl.createBuffer();
            +182             this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexUVBuffer);
            +183             this.vertexUVArray= new Float32Array(maxTris*8);
            +184             this.gl.bufferData(this.gl.ARRAY_BUFFER, this.vertexUVArray, this.gl.DYNAMIC_DRAW);
            +185             this.gl.vertexAttribPointer(this.shaderProgram.textureCoordAttribute, 2, this.gl.FLOAT, false, 0, 0);
            +186 
            +187             // vertex index
            +188             this.vertexIndexBuffer = this.gl.createBuffer();
            +189             this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, this.vertexIndexBuffer);            
            +190             var vertexIndex = [];
            +191             for( i=0; i<maxTris; i++ ) {
            +192                 vertexIndex.push(0 + i*4); vertexIndex.push(1 + i*4); vertexIndex.push(2 + i*4);
            +193                 vertexIndex.push(0 + i*4); vertexIndex.push(2 + i*4); vertexIndex.push(3 + i*4);
            +194             }
            +195             this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(vertexIndex), this.gl.DYNAMIC_DRAW);
            +196 
            +197             return CAAT.TextureProgram.superclass.initialize.call(this);
            +198         },
            +199         setUseColor : function( use,r,g,b,a ) {
            +200             this.gl.uniform1i(this.shaderProgram.useColor, use?1:0);
            +201             if ( use ) {
            +202                 if ( this.prevA!==a || this.prevR!==r || this.prevG!==g || this.prevB!==b ) {
            +203                     this.gl.uniform4f(this.shaderProgram.color, r,g,b,a );
            +204                     this.prevA= a;
            +205                     this.prevR= r;
            +206                     this.prevG= g;
            +207                     this.prevB= b;
            +208                 }
            +209             }
            +210         },
            +211         setTexture : function( glTexture ) {
            +212             if ( this.prevTexture!==glTexture ) {
            +213                 var gl= this.gl;
            +214 
            +215                 gl.activeTexture(gl.TEXTURE0);
            +216                 gl.bindTexture(gl.TEXTURE_2D, glTexture);
            +217                 gl.uniform1i(this.shaderProgram.samplerUniform, 0);
            +218 
            +219                 this.prevTexture= glTexture;
            +220             }
            +221 
            +222             return this;
            +223         },
            +224         updateVertexBuffer : function(vertexArray) {
            +225             var gl= this.gl;
            +226             gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexPositionBuffer );
            +227             gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertexArray);
            +228             return this;
            +229         },
            +230         updateUVBuffer : function(uvArray) {
            +231             var gl= this.gl;
            +232             gl.bindBuffer(gl.ARRAY_BUFFER, this.vertexUVBuffer );
            +233             gl.bufferSubData(gl.ARRAY_BUFFER, 0, uvArray);
            +234             return this;
            +235         },
            +236         setAlpha : function(alpha) {
            +237             if ( this.prevAlpha !== alpha ) {
            +238                 this.gl.uniform1f(
            +239                     this.shaderProgram.alphaUniform, alpha);
            +240                 this.prevAlpha= alpha;
            +241             }
            +242             return this;
            +243         },
            +244         /**
            +245          *
            +246          * @param lines_data {Float32Array} array of number with x,y,z coords for each line point.
            +247          * @param size {number} number of lines to draw.
            +248          * @param r
            +249          * @param g
            +250          * @param b
            +251          * @param a
            +252          * @param lineWidth {number} drawing line size.
            +253          */
            +254         drawLines : function( lines_data, size, r,g,b,a, lineWidth ) {
            +255             var gl= this.gl;
            +256 
            +257             this.setAlpha( a );
            +258 
            +259             gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.linesBuffer );
            +260             gl.lineWidth(lineWidth);
            +261 
            +262             this.updateVertexBuffer(lines_data);
            +263             this.setUseColor(true, r,g,b,1 );
            +264             gl.drawElements(gl.LINES, size, gl.UNSIGNED_SHORT, 0);
            +265 
            +266             /// restore
            +267             this.setAlpha( 1 );
            +268             this.setUseColor(false);
            +269             gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.vertexIndexBuffer);
            +270 
            +271         },
            +272         /**
            +273          * 
            +274          * @param polyline_data
            +275          * @param size
            +276          * @param r
            +277          * @param g
            +278          * @param b
            +279          * @param a
            +280          * @param lineWidth
            +281          */
            +282         drawPolylines : function( polyline_data, size, r,g,b,a, lineWidth ) {
            +283             var gl= this.gl;
            +284 
            +285             gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.linesBuffer );
            +286             gl.lineWidth(lineWidth);
            +287 
            +288             this.setAlpha(a);
            +289 
            +290             this.updateVertexBuffer(polyline_data);
            +291             this.setUseColor(true, r,g,b,1 );
            +292             gl.drawElements(gl.LINE_STRIP, size, gl.UNSIGNED_SHORT, 0);
            +293 
            +294             /// restore
            +295             this.setAlpha( 1 );
            +296             this.setUseColor(false);
            +297             gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this.vertexIndexBuffer);
            +298 
            +299         }
            +300     }
            +301 });
            +302 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_core_class.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_core_class.js.html new file mode 100644 index 0000000..9ec7d6e --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_core_class.js.html @@ -0,0 +1,228 @@ +
              1 
            +  2 extend = function (subc, superc) {
            +  3     var subcp = subc.prototype;
            +  4 
            +  5     // Class pattern.
            +  6     var CAATObject = function () {
            +  7     };
            +  8     CAATObject.prototype = superc.prototype;
            +  9 
            + 10     subc.prototype = new CAATObject();       // chain prototypes.
            + 11     subc.superclass = superc.prototype;
            + 12     subc.prototype.constructor = subc;
            + 13 
            + 14     // Reset constructor. See Object Oriented Javascript for an in-depth explanation of this.
            + 15     if (superc.prototype.constructor === Object.prototype.constructor) {
            + 16         superc.prototype.constructor = superc;
            + 17     }
            + 18 
            + 19     // los metodos de superc, que no esten en esta clase, crear un metodo que
            + 20     // llama al metodo de superc.
            + 21     for (var method in subcp) {
            + 22         if (subcp.hasOwnProperty(method)) {
            + 23             subc.prototype[method] = subcp[method];
            + 24 
            + 25             /**
            + 26              * Sintactic sugar to add a __super attribute on every overriden method.
            + 27              * Despite comvenient, it slows things down by 5fps.
            + 28              *
            + 29              * Uncomment at your own risk.
            + 30              *
            + 31              // tenemos en super un metodo con igual nombre.
            + 32              if ( superc.prototype[method]) {
            + 33             subc.prototype[method]= (function(fn, fnsuper) {
            + 34                 return function() {
            + 35                     var prevMethod= this.__super;
            + 36 
            + 37                     this.__super= fnsuper;
            + 38 
            + 39                     var retValue= fn.apply(
            + 40                             this,
            + 41                             Array.prototype.slice.call(arguments) );
            + 42 
            + 43                     this.__super= prevMethod;
            + 44 
            + 45                     return retValue;
            + 46                 };
            + 47             })(subc.prototype[method], superc.prototype[method]);
            + 48         }
            + 49              */
            + 50 
            + 51         }
            + 52     }
            + 53 };
            + 54 
            + 55 
            + 56 extendWith = function (base, subclass, with_object) {
            + 57     var CAATObject = function () {
            + 58     };
            + 59 
            + 60     CAATObject.prototype = base.prototype;
            + 61 
            + 62     subclass.prototype = new CAATObject();
            + 63     subclass.superclass = base.prototype;
            + 64     subclass.prototype.constructor = subclass;
            + 65 
            + 66     if (base.prototype.constructor === Object.prototype.constructor) {
            + 67         base.prototype.constructor = base;
            + 68     }
            + 69 
            + 70     if (with_object) {
            + 71         for (var method in with_object) {
            + 72             if (with_object.hasOwnProperty(method)) {
            + 73                 subclass.prototype[ method ] = with_object[method];
            + 74                 /*
            + 75                  if ( base.prototype[method]) {
            + 76                  subclass.prototype[method]= (function(fn, fnsuper) {
            + 77                  return function() {
            + 78                  var prevMethod= this.__super;
            + 79                  this.__super= fnsuper;
            + 80                  var retValue= fn.apply(this, arguments );
            + 81                  this.__super= prevMethod;
            + 82 
            + 83                  return retValue;
            + 84                  };
            + 85                  })(subclass.prototype[method], base.prototype[method]);
            + 86                  }
            + 87                  /**/
            + 88             }
            + 89         }
            + 90     }
            + 91 };
            + 92 
            + 93 
            + 94 
            + 95 function proxyFunction(object, method, preMethod, postMethod, errorMethod) {
            + 96 
            + 97     return function () {
            + 98 
            + 99         var args = Array.prototype.slice.call(arguments);
            +100 
            +101         // call pre-method hook if present.
            +102         if (preMethod) {
            +103             preMethod({
            +104                 object: object,
            +105                 method: method,
            +106                 arguments: args });
            +107         }
            +108 
            +109         var retValue = null;
            +110 
            +111         try {
            +112             // apply original object call with proxied object as
            +113             // function context.
            +114             retValue = object[method].apply(object, args);
            +115 
            +116             // everything went right on function call, the call
            +117             // post-method hook if present
            +118             if (postMethod) {
            +119                 /*var rr= */
            +120                 var ret2 = postMethod({
            +121                     object: object,
            +122                     method: method,
            +123                     arguments: args });
            +124 
            +125                 if (ret2) {
            +126                     retValue = ret2;
            +127                 }
            +128             }
            +129         } catch (e) {
            +130             // an exeception was thrown, call exception-method hook if
            +131             // present and return its result as execution result.
            +132             if (errorMethod) {
            +133                 retValue = errorMethod({
            +134                     object: object,
            +135                     method: method,
            +136                     arguments: args,
            +137                     exception: e});
            +138             } else {
            +139                 // since there's no error hook, just throw the exception
            +140                 throw e;
            +141             }
            +142         }
            +143 
            +144         // return original returned value to the caller.
            +145         return retValue;
            +146     };
            +147 
            +148 }
            +149 
            +150 function proxyAttribute( proxy, object, attribute, getter, setter) {
            +151 
            +152     proxy.__defineGetter__(attribute, function () {
            +153         if (getter) {
            +154             getter(object, attribute);
            +155         }
            +156         return object[attribute];
            +157     });
            +158     proxy.__defineSetter__(attribute, function (value) {
            +159         object[attribute] = value;
            +160         if (setter) {
            +161             setter(object, attribute, value);
            +162         }
            +163     });
            +164 }
            +165 
            +166 function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter) {
            +167 
            +168     /**
            +169      * If not a function then only non privitive objects can be proxied.
            +170      * If it is a previously created proxy, return the proxy itself.
            +171      */
            +172     if (typeof object !== 'object' || isArray(object) || isString(object) || object.$proxy) {
            +173         return object;
            +174     }
            +175 
            +176     var proxy = {};
            +177 
            +178     // hold the proxied object as member. Needed to assign proper
            +179     // context on proxy method call.
            +180     proxy.$proxy = true;
            +181     proxy.$proxy_delegate = object;
            +182 
            +183     // For every element in the object to be proxied
            +184     for (var method in object) {
            +185 
            +186         if (method === "constructor") {
            +187             continue;
            +188         }
            +189 
            +190         // only function members
            +191         if (typeof object[method] === 'function') {
            +192             proxy[method] = proxyFunction(object, method, preMethod, postMethod, errorMethod );
            +193         } else {
            +194             proxyAttribute(proxy, object, method, getter, setter);
            +195         }
            +196     }
            +197 
            +198     // return our newly created and populated with functions proxied object.
            +199     return proxy;
            +200 }
            +201 
            +202 
            +203 CAAT.Module({
            +204     defines : "CAAT.Core.Class",
            +205     extendsWith : function() {
            +206 
            +207         /**
            +208          * See LICENSE file.
            +209          *
            +210          * Extend a prototype with another to form a classical OOP inheritance procedure.
            +211          *
            +212          * @param subc {object} Prototype to define the base class
            +213          * @param superc {object} Prototype to be extended (derived class).
            +214          */
            +215 
            +216 
            +217         return {
            +218 
            +219         };
            +220     }
            +221 });
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_bezier.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_bezier.js.html new file mode 100644 index 0000000..c761831 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_bezier.js.html @@ -0,0 +1,267 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 
            +  6 CAAT.Module( {
            +  7 
            +  8     /**
            +  9      * @name Math
            + 10      * @memberOf CAAT
            + 11      * @namespace
            + 12      */
            + 13 
            + 14     /**
            + 15      * @name Bezier
            + 16      * @memberOf CAAT.Math
            + 17      * @extends CAAT.Math.Curve
            + 18      * @constructor
            + 19      */
            + 20 
            + 21     defines:    "CAAT.Math.Bezier",
            + 22     depends:    ["CAAT.Math.Curve"],
            + 23     extendsClass:    "CAAT.Math.Curve",
            + 24     aliases:    ["CAAT.Bezier"],
            + 25     extendsWith:    function() {
            + 26         return {
            + 27 
            + 28             /**
            + 29              * @lends CAAT.Math.Bezier.prototype
            + 30              */
            + 31 
            + 32             /**
            + 33              * This curbe is cubic or quadratic bezier ?
            + 34              */
            + 35             cubic:		false,
            + 36 
            + 37             applyAsPath : function( director ) {
            + 38 
            + 39                 var cc= this.coordlist;
            + 40 
            + 41                 if ( this.cubic ) {
            + 42                     director.ctx.bezierCurveTo(
            + 43                         cc[1].x,
            + 44                         cc[1].y,
            + 45                         cc[2].x,
            + 46                         cc[2].y,
            + 47                         cc[3].x,
            + 48                         cc[3].y
            + 49                     );
            + 50                 } else {
            + 51                     director.ctx.quadraticCurveTo(
            + 52                         cc[1].x,
            + 53                         cc[1].y,
            + 54                         cc[2].x,
            + 55                         cc[2].y
            + 56                     );
            + 57                 }
            + 58                 return this;
            + 59             },
            + 60             isQuadric : function() {
            + 61                 return !this.cubic;
            + 62             },
            + 63             isCubic : function() {
            + 64                 return this.cubic;
            + 65             },
            + 66             /**
            + 67              * Set this curve as a cubic bezier defined by the given four control points.
            + 68              * @param cp0x {number}
            + 69              * @param cp0y {number}
            + 70              * @param cp1x {number}
            + 71              * @param cp1y {number}
            + 72              * @param cp2x {number}
            + 73              * @param cp2y {number}
            + 74              * @param cp3x {number}
            + 75              * @param cp3y {number}
            + 76              */
            + 77             setCubic : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) {
            + 78 
            + 79                 this.coordlist= [];
            + 80 
            + 81                 this.coordlist.push( new CAAT.Math.Point().set(cp0x, cp0y ) );
            + 82                 this.coordlist.push( new CAAT.Math.Point().set(cp1x, cp1y ) );
            + 83                 this.coordlist.push( new CAAT.Math.Point().set(cp2x, cp2y ) );
            + 84                 this.coordlist.push( new CAAT.Math.Point().set(cp3x, cp3y ) );
            + 85 
            + 86                 this.cubic= true;
            + 87                 this.update();
            + 88 
            + 89                 return this;
            + 90             },
            + 91             /**
            + 92              * Set this curve as a quadric bezier defined by the three control points.
            + 93              * @param cp0x {number}
            + 94              * @param cp0y {number}
            + 95              * @param cp1x {number}
            + 96              * @param cp1y {number}
            + 97              * @param cp2x {number}
            + 98              * @param cp2y {number}
            + 99              */
            +100             setQuadric : function(cp0x,cp0y, cp1x,cp1y, cp2x,cp2y ) {
            +101 
            +102                 this.coordlist= [];
            +103 
            +104                 this.coordlist.push( new CAAT.Math.Point().set(cp0x, cp0y ) );
            +105                 this.coordlist.push( new CAAT.Math.Point().set(cp1x, cp1y ) );
            +106                 this.coordlist.push( new CAAT.Math.Point().set(cp2x, cp2y ) );
            +107 
            +108                 this.cubic= false;
            +109                 this.update();
            +110 
            +111                 return this;
            +112             },
            +113             setPoints : function( points ) {
            +114                 if ( points.length===3 ) {
            +115                     this.coordlist= points;
            +116                     this.cubic= false;
            +117                     this.update();
            +118                 } else if (points.length===4 ) {
            +119                     this.coordlist= points;
            +120                     this.cubic= true;
            +121                     this.update();
            +122                 } else {
            +123                     throw 'points must be an array of 3 or 4 CAAT.Point instances.'
            +124                 }
            +125 
            +126                 return this;
            +127             },
            +128             /**
            +129              * Paint this curve.
            +130              * @param director {CAAT.Director}
            +131              */
            +132             paint : function( director ) {
            +133                 if ( this.cubic ) {
            +134                     this.paintCubic(director);
            +135                 } else {
            +136                     this.paintCuadric( director );
            +137                 }
            +138 
            +139                 CAAT.Math.Bezier.superclass.paint.call(this,director);
            +140 
            +141             },
            +142             /**
            +143              * Paint this quadric Bezier curve. Each time the curve is drawn it will be solved again from 0 to 1 with
            +144              * CAAT.Bezier.k increments.
            +145              *
            +146              * @param director {CAAT.Director}
            +147              * @private
            +148              */
            +149             paintCuadric : function( director ) {
            +150                 var x1,y1;
            +151                 x1 = this.coordlist[0].x;
            +152                 y1 = this.coordlist[0].y;
            +153 
            +154                 var ctx= director.ctx;
            +155 
            +156                 ctx.save();
            +157                 ctx.beginPath();
            +158                 ctx.moveTo(x1,y1);
            +159 
            +160                 var point= new CAAT.Math.Point();
            +161                 for(var t=this.k;t<=1+this.k;t+=this.k){
            +162                     this.solve(point,t);
            +163                     ctx.lineTo(point.x, point.y );
            +164                 }
            +165 
            +166                 ctx.stroke();
            +167                 ctx.restore();
            +168 
            +169             },
            +170             /**
            +171              * Paint this cubic Bezier curve. Each time the curve is drawn it will be solved again from 0 to 1 with
            +172              * CAAT.Bezier.k increments.
            +173              *
            +174              * @param director {CAAT.Director}
            +175              * @private
            +176              */
            +177             paintCubic : function( director ) {
            +178 
            +179                 var x1,y1;
            +180                 x1 = this.coordlist[0].x;
            +181                 y1 = this.coordlist[0].y;
            +182 
            +183                 var ctx= director.ctx;
            +184 
            +185                 ctx.save();
            +186                 ctx.beginPath();
            +187                 ctx.moveTo(x1,y1);
            +188 
            +189                 var point= new CAAT.Math.Point();
            +190                 for(var t=this.k;t<=1+this.k;t+=this.k){
            +191                     this.solve(point,t);
            +192                     ctx.lineTo(point.x, point.y );
            +193                 }
            +194 
            +195                 ctx.stroke();
            +196                 ctx.restore();
            +197             },
            +198             /**
            +199              * Solves the curve for any given parameter t.
            +200              * @param point {CAAT.Point} the point to store the solved value on the curve.
            +201              * @param t {number} a number in the range 0..1
            +202              */
            +203             solve : function(point,t) {
            +204                 if ( this.cubic ) {
            +205                     return this.solveCubic(point,t);
            +206                 } else {
            +207                     return this.solveQuadric(point,t);
            +208                 }
            +209             },
            +210             /**
            +211              * Solves a cubic Bezier.
            +212              * @param point {CAAT.Point} the point to store the solved value on the curve.
            +213              * @param t {number} the value to solve the curve for.
            +214              */
            +215             solveCubic : function(point,t) {
            +216 
            +217                 var t2= t*t;
            +218                 var t3= t*t2;
            +219 
            +220                 var cl= this.coordlist;
            +221                 var cl0= cl[0];
            +222                 var cl1= cl[1];
            +223                 var cl2= cl[2];
            +224                 var cl3= cl[3];
            +225 
            +226                 point.x=(
            +227                     cl0.x + t * (-cl0.x * 3 + t * (3 * cl0.x-
            +228                     cl0.x*t)))+t*(3*cl1.x+t*(-6*cl1.x+
            +229                     cl1.x*3*t))+t2*(cl2.x*3-cl2.x*3*t)+
            +230                     cl3.x * t3;
            +231 
            +232                 point.y=(
            +233                         cl0.y+t*(-cl0.y*3+t*(3*cl0.y-
            +234                         cl0.y*t)))+t*(3*cl1.y+t*(-6*cl1.y+
            +235                         cl1.y*3*t))+t2*(cl2.y*3-cl2.y*3*t)+
            +236                         cl3.y * t3;
            +237 
            +238                 return point;
            +239             },
            +240             /**
            +241              * Solves a quadric Bezier.
            +242              * @param point {CAAT.Point} the point to store the solved value on the curve.
            +243              * @param t {number} the value to solve the curve for.
            +244              */
            +245             solveQuadric : function(point,t) {
            +246                 var cl= this.coordlist;
            +247                 var cl0= cl[0];
            +248                 var cl1= cl[1];
            +249                 var cl2= cl[2];
            +250                 var t1= 1-t;
            +251 
            +252                 point.x= t1*t1*cl0.x + 2*t1*t*cl1.x + t*t*cl2.x;
            +253                 point.y= t1*t1*cl0.y + 2*t1*t*cl1.y + t*t*cl2.y;
            +254 
            +255                 return point;
            +256             }
            +257         }
            +258     }
            +259 });
            +260 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_dimension.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_dimension.js.html new file mode 100644 index 0000000..4e4c7d6 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_dimension.js.html @@ -0,0 +1,44 @@ +
              1 CAAT.Module({
            +  2 
            +  3     /**
            +  4      * @name Dimension
            +  5      * @memberOf CAAT.Math
            +  6      * @constructor
            +  7      */
            +  8 
            +  9 
            + 10     defines:"CAAT.Math.Dimension",
            + 11     aliases:["CAAT.Dimension"],
            + 12     extendsWith:function () {
            + 13         return {
            + 14 
            + 15             /**
            + 16              * @lends CAAT.Math.Dimension.prototype
            + 17              */
            + 18 
            + 19             /**
            + 20              * Width dimension.
            + 21              */
            + 22             width:0,
            + 23 
            + 24             /**
            + 25              * Height dimension.
            + 26              */
            + 27             height:0,
            + 28 
            + 29             __init:function (w, h) {
            + 30                 this.width = w;
            + 31                 this.height = h;
            + 32                 return this;
            + 33             }
            + 34         }
            + 35     }
            + 36 });
            + 37 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_point.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_point.js.html new file mode 100644 index 0000000..6507777 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_math_point.js.html @@ -0,0 +1,243 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  **/
            +  5 CAAT.Module({
            +  6 
            +  7     /**
            +  8      * @name Point
            +  9      * @memberOf CAAT.Math
            + 10      * @constructor
            + 11      */
            + 12 
            + 13     defines:"CAAT.Math.Point",
            + 14     aliases:["CAAT.Point"],
            + 15     extendsWith:function () {
            + 16         return {
            + 17 
            + 18             /**
            + 19              * @lends CAAT.Math.Point.prototype
            + 20              */
            + 21 
            + 22 
            + 23             /**
            + 24              * point x coordinate.
            + 25              */
            + 26             x:0,
            + 27 
            + 28             /**
            + 29              * point y coordinate.
            + 30              */
            + 31             y:0,
            + 32 
            + 33             /**
            + 34              * point z coordinate.
            + 35              */
            + 36             z:0,
            + 37 
            + 38             __init:function (xpos, ypos, zpos) {
            + 39                 this.x = xpos;
            + 40                 this.y = ypos;
            + 41                 this.z = zpos || 0;
            + 42                 return this;
            + 43             },
            + 44 
            + 45             /**
            + 46              * Sets this point coordinates.
            + 47              * @param x {number}
            + 48              * @param y {number}
            + 49              * @param z {number=}
            + 50              *
            + 51              * @return this
            + 52              */
            + 53             set:function (x, y, z) {
            + 54                 this.x = x;
            + 55                 this.y = y;
            + 56                 this.z = z || 0;
            + 57                 return this;
            + 58             },
            + 59             /**
            + 60              * Create a new CAAT.Point equal to this one.
            + 61              * @return {CAAT.Point}
            + 62              */
            + 63             clone:function () {
            + 64                 var p = new CAAT.Math.Point(this.x, this.y, this.z);
            + 65                 return p;
            + 66             },
            + 67             /**
            + 68              * Translate this point to another position. The final point will be (point.x+x, point.y+y)
            + 69              * @param x {number}
            + 70              * @param y {number}
            + 71              *
            + 72              * @return this
            + 73              */
            + 74             translate:function (x, y, z) {
            + 75                 this.x += x;
            + 76                 this.y += y;
            + 77                 this.z += z;
            + 78 
            + 79                 return this;
            + 80             },
            + 81             /**
            + 82              * Translate this point to another point.
            + 83              * @param aPoint {CAAT.Point}
            + 84              * @return this
            + 85              */
            + 86             translatePoint:function (aPoint) {
            + 87                 this.x += aPoint.x;
            + 88                 this.y += aPoint.y;
            + 89                 this.z += aPoint.z;
            + 90                 return this;
            + 91             },
            + 92             /**
            + 93              * Substract a point from this one.
            + 94              * @param aPoint {CAAT.Point}
            + 95              * @return this
            + 96              */
            + 97             subtract:function (aPoint) {
            + 98                 this.x -= aPoint.x;
            + 99                 this.y -= aPoint.y;
            +100                 this.z -= aPoint.z;
            +101                 return this;
            +102             },
            +103             /**
            +104              * Multiply this point by a scalar.
            +105              * @param factor {number}
            +106              * @return this
            +107              */
            +108             multiply:function (factor) {
            +109                 this.x *= factor;
            +110                 this.y *= factor;
            +111                 this.z *= factor;
            +112                 return this;
            +113             },
            +114             /**
            +115              * Rotate this point by an angle. The rotation is held by (0,0) coordinate as center.
            +116              * @param angle {number}
            +117              * @return this
            +118              */
            +119             rotate:function (angle) {
            +120                 var x = this.x, y = this.y;
            +121                 this.x = x * Math.cos(angle) - Math.sin(angle) * y;
            +122                 this.y = x * Math.sin(angle) + Math.cos(angle) * y;
            +123                 this.z = 0;
            +124                 return this;
            +125             },
            +126             /**
            +127              *
            +128              * @param angle {number}
            +129              * @return this
            +130              */
            +131             setAngle:function (angle) {
            +132                 var len = this.getLength();
            +133                 this.x = Math.cos(angle) * len;
            +134                 this.y = Math.sin(angle) * len;
            +135                 this.z = 0;
            +136                 return this;
            +137             },
            +138             /**
            +139              *
            +140              * @param length {number}
            +141              * @return this
            +142              */
            +143             setLength:function (length) {
            +144                 var len = this.getLength();
            +145                 if (len)this.multiply(length / len);
            +146                 else this.x = this.y = this.z = length;
            +147                 return this;
            +148             },
            +149             /**
            +150              * Normalize this point, that is, both set coordinates proportionally to values raning 0..1
            +151              * @return this
            +152              */
            +153             normalize:function () {
            +154                 var len = this.getLength();
            +155                 this.x /= len;
            +156                 this.y /= len;
            +157                 this.z /= len;
            +158                 return this;
            +159             },
            +160             /**
            +161              * Return the angle from -Pi to Pi of this point.
            +162              * @return {number}
            +163              */
            +164             getAngle:function () {
            +165                 return Math.atan2(this.y, this.x);
            +166             },
            +167             /**
            +168              * Set this point coordinates proportinally to a maximum value.
            +169              * @param max {number}
            +170              * @return this
            +171              */
            +172             limit:function (max) {
            +173                 var aLenthSquared = this.getLengthSquared();
            +174                 if (aLenthSquared + 0.01 > max * max) {
            +175                     var aLength = Math.sqrt(aLenthSquared);
            +176                     this.x = (this.x / aLength) * max;
            +177                     this.y = (this.y / aLength) * max;
            +178                     this.z = (this.z / aLength) * max;
            +179                 }
            +180                 return this;
            +181             },
            +182             /**
            +183              * Get this point's lenght.
            +184              * @return {number}
            +185              */
            +186             getLength:function () {
            +187                 var length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
            +188                 if (length < 0.005 && length > -0.005) return 0.000001;
            +189                 return length;
            +190 
            +191             },
            +192             /**
            +193              * Get this point's squared length.
            +194              * @return {number}
            +195              */
            +196             getLengthSquared:function () {
            +197                 var lengthSquared = this.x * this.x + this.y * this.y + this.z * this.z;
            +198                 if (lengthSquared < 0.005 && lengthSquared > -0.005) return 0;
            +199                 return lengthSquared;
            +200             },
            +201             /**
            +202              * Get the distance between two points.
            +203              * @param point {CAAT.Point}
            +204              * @return {number}
            +205              */
            +206             getDistance:function (point) {
            +207                 var deltaX = this.x - point.x;
            +208                 var deltaY = this.y - point.y;
            +209                 var deltaZ = this.z - point.z;
            +210                 return Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
            +211             },
            +212             /**
            +213              * Get the squared distance between two points.
            +214              * @param point {CAAT.Point}
            +215              * @return {number}
            +216              */
            +217             getDistanceSquared:function (point) {
            +218                 var deltaX = this.x - point.x;
            +219                 var deltaY = this.y - point.y;
            +220                 var deltaZ = this.z - point.z;
            +221                 return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
            +222             },
            +223             /**
            +224              * Get a string representation.
            +225              * @return {string}
            +226              */
            +227             toString:function () {
            +228                 return "(CAAT.Math.Point)" +
            +229                     " x:" + String(Math.round(Math.floor(this.x * 10)) / 10) +
            +230                     " y:" + String(Math.round(Math.floor(this.y * 10)) / 10) +
            +231                     " z:" + String(Math.round(Math.floor(this.z * 10)) / 10);
            +232             }
            +233         }
            +234     }
            +235 });
            +236 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircle.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircle.js.html new file mode 100644 index 0000000..3ced438 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircle.js.html @@ -0,0 +1,205 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  ####  #####  ##### ####    ###  #   # ###### ###### ##     ##  #####  #     #      ########    ##    #  #  #####
            +  5  #   # #   #  ###   #   #  #####  ###    ##     ##   ##  #  ##    #    #     #     #   ##   #  #####  ###   ###
            +  6  ###  #   #  ##### ####   #   #   #   ######   ##   #########  #####  ##### ##### #   ##   #  #   #  #   # #####
            +  7  -
            +  8  File:
            +  9  PackedCircle.js
            + 10  Created By:
            + 11  Mario Gonzalez
            + 12  Project    :
            + 13  None
            + 14  Abstract:
            + 15  A single packed circle.
            + 16  Contains a reference to it's div, and information pertaining to it state.
            + 17  Basic Usage:
            + 18  http://onedayitwillmake.com/CirclePackJS/
            + 19  */
            + 20 
            + 21 CAAT.Module({
            + 22 
            + 23     /**
            + 24      * @name CircleManager
            + 25      * @memberOf CAAT.Module
            + 26      * @namespace
            + 27      */
            + 28 
            + 29     /**
            + 30      * @name PackedCircle
            + 31      * @memberOf CAAT.Module.CircleManager
            + 32      * @constructor
            + 33      */
            + 34 
            + 35     defines:"CAAT.Module.CircleManager.PackedCircle",
            + 36     depends:[
            + 37         "CAAT.Module.CircleManager.PackedCircle",
            + 38         "CAAT.Math.Point"
            + 39     ],
            + 40     constants:{
            + 41 
            + 42         /**
            + 43          * @lends CAAT.Module.CircleManager.PackedCircle
            + 44          */
            + 45 
            + 46         /** @const */ BOUNDS_RULE_WRAP:1, // Wrap to otherside
            + 47         /** @const */ BOUNDS_RULE_CONSTRAINT:2, // Constrain within bounds
            + 48         /** @const */ BOUNDS_RULE_DESTROY:4, // Destroy when it reaches the edge
            + 49         /** @const */ BOUNDS_RULE_IGNORE:8        // Ignore when reaching bounds
            + 50     },
            + 51     extendsWith:{
            + 52 
            + 53         /**
            + 54          * @lends CAAT.Module.CircleManager.PackedCircle.prototype
            + 55          */
            + 56 
            + 57         __init:function () {
            + 58             this.boundsRule = CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE;
            + 59             this.position = new CAAT.Math.Point(0, 0, 0);
            + 60             this.offset = new CAAT.Math.Point(0, 0, 0);
            + 61             this.targetPosition = new CAAT.Math.Point(0, 0, 0);
            + 62             return this;
            + 63         },
            + 64 
            + 65         /**
            + 66          *
            + 67          */
            + 68         id:0,
            + 69 
            + 70         /**
            + 71          *
            + 72          */
            + 73         delegate:null,
            + 74 
            + 75         /**
            + 76          *
            + 77          */
            + 78         position:null,
            + 79 
            + 80         /**
            + 81          *
            + 82          */
            + 83         offset:null,
            + 84 
            + 85         /**
            + 86          *
            + 87          */
            + 88         targetPosition:null, // Where it wants to go
            + 89 
            + 90         /**
            + 91          *
            + 92          */
            + 93         targetChaseSpeed:0.02,
            + 94 
            + 95         /**
            + 96          *
            + 97          */
            + 98         isFixed:false,
            + 99 
            +100         /**
            +101          *
            +102          */
            +103         boundsRule:0,
            +104 
            +105         /**
            +106          *
            +107          */
            +108         collisionMask:0,
            +109 
            +110         /**
            +111          *
            +112          */
            +113         collisionGroup:0,
            +114 
            +115         containsPoint:function (aPoint) {
            +116             var distanceSquared = this.position.getDistanceSquared(aPoint);
            +117             return distanceSquared < this.radiusSquared;
            +118         },
            +119 
            +120         getDistanceSquaredFromPosition:function (aPosition) {
            +121             var distanceSquared = this.position.getDistanceSquared(aPosition);
            +122             // if it's shorter than either radius, we intersect
            +123             return distanceSquared < this.radiusSquared;
            +124         },
            +125 
            +126         intersects:function (aCircle) {
            +127             var distanceSquared = this.position.getDistanceSquared(aCircle.position);
            +128             return (distanceSquared < this.radiusSquared || distanceSquared < aCircle.radiusSquared);
            +129         },
            +130 
            +131         /**
            +132          * ACCESSORS
            +133          */
            +134         setPosition:function (aPosition) {
            +135             this.position = aPosition;
            +136             return this;
            +137         },
            +138 
            +139         setDelegate:function (aDelegate) {
            +140             this.delegate = aDelegate;
            +141             return this;
            +142         },
            +143 
            +144         setOffset:function (aPosition) {
            +145             this.offset = aPosition;
            +146             return this;
            +147         },
            +148 
            +149         setTargetPosition:function (aTargetPosition) {
            +150             this.targetPosition = aTargetPosition;
            +151             return this;
            +152         },
            +153 
            +154         setTargetChaseSpeed:function (aTargetChaseSpeed) {
            +155             this.targetChaseSpeed = aTargetChaseSpeed;
            +156             return this;
            +157         },
            +158 
            +159         setIsFixed:function (value) {
            +160             this.isFixed = value;
            +161             return this;
            +162         },
            +163 
            +164         setCollisionMask:function (aCollisionMask) {
            +165             this.collisionMask = aCollisionMask;
            +166             return this;
            +167         },
            +168 
            +169         setCollisionGroup:function (aCollisionGroup) {
            +170             this.collisionGroup = aCollisionGroup;
            +171             return this;
            +172         },
            +173 
            +174         setRadius:function (aRadius) {
            +175             this.radius = aRadius;
            +176             this.radiusSquared = this.radius * this.radius;
            +177             return this;
            +178         },
            +179 
            +180         initialize:function (overrides) {
            +181             if (overrides) {
            +182                 for (var i in overrides) {
            +183                     this[i] = overrides[i];
            +184                 }
            +185             }
            +186 
            +187             return this;
            +188         },
            +189 
            +190         dealloc:function () {
            +191             this.position = null;
            +192             this.offset = null;
            +193             this.delegate = null;
            +194             this.targetPosition = null;
            +195         }
            +196     }
            +197 });
            +198 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircleManager.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircleManager.js.html new file mode 100644 index 0000000..c07cf24 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_CircleManager_PackedCircleManager.js.html @@ -0,0 +1,405 @@ +
              1 /**
            +  2  *
            +  3  * See LICENSE file.
            +  4  * 
            +  5 	  ####  #####  ##### ####    ###  #   # ###### ###### ##     ##  #####  #     #      ########    ##    #  #  #####
            +  6 	 #   # #   #  ###   #   #  #####  ###    ##     ##   ##  #  ##    #    #     #     #   ##   #  #####  ###   ###
            +  7 	 ###  #   #  ##### ####   #   #   #   ######   ##   #########  #####  ##### ##### #   ##   #  #   #  #   # #####
            +  8  -
            +  9  File:
            + 10  	PackedCircle.js
            + 11  Created By:
            + 12  	Mario Gonzalez
            + 13  Project	:
            + 14  	None
            + 15  Abstract:
            + 16  	 A single packed circle.
            + 17 	 Contains a reference to it's div, and information pertaining to it state.
            + 18  Basic Usage:
            + 19 	http://onedayitwillmake.com/CirclePackJS/
            + 20 */
            + 21 
            + 22 CAAT.Module( {
            + 23 
            + 24 
            + 25     /**
            + 26      * @name PackedCircleManager
            + 27      * @memberOf CAAT.Module.CircleManager
            + 28      * @constructor
            + 29      */
            + 30 
            + 31 
            + 32     defines : "CAAT.Module.CircleManager.PackedCircleManager",
            + 33     depends : [
            + 34         "CAAT.Math.Point",
            + 35         "CAAT.Math.Rectangle"
            + 36     ],
            + 37     extendsWith : {
            + 38 
            + 39         /**
            + 40          * @lends CAAT.Module.CircleManager.PackedCircleManager.prototype
            + 41          * @private
            + 42          */
            + 43 
            + 44         __init : function() {
            + 45             this.bounds= new CAAT.Math.Rectangle();
            + 46         },
            + 47 
            + 48         /**
            + 49          *
            + 50          */
            + 51 		allCircles:					[],
            + 52 
            + 53         /**
            + 54          *
            + 55          */
            + 56 		numberOfCollisionPasses:	1,
            + 57 
            + 58         /**
            + 59          *
            + 60          */
            + 61 		numberOfTargetingPasses:	0,
            + 62 
            + 63         /**
            + 64          *
            + 65          */
            + 66 		bounds:						null,
            + 67 
            + 68 		/**
            + 69 		 * Adds a circle to the simulation
            + 70 		 * @param aCircle
            + 71 		 */
            + 72 		addCircle: function(aCircle)
            + 73 		{
            + 74 			aCircle.id = this.allCircles.length;
            + 75 			this.allCircles.push(aCircle);
            + 76 			return this;
            + 77 		},
            + 78 
            + 79 		/**
            + 80 		 * Removes a circle from the simulations
            + 81 		 * @param aCircle	Circle to remove
            + 82 		 */
            + 83 		removeCircle: function(aCircle)
            + 84 		{
            + 85 			var index = 0,
            + 86 				found = false,
            + 87 				len = this.allCircles.length;
            + 88 
            + 89 			if(len === 0) {
            + 90 				throw "Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!";
            + 91 			}
            + 92 
            + 93 			while (len--) {
            + 94 				if(this.allCircles[len] === aCircle) {
            + 95 					found = true;
            + 96 					index = len;
            + 97 					break;
            + 98 				}
            + 99 			}
            +100 
            +101 			if(!found) {
            +102 				throw "Could not locate circle in allCircles array!";
            +103 			}
            +104 
            +105 			// Remove
            +106 			this.allCircles[index].dealloc();
            +107 			this.allCircles[index] = null;
            +108 
            +109 			return this;
            +110 		},
            +111 
            +112 		/**
            +113 		 * Forces all circles to move to where their delegate position is
            +114 		 * Assumes all targets have a 'position' property!
            +115 		 */
            +116 		forceCirclesToMatchDelegatePositions: function()
            +117 		{
            +118 			var len = this.allCircles.length;
            +119 
            +120 			// push toward target position
            +121 			for(var n = 0; n < len; n++)
            +122 			{
            +123 				var aCircle = this.allCircles[n];
            +124 				if(!aCircle || !aCircle.delegate) {
            +125 					continue;
            +126 				}
            +127 
            +128 				aCircle.position.set(aCircle.delegate.x + aCircle.offset.x,
            +129 						aCircle.delegate.y + aCircle.offset.y);
            +130 			}
            +131 		},
            +132 
            +133 		pushAllCirclesTowardTarget: function(aTarget)
            +134 		{
            +135 			var v = new CAAT.Math.Point(0,0,0),
            +136 				circleList = this.allCircles,
            +137 				len = circleList.length;
            +138 
            +139 			// push toward target position
            +140 			for(var n = 0; n < this.numberOfTargetingPasses; n++)
            +141 			{
            +142 				for(var i = 0; i < len; i++)
            +143 				{
            +144 					var c = circleList[i];
            +145 
            +146 					if(c.isFixed) continue;
            +147 
            +148 					v.x = c.position.x - (c.targetPosition.x+c.offset.x);
            +149 					v.y = c.position.y - (c.targetPosition.y+c.offset.y);
            +150 					v.multiply(c.targetChaseSpeed);
            +151 
            +152 					c.position.x -= v.x;
            +153 					c.position.y -= v.y;
            +154 				}
            +155 			}
            +156 		},
            +157 
            +158 		/**
            +159 		 * Packs the circles towards the center of the bounds.
            +160 		 * Each circle will have it's own 'targetPosition' later on
            +161 		 */
            +162 		handleCollisions: function()
            +163 		{
            +164 			this.removeExpiredElements();
            +165 
            +166 			var v = new CAAT.Math.Point(0,0, 0),
            +167 				circleList = this.allCircles,
            +168 				len = circleList.length;
            +169 
            +170 			// Collide circles
            +171 			for(var n = 0; n < this.numberOfCollisionPasses; n++)
            +172 			{
            +173 				for(var i = 0; i < len; i++)
            +174 				{
            +175 					var ci = circleList[i];
            +176 
            +177 
            +178 					for (var j = i + 1; j< len; j++)
            +179 					{
            +180 						var cj = circleList[j];
            +181 
            +182 						if( !this.circlesCanCollide(ci, cj) ) continue;   // It's us!
            +183 
            +184 						var dx = cj.position.x - ci.position.x,
            +185 							dy = cj.position.y - ci.position.y;
            +186 
            +187 						// The distance between the two circles radii, but we're also gonna pad it a tiny bit
            +188 						var r = (ci.radius + cj.radius) * 1.08,
            +189 							d = ci.position.getDistanceSquared(cj.position);
            +190 
            +191 						/**
            +192 						 * Collision detected!
            +193 						 */
            +194 						if (d < (r * r) - 0.02 )
            +195 						{
            +196 							v.x = dx;
            +197 							v.y = dy;
            +198 							v.normalize();
            +199 
            +200 							var inverseForce = (r - Math.sqrt(d)) * 0.5;
            +201 							v.multiply(inverseForce);
            +202 
            +203 							// Move cj opposite of the collision as long as its not fixed
            +204 							if(!cj.isFixed)
            +205 							{
            +206 								if(ci.isFixed)
            +207 									v.multiply(2.2);	// Double inverse force to make up for the fact that the other object is fixed
            +208 
            +209 								// ADD the velocity
            +210 								cj.position.translatePoint(v);
            +211 							}
            +212 
            +213 							// Move ci opposite of the collision as long as its not fixed
            +214 							if(!ci.isFixed)
            +215 							{
            +216 								if(cj.isFixed)
            +217 									v.multiply(2.2);	// Double inverse force to make up for the fact that the other object is fixed
            +218 
            +219 								 // SUBTRACT the velocity
            +220 								ci.position.subtract(v);
            +221 							}
            +222 
            +223 							// Emit the collision event from each circle, with itself as the first parameter
            +224 //							if(this.dispatchCollisionEvents && n == this.numberOfCollisionPasses-1)
            +225 //							{
            +226 //								this.eventEmitter.emit('collision', cj, ci, v);
            +227 //							}
            +228 						}
            +229 					}
            +230 				}
            +231 			}
            +232 		},
            +233 
            +234 		handleBoundaryForCircle: function(aCircle, boundsRule)
            +235 		{
            +236 //			if(aCircle.boundsRule === true) return; // Ignore if being dragged
            +237 
            +238 			var xpos = aCircle.position.x;
            +239 			var ypos = aCircle.position.y;
            +240 
            +241 			var radius = aCircle.radius;
            +242 			var diameter = radius*2;
            +243 
            +244 			// Toggle these on and off,
            +245 			// Wrap and bounce, are opposite behaviors so pick one or the other for each axis, or bad things will happen.
            +246 			var wrapXMask = 1 << 0;
            +247 			var wrapYMask = 1 << 2;
            +248 			var constrainXMask = 1 << 3;
            +249 			var constrainYMask = 1 << 4;
            +250 			var emitEvent = 1 << 5;
            +251 
            +252 			// TODO: Promote to member variable
            +253 			// Convert to bitmask - Uncomment the one you want, or concact your own :)
            +254 	//		boundsRule = wrapY; // Wrap only Y axis
            +255 	//		boundsRule = wrapX; // Wrap only X axis
            +256 	//		boundsRule = wrapXMask | wrapYMask; // Wrap both X and Y axis
            +257 			boundsRule = wrapYMask | constrainXMask;  // Wrap Y axis, but constrain horizontally
            +258 
            +259 			// Wrap X
            +260 			if(boundsRule & wrapXMask && xpos-diameter > this.bounds.right) {
            +261 				aCircle.position.x = this.bounds.left + radius;
            +262 			} else if(boundsRule & wrapXMask && xpos+diameter < this.bounds.left) {
            +263 				aCircle.position.x = this.bounds.right - radius;
            +264 			}
            +265 			// Wrap Y
            +266 			if(boundsRule & wrapYMask && ypos-diameter > this.bounds.bottom) {
            +267 				aCircle.position.y = this.bounds.top - radius;
            +268 			} else if(boundsRule & wrapYMask && ypos+diameter < this.bounds.top) {
            +269 				aCircle.position.y = this.bounds.bottom + radius;
            +270 			}
            +271 
            +272 			// Constrain X
            +273 			if(boundsRule & constrainXMask && xpos+radius >= this.bounds.right) {
            +274 				aCircle.position.x = aCircle.position.x = this.bounds.right-radius;
            +275 			} else if(boundsRule & constrainXMask && xpos-radius < this.bounds.left) {
            +276 				aCircle.position.x = this.bounds.left + radius;
            +277 			}
            +278 
            +279 			// Constrain Y
            +280 			if(boundsRule & constrainYMask && ypos+radius > this.bounds.bottom) {
            +281 				aCircle.position.y = this.bounds.bottom - radius;
            +282 			} else if(boundsRule & constrainYMask && ypos-radius < this.bounds.top) {
            +283 				aCircle.position.y = this.bounds.top + radius;
            +284 			}
            +285 		},
            +286 
            +287 		/**
            +288 		 * Given an x,y position finds circle underneath and sets it to the currently grabbed circle
            +289 		 * @param {Number} xpos		An x position
            +290 		 * @param {Number} ypos		A y position
            +291 		 * @param {Number} buffer	A radiusSquared around the point in question where something is considered to match
            +292 		 */
            +293 		getCircleAt: function(xpos, ypos, buffer)
            +294 		{
            +295 			var circleList = this.allCircles;
            +296 			var len = circleList.length;
            +297 			var grabVector = new CAAT.Math.Point(xpos, ypos, 0);
            +298 
            +299 			// These are set every time a better match i found
            +300 			var closestCircle = null;
            +301 			var closestDistance = Number.MAX_VALUE;
            +302 
            +303 			// Loop thru and find the closest match
            +304 			for(var i = 0; i < len; i++)
            +305 			{
            +306 				var aCircle = circleList[i];
            +307 				if(!aCircle) continue;
            +308 				var distanceSquared = aCircle.position.getDistanceSquared(grabVector);
            +309 
            +310 				if(distanceSquared < closestDistance && distanceSquared < aCircle.radiusSquared + buffer)
            +311 				{
            +312 					closestDistance = distanceSquared;
            +313 					closestCircle = aCircle;
            +314 				}
            +315 			}
            +316 
            +317 			return closestCircle;
            +318 		},
            +319 
            +320 		circlesCanCollide: function(circleA, circleB)
            +321 		{
            +322 		    if(!circleA || !circleB || circleA===circleB) return false; 					// one is null (will be deleted next loop), or both point to same obj.
            +323 //			if(circleA.delegate == null || circleB.delegate == null) return false;					// This circle will be removed next loop, it's entity is already removed
            +324 
            +325 //			if(circleA.isFixed & circleB.isFixed) return false;
            +326 //			if(circleA.delegate .clientID === circleB.delegate.clientID) return false; 				// Don't let something collide with stuff it owns
            +327 
            +328 			// They dont want to collide
            +329 //			if((circleA.collisionGroup & circleB.collisionMask) == 0) return false;
            +330 //			if((circleB.collisionGroup & circleA.collisionMask) == 0) return false;
            +331 
            +332 			return true;
            +333 		},
            +334 /**
            +335  * Accessors
            +336  */
            +337 		setBounds: function(x, y, w, h)
            +338 		{
            +339 			this.bounds.x = x;
            +340 			this.bounds.y = y;
            +341 			this.bounds.width = w;
            +342 			this.bounds.height = h;
            +343 		},
            +344 
            +345 		setNumberOfCollisionPasses: function(value)
            +346 		{
            +347 			this.numberOfCollisionPasses = value;
            +348 			return this;
            +349 		},
            +350 
            +351 		setNumberOfTargetingPasses: function(value)
            +352 		{
            +353 			this.numberOfTargetingPasses = value;
            +354 			return this;
            +355 		},
            +356 
            +357 /**
            +358  * Helpers
            +359  */
            +360 		sortOnDistanceToTarget: function(circleA, circleB)
            +361 		{
            +362 			var valueA = circleA.getDistanceSquaredFromPosition(circleA.targetPosition);
            +363 			var valueB = circleB.getDistanceSquaredFromPosition(circleA.targetPosition);
            +364 			var comparisonResult = 0;
            +365 
            +366 			if(valueA > valueB) comparisonResult = -1;
            +367 			else if(valueA < valueB) comparisonResult = 1;
            +368 
            +369 			return comparisonResult;
            +370 		},
            +371 
            +372 /**
            +373  * Memory Management
            +374  */
            +375 		removeExpiredElements: function()
            +376 		{
            +377 			// remove null elements
            +378 			for (var k = this.allCircles.length; k >= 0; k--) {
            +379 				if (this.allCircles[k] === null)
            +380 					this.allCircles.splice(k, 1);
            +381 			}
            +382 		},
            +383 
            +384 		initialize : function(overrides)
            +385 		{
            +386 			if (overrides)
            +387 			{
            +388 				for (var i in overrides)
            +389 				{
            +390 					this[i] = overrides[i];
            +391 				}
            +392 			}
            +393 
            +394 			return this;
            +395 		}
            +396 	}
            +397 });
            +398 
            \ No newline at end of file diff --git a/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_webgl_glu.js.html b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_webgl_glu.js.html new file mode 100644 index 0000000..2442563 --- /dev/null +++ b/CAAT/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_webgl_glu.js.html @@ -0,0 +1,101 @@ +
              1 /**
            +  2  * See LICENSE file.
            +  3  *
            +  4  */
            +  5 CAAT.Module( {
            +  6 
            +  7     /**
            +  8      * @name GLU
            +  9      * @memberOf CAAT.WebGL
            + 10      * @namespace
            + 11      */
            + 12 
            + 13     defines : "CAAT.WebGL.GLU",
            + 14     depends : [
            + 15         "CAAT.Math.Matrix3"
            + 16     ],
            + 17     constants : {
            + 18 
            + 19         /**
            + 20          * @lends CAAT.WebGL.GLU
            + 21          */
            + 22 
            + 23         /**
            + 24          * Create a perspective matrix.
            + 25          *
            + 26          * @param fovy
            + 27          * @param aspect
            + 28          * @param znear
            + 29          * @param zfar
            + 30          * @param viewportHeight
            + 31          */
            + 32         makePerspective : function (fovy, aspect, znear, zfar, viewportHeight) {
            + 33             var ymax = znear * Math.tan(fovy * Math.PI / 360.0);
            + 34             var ymin = -ymax;
            + 35             var xmin = ymin * aspect;
            + 36             var xmax = ymax * aspect;
            + 37 
            + 38             return makeFrustum(xmin, xmax, ymin, ymax, znear, zfar, viewportHeight);
            + 39         },
            + 40 
            + 41         /**
            + 42          * Create a matrix for a frustum.
            + 43          *
            + 44          * @param left
            + 45          * @param right
            + 46          * @param bottom
            + 47          * @param top
            + 48          * @param znear
            + 49          * @param zfar
            + 50          * @param viewportHeight
            + 51          */
            + 52         makeFrustum : function (left, right, bottom, top, znear, zfar, viewportHeight) {
            + 53             var X = 2*znear/(right-left);
            + 54             var Y = 2*znear/(top-bottom);
            + 55             var A = (right+left)/(right-left);
            + 56             var B = (top+bottom)/(top-bottom);
            + 57             var C = -(zfar+znear)/(zfar-znear);
            + 58             var D = -2*zfar*znear/(zfar-znear);
            + 59 
            + 60             return new CAAT.Math.Matrix3().initWithMatrix(
            + 61                     [
            + 62                         [X,  0,  A, -viewportHeight/2 ],
            + 63                         [0, -Y,  B,  viewportHeight/2 ],
            + 64                         [0,  0,  C,                 D ],
            + 65                         [0,  0, -1,                 0 ]
            + 66                     ]);
            + 67         },
            + 68 
            + 69         /**
            + 70          * Create an orthogonal projection matrix.
            + 71          * @param left
            + 72          * @param right
            + 73          * @param bottom
            + 74          * @param top
            + 75          * @param znear
            + 76          * @param zfar
            + 77          */
            + 78         makeOrtho : function (left, right, bottom, top, znear, zfar) {
            + 79             var tx = - (right + left) / (right - left) ;
            + 80             var ty = - (top + bottom) / (top - bottom) ;
            + 81             var tz = - (zfar + znear) / (zfar - znear);
            + 82 
            + 83             return new CAAT.Math.Matrix3().initWithMatrix(
            + 84                     [
            + 85                         [2 / (right - left), 0, 0, tx ],
            + 86                         [0, 2 / (top - bottom), 0, ty ],
            + 87                         [0, 0, -2 / (zfar- znear), tz ],
            + 88                         [0, 0, 0,                  1  ]
            + 89                     ]);
            + 90         }
            + 91 
            + 92     }
            + 93 });
            + 94 
            \ No newline at end of file diff --git a/CAAT/documentation/track.js b/CAAT/documentation/track.js new file mode 100644 index 0000000..261e7b3 --- /dev/null +++ b/CAAT/documentation/track.js @@ -0,0 +1,9 @@ +var _gaq = _gaq || []; +_gaq.push(['_setAccount', 'UA-17485141-4']); +_gaq.push(['_trackPageview']); + +(function() { + var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; + ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); +})(); diff --git a/CAAT/documentation/tutorials/00_Structure.html b/CAAT/documentation/tutorials/00_Structure.html new file mode 100644 index 0000000..72bf353 --- /dev/null +++ b/CAAT/documentation/tutorials/00_Structure.html @@ -0,0 +1,95 @@ + + + + + + + + CAAT Tutorial 0 - Structure + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +
            +

            Structure

            + +
            +

            CAAT uses a director as its base element. It contains different scenes which handle a set + of containers and single elements.

            +

            + Visually, contained elements would look like this: +

            +
            +
            +
            +

            CAAT.Foundation.Director +

            +
            +

            CAAT.Foundation.Scene +

            +
            +

            CAAT.Foundation.Actor *

            +
            +

            CAAT.Foundation.ActorContainer *

            +
            +

            CAAT.Foundation.ActorContainer *

            +

            CAAT.Foundation.Actor *

            +
            +
            +
            +
            + +
            +
            +
            +

            + This is CAAT's scene graph, where an undefined number of Scenes contain an unlimited number + of Actors and Containers. Containers, contains at the same time other Containers or Actors. +

            +

            + Scene and Director are an specialized type of ActorContainer instance. +

            +

            + Transformations applied to ActorContainer objects are hierarchically applied regardless its nesting + position in the scene graph, and are accumulated from container to children. +

            +

            + See demo8 and demo26 + for a visual explanation of transformations from parent to child. +

            +
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/00_Structure_ModuleManager.html b/CAAT/documentation/tutorials/00_Structure_ModuleManager.html new file mode 100644 index 0000000..0d52212 --- /dev/null +++ b/CAAT/documentation/tutorials/00_Structure_ModuleManager.html @@ -0,0 +1,243 @@ + + + + + + + + CAAT Tutorial 0 - CAAT.ModuleManager + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +
            +

            CAAT.ModuleManager

            + +
            +

            + The ModuleManager controls module loading operations. Tipically, a module consists of a + single JavaScript file, which after being processed by the ModuleManager, will define a + Class object. +

            +

            + It has the following features: +

            +
              +
            • Solves very deep transitive dependencies. +
            • Bundled files (all files concatenaded for production environments) +
            • Single file retrieval (get file by file for testing environments) +
            • Only javascript files loading +
            • Load Mixing of JavaScript file libraries and Modules loading +
            • Reentrant notification points. +
            • It does not pollute global namespace. +
            • Based on John Resig's Class pattern. +
            +

            + The ModuleManager, not only loads modules, and handles its dependencies by loading other + modules, and keeping you safe appart from cyclic dependencies, but also loads JavaScript + library files, notifies you about modules been solved, etc. +

            +

            + Minimally, a ModuleManager must be configured with a bring( [] ), + and an onReady callback function.. +

            +

            + A typical ModuleManager definition could be: +

            +
            +
            +                            CAAT.ModuleManager.
            +
            +                            // define the baseURL, a base URL component for all
            +                                baseURL("data/src/animation").
            +
            +                            // define some module
            +                                setModulePath("CAAT.Module",            "Modules").
            +                                setModulePath("CAAT.Math",              "Math/v1").
            +                                setModulePath....
            +
            +                            // get modules, and solve their dependencies.
            +                                bring(
            +                                [
            +                                  "CAAT.PathUtil.Path",
            +                                  "CAAT.Foundation.Director",
            +                                  "CAAT.Foundation.Scene",
            +                                  "CAAT.Foundation.UI.Layout.BoxLayout",
            +                                  "CAAT.Module.Preloader.ImagePreloader",
            +                                  "CAAT.Module.Storage.LocalStorage"
            +                                ]).
            +
            +                            // this function will be firer every time all dependencies have been solved.
            +                            // if you call again bring, this function could be fired again.
            +                                onReady(function () {
            +
            +                                    // safe to use these modules and their dependencies here.
            +
            +                              });
            +                        
            +
            +
            + + +
            + +
            +

            MoMa.ModuleManager.baseURL(path)

            +

            + The base URL defines a document root to read and solve modules from. + The function will append / in case the path does not contain it. +

            +
            + +
            +

            MoMa.ModuleManager.setModulePath(module, path)

            +

            + Define as much module paths as needed. for example: +

            + +
            +
            +                                MoMa.ModuleManager.setModulePath("CAAT.Foundation", "src/Foundation")
            +
            +                                //will make a module like
            +
            +                                MoMa.Module({
            +                                 defines : "CAAT.Foundation.UI.Label",
            +                                 ...
            +
            +                                //resolve to
            +
            +                                src/Foundation/UI/Label.js
            +                            
            +
            +
            + +
            +

            MoMa.ModuleManager.bring( ["module1 | .js file", "module2 | .js file",...] )

            + +

            + This functions loads all the modules or libraries specified. + Modules are loaded and solved on the fly, while .js files, are simply loaded. + When **MoMa** ends loading and solving all files/modules, it notifies via callback to MoMa's **onReady** function. + **The onReady function, when invoked, will remove all onReady observers.** +

            +

            + This function loads a file if the array value ends with **js**, or tries to load a module otherwise. +

            +
            + +
            +

            MoMa.ModuleManager.addModuleSolvedListener(modulename,callback)

            +

            + Add a callback function when a given module has been solved. +

            + +
            +

            MoMa.ModuleManager.load(file, onload, onerror)

            +

            + Load a js file, and notify callbacks on file load, or on error. This function does not try to solve any module + contained in the file. Intended to load independant non-module files. +

            + +
            +

            MoMa.ModuleManager.onReady(callback)

            +

            + Call the callback funtion when all the files specified by a call to bring have been loaded and solved. It is safe + to start any program from this callback function. +

            + +
            +

            MoMa.ModuleManager.status()

            +

            +

            + +
            +

            Module resolution

            + +

            + The rules to load a module from a call to **bring** are the following: + +

              +
            • if the module_name ends with .js +
                +
              • if starts with /, the module resolves to module_name.substring(1) +
              • else the module resolves to **baseURL/module_name +
              +
            • else +
            • if a suitable modulePath defined by a call to setModulePath exists +
                +
              • strip module_path prefix from module_name and change it by the associated path +
              • change . by / +
              • prepend baseURL +
              +
            • else return ModuleManager.baseURL + module.replace(/\./g,"/") + ".js"; (which may fail) +
            +

            + For example: +

            +
            +
            +
            +                               MoMa.ModuleManager.
            +                                 setBaseURL("/code/js").
            +                                 setModulePath( "CAAT.Foundation", "src/Foundation" );
            +
            +                               MoMa.bring( [
            +                                   "CAAT.Foundation.Actor",
            +                                   "CAAT.Foundation.UI.Label",
            +                                   "a.js",
            +                                   "/a.js"
            +                               ] );
            +                            
            +
            + +

            + CAAT.Foundation.Actor will resolve to: /code/js/src/Foundation/Actor.js ( + '/code/js/' + 'src/Foundation/' + 'Actor' + '.js') +

            + CAAT.Foundation.UI.Label will resolve to: /code/js/src/Foundation/UI/Label.js + ('/code/js/' + 'src/Foundation/' + 'UI/Label' + 'js') +

            + a.js will resolve to: /code/js/a.js ('/code/js' + 'a.js') +

            + /a.js will resolve to: a.js + +

            + +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/00_Structure_modules.html b/CAAT/documentation/tutorials/00_Structure_modules.html new file mode 100644 index 0000000..27b9a49 --- /dev/null +++ b/CAAT/documentation/tutorials/00_Structure_modules.html @@ -0,0 +1,231 @@ + + + + + + + + CAAT Tutorial 0 - CAAT.Module + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +
            +

            Modules and Classes

            + +
            +

            + CAAT is Object Oriented. Classes (constructor functions), constants and its names are + defined declaratively using CAAT's module manager: MoMa. +

            +

            + Every CAAT Class object is defined in a module. A module creates a new Class, can extend + one sinle Class, defines Class level constants, declares dependencies and a list of Class aliases. + MoMa will take care of loading dependency files and solving them. +

            +

            + CAAT can be bundled either in one single file instead of a file per module too. +

            +

            + You can find CAAT bulk bundled library files under the "build" folder. These files + contain all CAAT's modules and classes. +

            +
            +
            +

            + A module is defined as follows: +

            +
            +
            +                            CAAT.Module( {
            +                                defines : "CAAT.Foundation.UI.StarActor",
            +                                aliases : ["CAAT.StarActor"],
            +                                depends : [
            +                                    "CAAT.Foundation.ActorContainer"
            +                                ],
            +                                extendsClass : "CAAT.Foundation.ActorContainer",
            +                                extendsWith : function() {
            +
            +                                    return {
            +                                        __init : function() {
            +                                            this.__super();
            +                                            this.compositeOp= 'source-over';
            +                                            return this;
            +                                        },
            +                                        ...
            +                                    }
            +                                },
            +                                decorated : false
            +                            });
            +
            +                        
            +
            +
            +

            + This definition is for the StarActor object. MoMa will build a Class object (constructor + function) and assign it to CAAT.Foundation.UI.StarActor, as well as to the aliases + collection CAAT.StarActor. Both objects are the same constructor function. The aliases + block is optional. +

            +

            + To build a new ShapeActor, you can call new CAAT.StarActor() or new CAAT.Foundation.UI.StarActor + interchangeably. +

            +

            + This Class depends on CAAT.Foundation.ActorContainer, meaning that before building this + object class, CAAT.Foundation.ActorContainer and its dependencies will be loaded and solved. + The depends block is optional. +

            +

            + The extendsClass means a ShapeActor is an ActorContainer, and + can have other Actors contained inside. This is a kind of Object Oriented extension + mechanism where ShapeActor has all of ActorContainer's functionality. The extendsClass block + is optional. +

            +

            + The extendsWith clause can be either a function, which must + return an object that will be used as the new Class prototype (and possibly extending + the base Class defined in the extendsClass clause). +

            +

            + CAAT Class definition does not rely on the Constructor function to perform initialization. + Instead, an special function can be defined which must hold construction code. This + function is __init and if present is called from the + constructor function. If you want to chain constructors, the correct way of doing it is + by calling this.__super(arg1, arg2, ...);. +

            +

            + The decorated clause instruments MoMa to create a decorated + Class, which will be slower in execution, but more maintainable. When set to true, MoMa + will make all base class' overriden methods have a __super + attribute. So calling any overriden method will be via: this.__super(arg1, arg2, ...). + If decorated is set to true (default value), calling a super + class' overriden method will be faster in execution, but uglier. For example, for the + ShapeActor example you must call: +

            +
            +
            +                                CAAT.Foundation.UI.ShapeActor.superclass.method.call(this, arg1, arg2, ...);
            +                            
            +
            +
            +
            +
            +
            +

            Creating new Modules

            +
            +

            + For any given Class object, you could extend it, either by defining a new module + which sets an appropriate extendsClass clause or use the legacy + extend(subclass, superclass) function. +

            +

            MoMa module:

            +

            +

            +
            +                                CAAT.Foundation.UI.ShapeActor.extend(
            +                                    {
            +                                        abcd : 1234
            +                                    },
            +                                    {
            +                                        constant : 1
            +                                    },
            +                                    "MyNewClass",
            +                                    [
            +                                        "MyNewClassAlias1"
            +                                    ],
            +                                    decorated : true_or_false
            +                                );
            +                            
            +
            +

            +

            + This code will create a new Class called MyNewClass, which extendsClass CAAT.Foundation.UI.ShapeActor + with abcd:1234, defines a constant: CAAT.Foundation.UI.ShapeActor.constant= 1, creates an alias + MyNewClassAlias1, etc. +

            +

            + From this point, calling new MyNewClass or new MyNewClassAlias1 will have the same effect and + is creating a new Actor instance. +

            +

            Calling legacy extend function

            +

            + The following code: +

            +
            +                                (function() {
            +                                    HN.Chrono= function() {
            +                                        HN.Chrono.superclass.constructor.call(this);
            +                                        return this;
            +                                    };
            +
            +                                    HN.Chrono.prototype= {
            +
            +                                        maxTime:    0,
            +                                        elapsedTime:0,
            +
            +                                        animate : function(director, time) {
            +                                            var size=
            +                                                    this.maxTime!=0 ?
            +                                                            this.elapsedTime/this.maxTime * this.progressHole :
            +                                                            0;
            +                                            // make sure this actor is marked as dirty by calling setSize and not .width=new_size.
            +                                            this.actorcrono.setSize( this.progressHole-size, this.actorcrono.height );
            +
            +                                            return HN.Chrono.superclass.animate.call(this,director,time);
            +                                        }
            +                                    };
            +
            +                                    extend( HN.Chrono, CAAT.ActorContainer);
            +                                })();
            +                            
            +
            +

            +

            + Will create a new Class: HN.Chrono which extendsClass CAAT.ActorContainer. It has the same + effect as calling extend on a Module, or creating a CAAT.Module definition. + This is the way CAAT objects were extended and has full compatibility with current + Modules definition. +

            +

            + Both ways of creating new Actor classes are valid. It is preferred though using the + Module method. +

            +
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/01_getting_started.html b/CAAT/documentation/tutorials/01_getting_started.html new file mode 100644 index 0000000..3a4f554 --- /dev/null +++ b/CAAT/documentation/tutorials/01_getting_started.html @@ -0,0 +1,217 @@ + + + + + + + + CAAT Tutorial 1 - Getting started + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +
            +

            Getting started

            + +

            + To start with CAAT you first need to decide whether your application will be using DOM+CSS, + Canvas or Webgl as rendering engine. +

            + +

            + Under the build folder you'll find two files caat.js (needed to render with + Canvas or WebGL) and caat-css.js to render with DOM+CSS. There're subtle differences + between all three rendering technologies but you'll show no difference if using + CAAT's out-of-the-box animation elements. +

            +

            + In this folder, you can also access caat-box2d.js which is optionally used to bind box2d with + standard CAAT actor objects, as well as minified versions of all those files. +

            +

            + Located under documentation/demos/templates folder you can find two different template + files. Those template files are an starting point which set themselves up for canvas/gl and css + renderers. The developer could use the code in the folder documentation/demos/tempates/startup-wo-splash + as an starting point. The code in the folder documentation/demos/tempates/startup-with-splash + can be used as an starting point for an application with splash. +

            + +

            + Needed steps to setup up a basic CAAT project are: +

            + +
            +
              1. Include the desired renderer library file. In example:
            +
            +
            +                            
            +                        
            +
            +
              2. Create a director object.
            +
              3. Create an scene object.
            +
              4. Add some Actors to the scene object.
            +
              5. Start the animation loop.
            +
            +
            + Templated projects do all these steps at once. +
            +
            + +
            +

            CAAT Startup example

            + +

            One of the minimum CAAT library setup programs could be this one: + + +

            +
            +
            +        // create a director object
            +        var director = new CAAT.Foundation.Director().initialize(
            +                100,    // 100 pixels wide
            +                100,    // 100 pixels across
            +                document.getElementById('_c1')
            +        );
            +
            +        // add a scene object to the director.
            +        var scene=     director.createScene();
            +
            +        // create a CAAT actor
            +        var circle=    new CAAT.Foundation.UI.ShapeActor().
            +                setLocation(20,20).
            +                setSize(60,60).
            +                setFillStyle('#ff0000').
            +                setStrokeStyle('#000000');
            +
            +        // add it to the scene
            +        scene.addChild(circle);
            +
            +        // start the animation loop
            +        CAAT.loop(1);
            +    
            +
            + +

            By executing it, we'll get a black-outlined red circle at position 20,20 and of radius 30. + +

            Despite its simplicity, some facts must be taken into account: +

              +
            1. If using a Canvas/GL renderer CAAT renders on a Canvas object. You can supply one at + CAAT.Director object creation time, or let CAAT create and add one for you.
            2. +
            3. The Director instance is fed with scenes. CAAT.Scene instances are advanced actor containers. + We'll see how the Director manages Scenes, and how to elegantly switch from one to the other. +
            4. Scenes are fed with CAAT.Actor and CAAT.ActorContainer instances in a hierarchycal fashion. +
            5. CAAT.loop must be called to start CAAT event loop. +
            + +

            And that's it, our red circle: + + +

            + +
            + + +
            +

            In this other example, we're not specifying a DOM canvas element to the Director instantiation. + The + director itself will create and append one to the DOM.

            + +
            +
            +    // We are not pointing any canvas in the director creation statement,
            +    // so the director will create a Canvas for us.
            +    var director2 = new CAAT.Foundation.Director().initialize(100,100);
            +
            +    var scene2=     director.createScene();
            +    var circle2=    new CAAT.Foundation.UI.ShapeActor().
            +            setLocation(20,20).
            +            setSize(60,60).
            +            setFillStyle('#ff00ff').
            +            setStrokeStyle('#00ff00');
            +
            +    scene2.addChild(circle2);
            +
            +    CAAT.loop(1);
            +        
            +
            + +
            + +
            + +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor.html new file mode 100644 index 0000000..5edf54d --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor.html @@ -0,0 +1,115 @@ + + + + + + + + CAAT Tutorial 2 - Actors + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Actor

            +

            CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance. + An Actor has entity, it has a size, position and can have input sent to it. Everything that has a + visual representation is an Actor, including Director and Scene objects.

            +

            This object has functionality for:

            +
              +
            1. Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
            2. +
            3. Set affine transforms (rotation, scale and translation).
            4. +
            5. Define life cycle.
            6. +
            7. Manage alpha transparency.
            8. +
            9. Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.
            10. +
            11. Compose transformations. A container Actor will transform its children before they apply their own transformation.
            12. +
            13. Clipping capabilities. Either rectangular or arbitrary shapes.
            14. +
            15. The API is developed to allow method chaining when possible.
            16. +
            17. Handle input (either mouse events, touch, multitouch, keys and accelerometer).
            18. +
            19. Show an image.
            20. +
            21. Show some image animations.
            22. +
            23. etc.
            24. +
            +

            This class is the superclass for other Actors, so it must be specialized to + perform new behaviors. There some out-of-the-box Actors already available in CAAT:

            +
              +
            • Label. Shows multiline text with embedded font styles.
            • +
            • Dock. A container which behaves like OSX's dock.
            • +
            • TextActor. Show single line text with a font or Sprite font.
            • +
            • ShapeActor. Shows rectangles or circles.
            • +
            • StarActor. Shows an star where you can customize number of vertex, radius, etc..
            • +
            • InterpolatorActor. Shows curves for CAAT.Behavior.Interpolator objects.
            • +
            • PathActor. Shows and handles a CAAT.PathUtil.Path object.
            • +
            • ...
            • +
            +

            but as you'll see, developing a new breed of Actors will be just a few lines of code.

            +

            Take a look at Sumon sourcecode: https://github.com/hyperandroid/Sumon which defines lots of new Actors.

            + +

            + One important fact about Actors is the coordinate system. An Actor will always report local coordinates + despite the transformation applied to it. In example, an Actor can be scaled twice widely, and rotated + 45 degrees, and on mouseMove the received event will report local Actor coordinates as if the actor itself + weren't transformed. +

            +

            + Additionally, each actor defines anchors por position, rotation and scale independently. See methods + setPositionAnchor( ax, ay ); setRotateAnchor( ax, ay ); and + setScaleAnchor( ax, ay );. Anchors are defined in relative coordinates, so if for example, + a rotation anchor by an actor's center is to be set, you must call setRotateAnchor(.5,.5); +

            +
            + +
            +

            More info on CAAT.Actor class

            +

            + Events
            + Lifecycle
            + Transformations
            + Behaviors
            + Background Image
            + Paint method
            + Caching
            +

            +
            + + +
            +
            +
            + + + + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Behaviors.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Behaviors.html new file mode 100644 index 0000000..8ce6b45 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Behaviors.html @@ -0,0 +1,218 @@ + + + + + + + + + CAAT Tutorial 2- Actor Behaviors + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + +
            +

            CAAT.Foundation.Actor

            +

            Behaviors

            +

            + An Actor has the abbility to have transformations applied to it which will modify its visual aspect, + but only one value for translation, scale and rotation can be applied at the same time.

            +

            + A behavior has the ability to apply affine transformations to an actor instance during a given perior + of time. Thus a behavior is defined by a frame time, that is, when to start applying the behavior and + during how much time, and what values will be applied. +

            +

            + In example, apply a rotation from 0 to 2*PI radians (360 degrees) from scene time=2000 and take 5000ms + to rotate. +

            +

            + One important thing to note about RotateBehavior and ScaleBehavior is that as in + setScaleAnchored and setRotationAnchored + there's the possibility to set an anchor via a call to the method setAnchor. +

            +

            + But behaviors define anchors in percentage relative to actor's origo whereas + the methods do so in absolute pixel positions. +

            +

            + Here we'll just show an example of actors rotating and scaling on different anchors all that commanded + by behaviors: +

            +

            + Take a look at chapter 3 for a complete disgression on Behaviors ans the built-in behavior types. +

            +
            +
            +
            +                var _director_4= new CAAT.Director().initialize(
            +                        600,
            +                        200,
            +                        document.getElementById('_c4') );
            +
            +                var _scene_4= _director_4.createScene();
            +
            +                // these numbers correspond to anchor values:
            +                // TOP_LEFT     TOP     TOP_RIGHT
            +                // LEFT         CENTER  RIGHT
            +                // BOTTOM_LEFT  BOTTOM  BOTTOM_RIGHT
            +                var anchor= [
            +                    0,0,    .50,0,   1.00,0,
            +                    0,.50,  .50,.50,  1.00,.50,
            +                    0,1.00, .50,1.00, 1.00,1.00
            +                ];
            +
            +                var i;
            +
            +                for( i=0; i<9; i++ ) {
            +
            +                    // background actors under rotating ones. Just to have a reference
            +                    // of where the anchor is.
            +                    var _scene_4_rotating_actor_background = new CAAT.Actor().
            +                            setLocation( 50+50*(i%3), 35+50*((i/3)>>0) ).
            +                            setSize( 30, 30 ).
            +                            setFillStyle('#ffffff').
            +                            setStrokeStyle('#000000').
            +                            // do not accept mouse events.
            +                            enableEvents(false);
            +                    _scene_4.addChild( _scene_4_rotating_actor_background );
            +
            +                    // rotating actors.
            +                    var _scene_4_rotating_actor = new CAAT.Actor().
            +                            setLocation( 50+50*(i%3), 35+50*((i/3)>>0) ).
            +                            setSize( 30, 30 ).
            +                            setFillStyle('#ff0000');
            +                    // never ending rotating behavior
            +                    var _scene_4_rotating_behavior= new CAAT.RotateBehavior().
            +                            setCycle(true).
            +                            setFrameTime( 0, 2000 ).
            +                            setValues(0, 2*Math.PI, anchor[i*2], anchor[i*2+1] );
            +                    _scene_4_rotating_actor.addBehavior( _scene_4_rotating_behavior );
            +                    _scene_4.addChild( _scene_4_rotating_actor );
            +
            +                    // scaling actors
            +                    var _scene_4_scaling_actor= new CAAT.Actor().
            +                            setLocation( 300+60*(i%3), 30+60*((i/3)>>0) ).
            +                            setSize( 30, 30 ).
            +                            setFillStyle('#ff00ff');
            +                    // never ending scaling behavior
            +                    var _scene_4_scaling_behavior= new CAAT.ScaleBehavior().
            +                            setCycle(true).
            +                            setFrameTime( 0, 2000 ).
            +                            setValues( .5, 1.5, .5, 1.5, anchor[i*2], anchor[i*2+1] ).
            +                            setPingPong();
            +                    _scene_4_scaling_actor.addBehavior(_scene_4_scaling_behavior);
            +                    _scene_4.addChild( _scene_4_scaling_actor );
            +                }
            +
            +                CAAT.loop(20);
            +
            +        
            +
            +
            + +
            + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImages.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImages.html new file mode 100644 index 0000000..116162e --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImages.html @@ -0,0 +1,285 @@ + + + + + + + + CAAT Tutorial 2- Actor Background Image + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Actor

            +

            Background Images

            +

            + An actor instance can have a background image. This image is encapsulated into a + CAAT.Foundation.SpriteImage which allows for fine image control. +

            +

            + In order to set the background image, the method + setBackgroundImage(image,set_actor_size_as_image_size) must be called. + The image parameter can be either an HTMLImageElement or a + CAAT.Foundation.SpriteImage instance. +

            +

            + The SpriteImage object encapsulates an image and treats the image as if + it was composed by a bidimensional array of subimages or as a Map of different subimages. + In fact, when passing an instance of HTMLImageElement or + HTMLCanvasElement as parameter + it is transparently encapsulated into a CAAT.Foundation.SpriteImage + of 1 row by 1 column + in size. The SpriteImage allows to identify by index every subimage of the array. +

            +

            + By using this class as image holder, certain capabilities can be given to the background image: +

            + +
              +
            • setAnimationImageIndex( array_of_integers )
              + Define an array of indices over the spriteImage instance. This generates a sprite sequence. +
            • setChangeFPS( number_of_milliseconds )
              + If set, the actor will automatically change background image to the next SpriteImage's subimage in sequence + of the ones defined in the methos setAnimationImageIndex. +
            • setSpriteIndex( integer )
              + If no sprite sequence is defined, this method will make the actor draw on its background the specified + SpriteImage's subimage. +
            • setBackgroundImageOffset( offset_x, offset_y )
              + Set a displacement value to apply to the SpriteImage's subimage. +
            • setImageTransformation
              + Draw the actor's background transformed by one of these values: +
                +
              • CAAT.Foundation.SpriteImage.TR_NONE (default value) +
              • CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL +
              • CAAT.Foundation.SpriteImage.TR_FLIP_VERTICAL +
              • CAAT.Foundation.SpriteImage.TR_FLIP_ALL +
              • CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE (scale the image to fit in the actor size) +
              • CAAT.Foundation.SpriteImage.TR_FIXED_WIDTH_TO_SIZE (scale the image only widely to fit in the actor size) +
              • CAAT.Foundation.SpriteImage.TR_TILE (tile the image to fill the whole actor area with this image repeated) +
              +
            • +
            +
            + +
            +

            Example

            +

            + The following example shows the creation of actors on mousemove over a container. Every of this new + actors has an spriteImage instance of a single stars image which is reused among every star actor instance. +

            +

            + The image used in this code is the following: , + so setting a SpriteImage of one row by six columns will treat each image's piece as an + independent star. +

            + + + + +
            +
            +            function __scene(director) {
            +
            +                var scene= director.createScene();
            +
            +                var bg= new CAAT.Foundation.ActorContainer().
            +                        setBounds(0,0,director.width,director.height).
            +                        setFillStyle('#fff');
            +
            +                scene.addChild(bg);
            +
            +                // create a sprite image of 1 row by 6 columns
            +                var starsImage= new CAAT.Foundation.SpriteImage().
            +                        initialize(director.getImage('stars'), 1,6 );
            +
            +                var T= 1000;
            +
            +                var mouseStars= function(mouseEvent) {
            +
            +                    var actorStar= new CAAT.Foundation.Actor().
            +                        // set background image to be a reference of a SpriteImage instance
            +                        // and set actor's size equal to a SpriteImage's subimage size
            +                            setBackgroundImage( starsImage ).
            +                        // set background as a random SpriteImage's subimage.
            +                            setSpriteIndex( (Math.random()*6)>>0 ).
            +                        // center the actor on mouse position
            +                            centerOn( mouseEvent.x, mouseEvent.y).
            +                        // when the actor expires, remove in from the director
            +                            setDiscardable(true).
            +                        // avoid mouse event handling.
            +                            enableEvents(false).
            +                        // make this actor last to T milliseconds (1000)
            +                            setFrameTime(scene.time, T).
            +                        // add a scaling behavior
            +                            addBehavior(
            +                                new CAAT.Behavior.ScaleBehavior().
            +                                    setFrameTime(scene.time, T).
            +                                    setValues( 1,5, 1,5 ).
            +                                    setInterpolator(
            +                                        new CAAT.Behavior.Interpolator().createExponentialInInterpolator(
            +                                            3,
            +                                            false)
            +                                    )
            +                            ).
            +                        // add an alpha behavior so the actor takes 1000 ms to fade out to zero alpha
            +                            addBehavior(
            +                                new CAAT.Behavior.AlphaBehavior().
            +                                    setFrameTime(scene.time, T).
            +                                    setValues( 1, 0 ) );
            +
            +                    // add the actor.
            +                    bg.addChild(actorStar);
            +                };
            +
            +                // set background's mouse handlers.
            +                bg.mouseMove= mouseStars;
            +                bg.mouseDrag= mouseStars;
            +            }
            +
            +            function __init()   {
            +
            +                var director = new CAAT.Foundation.Director().
            +                        initialize(700,500, document.getElementById('_c1')).
            +                        setClear(false);
            +
            +                new CAAT.Module.Preloader.ImagePreloader().loadImages(
            +                    [
            +                        {id:'stars',    url:'../demos/demo-resources/img/stars.png'}
            +                    ],
            +                    function( counter, images ) {
            +                        director.setImagesCache(images);
            +                        __scene(director);
            +                    }
            +                );
            +
            +                CAAT.loop(60);
            +            }
            +
            +            __init();
            +        
            +
            +
            + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImagesSprites.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImagesSprites.html new file mode 100644 index 0000000..393ef8d --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_BgImagesSprites.html @@ -0,0 +1,113 @@ + + + + + + + + CAAT Tutorial 2- Actor Sprite animations + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Actor

            +

            Sprites Animation

            +

            + CAAT offers fine grained sprite animation control with the methods: +

            +

            +

          • addAnimation( name, images_array, time, onAnimationEndCallback )
          • +
          • playAnimation( name )
          • +

            +

            + For example, the following code: +

            +
            +
            +        var reset= function(spriteImage, time) {
            +            spriteImage.playAnimation("stand");
            +        };
            +
            +        var si= new CAAT.Foundation.SpriteImage().initialize( image, 21, 7).
            +                addAnimation("stand",   [123,124,125, 126,127,128,129,130,131,132], 100).
            +                addAnimation("fall",    [0,1,2,3,4,5,6,7], 100, reset).
            +                addAnimation("wall_ud", [74,75,76, 77,78,79,80,81], 100).
            +                addAnimation("wall_lr", [82,83, 84,85,86,87,88,89], 100).
            +                addAnimation("tidy",    [42,43,44,45,46,47,48, 49,50], 100, reset).
            +                addAnimation("die",     [68,69, 70,71,72,73], 100, reset).
            +                addAnimation("jump",    [95,94,93,92,91, 90], 100, reset).
            +                addAnimation("run_b",   [96,97, 98,99,100,101,102,103,104, 105,106], 30).
            +                addAnimation("run_f",   [122,121,120,119, 118,117,116,115], 30).
            +                addAnimation("sad",     [26,27, 28,29,30,31,32,33], 100);
            +
            +        actor.setBackgroundImage(si).playAnimation("fall");
            +        
            +
            +

            + will create an spriteImage instance with several animations. The animations are defined in this case + as indexes into an array of 21x7 elements over the image supplied as parameter. + For example, the "fall" animation uses the following animation [0,1,2,3,4,5,6,7] and will rotate + among these images every 100 milliseconds. Additionally, when it has ended playing the sequence, + the callback function "reset" will be invoked. +

            +

            + It is safe to change an animation in the callback function, and should be the preferred way to go. +

            +

            + In the sample, we're using addAnimation directly on the SpriteImage + instance. This is valid since an actor's addAnimation and + playAnimation methods simply delegate the call to their background + image SpriteImage instance. +

            +

            + It is important to note that a shared SpriteImage object instance via a call to its + getRef() method, shares the sprite's animations definition with + the original SpriteImage object. This + means that changing a animation duration or the sprite sequence for an SpriteImage will be changed + for all actors sharing that SpriteImage. +

            + +

            + Click here for a complete sprite management example. +

            + + + + + + + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_CacheAsBitmap.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_CacheAsBitmap.html new file mode 100644 index 0000000..7019552 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_CacheAsBitmap.html @@ -0,0 +1,318 @@ + + + + + + + CAAT Tutorial 1 - Getting started + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Foundation.Actor

            +

            Caching actors as bitmaps

            +
            +

            + The method cacheAsBitmap(time, strategy) creates an image representation of the actor the + method is invoked for. The main objective is to cache complex drawing routines into an image to avoid + recreating it constantly. It is suited for example for TextActors whom drawing operations are quite + expensive or for any custom drawing actor. +

            +

            + The time parameter is used to specify at what virtual time you'd like to have the actor cached. + CAAT uses a timeline for each scene, so different time values could give different cached images. +

            +

            + The strategy parameter can be either +

          • CAAT.Foundation.Actor.CACHE_SIMPLE
          • +
          • CAAT.Foundation.Actor.CACHE_DEEP
          • +

            +

            + CACHE_SIMPLE means the cache will only be applied to the Actor or Container. CACHE_DEEP + for a container means that the Container and all of its children will be cached in the same + image. This can dramatically speed drawing operations at the cost of creating new in-memory + images. +

            +

            + Any CAAT.Foundation.Actor instance already takes care of drawing the cached image instead + of the stroked/filled text. It is developers responsibility to do it if the + paint or paintActorGL methods have been overridden. +

            +

            + The method stopCacheAsBitmap() will make the actor not being cached + anymore, and its paint method will be called again. +

            +

            + As it was expected, the cached image will be wrapped into a + CAAT.Foundation.SpriteImage + of one row by one column. That means if the cached image is to be accessed in a webGL environment + (or just needs be accessed) it could be obtained the associated HTMLCanvasElement by calling + actor.backgroundImage.image. +

            +
            +
            +

            + In the following example, a container is being cachedAsBitmap. On the left, it uses CACHE_SIMPLE, + which means that the container caches itself, but still makes calls to animate and paint its + children. The proof about it, is that the container is smaller than its children but still + shows completely the children. +

            +

            + In the right, it uses CACHE_DEEP. The container and its children have been cached in an image, + preventing CAAT from traversing the container and its children for animation and painting. + That's the reason why the content is clipped, since it was drawn in an smaller image than needed. +

            +
            +
            + +
            +

            Example

            +

            + The following example shows some leaning cached text actors. +

            +
            +
            +
            +
            +                function __scene(director) {
            +
            +                    var scene= director.createScene();
            +
            +                    var t1= text( director, scene, CAAT.Foundation.Actor.CACHE_SIMPLE, "CACHE_SIMPLE" );
            +                    var t2= text( director, scene, CAAT.Foundation.Actor.CACHE_DEEP, "CACHE_DEEP" );
            +
            +                    t1.centerAt( director.width/2/2, director.height/2 );
            +                    t2.centerAt( director.width/2/2 + director.width/2, director.height/2 );
            +
            +                    scene.addChild(t1);
            +                    scene.addChild(t2);
            +
            +                }
            +
            +                function text(director, scene, hint, name) {
            +
            +                    var cc1 = new CAAT.Foundation.ActorContainer( ).
            +                            setBounds(0, 100, 300, 300).
            +                            enableEvents(false);
            +
            +                    cc1.addBehavior(
            +                            new CAAT.Behavior.RotateBehavior().
            +                                    setCycle(true).
            +                                    setFrameTime(0, 4000).
            +                                    setValues(-Math.PI / 8, Math.PI / 8, .50, 0).    // anchor at 50%, 0%
            +                                    setInterpolator(
            +                                    new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(3, true))
            +                            );
            +
            +                    var gradient = director.ctx.createLinearGradient(0, 0, 0, 50);
            +                    gradient.addColorStop(0, '#00ff00');
            +                    gradient.addColorStop(0.5, 'red');
            +                    gradient.addColorStop(1, 'blue');
            +
            +                    var font= "36px sans-serif";
            +
            +                    var text = new CAAT.Foundation.UI.TextActor().
            +                            setFont(font).
            +                            setText("This Container").
            +                            setAlign("center").
            +                            setTextFillStyle(gradient).
            +                            setOutline(true).
            +                            setOutlineColor('white');
            +                    cc1.addChild(text.setLocation(cc1.width / 2, 0));
            +
            +                    var text2 = new CAAT.Foundation.UI.TextActor().
            +                            setFont(font).
            +                            setText("is Cached as Bitmap").
            +                            setAlign("center").
            +                            setTextFillStyle(gradient).
            +                            setOutline(true).
            +                            setOutlineColor('white');
            +                    cc1.addChild(text2.setLocation(cc1.width/2, 50));
            +
            +                    var text4 = new CAAT.Foundation.UI.TextActor().
            +                            setFont(font).
            +                            setText("Using " + name).
            +                            setAlign("center").
            +                            setTextFillStyle(gradient).
            +                            setOutline(true).
            +                            setOutlineColor('white');
            +                    cc1.addChild( text4.setLocation(cc1.width/2, 100) );
            +
            +                    var text3 = new CAAT.Foundation.UI.TextActor().
            +                            setFont(font).
            +                            setText("as caching strategy").
            +                            setAlign("center").
            +                            setTextFillStyle(gradient).
            +                            setOutline(true).
            +                            setOutlineColor('white');
            +                    cc1.addChild(text3.setLocation(cc1.width/2, 150));
            +
            +                    cc1.cacheAsBitmap(1000,hint);
            +
            +                    return cc1;
            +                }
            +
            +                function __init()   {
            +
            +                    var director = new CAAT.Foundation.Director().
            +                            initialize(700,500, document.getElementById('_c1'));
            +
            +                    __scene(director);
            +
            +                    CAAT.loop(30);
            +                }
            +
            +                __init();
            +
            +            
            +
            + + +
            + + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Clip.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Clip.html new file mode 100644 index 0000000..3b93013 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Clip.html @@ -0,0 +1,368 @@ + + + + + + + + CAAT Tutorial 2- Actor clip + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Foundation.Actor

            + +

            Clip

            + +
            +

            + Clipping is by default disabled on CAAT. Enabling it results in slower performance, so it + must be treated carefully. It can be enabled globally by setting + CAAT.Foundation.Actor.prototype.clip= true. + +

            + Optionally, you can enable/disable clipping for individual actors by + calling the method setClip(bool, path). +

            +

            + Parameters for this method are: +

              +
            • a boolean indicating whether clip is enabled.
            • +
            • path. This parameter is optional. If not supplied, a rectangle equal + to the actor size will be used as clipping area. If set, this parameter + must be a CAAT.Path instance. This + CAAT.PathUtil.Path can also have + CAAT.Foundation.Behavior + objects applied. It will only honor CAAT.Behavior.ScaleBehavior, + CAAT.Behavior.RotateBehavior and + CAAT.Behavior.PathBehavior object instances, so that the mask + can be rotating, scaling and translating all together.
            • +
            +

            +

            + The following sample code could be used to define a CAAT.PathUtil.Path instance as + clip area as well as adding some behaviors to the clipping mask. +

            +
            +
            +
            +            // define a path
            +            var path =
            +                        new CAAT.Path().
            +                                beginPath(100, director.height / 2).
            +                                addCubicTo(
            +                                100, 10,
            +                                director.width - 100, 10,
            +                                director.width - 100, director.height / 2).
            +                                addCubicTo(
            +                                director.width - 100, director.height - 10,
            +                                100, director.height - 10,
            +                                100, director.height / 2).
            +                                closePath();
            +
            +            // define another path instance to make the traverse traverse across.
            +            var traversePath= new CAAT.Path()...;
            +
            +            // add to the mask a behavior to traverse the path,
            +            path.addBehavior(
            +                new CAAT.PathBehavior().
            +                    setValues( traversePath ).
            +                    setFrameTime( 0,15000 ).
            +                    setCycle( true ).
            +                    setTranslation( path2.width/2, path2.height/2 )
            +            // and a rotation, so that it rotates while traversing.
            +            ).addBehavior(
            +                new CAAT.RotateBehavior().
            +                    setValues( 0,Math.PI*2 ).
            +                    setFrameTime( 0,5000 ).
            +                    setCycle( true )
            +            // add as much as needed.
            +            ).addBehavior(
            +                ...
            +            );
            +
            +            // enable clip on a CAAT.Actor instance (container, button, whichever) with
            +            // the given path shape as clip area.
            +            actor.setClip( true, path );
            +                
            +
            + +

            + This method is a powerful feature which allow to set arbitrary paths as clippling + areas. See this example for a visual demo. +

            +

            + Clip will work only on canvas and DOM/CSS renderers. + GL won't have any clip applied. Arbitrary clip areas can + only be used on Canvas renderer. +

            +
            +
            + +
            +

            Example

            + +

            + This example allows dragging of shown actors. + Use shift+alt+control to modify default drag behavior. + One of the Scene Actors will have clipping enabled. You'll see that in one instance you're + able to drag the inner green Actor outside the Magenta one area. + But after dropping it outside + its parent area, you won't be able to gain mouse control over the inner Actor again. + This is because of the way CAAT routes events to its Actors. In order to send an + event to an Actor, the Actor must be contained into its parent area. Period. +

            +

            + It also defines an elliptical clip area on the scene. +

            + +
            + +
            + +
            +
            +
            +                var _director_5= new CAAT.Director().initialize(
            +                        600,
            +                        200,
            +                        document.getElementById('_c5') );
            +
            +                var _scene_5= _director_5.createScene().setFillStyle('#c0c0c0');
            +
            +                for(var i=0; i<2; i++ ) {
            +
            +                    // rectangle shaped actors of 80x80 pixels.
            +                    var s = 80;
            +
            +                    // containers can contain other actors or containers.
            +                    var _c5_container = new CAAT.ActorContainer().
            +                            setBounds(i*400+10, 20, s, s).
            +                            setRotation( Math.PI*2*Math.random() ).
            +                            setFillStyle('#ff3fff').
            +                            enableDrag().
            +                            setClip( i==0 );
            +
            +                    // set container paint routine to draw an arrow
            +                    _c5_container.paint= function(director, time) {
            +
            +                        var crx= director.ctx;
            +
            +                        // fill actor
            +                        crx.fillStyle= this.fillStyle;
            +                        crx.fillRect(0,0,this.width,this.height );
            +
            +                        // outline it.
            +                        crx.strokeStyle= 'black';
            +                        crx.strokeRect(0,0,this.width,this.height );
            +
            +                        // draw a white arrow. just to point where position 0,0 is.
            +                        crx.strokeStyle='white';
            +                        crx.beginPath();
            +                        crx.moveTo(5,10);
            +                        crx.lineTo(20,10);
            +                        crx.lineTo(15,5);
            +
            +                        crx.moveTo(20,10);
            +                        crx.lineTo(15,15);
            +
            +                        crx.lineWidth=2;
            +                        crx.lineJoin='round';
            +                        crx.lineCap='round';
            +
            +                        crx.stroke();
            +                    };
            +
            +                    // add actor to scene.
            +                    _scene_5.addChild(_c5_container);
            +
            +                    // create a container.
            +                    var _c5_container_child= new CAAT.ActorContainer().
            +                            setBounds(s/2,s/2,s/4,s/4).
            +                            setRotation( Math.PI*2*Math.random() ).
            +                            setFillStyle('#00ff00').
            +                            enableDrag();
            +
            +                    // set a custom paint function for children inside containers.
            +                    _c5_container_child.paint= function(director,time) {
            +                        // call default container paint method.
            +                        CAAT.ActorContainer.superclass.paint.call(this,director,time);
            +                        var ctx= director.ctx;
            +
            +                        // fill a white circle of 10x10 pixels at position 2,2
            +                        // just to show where 0,0 is positioned on screen.
            +                        ctx.fillStyle='white';
            +                        ctx.beginPath();
            +                        ctx.arc(7,7,5,0,2*Math.PI,false);
            +                        ctx.fill();
            +                    }
            +
            +                    // add this container as a child of the previous created container.
            +                    _c5_container.addChild(_c5_container_child);
            +
            +                    );
            +
            +                    // set an elliptical clip area
            +                    _scene_5.setClip(
            +                        true,
            +                        new CAAT.Path().
            +                            beginPath(10,_director_5.height/2).
            +                            addCubicTo(
            +                                10,10,
            +                                _director_5.width-10,10,
            +                                _director_5.width-10,_director_5.height/2 ).
            +                            addCubicTo(
            +                                _director_5.width-10,_director_5.height-10,
            +                                10, _director_5.height-10,
            +                                10, _director_5.height/2 ).
            +                            closePath()
            +                    );
            +
            +                }
            +
            +                CAAT.loop(20);
            +
            +            
            +
            + +
            + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Events.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Events.html new file mode 100644 index 0000000..c5f175b --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Events.html @@ -0,0 +1,416 @@ + + + + + + + CAAT Tutorial 2 - Actor Events + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +

            CAAT.Actor

            + +
            +

            Input system

            +
            + CAAT input system works in two ways. +
            +
            + By default every Actor has input enabled (mouse/touch). The system traverses the scene graph + in-orderly trying to find what Actor will have input events routed to. The main issue with this + way of input routing is that children which lie out of its parent bounds won't be able to have + input events sent. To prevent this, a CAAT.Foundation.ActorContainer + can be created with CAAT.Foundation.ActorContainer.AddHint.CONFORM so + that it will conform its size by computing their children bounding box. +
            +
            + The other way of going with input are input lists. These lists, are managed by the methods +
              +
            • enableInputList(number): number of priority lists to set for this scene. + A priority list is a list of actors you want to receive input first. + If no actor on the priority lists are under the cursor/touch, the whole scene graph is + traversed instead, as if no priority list existed. +
            • addActorToInputList( actor, index, position ): + add an actor to a given priority list at certain position. +
            • emptyInputList( index ): + remove all elements from a list. +
            • removeActorFromInputList( actor, index ): + remove an actor from the list identified by index. +
            +
            +
            + The input lists change the input semantics so that the developer can decide what scene graph actors + will be immediately tested to have input sent. This procedure bypasses the + container size restriction making non prioritized actors behave as if they were not on screen + regarding input events. +
            +
            + To globally disable input for every scene actor, you can set + CAAT.Foundation.Actor.prototype.mouseEnabled= false; + and then a call to actor.enableEvents(true); must be explicitly + called to enable input for any given actor. +
            +
            + +

            Actor Input Events

            + +

            An Actor instance has mouse events enabled by default. The mouse control methods are the following:

            +
              +
            • function mouseEnter(mouseEvent)
              Triggered whenever the mouse + enters the rectangular area of an Actor. CAAT will perform perfect pixel collision regardless the + transformation an actor has applied. See demo4 + for a demo on this fact. +
            • +
            • mouseExit(mouseEvent)
              Exactly like in mouseEnter, but when leaving + the Actors bounding box. +
            • +
            • mouseMove(mouseEvent)
              Triggered whenever the mouse arrow + traverses inside the Actor's bounding box. +
            • +
            • mouseDown(mouseEvent)
              Triggered whenever we press the mouse + button inside the Actor's contour. +
            • +
            • mouseUp(mouseEvent)
              Same as mouseDown but when releasing the mouse + button. +
            • +
            • mouseClick(mouseEvent)
              Triggered whenever a click has been generated + on the Actor. That means that previously a mouseDown and then a mouseDown have been triggered on the Actor. + A mouseClick event won't be received if any mouseDrag has been detected. +
            • +
            • mouseDblClick(mouseEvent)
              Same as mouseClick but double click.
            • +
            • mouseDrag(mouseEvent)
              Triggered after we perform an equivalent to + mouseMove after having done mouseDown. After dragging, when releasing the mouse button, only + mouseUp will be triggered avoiding to trigger mouseClick event. +
            • +
            +

            All these methods receive a unique parameter of type CAAT.Event.MouseEvent. It contains + the following information:

            +
              +
            • screenPoint
              The 2D point of the screen coordinate that originated the mouse event.
            • +
            • x,y the same as screenPoint but w/o being wrapped in an object.
            • +
            • point
              The 2D point of local Actor coordinates. Remember that local coordinates are from (0,0) to + actor's + (width,height). These 2D point is derived from the screenPoint. +
            • +
            • modifiers
              Modifiers will tell you whether some special keys where pressed during the mouse input. + The CAAT.Event.MouseEvent class has some methods to check for these special keys. +
            • +
            • time
              The Scene time (more on this later) at which the event was produced.
            • +
            • source
              The actor the event was produced at.
            • +
            + +
            +

            Multitouch

            +

            + CAAT also supports multitouch features but they must be explicitly enabled. See + demo22 for a multitouch example.. Single touch and + multitouch can't run at the same time, but can switch from multitouch to mouse/single touch by setting + a global variable. +

            +

            + First of all, multitouch must be enabled by setting CAAT's global variable + CAAT.TOUCH_BEHAVIOR to CAAT.TOUCH_AS_MULTITOUCH; + like: CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH; +

            +

            + To get back to single touch/mouse, set the variable to CAAT.TOUCH_AS_MOUSE + value. +

            +

            + From this point, CAAT actors will be notified to multitouch control functions: +

            +
              +
            • touchStart(mouseEvent); +
            • touchMove(mouseEvent) +
            • touchEnd(mouseEvent) +
            • gestureStart(rotation, scaleX, scaleY) +
            • gestureChange(rotation, scaleX, scaleY) +
            • gestureEnd(rotation, scaleX, scaleY) +
            +

            + touchStart, touchMove and touchEnd receive a CAAT.Event.MouseEvent object instance. +

            +

            + gestureStart, gestureChange and gestureEnd receive a value from 0 to 2*PI for rotation, and values + from 0 to N for scaleX and scaleY. +

            +

            + CAAT actors receive gesture events by default, there's no need to enable multitouch. The method + setGestureEnagled(bool) and isGestureEnabled() => bool + control default behavior for gestures which are pinch and zoom capabilities. You can define your + own behavior by redefining gesture methods. See + demo4 for gesture support. +

            +
            +
            + +
            +

            Input control

            +

            + If an Actor instance is not supposed to process input from mouse, a call to enableEvents(false) + must be explicitly called. This method can be called at any given time with a boolean parameter to set + or reset mouse handling. +

            + +

            + Two methods of CAAT.Foundation.Actor instances will change default mouse event handling methods for others: +

              +
            • + function enableEvents(bool). Will enable/disable mouse/touch/multitouch + in an Actor. +
            • +
            • function enableDrag(). Will set mouse methods to allow an actor + instance's drag. Some drag modifiers such as shift, control and shift+control will change actor's rotation + and scale. +
            • +
            • + function setAsButton(). Will set mouse methods to allow a given actor behave + as a button. +
            • +
            +

            +

            + Other input types such as keys and accelerometer are handled directly by + CAAT.Foundation.Director instances. +

            + +
            + +
            +

            Example

            + +

            In this example, you can see some rectangle-shaped actors with other rectangle child inside.

            + +

            A CAAT.ActorContainer can contain any number of Actors and hence any number of other ActorContainer + instances.

            + +
            +
            +            var director_1 = new CAAT.Foundation.Director().initialize(
            +                    600,120,
            +                    document.getElementById('_c1'));
            +
            +            var scene_1=     director_1.createScene().setFillStyle('#fff');
            +            
            +            // make the scene clear background and draw a black rectangle
            +            scene_1.paint= function(director, time) {
            +                var ctx= director.ctx;
            +                ctx.fillStyle= this.fillStyle;
            +                ctx.fillRect(0,0,this.width,this.height);
            +                ctx.strokeStyle= '#000';
            +                ctx.strokeRect(0,0,this.width-1,this.height-1);
            +            }
            +
            +
            +            // create six actors for this scene.
            +            for(var i=0; i<6; i++ ) {
            +
            +                // rectangle shaped actors of 80x80 pixels.
            +                var s = 80;
            +
            +                // containers can contain other actors or containers.
            +                var _c1_container = new CAAT.Foundation.ActorContainer().
            +                        setBounds(i*100+10, 20, s, s).
            +                        setRotation( Math.PI*2*Math.random() ).
            +                        setFillStyle('#ff3fff').
            +                        enableDrag();
            +
            +                _c1_container.name = 'rectangle'+i;
            +                // set container paint routine to draw an arrow
            +                _c1_container.paint= function(director, time) {
            +
            +                    var crx= director.ctx;
            +
            +                    // fill actor
            +                    crx.fillStyle= this.fillStyle;
            +                    crx.fillRect(0,0,this.width,this.height );
            +
            +                    // outline it.
            +                    crx.strokeStyle= 'black';
            +                    crx.strokeRect(0,0,this.width,this.height );
            +
            +                    // draw a white arrow. just to point where position 0,0 is.
            +                    crx.strokeStyle='white';
            +                    crx.beginPath();
            +                    crx.moveTo(5,10);
            +                    crx.lineTo(20,10);
            +                    crx.lineTo(15,5);
            +
            +                    crx.moveTo(20,10);
            +                    crx.lineTo(15,15);
            +
            +                    crx.lineWidth=2;
            +                    crx.lineJoin='round';
            +                    crx.lineCap='round';
            +
            +                    crx.stroke();
            +                };
            +
            +                // add actor to scene.
            +                scene_1.addChild(_c1_container);
            +
            +                // create a container.
            +                var _c1_container_child= new CAAT.Foundation.ActorContainer().
            +                        setBounds(s/2,s/2,s/4,s/4).
            +                        setRotation( Math.PI*2*Math.random() ).
            +                        setFillStyle('#00ff00').
            +                        enableDrag();
            +
            +                // set a custom paint function for children inside containers.
            +                _c1_container_child.paint= function(director,time) {
            +                    // call default container paint method.
            +                    CAAT.Foundation.ActorContainer.superclass.paint.call(this,director,time);
            +                    var ctx= director.ctx;
            +
            +                    // fill a white circle of 10x10 pixels at position 2,2
            +                    // just to show where 0,0 is positioned on screen.
            +                    ctx.fillStyle='white';
            +                    ctx.beginPath();
            +                    ctx.arc(7,7,5,0,2*Math.PI,false);
            +                    ctx.fill();
            +                }
            +
            +
            +                // add this container as a child of the previous created container.
            +                _c1_container.addChild(_c1_container_child);
            +            }
            +
            +            // set animation to 10fps.
            +            CAAT.loop(10);
            +        
            +
            + +
            +
            + +
            +
            + +
            + +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_LifeCycle.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_LifeCycle.html new file mode 100644 index 0000000..5fd9328 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_LifeCycle.html @@ -0,0 +1,216 @@ + + + + + + + + CAAT Tutorial 2 - Actors Lifecycle + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +
            +

            CAAT.Foundation.Actor

            +

            Life cycle

            +

            An actor by default is shown in the Scene as soon as the Scene is showing, and lasts forever. + But the life cycle can be limited to certain range of time on the Scene timeline. + By calling the method setFrameTime( start_time, duration ) an actors lifecycle can + be controlled.

            + +

            + While the Scene time is less than actor's start_time or the Scene time is bigger than actor's start_time+duration, + the Actor is considered to be out of frame time. Otherwise the Actor is considered to be in frame time + and will be processed, have beaviors applied and probably be drawn on screen. +

            + +

            + When the Scene time is greater than Actor.start_time+Actor.duration, besides out of frame time, the actor + is considered to be expired. This is a readonly property by calling the method + isExpired(). + An Actor will only be set as Expired once. During this expiration setting, an + Actor will notify its registered life cycle listeners. + One of these listeners could for instance reset the Actor's frame time to let the Actor be again in + frame time. +

            + +

            + An actor's destroy operation can be delegated to CAAT by flagging an actor as discardable + by calling the method setDiscardable(true). + By default an Actor is non discardable. + This means that at the end of a Director's frame cycle, that is, when finished processing + and rendering a frame, every Actor that is expired, and flagged as discardable, will be + thrown away from the scene and properly destroyed. + This means that the Actor won't be drawn again since it is not + present at Scene's Actor list anymore. The destroyed actor will also be removed from its parent. + Upon destruction, the Actor will notify its listeners about this fact by calling the + listener life cycle. +

            + +

            Life cycle listener

            + +

            + An Actor has some methods to expose its lifecycle to third party interested entities.

            + +

            + The actor methods addListener( actor_life_cycle_listener ), + removeListener( actor_life_cycle_listener ) and + fireEvent( event_type, time ) control an actor's lifecycle notification +

            + +

            + The developer has only control over the add/remove methods, and it is the Director/Scene + animation cycle that will notify the life cycle changes to interested parties for us by + calling actor's fireEvent method.

            +

            + The Actor life cycle listener must be an object with a method of the form +

            +

            + + { + actorLifeCycleEvent : function( actor_ref, event_type, time) { + } + } + +

            + + +

            This method will receive on its parameters:

            +
              +
            • actor_ref: A reference to the actor that is notifying its life cycle events. It is necessary + since the developer can reuse the same listener for different Actors, and surely would + like to know which of them is notifying about the event
            • +
            • event_type: Event type. It must be one of these string values: + expired, destroyed. + The minimum action a life cycle Actor listener must perform is remove himself as listener, + so that all references to the destroyed Actor are removed and the garbage collector could + do its job properly.
            • +
            • time: the Scene time at which the Actor has been destroyed.
            • +
            +

            +

            Here's some sample code featuring life cycle listener. It is a green-colored pulsating rectangle. + This Actor is in frame time since the Scene started, and will last for two seconds. After these two + seconds, the life cycle listener is notified about Actor expiration, which will stablish again + Actor's lifecycle to start again one second after notification and lasting for two more seconds.

            + +
            +
            +                 // Initialize director.
            +                 var _director_2= new CAAT.Foundation.Director().initialize(
            +                         400,
            +                         100,
            +                         document.getElementById('_c2'));
            +
            +                 // create scene.
            +                 var _scene_2=    _director_2.createScene();
            +
            +                 // create a simple actor. will last for two seconds on Scene.
            +                 var _pulsating_actor_2= new CAAT.Foundation.Actor().
            +                         create().
            +                         setBounds(10,10,80,80).
            +                         setFillStyle('#00ff00').
            +                         setFrameTime(0,2000);
            +
            +                 // add a life cycle listener to the actor.
            +                 _pulsating_actor_2.addListener( {
            +                     actorLifeCycleEvent : function( actor, event_type, time ) {
            +
            +                         // on expiration notification,
            +                         if ( event_type==='expired' ) {
            +                             // just make the Actor sleep for 1 second.
            +                             // After waking up, last for 2 seconds.
            +                             actor.setFrameTime( time+1000, 2000 );
            +                         }
            +                     }
            +                 } );
            +
            +                 // don't forget to add the actor to the scene.
            +                 _scene_2.addChild( _pulsating_actor_2 );
            +
            +                 // set 20 fps animation
            +                 CAAT.loop(20);
            +        
            +
            + +
            +
            + +
            +
            + + + +
            +
            +
            + + + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Multitouch.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Multitouch.html new file mode 100644 index 0000000..d8d27f5 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Multitouch.html @@ -0,0 +1,103 @@ + + + + + + + CAAT Tutorial 2 - CAAT.Actor Touch events + + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +

            CAAT.Foundation.Actor

            +

            Actors touch events

            + +

            + CAAT offers out-of-the-box multitouch support. +

            +

            + The framework, is smart enough to route to any given actor, only touch information relating to it. + So multitouch events on a canvas/DOM element, can lead to touch events being routed to different + actors. +

            +

            + Multitouch, is disabled by default in favor of a touch-as-mouse multitouch behavior. CAAT can't + switch from touch-as-mouse to multitouch at will, so this feature must be selected previously to + creating a CAAT.Director object instance. +

            +

            + Gestures, where available, and if the actor has setGestureEnabled(bool) + will also be delivered to the actor identified by the first registered touch event. +

            +

            + The CAAT.TOUCH_BEHAVIOR internal variable can be assigned to: +

          • CAAT.TOUCH_AS_MOUSE, which is the default value
          • +
          • CAAT.TOUCH_AS_MULTITOUCH, which enables multitouch support.
          • +

            +

            + Touch events, will be notified to the following Actor functions: +

          • touchStart( CAAT.TouchEvent )
          • +
          • touchMove( CAAT.TouchEvent )
          • +
          • touchEnd( CAAT.TouchEvent )
          • +

            +

            + Gestures, when explicitly enabled on an Actor, will be notified to the following Actor functions: +

          • gestureStart( rotation, scaleX, scaleY )
          • +
          • gestureEnd( rotation, scaleX, scaleY )
          • +
          • gestureChange( rotation, scaleX, scaleY ). This + method, by default, handles rotation and scale of the Actor, and must be overriden + if this behavior is not desired.
          • +

            +

            + Each device, will support a different number of touch events at the same time. Regardless of this + number, CAAT will find each touch affected Actor, and call those Touch handling methods with an + instance of CAAT.TouchEvent. This class, resembles a regular browser touch event object, and contains + touch information in its members: +

          • touches list of current active touches.
          • +
          • changedTouches list of affected touches.
          • +

            + +
            +
            +

            + Refer to this demo + with a touch enabled device to test its multitouch capabilities. +

            +
            +
            +
            +
            + + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_PaintMethod.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_PaintMethod.html new file mode 100644 index 0000000..fc327df --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_PaintMethod.html @@ -0,0 +1,285 @@ + + + + + + + + + CAAT Tutorial 2- Actor paint method + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + + +
            +

            CAAT.Actor

            +

            Actor Paint method

            +
            +

            + The method paint(director, time) allows developers to create + custom drawing routines. + Default paint method implementation manages background image and/or color. +

            +

            + With the director parameter, the developer can get directly a canvas 2D rendering context by + accessing the attribute director.ctx. This context instance is in save state, that means CAAT + has already stacked transformations, transparency, etc. so the developer simply can issue + context drawing commands w/o worrying about context state. Don't waste your time calling ctx.save() + and restore(). +

            +

            + See + Sumon's source code for multiple paint method overriding examples. +

            +
            +
            +

            Override correctly

            +

            + When overriding the paint method, you must take into account that CAAT actors can be cached. + This is done by calling cacheAsBitmap( time, hint ); as explained + in Actor CacheAsBitmap. +

            +

            + A correct paint custom implementation must honor a cached as bitmap actor, with the following code: +

            +
            +
            +                actor.paint= function( director, time ) {
            +                    if ( this.isCached() ) {
            +                        <Class_that_extends_Actor_or_ActorContainer>.prototype.paint.call(this,director,time);
            +                        return;
            +                    }
            +
            +                    // Add your custom paint code here.
            +                }
            +
            +            
            +
            +
            +

            Actor Paint method (WebGL)

            +
            +

            + When dealing with WebGL enabled contexts, the paintActorGL(director,time) + will be called. +

            +

            + The developer must take into account that the context instance is not a 2D rendereing + context but a webGL one, so the rendering context drawing primitives are not available. +

            +

            + CAAT only offers availability to draw polylines and must be improved the way it does so + take this possibility with care. This method will be changed shortly as well as more + drawing primitives will be added. +

            +
            +

            Actor Paint method (CSS/DOM)

            +
            + Since DOM/CSS can't handle any drawing primitive, in this renderer the paint method is simply + ignored. +
            +
            + +
            +

            Example

            +

            + The following example shows an actor which faces an arrow to the mouse position. +

            +
            +
            +
            +            function __scene(director) {
            +
            +                var scene= director.createScene();
            +
            +                var bg= new CAAT.ActorContainer().
            +                        setBounds(0,0,director.width,director.height);
            +
            +                // custom paint: stroke a bounding rectangle
            +                bg.paint= function(director,time) {
            +                    var ctx= director.ctx;
            +                    ctx.stokeStyle='black';
            +                    ctx.strokeRect(0,0,bg.width,bg.height);
            +                };
            +
            +                scene.addChild(bg);
            +
            +                var arrow= new CAAT.Actor().
            +                        setBounds(0,0,director.width,director.height).
            +                        enableEvents(false);
            +                bg.addChild(arrow);
            +
            +                // custom paint: draw a proportional arrow
            +                // DOES NOT HONOR CACHED_AS_BITMAP ACTORS !!!
            +                arrow.paint= function(director, time) {
            +
            +                    var ctx= director.ctx;
            +                    var gap= 80;
            +
            +                    // build a random color
            +                    var color= 'rgb(';
            +                    color+= time%255;
            +                    color+=',';
            +                    color+= (time>>8)&255;
            +                    color+=',';
            +                    color+= 0xa0;
            +                    color+=')';
            +
            +                    ctx.strokeStyle= color;
            +                    ctx.beginPath();
            +                    ctx.moveTo(gap, bg.height / 2);
            +                    ctx.lineTo(bg.width - gap, bg.height/2);
            +                    ctx.lineTo( bg.width - gap - (bg.height / 4), bg.height / 4);
            +
            +                    ctx.moveTo(bg.width - gap, bg.height/2);
            +                    ctx.lineTo(bg.width - gap - (bg.height / 4), bg.height / 2 + bg.height / 4);
            +
            +                    ctx.lineWidth=15;
            +                    ctx.lineJoin='round';
            +                    ctx.lineCap='round';
            +
            +                    ctx.stroke();
            +                };
            +
            +                // make the arrow face the mouse position
            +                bg.mouseMove= function(e) {
            +                    var angle= Math.atan2(
            +                            e.y - arrow.height / 2,
            +                            e.x - arrow.width / 2 );
            +                    arrow.setRotation(angle);
            +                }
            +            }
            +
            +            function __init()   {
            +
            +                var director = new CAAT.Director().
            +                        initialize(500,500, document.getElementById('_c1'));
            +
            +                __scene(director);
            +
            +                CAAT.loop(30);
            +            }
            +
            +            __init();
            +
            +        
            +
            + + +
            + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_SetAsButton.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_SetAsButton.html new file mode 100644 index 0000000..93b7d6a --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_SetAsButton.html @@ -0,0 +1,168 @@ + + + + + + + CAAT Tutorial 2 - CAAT.Actor as a button + + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +

            CAAT.Foundation.Actor

            +

            Actors as buttons

            + +

            + A CAAT.Actor instance can behave as a button simply by invoking the method + setAsButton( sprite_image, normal, over, press, disabled, on_click). +

            +

            + This methos instruments that this actor will set as its background image the suplied + sprite_image and that its size will be set equivalent to a sprite_image's subimage. + The normal, over, press, disabled are sprite_image's + subimage indexes indicating which subimage to use under the buttons states described + by the parameters. +

            +

            + The on_click parameter is a callback function that will be invoked upon button click. + This function receives the button itself as parameter.. +

            +
            +
            +
            +

            + In this example, we're setting up a button and showing an alert upon click. + We'll be using a common CAAT's template for this sample. +

            +
            +
            +                            
            +
            +
            +                            window.addEventListener(
            +                                    'load',
            +                                    function() {
            +                                        CAAT.Module.Initialization.Template.init(
            +                                                800, 100,
            +                                                '_c1',
            +                                                [
            +                                                    {id:'botones', url:'resource/botones.png'}
            +                                                ],
            +                                                __scene1
            +                                                );
            +                                    },
            +                                    false);
            +
            +                            function __scene1(director) {
            +
            +                                // an image of 7 rows by 3 columns
            +                                var ci= new CAAT.Foundation.SpriteImage().initialize(
            +                                        director.getImage('botones'), 7, 3 );
            +
            +                                var scene= director.createScene();
            +
            +                                var b1= new CAAT.Foundation.Actor().setAsButton(
            +                                            ci.getRef(), 0, 1, 2, 0, function(button) {
            +                                                alert('easy pressed');
            +                                            }
            +                                        ).
            +                                        setLocation(0,30);
            +
            +                                var b2= new CAAT.Foundation.Actor().setAsButton(
            +                                            ci.getRef(), 6, 7, 8, 6, function(button) {
            +                                                alert('start pressed');
            +                                            }
            +                                        ).
            +                                        setLocation(1.5*ci.singleWidth, 30);
            +
            +                                scene.addChild( b1 );
            +                                scene.addChild( b2 );
            +                            }
            +
            +                        
            +
            +
            + + +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Transformations.html b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Transformations.html new file mode 100644 index 0000000..cb18a37 --- /dev/null +++ b/CAAT/documentation/tutorials/02_CAAT_Foundation_Actor_Transformations.html @@ -0,0 +1,320 @@ + + + + + + + + CAAT Tutorial 2- Actor Transformations + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + +
            +

            CAAT.Foundation.Actor

            +

            Transformations

            +

            Transformations are the way an Actor can modify its appearance and still be the same Actor. + In example, when the developer sets a width Scaling transformation, though the actor visually + has a different size, it is still the same size. This may seem a little bit odd, but one + property of an Actor is its dimension (either set by the method setSize, setBounds, or directly + modifying its width and height attributes), and other property is how it is seen and managed + through out the Director via affine transformations.

            +

            + Homogeneous Coordinates FTW!!!. +

            +

            An Actor can have three different transformations applied.

            + +
            +

            Translation

            +

            + This is a trivial translation which does not affect the visual appearance, but + just location. It is not recommended to directly set Actor.x and Actor.y attributes since this will + prevent CAAT to set the correct transformation in certain renderers.

            +

            + As a rule of thumb, always use accesor/mutator methods to get/set an actor instance properties. +

            +
              +
            • setPosition( x, y ). Set an actor's position at x,y inside its parent.
            • +
            • setPositionAnchor( x, y ). Set an actor's anchor position. By default + the anchor position is (0,0) or top left corner. Call setLocationAnchor(.5,.5) to set default actor's + position to its center.
            • +
            • setPositionAnchored( x, y, ax, ay ). Set an actor's anchor position + and anchor at the same time. +
            +
            +
            +

            Rotation

            +

            + This transformation will rotate the Actor a number of radians. There are two methods for applying + rotations: +

            +

            function setRotation( angle_in_radians )

            +

            function setRotationAnchor( center_x, center_y ). Set rotation point. Again the + values are between 0 and 1.

            +

            function setRotationAnchored( angle_in_radians, center_x, center_y )

            +

            the function setRotation is a helper for setRotationAnchored, and assumes the developer + wants to rotate around actor's center. The default rotation is 0 radians, ie, no rotation.

            +

            + The values center_x and center_y define an offset position to rotate around in + pixels from + the top left corner of the actor (0,0 posisiton). The value in pixels is opposed to that in percentage + specified in setValues method of RotateBehavior as we'll see. +

            +
            +
            +

            Scale

            +

            + This transformation will make the Actor wider and or taller. The developer + specifies two scale values one for width and another for height. These values are a multiplier + for Actors dimension. The default values for scale are both 1, meaning the resulting Actor size + will be width*1 and height*1, ie, no changes. The developer could specify negative values, + meaning that the Actor would be mirrored. The methods to set Actor's Scale are: +

            +

            function setScale( scale_x, scale_y ) +

            function setScaleAnchor( anchorX, anchorY ) +

            function setScaleAnchored( scale_x, scale_y, anchorX, anchorY ) +

            + As with rotations, setScale is a helper method for setScaleAnchored. Also the + anchor values are interpreted the same way. +

            +
            +
            +

            One important thing about rotation and scale transformations is that the + rotation anchor and the scale anchor can be different.

            +
            +
            + +
            +

            Example

            +

            In this example, we see some transformations applied to different 80x80 pixels Actors. + Move the mouse over the green actors, and see how the Local coord parameter varies. + Despite the size on screen, it will always give the correct values from 0 to 80 in width + and height.

            +
            +
            +
            +                // Initialize director.
            +                var _director_3= new CAAT.Director().initialize(
            +                        400,
            +                        120,
            +                        document.getElementById('_c3'));
            +
            +                // create scene.
            +                var _scene_3=    _director_3.createScene();
            +
            +                // create a simple actor. no transformations.
            +                var _pulsating_actor_3_0= new CAAT.Actor().
            +                        setBounds(10,20,80,80).
            +                        setFillStyle('#00ff00');
            +                _pulsating_actor_3_0.name= 'no transformation';
            +
            +                // rotated 30 degrees
            +                var _pulsating_actor_3_1= new CAAT.Actor().
            +                        setBounds(120,20,80,80).
            +                        setFillStyle('#00ff00').
            +                        setRotation( Math.PI/6 );
            +                _pulsating_actor_3_1.name= 'rotated 30 degrees';
            +
            +                // half in width
            +                var _pulsating_actor_3_2= new CAAT.Actor().
            +                        setBounds(200,20,80,80).
            +                        setFillStyle('#00ff00').
            +                        setScale( .5, 1 );
            +                _pulsating_actor_3_2.name= 'scaled(.5,1)';
            +
            +                // 125% width, half height
            +                var _pulsating_actor_3_3= new CAAT.Actor().
            +                        setBounds(300,20,80,80).
            +                        setFillStyle('#00ff00').
            +                        setScale( 1.2, .4 );
            +                _pulsating_actor_3_3.name= 'scaled(1.25,.5)';
            +
            +                // from example 1
            +                var mouseMoveHandler= function(mouseEvent) {
            +                    // get the scene Actor the event was generated for.
            +                    var actor= mouseEvent.source;
            +
            +                    // show some event info:
            +                    document.getElementById('_c3_coords').innerHTML=
            +                            "Actor:"+ actor.name+" "+
            +                            "Local Coord: ("+
            +                                // with all this stuff i'm just stripping
            +                                // off any decimal beyond .99
            +                                ((mouseEvent.point.x*100)>>0)/100+", "+
            +                                ((mouseEvent.point.y*100)>>0)/100+") "+
            +                            "Screen Coord: ("+
            +                                mouseEvent.screenPoint.x+", "+
            +                                mouseEvent.screenPoint.y+") ";
            +                };
            +
            +                // change default mouse handler to report coordinates.
            +                _pulsating_actor_3_0.mouseMove= mouseMoveHandler;
            +                _pulsating_actor_3_1.mouseMove= mouseMoveHandler;
            +                _pulsating_actor_3_2.mouseMove= mouseMoveHandler;
            +                _pulsating_actor_3_3.mouseMove= mouseMoveHandler;
            +
            +                // don't forget to actors to the scene.
            +                _scene_3.addChild( _pulsating_actor_3_0 );
            +                _scene_3.addChild( _pulsating_actor_3_1 );
            +                _scene_3.addChild( _pulsating_actor_3_2 );
            +                _scene_3.addChild( _pulsating_actor_3_3 );
            +
            +                var p= _scene_3, s= 150;
            +                for( var i=0; i<5; i++ ) {
            +                    var c= new CAAT.Foundation.ActorContainer().
            +                            setSize( s, s).
            +                            centerAt(p.width/2, p.height/2).
            +                            setFillStyle( CAAT.Module.ColorUtil.Color.random()).
            +                            enableEvents(false).
            +                            addBehavior( new CAAT.Behavior.RotateBehavior().
            +                                setValues( 0 , 2*Math.PI).
            +                                setDelayTime( 0, 30000 + i*1000).
            +                                setCycle( true )
            +                            );
            +                    p.addChild( c );
            +                    p= c;
            +                    s-=25-i*3;
            +                }
            +
            +                // set 20 fps animation
            +                CAAT.loop(20);
            +
            +        
            +
            +
            +
            + + +
            + + +
            +
            + +

            + +

            +
            + + diff --git a/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer.html b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer.html new file mode 100644 index 0000000..302ff9f --- /dev/null +++ b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer.html @@ -0,0 +1,197 @@ + + + + + + + CAAT Tutorial 3 - CAAT.ActorContainer + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + +
            +

            CAAT.ActorContainer

            + +

            + A CAAT.Foundation.ActorContainer instance, is a container for other Actors + including other CAAT.ActorContainers instances. Its main responsibility is to contain and + manage other Actors. +

            + +

            + It will compound every operation hierarchically for itslef and its children + so that it will compose its transformations to all of its contained Actors, + and that it will animate, paint and destroy its children when necessary. +

            + +

            + The most special kind of ActorContainer are CAAT.Foundation.Director and CAAT.Foundation.Scene + objects. + Setting a transformation on the Scene means it will be applied for every + contained actor, as it happens for example when switching from scene to scene with Director's + built-in + methods. +

            + +

            + CAAT.Foundation.ActorContainer polimorphically extendsClass CAAT.Foundation.Actor. +

            + +

            + While treating with ActorContainers, we'll take special attention on Alpha composition. + If isGlobalAlpha flag is set, the ActorContainers Alpha + value will be set as the reference for all of its children. Otherwise, the alpha value + will be set only for this ActorContainer and won't affect any contained children. +

            + +
            +
            +
            +            function elem( globalAlpha ) {
            +                var container = new CAAT.Foundation.ActorContainer().
            +                        setSize(180, 180).
            +                        setFillStyle('red').
            +                        setGlobalAlpha( globalAlpha).
            +                        setAlpha(.33);
            +
            +                var circle = new CAAT.Foundation.UI.ShapeActor().
            +                        setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE).
            +                        setFillStyle('green').
            +                        setBounds(20, 20, 140, 140);
            +
            +                var text= new CAAT.Foundation.UI.TextActor().
            +                        setFont("20px arial").
            +                        setTextAlign("center").
            +                        setTextBaseline("middle").
            +                        setText("GlobalAlpha "+(globalAlpha ? "true" : "false")).
            +                        setLocation( container.width/2, container.height/2 );
            +
            +                container.addChild(circle);
            +                container.addChild(text);
            +
            +                return container;
            +            }
            +
            +            var director = new CAAT.Foundation.Director().initialize(
            +                    400,
            +                    200,
            +                    document.getElementById('_c9'));
            +
            +            // create a vertical gradient to apply to text.
            +            var gradient = director.ctx.createLinearGradient(0, 0, 0, director.canvas.height);
            +            gradient.addColorStop(0, '#ffff00');
            +            gradient.addColorStop(0.5, '#00ffff');
            +            gradient.addColorStop(1, 'blue');
            +
            +            var scene = director.createScene().
            +                    setFillStyle(gradient);
            +
            +            director.addScene(scene);
            +
            +            var block0= elem(false).setLocation(10,10);
            +            var block1= elem(true).setLocation(210,10);
            +
            +            scene.addChild(block0);
            +            scene.addChild(block1);
            +
            +            CAAT.loop(1);
            +
            +        
            +
            +
            +
            + +
            + +
            +
            + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_AddChildren.html b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_AddChildren.html new file mode 100644 index 0000000..9667495 --- /dev/null +++ b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_AddChildren.html @@ -0,0 +1,315 @@ + + + + + + + CAAT Tutorial 3 - CAAT.ActorContainer + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + +
            +

            CAAT.Foundation.ActorContainer

            + +

            Adding actors to a container

            + +
            +

            + In CAAT, every out-of-the-box actor instance is a CAAT.ActorContainer + except the CAAT.Actor object instances themselves. + Despite it could seem odd adding an Actor object to (for instance) a CAAT.Shape + it makes sense to do so when you need to link hierarchycally other actors to the shape. + A good example could be when trying to do an elbow like relationshiop between two + given actor instances. See dem8 for an example. +

            + +

            + It must be noticed that a CAAT.Foundation.ActorContainer has no size by default, and that unless specified, + a container's size will be 1x1 regardless adding/removing actors to/from it. +

            + +

            + You can eventually, call new CAAT.Foundation.ActorContainer( CAAT.Foundation.ActorContainer.AddHint.CONFORM ); + which will make the container to grow in size when adding children to it. +

            + +
            + + +
            +

            Addition Methods

            + +

            + There're two methods to add Actors to a Container. +

            + +

            + The method function addChildDelayed(actor, constraint) + batches the actor addition until CAAT.Director's current frame is processed. + When adding actors to a container (in example in response to behavior events), the + current frame is being processed, and adding new Actors could lead to visual artifacts. + The reason is that the newly added actors have not yet executed their animation stage + when being drawn on screen.

            +

            +

            + The methods function addChild(actor, constraint ) and + function addActorImmediately(actor, constraint) in opposition to the + previous method addActor, adds immediately an actor to + the rendering pipeline, and could cause such visual artifacts. +

            +

            + The constraint parameter is used in case the container has a LayoutManager object associated. + See Layout in the documentation for more info. +

            +

            + The methods function addChildAt(pos) adds an actor at a given ZIndex + position. +

            + +

            + addActorImmediately is the default actor addition behavior. +

            + +

            + As a rule of thumb, you must take care of adding/removing actors while + animate, paintActor or + paint methods are being executed. These methods are traversing the list + of actors present in a scene (or containers of current scene) and modifying this list while is traversed + is not a good idea. In such cases, use addActorDelayed function. +

            +
            + + +
            +

            + In this example, every tentacle is linked to the center, and every tentacle's shape + is linked (contained) to the previous one. So rotating slightly every tentacle's + element turns into an accumulative rotation transformation. +

            + +
            + +
            +
            +
            +
            +                // create a tentacle
            +                    function __createTentacle( root, angle, segments, armSegmentSizeW, armSegmentSizeH, armIndex, maxAngle ) {
            +
            +                        var i;
            +                        var segment= root;
            +
            +                        for( i=0; i < segments; i++ ) {
            +
            +                // calculate a color which lies somewhere between the rgb colors
            +                // (255,255,0) yellow and (255,128,0) orange.
            +                            var color= CAAT.Module.ColorUtil.Color.interpolate(
            +                                    255,255,0,
            +                                    255,128,0,
            +                                    segments,
            +                                    i
            +                            );
            +
            +                // create a tentacle's segment
            +                            var newSegment= new CAAT.ActorContainer().
            +                                setSize( armSegmentSizeH-4, armSegmentSizeH-4 ).
            +                                setFillStyle( "rgb("+color.r+","+color.g+","+color.b+")" ).
            +                                setLocation( 0,-armSegmentSizeH );
            +
            +                // and link it to the previos tentacle segment or root element
            +                            if ( segment==root ) {
            +                                newSegment.setRotationAnchored(angle, .5, 1);
            +                                newSegment.oldAngle= angle;
            +                            } else {
            +                                newSegment.oldAngle= 0;
            +                // set for every tentacle's segment up an animation function which applies
            +                // some rotation. Every segment's rotation will be composed with the previous
            +                // segment's one.
            +                                newSegment.animate= function(director,time) {
            +                                    this.setRotationAnchored(
            +                                            this.oldAngle+
            +                                            maxAngle*Math.sin(new Date().getTime()*.0005 + armIndex*Math.PI/segments/2
            +                                            ),
            +                                            .5,
            +                                            1
            +                                    );
            +                                    return CAAT.ActorContainer.prototype.animate.call(this,director,time);
            +
            +                                };
            +                            }
            +
            +                            segment.addChild(newSegment);
            +                            segment= newSegment;
            +                        }
            +                    }
            +
            +                var _director_9= new CAAT.Director().initialize(
            +                        200,
            +                        200,
            +                        document.getElementById('_tut3_100'));
            +
            +                var _scene_9= _director_9.createScene();
            +
            +                _director_9.addScene( _scene_9 );
            +
            +            // make this actor each tentacle's parent.
            +            // rotating this actor will make every tentacle to rotate around it.
            +                var root= new CAAT.ShapeActor().
            +                        setShape( CAAT.ShapeActor.prototype.SHAPE_CIRCLE ).
            +                        setBounds( _director_9.width/2, _director_9.height/2, 1, 1 ).
            +                        setFillStyle( 'yellow' ).
            +                        addBehavior(
            +                            new CAAT.RotateBehavior().
            +                                setFrameTime(0,20000).
            +                                setValues(0,2*Math.PI).
            +                                setCycle(true)
            +                        );
            +
            +            // create 10 tentacles
            +                var arms= 10;
            +            // with 10 segments each
            +                var segments=10;
            +
            +                var i;
            +
            +                for( i=0; i<arms; i++ ) {
            +                    __createTentacle( root, 2*Math.PI/arms * i, segments, 2, 10, i, Math.PI/segments/2 );
            +                }
            +
            +                _scene_9.addChild(root);
            +                CAAT.loop(15);
            +            
            +
            + +
            + +
            +
            +
            + + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Layout.html b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Layout.html new file mode 100644 index 0000000..d43f7a0 --- /dev/null +++ b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Layout.html @@ -0,0 +1,352 @@ + + + + + + + CAAT Tutorial 2 - CAAT.ActorContainer, Layout + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Foundation.ActorContainer

            + +
            +

            Layout

            + +

            + CAAT containers have the abbility of laying out its children automatically. When the container + is resized or has children added/removed, it can lay out again based on simple rules its + content. Think of it as responsive content. +

            +

            + The container instance relies on objects of type + CAAT.Foundation.UI.Layout.LayoutManager for auto layout. +

            +
              +
            • CAAT.Foundation.UI.Layout.GridLayout
            • +
            • CAAT.Foundation.UI.Layout.BoxLayout
            • +
            • CAAT.Foundation.UI.Layout.BorderLayout
            • +
            +

            + Each of these layout objects organize elements differently, but the most important feature + is that you can combine them. For example you can have a boxLayout for each element in a + GridLayout and the system will conform all its content based on the rules set. +

            +

            + For a complete Layout example see demo29. +

            +
            + +
            +

            LayoutManager

            +

            + CAAT.Foundation.UI.Layout.LayoutManager is the base class + for all the other Layout objects. +

            +

            + It offers the following functionality for all layouts: +

            +
            +

            Gap

            +

            + The methods setHGap(number) and + setVGap(number) define the distance between any two adjacent + Actors in a container. +

            +
            +
            +

            Padding

            +

            + The methods setPadding(l,r, t,b) and + setAllPadding(number) define container's insets. +

            +
            +
            + +
            +

            GridLayout

            +

            + This is the simplest layout object, and lays its children in a grid. When the layout object + is created, you call new CAAT.Foundation.UI.Layout.GridLayout(rows, columns). + If rows set to 0, the layout will create a new objects row every 'column' counted elements. + Same when columns is set to 0. +

            +

            + The layout rules will set a container's children bounds based on the container size, and + the number of rows/columns needed to fit all its children. Actor's preferred size will be + ignored. +

            +

            + In the following example, the left container is laying out 13 elements in 3 rows and 0 columns. + That means lay out in a new columns every 3 rows. + The right container, on the other hand, is laying 13 elements with 0 rows, and 2 columns, + so a new row is created every two elements. +

            +
            + + +
            +
            + +
            +

            BorderLayout

            +

            + This layout divides a container's area into 5 sections: left, right, top, bottom and center. + The actor added in the center will conform to the remaining space not allocated by the rest + of the elements. The container's space will be allocated in the + following order: top, bottom, right, left and center. +

            +

            + To add Actors for each of these layout positions, addChild's method constraint parameters + must be: "left", "right", "top", "bottom", "center". If no constraint value is set "center" + will be assumed. +

            +

            + In this example, two elements are added on "left" and "top" constraints. The interesting part + is the "center" contraint, which adds a container with a + CAAT.Foundation.UI.Layout.GridLayout layout that conforms a + container and its children to the remaining space inside the root container. +

            + +
            + + +
            +
            + + +
            +

            BoxLayout

            +

            + This layout groups elements adjacently, one after the other. It is as an stack but in any + direction. +

            +

            + You can select the axis of piling with a call to setAxis( axis ) + which accepts values: +

            +
              +
            • CAAT.Foundation.UI.Layout.LayoutManager.AXIS.X
            • +
            • CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y
            • +
            +

            + Additionally, this layout can align its contents horizontally and vertically by calling: +

            + setHorizontalAlignment( align ) +

            +
              +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT
            • +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER
            • +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT
            • +
            +

            + setVerticalAlignment( align ) +

            +
              +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP
            • +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER
            • +
            • CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM
            • +
            + +
            + + +
            +
            + + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Operations.html b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Operations.html new file mode 100644 index 0000000..fff8198 --- /dev/null +++ b/CAAT/documentation/tutorials/03_CAAT_Foundation_ActorContainer_Operations.html @@ -0,0 +1,94 @@ + + + + + + + CAAT Tutorial 2 - CAAT.ActorContainer, Operations with contents + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Foundation.ActorContainer

            + +
            +

            Z Indexing child Actors

            + +

            + Every container, sets Z Index values so that the first added actor is below + the others, and the last one on top of every one. +

            +

            + This natural z index can be modified by calling container's method + setZOrder(actor, zindex). +

            +

            + The parameter 'actor' is an actor held by the container, and the zindex is the + new zindex position to set the actor at. if zindex is Number.MAX_VALUE, + (or simply greated that container's actor count) the actor will be above + every other actor of this container. +

            +
            + +
            +

            Retrieving Actors

            + +

            + Functions to retrieve elements inside a container are: +

            +
              +
            • getChildAt(number) => Actor: retrieve the nth element.
            • +
            • findChild(actor) => number: retrieve the position of an actor. -1 if not found.
            • +
            • findActorById(id) => Actor: retrieve the actor with given id. null if not found.
            • +
            • findActorByPosition( CAAT.Math.Point ) => Actor: retrieve the actor at a given coordinate in the container. returns the container itself if there's nothing at that coordinate.
            • +
            +
            + +
            +

            Removing Actors

            + +

            + Functions to remove actors are: +

            +
              +
            • removeChildAt(number) => Actor: remove and return the nth Actor.
            • +
            • removeChild(actor) => Actor: remove actor from this container.
            • +
            • removeFirstChild() => Actor: remove first actor (smallest zIndex).
            • +
            • removeLastChild() => Actor: remove last actor (biggest zIndex).
            • + +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/04_CAAT_Foundation_Director.html b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director.html new file mode 100644 index 0000000..b524fa0 --- /dev/null +++ b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director.html @@ -0,0 +1,107 @@ + + + + + + CAAT Tutorial 4 - CAAT.Foundation.Director + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + + +
            +

            CAAT.Director

            + +

            + The director is the root in the hierarchy of CAAT's components. + In its core is a CAAT.ActorContainer instance which manages the scene graph timeline, gives unique + timelines for each scene, and handles scene transitions. +

            + Note that there can be more than one director object per browser document. + The bad news is that all of them must be using the same rendering technology. So you can't mix a css + renderer with a canvas one. +

            + +

            + This element will be responsible for many key features including: +

            +
              +
            • Manage the Scenes and their transitions.
            • +
            • Route input events to the correct Actor.
            • +
            • Manage the main timeline, and supply with unique time lines for each scene.
            • +
            • Keep track of resources such as images and sounds.
            • +
            • Play sounds and music.
            • +
            • etc.
            • +
            + +

            + The Director object instances try to render frames using + requestAnimationFrame. In case there's not such browser functionality, the + developer has the opportunity of setting the desired animation + quality in the form of frames per second. +

            + +

            + The lifecycle of the director will be as follows +

            +
              +
            1. Create the director by specifying at least its dimension. +
            2. Add at least one scene to the director. +
            3. Instrument the engine to start de animation by calling CAAT.loop. It is also possible + to start the animation by calling + director.loop({number}expexted fps), but this is + not the recommended way.
            4. +
            + +

            +

            +

            + +
            + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_ClearBackground.html b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_ClearBackground.html new file mode 100644 index 0000000..e27156a --- /dev/null +++ b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_ClearBackground.html @@ -0,0 +1,91 @@ + + + + + + + CAAT Tutorial 4 - Director, cleaning the background + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Clear background

            + +

            + A CAAT.Director object will by default clean every frame the animations background. +

            +

            + Despite a Director object is an Actor, it will surpass the effects of calling either + setFillStle( style ) or + setBackgroundImage( image ) + methods. The Director instance clears the background by calling rendering context's + clearRect when using a Canvas renderer and + gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT) + if webGL is enabled. It has no effect when using the CSS renderer. +

            +

            + It will be a common error and performance sinker to let a canvas based director + to clean the background once and doing it again in the scene. It is interesting al least during + scene transition to have Director clear the screen since in can leave uncleared areas while + scenes are brought in-out. +

            +

            + To avoid this you could call director's setClear(false). +

            +

            + It will be more proper to do it as follows: +

            +
            +
            +                    scene.activated= function() {
            +                        director.setClear( CAAT.Foundation.Director.CLEAR_NONE );
            +                    };
            +                
            +
            +
            +

            + Recently, CAAT has added more background clear modes. Right now, you can call + director.setClear( CAAT.Director.CLEAR_XXX ).. Accepted values are: +

            +
          • CAAT.Director.CLEAR_NONE: the background is not cleared previous to draw a frame. Suitable when + the scene has Actors which cover the whole background. +
          • CAAT.Director.CLEAR_ALL: the background will be cleared previous to draw a frame.
          • +
          • CAAT.Director.CLEAR_DIRTY_RECTS: the background will be cleared and repainted only in dirty areas. + These areas will be optimized. Consider switching from CLEAR_DIRTY_RECTS to CLEAR_ALL when there're + many areas to repaint (8 or more). +
          • +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_DirtyRects.html b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_DirtyRects.html new file mode 100644 index 0000000..844c392 --- /dev/null +++ b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_DirtyRects.html @@ -0,0 +1,63 @@ + + + + + + + CAAT Tutorial 4 - Director, time line hooks. + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Dirty Rects

            +

            + When using a Canvas renderer, it may be a good idea to redraw only scene affected areas instead + of the whole frame. CAAT will take of this automatically by calling + director.setClear( CAAT.Foundation.Director.CLEAR_DIRTY_RECTS );. +

            +

            + CAAT can automatically identify what objects are dirty, based on Behavior application, position + change, etc. But in case you want an Actor to be repaint when dirty rects are enabled, a call + to actor.invalidate();. +

            +

            + Dirty rects are specially suited for low-end mobile devices and canvas rendering. Unfortunately, + dirty rects can result in no advantage if there're too many on-screen areas affected. It is your + responsibility to switch from CLEAR_DIRTY_RECTS to CLEAR_ALL and viceversa. This can be done + at any given moment, no need to restart CAAT at all. +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_TimelineCallbacks.html b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_TimelineCallbacks.html new file mode 100644 index 0000000..f6e42b8 --- /dev/null +++ b/CAAT/documentation/tutorials/04_CAAT_Foundation_Director_TimelineCallbacks.html @@ -0,0 +1,81 @@ + + + + + + + CAAT Tutorial 4 - Director, time line hooks. + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Time line callbacks

            +

            + During the regular Director loop there's the scene rendering procedure. In certain + situations, your may need to perform operations before and/or after the + scene rendering process. +

            +

            + There exist two hook points, one before rendering which is called + before the scene + actors have their behaviors and transformations applied + and the other after rendering, which is called after + every scene actor has been displayed on screen. +

            +

            + The developer can set such hooks by setting a function + onRenderStart and a function onRenderEnd. + These both methods will receive a parameter with director's current animation time. +

            +

            + Take into account that this hook points will be called always regardless of the + scene being shown. Even when scenes are being changed. +

            +

            + For example, I'm using an onRenderStart hook to let Box2D run a physics simulation + step with this code: +

            +
            +
            +                director.onRenderStart= function(director_time) {
            +                    this.world.Step(1.0/60, 1,1);
            +                    this.world.ClearForces();
            +                };
            +                
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/index.html b/CAAT/documentation/tutorials/index.html new file mode 100644 index 0000000..e806d4c --- /dev/null +++ b/CAAT/documentation/tutorials/index.html @@ -0,0 +1,154 @@ + + + + + + + CAAT Tutorials + + + + + + + + + + +
            + + +
            +
            +

            What is CAAT ?

            +

            + It is a
            +

            JavaScript based

            +
            multi-instance
            (there can be more than one executing instance per html document)
            +
            director-based

            +
            scene-graph manager
            (CAAT actors are entities which have state and may contain other actors). +

            +

            + CAAT stands for Canvas Advanced Animation Tookit. +

            +

            + The rendering engine is not only focused on + Canvas actually. WebGL and + CSS can be selected too. +

            +

            + CAAT it is a complete gaming framework, featuring on-screen entities, custom matrix + stack, game loop hooks, scenes, scene transition, affine transformations, pixel perfect + on-screen entity identification, complex paths, behaviors, seamless box2d integration, + multitouch, etc. +

            + + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/menu/menu.html b/CAAT/documentation/tutorials/menu/menu.html new file mode 100644 index 0000000..2dc4240 --- /dev/null +++ b/CAAT/documentation/tutorials/menu/menu.html @@ -0,0 +1,90 @@ +

            Tutorial

            + + +

            Demos & Games

            + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/menu/menu.js b/CAAT/documentation/tutorials/menu/menu.js new file mode 100644 index 0000000..ffd39c9 --- /dev/null +++ b/CAAT/documentation/tutorials/menu/menu.js @@ -0,0 +1,43 @@ +(function() { + var req; + + function loadXMLDoc() { + req = false; + if(window.XMLHttpRequest && !(window.ActiveXObject)) { + try { + req = new XMLHttpRequest(); + } catch(e) { + req = false; + } + } else if(window.ActiveXObject) { + try { + req = new ActiveXObject("Msxml2.XMLHTTP"); + } catch(e) { + try { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } catch(e) { + req = false; + } + } + } + if(req) { + req.onreadystatechange = processReqChange; + req.open("GET", 'menu/menu.html', true); + req.send(""); + } + } + + function processReqChange() { + if (req.readyState == 4) { + if (req.status == 200) { + var menu= document.getElementById('menu'); + menu.innerHTML= req.responseText; + } else { + document.getElementById('menu').innerHTML="Unable to load menu"; + } + } + } + + window.addEventListener('load',loadXMLDoc,false); + +})(); \ No newline at end of file diff --git a/CAAT/documentation/tutorials/resource/01.mp3 b/CAAT/documentation/tutorials/resource/01.mp3 new file mode 100644 index 0000000..3e50939 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/01.mp3 differ diff --git a/CAAT/documentation/tutorials/resource/10.mp3 b/CAAT/documentation/tutorials/resource/10.mp3 new file mode 100644 index 0000000..c42b824 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/10.mp3 differ diff --git a/CAAT/documentation/tutorials/resource/11.mp3 b/CAAT/documentation/tutorials/resource/11.mp3 new file mode 100644 index 0000000..a3ba411 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/11.mp3 differ diff --git a/CAAT/documentation/tutorials/resource/12.mp3 b/CAAT/documentation/tutorials/resource/12.mp3 new file mode 100644 index 0000000..62fa741 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/12.mp3 differ diff --git a/CAAT/documentation/tutorials/resource/body_bg.jpg b/CAAT/documentation/tutorials/resource/body_bg.jpg new file mode 100644 index 0000000..4fd3b72 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/body_bg.jpg differ diff --git a/CAAT/documentation/tutorials/resource/botones.png b/CAAT/documentation/tutorials/resource/botones.png new file mode 100644 index 0000000..4050eb8 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/botones.png differ diff --git a/CAAT/documentation/tutorials/resource/logo.png b/CAAT/documentation/tutorials/resource/logo.png new file mode 100644 index 0000000..4e14e86 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/logo.png differ diff --git a/CAAT/documentation/tutorials/resource/music.mp3 b/CAAT/documentation/tutorials/resource/music.mp3 new file mode 100644 index 0000000..e29cd02 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/music.mp3 differ diff --git a/CAAT/documentation/tutorials/resource/normal_mode.png b/CAAT/documentation/tutorials/resource/normal_mode.png new file mode 100644 index 0000000..b380cb4 Binary files /dev/null and b/CAAT/documentation/tutorials/resource/normal_mode.png differ diff --git a/CAAT/documentation/tutorials/resource/sound.png b/CAAT/documentation/tutorials/resource/sound.png new file mode 100644 index 0000000..23082ab Binary files /dev/null and b/CAAT/documentation/tutorials/resource/sound.png differ diff --git a/CAAT/documentation/tutorials/sh/shBrushJScript.js b/CAAT/documentation/tutorials/sh/shBrushJScript.js new file mode 100644 index 0000000..ff98dab --- /dev/null +++ b/CAAT/documentation/tutorials/sh/shBrushJScript.js @@ -0,0 +1,52 @@ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/SyntaxHighlighter + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + * + * @version + * 3.0.83 (July 02 2010) + * + * @copyright + * Copyright (C) 2004-2010 Alex Gorbatchev. + * + * @license + * Dual licensed under the MIT and GPL licenses. + */ +;(function() +{ + // CommonJS + typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null; + + function Brush() + { + var keywords = 'break case catch continue ' + + 'default delete do else false ' + + 'for function if in instanceof ' + + 'new null return super switch ' + + 'this throw true try typeof var while with' + ; + + var r = SyntaxHighlighter.regexLib; + + this.regexList = [ + { regex: r.multiLineDoubleQuotedString, css: 'string' }, // double quoted strings + { regex: r.multiLineSingleQuotedString, css: 'string' }, // single quoted strings + { regex: r.singleLineCComments, css: 'comments' }, // one line comments + { regex: r.multiLineCComments, css: 'comments' }, // multiline comments + { regex: /\s*#.*/gm, css: 'preprocessor' }, // preprocessor tags like #region and #endregion + { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' } // keywords + ]; + + this.forHtmlScript(r.scriptScriptTags); + }; + + Brush.prototype = new SyntaxHighlighter.Highlighter(); + Brush.aliases = ['js', 'jscript', 'javascript']; + + SyntaxHighlighter.brushes.JScript = Brush; + + // CommonJS + typeof(exports) != 'undefined' ? exports.Brush = Brush : null; +})(); diff --git a/CAAT/documentation/tutorials/sh/shCore.css b/CAAT/documentation/tutorials/sh/shCore.css new file mode 100644 index 0000000..4c3b3ce --- /dev/null +++ b/CAAT/documentation/tutorials/sh/shCore.css @@ -0,0 +1,226 @@ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/SyntaxHighlighter + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + * + * @version + * 3.0.83 (July 02 2010) + * + * @copyright + * Copyright (C) 2004-2010 Alex Gorbatchev. + * + * @license + * Dual licensed under the MIT and GPL licenses. + */ +.syntaxhighlighter a, +.syntaxhighlighter div, +.syntaxhighlighter code, +.syntaxhighlighter table, +.syntaxhighlighter table td, +.syntaxhighlighter table tr, +.syntaxhighlighter table tbody, +.syntaxhighlighter table thead, +.syntaxhighlighter table caption, +.syntaxhighlighter textarea { + -moz-border-radius: 0 0 0 0 !important; + -webkit-border-radius: 0 0 0 0 !important; + background: none !important; + border: 0 !important; + bottom: auto !important; + float: none !important; + height: auto !important; + left: auto !important; + line-height: 1.1em !important; + margin: 0 !important; + outline: 0 !important; + overflow: visible !important; + padding: 0 !important; + position: static !important; + right: auto !important; + text-align: left !important; + top: auto !important; + vertical-align: baseline !important; + width: auto !important; + box-sizing: content-box !important; + font-family: "Consolas", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace !important; + font-weight: normal !important; + font-style: normal !important; + font-size: 1em !important; + min-height: inherit !important; + min-height: auto !important; +} + +.syntaxhighlighter { + width: 100% !important; + margin: 1em 0 1em 0 !important; + position: relative !important; + overflow: auto !important; + font-size: 1em !important; +} +.syntaxhighlighter.source { + overflow: hidden !important; +} +.syntaxhighlighter .bold { + font-weight: bold !important; +} +.syntaxhighlighter .italic { + font-style: italic !important; +} +.syntaxhighlighter .line { + white-space: pre !important; +} +.syntaxhighlighter table { + width: 100% !important; +} +.syntaxhighlighter table caption { + text-align: left !important; + padding: .5em 0 0.5em 1em !important; +} +.syntaxhighlighter table td.code { + width: 100% !important; +} +.syntaxhighlighter table td.code .container { + position: relative !important; +} +.syntaxhighlighter table td.code .container textarea { + box-sizing: border-box !important; + position: absolute !important; + left: 0 !important; + top: 0 !important; + width: 100% !important; + height: 100% !important; + border: none !important; + background: #aaa !important; + padding-left: 1em !important; + overflow: hidden !important; + white-space: pre !important; +} +.syntaxhighlighter table td.gutter .line { + text-align: right !important; + padding: 0 0.5em 0 1em !important; +} +.syntaxhighlighter table td.code .line { + padding: 0 1em !important; +} +.syntaxhighlighter.nogutter td.code .container textarea, .syntaxhighlighter.nogutter td.code .line { + padding-left: 0em !important; +} +.syntaxhighlighter.show { + display: block !important; +} +.syntaxhighlighter.collapsed table { + display: none !important; +} +.syntaxhighlighter.collapsed .toolbar { + padding: 0.1em 0.8em 0em 0.8em !important; + font-size: 1em !important; + position: static !important; + width: auto !important; + height: auto !important; +} +.syntaxhighlighter.collapsed .toolbar span { + display: inline !important; + margin-right: 1em !important; +} +.syntaxhighlighter.collapsed .toolbar span a { + padding: 0 !important; + display: none !important; +} +.syntaxhighlighter.collapsed .toolbar span a.expandSource { + display: inline !important; +} +.syntaxhighlighter .toolbar { + position: absolute !important; + right: 1px !important; + top: 1px !important; + width: 11px !important; + height: 11px !important; + font-size: 10px !important; + z-index: 10 !important; +} +.syntaxhighlighter .toolbar span.title { + display: inline !important; +} +.syntaxhighlighter .toolbar a { + display: block !important; + text-align: center !important; + text-decoration: none !important; + padding-top: 1px !important; +} +.syntaxhighlighter .toolbar a.expandSource { + display: none !important; +} +.syntaxhighlighter.ie { + font-size: .9em !important; + padding: 1px 0 1px 0 !important; +} +.syntaxhighlighter.ie .toolbar { + line-height: 8px !important; +} +.syntaxhighlighter.ie .toolbar a { + padding-top: 0px !important; +} +.syntaxhighlighter.printing .line.alt1 .content, +.syntaxhighlighter.printing .line.alt2 .content, +.syntaxhighlighter.printing .line.highlighted .number, +.syntaxhighlighter.printing .line.highlighted.alt1 .content, +.syntaxhighlighter.printing .line.highlighted.alt2 .content { + background: none !important; +} +.syntaxhighlighter.printing .line .number { + color: #bbbbbb !important; +} +.syntaxhighlighter.printing .line .content { + color: black !important; +} +.syntaxhighlighter.printing .toolbar { + display: none !important; +} +.syntaxhighlighter.printing a { + text-decoration: none !important; +} +.syntaxhighlighter.printing .plain, .syntaxhighlighter.printing .plain a { + color: black !important; +} +.syntaxhighlighter.printing .comments, .syntaxhighlighter.printing .comments a { + color: #008200 !important; +} +.syntaxhighlighter.printing .string, .syntaxhighlighter.printing .string a { + color: blue !important; +} +.syntaxhighlighter.printing .keyword { + color: #006699 !important; + font-weight: bold !important; +} +.syntaxhighlighter.printing .preprocessor { + color: gray !important; +} +.syntaxhighlighter.printing .variable { + color: #aa7700 !important; +} +.syntaxhighlighter.printing .value { + color: #009900 !important; +} +.syntaxhighlighter.printing .functions { + color: #ff1493 !important; +} +.syntaxhighlighter.printing .constants { + color: #0066cc !important; +} +.syntaxhighlighter.printing .script { + font-weight: bold !important; +} +.syntaxhighlighter.printing .color1, .syntaxhighlighter.printing .color1 a { + color: gray !important; +} +.syntaxhighlighter.printing .color2, .syntaxhighlighter.printing .color2 a { + color: #ff1493 !important; +} +.syntaxhighlighter.printing .color3, .syntaxhighlighter.printing .color3 a { + color: red !important; +} +.syntaxhighlighter.printing .break, .syntaxhighlighter.printing .break a { + color: black !important; +} diff --git a/CAAT/documentation/tutorials/sh/shCore.js b/CAAT/documentation/tutorials/sh/shCore.js new file mode 100644 index 0000000..b47b645 --- /dev/null +++ b/CAAT/documentation/tutorials/sh/shCore.js @@ -0,0 +1,17 @@ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/SyntaxHighlighter + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + * + * @version + * 3.0.83 (July 02 2010) + * + * @copyright + * Copyright (C) 2004-2010 Alex Gorbatchev. + * + * @license + * Dual licensed under the MIT and GPL licenses. + */ +eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('K M;I(M)1S 2U("2a\'t 4k M 4K 2g 3l 4G 4H");(6(){6 r(f,e){I(!M.1R(f))1S 3m("3s 15 4R");K a=f.1w;f=M(f.1m,t(f)+(e||""));I(a)f.1w={1m:a.1m,19:a.19?a.19.1a(0):N};H f}6 t(f){H(f.1J?"g":"")+(f.4s?"i":"")+(f.4p?"m":"")+(f.4v?"x":"")+(f.3n?"y":"")}6 B(f,e,a,b){K c=u.L,d,h,g;v=R;5K{O(;c--;){g=u[c];I(a&g.3r&&(!g.2p||g.2p.W(b))){g.2q.12=e;I((h=g.2q.X(f))&&h.P===e){d={3k:g.2b.W(b,h,a),1C:h};1N}}}}5v(i){1S i}5q{v=11}H d}6 p(f,e,a){I(3b.Z.1i)H f.1i(e,a);O(a=a||0;a-1},3d:6(g){e+=g}};c1&&p(e,"")>-1){a=15(J.1m,n.Q.W(t(J),"g",""));n.Q.W(f.1a(e.P),a,6(){O(K c=1;c<14.L-2;c++)I(14[c]===1d)e[c]=1d})}I(J.1w&&J.1w.19)O(K b=1;be.P&&J.12--}H e};I(!D)15.Z.1A=6(f){(f=n.X.W(J,f))&&J.1J&&!f[0].L&&J.12>f.P&&J.12--;H!!f};1r.Z.1C=6(f){M.1R(f)||(f=15(f));I(f.1J){K e=n.1C.1p(J,14);f.12=0;H e}H f.X(J)};1r.Z.Q=6(f,e){K a=M.1R(f),b,c;I(a&&1j e.58()==="3f"&&e.1i("${")===-1&&y)H n.Q.1p(J,14);I(a){I(f.1w)b=f.1w.19}Y f+="";I(1j e==="6")c=n.Q.W(J,f,6(){I(b){14[0]=1f 1r(14[0]);O(K d=0;dd.L-3;){i=1r.Z.1a.W(g,-1)+i;g=1Q.3i(g/10)}H(g?d[g]||"":"$")+i}Y{g=+i;I(g<=d.L-3)H d[g];g=b?p(b,i):-1;H g>-1?d[g+1]:h}})})}I(a&&f.1J)f.12=0;H c};1r.Z.1e=6(f,e){I(!M.1R(f))H n.1e.1p(J,14);K a=J+"",b=[],c=0,d,h;I(e===1d||+e<0)e=5D;Y{e=1Q.3i(+e);I(!e)H[]}O(f=M.3c(f);d=f.X(a);){I(f.12>c){b.U(a.1a(c,d.P));d.L>1&&d.P=e)1N}f.12===d.P&&f.12++}I(c===a.L){I(!n.1A.W(f,"")||h)b.U("")}Y b.U(a.1a(c));H b.L>e?b.1a(0,e):b};M.1h(/\\(\\?#[^)]*\\)/,6(f){H n.1A.W(A,f.2S.1a(f.P+f[0].L))?"":"(?:)"});M.1h(/\\((?!\\?)/,6(){J.19.U(N);H"("});M.1h(/\\(\\?<([$\\w]+)>/,6(f){J.19.U(f[1]);J.2N=R;H"("});M.1h(/\\\\k<([\\w$]+)>/,6(f){K e=p(J.19,f[1]);H e>-1?"\\\\"+(e+1)+(3R(f.2S.3a(f.P+f[0].L))?"":"(?:)"):f[0]});M.1h(/\\[\\^?]/,6(f){H f[0]==="[]"?"\\\\b\\\\B":"[\\\\s\\\\S]"});M.1h(/^\\(\\?([5A]+)\\)/,6(f){J.3d(f[1]);H""});M.1h(/(?:\\s+|#.*)+/,6(f){H n.1A.W(A,f.2S.1a(f.P+f[0].L))?"":"(?:)"},M.1B,6(){H J.2K("x")});M.1h(/\\./,6(){H"[\\\\s\\\\S]"},M.1B,6(){H J.2K("s")})})();1j 2e!="1d"&&(2e.M=M);K 1v=6(){6 r(a,b){a.1l.1i(b)!=-1||(a.1l+=" "+b)}6 t(a){H a.1i("3e")==0?a:"3e"+a}6 B(a){H e.1Y.2A[t(a)]}6 p(a,b,c){I(a==N)H N;K d=c!=R?a.3G:[a.2G],h={"#":"1c",".":"1l"}[b.1o(0,1)]||"3h",g,i;g=h!="3h"?b.1o(1):b.5u();I((a[h]||"").1i(g)!=-1)H a;O(a=0;d&&a\'+c+""});H a}6 n(a,b){a.1e("\\n");O(K c="",d=0;d<50;d++)c+=" ";H a=v(a,6(h){I(h.1i("\\t")==-1)H h;O(K g=0;(g=h.1i("\\t"))!=-1;)h=h.1o(0,g)+c.1o(0,b-g%b)+h.1o(g+1,h.L);H h})}6 x(a){H a.Q(/^\\s+|\\s+$/g,"")}6 D(a,b){I(a.Pb.P)H 1;Y I(a.Lb.L)H 1;H 0}6 y(a,b){6 c(k){H k[0]}O(K d=N,h=[],g=b.2D?b.2D:c;(d=b.1I.X(a))!=N;){K i=g(d,b);I(1j i=="3f")i=[1f e.2L(i,d.P,b.23)];h=h.1O(i)}H h}6 E(a){K b=/(.*)((&1G;|&1y;).*)/;H a.Q(e.3A.3M,6(c){K d="",h=N;I(h=b.X(c)){c=h[1];d=h[2]}H\'\'+c+""+d})}6 z(){O(K a=1E.36("1k"),b=[],c=0;c<1z 4I="1Z://2y.3L.3K/4L/5L"><3J><4N 1Z-4M="5G-5M" 6K="2O/1z; 6J=6I-8" /><1t>6L 1v<3B 1L="25-6M:6Q,6P,6O,6N-6F;6y-2f:#6x;2f:#6w;25-22:6v;2O-3D:3C;">1v3v 3.0.76 (72 73 3x)1Z://3u.2w/1v70 17 6U 71.6T 6X-3x 6Y 6D.6t 61 60 J 1k, 5Z 5R 5V <2R/>5U 5T 5S!\'}},1Y:{2j:N,2A:{}},1U:{},3A:{6n:/\\/\\*[\\s\\S]*?\\*\\//2c,6m:/\\/\\/.*$/2c,6l:/#.*$/2c,6k:/"([^\\\\"\\n]|\\\\.)*"/g,6o:/\'([^\\\\\'\\n]|\\\\.)*\'/g,6p:1f M(\'"([^\\\\\\\\"]|\\\\\\\\.)*"\',"3z"),6s:1f M("\'([^\\\\\\\\\']|\\\\\\\\.)*\'","3z"),6q:/(&1y;|<)!--[\\s\\S]*?--(&1G;|>)/2c,3M:/\\w+:\\/\\/[\\w-.\\/?%&=:@;]*/g,6a:{18:/(&1y;|<)\\?=?/g,1b:/\\?(&1G;|>)/g},69:{18:/(&1y;|<)%=?/g,1b:/%(&1G;|>)/g},6d:{18:/(&1y;|<)\\s*1k.*?(&1G;|>)/2T,1b:/(&1y;|<)\\/\\s*1k\\s*(&1G;|>)/2T}},16:{1H:6(a){6 b(i,k){H e.16.2o(i,k,e.13.1x[k])}O(K c=\'\',d=e.16.2x,h=d.2X,g=0;g";H c},2o:6(a,b,c){H\'<2W>\'+c+""},2b:6(a){K b=a.1F,c=b.1l||"";b=B(p(b,".20",R).1c);K d=6(h){H(h=15(h+"6f(\\\\w+)").X(c))?h[1]:N}("6g");b&&d&&e.16.2x[d].2B(b);a.3N()},2x:{2X:["21","2P"],21:{1H:6(a){I(a.V("2l")!=R)H"";K b=a.V("1t");H e.16.2o(a,"21",b?b:e.13.1x.21)},2B:6(a){a=1E.6j(t(a.1c));a.1l=a.1l.Q("47","")}},2P:{2B:6(){K a="68=0";a+=", 18="+(31.30-33)/2+", 32="+(31.2Z-2Y)/2+", 30=33, 2Z=2Y";a=a.Q(/^,/,"");a=1P.6Z("","38",a);a.2C();K b=a.1E;b.6W(e.13.1x.37);b.6V();a.2C()}}}},35:6(a,b){K c;I(b)c=[b];Y{c=1E.36(e.13.34);O(K d=[],h=0;h(.*?))\\\\]$"),s=1f M("(?<27>[\\\\w-]+)\\\\s*:\\\\s*(?<1T>[\\\\w-%#]+|\\\\[.*?\\\\]|\\".*?\\"|\'.*?\')\\\\s*;?","g");(j=s.X(k))!=N;){K o=j.1T.Q(/^[\'"]|[\'"]$/g,"");I(o!=N&&m.1A(o)){o=m.X(o);o=o.2V.L>0?o.2V.1e(/\\s*,\\s*/):[]}l[j.27]=o}g={1F:g,1n:C(i,l)};g.1n.1D!=N&&d.U(g)}H d},1M:6(a,b){K c=J.35(a,b),d=N,h=e.13;I(c.L!==0)O(K g=0;g")==o-3){m=m.4h(0,o-3);s=R}l=s?m:l}I((i.1t||"")!="")k.1t=i.1t;k.1D=j;d.2Q(k);b=d.2F(l);I((i.1c||"")!="")b.1c=i.1c;i.2G.74(b,i)}}},2E:6(a){w(1P,"4k",6(){e.1M(a)})}};e.2E=e.2E;e.1M=e.1M;e.2L=6(a,b,c){J.1T=a;J.P=b;J.L=a.L;J.23=c;J.1V=N};e.2L.Z.1q=6(){H J.1T};e.4l=6(a){6 b(j,l){O(K m=0;md)1N;Y I(g.P==c.P&&g.L>c.L)a[b]=N;Y I(g.P>=c.P&&g.P\'+c+""},3Q:6(a,b){K c="",d=a.1e("\\n").L,h=2u(J.V("2i-1s")),g=J.V("2z-1s-2t");I(g==R)g=(h+d-1).1q().L;Y I(3R(g)==R)g=0;O(K i=0;i\'+j+"":"")+i)}H a},4f:6(a){H a?"<4a>"+a+"":""},4b:6(a,b){6 c(l){H(l=l?l.1V||g:g)?l+" ":""}O(K d=0,h="",g=J.V("1D",""),i=0;i|&1y;2R\\s*\\/?&1G;/2T;I(e.13.46==R)b=b.Q(h,"\\n");I(e.13.44==R)b=b.Q(h,"");b=b.1e("\\n");h=/^\\s*/;g=4Q;O(K i=0;i0;i++){K k=b[i];I(x(k).L!=0){k=h.X(k);I(k==N){a=a;1N a}g=1Q.4q(k[0].L,g)}}I(g>0)O(i=0;i\'+(J.V("16")?e.16.1H(J):"")+\'<3Z 5z="0" 5H="0" 5J="0">\'+J.4f(J.V("1t"))+"<3T><3P>"+(1u?\'<2d 1g="1u">\'+J.3Q(a)+"":"")+\'<2d 1g="17">\'+b+""},2F:6(a){I(a===N)a="";J.17=a;K b=J.3Y("T");b.3X=J.1H(a);J.V("16")&&w(p(b,".16"),"5c",e.16.2b);J.V("3V-17")&&w(p(b,".17"),"56",f);H b},2Q:6(a){J.1c=""+1Q.5d(1Q.5n()*5k).1q();e.1Y.2A[t(J.1c)]=J;J.1n=C(e.2v,a||{});I(J.V("2k")==R)J.1n.16=J.1n.1u=11},5j:6(a){a=a.Q(/^\\s+|\\s+$/g,"").Q(/\\s+/g,"|");H"\\\\b(?:"+a+")\\\\b"},5f:6(a){J.28={18:{1I:a.18,23:"1k"},1b:{1I:a.1b,23:"1k"},17:1f M("(?<18>"+a.18.1m+")(?<17>.*?)(?<1b>"+a.1b.1m+")","5o")}}};H e}();1j 2e!="1d"&&(2e.1v=1v);',62,441,'||||||function|||||||||||||||||||||||||||||||||||||return|if|this|var|length|XRegExp|null|for|index|replace|true||div|push|getParam|call|exec|else|prototype||false|lastIndex|config|arguments|RegExp|toolbar|code|left|captureNames|slice|right|id|undefined|split|new|class|addToken|indexOf|typeof|script|className|source|params|substr|apply|toString|String|line|title|gutter|SyntaxHighlighter|_xregexp|strings|lt|html|test|OUTSIDE_CLASS|match|brush|document|target|gt|getHtml|regex|global|join|style|highlight|break|concat|window|Math|isRegExp|throw|value|brushes|brushName|space|alert|vars|http|syntaxhighlighter|expandSource|size|css|case|font|Fa|name|htmlScript|dA|can|handler|gm|td|exports|color|in|href|first|discoveredBrushes|light|collapse|object|cache|getButtonHtml|trigger|pattern|getLineHtml|nbsp|numbers|parseInt|defaults|com|items|www|pad|highlighters|execute|focus|func|all|getDiv|parentNode|navigator|INSIDE_CLASS|regexList|hasFlag|Match|useScriptTags|hasNamedCapture|text|help|init|br|input|gi|Error|values|span|list|250|height|width|screen|top|500|tagName|findElements|getElementsByTagName|aboutDialog|_blank|appendChild|charAt|Array|copyAsGlobal|setFlag|highlighter_|string|attachEvent|nodeName|floor|backref|output|the|TypeError|sticky|Za|iterate|freezeTokens|scope|type|textarea|alexgorbatchev|version|margin|2010|005896|gs|regexLib|body|center|align|noBrush|require|childNodes|DTD|xhtml1|head|org|w3|url|preventDefault|container|tr|getLineNumbersHtml|isNaN|userAgent|tbody|isLineHighlighted|quick|void|innerHTML|create|table|links|auto|smart|tab|stripBrs|tabs|bloggerMode|collapsed|plain|getCodeLinesHtml|caption|getMatchesHtml|findMatches|figureOutLineNumbers|removeNestedMatches|getTitleHtml|brushNotHtmlScript|substring|createElement|Highlighter|load|HtmlScript|Brush|pre|expand|multiline|min|Can|ignoreCase|find|blur|extended|toLowerCase|aliases|addEventListener|innerText|textContent|wasn|select|createTextNode|removeChild|option|same|frame|xmlns|dtd|twice|1999|equiv|meta|htmlscript|transitional|1E3|expected|PUBLIC|DOCTYPE|on|W3C|XHTML|TR|EN|Transitional||configured|srcElement|Object|after|run|dblclick|matchChain|valueOf|constructor|default|switch|click|round|execAt|forHtmlScript|token|gimy|functions|getKeywords|1E6|escape|within|random|sgi|another|finally|supply|MSIE|ie|toUpperCase|catch|returnValue|definition|event|border|imsx|constructing|one|Infinity|from|when|Content|cellpadding|flags|cellspacing|try|xhtml|Type|spaces|2930402|hosted_button_id|lastIndexOf|donate|active|development|keep|to|xclick|_s|Xml|please|like|you|paypal|cgi|cmd|webscr|bin|highlighted|scrollbars|aspScriptTags|phpScriptTags|sort|max|scriptScriptTags|toolbar_item|_|command|command_|number|getElementById|doubleQuotedString|singleLinePerlComments|singleLineCComments|multiLineCComments|singleQuotedString|multiLineDoubleQuotedString|xmlComments|alt|multiLineSingleQuotedString|If|https|1em|000|fff|background|5em|xx|bottom|75em|Gorbatchev|large|serif|CDATA|continue|utf|charset|content|About|family|sans|Helvetica|Arial|Geneva|3em|nogutter|Copyright|syntax|close|write|2004|Alex|open|JavaScript|highlighter|July|02|replaceChild|offset|83'.split('|'),0,{})) diff --git a/CAAT/documentation/tutorials/sh/shThemeDefault.css b/CAAT/documentation/tutorials/sh/shThemeDefault.css new file mode 100644 index 0000000..89f99b6 --- /dev/null +++ b/CAAT/documentation/tutorials/sh/shThemeDefault.css @@ -0,0 +1,117 @@ +/** + * SyntaxHighlighter + * http://alexgorbatchev.com/SyntaxHighlighter + * + * SyntaxHighlighter is donationware. If you are using it, please donate. + * http://alexgorbatchev.com/SyntaxHighlighter/donate.html + * + * @version + * 3.0.83 (July 02 2010) + * + * @copyright + * Copyright (C) 2004-2010 Alex Gorbatchev. + * + * @license + * Dual licensed under the MIT and GPL licenses. + */ +.syntaxhighlighter { + background-color: white !important; +} +.syntaxhighlighter .line.alt1 { + background-color: white !important; +} +.syntaxhighlighter .line.alt2 { + background-color: #f7f7f7 !important; +} +.syntaxhighlighter .line.highlighted.alt1, .syntaxhighlighter .line.highlighted.alt2 { + background-color: #e0e000 !important; +} +.syntaxhighlighter .line.highlighted.number { + color: black !important; +} +.syntaxhighlighter table caption { + color: black !important; +} +.syntaxhighlighter .gutter { + color: #afafaf !important; +} +.syntaxhighlighter .gutter .line { + border-right: 3px solid #6ce26c !important; +} +.syntaxhighlighter .gutter .line.highlighted { + background-color: #6ce26c !important; + color: white !important; +} +.syntaxhighlighter.printing .line .content { + border: none !important; +} +.syntaxhighlighter.collapsed { + overflow: visible !important; +} +.syntaxhighlighter.collapsed .toolbar { + color: blue !important; + background: white !important; + border: 1px solid #6ce26c !important; +} +.syntaxhighlighter.collapsed .toolbar a { + color: blue !important; +} +.syntaxhighlighter.collapsed .toolbar a:hover { + color: red !important; +} +.syntaxhighlighter .toolbar { + color: white !important; + background: #6ce26c !important; + border: none !important; +} +.syntaxhighlighter .toolbar a { + color: white !important; +} +.syntaxhighlighter .toolbar a:hover { + color: black !important; +} +.syntaxhighlighter .plain, .syntaxhighlighter .plain a { + color: black !important; +} +.syntaxhighlighter .comments, .syntaxhighlighter .comments a { + color: #008200 !important; +} +.syntaxhighlighter .string, .syntaxhighlighter .string a { + color: blue !important; +} +.syntaxhighlighter .keyword { + color: #006699 !important; +} +.syntaxhighlighter .preprocessor { + color: gray !important; +} +.syntaxhighlighter .variable { + color: #aa7700 !important; +} +.syntaxhighlighter .value { + color: #009900 !important; +} +.syntaxhighlighter .functions { + color: #ff1493 !important; +} +.syntaxhighlighter .constants { + color: #0066cc !important; +} +.syntaxhighlighter .script { + font-weight: bold !important; + color: #006699 !important; + background-color: none !important; +} +.syntaxhighlighter .color1, .syntaxhighlighter .color1 a { + color: gray !important; +} +.syntaxhighlighter .color2, .syntaxhighlighter .color2 a { + color: #ff1493 !important; +} +.syntaxhighlighter .color3, .syntaxhighlighter .color3 a { + color: red !important; +} + +.syntaxhighlighter .keyword { + font-weight: bold !important; +} diff --git a/CAAT/documentation/tutorials/style/demo.css b/CAAT/documentation/tutorials/style/demo.css new file mode 100644 index 0000000..57699a8 --- /dev/null +++ b/CAAT/documentation/tutorials/style/demo.css @@ -0,0 +1,129 @@ +body { + background: #fff; + color: #000; + font-family: "Oswald", Arial, sans-serif; + font-size: 13px; + line-height: 1.2em; + + margin: 0; + padding: 0; +} + +.tlogo { + background: url(../resource/logo.png) no-repeat; + width: 140px; + height: 82px; +} + +h1 { + border-bottom: 1px solid #888; + color: #33d; + line-height: 1.5em; +} + +h2 { + color: #336; +} + +h3 { + color: #336; +} + + +#page { + margin: 0 auto; + position: relative; + width: 950px; +} + +#header { + height: 10px; + width: 950px; +} + +#experiment h1 { + font:normal 16pt Arial; + color:#FFFFFF; + text-shadow: + 0 1px 0 #ccc, + 0 2px 0 #c9c9c9, + 0 3px 0 #bbb, + 0 4px 0 #b9b9b9, + 0 5px 0 #aaa, + 0 6px 1px rgba(0,0,0,.1), + 0 0 5px rgba(0,0,0,.1), + 0 1px 3px rgba(0,0,0,.3), + 0 3px 5px rgba(0,0,0,.2), + 0 5px 10px rgba(0,0,0,.25), + 0 10px 10px rgba(0,0,0,.2); + + border: 0; +} + + +#content #menu { + float: left; + width: 150px; + padding-left: 10px; + padding-right: 10px; +} + +#content #tutorial { + float: left; + width: 780px; +} + +#menu ul { + padding: 4px 0 !important; + overflow: hidden; + margin: 0; +} + +#menu li { + text-indent: 0px; + margin-left: 0; +} + +a { + text-decoration: none; + color: #73f; +} + +a:hover { + background: #55f; + color: #fff; +} + +#menu .indented { + text-indent: 15px; !important; +} + +#menu-index .indented { + text-indent: 15px; !important; +} + + +.important { + padding: 0 5px; + border: 1px; + border-style: solid; + background: #ddd; + color: #000; + font-family: monospace; + font-size: 1em; + font-weight: bold; +} + +.apicode { + padding: 0 5px; + border: 1px; + border-style: solid; + background: #ffe; + color: #000; + font-family: monospace; + font-size: 1em; +} + +.sample { + margin: 0 auto; +} \ No newline at end of file diff --git a/CAAT/documentation/tutorials/style/tut.css b/CAAT/documentation/tutorials/style/tut.css new file mode 100644 index 0000000..bfe4500 --- /dev/null +++ b/CAAT/documentation/tutorials/style/tut.css @@ -0,0 +1,24 @@ +.important { + padding: 0 5px; + border: 1px; + border-style: solid; + background: #eee; + color: #000; + font-family: monospace; + font-size: 1em; + font-weight: bold; +} + +.apicode { + padding: 0 5px; + border: 1px; + border-style: solid; + background: #eee; + color: #000; + font-family: monospace; + font-size: 1.1em; +} + +.sample { + margin: 0 auto; +} \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t10-1.html b/CAAT/documentation/tutorials/t10-1.html new file mode 100644 index 0000000..b9c45df --- /dev/null +++ b/CAAT/documentation/tutorials/t10-1.html @@ -0,0 +1,330 @@ + + + + + + CAAT Tutorial 10 - Helpers. Audio manager. + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Helpers

            +

            Audio Manager

            +
            +

            + The CAAT.AudioManager object is located in the + file AudioManager.js. +

            +

            + Even though the AudioManager can be instantiated and used directly, it is + normally instrumented via a CAAT.Director + object. +

            +

            + This tutorial uses a director instance to perform audio play. +

            +

            + Prior to using the audio manager, audio elements must be preloaded into + the director. This can be done however + the developer likes more, either by defining audio elements in the + html, or by creating Audio objects. To do so the function + addAudio( id, url_or_DOMaudio ) must be called. + This function call is chainable, here's an example: +

            +
            +                            director.
            +                                addAudio('01', document.getElementById('audio_01')).
            +                                addAudio('10', document.getElementById('audio_10')).
            +                                addAudio('11', document.getElementById('audio_11'));
            +                        
            +
            +

            +

            + After this, the audio elements can be referenced by their ids, in this case + '01', '10', '11'. +

            +

            + The underlying AudioManager instance can play concurrently the same sound, + loop an audio, cancel playing sounds, etc. It is limited to a maximum number + of concurrent sounds though, 8 by default. So if concurrently more than 8 + audio elements are already playing, calling another audio play won't have + any effect until one ends playing. +

            +

            + The function audioLoop(id) will make a sound + loop. +

            +

            + The function audioPlay(id) will make a sound + play. It can be concurrently called up to 8 times (maximum number of audio + channels). +

            +

            + The functions setSoundEffectsEnabled + setMusicEnabled + isMusicEnabled + isSoundEffectsEnabled allow the developer + to know about music and FX flags status. +

            +

            + Looping audios are considered music, and playing audios sound effects, so + enabling/disabling Music or SoundEffects will enable/disable such audio + elements. +

            +

            + Finally, calling the method endSound() will + terminate Music and SoundEffects at once. It must be called again + audioLoop(id) for each music that wants to be + played. +

            +
            + +
            +

            Example

            +

            + Mouse over the colored actors to play a sound. Use audio controls to the right + to enable/disable music and/or FX. +

            + + + + + +
            + + +
            +
            +                        new CAAT.Module.Preloader.ImagePreloader().loadImages(
            +                                [
            +                                    { id:'sound', url:'resource/sound.png' }
            +                                ],
            +                                function(count, images) {
            +
            +                                    var director = new CAAT.Foundation.Director().initialize(400, 100, '_c1');
            +                                    director.setImagesCache(images);
            +                                    var scene = director.createScene();
            +
            +                                // add audio elements to director cache.
            +                                    director.
            +                                            addAudio('0', document.getElementById('audio_01')).
            +                                            addAudio('1', document.getElementById('audio_11')).
            +                                            addAudio('2', document.getElementById('audio_12')).
            +                                            addAudio('mm', document.getElementById('music'));
            +
            +                                    var actor = [];
            +                                    var i;
            +                                    var color = [ '#f00', '#0f0', '#00f' ];
            +
            +                                // create 3 actors to play each of the audio_xx sounds.
            +                                    for (i = 0; i < 3; i++) {
            +                                        var ac = new CAAT.Actor().
            +                                                setSize(100, 100).
            +                                                setFillStyle(color[i]);
            +
            +                                        (function(ac, i) {
            +                                // on mouseEnter, play the sound
            +                                            ac.mouseEnter = function(e) {
            +                                                ac.setStrokeStyle('green');
            +                                                director.audioPlay('' + i);
            +                                                CAAT.setCursor('pointer');
            +                                            };
            +                                        })(ac, i);
            +
            +                                        ac.mouseExit = function(e) {
            +                                            ac.setStrokeStyle(null);
            +                                            CAAT.setCursor('default');
            +                                        };
            +
            +                                        actor.push(ac);
            +                                        scene.addChild(ac);
            +                                    }
            +
            +                                // lay out the colored actors on a row
            +                                    CAAT.Module.LayoutUtils.RowLayout.Row(
            +                                            scene,
            +                                            actor,
            +                                            {
            +                                                padding_left: 10,
            +                                                padding_right:40
            +                                            }
            +                                    );
            +
            +                                // define audio control UI.
            +                                    var ci = new CAAT.Foundation.SpriteImage().initialize(director.getImage('sound'), 2, 3);
            +                                    var dw = director.width;
            +                                    var dh = director.height;
            +
            +                                // one button to enable/disabled music
            +                                    var music = new CAAT.Foundation.Actor().
            +                                            setAsButton(ci.getRef(), 0, 1, 0, 0,
            +                                            function(button) {
            +                                                director.setMusicEnabled(!director.audioManager.isMusicEnabled());
            +                                                if (director.isMusicEnabled()) {
            +                                                    button.setButtonImageIndex(0, 1, 0, 0);
            +                                                } else {
            +                                                    button.setButtonImageIndex(2, 2, 2, 2);
            +                                                }
            +
            +                                            }).
            +                                            setBounds(dw - ci.singleWidth - 2, 2, ci.singleWidth, ci.singleHeight);
            +
            +                                // one button to enable/disabled sound fx
            +                                    var sound = new CAAT.Foundation.Actor().
            +                                            setAsButton(ci.getRef(), 3, 4, 3, 3,
            +                                            function(button) {
            +                                                director.setSoundEffectsEnabled(!director.audioManager.isSoundEffectsEnabled());
            +                                                if (director.isSoundEffectsEnabled()) {
            +                                                    button.setButtonImageIndex(3, 4, 3, 3);
            +                                                } else {
            +                                                    button.setButtonImageIndex(5, 5, 5, 5);
            +                                                }
            +                                            }).
            +                                            setBounds(dw - ci.singleWidth - 2, 2 + 2 + ci.singleHeight, ci.singleWidth, ci.singleHeight);
            +
            +                                    scene.addChild(sound);
            +                                    scene.addChild(music);
            +
            +                                // set background music on.
            +                                    director.audioLoop('mm');
            +
            +                                    CAAT.loop(20);
            +                                });
            +
            +
            +                    
            +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t10-2.html b/CAAT/documentation/tutorials/t10-2.html new file mode 100644 index 0000000..4cfa72d --- /dev/null +++ b/CAAT/documentation/tutorials/t10-2.html @@ -0,0 +1,253 @@ + + + + + + CAAT Tutorial 10 - Helpers. CAAT.modules.ImageUtil + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Helpers

            +

            Image Utils

            +
            +

            + The image utils elements has some handy functions to manipulate and create + images on the fly. It is located at CAAT.modules.ImageUtils + and must be instantiated. +

            +
            +

            Alpha Sprite Sheet

            + The function createAlphaSpriteSheet(maxAlpha, minAlpha, sheetSize, image, bg_fill_style) + creates a new image with an sprite sheet of transparent copies of the same image. + The parameter bg_fill_style is optional, and if not set, it will create an image with transparency. +

            Example

            +
            +
            + +
            +
            +

            Optimize

            +

            + This function optimizes an image, that means, removes alpha transparency + surrounding the image. the function is optimize(image, threshold). + The threshold parameter indicates the minimum alpha value to consider transparent. + It is useful to remove all that insets your graphician loves to leave around every + bitmap he draws. +

            +

            + This is the original image, and the image optimized with a threshold of 32. Note + the resulting image is smaller in size. +

            +
            + +
            +
            +

            Thumb

            +

            + The function createThumb(image, width, height, best_fit) + creates a thumg from the original image of the given size. The source image + will be scaled accordingly to fit the new size. +

            +

            + The parameter best_fit will try to fit the image as best as possible to keep its + aspect ratio, otherwise, it will create a thumbnail of the given size. +

            +

            + In the example, the first thumb image, has a size which keeps aspect ratio. + The second one, is drawn with best_fit to false and the third one with best_fit + set to true. +

            +
            + +
            + +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t10-3.html b/CAAT/documentation/tutorials/t10-3.html new file mode 100644 index 0000000..01b3955 --- /dev/null +++ b/CAAT/documentation/tutorials/t10-3.html @@ -0,0 +1,152 @@ + + + + + + CAAT Tutorial 11 - SpriteImage + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Foundation.SpriteImage

            +
            +

            + This function creates the base object to hold Actor images. When setting a background image, + if a plain call to diretor.getImage("img_name") is called, the result will be encapsulated in + one instance of CAAT.SpriteImage. +

            +

            + The basic usage form, is to define a grid of subimages out of an image object. For example: + var si= new CAAT.SpriteImage().initialize( director.getImage("img"), rows, columns ) + will set an image as an array of rows*columns sub-images. After calling the method, the attributes + spriteImage.singleWidth, spriteImage.singleHeight will give each subimage's dimension. +

            +

            + The way to assign an image to an actor is by calling actor.setBackgroundImage( si, resize );. + If resize is true (default value), the actor size will be set to that of the sprite image subimage size. That means, + for an image 200x200 pixels, and an spriteImage of 4x2, the actor will be resized to 200/2 by 200/4 pixels. + The default subimage selected as actor image will the the zero index, or the first subimage. +

            +

            + From this point, you can select any of the SpriteImage subimages as actor background by calling + actor.setSpriteIndex(index). index is a value in the rango 0..rows*columns-1. +

            +

            + You can share the same sprite image among different actors to save some resources. To do so, a call to + actor.setBackgroundImage should be called the following way: actor.setBackgroundImage( + spriteImage.getRef() );. Otherwise, when changing the spriteImage's sprite index, it will be changed + for every actor. +

            +

            + A good feature of CAAT.SpriteImage actor, is the capability to define animation sequences. A call to + actor.setAnimationImageIndex( [] ). The array parameter are index values + to the SpriteImage's sub images. The combination of this method and + actor.setChangeFPS( millis ) is a perfect fit to create sprite animations. +

            +

            + Another feature of an actor sprite image is the call to the method + actor.setImageTransformation( value ). Values can be the following + CAAT.Foundation.SpriteImage. +

          • TR_FLIP_HORIZONTAL: invert horizontally.
          • +
          • TR_FLIP_VERTICAL: invert vertically.
          • +
          • TR_FLIP_ALL: invert vertical and horizontally at the same time.
          • +
          • TR_FIXED_TO_SIZE: scale the sprite image subimage to fit actor's size.
          • +
          • TR_TILE: tile with selected subimage.
          • +

            +
            +
            +

            More initialization functions:

            +

            + The previous functions are all (but the initialization) proxied to the SpriteImage instance through + out the actor object instance. But there're more initialization methods. +

            +
            +
            +

            + SpriteImage.initializeFromMap( image, map ) defines an atlas image. + The format of the map parameter is an object of the form: +

            +
            +                        {
            +                            id : {
            +                                x       : <number>,
            +                                y       : <number>,
            +                                width   : <number>,
            +                                height  : <number>
            +                            },
            +                            ...
            +                        }
            +                        
            +
            +

            +

            + This output can be automatically generated with this tool. + It can only be use to extract individual sprites out of an atlas image. +

            +
            +
            + SpriteImage.initializeAsMonoTypeFontMap( director.getImage("img"), chars ). +

            + This function, assumes a sprite image of size 1 row, and chars.length columns. This function relies + on the function spriteImage.initializeAsFontMap. +

            +

            + For example, this function could be called like: + spriteImage.initializeAsMonoTypeFontMap( director.getImage("img"), "0123456789" ) to have + defined a numbers font. +

            +

            + The resulting spriteImage, is initialized in a way so that a call to + spriteImage.drawString( ctx, str, x, y ) can be performed. Characters in str that weren't defined + in the initializeAsMonoTypeFontMap chars parameter won't be renderer on screen. +

            +
            +
            + SpriteImage.initializeAsFontMap( director.getImage("img"), map ) +

            + This function assumes a sprite image of 1 row and a number of non equal columns. The map parameter + has the following structure: +

            +
            +                            [
            +                                c       : <char>,
            +                                width   : <number> // character width in pixels
            +                            ]
            +                        
            +
            +

            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t10.html b/CAAT/documentation/tutorials/t10.html new file mode 100644 index 0000000..434c0a8 --- /dev/null +++ b/CAAT/documentation/tutorials/t10.html @@ -0,0 +1,58 @@ + + + + + + CAAT Tutorial 10 - Helpers + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Helpers

            +
            +

            + Helpers are some tools and utilities present at CAAT which can benefit + developer's work. +

            +

            + Some of them have just a rough cople of methods, but will grow as more + functionalities are needed. +

            +

            + These helpers range from audio play utilities to image or color manipulation. +

            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t12.html b/CAAT/documentation/tutorials/t12.html new file mode 100644 index 0000000..b6bc495 --- /dev/null +++ b/CAAT/documentation/tutorials/t12.html @@ -0,0 +1,138 @@ + + + + + + CAAT Tutorial 1 - Getting started + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +

            + CAAT.DEBUG +

            +

            + Set this varible to show a control panel showing some debug info, like FPS, currently animated + actors, bounding boxes, etc. +

            +
            + +
            +

            + CAAT.TOUCH_BEHAVIOR +

            +

            + By default this variable defaults to CAAT.TOUCH_AS_MOUSE, + which means, only one touch event will be handled, and will behave as a mouse. +

            +

            + It can also be set to CAAT.TOUCH_AS_MULTITOUCH, + which will handle multitouch events. +

            +
            + +
            +

            + CAAT.PMR +

            +

            + Default value for "points by meter" ratio. This value is needed for CAAT to Box2D binding. +

            +
            + +
            +

            + CAAT.DEBUG_DIRTYRECTS +

            +

            + Show affected dirty rectangles. +

            +
            + +
            +

            + CAAT.DRAG_THRESHOLD_X, CAAT.DRAG_THRESHOLD_Y +

            +

            + These values are a threshold that mouse drag events (or touch if CAAT.TOUCH_BEHAVIOR==CAAt.TOUCH_AS_MOUSE) + must traverse previously to have mouseDrag events triggered. These are needed when pointing with another + device than a mouse, like a Wacom tablet. Since these devices don't report the same coordinate when + pointing than when releasing, those values come handy. +

            +
            + +
            +

            + CAAT.SET_INTERVAL +

            +

            + Prevent using RAF for loop control in favor of setInterval function. Weird ? I've been reported + that with online games, when in another tab, the game will suspend. So I was asked for this + possibility. So there it is. +

            +
            + +
            +

            + CAAT.currentDirector +

            +

            + Readonly value which holds the reference of the currently rendering Director. +

            +
            + +
            +

            + CAAT.getCurrentScene() +

            +

            + Get current Director's current Scene. +

            +
            + +
            +

            + CAAT.RETINA_DISPLAY_ENABLED +

            +

            + If not false, CAAT will honor retina display and HIDPI screens behind the scenes. + This will set up a bigger as needed canvas object and set up appropriate scale + operations for drawing purposes. +

            +
            + + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-3.html b/CAAT/documentation/tutorials/t4-3.html new file mode 100644 index 0000000..65475ba --- /dev/null +++ b/CAAT/documentation/tutorials/t4-3.html @@ -0,0 +1,135 @@ + + + + + + + CAAT Tutorial 4 - Director, caching resources + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +

            Director

            +

            Caching Resources

            +

            + A director object is able to manage resources, concretely images and sounds. +

            +
            + +
            +

            Images

            +

            + Caching images is a pretty straightforward operation. The methods to manage + images are: +

            +

            + setImagesCache( obj ). This method substitutes + director's previous images cache. The obj parameter is an object of the form: +

            +
            +                            [
            +                                { id: string, image: image },
            +                                ...
            +                            ]
            +                        
            +
            + This method should be used in conjunction with an instance of + CAAT.ImagePreloader in the following way: +
            +
            +                            new CAAT.ImagePreloader().loadImages(
            +                                [
            +                                    {id:'fish',     url:'res/img/anim1.png'},
            +                                    {id:'fish2',    url:'res/img/anim2.png'},
            +                                    {id:'fish3',    url:'res/img/anim3.png'},
            +                                    ...
            +                                ],
            +
            +                                function( counter, images ) {
            +
            +                                    if ( counter==images.length ) {
            +                                        director.setImagesCache(images);
            +                                    }
            +                                }
            +                        
            +
            +

            +

            + Other image management methods are: +

            +

            + addImage : function( id, image, noUpdateGL ).
            + This method adds a new image to the cache. If the id parameter corresponds + to an already existent image, the image will be modified with the new one. + The parameter noUpdateGL if set to false, will cause the webGL texture pages + to be recreated. If rendering with webGL, this + operation is error prone, since the already created + CAAT.SpriteImage instances could reference wrongly its textures. +

            +

            + deleteImage : function( id, noUpdateGL ).
            + This method removes an image from the cache. As in the previous method, be + aware of calling this method with webGL enabled renderers. +

            +
            + +
            +

            Sound

            +

            + CAAT has a built in AudioManager which is able to play eight simultaneous sounds. + Each concurrent sound is called a channel, and allows to play concurrently the + same sound, loop (and fix FF<5 loop problems), etc. When there are arlready 8 + playing channels, no more sounds will be played until any channel gets + available. +

            +

            + The method to manage the sounds are: +

            +

            + addAudio : function(id, url).
            + This method adds a reference to an Audio or HTMLAudioElement object. +

            +

            + audioPlay : function(id).
            + Plays a sound, occupying a channel which will be freed upon audio play end. +

            +

            + audioLoop : function(id).
            + Loops a sound, occupying a channel which will be freed upon audio play end. +

            + +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-4.html b/CAAT/documentation/tutorials/t4-4.html new file mode 100644 index 0000000..4ee00a6 --- /dev/null +++ b/CAAT/documentation/tutorials/t4-4.html @@ -0,0 +1,426 @@ + + + + + + CAAT Tutorial 4 - Director, Switching Scenes + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Switching Scenes

            +
            +

            + During execution, the Director class instance exposes a lot of functionality + to switch between two given Scenes or to change the current Scene. + The following methods will do it: +

            + +

            + function setScene( sceneIndex ).
            + Changes (or sets) the current Director scene to the index specified + as parameter. There will be no transition on scene change. +

            +

            + function switchToPrevScene(time, alpha, transition).
            + function switchToNextScene(time, alpha, transition).
            + These methods will switch from the current scene to the previous or next one + respectively. The supplied parameters are:

            +
              +
            • time: how much time to take for the switching process. Expressed in milliseconds.
            • +
            • alpha: wheter alpha transparency fading should be applied to entering/exiting scenes.
            • +
            • transition: whether to apply transition for the entering and exiting scenes.
            • +
            + The type of transition will be set randomly. + +

            + function easeInOut( inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, + alpha, + interpolatorIn, interpolatorOut ).
            + This method offers full control over the process of switching between + any given two Scenes. + To apply this method, you must specify the type of transition to apply + for each Scene and the anchor to keep the Scene pinned at. + The type of transition will be one of the following values defined in + CAAT.Foundation.Scene: +

              +
            • EASE_ROTATION +
            • EASE_SCALE +
            • EASE_TRANSLATION +
            + The anchor will be any of these values defined in CAAT.Foundation.Actor: +
              +
            • ANCHOR_CENTER +
            • ANCHOR_TOP +
            • ANCHOR_BOTTOM +
            • ANCHOR_LEFT +
            • ANCHOR_RIGHT +
            • ANCHOR_TOP_LEFT +
            • ANCHOR_TOP_RIGHT +
            • ANCHOR_BOTTOM_LEFT +
            • ANCHOR_BOTTOM_RIGHT +
            + In example, for an entering scene performing a EASE_SCALE transition, + the anchor is the point by which the scene will scaled. + +

            + function easeInOutRandom(inIndex,outIndex,time,alpha).
            + This method will switch between two given Scene indexes (ie, take away scene + number 2, and bring in scene number 5). + It will randomly choose for each Scene the type of transition to apply and + the anchor point of each transition type. + It will also set for different kind of transitions the following interpolators: +

              +
            • EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +
            • EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +
            • EASE_TRANSLATION -> BounceOutInterpolator +
            + These are the default values, and could not be changed by now. + This method in final instance delegates the process to easeInOutMethod. + +
            +
            +

            Example

            +

            + This example show two scenes with a button to switch to next and previous + scene. Every time, a different transition will be played. Note that scenes + get paused when being removed from screen, and that input won't be enabled + until entering scene's transition ends. +

            +
            +
            +                        // screat an actor with the text Scene1 or Scene2
            +                            function createNumber(director, n, color) {
            +                                var actor= new CAAT.Foundation.UI.TextActor().
            +                                        setFont("200px Lucida-sans").
            +                                        setText("Scene "+n).
            +                                        setAlign("center").
            +                                        setTextBaseline("center").
            +                                        setTextFillStyle(color).
            +                                        setOutline(true).
            +                                        cacheAsBitmap().
            +                                        enableEvents(false).
            +                                        addBehavior(
            +                                            new CAAT.Behavior.RotateBehavior().
            +                                                    setFrameTime( 0, 20000 ).
            +                                                    setValues( 0, 2 * Math.PI ).
            +                                                    setCycle( true ) );
            +
            +                                actor.centerAt( director.width/2, director.height/2 );
            +                                return actor;
            +                            }
            +
            +                        // create an actor with a custom paint method. its behavior resembles that of
            +                        // a button.
            +                            function createButton(director, rotated) {
            +                                var actor= new CAAT.Foundation.Actor().
            +                                        setSize( 60, 60 ).
            +                                        centerAt( director.width - 40, director.height - 40 );
            +
            +                                actor.paint= function( director, time ) {
            +
            +                                    var ctx= director.ctx;
            +                                    ctx.save();
            +                                    if ( rotated ) {
            +                                        ctx.translate( this.width, 0 );
            +                                        ctx.scale(-1,1);
            +                                    }
            +
            +                                    ctx.fillStyle= this.pointed ? 'orange' : '#f3f';
            +                                    ctx.fillRect(0,0,this.width,this.height );
            +
            +                                    ctx.strokeStyle= this.pointed ? 'red' : 'black';
            +                                    ctx.strokeRect(0,0,this.width,this.height );
            +
            +                                    ctx.strokeStyle='white';
            +                                    ctx.beginPath();
            +                                    ctx.moveTo(5,10);
            +                                    ctx.lineTo(20,10);
            +                                    ctx.lineTo(15,5);
            +
            +                                    ctx.moveTo(20,10);
            +                                    ctx.lineTo(15,15);
            +
            +                                    ctx.lineWidth=2;
            +                                    ctx.lineJoin='round';
            +                                    ctx.lineCap='round';
            +                                    ctx.stroke();
            +                                    ctx.restore();
            +
            +                                    ctx.font= '10px sans-serif';
            +                                    ctx.fillStyle='black';
            +                                    ctx.fillText(
            +                                        rotated ? 'Prev Scene' : 'Next Scene',
            +                                        3,
            +                                        45);
            +
            +
            +                                };
            +
            +                                return actor;
            +                            }
            +
            +                        // create a background pattern of horizontal and vertical lines
            +                            function createPattern(director, color) {
            +                                var actor= new CAAT.Foundation.Actor().
            +                                        setSize(director.width,director.height).
            +                                        enableEvents(false);
            +
            +                                actor.paint= function( director, time ) {
            +
            +                                    var i,j,ctx;
            +
            +                                    if ( this.backgroundImage ) {
            +                                        this.backgroundImage.paint(director,0,0,0);
            +                                        return;
            +                                    }
            +
            +                                    ctx= director.ctx;
            +
            +                                    for( j=0.5; j
            +                
            +
            + +

            + +

            +
            +
            +
            +
            + + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-5.html b/CAAT/documentation/tutorials/t4-5.html new file mode 100644 index 0000000..da5e8f2 --- /dev/null +++ b/CAAT/documentation/tutorials/t4-5.html @@ -0,0 +1,64 @@ + + + + + + CAAT Tutorial 4 - Director utils + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Utils

            + +

            + The director object exposes some utility methods to know what environment it is + being played. Methods such us +

            +

            + getBrowserName(). Get the running browser name. +

            +

            + getBrowserVersion(). Get the running browser version. +

            +

            + getOSName(). Get the operating system name. +

            +

            + getRendererType(). Get the director rendering technology. + Will return either 'CSS','CANVAS' or 'WEBGL'; +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-6-p.html b/CAAT/documentation/tutorials/t4-6-p.html new file mode 100644 index 0000000..f023138 --- /dev/null +++ b/CAAT/documentation/tutorials/t4-6-p.html @@ -0,0 +1,102 @@ + + + + + + + + +
            Resize me
            + +
            + + + + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-6.html b/CAAT/documentation/tutorials/t4-6.html new file mode 100644 index 0000000..d21b7b5 --- /dev/null +++ b/CAAT/documentation/tutorials/t4-6.html @@ -0,0 +1,74 @@ + + + + + + CAAT Tutorial 4 - Director resize events + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Resize Events

            + +

            + The director object can listen to window resize events and thus adapt itself to + the new conditions, either by conforming its size, or by scaling accordingly. +

            +

            + The resize values are defined in CAAT.Foundation.Director and are the following: +

              +
            • RESIZE_WIDTH, only conforms director's width. +
            • RESIZE_HEIGHT, only conforms director's height. +
            • RESIZE_BOTH, resizes both width and height. +
            • RESIZE_PROPORTIONAL, the director scales accordingly. + Sample (opens a new window) +
            +

            +

            + To enable the resizing event listening, a call to director's + enableResizeEvents(resize_constant, onResizeCallback). +

            +

            + This method, will cause a director, and its contained scenes resize. But has no idea on how to make + your scene actors conform to the new size. The onResizeCallback function + is comes handy for this purpose, since you have the opportunity to modify your actor's dimension, + position or desired attributes upon being called. +

            +

            + The callback function signature is as follow: function( director, newWidth, newHeight ). +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-7.html b/CAAT/documentation/tutorials/t4-7.html new file mode 100644 index 0000000..ce7fee8 --- /dev/null +++ b/CAAT/documentation/tutorials/t4-7.html @@ -0,0 +1,77 @@ + + + + + + CAAT Tutorial 4 - Director keyboard events + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            +

            Keyboard Events

            + +

            + The director object can receive keyboard events. In fact, it is not a + director object's property, but a CAAT environment property. +

            +

            + Simply by calling: +

            +
            +                        /**
            +                         * @param key {number} key code
            +                         * @param action {up|down}
            +                         * @param modifiers {object} is as object with the structure
            +                         *   {
            +                         *     alt:     {boolean},
            +                         *     control: { boolean },
            +                         *     shift:   { boolean }
            +                         *   }
            +                         * @param originalKeyEvent {object} the original key event. Suitable for calling
            +                         *  preventdefault.
            +                         */
            +                        CAAT.registerKeyListener( function(key,action,modifiers,originalKeyEvent) {
            +                                if ( key==68 && action=='up') {
            +                                    director.debug= !director.debug;
            +                                }
            +                            });
            +                    
            +
            + the parameter function will be notified upon action='up' or action='down' for + each key press event. +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t4-8.html b/CAAT/documentation/tutorials/t4-8.html new file mode 100644 index 0000000..6ecd19e --- /dev/null +++ b/CAAT/documentation/tutorials/t4-8.html @@ -0,0 +1,192 @@ + + + + + + CAAT Tutorial 4 - Director accelerometer events + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Director

            + +

            Accelerometer Events

            + +

            + The director object can receive accelerometer events. In fact, it is not a + director object's property, but a CAAT environment property. The accelerometer + vales, are directly accesible from CAAT's environment and will only work on + FF3+ or Chrome. +

            +

            + To start capturing accelerometer info, you must call + CAAT.enableDeviceMotion();. +

            + +

            + Accelerometer angle values can be accesed via + +

            +
            +                        CAAT.rotationRate.alpha
            +                        CAAT.rotationRate.beta
            +                        CAAT.rotationRate.gamma
            +                    
            +
            +

            +
            +

            Example

            + +

            + In this example, when moving your laptop, the text will rotate to be readable + horizontally. It will only work on FF3+ and Chrome. +

            + +
            + +
            +
            +
            +
            +                        var CW = 700;
            +                        var CH = 400;
            +                        /**
            +                         * Startup it all up when the document is ready.
            +                         * Change for your favorite frameworks initialization code.
            +                         */
            +                        window.addEventListener(
            +                                'load',
            +                                __accelerometer,
            +                                false);
            +
            +                        function __accelerometer(director) {
            +
            +                            CAAT.enableDeviceMotion();
            +
            +                            var director = new CAAT.Foundation.Director().
            +                                    initialize(CW, CH, document.getElementById('_c'));
            +                            var i;
            +                            var scene = director.createScene();
            +
            +                            scene.activated = function() {
            +                                director.setClear(false);
            +                            };
            +
            +                            var root = new CAAT.Foundation.ActorContainer().setBounds(0, 0, director.width, director.height);
            +                            scene.addChild(root);
            +
            +                            var text = new CAAT.Foundation.UI.TextActor().
            +                                    setFont("100px sans-serif").
            +                                    setText("Rotate Device").
            +                                    setFillStyle('red').
            +                                    setOutlineColor('#ffff00').
            +                                    setOutline(true).
            +                                    setAlign("center").
            +                                    setBaseline("center").
            +                                    cacheAsBitmap();
            +                            scene.addChild(text.centerAt(director.canvas.width/ 2, director.canvas.height/ 2));
            +
            +                            // Hook on scene life cycle. After rendering, calculate an angle based on accelerometer
            +                            // information for the text.
            +                            scene.onRenderEnd = function(director, time) {
            +                                var rx = CAAT.rotationRate.gamma;
            +
            +                                var ixy = -rx * Math.PI / 180;
            +                                text.setRotation(ixy);
            +                            };
            +
            +                            CAAT.loop(33);
            +                        }
            +                    
            +
            + + +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t5-1.html b/CAAT/documentation/tutorials/t5-1.html new file mode 100644 index 0000000..fb96d6c --- /dev/null +++ b/CAAT/documentation/tutorials/t5-1.html @@ -0,0 +1,78 @@ + + + + + + CAAT Tutorial 5 - Scene time line hooks + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +

            CAAT.Scene

            +

            Time line hooks

            + +

            + As we've said, an Scene has its own timeline. This is a virtual timeline, + which is fed by the Director and is independant of other scene's time line.

            + An Scene will start feeding is timeline as soon as it starts to be brought + in to the Director. + An Scene will stop feeding is timeline as soon as the Director finishes starts + taking the scene out. +

            +

            + The Scene's timeline will be the reference time passed to all of its children + as their current animation time. +

            + +

            + When an Scene is not anymore visible its timeline will be paused until the + Scene will again be elligible to feed its timeline. +

            + +

            + Exactly as the Director, the Scene can set hooks by setting a function + onRenderStart and a function + onRenderEnd. + These both methods will receive a parameter with scene's virtual time. +

            +

            + There's another hook point on scenes and is the method + activated. If set, this method will be called when the scene is totally + brought in and is ready to receive input events. +

            + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/t5-2.html b/CAAT/documentation/tutorials/t5-2.html new file mode 100644 index 0000000..6658298 --- /dev/null +++ b/CAAT/documentation/tutorials/t5-2.html @@ -0,0 +1,455 @@ + + + + + + CAAT Tutorial 5 - Scene timers + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +

            CAAT.Scene

            + +

            Timers

            + +

            + Each Scene can have an unlimited number of timers which will run upon its + virtual time line. The timers will be backed into a + CAAT.TimerTask object instance. It is important + to note that timers will be paused when scenes are removed from screen. +

            + +

            + Each timer is defined by 5 parameters: +

              +
            • The timer start time, related to scene's time.
            • +
            • The timer duration. How many milliseconds to last until timer expiration
            • +
            • A expiration callback.
            • +
            • A timer tick callback.
            • +
            • A timer cancellation callback.
            • +
            +

            +

            + The timer tick will be called everytime it is in director's frame time. + This is suitable for modelling a chronometer in CAAT. +

            + +

            + The expiration and cancellation callbacks will be called only once, either on + expiration or on cancellation. +

            + +

            + The parameters received by the callbacks are: +

              +
            • + Scene time when the callback has been generated. +
            • +
            • + Timertask time when the callback has been generated. This is a value between + zero and timer task duration. +
            • +
            • + The timer task object. +
            • +
            +

            +

            + At any moment, the timer task can be set to start at another scene time. + This is useful for the situation when the timer task has expired and you'd like + to restart it again keeping the same duration. +

            + +
            +

            + In this example, you can see two timer task which show a chronometer + for elapsed time. One chronometer drawn on every timer tick, and the + other upon timer task expiration. When expired, it is being reset to + start counting time again. The example has two scenes to demonstrate + that timers are per scene, and thus will count and pause independently. +

            + +
            + +
            + +
            + +
            +
            +
            +        function createText(director, color) {
            +            var actor = new CAAT.Foundation.UI.TextActor().
            +                    setFont("100px Lucida sans").
            +                    setTextFillStyle(color).
            +                    setOutline(true).
            +                    enableEvents(false);
            +
            +            return actor;
            +        }
            +
            +        function createButton(director, rotated) {
            +            var actor = new CAAT.Foundation.Actor().
            +                    setSize(60, 60).
            +                    centerAt(director.width - 40, director.height - 40);
            +
            +            actor.paint = function (director, time) {
            +
            +                var ctx = director.ctx;
            +                ctx.save();
            +                if (rotated) {
            +                    ctx.translate(this.width, 0);
            +                    ctx.scale(-1, 1);
            +                }
            +
            +                ctx.fillStyle = this.pointed ? 'orange' : '#f3f';
            +                ctx.fillRect(0, 0, this.width, this.height);
            +
            +                ctx.strokeStyle = this.pointed ? 'red' : 'black';
            +                ctx.strokeRect(0, 0, this.width, this.height);
            +
            +                ctx.strokeStyle = 'white';
            +                ctx.beginPath();
            +                ctx.moveTo(5, 10);
            +                ctx.lineTo(20, 10);
            +                ctx.lineTo(15, 5);
            +
            +                ctx.moveTo(20, 10);
            +                ctx.lineTo(15, 15);
            +
            +                ctx.lineWidth = 2;
            +                ctx.lineJoin = 'round';
            +                ctx.lineCap = 'round';
            +                ctx.stroke();
            +                ctx.restore();
            +
            +                ctx.font = '10px sans-serif';
            +                ctx.fillStyle = 'black';
            +                ctx.fillText(
            +                        rotated ? 'Prev Scene' : 'Next Scene',
            +                        3,
            +                        45);
            +
            +
            +            };
            +
            +            return actor;
            +        }
            +
            +        function format(time) {
            +            var millis = time % 1000;
            +            time /= 1000;
            +            time >>= 0;
            +
            +            var seconds = time % 60;
            +            time /= 60;
            +            time >>= 0;
            +
            +            var mins = time % 60;
            +            time /= 60;
            +            time >>= 0;
            +
            +            var hours = time;
            +
            +            return '' +
            +                    (hours > 9 ? hours : '0' + hours) +
            +                    ' : ' +
            +                    (mins > 9 ? mins : '0' + mins) +
            +                    ' : ' +
            +                    (seconds > 9 ? seconds : '0' + seconds) +
            +                    '.' +
            +                    millis;
            +        }
            +
            +        function createScene(director, rotated) {
            +
            +            var scene1 = director.createScene();
            +            var s1t1 = createText(director, 'red');
            +            var s1t2 = createText(director, 'green');
            +            scene1.addChild(s1t1.setLocation(20, 20));
            +            scene1.addChild(s1t2.setLocation(20, 150));
            +
            +            // create a timer which runs for ever
            +            // on every timer tick, update counter.
            +            scene1.createTimer(
            +                    0,
            +                    Number.MAX_VALUE,
            +                    function (scene_time, timer_time, timertask_instance) {   // timeout
            +                    },
            +                    function (scene_time, timer_time, timertask_instance) {   // tick
            +                        s1t1.setText(format(timer_time));
            +                    },
            +                    function (scene_time, timer_time, timertask_instance) {   // cancel
            +                    }
            +            )
            +
            +            var seconds1 = 0;
            +            scene1.createTimer(
            +                    0,
            +                    1000,
            +                    function (scene_time, timer_time, timertask_instance) {   // timeout
            +                        seconds1 += 1000;
            +                        timertask_instance.reset(scene_time);
            +                        s1t2.setText(format(seconds1));
            +                    },
            +                    function (scene_time, timer_time, timertask_instance) {   // tick
            +                    },
            +                    function (scene_time, timer_time, timertask_instance) {   // cancel
            +                    }
            +            )
            +
            +            // this timer increases timer count on timeout, and then, resets itself.
            +            var button = createButton(director, rotated);
            +            button.mouseClick = function (e) {
            +                if (!rotated) {
            +                    director.switchToNextScene(
            +                            2000,
            +                            false,
            +                            true);
            +                } else {
            +                    director.switchToPrevScene(
            +                            2000,
            +                            false,
            +                            true);
            +                }
            +
            +            }
            +            scene1.addChild(button);
            +
            +        }
            +
            +        function __scene1() {
            +            var director = new CAAT.Foundation.Director().
            +                    initialize(700, 300, document.getElementById('_c1'));
            +
            +            // create 2 scenes to show timers are per scene.
            +            createScene(director, false);
            +            createScene(director, true);
            +
            +            CAAT.loop(60);
            +        }
            +
            +        __scene1();
            +
            +    
            +
            + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/t5.html b/CAAT/documentation/tutorials/t5.html new file mode 100644 index 0000000..2436432 --- /dev/null +++ b/CAAT/documentation/tutorials/t5.html @@ -0,0 +1,94 @@ + + + + + + CAAT Tutorial 5 - Scene + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            + +

            CAAT.Scene

            + +

            The CAAT.Scene object is the main container of animation Actors in a Scene. + It is an advanced ActorContainer which has two main responsibilities: +

              +
            1. Knows how to elegantly get out of screen +
            2. Maintain a virtual timeline for all its contained Actors fed by a Director. +
            + +

            + An Scene can not contain neither other Scenes, nor any Director. The size of + the scene will by default be the same of the Director, and hence, equals to + the Canvas size, that is, the values passed to director's initialize method. + The canvas size may vary with the window resize listener thought.

            + +

            + There are two ways of creating an scene: +

              +
            1. + Manually, by calling var scene= new CAAT.Scene() + and then adding it to the director by calling + director.addScene(scene);. +
            2. +
            3. + The recommended way which is call + director.createScene() which also adds the scene to the director + instance. +
            4. +
            + +

            + The only method the devloper should call directly on Scene instances is + addChild(actor) which adds a new animation + Actor to the Scene. It can be any kind of ActorContainer or Actor. +

            + +

            There's no limitation regarding the number of elements in an Scene, but for + better performance, the developer should create groups of actors in containers, + as if they where in layers. The performance hit is + strictly on event dispatching to Scene Actors, since the event bubbling will + try to check for every Actor in a Container (or Scene) if it is the target + of a concrete event. +

            + +

            + The Actors on a Scene will keep z-order equally to the same order as they were added to the + Scene/ActorContainer, so the last added Actor, will be behind all the other Actors. +

            + +
            +
            +
            + + diff --git a/CAAT/documentation/tutorials/t6-1.html b/CAAT/documentation/tutorials/t6-1.html new file mode 100644 index 0000000..2183add --- /dev/null +++ b/CAAT/documentation/tutorials/t6-1.html @@ -0,0 +1,201 @@ + + + + + + CAAT Tutorial 6 - Behavior life cycle + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Behavior

            + +

            Life cycle

            + +
            +

            + A Behavior has a very simple lifecycle. If the Behavior is not cycling, + the developer has the option of being notified on Behavior + expiration by adding a listener to it. + This is a simple triggering mechanism by which you will get informed of + which Behavior has expired, and at exactly what time. + The behavior listener can also be notified every time the behavior has + been applied. + A behavior is guaranteed to apply the final + value it is defined for. + +

            + A behavior listener is an object of the form: + +

            +
            +                            {
            +                                behaviorExpired : function( behavior, time, actor);
            +                                behaviorApplied : function( behavior, time, normalizedTime, actor, value);
            +                            }
            +                        
            +
            + Note that any behavior can have an arbitrary + number of observers. +

            +

            + A behavior observer will be added by calling + addListener( behavior_listener_object ). +

            + +

            + The behavior listener object function behaviorExpired + parameters are: +

              +
            1. The CAAT.Behavior object that just expired.
            2. +
            3. The CAAT.Scene object time the CAAT.Behavior just expired at.
            4. +
            5. The CAAT.Actor the CAAT.Behavior was acting upon.
            6. +
            +

            + and for the function behaviorApplied + parameters are: +

              +
            1. The CAAT.Behavior object that just expired.
            2. +
            3. The CAAT.Scene object time the CAAT.Behavior just expired at.
            4. +
            5. The behavior related time it was applied at.
            6. +
            7. The CAAT.Actor the CAAT.Behavior was acting upon.
            8. +
            9. The behaviors value that has been applied.
            10. +
            +

            + +

            + In this example, two behaviors are set for an actor. When on ebehavior expires, the + other one is started and vice versa:

            + +
            + +
            + +
            + +
            +
            +var director_4 = new CAAT.Foundation.Director().initialize(160, 160, "_c4");
            +var scene_4 = director_4.createScene();
            +
            +var shape = new CAAT.Foundation.UI.ShapeActor().
            +        setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE).
            +        setLocation(50, 50).
            +        setSize(60, 60).
            +        setFillStyle('#f00').
            +        setStrokeStyle('#000');
            +scene_4.addChild(shape);
            +
            +var scaleBehavior = new CAAT.Behavior.ScaleBehavior().
            +        setPingPong().
            +    // 50, 50 means to scale at 50% actor width and 50% actor height
            +    // its center.
            +        setValues(1, 2, 1, 2, .50, .50).
            +    // scale Behavior enabled by default. Start at time=2000ms, and
            +    // last for 3000ms.
            +        setFrameTime(2000, 3000);
            +
            +// unless otherwise stated, Behaviors are expired by default,
            +// so this actor won't rotate until instrumented to do so.
            +var rotateBehavior = new CAAT.Behavior.RotateBehavior().
            +    // 50, 50 means to scale at 50% actor width and 50% actor height
            +    // its center.
            +        setValues(0, 2 * Math.PI, .50, .50);
            +
            +shape.addBehavior(scaleBehavior);
            +shape.addBehavior(rotateBehavior);
            +
            +// when scale Behavior finishes, start rotation Behavior.
            +scaleBehavior.addListener({
            +    behaviorExpired : function(behavior, time, actor) {
            +        rotateBehavior.setFrameTime(time, 3000);
            +    }});
            +
            +// when rotation Behavior finishes, start scale Behavior.
            +rotateBehavior.addListener({
            +    behaviorExpired : function(behavior, time, actor) {
            +        scaleBehavior.setFrameTime(time, 3000);
            +    }});
            +
            +director_4.loop(30);
            +
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t6-2.html b/CAAT/documentation/tutorials/t6-2.html new file mode 100644 index 0000000..2fb620b --- /dev/null +++ b/CAAT/documentation/tutorials/t6-2.html @@ -0,0 +1,237 @@ + + + + + + CAAT Tutorial 6 - Behaviors, out-of-the-box behaviors + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Behavior

            +

            Out-of-the-box behaviors

            + +
            + Every actor is defined with a method chain call like the following: +
            +
            +                        var behavior= new CAAT.<Type>Behavior().
            +                            setValues( values parameters ).
            +                            setFrameTime( start_time, duration ).
            +                            setCycle( boolean, by default no ).
            +                            addListener( {
            +                                behaviorApplied : function(...),
            +                                behaviorExpired : function(...)
            +                            } );
            +                    
            +
            +
            + +
            +

            CAAT.AlphaBehavior

            +

            + This behavior must have two values, one for the start alpha and another + for the last alpha value. + This alpha value affects to a container and its children honoring the + isGlobalAlpha property. + The method setValues accepts two values + from zero to 1. +

            +
            + +
            +

            CAAT.RotateBehavior

            +

            + The method setValues accepts four values: + the two first values define the starting and ending rotation angle values + in radians. + The other two values are the rotation anchor point defined in relative + percent to actor's width and height. The two values at 50 means rotation + around actor's center. These two values must be between zero and a hundred. +

            +

            + If no anchor values are specified, actor's center + will be set by default. +

            +
            + +
            +

            CAAT.ScaleBehavior

            +

            + The method setValues accepts six values: + the two first values define the starting and ending x axis scale values. + The two next values define the starting and ending y axis scale values. + The last two define an anchor point for scale just like CAAT.RotateBehavior + does. + Both anchors can be different so that you can + set rotation around the center and scale from bottom right corner +

            +

            + If no anchor values are specified, actor's center + will be set by default. +

            +
            + +
            +

            CAAT.PathBehavior

            +

            + The method setValues accepts one single value + which must be a CAAT.Path object instance. + The actor origin (0,0) position and not its center will be positioned on + the path. +

            +

            + This behavior has two exclusive methods: +

            +

            + The function setAutorotate(boolean) if set, + actors traversing a path will be rotated accordingly so that it heads + to the next path point. +

            +

            + The function setTranslation(x,y) define an + offset displacement to set what actor position you want to be on the path + instead its origin.. deprecated see Actor.setPositionAnchor(anchorx,anchory). +

            +

            + The following example show a rectangle centered and traversing a path: +

            + +
            + + + +
            +
            +            var director = new CAAT.Director().initialize(
            +                    250,250,document.getElementById('_c6'));
            +            var scene=  director.createScene();
            +
            +            var shape= new CAAT.StarActor().
            +                    initialize( 8, 30, 10 ).
            +                    setLocation( 50,50 ).
            +                    setSize(50,50).
            +                    setFillStyle('#00f').
            +                    setStrokeStyle('#0f0').
            +                    setOutlined(true).
            +                    setAlpha(.75);
            +
            +            // add two rectangle shapes to the scene.
            +            scene.addChild(shape);
            +
            +            // create a circular path.
            +            var path= new CAAT.Path().
            +                    beginPath(25,125).
            +                    addCubicTo( 25,25,   225,25,   225,125 ).
            +                    addCubicTo( 225,225,  25,225,  25,125 ).
            +                    endPath();
            +
            +            // add an actor to show the path.
            +            var path_actor= new CAAT.PathActor().
            +                    setPath(path).
            +                    setBounds(0,0,director.width,director.height);
            +            scene.addChild( path_actor );
            +
            +            // setup up a path traverser for the path.
            +            var path_behavior= new CAAT.PathBehavior().
            +                    setPath( path ).
            +                // take 5 seconds to traverse the path
            +                    setFrameTime(0,5000).
            +                // do it continuously, not just one time
            +                    setCycle(true).
            +                // head the actor across the path to the next point.
            +                    setAutoRotate( true ).
            +                // set path traverse by the center of the rectangle shape.
            +                    setTranslation(
            +                        shape.width/2,
            +                        shape.height/2);
            +
            +            shape.addBehavior( path_behavior );
            +
            +            CAAT.loop(30);
            +    
            +
            + + +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t6-3.html b/CAAT/documentation/tutorials/t6-3.html new file mode 100644 index 0000000..63ac6a4 --- /dev/null +++ b/CAAT/documentation/tutorials/t6-3.html @@ -0,0 +1,190 @@ + + + + + + CAAT Tutorial 6 - ContainerBehavior + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Behavior

            +

            CAAT.ContainerBehavior

            + +

            + A CAAT.Actor can have any number of CAAT.Behaviors enabled at once. + There are no constraints about their type, duration + and property application so the developer must take care of overlapping + in time behavior instances. +

            +

            + There's also the possibility of grouping CAAT.Behaviors together as if they + were just a single CAAT.Behavior. This can be accomplished by using a + CAAT.BehaviorContainer. The features a container are: +

              +
            1. + A CAAT.ContainerBehavior can contain many other CAAT.Behavior instances, including other + CAAT.ContainerBehaviors +
            2. +
            3. + It relates its contained children time from zero to its duration. + This means that contained baheviors have zero time when the container + starts. +
            4. +
            5. + Any contained behavior can not last beyond the container time duration. + This means, the behavior will stop applying when the container + duration is reached. +
            6. +
            +

            + In the following example, we're going to set up a simple container behaviour. + For the ease of the demo, the container has a lifecycle longer than its + children behaviors. During the time that no behavior is being applied, + nothing happens. + Despite having a start time of 0 and 500, the children behaviors won't + start applying until 5000 and 5500 milliseconds have elapsed respectively. + This is because the children behaviors won't starts applying until the container + does. + + +

            + + + +
            + +
            + + +
            +
            +                    var director = new CAAT.Foundation.Director().initialize(150, 150, '_c5');
            +                    var scene = director.createScene();
            +
            +                    var shape = new CAAT.Foundation.UI.ShapeActor().
            +                            setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE).
            +                            setLocation(50, 50).
            +                            setSize(50, 50).
            +                            setFillStyle('#ff0').
            +                            setStrokeStyle('#000')
            +                    scene.addChild(shape);
            +
            +                    // set a Container for behaviors up.
            +                    var cb = new CAAT.Behavior.ContainerBehavior().
            +                            setCycle(true).
            +                        // take 3 seconds to perform contained behaviors. If any
            +                        // takes more than such time, it will be truncated.
            +                            setFrameTime(0, 3000);
            +
            +                    // setup an Scaling behavior. Min scale 1, Max scale 2
            +                    // (twice in size)
            +                    var sb = new CAAT.Behavior.ScaleBehavior().
            +                            setPingPong().
            +                            setValues(1, 2, 1, 2, .50, .50).
            +                        // takes 2 seconds to scale. time measured from parent's
            +                        // zero time.
            +                            setFrameTime(0, 2000);
            +
            +                    // setup a Rotating behavior. 0-2PI, ie 360 degrees.
            +                    var rb = new CAAT.Behavior.RotateBehavior().
            +                            setValues(0, Math.PI, .50, .50).
            +                        // takes 1 second, starting half a second after parent's
            +                        // time.
            +                            setFrameTime(500, 1000);
            +
            +                    // add scale and rotation to the rectangle.
            +                    cb.addBehavior(sb);
            +                    cb.addBehavior(rb);
            +
            +                    // add path and conpound behavior of rotation and scale to
            +                    // the rectanble shape.
            +                    shape.addBehavior(cb);
            +
            +                    CAAT.loop(30);
            +
            +                
            +
            + + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t6-4.html b/CAAT/documentation/tutorials/t6-4.html new file mode 100644 index 0000000..b657b00 --- /dev/null +++ b/CAAT/documentation/tutorials/t6-4.html @@ -0,0 +1,50 @@ + + + + + + CAAT Tutorial 6 - CAAT.GenericBehavior + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Behavior

            +

            CAAT.GenericBehavior

            + +

            + TBD +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t6.html b/CAAT/documentation/tutorials/t6.html new file mode 100644 index 0000000..74e1d84 --- /dev/null +++ b/CAAT/documentation/tutorials/t6.html @@ -0,0 +1,187 @@ + + + + + + CAAT Tutorial 6 - Behaviors + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Behaviors

            + +

            + Behaviors are timeboxed modifiers for some special CAAT.Actors properties. +

            + +

            + Concretely there are already out-of-the-box Behaviors to manage: +

              +
            1. Rotations +
            2. Translations across (complex or not) Paths +
            3. Scale +
            4. Alpha transparency +
            5. Compositions of all the other types
            6. +
            + +

            + Behaviors apply to every kind of CAAT.Actor, including Scenes. + This means you can easily instrument an actor instance to rotate some degrees, + scale horizontally or vertically, etc. with fine grained time control. One + important thing to note about behaviors is that + applying a behavior to a container makes it affect all its children. + In example, if rotating a container, all its content will be rotated accordingly. + +

            + Behaviors apply linearly by default but there are + Interpolators which can modify this by for example applying easing + functions. +

            +

            + Every behavior instance must have the methods + setFrameTime( time ) which defines the temporal + frame where the behavior will be applied and + setValues( variable number of parameters ) which defines the behavior + values, called. +

            + +
            +

            + In this simple example, we're applying alpha behaviors to a rectangle and a + circle. The rectangle's behavior keeps applying forever (setCycle is true) + and the circle's one will last for ten seconds and finish applying. +

            + + +
            + +
            + + + +
            +
            +                    var director = new CAAT.Foundation.Director().initialize(150, 80, '_c2');
            +                    var scene = director.createScene();
            +
            +                    // create a rectangle
            +                    var rectangle = new CAAT.Foundation.UI.ShapeActor().
            +                            setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE).
            +                            setLocation(10, 10).
            +                            setSize(60, 60).
            +                            setFillStyle('#ff0000').
            +                            setStrokeStyle('#000000');
            +
            +                    // create a circle
            +                    var circle = new CAAT.Foundation.UI.ShapeActor().
            +                            setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE).
            +                            setBounds(80, 10, 60, 60).
            +                            setFillStyle('#00ff00').
            +                            setStrokeStyle('#000000');
            +
            +                    scene.addChild(rectangle);
            +                    scene.addChild(circle);
            +
            +                    // create an alpha transparency behavior, which takes two seconds to start,
            +                    // and will be applied for five seconds. During this time, the trsnsparency
            +                    // will fade from 1 (total opacity) to 0 (total transparency)
            +                    var alpha_2 = new CAAT.Behavior.AlphaBehavior().
            +                            setValues(1, 0).
            +
            +                        // by cycling a behavior, upon expiration (on time = 7000 milliseconds),
            +                        // it will start applying again from the beginning.
            +                            setCycle(true).
            +                            setFrameTime(2000, 5000);
            +
            +                    // set the behavior to the rectangle.
            +                    rectangle.addBehavior(alpha_2);
            +
            +                    var alpha_3 = new CAAT.Behavior.AlphaBehavior().
            +                            setValues(1, 0).
            +                            setFrameTime(2000, 5000);
            +                    circle.addBehavior(alpha_3);
            +
            +                    CAAT.loop(10);
            +
            +                
            +
            + +
            +
            + +
            + +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t7-1.html b/CAAT/documentation/tutorials/t7-1.html new file mode 100644 index 0000000..13713f8 --- /dev/null +++ b/CAAT/documentation/tutorials/t7-1.html @@ -0,0 +1,244 @@ + + + + + + CAAT Tutorial 7 - Interpolators example + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Interpolator

            +

            Example

            + +

            + Here, we're going to present an array of actors. Select an Interpolator from the + bottom (will show in green), and then press on the desired Actor to apply the + Interpolator to. You can then see how different interpolators modify + the Behavior application. Every Behavior will last for five seconds. + This example also shows the type and parameters needed to create the interpolator object + instance. +

            +
            Select a curve and press on any Actor.
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t7.html b/CAAT/documentation/tutorials/t7.html new file mode 100644 index 0000000..cedce31 --- /dev/null +++ b/CAAT/documentation/tutorials/t7.html @@ -0,0 +1,496 @@ + + + + + + CAAT Tutorial 7 - CAAT.Behavior.Interpolator + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Behavior.Interpolator

            +

            + Interpolator object instances are used mainly in CAAT.Behavior objects to define + the way they are applied. +

            + The default interpolator applied to any Behavior is a linear ramp, that is, + the Behavior is applied in regular time increments. +

            + A CAAT.Behavior.Interpolator object has the ability to modify this linearity, and apply + Behaviors differently, in example accelerating, exponentially, etc. + Despite the interpolator function being applied, the behavior will apply + for the range of values it had defined. +

            + In CAAT an interpolator is an object with a function + getPosition( time ) which returns an object of the form + {x: time, y: float}. + The time parameter is a value between 0 and 1, + meaning 0 behavior's start time and 1 behavior's start time + duration. +

            + Interpolators have a function setPingPong() which + modifies the time parameter. If this method is called, the interpolator will take + half application time to go from start to end values, the other half to go + from end to start values. +

            + +

            + Here you can see the visual representation of every defined CAAT.Behavior.Interpolator. + The x axis means behavior application time, and the y axis means the resulting + value time to apply the behavior for. +

            + +
            +

            Linear Interpolator

            +

            + Instance interpolators are created by calling + new CAAT.Behavior.Interpolator().createLinearInterpolator +

            +
            + + Inverse= false + + + + + + + + +
            Pinpong=falsePinpong=true
            +
            + +
            + +
            +

            Linear Inverse Interpolator

            +

            + Instance interpolators are created by calling + new CAAT.Behavior.Interpolator().createLinearInterpolator +

            + +
            + + Inverse= true + + + + + + + + +
            Pinpong=falsePinpong=true
            +
            + +
            + +
            +

            Exponential Interpolator

            +

            + Instance interpolators are created by calling + new CAAT.Behavior.Interpolator().createExponentialInInterpolator or + + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator or + + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator. +

            + +

            + The exponential interpolator, accepts two parameters. The exponent of the Interpolator function and the + previously described pingpong boolean value.

            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Pinpong=false
            ExponentExponentialInExponentialOutExponentialInOut
            2
            4
            6
            Pinpong=true
            ExponentExponentialInExponentialOutExponentialInOut
            2
            4
            6
            +
            + +
            + + +
            +

            Bounce Interpolator

            +

            + Instance interpolators are created by calling + new CAAT.Behavior.Interpolator().createBounceInInterpolator or + + new CAAT.Behavior.Interpolator().createBounceOutInterpolator or + + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator. +

            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Pinpong=false
            BounceInBounceOutBounceInOut
            Pinpong=true
            BounceInBounceOutBounceInOut
            +
            + +
            + +
            +

            Elastic Interpolator

            +

            + Instance interpolators are created by calling + new CAAT.Behavior.Interpolator().createElasticInInterpolator or + + new CAAT.Behavior.Interpolator().createElasticOutInterpolator or + + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator. +

            +
            + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
            Pinpong=false
            ParametersElasticInElasticOutElasticInOut
            amp=1.1, liquid=.4
            amp=1.0, liquid=.2
            Pinpong=true
            ParametersElasticInElasticOutElasticInOut
            amp=1.1, liquid=.4
            amp=1.0, liquid=.2
            +
            + +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8-1.html b/CAAT/documentation/tutorials/t8-1.html new file mode 100644 index 0000000..486d68c --- /dev/null +++ b/CAAT/documentation/tutorials/t8-1.html @@ -0,0 +1,61 @@ + + + + + + CAAT Tutorial 8 - CAAT.Path, CAAT.LinearPath + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            +

            CAAT.LinearPath

            +

            + A linear path is a straight line between two given points. + It is created by calling: +

            +
            +
            +                    var path= new CAAT.PathUtil.LinearPath().
            +                            setInitialPosition(x,y).
            +                            setFinalPosition(x,y);
            +                
            +
            +

            + This object exists for backwards compatibility, instead look at + CAAT.PathUtil.Path object. +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8-2.html b/CAAT/documentation/tutorials/t8-2.html new file mode 100644 index 0000000..6e8cb21 --- /dev/null +++ b/CAAT/documentation/tutorials/t8-2.html @@ -0,0 +1,72 @@ + + + + + + CAAT Tutorial 8 - CAAT.Path, CAAT.CurvePath + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            +

            CAAT.CurvePath

            +

            + A curve path can be either a quadric or cubir bezier or a Catmull-Rom curve. +

            +

            Quadric Bezier

            +
            +
            +                    var path= new CAAT.PathUtil.CurvePath().
            +                            setQuadric( p0x,p0y, p1x,p1y, p2x,p2y );
            +                
            +
            +

            Cubic Bezier

            +
            +
            +                    var path= new CAAT.PathUtil.CurvePath().
            +                            setCubic( p0x,p0y, p1x,p1y, p2x,p2y, p3x,p3y );
            +                
            +
            +

            + This object, besides the method getPosition(time) + has a method getPositionFromLength(time) which + calculates a position on the path relative to the path's length. +

            +

            + This object exists for backwards compatibility, instead look at + CAAT.PathUtil.Path object. +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8-3.html b/CAAT/documentation/tutorials/t8-3.html new file mode 100644 index 0000000..3c88b7e --- /dev/null +++ b/CAAT/documentation/tutorials/t8-3.html @@ -0,0 +1,214 @@ + + + + + + CAAT Tutorial 8 - CAAT.Path, complex path + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            +

            Complex paths

            +

            + This kind of path object, gives thorough control on path definition. It asumes + new path segments can be added at any time. +

            + +
            +

            Linear Path

            +

            + To define a linear path, simply call the method + setLinear on a CAAT.PathUtil.Path object instance. This method substitutes + CAAT.LinearPath and is the preferred way of building paths. +

            +
            +
            +                        var path= new CAAT.PathUtil.Path().
            +                                setLinear( x0,y0, x1,y1 );
            +                    
            +
            +
            + +
            +

            Curve Path

            +

            + To define a curve path, simply call either the method + setQuadric(x0,y0, x1,y1, x2,y2) or setCubic( + x0,y0, x1,y1, x2,y2, x3,y3) on a CAAT.Path object instance. + This methods substitute CAAT.PathUtil.CurvePath and is the preferred way of building paths. +

            +
            +
            +                        var path= new CAAT.PathUtil.Path().
            +                                setQuadric( x0,y0, x1,y1, x2,y2 );
            +                        var path2= new CAAT.PathUtil.Path().
            +                                setCubic( x0,y0, x1,y1, x2,y2, x3,y3 );
            +                    
            +
            +
            + +
            +

            Complex Path

            +

            + The procedure to define a complex path is to call + beginPath() add segments to the path, and finally call either + endPath() or closePath(). +

            +

            + endPath will terminate adding segments, and closePath will add a final straight line + segment to the very beginning point of the path. +

            +

            Example

            + + +
            +
            +
            +                    var p= new CAAT.PathUtil.Path().
            +                            beginPath(20,20).
            +                            addCubicTo( 30,80, 90,30, 50,70, 'red' ).
            +                            addQuadricTo( 80,60, 65,85, 'blue' ).
            +                            addLineTo( 99,40, 'rgb(0,255,255)' ).
            +                            endPath().
            +                            setInteractive(false);
            +
            +                    
            +
            +

            + The color parameters are optional, but since I want you to show the different + path segments, i've included them. This block of code defines the following + path: +

            + +
            +
            + +
            + +
            + +

            + This path does noe end with a call to closePath. + By doing so, the result would be: +

            + +
            +
            +
            + +
            + + + +

            + CAAT.Path objects have two interesting properties that other path types + don't: +

            +

            + function setTranslation(offsetX,offsetY)
            + This method applies an extra displacement to the position calculated on + path at any given time. As we already saw, an actor's 0,0, position is + located at its top left corner. And by default an actor will traverse the + path by locating this top left corner over the path. This method gets handy + when we want in example, our Actor instances to traverse the path from its + center, and not the top left right. So by calling + setTranslation( actor.width/2, actor.height/2 ) + on a CAAT.PathBehavior instance will solve that it.

            +

            +

            + function setAutoRotate( boolean )
            + This method will set the exact rotation angle needed to head from one point + in the path to the next one. A CAAT.PathBehavior target Actor should not + apply other rotations to make this method work properly. +

            +

            + The methods getBoundingBox, + getLength, + getPosition, + getPositionFromLength, + etc. will give its values by taking into account every path segment. +

            + +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8-4.html b/CAAT/documentation/tutorials/t8-4.html new file mode 100644 index 0000000..f9bf1f7 --- /dev/null +++ b/CAAT/documentation/tutorials/t8-4.html @@ -0,0 +1,349 @@ + + + + + + CAAT Tutorial 8 - Traversing a path + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            +

            Traversing a path

            +

            + When dealing with CAAT.Path object instances, the methods getPosition and + getPositionFromLength could be used to get a position on the path based on + a timely basis. +

            +

            + When the path is created, its length is calculated and normalized, so that by + passing a value between 0 and 1, a position on path can be obtained relative + to its length, being 0 the path start position and 1 the path end position. +

            +

            + A CAAT.Interpolator object instance is such an object that accepts a value + between zero and one, and return another value between zero and one (or near to). + Knowing that, it is easy to understand what a CAAT.PathBehavior object instance + does. +

            +

            Example

            +

            + In this example an actor takes 10 seconds to traverse a path. Any of the + out-of-the-box CAAT.Interpolator object instances can be selected to see the + effect of applying them to the path behavior. There are two actors a red and + a green one. The red always traverse via a linear interpolator, that is, the + default one, and the green will traverse by the selected one. +

            + +
            +
            +
            +                    // create some CAAT.Dock actors with some Interpolator Actors.
            +                        function __scene1_generateInterpolators(director, scene, pathBehavior) {
            +                            var lerps= CAAT.Behavior.Interpolator.enumerateInterpolators();
            +
            +                            var cols= 20;
            +                            var j=0, i=0;
            +                            var rows= lerps.length/2/cols;
            +                            var min= 20;
            +                            var max= 45;
            +                            var selectedInterpolatorActor= null;
            +
            +                            // generate interpolator actors.
            +                            for( j=0; j=lerps.length ) {
            +                                        break;
            +                                    }
            +
            +                                    var actor= new CAAT.Foundation.UI.InterpolatorActor().
            +                                         setInterpolator( lerps[(j*cols+i)*2] ).
            +                                         setBounds( 0, 0, min, min ).
            +                                         setStrokeStyle( 'blue' );
            +
            +                                    actor.mouseExit= function(mouseEvent) {
            +                                        if ( mouseEvent.source!=selectedInterpolatorActor ) {
            +                                            mouseEvent.source.setFillStyle(null);
            +                                        }
            +                                    };
            +                                    actor.mouseEnter= function(mouseEvent) {
            +                                        if ( mouseEvent.source!=selectedInterpolatorActor ) {
            +                                            mouseEvent.source.setFillStyle('#f0f0f0');
            +                                        }
            +                                    };
            +                                    actor.mouseClick= function(mouseEvent) {
            +                                        if ( null!=selectedInterpolatorActor ) {
            +                                            selectedInterpolatorActor.setFillStyle(null);
            +                                        }
            +                                        selectedInterpolatorActor= mouseEvent.source;
            +                                        mouseEvent.source.setFillStyle('#00ff00');
            +                                        selectedInterpolatorActor= mouseEvent.source;
            +
            +                                        pathBehavior.setInterpolator( mouseEvent.source.getInterpolator() );
            +                                    }
            +
            +                                    root.addChildImmediately( actor );
            +                                }
            +
            +                                root.layout();
            +                            }
            +                        };
            +
            +                        var director = new CAAT.Foundation.Director().initialize(700,500,'_tut5_4');
            +                        var scene= director.createScene().setFillStyle('white');
            +                        scene.activated= function() {
            +                            director.setClear(false);
            +                        };
            +
            +                    // path actor. to show the path and manipulate its control points.
            +                    // by default CAAT.PathActor instances are interactive, so the control points
            +                    // can be moved and the path interactively changed.
            +                        var pa= new CAAT.Foundation.UI.PathActor().
            +                            setBounds(0,0,600,director.canvas.height).
            +                            setPath(
            +                            // create a complex path composed of some heterogeneous segments.
            +                                new CAAT.PathUtil.Path().
            +                                    beginPath(200,200).
            +                                    addCubicTo( 300,15, 400,10, 500,200 ).
            +                                    addQuadricTo( 550,300, 450,350 ).
            +                                    addQuadricTo( 400,400, 350,200 ).
            +                                    addCubicTo( 100,300, 300,450, 10,400).
            +                                    addQuadricTo( 40,200, 200,200 ).
            +                                    closePath()).
            +                            setInteractive(true);
            +
            +                    // a green actor
            +                        var fish = new CAAT.Foundation.Actor().
            +                                setLocation( 50,50 ).
            +                                setSize(50,20).
            +                                setFillStyle('#00ff00').
            +                                setStrokeStyle('#ff00ff').
            +                                setPositionAnchor(.5,.5).
            +                                enableEvents(false);
            +                    // a red actor
            +                        var fish2 = new CAAT.Foundation.Actor().
            +                                setLocation( 50,50 ).
            +                                setSize(50,20).
            +                                setFillStyle('#f00').
            +                                setStrokeStyle('#ff00ff').
            +                                setPositionAnchor(.5,.5).
            +                                setAlpha(.75).
            +                                enableEvents(false);
            +
            +                    // path measurer behaviour
            +                        var pb= new CAAT.Behavior.PathBehavior().
            +                            setPath(pa.getPath()).
            +                            setFrameTime(0,10000).
            +                            setCycle(true).
            +                    // make the actor heading across the path
            +                            setAutoRotate(true);
            +
            +                        fish.addBehavior( pb );
            +                    // create anothe behavior for the same path.
            +                        fish2.addBehavior(
            +                                new CAAT.PathBehavior().
            +                                    setPath(pa.getPath()).
            +                                    setFrameTime(0,10000).
            +                                    setCycle(true).
            +                                    setAutoRotate(true) );
            +
            +                        scene.addChildImmediately(pa);
            +                        scene.addChildImmediately(fish);
            +                        scene.addChildImmediately(fish2);
            +
            +                        __scene1_generateInterpolators(director, scene, pb);
            +
            +                        director.addScene(scene);
            +                        CAAT.loop(30);
            +
            +                
            +
            + + + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8-5.html b/CAAT/documentation/tutorials/t8-5.html new file mode 100644 index 0000000..799dce2 --- /dev/null +++ b/CAAT/documentation/tutorials/t8-5.html @@ -0,0 +1,159 @@ + + + + + + CAAT Tutorial 8 - CAAT.Path as an Interpolator instance + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            +

            CAAT.Path as a CAAT.Interpolator instance.

            +
            +

            + One feature of CAAT.Path instances is that they can be used as + CAAT.Interpolators objects. + The following functions from a CAAT.Interpolator instance produce + interpolators by wrapping a CAAT.Path instance: +

            +

            + createQuadricBezierInterpolator(p0,p1,p2,pingpong). + This function creates a CAAT.Interpolator based on a QuadricBezier curve. + The point parameters must be normalized, that is values ranging from 0 to 1. +

            +

            + createCubicBezierInterpolator(p0,p1,p2,p3,pingpong). + This function creates a CAAT.Interpolator based on a CubicBezier curve. + The point parameters must be normalized, that is coordinate values ranging + from 0 to 1. +

            +

            + createPathInterpolator(path,pingpong). + This function creates a CAAT.Interpolator based on a CAAT.Path instance. + The path can be of any kind. +

            +
            +
            +

            Example

            +

            + The following code creates two CAAT.Interpolator intances from a Quadric and a + Cubic Bezier curves. +

            +
            + + +
            +
            +
            +
            +                var director= new CAAT.Foundation.Director().initialize(200,100,'_tut5_5');
            +                var scene= director.createScene();
            +
            +                scene.addChild(
            +                        new CAAT.Foundation.UI.InterpolatorActor().
            +                            setInterpolator(
            +                                new CAAT.Behavior.Interpolator().createQuadricBezierInterpolator(
            +                                        {x:0, y:0},
            +                                        {x:1, y:0},
            +                                        {x:1, y:1},
            +                                        false
            +                                        )
            +                            ).
            +                            setBounds( 10, 10, 80, 80 ).
            +                            setFillStyle('#d0d0d0').
            +                            setGap(0)
            +                );
            +
            +                scene.addChild(
            +                        new CAAT.Foundation.UI.InterpolatorActor().
            +                            setInterpolator(
            +                                new CAAT.Behavior.Interpolator().createCubicBezierInterpolator(
            +                                        {x:0, y:0},
            +                                        {x:0, y:1},
            +                                        {x:1, y:0},
            +                                        {x:1, y:1},
            +                                        true
            +                                        )
            +                            ).
            +                            setBounds( 100, 10, 80, 80 ).
            +                            setFillStyle('#d0d0d0').
            +                            setGap(0)
            +                );
            +
            +                CAAT.loop(1);
            +            
            +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t8.html b/CAAT/documentation/tutorials/t8.html new file mode 100644 index 0000000..c8027f2 --- /dev/null +++ b/CAAT/documentation/tutorials/t8.html @@ -0,0 +1,148 @@ + + + + + + CAAT Tutorial 8 - CAAT.Path + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            CAAT.Path

            + +

            + CAAT toolkit has advanced path capabilities. In its basic definition, a path is + defined by the class CAAT.PathSegment. This class does not define any method + implementation but is referred to as an interface, that is, just definition, + no implementation. +

            + Despite that, every path on CAAT will be composed by one or more path segments. + These segments can be either straight lines, quadric or cubic bezier curves, + catmull-rom curves or complex paths composed of an arbitrary number of segments. + A path can have any level of complexity with the combination of such segments. +

            + PathSegment has the following methods: +

            + +
            +
            +
            +    CAAT.PathSegment.prototype =  {
            +        /**
            +         * Get path's last coordinate.
            +         */
            +		endCurvePosition : function() { },
            +
            +        /**
            +         * Get path's starting coordinate.
            +         */
            +		startCurvePosition : function() { },
            +
            +        /**
            +         * Get a coordinate on path.
            +         * The parameter time is normalized, that is, its values range from zero to one.
            +         * zero will mean startCurvePosition and one will be endCurvePosition. Other values
            +         * will be a position on the path relative to the path length. if the value is greater that 1, if will be set
            +         * to modulus 1.
            +         * @param time a float with a value between zero and 1 inclusive both.
            +         */
            +        getPosition : function(time) { },
            +
            +        /**
            +         * Gets Path length.
            +         */
            +        getLength : function() { },
            +
            +        /**
            +         * Gets the path bounding box (or the rectangle that contains the whole path).
            +         * @param rectangle a CAAT.Rectangle instance with the bounding box.
            +         */
            +		getBoundingBox : function(rectangle) { },
            +
            +        /**
            +         * Gets the number of control points needed to create the path.
            +         * Each PathSegment type can have different control points.
            +         * @return an integer with the number of control points.
            +         */
            +		numControlPoints : function() { },
            +
            +        /**
            +         * Gets CAAT.Point instance with the 2d position of a control point.
            +         * @param index an integer indicating the desired control point coordinate.
            +         */
            +		getControlPoint: function(index) { },
            +
            +        /**
            +         * Instruments the path has finished building, and that no more segments will be added to it.
            +         * You could later add more PathSegments and endPath must be called again.
            +         */
            +        endPath : function() {},
            +
            +        /**
            +         * Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments.
            +         * @param iSize an integer indicating the number of segments of the contour polyline.
            +         */
            +        getContour : function(iSize) {}
            +    }
            +            
            + +
            +

            + By watching at this definition, it can be inferred that every path, regardless of its + type: +

              +
            • + Can get its bounding box. function getBoundingBox +
            • +
            • + Can get its length. function getLength +
            • +
            • + Can get a position on the path. function + getPosition(time). The parameter time will be zero to get the + starting path position and one, to get path's last position. +
            • +
            • + Get its contour as an array of points. function + getContour() +
            • +
            • + Get the number of control points needed to handle/define the path. + function numControlPoints(). +
            • +
            +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-1.html b/CAAT/documentation/tutorials/t9-1.html new file mode 100644 index 0000000..02e12c9 --- /dev/null +++ b/CAAT/documentation/tutorials/t9-1.html @@ -0,0 +1,284 @@ + + + + + + CAAT Tutorial 9 - CAAT.Shape object + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.ShapeActor

            +
            +

            + This object draws shapes on screen. Up to the moment of this writing, just + circles and rectangles. A CAAT.Shape object instance is a container, so it + could contain other actor instances. +

            +

            + By default, this actor will draw a circle shape, unless the function + setShape(shape) is called. The shape types + are defined by any of the values defined in CAAT. + ShapeActor.prototype.SHAPE_xxx constants. +

            +

            + A shape object can be filled and or stroked. The Actor base methods + setFillStyle(fill_style) which accepts from + plain colors to gradients and setStrokeStyle(style) + will do. +

            +

            + The method setCompositeOp(op) which + accepts any value of set rendering context's composite operation. +

            +

            + Shapes, since are CAAT.Actor objects, accept behaviors, affine transformations, + transparency, etc. +

            +

            + This actor only works with a Canvas renderer. +

            +

            Example

            +

            + Move the mouse over the black area to randomly see some colored Circle-Shaped + or Rectangle-Shaped actors. Upon behavior + expiration (ie, elements en moving and fading), the correspondent Actor is + marked as expired and discardable, so it will be removed from Scene. + +

            + +
            + +
            +
            + +
            +
            +
            +            var _director_8 = new CAAT.Foundation.Director().initialize(700,300,'_c8').
            +                    setClear(false);
            +
            +            var _scene_8 = _director_8.createScene();
            +
            +            var colors= [ 'blue', 'red', 'yellow', 'white', 'gray' ,'orange' ];
            +            var color_index=0;
            +
            +            // create a container, equals in size to the director.
            +            var root = new CAAT.Foundation.ActorContainer().
            +                    setBounds(0, 0,
            +                    _director_8.canvas.width, _director_8.canvas.height).
            +                    setFillStyle('#000000')
            +
            +            root.mouseEnter = function(mouseEvent) {
            +            };
            +            root.mouseExit = function(mouseEvent) {
            +            };
            +
            +            _scene_8.addChild(root);
            +
            +            // on mouse move over the root Actor
            +            root.mouseMove = function(mouseEvent) {
            +
            +                var r = 5 + 15 * Math.random();
            +
            +                var bubble;
            +
            +                // is pressing control, add a Rectangle-Shaped blue Actor
            +                if ( Math.random()<.5 ) {
            +                    bubble = new CAAT.Foundation.UI.ShapeActor().
            +                            setLocation(mouseEvent.point.x, mouseEvent.point.y).
            +                            setSize(r, r).
            +                            setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_RECTANGLE).
            +                            enableEvents(false).
            +                            setCompositeOp('lighter').
            +                            setFillStyle( colors[(color_index++)%colors.length]).
            +                            setPositionAnchor(.5,.5);
            +
            +                } else {
            +                    // else, add a Circle-Shaped red Actor
            +                    bubble = new CAAT.Foundation.UI.ShapeActor().
            +                            setLocation(mouseEvent.point.x, mouseEvent.point.y).
            +                            setSize(r, r).
            +                            enableEvents(false).
            +                            setCompositeOp('lighter').
            +                            setFillStyle( colors[(color_index++)%colors.length]).
            +                            setPositionAnchor(.5,.5);
            +                }
            +
            +                root.addChild(bubble);
            +
            +                // Add a container behavior, to hold a fading behavior and a moving
            +                // behavior.
            +                var cb = new CAAT.Behavior.ContainerBehavior().
            +                        setFrameTime(_scene_8.time + 2000 + 1000 * Math.random(), 500).
            +                        addListener(
            +                        // when the container behavior is expired, expire and discard
            +                        // the actor.
            +                        {
            +                            behaviorExpired : function(behaviour, time, actor) {
            +                                actor.
            +                                        setDiscardable(true).
            +                                        setExpired(true);
            +                            }
            +                        });
            +
            +                // fade from opacity to total transparency
            +                var ab = new CAAT.Behavior.AlphaBehavior().
            +                        setFrameTime(0, 500).
            +                        setValues(1, 0);
            +
            +                cb.addBehavior(ab);
            +
            +                // follow a vertical path of at least 100 pixels
            +                var tb = new CAAT.Behavior.PathBehavior().
            +                        setFrameTime(0, 500).
            +                        setPath(
            +                        new CAAT.Path().setLinear(
            +                                bubble.x, bubble.y,
            +                                bubble.x, bubble.y - 100 - 100 * Math.random()));
            +                cb.addBehavior(tb);
            +
            +                bubble.addBehavior(cb);
            +            };
            +
            +            var span = document.getElementById('_c8_data');
            +
            +            _scene_8.onRenderEnd= function() {
            +                span.innerText= 'Actors: '+root.getNumChildren();
            +            };
            +
            +            CAAT.loop(20);
            +
            +        
            +
            +
            +
            +
            + + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-2.html b/CAAT/documentation/tutorials/t9-2.html new file mode 100644 index 0000000..dabb35c --- /dev/null +++ b/CAAT/documentation/tutorials/t9-2.html @@ -0,0 +1,227 @@ + + + + + + CAAT Tutorial 9 - CAAT.StarActor object + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.StarActor

            +
            +

            + This object draws stars of an arbitrary number of arms. It is defined by + two values, an external and an internal radius. The method initialize(arms, max_radius, min_radius). +

            +

            + Stars have the first arm at zero degrees, but this can be modified by calling + the method setInitialAngle(angle_in_radians. +

            +

            + A star object can be filled and or stroked. The Actor base methods + setFillStyle(fill_style) which accepts from + plain colors to gradients and setStrokeStyle(style) + will do. +

            +

            + The method setCompositeOp(op) which + accepts any value of set rendering context's composite operation. +

            +

            + Stars, since are CAAT.Actor objects, accept behaviors, affine transformations, + transparency, etc. +

            + +

            + This actor only works with a Canvas renderer. +

            +

            Example

            +

            + Move the mouse over the black area to randomly see some colored Circle-Shaped + or Rectangle-Shaped actors. Upon behavior + expiration (ie, elements en moving and fading), the correspondent Actor is + marked as expired and discardable, so it will be removed from Scene. + +

            + +
            + +
            +
            + +
            +
            +
            +            var _director_8 = new CAAT.Director().initialize(700,300,'_c8').
            +                    setClear(false);
            +
            +            var _scene_8 = _director_8.createScene();
            +
            +            var colors= [ 'blue', 'red', 'yellow', 'white', 'gray' ,'orange' ];
            +            var color_index=0;
            +
            +            // create a container, equals in size to the director.
            +            var root = new CAAT.Foundation.ActorContainer().
            +                    setBounds(0, 0,
            +                    _director_8.canvas.width, _director_8.canvas.height).
            +                    setFillStyle('#000000')
            +            root.mouseEnter = function(mouseEvent) {
            +            };
            +            root.mouseExit = function(mouseEvent) {
            +            };
            +
            +            _scene_8.addChild(root);
            +
            +            // on mouse move over the root Actor
            +            root.mouseMove = function(mouseEvent) {
            +
            +                var r = 10 + 15 * Math.random();
            +
            +                var star;
            +
            +                star = new CAAT.Foundation.UI.StarActor().
            +                        initialize( 6, r, 5 ).
            +                        setInitialAngle( Math.random()*2*Math.PI ).
            +                        setLocation(mouseEvent.point.x, mouseEvent.point.y).
            +                        setSize(r, r).
            +                        enableEvents(false).
            +                        setCompositeOp('lighter').
            +                        setFillStyle( colors[(color_index++)%colors.length] );
            +
            +                root.addChild(star);
            +
            +                // fade from opacity to total transparency
            +                var ab = new CAAT.Behavior.AlphaBehavior().
            +                        setFrameTime(_scene_8.time + 2000, 500 +  500 * Math.random()).
            +                        setValues(1, 0).
            +                        addListener(
            +                    // when the container behavior is expired, expire and discard
            +                    // the actor.
            +                            {
            +                                behaviorExpired : function(behaviour, time, actor) {
            +                                    actor.
            +                                            setDiscardable(true).
            +                                            setExpired(true);
            +                                }
            +                            });
            +
            +                star.addBehavior(ab);
            +            };
            +
            +            var span = document.getElementById('_c8_data');
            +
            +            _scene_8.onRenderEnd= function() {
            +                span.innerText= 'Actors: '+root.getNumChildren();
            +            };
            +
            +            CAAT.loop(20);
            +
            +
            +                    
            +
            + +
            +
            +
            + + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-3.html b/CAAT/documentation/tutorials/t9-3.html new file mode 100644 index 0000000..1a5dd87 --- /dev/null +++ b/CAAT/documentation/tutorials/t9-3.html @@ -0,0 +1,49 @@ + + + + + + CAAT Tutorial 9 - CAAT.TextActor + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.Foundation.UI.TextActor

            +
            +

            TBD

            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-7.html b/CAAT/documentation/tutorials/t9-7.html new file mode 100644 index 0000000..8f0aa79 --- /dev/null +++ b/CAAT/documentation/tutorials/t9-7.html @@ -0,0 +1,72 @@ + + + + + + CAAT Tutorial 9 - CAAT.InterpolatorActor + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.InterpolatorActor

            +

            + This actor object draws a given CAAT.Interpolator instance. It is useful when the + developer wants to know how an Interpolator will behave. +

            +

            + The setup is simple, simply call the method setInterpolator( + caat.interpolator_instance, size) and then set actor's bounds by calling + setBounds(x,y,width,height) or + setSize( width, height ). +

            +

            + The parameter size defines by how many line segments the interpolator will be + drawn. This contour polyline is cached, so drawing constantly the actor won't + impact performance. If no such parameter is supplied, 50 segments will be used. +

            +

            + The line color will be the one defined by the method + setStrokeStyle( style ) or black by default. +

            +

            + The method setGap( size ) allow to set some insets + to the actor. By default it is 5 units. +

            +

            + This actor has been extensively used in the Interpolators tutorial. +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-8.html b/CAAT/documentation/tutorials/t9-8.html new file mode 100644 index 0000000..2612e44 --- /dev/null +++ b/CAAT/documentation/tutorials/t9-8.html @@ -0,0 +1,142 @@ + + + + + + CAAT Tutorial 9 - CAAT.PathActor + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.PathActor

            +
            +

            + A CAAT.PathActor object instance draws a path on screen. The path can be + as complex as needed, and each path segment can have its own color. +

            +

            + This actors, simply delegates its drawing to the contained + CAAT.Path object. +

            +

            + Besides drawing, this actors allows for real-time path segment manipulation. + The addition of new segments and type change is not allowed, only path control + points manipulation. As in the drawing, this actor delegates control point + maniulation to the contained CAAT.Path object. +

            +

            + Refer to Chapter 8 - CAAT.Path to learn how to build + complex paths. +

            +

            + To set a contained CAAT.PathActor object interactive, + the method setInteractive( bool ) must be called. + Setting this to true, will make this PathActor object instance to draw handles for + each control points which can be moved dynamically. This setInteractive method can + be called directly on the contained path object instance as well. +

            +

            + The method showBoundingBox : function(show, color) can + be invoked to draw this path's bounding box on screen. If the color parameter + is set, it will define the path bounding stroke style. +

            +
            +
            +

            Example

            +

            + In this example you can manipulate a complex path composed of a mix of + quadric and cubic bezier segments. +

            + +
            + +
            + +
            +
            +
            +                        var director= new CAAT.Foundation.Director().initialize(800,500,'_c1');
            +                        var scene= director.createScene().setFillStyle('#fff');
            +
            +                        // path actor. to show the path and manipulate its control points.
            +                        var pa= new CAAT.Foundation.UI.PathActor().
            +                            setBounds(100,0,600,director.height).
            +                            setPath(
            +                                new CAAT.PathUtil.Path().
            +                                    beginPath(200,200).
            +                                    addCubicTo( 300,15, 400,10, 500,200 ).
            +                                    addQuadricTo( 550,300, 450,350 ).
            +                                    addQuadricTo( 400,400, 350,200 ).
            +                                    addCubicTo( 100,300, 300,450, 10,400).
            +                                    addQuadricTo( 40,200, 200,200 ).
            +                                    endPath() ).
            +                            setInteractive(true);
            +
            +
            +                        scene.addChild(pa);
            +
            +                        CAAT.loop(20);
            +                    
            +
            +
            + +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9-9.html b/CAAT/documentation/tutorials/t9-9.html new file mode 100644 index 0000000..f8f4661 --- /dev/null +++ b/CAAT/documentation/tutorials/t9-9.html @@ -0,0 +1,277 @@ + + + + + + CAAT Tutorial 9 - CAAT.Dock + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            CAAT.Dock

            + +
            +

            + This actor instances mimic the functionality of OSX's docking bar. + It is fully configurable, from minimum/maximum elements size, number of + elements affected, layout operations, etc. +

            +

            + Every added actor will be laid out in rows or columns. +

            +

            + The method initialize(scene) must be called + to let the Dock object initialize. It is needed because this actor uses + internally uses timer instances for its animations. +

            +

            + The method setSizes(min,max) must be + called to set docked actors minimum and maximum sizes. It defaults to + zero for min and max. +

            +

            + The method setApplicationRange( size ) defines + how many elements will be affected by the docking effect. It defaults to 2. +

            +

            + Call the method setLayoutOp( layoutOp ) to + define the form in which docked actors grow and shrink. The constants are + defined in CAAT.Dock.prototype and may have the following values: +

              +
            • OP_LAYOUT_BOTTOM. This is the default value. Docked elements grow + keeping its baseline at bottom. +
            • OP_LAYOUT_TOP. Baseline at top. +
            • OP_LAYOUT_LEFT. Baseline at left. +
            • OP_LAYOUT_RIGHT. Baseline at right. +
            +

            +

            + After adding the dockable elements, the method + layout() must be called to perform position initialization. +

            +

            + Note, that this actor sets dockable actor's + width and height in opposition to set a scale value. It also expects + its contained children to be square sized. +

            +
            +
            +

            Example

            +

            + This example shows 4 Dock actor instances with different application + ranges and layouts. +

            +
            +
            + +
            +
            +
            +                        // initialize director and preload images.
            +                            new CAAT.Module.Preloader.ImagePreloader().loadImages(
            +                                    [
            +                                        {id:'nums', url:'../demos/demo-resources/img/numbers.png'}
            +                                    ],
            +                                    function(counter, images) {
            +                                        if ( counter==images.length ) {
            +                                            var director= new CAAT.Foundation.Director().initialize(
            +                                                    800, 500, '_c1');
            +                                            director.setImagesCache(images);
            +                                            __scene(director);
            +                                        }
            +                                    }
            +                            );
            +
            +                            function __scene(director) {
            +
            +                                var scene= director.createScene();
            +
            +                            // min docked actor size.
            +                                var min= 20;
            +                            // max docked actor size.
            +                                var max= 100;
            +                                var width= 500;
            +                                var height= 100;
            +                                var insets= 50;
            +
            +                            // reuse a sprite image
            +                                var ic= new CAAT.Foundation.SpriteImage().initialize(
            +                                        director.getImage('nums'), 9, 9);
            +
            +                                var i,j;
            +                                var dock = [];
            +                            // build 4 dock actors with the different layout ops available.
            +                                dock.push(
            +                                    new CAAT.Foundation.UI.Dock().
            +                                        initialize(scene).
            +                                        setBounds( (director.width-width)/2, insets, width, height ).
            +                                        setSizes(min, max).
            +                                        setApplicationRange(3).
            +                                        setLayoutOp(CAAT.Foundation.UI.Dock.OP_LAYOUT_TOP) );
            +                                dock.push(
            +                                    new CAAT.Foundation.UI.Dock().
            +                                        initialize(scene).
            +                                        setBounds( (director.width-width)/2, director.height-height-insets, width, height ).
            +                                        setSizes(min, max).
            +                                        setApplicationRange(5).
            +                                        setLayoutOp(CAAT.Foundation.UI.Dock.OP_LAYOUT_BOTTOM) );
            +                                dock.push(
            +                                    new CAAT.Foundation.UI.Dock().
            +                                        initialize(scene).
            +                                        setBounds( insets, insets, height, 400 ).
            +                                        setSizes(min, max).
            +                                        setApplicationRange(3).
            +                                        setLayoutOp(CAAT.Foundation.UI.Dock.OP_LAYOUT_LEFT) );
            +                                dock.push(
            +                                    new CAAT.Foundation.UI.Dock().
            +                                        initialize(scene).
            +                                        setBounds( director.width-height-insets, insets, height, 400 ).
            +                                        setSizes(min, max).
            +                                        setApplicationRange(6).
            +                                        setLayoutOp(CAAT.Foundation.UI.Dock.OP_LAYOUT_RIGHT) );
            +
            +                                for( j=0; j>0 ).
            +                            // and make its image conform to all the available space.
            +                                                setImageTransformation( CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE );
            +
            +                                        dock[j].addChild(img);
            +                                    }
            +
            +                                    dock[j].layout();
            +                                    scene.addChild(dock[j]);
            +                                }
            +
            +                                CAAT.loop(33);
            +
            +                    
            +
            +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/t9.html b/CAAT/documentation/tutorials/t9.html new file mode 100644 index 0000000..7c5f307 --- /dev/null +++ b/CAAT/documentation/tutorials/t9.html @@ -0,0 +1,63 @@ + + + + + + CAAT Tutorial 9 - Other CAAT actors + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +

            Other CAAT actors

            +

            + Besides the base actors CAAT contains some helper actors which will make + developers life easier. +

            + It must be noted that some of those actors have been deprecated by adding new + functionalities to the base actor CAAT.Actor. +

            +

            + Those helper actors are: +

              +
            • ShapeActor. Draws common shapes. Only for CANVAS renderer. +
            • StarActor. Draws star shaped actors. Only for CANVAS renderer. +
            • TextActor. Draws text. ALL renderers, with limitations. +
            • InterpolatorActor. Shows an interpolator on screen. +
            • PathActor. Draw complex paths and also allows for its modification. +
            • Dock. Allows compact presentation of other actors. +
            +

            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/documentation/tutorials/template.html b/CAAT/documentation/tutorials/template.html new file mode 100644 index 0000000..68b2865 --- /dev/null +++ b/CAAT/documentation/tutorials/template.html @@ -0,0 +1,44 @@ + + + + + + CAAT Tutorial 1 - Getting started + + + + + + + + + + + + + + + + + + + +
            + + +
            + +
            +
            +
            +
            + + \ No newline at end of file diff --git a/CAAT/index.html b/CAAT/index.html new file mode 100644 index 0000000..6540ef5 --- /dev/null +++ b/CAAT/index.html @@ -0,0 +1,152 @@ + + + + + + Caat by hyperandroid + + + + + + + + + +
            +
            +

            Caat

            + +

            Canvas Advanced Animation Toolkit

            + +

            View the Project on GitHub + hyperandroid/CAAT +

            + + +
            + +
            +
            + + +
            +

            Canvas Advanced Animation Toolkit

            +

            + CAAT is an scene graph director-based animation framework for javascript. +

            + Based in the concept of a timeline, offers a powerful animation environment featuring: +
              +
            • Scenes.
            • +
            • Input abstraction, where touch, mouse, keyboard and accelerometer coexist.
            • +
            • Screen resolution abstraction, where you can make your games up/down scale gracefully.
            • +
            • Multi render technology, making your games render with Canvas, WebGL or CSS transparently.
            • +
            • Clipping masks.
            • +
            • Hierarchycal applied affine transformations, or containers inside containers inside contrainer.
            • +
            • Behaviors, or how to define easily on a timely basis complex mixtures of translations, + rotations, scalations.
            • +
            • Easing functions for behaviors, or how to make that path traversal feel more natural.
            • +
            • Easily define (very) complex paths.
            • +
            • Box2D integration.
            • +
            • ...
            • +
            +

            + +

            Samples

            +
            + Skeletal animation + Sprite Animations + Multiline text + Atlas Bitmap + Path management + Procedural fishpond + Sprites traversing a random path + Pixel perfect collistion detection with mouse + Sprites traversing a random path + accelerometer input + Actor anchors + Hierarchical rotations + Hierarchy II + Some actor behaviors + Procedural grass + Circles collision + Box2D integration + Scene transitions + Scene timers + SpriteImage demo + Masking + Video playback and manipullation + Keyboard demo + Quadtree based collision + Flightcontrol like demo + TileMap engine preview + Multitouch test + Action To + Path Creation + Flip cards + Fonts + Paint demo + Auto Layout + UI.TextActor vs drawString + SVG Parser + CSS3 @KeyFrames + +
            + +

            + +

            Featured Games

            +
            +
            + +

            + +

            Tutorials

            +

            Tutorials

            + +

            JSDoc API

            +

            API documentation

            + + +
            +

            Support or Contact

            + +

            Contact info: hyperandroid@gmail.com or + @hyperandroid + @caatjs

            +
            +
            + + +
            + + + + + + + \ No newline at end of file diff --git a/CAAT/javascripts/scale.fix.js b/CAAT/javascripts/scale.fix.js new file mode 100644 index 0000000..87a40ca --- /dev/null +++ b/CAAT/javascripts/scale.fix.js @@ -0,0 +1,17 @@ +var metas = document.getElementsByTagName('meta'); +var i; +if (navigator.userAgent.match(/iPhone/i)) { + for (i=0; i>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "opacity: " + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + } + } + } +}); diff --git a/CAAT/src/Behavior/BaseBehavior.js b/CAAT/src/Behavior/BaseBehavior.js new file mode 100644 index 0000000..527afed --- /dev/null +++ b/CAAT/src/Behavior/BaseBehavior.js @@ -0,0 +1,659 @@ +/** + * See LICENSE file. + * + * Behaviors are keyframing elements. + * By using a BehaviorContainer, you can specify different actions on any animation Actor. + * An undefined number of Behaviors can be defined for each Actor. + * + * There're the following Behaviors: + * + AlphaBehavior: controls container/actor global alpha. + * + RotateBehavior: takes control of rotation affine transform. + * + ScaleBehavior: takes control of scaling on x and y axis affine transform. + * + Scale1Behavior: takes control of scaling on x or y axis affine transform. + * + PathBehavior: takes control of translating an Actor/ActorContainer across a path [ie. pathSegment collection]. + * + GenericBehavior: applies a behavior to any given target object's property, or notifies a callback. + * + * + **/ + +CAAT.Module({ + + /** + * + * Namespace for all behavior-based actor properties instrumenter objects. + * + * @name Behavior + * @memberOf CAAT + * @namespace + */ + + /** + * + * The BaseBehavior is the base class of all Behavior modifiers: + * + *
          • AlphaBehabior + *
          • RotateBehavior + *
          • ScaleBehavior + *
          • Scale1Behavior + *
          • PathBehavior + *
          • GenericBehavior + *
          • ContainerBehavior + * + * Behavior base class. + * + *

            + * A behavior is defined by a frame time (behavior duration) and a behavior application function called interpolator. + * In its default form, a behaviour is applied linearly, that is, the same amount of behavior is applied every same + * time interval. + *

            + * A concrete Behavior, a rotateBehavior in example, will change a concrete Actor's rotationAngle during the specified + * period. + *

            + * A behavior is guaranteed to notify (if any observer is registered) on behavior expiration. + *

            + * A behavior can keep an unlimited observers. Observers are objects of the form: + *

            + * + * { + * behaviorExpired : function( behavior, time, actor); + * behaviorApplied : function( behavior, time, normalizedTime, actor, value); + * } + * + *

            + * behaviorExpired: function( behavior, time, actor). This method will be called for any registered observer when + * the scene time is greater than behavior's startTime+duration. This method will be called regardless of the time + * granurality. + *

            + * behaviorApplied : function( behavior, time, normalizedTime, actor, value). This method will be called once per + * frame while the behavior is not expired and is in frame time (behavior startTime>=scene time). This method can be + * called multiple times. + *

            + * Every behavior is applied to a concrete Actor. + * Every actor must at least define an start and end value. The behavior will set start-value at behaviorStartTime and + * is guaranteed to apply end-value when scene time= behaviorStartTime+behaviorDuration. + *

            + * You can set behaviors to apply forever that is cyclically. When a behavior is cycle=true, won't notify + * behaviorExpired to its registered observers. + *

            + * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. + * + * @name BaseBehavior + * @memberOf CAAT.Behavior + * @constructor + * + */ + + /** + * + * Internal behavior status values. Do not assign directly. + * + * @name Status + * @memberOf CAAT.Behavior.BaseBehavior + * @namespace + * @enum {number} + */ + + + defines: "CAAT.Behavior.BaseBehavior", + constants: { + + Status: { + /** + * @lends CAAT.Behavior.BaseBehavior.Status + */ + + /** @const @type {number}*/ NOT_STARTED: 0, + /** @const @type {number} */ STARTED: 1, + /** @const @type {number}*/ EXPIRED: 2 + }, + + /** + * @lends CAAT.Behavior.BaseBehavior + * @function + * @param obj a JSON object with a behavior definition. + */ + parse : function( obj ) { + + function findClass( qualifiedClassName ) { + var ns= qualifiedClassName.split("."); + var _global= window; + for( var i=0; i= this.behaviorStartTime) { + time = (time - this.behaviorStartTime) % this.behaviorDuration + this.behaviorStartTime; + } + } + + if (time > this.behaviorStartTime + this.behaviorDuration) { + if (this.status !== st.EXPIRED) { + this.setExpired(actor, time); + } + + return false; + } + + if (this.status === st.NOT_STARTED) { + this.status = st.STARTED; + this.fireBehaviorStartedEvent(actor, time); + } + + return this.behaviorStartTime <= time; // && time} + */ + behaviors:null, // contained behaviors array + recursiveCycleBehavior : false, + conforming : false, + + /** + * @param conforming {bool=} conform this behavior duration to that of its children. + * @inheritDoc + * @private + */ + __init:function ( conforming ) { + this.__super(); + this.behaviors = []; + if ( conforming ) { + this.conforming= true; + } + return this; + }, + + /** + * Proportionally change this container duration to its children. + * @param duration {number} new duration in ms. + * @return this; + */ + conformToDuration:function (duration) { + this.duration = duration; + + var f = duration / this.duration; + var bh; + for (var i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + bh.setFrameTime(bh.getStartTime() * f, bh.getDuration() * f); + } + + return this; + }, + + /** + * Get a behavior by mathing its id. + * @param id {object} + */ + getBehaviorById : function(id) { + for( var i=0; i= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + var obj= bh.getKeyFrameDataValues(time); + for( var pr in obj ) { + keyFrameData[pr]= obj[pr]; + } + } + } + } + + return keyFrameData; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (referenceTime, prefix) { + + var i; + var bh; + + var retValue = {}; + var time; + var cssRuleValue; + var cssProperty; + var property; + + for (i = 0; i < this.behaviors.length; i++) { + bh = this.behaviors[i]; + if (bh.status !== CAAT.Behavior.BaseBehavior.Status.EXPIRED && !(bh instanceof CAAT.Behavior.GenericBehavior)) { + + // ajustar tiempos: + // time es tiempo normalizado a duracion de comportamiento contenedor. + // 1.- desnormalizar + time = referenceTime * this.behaviorDuration; + + // 2.- calcular tiempo relativo de comportamiento respecto a contenedor + if (bh.behaviorStartTime <= time && bh.behaviorStartTime + bh.behaviorDuration >= time) { + // 3.- renormalizar tiempo reltivo a comportamiento. + time = (time - bh.behaviorStartTime) / bh.behaviorDuration; + + // 4.- obtener valor de comportamiento para tiempo normalizado relativo a contenedor + cssRuleValue = bh.calculateKeyFrameData(time); + cssProperty = bh.getPropertyName(prefix); + + if (typeof retValue[cssProperty] === 'undefined') { + retValue[cssProperty] = ""; + } + + // 5.- asignar a objeto, par de propiedad/valor css + retValue[cssProperty] += cssRuleValue + " "; + } + + } + } + + + var tr = ""; + var pv; + + function xx(pr) { + if (retValue[pr]) { + tr += retValue[pr]; + } else { + if (prevValues) { + pv = prevValues[pr]; + if (pv) { + tr += pv; + retValue[pr] = pv; + } + } + } + } + + xx('translate'); + xx('rotate'); + xx('scale'); + + var keyFrameRule = ""; + + if (tr) { + keyFrameRule = '-' + prefix + '-transform: ' + tr + ';'; + } + + tr = ""; + xx('opacity'); + if (tr) { + keyFrameRule += ' opacity: ' + tr + ';'; + } + + keyFrameRule+=" -webkit-transform-origin: 0% 0%"; + + return { + rules:keyFrameRule, + ret:retValue + }; + + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize, anchorX, anchorY) { + + function toKeyFrame(obj, prevKF) { + + for( var i in prevKF ) { + if ( !obj[i] ) { + obj[i]= prevKF[i]; + } + } + + var ret= "-" + prefix + "-transform:"; + + if ( obj.x || obj.y ) { + var x= obj.x || 0; + var y= obj.y || 0; + ret+= "translate("+x+"px,"+y+"px)"; + } + + if ( obj.angle ) { + ret+= " rotate("+obj.angle+"rad)"; + } + + if ( obj.scaleX!==1 || obj.scaleY!==1 ) { + ret+= " scale("+(obj.scaleX)+","+(obj.scaleY)+")"; + } + + ret+=";"; + + if ( obj.alpha ) { + ret+= " opacity: "+obj.alpha+";"; + } + + if ( anchorX!==.5 || anchorY!==.5) { + ret+= " -" + prefix + "-transform-origin:"+ (anchorX*100) + "% " + (anchorY*100) + "%;"; + } + + return ret; + } + + if (this.duration === Number.MAX_VALUE) { + return ""; + } + + if (typeof anchorX==="undefined") { + anchorX= .5; + } + + if (typeof anchorY==="undefined") { + anchorY= .5; + } + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + + var i; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + var time; + var prevKF= {}; + + for (i = 0; i <= keyframessize; i++) { + time = this.interpolator.getPosition(i / keyframessize).y; + + var obj = this.getKeyFrameDataValues(time); + + kfd += "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + toKeyFrame(obj, prevKF) + "}\n"; + + prevKF= obj; + + } + + kfd += "}\n"; + + return kfd; + } + } + } +}); diff --git a/CAAT/src/Behavior/GenericBehavior.js b/CAAT/src/Behavior/GenericBehavior.js new file mode 100644 index 0000000..1632c19 --- /dev/null +++ b/CAAT/src/Behavior/GenericBehavior.js @@ -0,0 +1,79 @@ +CAAT.Module({ + /** + * @name GenericBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + defines:"CAAT.Behavior.GenericBehavior", + depends:["CAAT.Behavior.BaseBehavior"], + aliases:["CAAT.GenericBehavior"], + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.GenericBehavior.prototype + */ + + + /** + * starting value. + */ + start:0, + + /** + * ending value. + */ + end:0, + + /** + * target to apply this generic behvior. + */ + target:null, + + /** + * property to apply values to. + */ + property:null, + + /** + * this callback will be invoked for every behavior application. + */ + callback:null, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var value = this.start + time * (this.end - this.start); + if (this.callback) { + this.callback(value, this.target, actor); + } + + if (this.property) { + this.target[this.property] = value; + } + }, + + /** + * Defines the values to apply this behavior. + * + * @param start {number} initial behavior value. + * @param end {number} final behavior value. + * @param target {object} an object. Usually a CAAT.Actor. + * @param property {string} target object's property to set value to. + * @param callback {function} a function of the form function( target, value ). + */ + setValues:function (start, end, target, property, callback) { + this.start = start; + this.end = end; + this.target = target; + this.property = property; + this.callback = callback; + return this; + } + }; + } +}); diff --git a/CAAT/src/Behavior/Interpolator.js b/CAAT/src/Behavior/Interpolator.js new file mode 100644 index 0000000..b6c0faa --- /dev/null +++ b/CAAT/src/Behavior/Interpolator.js @@ -0,0 +1,485 @@ +/** + * See LICENSE file. + * + * Partially based on Robert Penner easing equations. + * http://www.robertpenner.com/easing/ + * + * + **/ + +CAAT.Module({ + + /** + * @name Interpolator + * @memberOf CAAT.Behavior + * @constructor + */ + + defines:"CAAT.Behavior.Interpolator", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Interpolator"], + constants : { + /** + * @lends CAAT.Behavior.Interpolator + */ + + enumerateInterpolators: function () { + return [ + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, false), 'Linear pingpong=false, inverse=false', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, false), 'Linear pingpong=true, inverse=false', + + new CAAT.Behavior.Interpolator().createBackOutInterpolator(false), 'BackOut pingpong=true, inverse=false', + new CAAT.Behavior.Interpolator().createBackOutInterpolator(true), 'BackOut pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createLinearInterpolator(false, true), 'Linear pingpong=false, inverse=true', + new CAAT.Behavior.Interpolator().createLinearInterpolator(true, true), 'Linear pingpong=true, inverse=true', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, false), 'ExponentialIn pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, false), 'ExponentialOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, false), 'ExponentialInOut pingpong=false, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(2, true), 'ExponentialIn pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2, true), 'ExponentialOut pingpong=true, exponent=2', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(2, true), 'ExponentialInOut pingpong=true, exponent=2', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, false), 'ExponentialIn pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, false), 'ExponentialOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, false), 'ExponentialInOut pingpong=false, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(4, true), 'ExponentialIn pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4, true), 'ExponentialOut pingpong=true, exponent=4', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4, true), 'ExponentialInOut pingpong=true, exponent=4', + + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, false), 'ExponentialIn pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, false), 'ExponentialOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, false), 'ExponentialInOut pingpong=false, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInInterpolator(6, true), 'ExponentialIn pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(6, true), 'ExponentialOut pingpong=true, exponent=6', + new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(6, true), 'ExponentialInOut pingpong=true, exponent=6', + + new CAAT.Behavior.Interpolator().createBounceInInterpolator(false), 'BounceIn pingpong=false', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(false), 'BounceOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(false), 'BounceInOut pingpong=false', + new CAAT.Behavior.Interpolator().createBounceInInterpolator(true), 'BounceIn pingpong=true', + new CAAT.Behavior.Interpolator().createBounceOutInterpolator(true), 'BounceOut pingpong=true', + new CAAT.Behavior.Interpolator().createBounceInOutInterpolator(true), 'BounceInOut pingpong=true', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, false), 'ElasticIn pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, false), 'ElasticOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, false), 'ElasticInOut pingpong=false, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.1, 0.4, true), 'ElasticIn pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4, true), 'ElasticOut pingpong=true, amp=1.1, d=.4', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.1, 0.4, true), 'ElasticInOut pingpong=true, amp=1.1, d=.4', + + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, false), 'ElasticIn pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, false), 'ElasticOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, false), 'ElasticInOut pingpong=false, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInInterpolator(1.0, 0.2, true), 'ElasticIn pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.0, 0.2, true), 'ElasticOut pingpong=true, amp=1.0, d=.2', + new CAAT.Behavior.Interpolator().createElasticInOutInterpolator(1.0, 0.2, true), 'ElasticInOut pingpong=true, amp=1.0, d=.2' + ]; + }, + + parse : function( obj ) { + var name= "create"+obj.type+"Interpolator"; + var interpolator= new CAAT.Behavior.Interpolator(); + try { + interpolator[name].apply( interpolator, obj.params||[] ); + } catch(e) { + interpolator.createLinearInterpolator(false, false); + } + + return interpolator; + } + + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Interpolator.prototype + */ + + interpolated:null, // a coordinate holder for not building a new CAAT.Point for each interpolation call. + paintScale:90, // the size of the interpolation draw on screen in pixels. + + __init:function () { + this.interpolated = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * Set a linear interpolation function. + * + * @param bPingPong {boolean} + * @param bInverse {boolean} will values will be from 1 to 0 instead of 0 to 1 ?. + */ + createLinearInterpolator:function (bPingPong, bInverse) { + /** + * Linear and inverse linear interpolation function. + * @param time {number} + */ + this.getPosition = function getPosition(time) { + + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (bInverse !== null && bInverse) { + time = 1 - time; + } + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + + createBackOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = time - 1; + var overshoot = 1.70158; + + return this.interpolated.set( + orgTime, + time * time * ((overshoot + 1) * time + overshoot) + 1); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be Math.pow(time,exponent). + * This function starts with 0 and ends in values of 1. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, Math.pow(time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. The function to apply will be 1-Math.pow(time,exponent). + * This function starts with 1 and ends in values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.interpolated.set(orgTime, 1 - Math.pow(1 - time, exponent)); + }; + + return this; + }, + /** + * Set an exponential interpolator function. Two functions will apply: + * Math.pow(time*2,exponent)/2 for the first half of the function (t<0.5) and + * 1-Math.abs(Math.pow(time*2-2,exponent))/2 for the second half (t>=.5) + * This function starts with 0 and goes to values of 1 and ends with values of 0. + * + * @param exponent {number} exponent of the function. + * @param bPingPong {boolean} + */ + createExponentialInOutInterpolator:function (exponent, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + if (time * 2 < 1) { + return this.interpolated.set(orgTime, Math.pow(time * 2, exponent) / 2); + } + + return this.interpolated.set(orgTime, 1 - Math.abs(Math.pow(time * 2 - 2, exponent)) / 2); + }; + + return this; + }, + /** + * Creates a Quadric bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createQuadricBezierInterpolator:function (p0, p1, p2, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + time = (1 - time) * (1 - time) * p0.y + 2 * (1 - time) * time * p1.y + time * time * p2.y; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + /** + * Creates a Cubic bezier curbe as interpolator. + * + * @param p0 {CAAT.Math.Point} + * @param p1 {CAAT.Math.Point} + * @param p2 {CAAT.Math.Point} + * @param p3 {CAAT.Math.Point} + * @param bPingPong {boolean} a boolean indicating if the interpolator must ping-pong. + */ + createCubicBezierInterpolator:function (p0, p1, p2, p3, bPingPong) { + this.getPosition = function getPosition(time) { + var orgTime = time; + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var t2 = time * time; + var t3 = time * t2; + + time = (p0.y + time * (-p0.y * 3 + time * (3 * p0.y - + p0.y * time))) + time * (3 * p1.y + time * (-6 * p1.y + + p1.y * 3 * time)) + t2 * (p2.y * 3 - p2.y * 3 * time) + + p3.y * t3; + + return this.interpolated.set(orgTime, time); + }; + + return this; + }, + createElasticOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + (amplitude * Math.pow(2, -10 * time) * Math.sin((time - s) * (2 * Math.PI) / p) + 1 )); + }; + return this; + }, + createElasticInInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + if (time === 0) { + return {x:0, y:0}; + } + if (time === 1) { + return {x:1, y:1}; + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + return this.interpolated.set( + time, + -(amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p) )); + }; + + return this; + }, + createElasticInOutInterpolator:function (amplitude, p, bPingPong) { + this.getPosition = function getPosition(time) { + + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var s = p / (2 * Math.PI) * Math.asin(1 / amplitude); + time *= 2; + if (time <= 1) { + return this.interpolated.set( + time, + -0.5 * (amplitude * Math.pow(2, 10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + } + + return this.interpolated.set( + time, + 1 + 0.5 * (amplitude * Math.pow(2, -10 * (time -= 1)) * Math.sin((time - s) * (2 * Math.PI) / p))); + }; + + return this; + }, + /** + * @param time {number} + * @private + */ + bounce:function (time) { + if ((time /= 1) < (1 / 2.75)) { + return {x:time, y:7.5625 * time * time}; + } else if (time < (2 / 2.75)) { + return {x:time, y:7.5625 * (time -= (1.5 / 2.75)) * time + 0.75}; + } else if (time < (2.5 / 2.75)) { + return {x:time, y:7.5625 * (time -= (2.25 / 2.75)) * time + 0.9375}; + } else { + return {x:time, y:7.5625 * (time -= (2.625 / 2.75)) * time + 0.984375}; + } + }, + createBounceOutInterpolator:function (bPingPong) { + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + return this.bounce(time); + }; + + return this; + }, + createBounceInInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + var r = this.bounce(1 - time); + r.y = 1 - r.y; + return r; + }; + + return this; + }, + createBounceInOutInterpolator:function (bPingPong) { + + this.getPosition = function getPosition(time) { + if (bPingPong) { + if (time < 0.5) { + time *= 2; + } else { + time = 1 - (time - 0.5) * 2; + } + } + + var r; + if (time < 0.5) { + r = this.bounce(1 - time * 2); + r.y = (1 - r.y) * 0.5; + return r; + } + r = this.bounce(time * 2 - 1, bPingPong); + r.y = r.y * 0.5 + 0.5; + return r; + }; + + return this; + }, + + /** + * Paints an interpolator on screen. + * @param ctx {CanvasRenderingContext} + */ + paint:function (ctx) { + + ctx.save(); + ctx.beginPath(); + + ctx.moveTo(0, this.getPosition(0).y * this.paintScale); + + for (var i = 0; i <= this.paintScale; i++) { + ctx.lineTo(i, this.getPosition(i / this.paintScale).y * this.paintScale); + } + + ctx.strokeStyle = 'black'; + ctx.stroke(); + ctx.restore(); + }, + + /** + * Gets an array of coordinates which define the polyline of the intepolator's curve contour. + * Values for both coordinates range from 0 to 1. + * @param iSize {number} an integer indicating the number of contour segments. + * @return Array. of object of the form {x:float, y:float}. + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } +}); diff --git a/CAAT/src/Behavior/PathBehavior.js b/CAAT/src/Behavior/PathBehavior.js new file mode 100644 index 0000000..e8ae814 --- /dev/null +++ b/CAAT/src/Behavior/PathBehavior.js @@ -0,0 +1,344 @@ +CAAT.Module({ + + /** + * @name PathBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name AUTOROTATE + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + */ + + /** + * + * Internal PathBehavior rotation constants. + * + * @name autorotate + * @memberOf CAAT.Behavior.PathBehavior + * @namespace + * @enum {number} + * @deprecated + */ + + defines:"CAAT.Behavior.PathBehavior", + aliases: ["CAAT.PathBehavior"], + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.SpriteImage" + ], + constants : { + + AUTOROTATE : { + + /** + * @lends CAAT.Behavior.PathBehavior.AUTOROTATE + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + }, + + autorotate: { + /** + * @lends CAAT.Behavior.PathBehavior.autorotate + */ + + /** @const */ LEFT_TO_RIGHT: 0, + /** @const */ RIGHT_TO_LEFT: 1, + /** @const */ FREE: 2 + } + }, + extendsClass : "CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.PathBehavior.prototype + * @param obj + */ + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.PathBehavior.superclass.parse.call(this,obj); + + if ( obj.SVG ) { + var parser= new CAAT.PathUtil.SVGPath(); + var path=parser.parsePath( obj.SVG ); + this.setValues(path); + } + + if ( obj.autoRotate ) { + this.autoRotate= obj.autoRotate; + } + }, + + /** + * A path to traverse. + * @type {CAAT.PathUtil.Path} + * @private + */ + path:null, + + /** + * Whether to set rotation angle while traversing the path. + * @private + */ + autoRotate:false, + + prevX:-1, // private, do not use. + prevY:-1, // private, do not use. + + /** + * Autorotation hint. + * @type {CAAT.Behavior.PathBehavior.autorotate} + * @private + */ + autoRotateOp: CAAT.Behavior.PathBehavior.autorotate.FREE, + + isOpenContour : false, + + relativeX : 0, + relativeY : 0, + + setOpenContour : function(b) { + this.isOpenContour= b; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "translate"; + }, + + setRelativeValues : function( x, y ) { + this.relativeX= x; + this.relativeY= y; + this.isRelative= true; + return this; + }, + + + /** + * Sets an actor rotation to be heading from past to current path's point. + * Take into account that this will be incompatible with rotation Behaviors + * since they will set their own rotation configuration. + * @param autorotate {boolean} + * @param autorotateOp {CAAT.PathBehavior.autorotate} whether the sprite is drawn heading to the right. + * @return this. + */ + setAutoRotate:function (autorotate, autorotateOp) { + this.autoRotate = autorotate; + if (autorotateOp !== undefined) { + this.autoRotateOp = autorotateOp; + } + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * + * @deprecated + */ + setPath:function (path) { + this.path = path; + return this; + }, + + /** + * Set the behavior path. + * The path can be any length, and will take behaviorDuration time to be traversed. + * @param {CAAT.Path} + * @return this + */ + setValues:function (path) { + return this.setPath(path); + }, + + /** + * @see Actor.setPositionAnchor + * @deprecated + * @param tx a float with xoffset. + * @param ty a float with yoffset. + */ + setTranslation:function (tx, ty) { + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + return "translateX(" + point.x + "px) translateY(" + point.y + "px)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var point = this.path.getPosition(time); + var obj= { + x : point.x, + y : point.y + }; + + if ( this.autoRotate ) { + + var point2= time===0 ? point : this.path.getPosition(time -.001); + var ax = point.x - point2.x; + var ay = point.y - point2.y; + var angle = Math.atan2(ay, ax); + + obj.angle= angle; + } + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var time; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "}"; + + kfd += kfr; + } + + kfd += "}"; + + return kfd; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + if (!this.path) { + return { + x:actor.x, + y:actor.y + }; + } + + var point = this.path.getPosition(time, this.isOpenContour,.001); + if (this.isRelative ) { + point.x+= this.relativeX; + point.y+= this.relativeY; + } + + if (this.autoRotate) { + + if (-1 === this.prevX && -1 === this.prevY) { + this.prevX = point.x; + this.prevY = point.y; + } + + var ax = point.x - this.prevX; + var ay = point.y - this.prevY; + + if (ax === 0 && ay === 0) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } + + var angle = Math.atan2(ay, ax); + var si = CAAT.Foundation.SpriteImage; + var pba = CAAT.Behavior.PathBehavior.AUTOROTATE; + + // actor is heading left to right + if (this.autoRotateOp === pba.LEFT_TO_RIGHT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_NONE); + } + else { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + angle += Math.PI; + } + } else if (this.autoRotateOp === pba.RIGHT_TO_LEFT) { + if (this.prevX <= point.x) { + actor.setImageTransformation(si.TR_FLIP_HORIZONTAL); + } + else { + actor.setImageTransformation(si.TR_NONE); + angle -= Math.PI; + } + } + + actor.setRotation(angle); + + this.prevX = point.x; + this.prevY = point.y; + + var modulo = Math.sqrt(ax * ax + ay * ay); + ax /= modulo; + ay /= modulo; + } + + if (this.doValueApplication) { + actor.setLocation(point.x, point.y); + return { x:actor.x, y:actor.y }; + } else { + return { + x:point.x, + y:point.y + }; + } + + + }, + + /** + * Get a point on the path. + * If the time to get the point at is in behaviors frame time, a point on the path will be returned, otherwise + * a default {x:-1, y:-1} point will be returned. + * + * @param time {number} the time at which the point will be taken from the path. + * @return {object} an object of the form {x:float y:float} + */ + positionOnTime:function (time) { + if (this.isBehaviorInTime(time, null)) { + time = this.normalizeTime(time); + return this.path.getPosition(time); + } + + return {x:-1, y:-1}; + + } + }; + } +}); diff --git a/CAAT/src/Behavior/RotateBehavior.js b/CAAT/src/Behavior/RotateBehavior.js new file mode 100644 index 0000000..8eec95e --- /dev/null +++ b/CAAT/src/Behavior/RotateBehavior.js @@ -0,0 +1,212 @@ +CAAT.Module({ + + /** + * @name RotateBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.RotateBehavior", + extendsClass: "CAAT.Behavior.BaseBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.RotateBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.RotateBehavior.prototype + */ + + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.RotateBehavior.superclass.parse.call(this,obj); + this.startAngle= obj.start || 0; + this.endAngle= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * Start rotation angle. + * @type {number} + * @private + */ + startAngle:0, + + /** + * End rotation angle. + * @type {number} + * @private + */ + endAngle:0, + + /** + * Rotation X anchor. + * @type {number} + * @private + */ + anchorX:.50, + + /** + * Rotation Y anchor. + * @type {number} + * @private + */ + anchorY:.50, + + rotationRelative: 0, + + setRelativeValues : function(r) { + this.rotationRelative= r; + this.isRelative= true; + return this; + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "rotate"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + var angle = this.startAngle + time * (this.endAngle - this.startAngle); + + if ( this.isRelative ) { + angle+= this.rotationRelative; + if (angle>=Math.PI) { + angle= (angle-2*Math.PI) + } + if ( angle<-2*Math.PI) { + angle= (angle+2*Math.PI); + } + } + + if (this.doValueApplication) { + actor.setRotationAnchored(angle, this.anchorX, this.anchorY); + } + + return angle; + + }, + + /** + * Set behavior bound values. + * if no anchorx,anchory values are supplied, the behavior will assume + * 50% for both values, that is, the actor's center. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startAngle {float} indicating the starting angle. + * @param endAngle {float} indicating the ending angle. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + */ + setValues:function (startAngle, endAngle, anchorx, anchory) { + this.startAngle = startAngle; + this.endAngle = endAngle; + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + return this; + }, + + /** + * @deprecated + * Use setValues instead + * @param start + * @param end + */ + setAngles:function (start, end) { + return this.setValues(start, end); + }, + + /** + * Set the behavior rotation anchor. Use this method when setting an exact percent + * by calling setValues is complicated. + * @see CAAT.Actor + * + * These parameters are to set a custom rotation anchor point. if anchor==CAAT.Actor.ANCHOR_CUSTOM + * the custom rotation point is set. + * @param actor + * @param rx + * @param ry + * + */ + setAnchor:function (actor, rx, ry) { + this.anchorX = rx / actor.width; + this.anchorY = ry / actor.height; + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + time = this.interpolator.getPosition(time).y; + return "rotate(" + (this.startAngle + time * (this.endAngle - this.startAngle)) + "rad)"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + angle : this.startAngle + time * (this.endAngle - this.startAngle) + }; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + + }; + + } +}); diff --git a/CAAT/src/Behavior/Scale1Behavior.js b/CAAT/src/Behavior/Scale1Behavior.js new file mode 100644 index 0000000..2e98f4d --- /dev/null +++ b/CAAT/src/Behavior/Scale1Behavior.js @@ -0,0 +1,240 @@ +CAAT.Module({ + /** + * @name Scale1Behavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + /** + * @name AXIS + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + */ + + /** + * @name Axis + * @memberOf CAAT.Behavior.Scale1Behavior + * @enum {number} + * @namespace + * @deprecated + */ + + + defines:"CAAT.Behavior.Scale1Behavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + aliases: ["CAAT.Scale1Behavior"], + constants : { + + AXIS : { + /** + * @lends CAAT.Behavior.Scale1Behavior.AXIS + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + }, + + Axis : { + /** + * @lends CAAT.Behavior.Scale1Behavior.Axis + */ + + /** @const */ X: 0, + /** @const */ Y: 1 + } + }, + extendsClass:"CAAT.Behavior.BaseBehavior", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.Scale1Behavior.prototype + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start scale value. + * @private + */ + startScale:1, + + /** + * End scale value. + * @private + */ + endScale:1, + + /** + * Scale X anchor. + * @private + */ + anchorX:.50, + + /** + * Scale Y anchor. + * @private + */ + anchorY:.50, + + /** + * Apply on Axis X or Y ? + */ + applyOnX:true, + + parse : function( obj ) { + CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,obj); + this.startScale= obj.start || 0; + this.endScale= obj.end || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + this.applyOnX= obj.axis ? obj.axis.toLowerCase()==="x" : true; + }, + + /** + * @param axis {CAAT.Behavior.Scale1Behavior.AXIS} + */ + applyOnAxis:function (axis) { + if (axis === CAAT.Behavior.Scale1Behavior.AXIS.X) { + this.applyOnX = false; + } else { + this.applyOnX = true; + } + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * @inheritDoc + */ + setForTime:function (time, actor) { + + var scale = this.startScale + time * (this.endScale - this.startScale); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scale) { + scale = 0.01; + } + + if (this.doValueApplication) { + if (this.applyOnX) { + actor.setScaleAnchored(scale, actor.scaleY, this.anchorX, this.anchorY); + } else { + actor.setScaleAnchored(actor.scaleX, scale, this.anchorX, this.anchorY); + } + } + + return scale; + }, + + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param start {number} initial X axis scale value. + * @param end {number} final X axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (start, end, applyOnX, anchorx, anchory) { + this.startScale = start; + this.endScale = end; + this.applyOnX = !!applyOnX; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scale; + + time = this.interpolator.getPosition(time).y; + scale = this.startScale + time * (this.endScale - this.startScale); + + return this.applyOnX ? "scaleX(" + scale + ")" : "scaleY(" + scale + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + var obj= {}; + obj[ this.applyOnX ? "scaleX" : "scaleY" ]= this.startScale + time * (this.endScale - this.startScale); + + return obj; + }, + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); diff --git a/CAAT/src/Behavior/ScaleBehavior.js b/CAAT/src/Behavior/ScaleBehavior.js new file mode 100644 index 0000000..501dd0d --- /dev/null +++ b/CAAT/src/Behavior/ScaleBehavior.js @@ -0,0 +1,219 @@ +CAAT.Module({ + + /** + * @name ScaleBehavior + * @memberOf CAAT.Behavior + * @extends CAAT.Behavior.BaseBehavior + * @constructor + */ + + defines:"CAAT.Behavior.ScaleBehavior", + depends:[ + "CAAT.Behavior.BaseBehavior", + "CAAT.Foundation.Actor" + ], + extendsClass:"CAAT.Behavior.BaseBehavior", + aliases : ["CAAT.ScaleBehavior"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Behavior.ScaleBehavior + */ + + __init:function () { + this.__super(); + this.anchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + return this; + }, + + /** + * Start X scale value. + * @private + * @type {number} + */ + startScaleX:1, + + /** + * End X scale value. + * @private + * @type {number} + */ + endScaleX:1, + + /** + * Start Y scale value. + * @private + * @type {number} + */ + startScaleY:1, + + /** + * End Y scale value. + * @private + * @type {number} + */ + endScaleY:1, + + /** + * Scale X anchor value. + * @private + * @type {number} + */ + anchorX:.50, + + /** + * Scale Y anchor value. + * @private + * @type {number} + */ + anchorY:.50, + + /** + * @inheritDoc + */ + parse : function( obj ) { + CAAT.Behavior.ScaleBehavior.superclass.parse.call(this,obj); + this.startScaleX= (obj.scaleX && obj.scaleX.start) || 0; + this.endScaleX= (obj.scaleX && obj.scaleX.end) || 0; + this.startScaleY= (obj.scaleY && obj.scaleY.start) || 0; + this.endScaleY= (obj.scaleY && obj.scaleY.end) || 0; + this.anchorX= (typeof obj.anchorX!=="undefined" ? parseInt(obj.anchorX) : 0.5); + this.anchorY= (typeof obj.anchorY!=="undefined" ? parseInt(obj.anchorY) : 0.5); + }, + + /** + * @inheritDoc + */ + getPropertyName:function () { + return "scale"; + }, + + /** + * Applies corresponding scale values for a given time. + * + * @param time the time to apply the scale for. + * @param actor the target actor to Scale. + * @return {object} an object of the form { scaleX: {float}, scaleY: {float}�} + */ + setForTime:function (time, actor) { + + var scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + var scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + // Firefox 3.x & 4, will crash animation if either scaleX or scaleY equals 0. + if (0 === scaleX) { + scaleX = 0.01; + } + if (0 === scaleY) { + scaleY = 0.01; + } + + if (this.doValueApplication) { + actor.setScaleAnchored(scaleX, scaleY, this.anchorX, this.anchorY); + } + + return { scaleX:scaleX, scaleY:scaleY }; + }, + /** + * Define this scale behaviors values. + * + * Be aware the anchor values are supplied in RELATIVE PERCENT to + * actor's size. + * + * @param startX {number} initial X axis scale value. + * @param endX {number} final X axis scale value. + * @param startY {number} initial Y axis scale value. + * @param endY {number} final Y axis scale value. + * @param anchorx {float} the percent position for anchorX + * @param anchory {float} the percent position for anchorY + * + * @return this. + */ + setValues:function (startX, endX, startY, endY, anchorx, anchory) { + this.startScaleX = startX; + this.endScaleX = endX; + this.startScaleY = startY; + this.endScaleY = endY; + + if (typeof anchorx !== 'undefined' && typeof anchory !== 'undefined') { + this.anchorX = anchorx; + this.anchorY = anchory; + } + + return this; + }, + /** + * Set an exact position scale anchor. Use this method when it is hard to + * set a thorough anchor position expressed in percentage. + * @param actor + * @param x + * @param y + */ + setAnchor:function (actor, x, y) { + this.anchorX = x / actor.width; + this.anchorY = y / actor.height; + + return this; + }, + + /** + * @inheritDoc + */ + calculateKeyFrameData:function (time) { + var scaleX; + var scaleY; + + time = this.interpolator.getPosition(time).y; + scaleX = this.startScaleX + time * (this.endScaleX - this.startScaleX); + scaleY = this.startScaleY + time * (this.endScaleY - this.startScaleY); + + return "scale(" + scaleX +"," + scaleY + ")"; + }, + + /** + * @inheritDoc + */ + getKeyFrameDataValues : function(time) { + time = this.interpolator.getPosition(time).y; + return { + scaleX : this.startScaleX + time * (this.endScaleX - this.startScaleX), + scaleY : this.startScaleY + time * (this.endScaleY - this.startScaleY) + }; + }, + + + /** + * @inheritDoc + */ + calculateKeyFramesData:function (prefix, name, keyframessize) { + + if (typeof keyframessize === 'undefined') { + keyframessize = 100; + } + keyframessize >>= 0; + + var i; + var kfr; + var kfd = "@-" + prefix + "-keyframes " + name + " {"; + + for (i = 0; i <= keyframessize; i++) { + kfr = "" + + (i / keyframessize * 100) + "%" + // percentage + "{" + + "-" + prefix + "-transform:" + this.calculateKeyFrameData(i / keyframessize) + + "; -" + prefix + "-transform-origin:" + (this.anchorX*100) + "% " + (this.anchorY*100) + "% " + + "}\n"; + + kfd += kfr; + } + + kfd += "}\n"; + + return kfd; + } + } + + } +}); diff --git a/CAAT/src/CAAT.js b/CAAT/src/CAAT.js new file mode 100644 index 0000000..74a0ff1 --- /dev/null +++ b/CAAT/src/CAAT.js @@ -0,0 +1,12 @@ +/** + * See LICENSE file. + * + * Library namespace. + * CAAT stands for: Canvas Advanced Animation Tookit. + */ + + + /** + * @namespace + */ +var CAAT= CAAT || {}; diff --git a/CAAT/src/Core/Class.js b/CAAT/src/Core/Class.js new file mode 100644 index 0000000..dfd8efd --- /dev/null +++ b/CAAT/src/Core/Class.js @@ -0,0 +1,221 @@ + +extend = function (subc, superc) { + var subcp = subc.prototype; + + // Class pattern. + var CAATObject = function () { + }; + CAATObject.prototype = superc.prototype; + + subc.prototype = new CAATObject(); // chain prototypes. + subc.superclass = superc.prototype; + subc.prototype.constructor = subc; + + // Reset constructor. See Object Oriented Javascript for an in-depth explanation of this. + if (superc.prototype.constructor === Object.prototype.constructor) { + superc.prototype.constructor = superc; + } + + // los metodos de superc, que no esten en esta clase, crear un metodo que + // llama al metodo de superc. + for (var method in subcp) { + if (subcp.hasOwnProperty(method)) { + subc.prototype[method] = subcp[method]; + + /** + * Sintactic sugar to add a __super attribute on every overriden method. + * Despite comvenient, it slows things down by 5fps. + * + * Uncomment at your own risk. + * + // tenemos en super un metodo con igual nombre. + if ( superc.prototype[method]) { + subc.prototype[method]= (function(fn, fnsuper) { + return function() { + var prevMethod= this.__super; + + this.__super= fnsuper; + + var retValue= fn.apply( + this, + Array.prototype.slice.call(arguments) ); + + this.__super= prevMethod; + + return retValue; + }; + })(subc.prototype[method], superc.prototype[method]); + } + */ + + } + } +}; + + +extendWith = function (base, subclass, with_object) { + var CAATObject = function () { + }; + + CAATObject.prototype = base.prototype; + + subclass.prototype = new CAATObject(); + subclass.superclass = base.prototype; + subclass.prototype.constructor = subclass; + + if (base.prototype.constructor === Object.prototype.constructor) { + base.prototype.constructor = base; + } + + if (with_object) { + for (var method in with_object) { + if (with_object.hasOwnProperty(method)) { + subclass.prototype[ method ] = with_object[method]; + /* + if ( base.prototype[method]) { + subclass.prototype[method]= (function(fn, fnsuper) { + return function() { + var prevMethod= this.__super; + this.__super= fnsuper; + var retValue= fn.apply(this, arguments ); + this.__super= prevMethod; + + return retValue; + }; + })(subclass.prototype[method], base.prototype[method]); + } + /**/ + } + } + } +}; + + + +function proxyFunction(object, method, preMethod, postMethod, errorMethod) { + + return function () { + + var args = Array.prototype.slice.call(arguments); + + // call pre-method hook if present. + if (preMethod) { + preMethod({ + object: object, + method: method, + arguments: args }); + } + + var retValue = null; + + try { + // apply original object call with proxied object as + // function context. + retValue = object[method].apply(object, args); + + // everything went right on function call, the call + // post-method hook if present + if (postMethod) { + /*var rr= */ + var ret2 = postMethod({ + object: object, + method: method, + arguments: args }); + + if (ret2) { + retValue = ret2; + } + } + } catch (e) { + // an exeception was thrown, call exception-method hook if + // present and return its result as execution result. + if (errorMethod) { + retValue = errorMethod({ + object: object, + method: method, + arguments: args, + exception: e}); + } else { + // since there's no error hook, just throw the exception + throw e; + } + } + + // return original returned value to the caller. + return retValue; + }; + +} + +function proxyAttribute( proxy, object, attribute, getter, setter) { + + proxy.__defineGetter__(attribute, function () { + if (getter) { + getter(object, attribute); + } + return object[attribute]; + }); + proxy.__defineSetter__(attribute, function (value) { + object[attribute] = value; + if (setter) { + setter(object, attribute, value); + } + }); +} + +function proxyObject(object, preMethod, postMethod, errorMethod, getter, setter) { + + /** + * If not a function then only non privitive objects can be proxied. + * If it is a previously created proxy, return the proxy itself. + */ + if (typeof object !== 'object' || isArray(object) || isString(object) || object.$proxy) { + return object; + } + + var proxy = {}; + + // hold the proxied object as member. Needed to assign proper + // context on proxy method call. + proxy.$proxy = true; + proxy.$proxy_delegate = object; + + // For every element in the object to be proxied + for (var method in object) { + + if (method === "constructor") { + continue; + } + + // only function members + if (typeof object[method] === 'function') { + proxy[method] = proxyFunction(object, method, preMethod, postMethod, errorMethod ); + } else { + proxyAttribute(proxy, object, method, getter, setter); + } + } + + // return our newly created and populated with functions proxied object. + return proxy; +} + + +CAAT.Module({ + defines : "CAAT.Core.Class", + extendsWith : function() { + + /** + * See LICENSE file. + * + * Extend a prototype with another to form a classical OOP inheritance procedure. + * + * @param subc {object} Prototype to define the base class + * @param superc {object} Prototype to be extended (derived class). + */ + + + return { + + }; + } +}); \ No newline at end of file diff --git a/CAAT/src/Core/Constants.js b/CAAT/src/Core/Constants.js new file mode 100644 index 0000000..e5c8d7e --- /dev/null +++ b/CAAT/src/Core/Constants.js @@ -0,0 +1,119 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module( { + + defines: "CAAT.Core.Constants", + depends : [ + "CAAT.Math.Matrix" + ], + + extendsWith: function() { + + /** + * @lends CAAT + */ + + /** + * // do not clamp coordinates. speeds things up in older browsers. + * @type {Boolean} + * @private + */ + CAAT.CLAMP= false; + + /** + * This function makes the system obey decimal point calculations for actor's position, size, etc. + * This may speed things up in some browsers, but at the cost of affecting visuals (like in rotating + * objects). + * + * Latest Chrome (20+) is not affected by this. + * + * Default CAAT.Matrix try to speed things up. + * + * @param clamp {boolean} + */ + CAAT.setCoordinateClamping= function( clamp ) { + CAAT.CLAMP= clamp; + CAAT.Math.Matrix.setCoordinateClamping(clamp); + }; + + /** + * Log function which deals with window's Console object. + */ + CAAT.log= function() { + if(window.console){ + window.console.log( Array.prototype.slice.call(arguments) ); + } + }; + + /** + * Control how CAAT.Font and CAAT.TextActor control font ascent/descent values. + * 0 means it will guess values from a font height + * 1 means it will try to use css to get accurate ascent/descent values and fall back to the previous method + * in case it couldn't. + * + * @type {Number} + */ + CAAT.CSS_TEXT_METRICS= 0; + + /** + * is GLRendering enabled. + * @type {Boolean} + */ + CAAT.GLRENDER= false; + + /** + * set this variable before building CAAT.Director intances to enable debug panel. + */ + CAAT.DEBUG= false; + + /** + * show Bounding Boxes + * @type {Boolean} + */ + CAAT.DEBUGBB= false; + + /** + * Bounding Boxes color. + * @type {String} + */ + CAAT.DEBUGBBBCOLOR = '#00f'; + + /** + * debug axis aligned bounding boxes. + * @type {Boolean} + */ + CAAT.DEBUGAABB = false; + + /** + * Bounding boxes color. + * @type {String} + */ + CAAT.DEBUGAABBCOLOR = '#f00'; + + /** + * if CAAT.Director.setClear uses CLEAR_DIRTY_RECTS, this will show them on screen. + * @type {Boolean} + */ + CAAT.DEBUG_DIRTYRECTS= false; + + /** + * Do not consider mouse drag gesture at least until you have dragged + * DRAG_THRESHOLD_X and DRAG_THRESHOLD_Y pixels. + * This is suitable for tablets, where just by touching, drag events are delivered. + */ + CAAT.DRAG_THRESHOLD_X= 5; + CAAT.DRAG_THRESHOLD_Y= 5; + + /** + * When switching scenes, cache exiting scene or not. Set before building director instance. + * @type {Boolean} + */ + CAAT.CACHE_SCENE_ON_CHANGE= true; + + return { + } + } +} ); diff --git a/CAAT/src/Core/ModuleManager.js b/CAAT/src/Core/ModuleManager.js new file mode 100644 index 0000000..8208ba2 --- /dev/null +++ b/CAAT/src/Core/ModuleManager.js @@ -0,0 +1,917 @@ +(function(global, __obj_namespace) { + + String.prototype.endsWith= function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; + }; + + Function.prototype.bind = Function.prototype.bind || function () { + var fn = this; // the function + var args = Array.prototype.slice.call(arguments); // copy the arguments. + var obj = args.shift(); // first parameter will be context 'this' + return function () { + return fn.apply( + obj, + args.concat(Array.prototype.slice.call(arguments))); + } + }; + + global.isArray = function (input) { + return typeof(input) == 'object' && (input instanceof Array); + }; + global.isString = function (input) { + return typeof(input) == 'string'; + }; + global.isFunction = function( input ) { + return typeof input == "function" + } + + var initializing = false; + + // The base Class implementation (does nothing) + var Class = function () { + }; + + Class['__CLASS']='Class'; + + // Create a new Class that inherits from this class + Class.extend = function (extendingProt, constants, name, aliases, flags) { + + var _super = this.prototype; + + // Instantiate a base class (but only create the instance, + // don't run the init constructor) + initializing = true; + var prototype = new this(); + initializing = false; + + // The dummy class constructor + function CAATClass() { + // All construction is actually done in the init method + if (!initializing && this.__init) { + this.__init.apply(this, arguments); + } + } + + // Populate our constructed prototype object + CAATClass.prototype = prototype; + // Enforce the constructor to be what we expect + CAATClass.prototype.constructor = CAATClass; + CAATClass.superclass = _super; + // And make this class extendable + CAATClass.extend = Class.extend; + + assignNamespace( name, CAATClass ); + if ( constants ) { + constants= (isFunction(constants) ? constants() : constants); + for( var constant in constants ) { + if ( constants.hasOwnProperty(constant) ) { + CAATClass[ constant ]= constants[constant]; + } + } + } + + CAATClass["__CLASS"]= name; + + if ( aliases ) { + if ( !isArray(aliases) ) { + aliases= [aliases]; + } + for( var i=0; i NOT solved.") + ); + }, + + removeDependency : function( modulename ) { + for( var i=0; i Can't extend non-existant class: "+this.baseClass ); + return; + } + + } else { + c= Class; + } + + c= c.extend( this.extendWith, this.constants, this.name, this.aliases, { decorated : this.decorated } ); + + console.log("Created module: "+this.name); + + if ( this.callback ) { + this.callback(); + } + + } + }; + + var ScriptFile= function(path, module) { + this.path= path; + this.module= module; + return this; + } + + ScriptFile.prototype= { + path : null, + processed: false, + module: null, + + setProcessed : function() { + this.processed= true; + }, + + isProcessed : function() { + return this.processed; + } + }; + + var ModuleManager= function() { + this.nodes= []; + this.loadedFiles= []; + this.path= {}; + this.solveListener= []; + this.orderedSolvedModules= []; + this.readyListener= []; + + return this; + }; + + ModuleManager.baseURL= ""; + ModuleManager.modulePath= {}; + ModuleManager.sortedModulePath= []; + ModuleManager.symbol= {}; + + ModuleManager.prototype= { + + nodes: null, // built nodes. + loadedFiles:null, // list of loaded files. avoid loading each file more than once + solveListener: null, // listener for a module solved + readyListener: null, // listener for all modules solved + orderedSolvedModules: null, // order in which modules where solved. + + addSolvedListener : function( modulename, callback ) { + this.solveListener.push( { + name : modulename, + callback : callback + }); + }, + + solved : function( module ) { + var i; + + for( i=0; i "+obj.defines+" onPrecreation"); + try { + obj.onPreCreate(); + } catch(e) { + console.log(" -> catched "+e+" on module "+obj.defines+" preCreation."); + } + } + + if (!obj.depends ) { + obj.depends= []; + } + + var dependencies= obj.depends; + + if ( dependencies ) { + if ( !isArray(dependencies) ) { + dependencies= [ dependencies ]; + obj.depends= dependencies; + } + } + + // elimina dependencias ya resueltas en otras cargas. + i=0; + while( i=}, // dependencies class names + * extendsClass{string}, // class to extend from + * extensdWith{object}, // actual prototype to extend + * aliases{Array} // other class names + * } + * + * @name Module + * @memberof CAAT + * @static + * + * @param obj {object} + */ + NS.Module= function loadModule(obj) { + + if (!obj.defines) { + console.error("Bad module definition: "+obj); + return; + } + + ensureNamespace(obj.defines); + + mm.module( obj ); + + }; + + /** + * @name ModuleManager + * @memberOf CAAT + * @namespace + */ + NS.ModuleManager= {}; + + /** + * Define global base position for modules structure. + * @param baseURL {string} + * @return {*} + */ + NS.ModuleManager.baseURL= function(baseURL) { + + if ( !baseURL ) { + return NS.Module; + } + + if (!baseURL.endsWith("/") ) { + baseURL= baseURL + "/"; + } + + ModuleManager.baseURL= baseURL; + return NS.ModuleManager; + }; + + /** + * Define a module path. Multiple module paths can be specified. + * @param module {string} + * @param path {string} + */ + NS.ModuleManager.setModulePath= function( module, path ) { + + if ( !path.endsWith("/") ) { + path= path + "/"; + } + + if ( !ModuleManager.modulePath[module] ) { + ModuleManager.modulePath[ module ]= path; + + ModuleManager.sortedModulePath.push( module ); + + /** + * Sort function so that CAAT.AB is below CAAT.AB.CD + */ + ModuleManager.sortedModulePath.sort( function(a,b) { + if (a==b) { + return 0; + } + return a, + * point : { + * x: , + * y: }� + * }> + * @return {*} + */ + addTouch : function( touchInfo ) { + if ( -1===this.touches.indexOf( touchInfo ) ) { + this.touches.push( touchInfo ); + } + return this; + }, + addChangedTouch : function( touchInfo ) { + if ( -1===this.changedTouches.indexOf( touchInfo ) ) { + this.changedTouches.push( touchInfo ); + } + return this; + }, + isAltDown : function() { + return this.alt; + }, + isControlDown : function() { + return this.control; + }, + isShiftDown : function() { + return this.shift; + }, + isMetaDown: function() { + return this.meta; + }, + getSourceEvent : function() { + return this.sourceEvent; + } + } +}); diff --git a/CAAT/src/Event/TouchInfo.js b/CAAT/src/Event/TouchInfo.js new file mode 100644 index 0000000..2aa615e --- /dev/null +++ b/CAAT/src/Event/TouchInfo.js @@ -0,0 +1,38 @@ +CAAT.Module( { + + /** + * @name TouchInfo + * @memberOf CAAT.Event + * @constructor + */ + + defines : "CAAT.Event.TouchInfo", + aliases : ["CAAT.TouchInfo"], + extendsWith : { + + /** + * @lends CAAT.Event.TouchInfo.prototype + */ + + /** + * Constructor delegate. + * @param id {number} + * @param x {number} + * @param y {number} + * @param target {DOMElement} + * @private + */ + __init : function( id, x, y, target ) { + + this.identifier= id; + this.clientX= x; + this.pageX= x; + this.clientY= y; + this.pageY= y; + this.target= target; + this.time= new Date().getTime(); + + return this; + } + } +}); diff --git a/CAAT/src/Foundation/Actor.js b/CAAT/src/Foundation/Actor.js new file mode 100644 index 0000000..a60ac27 --- /dev/null +++ b/CAAT/src/Foundation/Actor.js @@ -0,0 +1,2591 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + + + + /** + * + * CAAT.Foundation is the base namespace for all the core animation elements. + * + * @name Foundation + * @namespace + * @memberOf CAAT + * + */ + + /** + * + * CAAT.Foundation.Actor is the base animable element. It is the base object for Director, Scene and + * Container. + *

            CAAT.Actor is the simplest object instance CAAT manages. Every on-screen element is an Actor instance. + * An Actor has entity, it has a size, position and can have input sent to it. Everything that has a + * visual representation is an Actor, including Director and Scene objects.

            + *

            This object has functionality for:

            + *
              + *
            1. Set location and size on screen. Actors are always rectangular shapes, but not needed to be AABB.
            2. + *
            3. Set affine transforms (rotation, scale and translation).
            4. + *
            5. Define life cycle.
            6. + *
            7. Manage alpha transparency.
            8. + *
            9. Manage and keep track of applied Behaviors. Behaviors apply transformations via key-framing.
            10. + *
            11. Compose transformations. A container Actor will transform its children before they apply their own transformation.
            12. + *
            13. Clipping capabilities. Either rectangular or arbitrary shapes.
            14. + *
            15. The API is developed to allow method chaining when possible.
            16. + *
            17. Handle input (either mouse events, touch, multitouch, keys and accelerometer).
            18. + *
            19. Show an image.
            20. + *
            21. Show some image animations.
            22. + *
            23. etc.
            24. + *
            + * + * @name Actor + * @memberOf CAAT.Foundation + * @constructor + * + */ + + defines:"CAAT.Foundation.Actor", + aliases: [ "CAAT.Actor" ], + depends: [ + "CAAT.Math.Dimension", + "CAAT.Event.AnimationLoop", + "CAAT.Foundation.SpriteImage", + "CAAT.Core.Constants", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.Scale1Behavior", + "CAAT.PathUtil.LinearPath", + "CAAT.Event.AnimationLoop" + ], + constants : { + /** + * @lends CAAT.Foundation.Actor + */ + + /** @const @type {number} */ ANCHOR_CENTER:0, // constant values to determine different affine transform + /** @const @type {number} */ ANCHOR_TOP:1, // anchors. + /** @const @type {number} */ ANCHOR_BOTTOM:2, + /** @const @type {number} */ ANCHOR_LEFT:3, + /** @const @type {number} */ ANCHOR_RIGHT:4, + /** @const @type {number} */ ANCHOR_TOP_LEFT:5, + /** @const @type {number} */ ANCHOR_TOP_RIGHT:6, + /** @const @type {number} */ ANCHOR_BOTTOM_LEFT:7, + /** @const @type {number} */ ANCHOR_BOTTOM_RIGHT:8, + /** @const @type {number} */ ANCHOR_CUSTOM:9, + + /** @const @type {number} */ CACHE_NONE:0, + /** @const @type {number} */ CACHE_SIMPLE:1, + /** @const @type {number} */ CACHE_DEEP:2 + }, + + extendsWith : function () { + + var __index = 0; + + return { + + /** + * @lends CAAT.Foundation.Actor.prototype + */ + + __init:function () { + this.behaviorList = []; + this.lifecycleListenerList = []; + this.AABB = new CAAT.Math.Rectangle(); + this.viewVertices = [ + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0), + new CAAT.Math.Point(0, 0, 0) + ]; + + this.scaleAnchor = CAAT.Foundation.Actor.ANCHOR_CENTER; + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrixI = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrixI = new CAAT.Math.Matrix(); + + this.resetTransform(); + this.setScale(1, 1); + this.setRotation(0); + + this.id = __index++; + + return this; + }, + + /** + * @type {object} + */ + __super : null, + + /** + * A collection of this Actors lifecycle observers. + * @type { Array.<{actorLifeCycleEvent : function( CAAT.Foundation.Actor, string, number ) }> } + */ + lifecycleListenerList:null, + + /** + * A collection of behaviors to modify this actor´s properties. + * @type { Array. } + */ + behaviorList:null, + + /** + * This actor's parent container. + * @type { CAAT.Foundation.ActorContainer } + */ + parent:null, // Parent of this Actor. May be Scene. + + /** + * x position on parent. In parent's local coord. system. + * @type {number} + */ + x:0, + /** + * y position on parent. In parent's local coord. system. + * @type {number} + */ + y:0, + + /** + * Actor's width. In parent's local coord. system. + * @type {number} + */ + width:0, + + /** + * Actor's height. In parent's local coord. system. + * @type {number} + */ + height:0, + + /** + * actor´s layout preferred size. + * @type {CAAT.Math.Dimension} + */ + preferredSize:null, + + /** + * actor's layout minimum size. + * @type {CAAT.Math.Dimension} + */ + minimumSize:null, + + /** + * Marks since when this actor, relative to scene time, is going to be animated/drawn. + * @type {number} + */ + start_time:0, + + /** + * Marks from the time this actor is going to be animated, during how much time. + * Forever by default. + * @type {number} + */ + duration:Number.MAX_VALUE, + + /** + * Will this actor be clipped before being drawn on screen ? + * @type {boolean} + */ + clip:false, + + /** + * If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise, + * clipPath contains a reference to a CAAT.PathUtil.Path object. + * @type {CAAT.PathUtil.Path} + */ + clipPath:null, + + /** + * Translation x anchor. 0..1 + * @type {number} + */ + tAnchorX:0, + + /** + * Translation y anchor. 0..1 + * @type {number} + */ + tAnchorY:0, + + /** + * ScaleX value. + * @type {number} + */ + scaleX:1, // transformation. width scale parameter + + /** + * ScaleY value. + * @type {number} + */ + scaleY:1, // transformation. height scale parameter + + /** + * Scale Anchor X. Value 0-1 + * @type {number} + */ + scaleTX:.50, // transformation. scale anchor x position + + /** + * Scale Anchor Y. Value 0-1 + * @type {number} + */ + scaleTY:.50, // transformation. scale anchor y position + + /** + * A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value. + * @type {CAAT.Foundation.Actor.ANCHOR_*} + */ + scaleAnchor:0, // transformation. scale anchor + + /** + * This actor´s rotation angle in radians. + * @type {number} + */ + rotationAngle:0, // transformation. rotation angle in radians + + /** + * Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + * @type {number} + */ + rotationY:.50, // transformation. rotation center y + + /** + * Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1. + * @type {number} + */ + rotationX:.50, // transformation. rotation center x + + /** + * Transparency value. 0 is totally transparent, 1 is totally opaque. + * @type {number} + */ + alpha:1, // alpha transparency value + + /** + * true to make all children transparent, false, only this actor/container will be transparent. + * @type {boolean} + */ + isGlobalAlpha:false, // is this a global alpha + + /** + * @type {number} + * @private + */ + frameAlpha:1, // hierarchically calculated alpha for this Actor. + + /** + * Mark this actor as expired, or out of the scene time. + * @type {boolean} + */ + expired:false, + + /** + * Mark this actor as discardable. If an actor is expired and mark as discardable, if will be + * removed from its parent. + * @type {boolean} + */ + discardable:false, // set when you want this actor to be removed if expired + + /** + * @type {boolean} + */ + pointed:false, // is the mouse pointer inside this actor + + /** + * Enable or disable input on this actor. By default, all actors receive input. + * See also priority lists. + * see demo4 for an example of input and priority lists. + * @type {boolean} + */ + mouseEnabled:true, // events enabled ? + + /** + * Make this actor visible or not. + * An invisible actor avoids making any calculation, applying any behavior on it. + * @type {boolean} + */ + visible:true, + + /** + * any canvas rendering valid fill style. + * @type {string} + */ + fillStyle:null, + + /** + * any canvas rendering valid stroke style. + * @type {string} + */ + strokeStyle:null, + + /** + * This actor´s scene time. + * @type {number} + */ + time:0, // Cache Scene time. + + /** + * This rectangle keeps the axis aligned bounding box in screen coords of this actor. + * In can be used, among other uses, to realize whether two given actors collide regardless + * the affine transformation is being applied on them. + * @type {CAAT.Math.Rectangle} + */ + AABB:null, + + /** + * These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding + * box. If the actor is not rotated, viewVertices and AABB define the same bounding box. + * @type {Array.} + */ + viewVertices:null, // model to view transformed vertices. + + /** + * Is this actor processed in the last frame ? + * @type {boolean} + */ + inFrame:false, // boolean indicating whether this Actor was present on last frame. + + /** + * Local matrix dirtyness flag. + * @type {boolean} + * @private + */ + dirty:true, // model view is dirty ? + + /** + * Global matrix dirtyness flag. + * @type {boolean} + * @private + */ + wdirty:true, // world model view is dirty ? + + /** + * @type {number} + * @private + */ + oldX:-1, + + /** + * @type {number} + * @private + */ + oldY:-1, + + /** + * This actor´s affine transformation matrix. + * @type {CAAT.Math.Matrix} + */ + modelViewMatrix:null, // model view matrix. + + /** + * This actor´s world affine transformation matrix. + * @type {CAAT.Math.Matrix} + */ + worldModelViewMatrix:null, // world model view matrix. + + /** + * @type {CAAT.Math.Matrix} + */ + modelViewMatrixI:null, // model view matrix. + + /** + * @type {CAAT.Math.Matrix} + */ + worldModelViewMatrixI:null, // world model view matrix. + + /** + * Is this actor enabled on WebGL ? + * @type {boolean} + */ + glEnabled:false, + + /** + * Define this actor´s background image. + * See SpriteImage object. + * @type {CAAT.Foundation.SpriteImage} + */ + backgroundImage:null, + + /** + * Set this actor´ id so that it can be later identified easily. + * @type {object} + */ + id:null, + + /** + * debug info. + * @type {number} + */ + size_active:1, // number of animated children + + /** + * debug info. + * @type {number} + */ + size_total:1, + + __d_ax:-1, // for drag-enabled actors. + __d_ay:-1, + + /** + * Is gesture recognition enabled on this actor ?? + * @type {boolean} + */ + gestureEnabled:false, + + /** + * If dirty rects are enabled, this flag indicates the rendering engine to invalidate this + * actor´s screen area. + * @type {boolean} + */ + invalid:true, + + /** + * Caching as bitmap strategy. Suitable to cache very complex actors. + * + * 0 : no cache. + * CACHE_SIMPLE : if a container, only cache the container. + * CACHE_DEEP : if a container, cache the container and recursively all of its children. + * + * @type {number} + */ + cached:0, // 0 no, CACHE_SIMPLE | CACHE_DEEP + + /** + * Exclude this actor from automatic layout on its parent. + * @type {boolean} + */ + preventLayout : false, + + /** + * is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated. + * @type {boolean} + * @private + */ + isAA:true, + + /** + * if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some + * internal properties. + */ + isCachedActor : false, + + setCachedActor : function(cached) { + this.isCachedActor= cached; + return this; + }, + + /** + * Make this actor not be laid out. + */ + setPreventLayout : function(b) { + this.preventLayout= b; + return this; + }, + + invalidateLayout:function () { + if (this.parent && !this.parent.layoutInvalidated) { + this.parent.invalidateLayout(); + } + + return this; + }, + + __validateLayout:function () { + + }, + + /** + * Set this actors preferred layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setPreferredSize:function (pw, ph) { + if (!this.preferredSize) { + this.preferredSize = new CAAT.Math.Dimension(); + } + this.preferredSize.width = pw; + this.preferredSize.height = ph; + return this; + }, + + getPreferredSize:function () { + return this.preferredSize ? this.preferredSize : + this.getMinimumSize(); + }, + + /** + * Set this actors minimum layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setMinimumSize:function (pw, ph) { + if (!this.minimumSize) { + this.minimumSize = new CAAT.Math.Dimension(); + } + + this.minimumSize.width = pw; + this.minimumSize.height = ph; + return this; + }, + + getMinimumSize:function () { + return this.minimumSize ? this.minimumSize : + new CAAT.Math.Dimension(this.width, this.height); + }, + + /** + * @deprecated + * @return {*} + */ + create:function () { + return this; + }, + /** + * Move this actor to a position. + * It creates and adds a new PathBehavior. + * @param x {number} new x position + * @param y {number} new y position + * @param duration {number} time to take to get to new position + * @param delay {=number} time to wait before start moving + * @param interpolator {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance + */ + moveTo:function (x, y, duration, delay, interpolator, callback) { + + if (x === this.x && y === this.y) { + return; + } + + var id = '__moveTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.PathBehavior(). + setId(id). + setValues(new CAAT.PathUtil.LinearPath()); + this.addBehavior(b); + } + + b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y); + b.setDelayTime(delay ? delay : 0, duration); + if (interpolator) { + b.setInterpolator(interpolator); + } + + if (callback) { + b.lifecycleListenerList = []; + b.addListener({ + behaviorExpired:function (behavior, time, actor) { + callback(behavior, time, actor); + } + }); + } + + return this; + }, + + /** + * + * @param angle {number} new rotation angle + * @param duration {number} time to rotate + * @param delay {number=} millis to start rotation + * @param anchorX {number=} rotation anchor x + * @param anchorY {number=} rotation anchor y + * @param interpolator {CAAT.Behavior.Interpolator=} + * @return {*} + */ + rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) { + + if (angle === this.rotationAngle) { + return; + } + + var id = '__rotateTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.RotateBehavior(). + setId(id). + setValues(0, 0, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.rotationAngle, angle, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) { + + if (this.scaleX === scaleX && this.scaleY === scaleY) { + return; + } + + var id = '__scaleTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.ScaleBehavior(). + setId(id). + setValues(1, 1, 1, 1, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Behavior.Scale1Behavior.AXIS_X, + scaleX, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Behavior.Interpolator} + * @return {*} + */ + scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Behavior.Scale1Behavior.AXIS_Y, + scaleY, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis + * @param scale {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Bahavior.Interpolator} + * @return {*} + */ + __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) { + + if (( axis === CAAT.Behavior.Scale1Behavior.AXIS_X && scale === this.scaleX) || + ( axis === CAAT.Behavior.Scale1Behavior.AXIS_Y && scale === this.scaleY)) { + + return; + } + + var id = '__scaleXTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Behavior.Scale1Behavior(). + setId(id). + setValues(1, 1, axis === CAAT.Behavior.Scale1Behavior.AXIS_X, .5, .5); + this.addBehavior(b); + } + + b.setValues( + axis ? this.scaleX : this.scaleY, + scale, + anchorX, + anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH + * @param e + */ + touchStart:function (e) { + }, + touchMove:function (e) { + }, + touchEnd:function (e) { + }, + gestureStart:function (rotation, scaleX, scaleY) { + }, + gestureChange:function (rotation, scaleX, scaleY) { + if (this.gestureEnabled) { + this.setRotation(rotation); + this.setScale(scaleX, scaleY); + } + return this; + }, + gestureEnd:function (rotation, scaleX, scaleY) { + }, + + isVisible:function () { + return this.visible; + }, + + invalidate:function () { + this.invalid = true; + return this; + }, + setGestureEnabled:function (enable) { + this.gestureEnabled = !!enable; + return this; + }, + isGestureEnabled:function () { + return this.gestureEnabled; + }, + getId:function () { + return this.id; + }, + setId:function (id) { + this.id = id; + return this; + }, + /** + * Set this actor's parent. + * @param parent {CAAT.Foundation.ActorContainer} + * @return this + */ + setParent:function (parent) { + this.parent = parent; + return this; + }, + /** + * Set this actor's background image. + * The need of a background image is to kept compatibility with the new CSSDirector class. + * The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image + * is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column. + * If the actor has set an image in the background, the paint method will draw the image, otherwise + * and if set, will fill its background with a solid color. + * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one + * single image from the SpriteImage (either supplied or generated because of passing an Image or + * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth, + * height:singleHeight]. + * + * WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance. + * + * @see CAAT.Foundation.SpriteImage + * + * @param image {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage} + * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter. + * + * @return this + */ + setBackgroundImage:function (image, adjust_size_to_image) { + if (image) { + if (!(image instanceof CAAT.Foundation.SpriteImage)) { + if ( isString(image) ) { + image = new CAAT.Foundation.SpriteImage().initialize(CAAT.currentDirector.getImage(image), 1, 1); + } else { + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } + } else { + image= image.getRef(); + } + + image.setOwner(this); + this.backgroundImage = image; + if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) { + this.width = image.getWidth(); + this.height = image.getHeight(); + } + + this.glEnabled = true; + + this.invalidate(); + + } else { + this.backgroundImage = null; + } + + return this; + }, + /** + * Set the actor's SpriteImage index from animation sheet. + * @see CAAT.Foundation.SpriteImage + * @param index {number} + * + * @return this + */ + setSpriteIndex:function (index) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteIndex(index); + this.invalidate(); + } + + return this; + + }, + /** + * Set this actor's background SpriteImage offset displacement. + * The values can be either positive or negative meaning the texture space of this background + * image does not start at (0,0) but at the desired position. + * @see CAAT.Foundation.SpriteImage + * @param ox {number} horizontal offset + * @param oy {number} vertical offset + * + * @return this + */ + setBackgroundImageOffset:function (ox, oy) { + if (this.backgroundImage) { + this.backgroundImage.setOffset(ox, oy); + } + + return this; + }, + /** + * Set this actor's background SpriteImage its animation sequence. + * In its simplet's form a SpriteImage treats a given image as an array of rows by columns + * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages. + * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the + * animation sequence + * @param ii {Array} an array of integers. + */ + setAnimationImageIndex:function (ii) { + if (this.backgroundImage) { + this.backgroundImage.resetAnimationTime(); + this.backgroundImage.setAnimationImageIndex(ii); + this.invalidate(); + } + return this; + }, + + addAnimation : function( name, array, time, callback ) { + if (this.backgroundImage) { + this.backgroundImage.addAnimation(name, array, time, callback); + } + return this; + }, + + playAnimation : function(name) { + if (this.backgroundImage) { + this.backgroundImage.playAnimation(name); + } + return this; + }, + + setAnimationEndCallback : function(f) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationEndCallback(f); + } + return this; + }, + + resetAnimationTime:function () { + if (this.backgroundImage) { + this.backgroundImage.resetAnimationTime(); + this.invalidate(); + } + return this; + }, + + setChangeFPS:function (time) { + if (this.backgroundImage) { + this.backgroundImage.setChangeFPS(time); + } + return this; + + }, + /** + * Set this background image transformation. + * If GL is enabled, this parameter has no effect. + * @param it any value from CAAT.Foundation.SpriteImage.TR_* + * @return this + */ + setImageTransformation:function (it) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteTransformation(it); + } + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + * @deprecated + */ + centerOn:function (x, y) { + this.setPosition(x - this.width / 2, y - this.height / 2); + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + */ + centerAt:function (x, y) { + this.setPosition( + x - this.width * (.5 - this.tAnchorX ), + y - this.height * (.5 - this.tAnchorY ) ); + return this; + }, + /** + * If GL is enables, get this background image's texture page, otherwise it will fail. + * @return {CAAT.GLTexturePage} + */ + getTextureGLPage:function () { + return this.backgroundImage.image.__texturePage; + }, + /** + * Set this actor invisible. + * The actor is animated but not visible. + * A container won't show any of its children if set visible to false. + * + * @param visible {boolean} set this actor visible or not. + * @return this + */ + setVisible:function (visible) { + this.invalidate(); + // si estoy visible y quiero hacerme no visible + if (CAAT.currentDirector && CAAT.currentDirector.dirtyRectsEnabled && !visible && this.visible) { + // if dirty rects, add this actor + CAAT.currentDirector.scheduleDirtyRect(this.AABB); + } + + if ( visible && !this.visible) { + this.dirty= true; + } + + this.visible = visible; + return this; + }, + /** + * Puts an Actor out of time line, that is, won't be transformed nor rendered. + * @return this + */ + setOutOfFrameTime:function () { + this.setFrameTime(-1, 0); + return this; + }, + /** + * Adds an Actor's life cycle listener. + * The developer must ensure the actorListener is not already a listener, otherwise + * it will notified more than once. + * @param actorListener {object} an object with at least a method of the form: + * actorLyfeCycleEvent( actor, string_event_type, long_time ) + */ + addListener:function (actorListener) { + this.lifecycleListenerList.push(actorListener); + return this; + }, + /** + * Removes an Actor's life cycle listener. + * It will only remove the first occurrence of the given actorListener. + * @param actorListener {object} an Actor's life cycle listener. + */ + removeListener:function (actorListener) { + var n = this.lifecycleListenerList.length; + while (n--) { + if (this.lifecycleListenerList[n] === actorListener) { + // remove the nth element. + this.lifecycleListenerList.splice(n, 1); + return; + } + } + }, + /** + * Set alpha composition scope. global will mean this alpha value will be its children maximum. + * If set to false, only this actor will have this alpha value. + * @param global {boolean} whether the alpha value should be propagated to children. + */ + setGlobalAlpha:function (global) { + this.isGlobalAlpha = global; + return this; + }, + /** + * Notifies the registered Actor's life cycle listener about some event. + * @param sEventType an string indicating the type of event being notified. + * @param time an integer indicating the time related to Scene's timeline when the event + * is being notified. + */ + fireEvent:function (sEventType, time) { + for (var i = 0; i < this.lifecycleListenerList.length; i++) { + this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time); + } + }, + /** + * Sets this Actor as Expired. + * If this is a Container, all the contained Actors won't be nor drawn nor will receive + * any event. That is, expiring an Actor means totally taking it out the Scene's timeline. + * @param time {number} an integer indicating the time the Actor was expired at. + * @return this. + */ + setExpired:function (time) { + this.expired = true; + this.fireEvent('expired', time); + return this; + }, + /** + * Enable or disable the event bubbling for this Actor. + * @param enable {boolean} a boolean indicating whether the event bubbling is enabled. + * @return this + */ + enableEvents:function (enable) { + this.mouseEnabled = enable; + return this; + }, + /** + * Removes all behaviors from an Actor. + * @return this + */ + emptyBehaviorList:function () { + this.behaviorList = []; + return this; + }, + /** + * Caches a fillStyle in the Actor. + * @param style a valid Canvas rendering context fillStyle. + * @return this + */ + setFillStyle:function (style) { + this.fillStyle = style; + this.invalidate(); + return this; + }, + /** + * Caches a stroke style in the Actor. + * @param style a valid canvas rendering context stroke style. + * @return this + */ + setStrokeStyle:function (style) { + this.strokeStyle = style; + this.invalidate(); + return this; + }, + /** + * @deprecated + * @param paint + */ + setPaint:function (paint) { + return this.setFillStyle(paint); + }, + /** + * Stablishes the Alpha transparency for the Actor. + * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors. + * The alpha must be between 0 and 1. + * @param alpha a float indicating the alpha value. + * @return this + */ + setAlpha:function (alpha) { + this.alpha = alpha; + this.invalidate(); + return this; + }, + /** + * Remove all transformation values for the Actor. + * @return this + */ + resetTransform:function () { + this.rotationAngle = 0; + this.rotationX = .5; + this.rotationY = .5; + this.scaleX = 1; + this.scaleY = 1; + this.scaleTX = .5; + this.scaleTY = .5; + this.scaleAnchor = 0; + this.oldX = -1; + this.oldY = -1; + this.dirty = true; + + return this; + }, + /** + * Sets the time life cycle for an Actor. + * These values are related to Scene time. + * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene. + * @param duration an integer indicating how much the Actor will last once visible. + * @return this + */ + setFrameTime:function (startTime, duration) { + this.start_time = startTime; + this.duration = duration; + this.expired = false; + this.dirty = true; + + return this; + }, + /** + * This method should me overriden by every custom Actor. + * It will be the drawing routine called by the Director to show every Actor. + * @param director {CAAT.Foundation.Director} instance that contains the Scene the Actor is in. + * @param time {number} indicating the Scene time in which the drawing is performed. + */ + paint:function (director, time) { + if (this.backgroundImage) { + this.backgroundImage.paint(director, time, 0, 0); + } else if (this.fillStyle) { + var ctx = director.ctx; + ctx.fillStyle = this.fillStyle; + ctx.fillRect(0, 0, this.width, this.height); + } + + }, + /** + * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER + * + * @see setScaleAnchored + * + * @param sx a float indicating a width size multiplier. + * @param sy a float indicating a height size multiplier. + * @return this + */ + setScale:function (sx, sy) { + this.scaleX = sx; + this.scaleY = sy; + this.dirty = true; + return this; + }, + getAnchorPercent:function (anchor) { + + var anchors = [ + .50, .50, .50, 0, .50, 1.00, + 0, .50, 1.00, .50, 0, 0, + 1.00, 0, 0, 1.00, 1.00, 1.00 + ]; + + return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] }; + }, + /** + * Private. + * Gets a given anchor position referred to the Actor. + * @param anchor + * @return an object of the form { x: float, y: float } + */ + getAnchor:function (anchor) { + var tx = 0, ty = 0; + + var A= CAAT.Foundation.Actor; + + switch (anchor) { + case A.ANCHOR_CENTER: + tx = .5; + ty = .5; + break; + case A.ANCHOR_TOP: + tx = .5; + ty = 0; + break; + case A.ANCHOR_BOTTOM: + tx = .5; + ty = 1; + break; + case A.ANCHOR_LEFT: + tx = 0; + ty = .5; + break; + case A.ANCHOR_RIGHT: + tx = 1; + ty = .5; + break; + case A.ANCHOR_TOP_RIGHT: + tx = 1; + ty = 0; + break; + case A.ANCHOR_BOTTOM_LEFT: + tx = 0; + ty = 1; + break; + case A.ANCHOR_BOTTOM_RIGHT: + tx = 1; + ty = 1; + break; + case A.ANCHOR_TOP_LEFT: + tx = 0; + ty = 0; + break; + } + + return {x:tx, y:ty}; + }, + + setGlobalAnchor:function (ax, ay) { + this.tAnchorX = ax; + this.rotationX = ax; + this.scaleTX = ax; + + this.tAnchorY = ay; + this.rotationY = ay; + this.scaleTY = ay; + + this.dirty = true; + return this; + }, + + setScaleAnchor:function (sax, say) { + this.scaleTX = sax; + this.scaleTY = say; + this.dirty = true; + return this; + }, + /** + * Modify the dimensions on an Actor. + * The dimension will not affect the local coordinates system in opposition + * to setSize or setBounds. + * + * @param sx {number} width scale. + * @param sy {number} height scale. + * @param anchorx {number} x anchor to perform the Scale operation. + * @param anchory {number} y anchor to perform the Scale operation. + * + * @return this; + */ + setScaleAnchored:function (sx, sy, anchorx, anchory) { + this.scaleTX = anchorx; + this.scaleTY = anchory; + + this.scaleX = sx; + this.scaleY = sy; + + this.dirty = true; + + return this; + }, + + setRotationAnchor:function (rax, ray) { + this.rotationX = ray; + this.rotationY = rax; + this.dirty = true; + return this; + }, + /** + * A helper method for setRotationAnchored. This methods stablishes the center + * of rotation to be the center of the Actor. + * + * @param angle a float indicating the angle in radians to rotate the Actor. + * @return this + */ + setRotation:function (angle) { + this.rotationAngle = angle; + this.dirty = true; + return this; + }, + /** + * This method sets Actor rotation around a given position. + * @param angle {number} indicating the angle in radians to rotate the Actor. + * @param rx {number} value in the range 0..1 + * @param ry {number} value in the range 0..1 + * @return this; + */ + setRotationAnchored:function (angle, rx, ry) { + this.rotationAngle = angle; + this.rotationX = rx; + this.rotationY = ry; + this.dirty = true; + return this; + }, + /** + * Sets an Actor's dimension + * @param w a float indicating Actor's width. + * @param h a float indicating Actor's height. + * @return this + */ + setSize:function (w, h) { + + this.width = w; + this.height = h; + + this.dirty = true; + + return this; + }, + /** + * Set location and dimension of an Actor at once. + * + * @param x{number} a float indicating Actor's x position. + * @param y{number} a float indicating Actor's y position + * @param w{number} a float indicating Actor's width + * @param h{number} a float indicating Actor's height + * @return this + */ + setBounds:function (x, y, w, h) { + + this.x = x; + this.y = y; + this.width = w; + this.height = h; + + this.dirty = true; + + return this; + }, + /** + * This method sets the position of an Actor inside its parent. + * + * @param x{number} a float indicating Actor's x position + * @param y{number} a float indicating Actor's y position + * @return this + * + * @deprecated + */ + setLocation:function (x, y) { + this.x = x; + this.y = y; + this.oldX = x; + this.oldY = y; + + this.dirty = true; + + return this; + }, + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + + /** + * This method is called by the Director to know whether the actor is on Scene time. + * In case it was necessary, this method will notify any life cycle behaviors about + * an Actor expiration. + * @param time {number} time indicating the Scene time. + * + * @private + * + */ + isInAnimationFrame:function (time) { + if (this.expired) { + return false; + } + + if (this.duration === Number.MAX_VALUE) { + return this.start_time <= time; + } + + if (time >= this.start_time + this.duration) { + if (!this.expired) { + this.setExpired(time); + } + + return false; + } + + return this.start_time <= time && time < this.start_time + this.duration; + }, + /** + * Checks whether a coordinate is inside the Actor's bounding box. + * @param x {number} a float + * @param y {number} a float + * + * @return boolean indicating whether it is inside. + */ + contains:function (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + }, + + /** + * Add a Behavior to the Actor. + * An Actor accepts an undefined number of Behaviors. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + * @return this + */ + addBehavior:function (behavior) { + this.behaviorList.push(behavior); + return this; + }, + + /** + * Remove a Behavior from the Actor. + * If the Behavior is not present at the actor behavior collection nothing happends. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + */ + removeBehaviour:function (behavior) { + var c = this.behaviorList; + var n = c.length - 1; + while (n) { + if (c[n] === behavior) { + c.splice(n, 1); + return this; + } + } + return this; + }, + /** + * Remove a Behavior with id param as behavior identifier from this actor. + * This function will remove ALL behavior instances with the given id. + * + * @param id {number} an integer. + * return this; + */ + removeBehaviorById:function (id) { + var c = this.behaviorList; + for (var n = 0; n < c.length; n++) { + if (c[n].id === id) { + c.splice(n, 1); + } + } + + return this; + + }, + getBehavior:function (id) { + var c = this.behaviorList; + for (var n = 0; n < c.length; n++) { + var cc = c[n]; + if (cc.id === id) { + return cc; + } + } + return null; + }, + /** + * Set discardable property. If an actor is discardable, upon expiration will be removed from + * scene graph and hence deleted. + * @param discardable {boolean} a boolean indicating whether the Actor is discardable. + * @return this + */ + setDiscardable:function (discardable) { + this.discardable = discardable; + return this; + }, + /** + * This method will be called internally by CAAT when an Actor is expired, and at the + * same time, is flagged as discardable. + * It notifies the Actor life cycle listeners about the destruction event. + * + * @param time an integer indicating the time at wich the Actor has been destroyed. + * + * @private + * + */ + destroy:function (time) { + if (this.parent) { + this.parent.removeChild(this); + } + + this.fireEvent('destroyed', time); + if ( !this.isCachedActor ) { + this.clean(); + } + + }, + + clean : function() { + this.backgroundImage= null; + this.emptyBehaviorList(); + this.lifecycleListenerList= []; + }, + + /** + * Transform a point or array of points in model space to view space. + * + * @param point {CAAT.Math.Point|Array} an object of the form {x : float, y: float} + * + * @return the source transformed elements. + * + * @private + * + */ + modelToView:function (point) { + var x, y, pt, tm; + + if (this.dirty) { + this.setModelViewMatrix(); + } + + tm = this.worldModelViewMatrix.matrix; + + if (point instanceof Array) { + for (var i = 0; i < point.length; i++) { + //this.worldModelViewMatrix.transformCoord(point[i]); + pt = point[i]; + x = pt.x; + y = pt.y; + pt.x = x * tm[0] + y * tm[1] + tm[2]; + pt.y = x * tm[3] + y * tm[4] + tm[5]; + } + } + else { +// this.worldModelViewMatrix.transformCoord(point); + x = point.x; + y = point.y; + point.x = x * tm[0] + y * tm[1] + tm[2]; + point.y = x * tm[3] + y * tm[4] + tm[5]; + } + + return point; + }, + /** + * Transform a local coordinate point on this Actor's coordinate system into + * another point in otherActor's coordinate system. + * @param point {CAAT.Math.Point} + * @param otherActor {CAAT.Math.Actor} + */ + modelToModel:function (point, otherActor) { + if (this.dirty) { + this.setModelViewMatrix(); + } + + return otherActor.viewToModel(this.modelToView(point)); + }, + /** + * Transform a point from model to view space. + *

            + * WARNING: every call to this method calculates + * actor's world model view matrix. + * + * @param point {CAAT.Math.Point} a point in screen space to be transformed to model space. + * + * @return the source point object + * + * + */ + viewToModel:function (point) { + if (this.dirty) { + this.setModelViewMatrix(); + } + this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI); + this.worldModelViewMatrixI.transformCoord(point); + return point; + }, + /** + * Private + * This method does the needed point transformations across an Actor hierarchy to devise + * whether the parameter point coordinate lies inside the Actor. + * @param point {CAAT.Math.Point} + * + * @return null if the point is not inside the Actor. The Actor otherwise. + */ + findActorAtPosition:function (point) { + if (this.scaleX===0 || this.scaleY===0) { + return null; + } + if (!this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time)) { + return null; + } + + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.modelViewMatrixI.transformCoord(point); + return this.contains(point.x, point.y) ? this : null; + }, + /** + * Enables a default dragging routine for the Actor. + * This default dragging routine allows to: + *

          • scale the Actor by pressing shift+drag + *
          • rotate the Actor by pressing control+drag + *
          • scale non uniformly by pressing alt+shift+drag + * + * @return this + */ + enableDrag:function () { + + this.ax = 0; + this.ay = 0; + this.asx = 1; + this.asy = 1; + this.ara = 0; + this.screenx = 0; + this.screeny = 0; + + /** + * Mouse enter handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + this.pointed = true; + CAAT.setCursor('move'); + }; + + /** + * Mouse exit handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseExit = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + this.pointed = false; + CAAT.setCursor('default'); + }; + + /** + * Mouse move handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseMove = function (mouseEvent) { + }; + + /** + * Mouse up handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseUp = function (mouseEvent) { + this.__d_ax = -1; + this.__d_ay = -1; + }; + + /** + * Mouse drag handler for default drag behavior. + * @param mouseEvent {CAAT.Event.MouseEvent} + * + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + + var pt; + + pt = this.modelToView(new CAAT.Math.Point(mouseEvent.x, mouseEvent.y)); + this.parent.viewToModel(pt); + + if (this.__d_ax === -1 || this.__d_ay === -1) { + this.__d_ax = pt.x; + this.__d_ay = pt.y; + this.__d_asx = this.scaleX; + this.__d_asy = this.scaleY; + this.__d_ara = this.rotationAngle; + this.__d_screenx = mouseEvent.screenPoint.x; + this.__d_screeny = mouseEvent.screenPoint.y; + } + + if (mouseEvent.isShiftDown()) { + var scx = (mouseEvent.screenPoint.x - this.__d_screenx) / 100; + var scy = (mouseEvent.screenPoint.y - this.__d_screeny) / 100; + if (!mouseEvent.isAltDown()) { + var sc = Math.max(scx, scy); + scx = sc; + scy = sc; + } + this.setScale(scx + this.__d_asx, scy + this.__d_asy); + + } else if (mouseEvent.isControlDown()) { + var vx = mouseEvent.screenPoint.x - this.__d_screenx; + var vy = mouseEvent.screenPoint.y - this.__d_screeny; + this.setRotation(-Math.atan2(vx, vy) + this.__d_ara); + } else { + this.x += pt.x - this.__d_ax; + this.y += pt.y - this.__d_ay; + } + + this.__d_ax = pt.x; + this.__d_ay = pt.y; + }; + + return this; + }, + disableDrag:function () { + + this.mouseEnter = function (mouseEvent) { + }; + this.mouseExit = function (mouseEvent) { + }; + this.mouseMove = function (mouseEvent) { + }; + this.mouseUp = function (mouseEvent) { + }; + this.mouseDrag = function (mouseEvent) { + }; + + return this; + }, + /** + * Default mouseClick handler. + * Mouse click events are received after a call to mouseUp method if no dragging was in progress. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseClick:function (mouseEvent) { + }, + /** + * Default double click handler + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDblClick:function (mouseEvent) { + }, + /** + * Default mouse enter on Actor handler. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseEnter:function (mouseEvent) { + this.pointed = true; + }, + /** + * Default mouse exit on Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseExit:function (mouseEvent) { + this.pointed = false; + }, + /** + * Default mouse move inside Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseMove:function (mouseEvent) { + }, + /** + * default mouse press in Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDown:function (mouseEvent) { + }, + /** + * default mouse release in Actor handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseUp:function (mouseEvent) { + }, + mouseOut:function (mouseEvent) { + }, + mouseOver:function (mouseEvent) { + }, + /** + * default Actor mouse drag handler. + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDrag:function (mouseEvent) { + }, + /** + * Draw a bounding box with on-screen coordinates regardless of the transformations + * applied to the Actor. + * + * @param director {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in. + * @param time {number} integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + if (null !== this.AABB && this.inFrame) { + var s = this.AABB; + var ctx = director.ctx; + ctx.strokeStyle = CAAT.DEBUGAABBCOLOR; + ctx.strokeRect(.5 + (s.x | 0), .5 + (s.y | 0), s.width | 0, s.height | 0); + if (CAAT.DEBUGBB) { + var vv = this.viewVertices; + ctx.beginPath(); + ctx.lineTo(vv[0].x, vv[0].y); + ctx.lineTo(vv[1].x, vv[1].y); + ctx.lineTo(vv[2].x, vv[2].y); + ctx.lineTo(vv[3].x, vv[3].y); + ctx.closePath(); + ctx.strokeStyle = CAAT.DEBUGBBCOLOR; + ctx.stroke(); + } + } + }, + /** + * Private + * This method is called by the Director instance. + * It applies the list of behaviors the Actor has registered. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + animate:function (director, time) { + + if (!this.visible) { + return false; + } + + var i; + + if (!this.isInAnimationFrame(time)) { + this.inFrame = false; + this.dirty = true; + return false; + } + + if (this.x !== this.oldX || this.y !== this.oldY) { + this.dirty = true; + this.oldX = this.x; + this.oldY = this.y; + } + + for (i = 0; i < this.behaviorList.length; i++) { + this.behaviorList[i].apply(time, this); + } + + if (this.clipPath) { + this.clipPath.applyBehaviors(time); + } + + // transformation stuff. + this.setModelViewMatrix(); + + if (this.dirty || this.wdirty || this.invalid) { + if (director.dirtyRectsEnabled) { + director.addDirtyRect(this.AABB); + } + this.setScreenBounds(); + if (director.dirtyRectsEnabled) { + director.addDirtyRect(this.AABB); + } + } + this.dirty = false; + this.invalid = false; + + this.inFrame = true; + + if ( this.backgroundImage ) { + this.backgroundImage.setSpriteIndexAtTime(time); + } + + return this.AABB.intersects(director.AABB); + //return true; + }, + /** + * Set this model view matrix if the actor is Dirty. + * + mm[2]+= this.x; + mm[5]+= this.y; + if ( this.rotationAngle ) { + this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) ); + this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) ); c= Math.cos( this.rotationAngle ); + } + if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) { + this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) ); + this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) ); + this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) ); + } + * + * @return this + */ + setModelViewMatrix:function () { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty = false; + mm = this.modelViewMatrix.matrix; + + if (this.dirty) { + + mm0 = 1; + mm1 = 0; + //mm2= mm[2]; + mm3 = 0; + mm4 = 1; + //mm5= mm[5]; + + mm2 = this.x - this.tAnchorX * this.width; + mm5 = this.y - this.tAnchorY * this.height; + + if (this.rotationAngle) { + + var rx = this.rotationX * this.width; + var ry = this.rotationY * this.height; + + mm2 += mm0 * rx + mm1 * ry; + mm5 += mm3 * rx + mm4 * ry; + + c = Math.cos(this.rotationAngle); + s = Math.sin(this.rotationAngle); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm2 += -mm0 * rx - mm1 * ry; + mm5 += -mm3 * rx - mm4 * ry; + } + if (this.scaleX != 1 || this.scaleY != 1) { + + var sx = this.scaleTX * this.width; + var sy = this.scaleTY * this.height; + + mm2 += mm0 * sx + mm1 * sy; + mm5 += mm3 * sx + mm4 * sy; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm2 += -mm0 * sx - mm1 * sy; + mm5 += -mm3 * sx - mm4 * sy; + } + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + + if (this.parent) { + + + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA; + + if (this.dirty || this.parent.wdirty) { + this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix); + if (this.isAA) { + var mmm = this.worldModelViewMatrix.matrix; + mmm[2] += mm[2]; + mmm[5] += mm[5]; + } else { + this.worldModelViewMatrix.multiply(this.modelViewMatrix); + } + this.wdirty = true; + } + + } else { + if (this.dirty) { + this.wdirty = true; + } + + this.worldModelViewMatrix.identity(); + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1; + } + + +//if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) { + // screen bounding boxes will always be calculated. + /* + if ( this.dirty || this.wdirty || this.invalid ) { + if ( director.dirtyRectsEnabled ) { + director.addDirtyRect( this.AABB ); + } + this.setScreenBounds(); + if ( director.dirtyRectsEnabled ) { + director.addDirtyRect( this.AABB ); + } + } + this.dirty= false; + this.invalid= false; + */ + }, + /** + * Calculates the 2D bounding box in canvas coordinates of the Actor. + * This bounding box takes into account the transformations applied hierarchically for + * each Scene Actor. + * + * @private + * + */ + setScreenBounds:function () { + + var AABB = this.AABB; + var vv = this.viewVertices; + var vvv, m, x, y, w, h; + + if (this.isAA) { + m = this.worldModelViewMatrix.matrix; + x = m[2]; + y = m[5]; + w = this.width; + h = this.height; + AABB.x = x; + AABB.y = y; + AABB.x1 = x + w; + AABB.y1 = y + h; + AABB.width = w; + AABB.height = h; + + if (CAAT.GLRENDER) { + vvv = vv[0]; + vvv.x = x; + vvv.y = y; + vvv = vv[1]; + vvv.x = x + w; + vvv.y = y; + vvv = vv[2]; + vvv.x = x + w; + vvv.y = y + h; + vvv = vv[3]; + vvv.x = x; + vvv.y = y + h; + } + + return this; + } + + vvv = vv[0]; + vvv.x = 0; + vvv.y = 0; + vvv = vv[1]; + vvv.x = this.width; + vvv.y = 0; + vvv = vv[2]; + vvv.x = this.width; + vvv.y = this.height; + vvv = vv[3]; + vvv.x = 0; + vvv.y = this.height; + + this.modelToView(this.viewVertices); + + var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE; + var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE; + + vvv = vv[0]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[1]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[2]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[3]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + + AABB.x = xmin; + AABB.y = ymin; + AABB.x1 = xmax; + AABB.y1 = ymax; + AABB.width = (xmax - xmin); + AABB.height = (ymax - ymin); + + return this; + }, + /** + * @private. + * This method will be called by the Director to set the whole Actor pre-render process. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return boolean indicating whether the Actor isInFrameTime + */ + paintActor:function (director, time) { + + if (!this.visible || !director.inDirtyRect(this)) { + return true; + } + + var ctx = director.ctx; + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + ctx.globalAlpha = this.frameAlpha; + + director.modelViewMatrix.transformRenderingContextSet(ctx); + this.worldModelViewMatrix.transformRenderingContext(ctx); + + if (this.clip) { + ctx.beginPath(); + if (!this.clipPath) { + ctx.rect(0, 0, this.width, this.height); + } else { + this.clipPath.applyAsPath(director); + } + ctx.clip(); + } + + this.paint(director, time); + + return true; + }, + /** + * for js2native + * @param director + * @param time + */ + __paintActor:function (director, time) { + if (!this.visible) { + return true; + } + var ctx = director.ctx; + + // global opt: set alpha as owns alpha, not take globalAlpha procedure. + this.frameAlpha = this.alpha; + + var m = this.worldModelViewMatrix.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha); + this.paint(director, time); + return true; + }, + + /** + * Set coordinates and uv values for this actor. + * This function uses Director's coords and indexCoords values. + * @param director + * @param time + */ + paintActorGL:function (director, time) { + + this.frameAlpha = this.parent.frameAlpha * this.alpha; + + if (!this.glEnabled || !this.visible) { + return; + } + + if (this.glNeedsFlush(director)) { + director.glFlush(); + this.glSetShader(director); + + if (!this.__uv) { + this.__uv = new Float32Array(8); + } + if (!this.__vv) { + this.__vv = new Float32Array(12); + } + + this.setGLCoords(this.__vv, 0); + this.setUV(this.__uv, 0); + director.glRender(this.__vv, 12, this.__uv); + + return; + } + + var glCoords = director.coords; + var glCoordsIndex = director.coordsIndex; + + ////////////////// XYZ + this.setGLCoords(glCoords, glCoordsIndex); + director.coordsIndex = glCoordsIndex + 12; + + ////////////////// UV + this.setUV(director.uv, director.uvIndex); + director.uvIndex += 8; + }, + /** + * TODO: set GLcoords for different image transformations. + * + * @param glCoords + * @param glCoordsIndex + */ + setGLCoords:function (glCoords, glCoordsIndex) { + + var vv = this.viewVertices; + glCoords[glCoordsIndex++] = vv[0].x; + glCoords[glCoordsIndex++] = vv[0].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[1].x; + glCoords[glCoordsIndex++] = vv[1].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[2].x; + glCoords[glCoordsIndex++] = vv[2].y; + glCoords[glCoordsIndex++] = 0; + + glCoords[glCoordsIndex++] = vv[3].x; + glCoords[glCoordsIndex++] = vv[3].y; + glCoords[glCoordsIndex ] = 0; + + }, + /** + * Set UV for this actor's quad. + * + * @param uvBuffer {Float32Array} + * @param uvIndex {number} + */ + setUV:function (uvBuffer, uvIndex) { + this.backgroundImage.setUV(uvBuffer, uvIndex); + }, + /** + * Test for compulsory gl flushing: + * 1.- opacity has changed. + * 2.- texture page has changed. + * + */ + glNeedsFlush:function (director) { + if (this.getTextureGLPage() !== director.currentTexturePage) { + return true; + } + if (this.frameAlpha !== director.currentOpacity) { + return true; + } + return false; + }, + /** + * Change texture shader program parameters. + * @param director + */ + glSetShader:function (director) { + + var tp = this.getTextureGLPage(); + if (tp !== director.currentTexturePage) { + director.setGLTexturePage(tp); + } + + if (this.frameAlpha !== director.currentOpacity) { + director.setGLCurrentOpacity(this.frameAlpha); + } + }, + /** + * @private. + * This method is called after the Director has transformed and drawn a whole frame. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * @return this + * + * @deprecated + */ + endAnimate:function (director, time) { + return this; + }, + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + /** + * Set this Actor's clipping area. + * @param enable {boolean} enable clip area. + * @param clipPath {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set, + * a rectangle will be used. + */ + setClip:function (enable, clipPath) { + this.clip = enable; + this.clipPath = clipPath; + return this; + }, + + isCached : function() { + return this.cached; + }, + + stopCacheAsBitmap:function () { + if (this.cached) { + this.backgroundImage = null; + this.cached = CAAT.Foundation.Actor.CACHE_NONE; + } + }, + + /** + * + * @param time {Number=} + * @param stragegy {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP} + * @return this + */ + cacheAsBitmap:function (time, strategy) { + + if (this.width<=0 || this.height<=0 ) { + return this; + } + + time = time || 0; + var canvas = document.createElement('canvas'); + canvas.width = this.width; + canvas.height = this.height; + var ctx = canvas.getContext('2d'); + + CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,time); + + var director = { + ctx:ctx, + modelViewMatrix: new CAAT.Math.Matrix(), + worldModelViewMatrix: new CAAT.Math.Matrix(), + dirtyRectsEnabled:false, + inDirtyRect:function () { + return true; + }, + AABB : new CAAT.Math.Rectangle(0,0,this.width,this.height) + }; + + var pmv = this.modelViewMatrix; + var pwmv = this.worldModelViewMatrix; + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + + this.cached = CAAT.Foundation.Actor.CACHE_NONE; + + if ( typeof strategy==="undefined" ) { + strategy= CAAT.Foundation.Actor.CACHE_SIMPLE; + } + if ( strategy===CAAT.Foundation.Actor.CACHE_DEEP ) { + this.animate(director, time ); + this.paintActor(director, time); + } else { + if ( this instanceof CAAT.Foundation.ActorContainer || this instanceof CAAT.ActorContainer ) { + CAAT.Foundation.ActorContainer.superclass.paintActor.call(this, director, time); + } else { + this.animate(director, time ); + this.paintActor(director, time); + } + } + this.setBackgroundImage(canvas); + + this.cached = strategy; + + this.modelViewMatrix = pmv; + this.worldModelViewMatrix = pwmv; + + return this; + }, + resetAsButton : function() { + this.actionPerformed= null; + this.mouseEnter= function() {}; + this.mouseExit= function() {}; + this.mouseDown= function() {}; + this.mouseUp= function() {}; + this.mouseClick= function() {}; + this.mouseDrag= function() {}; + return this; + }, + /** + * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's + * single size. + * + * @param buttonImage {CAAT.Foundation.SpriteImage} sprite image with button's state images. + * @param iNormal {number} button's normal state image index + * @param iOver {number} button's mouse over state image index + * @param iPress {number} button's pressed state image index + * @param iDisabled {number} button's disabled state image index + * @param fn {function(button{CAAT.Foundation.Actor})} callback function + */ + setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) { + + var me = this; + + this.setBackgroundImage(buttonImage, true); + + this.iNormal = iNormal || 0; + this.iOver = iOver || this.iNormal; + this.iPress = iPress || this.iNormal; + this.iDisabled = iDisabled || this.iNormal; + this.fnOnClick = fn; + this.enabled = true; + + this.setSpriteIndex(iNormal); + + /** + * Enable or disable the button. + * @param enabled {boolean} + * @ignore + */ + this.setEnabled = function (enabled) { + this.enabled = enabled; + this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled); + return this; + }; + + /** + * This method will be called by CAAT *before* the mouseUp event is fired. + * @param event {CAAT.Event.MouseEvent} + * @ignore + */ + this.actionPerformed = function (event) { + if (this.enabled && this.fnOnClick) { + this.fnOnClick(this); + } + }; + + /** + * Button's mouse enter handler. It makes the button provide visual feedback + * @param mouseEvent {CAAT.Event.MouseEvent} + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + if (!this.enabled) { + return; + } + + if (this.dragging) { + this.setSpriteIndex(this.iPress); + } else { + this.setSpriteIndex(this.iOver); + } + CAAT.setCursor('pointer'); + }; + + /** + * Button's mouse exit handler. Release visual apperance. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseExit = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iNormal); + CAAT.setCursor('default'); + }; + + /** + * Button's mouse down handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDown = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iPress); + }; + + /** + * Button's mouse up handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseUp = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iNormal); + this.dragging = false; + }; + + /** + * Button's mouse click handler. Do nothing by default. This event handler will be + * called ONLY if it has not been drag on the button. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseClick = function (mouseEvent) { + }; + + /** + * Button's mouse drag handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.dragging = true; + }; + + this.setButtonImageIndex = function (_normal, _over, _press, _disabled) { + this.iNormal = _normal || 0; + this.iOver = _over || this.iNormal; + this.iPress = _press || this.iNormal; + this.iDisabled = _disabled || this.iNormal; + this.setSpriteIndex(this.iNormal); + return this; + }; + + return this; + }, + + findActorById : function(id) { + return this.id===id ? this : null; + } + } + } +}); diff --git a/CAAT/src/Foundation/ActorCSS.js b/CAAT/src/Foundation/ActorCSS.js new file mode 100644 index 0000000..4ac0cb8 --- /dev/null +++ b/CAAT/src/Foundation/ActorCSS.js @@ -0,0 +1,2092 @@ +CAAT.Module({ + defines:"CAAT.Foundation.Actor", + aliases:[ "CAAT.Actor" ], + depends:[ + "CAAT.Event.AnimationLoop", + "CAAT.Foundation.SpriteImage", + "CAAT.Core.Constants", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.Scale1Behavior", + "CAAT.PathUtil.LinearPath", + "CAAT.Event.AnimationLoop" + ], + constants:{ + ANCHOR_CENTER:0, // constant values to determine different affine transform + ANCHOR_TOP:1, // anchors. + ANCHOR_BOTTOM:2, + ANCHOR_LEFT:3, + ANCHOR_RIGHT:4, + ANCHOR_TOP_LEFT:5, + ANCHOR_TOP_RIGHT:6, + ANCHOR_BOTTOM_LEFT:7, + ANCHOR_BOTTOM_RIGHT:8, + ANCHOR_CUSTOM:9, + + NO_CACHE:0, + CACHE_SIMPLE:1, + CACHE_DEEP:2 + }, + extendsWith:function () { + + var __index = 0; + + return { + + __init:function () { + this.behaviorList = []; + + this.styleCache = {}; + this.lifecycleListenerList = []; + this.scaleAnchor = this.ANCHOR_CENTER; + this.behaviorList = []; + + this.domElement = document.createElement('div'); + this.domElement.style['position'] = 'absolute'; + this.domElement.style['-webkit-transform'] = 'translate3d(0,0,0)'; + this.domElement.style['-webkit-transition'] = 'all 0s linear'; + this.style('display', 'none'); + + this.AABB = new CAAT.Rectangle(); + this.viewVertices = [ + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0), + new CAAT.Point(0, 0, 0) + ]; + + this.setVisible(true); + this.resetTransform(); + this.setScale(1, 1); + this.setRotation(0); + + this.modelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrixI = new CAAT.Math.Matrix(); + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.worldModelViewMatrixI = new CAAT.Math.Matrix(); + + return this; + }, + lifecycleListenerList:null, // Array of life cycle listener + behaviorList:null, // Array of behaviors to apply to the Actor + x:0, // x position on parent. In parent's local coord. system. + y:0, // y position on parent. In parent's local coord. system. + width:0, // Actor's width. In parent's local coord. system. + height:0, // Actor's height. In parent's local coord. system. + preferredSize:null, // actor's preferred size for layout. {CAAT.Dimension} + minimumSize:null, // actor's minimum size for layout. {CAAT.Dimension}, + start_time:0, // Start time in Scene time. + duration:Number.MAX_VALUE, // Actor duration in Scene time + clip:false, // should clip the Actor's content against its contour. + + tAnchorX:0, + tAnchorY:0, + scaleX:0, // transformation. width scale parameter + scaleY:0, // transformation. height scale parameter + scaleTX:.50, // transformation. scale anchor x position + scaleTY:.50, // transformation. scale anchor y position + scaleAnchor:0, // transformation. scale anchor + rotationAngle:0, // transformation. rotation angle in radians + rotationY:.50, // transformation. rotation center y + alpha:1, // alpha transparency value + rotationX:.50, // transformation. rotation center x + isGlobalAlpha:false, // is this a global alpha + frameAlpha:1, // hierarchically calculated alpha for this Actor. + expired:false, // set when the actor has been expired + discardable:false, // set when you want this actor to be removed if expired + + domParent:null, + domElement:null, + + visible:true, + + mouseEnabled:true, + + time:0, // Cache Scene time. + inFrame:false, // boolean indicating whether this Actor was present on last frame. + backgroundImage:null, + + size_active:1, // number of animated children + size_total:1, + + id:null, + + __d_ax:-1, // for drag-enabled actors. + __d_ay:-1, + gestureEnabled:false, + + AABB:null, + viewVertices:null, // model to view transformed vertices. + isAA:true, + + preventLayout : false, + + setPreventLayout : function(b) { + this.preventLayout= b; + return this; + }, + + invalidate:function () { + this.invalid = true; + return this; + }, + + invalidateLayout:function () { + if (this.parent && !this.parent.layoutInvalidated) { + this.parent.invalidateLayout(); + } + + return this; + }, + + __validateLayout:function () { + + }, + + /** + * Set this actors preferred layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setPreferredSize:function (pw, ph) { + if (!this.preferredSize) { + this.preferredSize = new CAAT.Dimension(); + } + this.preferredSize.width = pw; + this.preferredSize.height = ph; + return this; + }, + + getPreferredSize:function () { + return this.preferredSize ? this.preferredSize : + this.getMinimumSize(); + }, + + /** + * Set this actors minimum layout size. + * + * @param pw {number} + * @param ph {number} + * @return {*} + */ + setMinimumSize:function (pw, ph) { + if (!this.minimumSize) { + this.minimumSize = new CAAT.Dimension(); + } + + this.minimumSize.width = pw; + this.minimumSize.height = ph; + return this; + }, + + getMinimumSize:function () { + return this.minimumSize ? this.minimumSize : + new CAAT.Dimension(this.width, this.height); + }, + + isVisible:function () { + return this.visible; + }, + + /** + * @deprecated + * @return {*} + */ + create:function () { + return this; + }, + /** + * Move this actor to a position. + * It creates and adds a new PathBehavior. + * @param x {number} new x position + * @param y {number} new y position + * @param duration {number} time to take to get to new position + * @param delay {=number} time to wait before start moving + * @param interpolator {=CAAT.Interpolator} a CAAT.Interpolator instance + */ + moveTo:function (x, y, duration, delay, interpolator) { + + if (x === this.x && y === this.y) { + return; + } + + var id = '__moveTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.PathBehavior(). + setId(id). + setValues(new CAAT.LinearPath()); + this.addBehavior(b); + } + + b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y); + b.setDelayTime(delay ? delay : 0, duration); + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param angle {number} new rotation angle + * @param duration {number} time to rotate + * @param delay {number=} millis to start rotation + * @param anchorX {number=} rotation anchor x + * @param anchorY {number=} rotation anchor y + * @param interpolator {CAAT.Interpolator=} + * @return {*} + */ + rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) { + + if (angle === this.rotationAngle) { + return; + } + + var id = '__rotateTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.RotateBehavior(). + setId(id). + setValues(0, 0, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.rotationAngle, angle, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) { + + if (this.scaleX === scaleX && this.scaleY === scaleY) { + return; + } + + var id = '__scaleTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.ScaleBehavior(). + setId(id). + setValues(1, 1, 1, 1, .5, .5); + this.addBehavior(b); + } + + b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * + * @param scaleX {number} new X scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Scale1Behavior.AXIS_X, + scaleX, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * + * @param scaleY {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) { + return this.__scale1To( + CAAT.Scale1Behavior.AXIS_Y, + scaleY, + duration, + delay, + anchorX, + anchorY, + interpolator + ); + }, + + /** + * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis + * @param scale {number} new Y scale + * @param duration {number} time to rotate + * @param delay {=number} millis to start rotation + * @param anchorX {=number} rotation anchor x + * @param anchorY {=number} rotation anchor y + * @param interpolator {=CAAT.Interpolator} + * @return {*} + */ + __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) { + + if (( axis === CAAT.Scale1Behavior.AXIS_X && scale === this.scaleX) || + ( axis === CAAT.Scale1Behavior.AXIS_Y && scale === this.scaleY)) { + + return; + } + + var id = '__scaleXTo'; + var b = this.getBehavior(id); + if (!b) { + b = new CAAT.Scale1Behavior(). + setId(id). + setValues(1, 1, axis === CAAT.Scale1Behavior.AXIS_X, .5, .5); + this.addBehavior(b); + } + + b.setValues( + axis ? this.scaleX : this.scaleY, + scale, + anchorX, + anchorY). + setDelayTime(delay ? delay : 0, duration); + + if (interpolator) { + b.setInterpolator(interpolator); + } + + return this; + }, + + /** + * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH + * @param e + */ + touchStart:function (e) { + }, + touchMove:function (e) { + }, + touchEnd:function (e) { + }, + gestureStart:function (rotation, scaleX, scaleY) { + }, + gestureChange:function (rotation, scaleX, scaleY) { + if (this.gestureEnabled) { + this.setRotation(rotation); + this.setScale(scaleX, scaleY); + } + return this; + }, + gestureEnd:function (rotation, scaleX, scaleY) { + }, + + + /** + * Calculates the 2D bounding box in canvas coordinates of the Actor. + * This bounding box takes into account the transformations applied hierarchically for + * each Scene Actor. + * + * @private + * + */ + setScreenBounds:function () { + + var AABB = this.AABB; + var vv = this.viewVertices; + + if (this.isAA) { + var m = this.worldModelViewMatrix.matrix; + AABB.x = m[2]; + AABB.y = m[5]; + AABB.x1 = m[2] + this.width; + AABB.y1 = m[5] + this.height; + AABB.width = AABB.x1 - AABB.x; + AABB.height = AABB.y1 - AABB.y; + return this; + } + + + var vvv; + + vvv = vv[0]; + vvv.x = 0; + vvv.y = 0; + vvv = vv[1]; + vvv.x = this.width; + vvv.y = 0; + vvv = vv[2]; + vvv.x = this.width; + vvv.y = this.height; + vvv = vv[3]; + vvv.x = 0; + vvv.y = this.height; + + this.modelToView(this.viewVertices); + + var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE; + var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE; + + vvv = vv[0]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[1]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[2]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[3]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + + AABB.x = xmin; + AABB.y = ymin; + AABB.x1 = xmax; + AABB.y1 = ymax; + AABB.width = (xmax - xmin); + AABB.height = (ymax - ymin); + + return this; + }, + setGestureEnabled:function (enable) { + this.gestureEnabled = !!enable; + return this; + }, + isGestureEnabled:function () { + return this.gestureEnabled; + }, + getId:function () { + return this.id; + }, + setId:function (id) { + this.id = id; + return this; + }, + + /** + * Set this Actor's parent and connect in CSS a div with its parent. + * In case there's a parent set, previously the div will be removed from + * its old parent and reattached to the new one. + * @param parent {CAAT.ActorContainerCSS|CAAT.Actor} + * @return this + */ + setParent:function (parent) { + if (this.parent) { + try { + this.domParent.removeChild(this.domElement); + } catch (e) { + // when changing a parent, make sure the operation does not fail. + // it may happen a root node has had removed its children and all the dom hierarchy + // may have been lost. + } + } + + this.parent = parent; + if (null != parent) { + this.parent.domElement.appendChild(this.domElement); + this.domParent = this.parent.domElement; + } else { + this.domParent = null; + } + + this.dirty = true; + + return this; + }, + + /** + * Set this actor's background image. + * The need of a background image is to kept compatibility with the new CSSDirector class. + * The image parameter can be either an Image/Canvas or a CAAT.SpriteImage instance. If an image + * is supplied, it will be wrapped into a CAAT.SriteImage instance of 1 row by 1 column. + * If the actor has set an image in the background, the paint method will draw the image, otherwise + * and if set, will fill its background with a solid color. + * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one + * single image from the SpriteImage (either supplied or generated because of passing an Image or + * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth, + * height:singleHeight]. + * + * It is absolutely recommended not using a Canvas as argument. The performance + * of canvas.toDataURL (despite its result being cached) is very poor. + * + * @see CAAT.SpriteImage + * + * @param image {Image|Canvas|CAAT.SpriteImage} + * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter. + * @throws 'Invalid image object to set actor's background' in case the image parameter is not of the + * valid type. + * @return this + */ + setBackgroundImage:function (image, adjust_size_to_image) { + if (image) { + // Opera will complaint about instanceof Image, so better HTMLImageElement. + if (image instanceof HTMLImageElement) { + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } else if (image instanceof HTMLCanvasElement) { + image.src = image.toDataURL(); + image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1); + } else if (image instanceof CAAT.SpriteImage) { + if (image.image instanceof HTMLCanvasElement) { + if (!image.image.src) { + image.image.src = image.image.toDataURL(); + } + } + } else if (isString(image)) { + image= new CAAT.Foundation.SpriteImage().initialize( CAAT.currentDirector.getImage(image), 1, 1 ); + } else { + throw "Invalid image object to set actor's background"; + } + + image.setOwner(this); + this.backgroundImage = image; + if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) { + this.setSize(image.getWidth(), image.getHeight()); + } + + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } else { + this.backgroundImage = null; + this.style('background', 'none'); + } + + return this; + }, + /** + * Set the actor's SpriteImage index from animation sheet. + * @see CAAT.SpriteImage + * @param index {integer} + * + * @return this + */ + setSpriteIndex:function (index) { + if (this.backgroundImage) { + this.backgroundImage.setSpriteIndex(index); + + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + + } + + return this; + + }, + /** + * Set this actor's background SpriteImage offset displacement. + * The values can be either positive or negative meaning the texture space of this background + * image does not start at (0,0) but at the desired position. + * @see CAAT.SpriteImage + * @param ox {integer} horizontal offset + * @param oy {integer} vertical offset + * + * @return this + */ + setBackgroundImageOffset:function (ox, oy) { + if (this.backgroundImage) { + this.backgroundImage.setOffset(ox, oy); + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } + + return this; + }, + /** + * Set this actor's background SpriteImage its animation sequence. + * In its simplet's form a SpriteImage treats a given image as an array of rows by columns + * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages. + * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the + * animation sequence + * @param ii {array} an array of integers. + */ + setAnimationImageIndex:function (ii) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationImageIndex(ii); + this.style( + 'background', + 'url(' + this.backgroundImage.image.src + ') ' + + this.backgroundImage.getCurrentSpriteImageCSSPosition()); + } + return this; + }, + + addAnimation : function( name, array, time, callback ) { + if (this.backgroundImage) { + this.backgroundImage.addAnimation(name, array, time, callback); + } + return this; + }, + + playAnimation : function(name) { + if (this.backgroundImage) { + this.backgroundImage.playAnimation(name); + } + return this; + }, + + setAnimationEndCallback : function(f) { + if (this.backgroundImage) { + this.backgroundImage.setAnimationEndCallback(f); + } + }, + + + setChangeFPS:function (time) { + if (this.backgroundImage) { + this.backgroundImage.setChangeFPS(time); + } + return this; + }, + /** + * This method has no effect on ActorCSS + * @param it any value from CAAT.Actor.TR_* + * @return this + */ + setImageTransformation:function (it) { + this.transformation = it; + if (it === CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE) { + this.style('background-size', '100%'); + } else if (it === CAAT.Foundation.SpriteImage.TR_NONE) { + this.style('background-size', 'auto'); + } + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {float} x position + * @param y {float} y position + * + * @return this + */ + centerOn:function (x, y) { + this.setLocation(x - this.width / 2, y - this.height / 2); + return this; + }, + /** + * Center this actor at position (x,y). + * @param x {number} x position + * @param y {number} y position + * + * @return this + */ + centerAt:function (x, y) { + return this.centerOn(x, y); + }, + /** + * Set this actor invisible. + * The actor is animated but not visible. + * A container won't show any of its children if set visible to false. + * + * @param visible {boolean} set this actor visible or not. + * @return this + */ + setVisible:function (visible) { + this.visible = visible; + return this; + }, + style:function (attr, value) { + if (value !== this.styleCache[attr]) { + this.styleCache[attr] = value; + this.domElement.style[attr] = value; + } + }, + style3:function () { + + var imageop = ''; + if (this.transformation === CAAT.Foundation.SpriteImage.TR_FLIP_HORIZONTAL) { + imageop = ' scale(-1,1) '; + } + + this.rotationAngle = Math.round(this.rotationAngle * 100) / 100; + + var value = + "translate(" + this.x + "px," + this.y + "px) " + + "rotate(" + this.rotationAngle + "rad) scale(" + this.scaleX + "," + this.scaleY + ")" + + imageop; + + if (value !== this.styleCache['transform']) { + this.domElement.style['-ms-transform'] = value; + this.domElement.style['-webkit-transform'] = "translate3d(0,0,0) " + value; + this.domElement.style.OTransform = value; + this.domElement.style.MozTransform = value; + this.domElement.style['transform'] = value; + this.styleCache['transform'] = value; + } + + var anchor = '' + (this.rotationX * 100) + '% ' + + (this.rotationY * 100) + '% '; + + if (anchor !== this.styleCache['transform-origin']) { + this.domElement.style['transform-origin'] = anchor; + this.domElement.style['-webkit-transform-origin'] = anchor; + this.domElement.style['-ms-transform-origin'] = anchor; + this.domElement.style.OTransformOrigin = anchor; + this.domElement.style.MozTransformOrigin = anchor; + this.styleCache['transform-origin'] = anchor; + } + + return this; + }, + styleAlpha:function (alpha) { + if (this.alpha !== this.styleCache['opacity']) { + this.domElement.style['filter'] = 'alpha(opacity=' + ((this.alpha * 100) >> 0) + ')'; + this.domElement.style.Oopacity = this.alpha; + this.domElement.style.MozOpacity = this.alpha; + this.domElement.style['-khtml-opacity'] = this.alpha; + this.domElement.style.opacity = this.alpha; + this.styleCache['opacity'] = this.alpha; + } + + return this; + }, + /** + * Puts an Actor out of time line, that is, won't be transformed nor rendered. + * @return this + */ + setOutOfFrameTime:function () { + this.setFrameTime(-1, 0); + this.style('display', 'none'); + return this; + }, + /** + * Adds an Actor's life cycle listener. + * The developer must ensure the actorListener is not already a listener, otherwise + * it will notified more than once. + * @param actorListener {object} an object with at least a method of the form: + * actorLyfeCycleEvent( actor, string_event_type, long_time ) + */ + addListener:function (actorListener) { + this.lifecycleListenerList.push(actorListener); + }, + /** + * Removes an Actor's life cycle listener. + * It will only remove the first occurrence of the given actorListener. + * @param actorListener {object} an Actor's life cycle listener. + */ + removeListener:function (actorListener) { + var n = this.lifecycleListenerList.length; + while (n--) { + if (this.lifecycleListenerList[n] === actorListener) { + // remove the nth element. + this.lifecycleListenerList.splice(n, 1); + return; + } + } + }, + /** + * Set alpha composition scope. global will mean this alpha value will be its children maximum. + * If set to false, only this actor will have this alpha value. + * @param global {boolean} whether the alpha value should be propagated to children. + */ + setGlobalAlpha:function (global) { + this.isGlobalAlpha = global; + return this; + }, + /** + * Notifies the registered Actor's life cycle listener about some event. + * @param sEventType an string indicating the type of event being notified. + * @param time an integer indicating the time related to Scene's timeline when the event + * is being notified. + */ + fireEvent:function (sEventType, time) { + for (var i = 0; i < this.lifecycleListenerList.length; i++) { + this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time); + } + }, + /** + * Sets this Actor as Expired. + * If this is a Container, all the contained Actors won't be nor drawn nor will receive + * any event. That is, expiring an Actor means totally taking it out the Scene's timeline. + * @param time {number} an integer indicating the time the Actor was expired at. + * @return this. + */ + setExpired:function (time) { + this.expired = true; + this.style('display', 'none'); + this.fireEvent('expired', time); + return this; + }, + /** + * Enable or disable the event bubbling for this Actor. + * @param enable {boolean} a boolean indicating whether the event bubbling is enabled. + * @return this + */ + enableEvents:function (enable) { + this.mouseEnabled = enable; + return this; + }, + /** + * Removes all behaviors from an Actor. + * @return this + */ + emptyBehaviorList:function () { + this.behaviorList = []; + return this; + }, + /* + emptyKeyframesList : function() { + this.keyframesList= []; + }, + */ + /** + * Caches a fillStyle in the Actor. + * @param style a valid Canvas rendering context fillStyle. + * @return this + */ + setFillStyle:function (style) { + this.style('background', style); + return this; + }, + /** + * Caches a stroke style in the Actor. + * @param style a valid canvas rendering context stroke style. + * @return this + */ + setStrokeStyle:function (style) { + return this; + }, + /** + * @deprecated + * @param paint + */ + setPaint:function (paint) { + }, + /** + * Stablishes the Alpha transparency for the Actor. + * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors. + * The alpha must be between 0 and 1. + * @param alpha a float indicating the alpha value. + * @return this + */ + setAlpha:function (alpha) { + this.alpha = alpha; + return this; + }, + /** + * Remove all transformation values for the Actor. + * @return this + */ + resetTransform:function () { + this.rotationAngle = 0; + this.rotationX = .5; + this.rotationY = .5; + this.scaleX = 1; + this.scaleY = 1; + this.scaleTX = .5; + this.scaleTY = .5; + this.scaleAnchor = 0; + this.oldX = -1; + this.oldY = -1; + + this.style3(); + + this.dirty = true; + + return this; + }, + /** + * Sets the time life cycle for an Actor. + * These values are related to Scene time. + * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene. + * @param duration an integer indicating how much the Actor will last once visible. + * @return this + */ + setFrameTime:function (startTime, duration) { + this.start_time = startTime; + this.duration = duration; + this.expired = false; + this.dirty = true; + + return this; + }, + /** + * This method should me overriden by every custom Actor. + * It will be the drawing routine called by the Director to show every Actor. + * @param director the CAAT.Director instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time in which the drawing is performed. + */ + paint:function (director, time) { + }, + /** + * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER + * + * @see setScaleAnchored + * + * @param sx a float indicating a width size multiplier. + * @param sy a float indicating a height size multiplier. + * @return this + */ + setScale:function (sx, sy) { + this.setScaleAnchored(sx, sy, .5, .5); + return this; + }, + /** + * Private. + * Gets a given anchor position referred to the Actor. + * @param anchor + * @return an object of the form { x: float, y: float } + */ + getAnchor:function (anchor) { + var tx = 0, ty = 0; + + switch (anchor) { + case this.ANCHOR_CENTER: + tx = .5; + ty = .5; + break; + case this.ANCHOR_TOP: + tx = .5; + ty = 0; + break; + case this.ANCHOR_BOTTOM: + tx = .5; + ty = 1; + break; + case this.ANCHOR_LEFT: + tx = 0; + ty = .5; + break; + case this.ANCHOR_RIGHT: + tx = 1; + ty = .5; + break; + case this.ANCHOR_TOP_RIGHT: + tx = 1; + ty = 0; + break; + case this.ANCHOR_BOTTOM_LEFT: + tx = 0; + ty = 1; + break; + case this.ANCHOR_BOTTOM_RIGHT: + tx = 1; + ty = 1; + break; + case this.ANCHOR_TOP_LEFT: + tx = 0; + ty = 0; + break; + } + + return {x:tx, y:ty}; + }, + getAnchorPercent:function (anchor) { + + var anchors = [ + .50, .50, .50, 0, .50, 1.00, + 0, .50, 1.00, .50, 0, 0, + 1.00, 0, 0, 1.00, 1.00, 1.00 + ]; + + return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] }; + }, + + setGlobalAnchor:function (ax, ay) { + this.tAnchorX = ax; + this.rotationX = ax; + this.scaleTX = ax; + + this.tAnchorY = ay; + this.rotationY = ay; + this.scaleTY = ay; + + this.dirty = true; + return this; + }, + + setScaleAnchor:function (sax, say) { + this.rotationX = sax; + this.rotationY = say; + this.scaleTX = sax; + this.scaleTY = say; + + this.style3(); + + this.dirty = true; + return this; + }, + /** + * Modify the dimensions on an Actor. + * The dimension will not affect the local coordinates system in opposition + * to setSize or setBounds. + * + * @param sx {number} width scale. + * @param sy {number} height scale. + * @param anchorx {number} x anchor to perform the Scale operation. + * @param anchory {number} y anchor to perform the Scale operation. + * + * @return this; + */ + setScaleAnchored:function (sx, sy, anchorx, anchory) { + this.rotationX = anchorx; + this.rotationY = anchory; + this.scaleTX = anchorx; + this.scaleTY = anchory; + + this.scaleX = sx; + this.scaleY = sy; + + this.style3(); + + this.dirty = true; + + return this; + }, + + + /** + * A helper method for setRotationAnchored. This methods stablishes the center + * of rotation to be the center of the Actor. + * + * @param angle a float indicating the angle in radians to rotate the Actor. + * @return this + */ + setRotation:function (angle) { + this.rotationAngle = angle; + this.style3(); + this.dirty = true; + return this; + }, + + setRotationAnchor:function (rax, ray) { + this.rotationX = ray; + this.rotationY = rax; + this.style3(); + this.dirty = true; + return this; + }, + + setRotationAnchored:function (angle, rx, ry) { + this.rotationAngle = angle; + this.rotationX = rx; + this.rotationY = ry; + this.style3(); + + this.dirty = true; + return this; + }, + + /** + * Sets an Actor's dimension + * @param w a float indicating Actor's width. + * @param h a float indicating Actor's height. + * @return this + */ + setSize:function (w, h) { + this.width = w; + this.height = h; + + this.style('width', '' + w + 'px'); + this.style('height', '' + h + 'px'); + + this.dirty = true; + + return this; + }, + /** + * Set location and dimension of an Actor at once. + * + * as http://jsperf.com/drawimage-whole-pixels states, drawing at whole pixels rocks while at subpixels sucks. + * thanks @pbakaus + * + * @param x a float indicating Actor's x position. + * @param y a float indicating Actor's y position + * @param w a float indicating Actor's width + * @param h a float indicating Actor's height + * @return this + */ + setBounds:function (x, y, w, h) { + //this.x= x; + //this.y= y; + this.x = x; + this.y = y; + this.width = w; + this.height = h; + + this.setLocation(x, y); + this.setSize(w, h); + + return this; + }, + + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + this.style3(); + this.dirty = true; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + + /** + * This method sets the position of an Actor inside its parent. + * + * as http://jsperf.com/drawimage-whole-pixels states, drawing at whole pixels rocks while at subpixels sucks. + * thanks @pbakaus + * + * @param x a float indicating Actor's x position + * @param y a float indicating Actor's y position + * @return this + */ + setLocation:function (x, y) { + + this.x = x; + this.y = y; + + this.style3(); + /* + this.style('left', x+'px'); + this.style('top', y+'px'); + */ + this.dirty = true; + + return this; + }, + /** + * This method is called by the Director to know whether the actor is on Scene time. + * In case it was necessary, this method will notify any life cycle behaviors about + * an Actor expiration. + * @param time an integer indicating the Scene time. + * + * @private + * + */ + isInAnimationFrame:function (time) { + if (this.expired) { + return false; + } + + if (this.duration === Number.MAX_VALUE) { + if (this.start_time <= time) { + return true; + } else { + return false; + } + } + + if (time >= this.start_time + this.duration) { + if (!this.expired) { + this.setExpired(time); + } + return false; + } + + return this.start_time <= time && time < this.start_time + this.duration; + }, + /** + * Checks whether a coordinate is inside the Actor's bounding box. + * @param x {number} a float + * @param y {number} a float + * + * @return boolean indicating whether it is inside. + */ + contains:function (x, y) { + return x >= 0 && y >= 0 && x < this.width && y < this.height; + }, + + /** + addKeyframes : function( keyframe, start, duration, cycle ) { + this.keyframesList.push( new CAAT.KeyframesDescriptor( keyframe, start, duration, cycle ) ); + }, + + scheduleKeyframes : function( id, startTime, duration ) { + var kf= this.getKeyframesDescriptor(id); + if ( kf ) { + kf.schedule( startTime, duration ); + } + return this; + }, + + removeKeyframes : function( keyframe ) { + var kfs= this.keyframesList; + for( var i=0; i + * WARNING: every call to this method calculates + * actor's world model view matrix. + * + * @param point {CAAT.Point} a point in screen space to be transformed to model space. + * + * @return the source point object + * + * + */ + viewToModel:function (point) { + this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI); + this.worldModelViewMatrixI.transformCoord(point); + return point; + }, + /** + * Transform a local coordinate point on this Actor's coordinate system into + * another point in otherActor's coordinate system. + * @param point {CAAT.Point} + * @param otherActor {CAAT.Actor} + */ + modelToModel:function (point, otherActor) { + return otherActor.viewToModel(this.modelToView(point)); + }, + + /** + * Private + * This method does the needed point transformations across an Actor hierarchy to devise + * whether the parameter point coordinate lies inside the Actor. + * @param point an object of the form { x: float, y: float } + * + * @return null if the point is not inside the Actor. The Actor otherwise. + */ + findActorAtPosition:function (point) { + if (this.scaleX===0 || this.scaleY===0) { + return null; + } + + if (!this.mouseEnabled || !this.isInAnimationFrame(this.time)) { + return null; + } + + this.setModelViewMatrix(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.modelViewMatrixI.transformCoord(point); + return this.contains(point.x, point.y) ? this : null; + }, + /** + * Enables a default dragging routine for the Actor. + * This default dragging routine allows to: + *
          • scale the Actor by pressing shift+drag + *
          • rotate the Actor by pressing control+drag + *
          • scale non uniformly by pressing alt+shift+drag + * + * @return this + */ + enableDrag:function () { + + this.ax = 0; + this.ay = 0; + this.mx = 0; + this.my = 0; + this.asx = 1; + this.asy = 1; + this.ara = 0; + this.screenx = 0; + this.screeny = 0; + + /** + * Mouse enter handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseEnter = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + this.pointed = true; + CAAT.setCursor('move'); + }; + + /** + * Mouse exit handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseExit = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + this.pointed = false; + CAAT.setCursor('default'); + }; + + /** + * Mouse move handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseMove = function (mouseEvent) { + this.mx = mouseEvent.point.x; + this.my = mouseEvent.point.y; + }; + + /** + * Mouse up handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseUp = function (mouseEvent) { + this.ax = -1; + this.ay = -1; + }; + + /** + * Mouse drag handler for default drag behavior. + * @param mouseEvent {CAAT.MouseEvent} + * + * @inner + */ + this.mouseDrag = function (mouseEvent) { + + if (this.ax === -1 || this.ay === -1) { + this.ax = mouseEvent.point.x; + this.ay = mouseEvent.point.y; + this.asx = this.scaleX; + this.asy = this.scaleY; + this.ara = this.rotationAngle; + this.screenx = mouseEvent.screenPoint.x; + this.screeny = mouseEvent.screenPoint.y; + } + + if (mouseEvent.isShiftDown()) { + var scx = (mouseEvent.screenPoint.x - this.screenx) / 100; + var scy = (mouseEvent.screenPoint.y - this.screeny) / 100; + if (!mouseEvent.isAltDown()) { + var sc = Math.max(scx, scy); + scx = sc; + scy = sc; + } + this.setScale(scx + this.asx, scy + this.asy); + + } else if (mouseEvent.isControlDown()) { + var vx = mouseEvent.screenPoint.x - this.screenx; + var vy = mouseEvent.screenPoint.y - this.screeny; + this.setRotation(-Math.atan2(vx, vy) + this.ara); + } else { + this.setLocation( + this.x + mouseEvent.point.x - this.ax, + this.y + mouseEvent.point.y - this.ay); + this.ax = mouseEvent.point.x; + this.ay = mouseEvent.point.y; + } + + + }; + + return this; + }, + /** + * Default mouseClick handler. + * Mouse click events are received after a call to mouseUp method if no dragging was in progress. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseClick:function (mouseEvent) { + }, + /** + * Default double click handler + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDblClick:function (mouseEvent) { + }, + /** + * Default mouse enter on Actor handler. + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseEnter:function (mouseEvent) { + this.pointed = true; + }, + /** + * Default mouse exit on Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseExit:function (mouseEvent) { + this.pointed = false; + }, + /** + * Default mouse move inside Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseMove:function (mouseEvent) { + }, + /** + * default mouse press in Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDown:function (mouseEvent) { + }, + /** + * default mouse release in Actor handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseUp:function (mouseEvent) { + }, + /** + * default Actor mouse drag handler. + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseDrag:function (mouseEvent) { + }, + mouseOut:function (mouseEvent) { + }, + mouseOver:function (mouseEvent) { + }, + /** + * Draw a bounding box with on-screen coordinates regardless of the transformations + * applied to the Actor. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + }, + /** + * Private + * This method is called by the Director instance. + * It applies the list of behaviors the Actor has registered. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + animate:function (director, time) { + if (!this.isInAnimationFrame(time)) { + this.inFrame = false; + this.dirty = true; + this.style('display', 'none'); + return false; + } else { + this.style('display', this.visible ? 'block' : 'none'); + } + + for (var i = 0; i < this.behaviorList.length; i++) { + this.behaviorList[i].apply(time, this); + } + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + //this.setAlpha(this.frameAlpha); + this.styleAlpha(this.frameAlpha); + this.inFrame = true; + + this.setModelViewMatrix(false); + + if (this.dirty || this.wdirty || this.invalid) { + this.setScreenBounds(); + } + + this.dirty = false; + + if ( this.backgroundImage ) { + var bi = this.backgroundImage; + if (bi) { + var pi = bi.spriteIndex; + bi.setSpriteIndexAtTime(time); + if (pi != bi.spriteIndex) { + this.setSpriteIndex(bi.spriteIndex); + } + } + } + + //return true; + return this.AABB.intersects(director.AABB); + }, + /** + * Set this model view matrix if the actor is Dirty. + * + * @return this + */ + /* + setModelViewMatrix : function(glEnabled) { + var c,s,_m00,_m01,_m10,_m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty= false; + + if ( this.dirty ) { + + mm= this.modelViewMatrix.identity().matrix; + + mm0= mm[0]; + mm1= mm[1]; + mm2= mm[2]; + mm3= mm[3]; + mm4= mm[4]; + mm5= mm[5]; + + mm2+= this.x; + mm5+= this.y; + + if ( this.rotationAngle ) { + mm2+= mm0*this.rotationX*this.width + mm1*this.rotationY*this.height; + mm5+= mm3*this.rotationX*this.width + mm4*this.rotationY*this.height; + + c= Math.cos( this.rotationAngle ); + s= Math.sin( this.rotationAngle ); + _m00= mm0; + _m01= mm1; + _m10= mm3; + _m11= mm4; + mm0= _m00*c + _m01*s; + mm1= -_m00*s + _m01*c; + mm3= _m10*c + _m11*s; + mm4= -_m10*s + _m11*c; + + mm2+= -mm0*this.rotationX*this.width - mm1*this.rotationY*this.height; + mm5+= -mm3*this.rotationX*this.width - mm4*this.rotationY*this.height; + } + if ( this.scaleX!=1 || this.scaleY!=1 ) { + + mm2+= mm0*this.scaleTX*this.width + mm1*this.scaleTY*this.height; + mm5+= mm3*this.scaleTX*this.width + mm4*this.scaleTY*this.height; + + mm0= mm0*this.scaleX; + mm1= mm1*this.scaleY; + mm3= mm3*this.scaleX; + mm4= mm4*this.scaleY; + + mm2+= -mm0*this.scaleTX*this.width - mm1*this.scaleTY*this.height; + mm5+= -mm3*this.scaleTX*this.width - mm4*this.scaleTY*this.height; + } + + mm[0]= mm0; + mm[1]= mm1; + mm[2]= mm2; + mm[3]= mm3; + mm[4]= mm4; + mm[5]= mm5; + } + + if ( this.parent ) { + if ( this.dirty || this.parent.wdirty ) { + this.worldModelViewMatrix.copy( this.parent.worldModelViewMatrix ); + this.worldModelViewMatrix.multiply( this.modelViewMatrix ); + this.wdirty= true; + } + } else { + if ( this.dirty ) { + this.wdirty= true; + } + //this.worldModelViewMatrix.copy( this.modelViewMatrix ); + this.worldModelViewMatrix.identity(); + } + + // this.dirty= false; + + + return this; + },*/ + + setModelViewMatrix:function () { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + this.wdirty = false; + mm = this.modelViewMatrix.matrix; + + if (this.dirty) { + + mm0 = 1; + mm1 = 0; + //mm2= mm[2]; + mm3 = 0; + mm4 = 1; + //mm5= mm[5]; + + mm2 = this.x - this.tAnchorX * this.width; + mm5 = this.y - this.tAnchorY * this.height; + + if (this.rotationAngle) { + + var rx = this.rotationX * this.width; + var ry = this.rotationY * this.height; + + mm2 += mm0 * rx + mm1 * ry; + mm5 += mm3 * rx + mm4 * ry; + + c = Math.cos(this.rotationAngle); + s = Math.sin(this.rotationAngle); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm2 += -mm0 * rx - mm1 * ry; + mm5 += -mm3 * rx - mm4 * ry; + } + if (this.scaleX != 1 || this.scaleY != 1) { + + var sx = this.scaleTX * this.width; + var sy = this.scaleTY * this.height; + + mm2 += mm0 * sx + mm1 * sy; + mm5 += mm3 * sx + mm4 * sy; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm2 += -mm0 * sx - mm1 * sy; + mm5 += -mm3 * sx - mm4 * sy; + } + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + + if (this.parent) { + + + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA; + + if (this.dirty || this.parent.wdirty) { + this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix); + if (this.isAA) { + var mmm = this.worldModelViewMatrix.matrix; + mmm[2] += mm[2]; + mmm[5] += mm[5]; + } else { + this.worldModelViewMatrix.multiply(this.modelViewMatrix); + } + this.wdirty = true; + } + + } else { + if (this.dirty) { + this.wdirty = true; + } + + this.worldModelViewMatrix.identity(); + this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1; + } + + }, + + /** + * @private. + * This method will be called by the Director to set the whole Actor pre-render process. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return boolean indicating whether the Actor isInFrameTime + */ + paintActor:function (director, time) { + + return true; + }, + /** + * @private. + * This method is called after the Director has transformed and drawn a whole frame. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * @return this + * + * @deprecated + */ + endAnimate:function (director, time) { + return this; + }, + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + /** + * Enable or disable the clipping process for this Actor. + * + * @param clip a boolean indicating whether clip is enabled. + * @return this + */ + setClip:function (clip) { + this.clip = clip; + this.style('overflow', this.clip ? 'hidden' : 'visible'); + return this; + }, + stopCacheAsBitmap : function() { + return this; + }, + + /** + * + * @param time {Number=} + * @return canvas + */ + cacheAsBitmap:function (time) { + return this; + }, + /** + * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's + * single size. + * + * @param buttonImage + * @param iNormal + * @param iOver + * @param iPress + * @param iDisabled + * @param fn + */ + setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) { + + var me = this; + + this.setBackgroundImage(buttonImage, true); + + this.iNormal = iNormal || 0; + this.iOver = iOver || this.iNormal; + this.iPress = iPress || this.iNormal; + this.iDisabled = iDisabled || this.iNormal; + this.fnOnClick = fn; + this.enabled = true; + + this.setSpriteIndex(iNormal); + + /** + * Enable or disable the button. + * @param enabled {boolean} + * @ignore + */ + this.setEnabled = function (enabled) { + this.enabled = enabled; + this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled); + return this; + }; + + /** + * This method will be called by CAAT *before* the mouseUp event is fired. + * @param event {CAAT.MouseEvent} + * @ignore + */ + this.actionPerformed = function (event) { + if (this.enabled && null !== this.fnOnClick) { + this.fnOnClick(this); + } + }; + + /** + * Button's mouse enter handler. It makes the button provide visual feedback + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseEnter = function (mouseEvent) { + if (!this.enabled) { + return; + } + + if (this.dragging) { + this.setSpriteIndex(this.iPress); + } else { + this.setSpriteIndex(this.iOver); + } + CAAT.setCursor('pointer'); + }; + + /** + * Button's mouse exit handler. Release visual apperance. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseExit = function (mouseEvent) { + this.setSpriteIndex(this.iNormal); + CAAT.setCursor('default'); + }; + + /** + * Button's mouse down handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDown = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.setSpriteIndex(this.iPress); + }; + + /** + * Button's mouse up handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseUp = function (mouseEvent) { + this.setSpriteIndex(this.iNormal); + this.dragging = false; + }; + + /** + * Button's mouse click handler. Do nothing by default. This event handler will be + * called ONLY if it has not been drag on the button. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseClick = function (mouseEvent) { + }; + + /** + * Button's mouse drag handler. + * @param mouseEvent {CAAT.MouseEvent} + * @ignore + */ + this.mouseDrag = function (mouseEvent) { + if (!this.enabled) { + return; + } + + this.dragging = true; + }; + + this.setButtonImageIndex = function (_normal, _over, _press, _disabled) { + this.iNormal = _normal; + this.iOver = _over || this.iNormal; + this.iPress = _press || this.iNormal; + this.iDisabled = _disabled || this.iNormal; + this.setSpriteIndex(this.iNormal); + return this; + }; + + return this; + }, + + findActorById : function(id) { + return this.id===id ? this : null; + } + } + } + + + +}); diff --git a/CAAT/src/Foundation/ActorContainer.js b/CAAT/src/Foundation/ActorContainer.js new file mode 100644 index 0000000..de223da --- /dev/null +++ b/CAAT/src/Foundation/ActorContainer.js @@ -0,0 +1,714 @@ +CAAT.Module({ + + /** + * @name ActorContainer + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.Actor + * @constructor + */ + + /** + * @name ADDHINT + * @memberOf CAAT.Foundation.ActorContainer + * @namespace + */ + + /** + * @name AddHint + * @memberOf CAAT.Foundation.ActorContainer + * @namespace + * @deprecated + */ + + defines:"CAAT.Foundation.ActorContainer", + aliases:["CAAT.ActorContainer"], + depends:[ + "CAAT.Foundation.Actor", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + constants : { + + /** + * @lends CAAT.Foundation.ActorContainer + * */ + + ADDHINT:{ + + /** + * @lends CAAT.Foundation.ActorContainer.ADDHINT + */ + + /** @const */ CONFORM:1 + }, + + AddHint : { + + /** + * @lends CAAT.Foundation.ActorContainer.AddHint + */ + /** @const */ CONFORM:1 + } + }, + extendsClass : "CAAT.Foundation.Actor", + extendsWith : function () { + + + + var __CD = CAAT.Foundation.Actor.CACHE_DEEP; + + var sc= CAAT.Foundation.ActorContainer.superclass; + var sc_drawScreenBoundingBox= sc.drawScreenBoundingBox; + var sc_paintActor= sc.paintActor; + var sc_paintActorGL= sc.paintActorGL; + var sc_animate= sc.animate; + var sc_findActorAtPosition = sc.findActorAtPosition; + var sc_destroy = sc.destroy; + + return { + + /** + * + * @lends CAAT.Foundation.ActorContainer.prototype + */ + + /** + * Constructor delegate + * @param hint {CAAT.Foundation.ActorContainer.AddHint} + * @return {*} + * @private + */ + __init:function (hint) { + + this.__super(); + + this.childrenList = []; + this.activeChildren = []; + this.pendingChildrenList = []; + if (typeof hint !== 'undefined') { + this.addHint = hint; + this.boundingBox = new CAAT.Math.Rectangle(); + } + return this; + }, + + /** + * This container children. + * @type {Array.} + */ + childrenList:null, + + /** + * This container active children. + * @type {Array.} + * @private + */ + activeChildren:null, + + /** + * This container pending to be added children. + * @type {Array.} + * @private + */ + pendingChildrenList:null, + + /** + * Container redimension policy when adding children: + * 0 : no resize. + * CAAT.Foundation.ActorContainer.AddHint.CONFORM : resize container to a bounding box. + * + * @type {number} + * @private + */ + addHint:0, + + /** + * If container redimension on children add, use this rectangle as bounding box store. + * @type {CAAT.Math.Rectangle} + * @private + */ + boundingBox:null, + + /** + * Spare rectangle to avoid new allocations when adding children to this container. + * @type {CAAT.Math.Rectangle} + * @private + */ + runion:new CAAT.Math.Rectangle(), // Watch out. one for every container. + + /** + * Define a layout manager for this container that enforces children position and/or sizes. + * @see demo26 for an example of layouts. + * @type {CAAT.Foundation.UI.Layout.LayoutManager} + */ + layoutManager:null, // a layout manager instance. + + /** + * @type {boolean} + */ + layoutInvalidated:true, + + setLayout:function (layout) { + this.layoutManager = layout; + return this; + }, + + setBounds:function (x, y, w, h) { + CAAT.Foundation.ActorContainer.superclass.setBounds.call(this, x, y, w, h); + if (CAAT.currentDirector && !CAAT.currentDirector.inValidation) { + this.invalidateLayout(); + } + return this; + }, + + __validateLayout:function () { + + this.__validateTree(); + this.layoutInvalidated = false; + }, + + __validateTree:function () { + if (this.layoutManager && this.layoutManager.isInvalidated()) { + + CAAT.currentDirector.inValidation = true; + + this.layoutManager.doLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).__validateLayout(); + } + } + }, + + invalidateLayout:function () { + this.layoutInvalidated = true; + + if (this.layoutManager) { + this.layoutManager.invalidateLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).invalidateLayout(); + } + } + }, + + getLayout:function () { + return this.layoutManager; + }, + + /** + * Draws this ActorContainer and all of its children screen bounding box. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + drawScreenBoundingBox:function (director, time) { + + if (!this.inFrame) { + return; + } + + var cl = this.activeChildren; + for (var i = 0; i < cl.length; i++) { + cl[i].drawScreenBoundingBox(director, time); + } + sc_drawScreenBoundingBox.call(this, director, time); + }, + /** + * Removes all children from this ActorContainer. + * + * @return this + */ + emptyChildren:function () { + this.childrenList = []; + + return this; + }, + /** + * Private + * Paints this container and every contained children. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + paintActor:function (director, time) { + + if (!this.visible) { + return false; + } + + var ctx = director.ctx; + + ctx.save(); + + if (!sc_paintActor.call(this, director, time)) { + return false; + } + + if (this.cached === __CD) { + return false; + } + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent ? this.parent.frameAlpha : 1; + } + + for (var i = 0, l = this.activeChildren.length; i < l; ++i) { + var actor = this.activeChildren[i]; + + if (actor.visible) { + ctx.save(); + actor.paintActor(director, time); + ctx.restore(); + } + } + + if (this.postPaint) { + this.postPaint( director, time ); + } + + ctx.restore(); + + return true; + }, + __paintActor:function (director, time) { + if (!this.visible) { + return true; + } + + var ctx = director.ctx; + + this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1; + var m = this.worldModelViewMatrix.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha); + this.paint(director, time); + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent ? this.parent.frameAlpha : 1; + } + + for (var i = 0, l = this.activeChildren.length; i < l; ++i) { + var actor = this.activeChildren[i]; + actor.paintActor(director, time); + } + return true; + }, + paintActorGL:function (director, time) { + + var i, l, c; + + if (!this.visible) { + return true; + } + + sc_paintActorGL.call(this, director, time); + + if (!this.isGlobalAlpha) { + this.frameAlpha = this.parent.frameAlpha; + } + + for (i = 0, l = this.activeChildren.length; i < l; ++i) { + c = this.activeChildren[i]; + c.paintActorGL(director, time); + } + + }, + /** + * Private. + * Performs the animate method for this ActorContainer and every contained Actor. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return {boolean} is this actor in active children list ?? + */ + animate:function (director, time) { + + if (!this.visible) { + return false; + } + + this.activeChildren = []; + var last = null; + + if (false === sc_animate.call(this, director, time)) { + return false; + } + + if (this.cached === __CD) { + return true; + } + + this.__validateLayout(); + CAAT.currentDirector.inValidation = false; + + var i, l; + + /** + * Incluir los actores pendientes. + * El momento es ahora, antes de procesar ninguno del contenedor. + */ + var pcl = this.pendingChildrenList; + for (i = 0; i < pcl.length; i++) { + var child = pcl[i]; + this.addChildImmediately(child.child, child.constraint); + } + + this.pendingChildrenList = []; + var markDelete = []; + + var cl = this.childrenList; + this.size_active = 1; + this.size_total = 1; + for (i = 0; i < cl.length; i++) { + var actor = cl[i]; + actor.time = time; + this.size_total += actor.size_total; + if (actor.animate(director, time)) { + this.activeChildren.push(actor); + this.size_active += actor.size_active; + } else { + if (actor.expired && actor.discardable) { + markDelete.push(actor); + } + } + } + + for (i = 0, l = markDelete.length; i < l; i++) { + var md = markDelete[i]; + md.destroy(time); + if (director.dirtyRectsEnabled) { + director.addDirtyRect(md.AABB); + } + } + + return true; + }, + /** + * Removes Actors from this ActorContainer which are expired and flagged as Discardable. + * + * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @deprecated + */ + endAnimate:function (director, time) { + }, + /** + * Adds an Actor to this Container. + * The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at + * the time of method call. + * + * This method is only used by director's transitionScene. + * + * @param child {CAAT.Foundation.Actor} + * @param constraint {object} + * @return this. + */ + addChildImmediately:function (child, constraint) { + return this.addChild(child, constraint); + }, + + addActorImmediately: function(child,constraint) { + return this.addChildImmediately(child,constraint); + }, + + addActor : function( child, constraint ) { + return this.addChild(child,constraint); + }, + + /** + * Adds an Actor to this ActorContainer. + * The Actor will be added to the container AFTER frame animation, and not on method call time. + * Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this + * method directly. + * + * If the container has addingHint as CAAT.Foundation.ActorContainer.AddHint.CONFORM, new continer size will be + * calculated by summing up the union of every client actor bounding box. + * This method will not take into acount actor's affine transformations, so the bounding box will be + * AABB. + * + * @param child {CAAT.Foundation.Actor} object instance. + * @param constraint {object} + * @return this + */ + addChild:function (child, constraint) { + + if (child.parent != null) { + throw('adding to a container an element with parent.'); + } + + child.parent = this; + this.childrenList.push(child); + child.dirty = true; + + if (this.layoutManager) { + this.layoutManager.addChild(child, constraint); + this.invalidateLayout(); + } else { + /** + * if Conforming size, recalc new bountainer size. + */ + if (this.addHint === CAAT.Foundation.ActorContainer.AddHint.CONFORM) { + this.recalcSize(); + } + } + + return this; + }, + + /** + * Recalc this container size by computing the union of every children bounding box. + */ + recalcSize:function () { + var bb = this.boundingBox; + bb.setEmpty(); + var cl = this.childrenList; + var ac; + for (var i = 0; i < cl.length; i++) { + ac = cl[i]; + this.runion.setBounds( + ac.x < 0 ? 0 : ac.x, + ac.y < 0 ? 0 : ac.y, + ac.width, + ac.height); + bb.unionRectangle(this.runion); + } + this.setSize(bb.x1, bb.y1); + + return this; + }, + + /** + * Add a child element and make it active in the next frame. + * @param child {CAAT.Foundation.Actor} + */ + addChildDelayed:function (child, constraint) { + this.pendingChildrenList.push({ child:child, constraint: constraint }); + return this; + }, + /** + * Adds an Actor to this ActorContainer. + * + * @param child {CAAT.Foundation.Actor}. + * @param index {number} + * + * @return this + */ + addChildAt:function (child, index) { + + if (index <= 0) { + child.parent = this; + child.dirty = true; + this.childrenList.splice(0, 0, child); + this.invalidateLayout(); + return this; + } else { + if (index >= this.childrenList.length) { + index = this.childrenList.length; + } + } + + child.parent = this; + child.dirty = true; + this.childrenList.splice(index, 0, child); + this.invalidateLayout(); + + return this; + }, + /** + * Find the first actor with the supplied ID. + * This method is not recommended to be used since executes a linear search. + * @param id + */ + findActorById:function (id) { + + if ( CAAT.Foundation.ActorContainer.superclass.findActorById.call(this,id) ) { + return this; + } + + var cl = this.childrenList; + for (var i = 0, l = cl.length; i < l; i++) { + var ret= cl[i].findActorById(id); + if (null!=ret) { + return ret; + } + } + + return null; + }, + /** + * Private + * Gets a contained Actor z-index on this ActorContainer. + * + * @param child a CAAT.Foundation.Actor object instance. + * + * @return {number} + */ + findChild:function (child) { + var cl = this.childrenList; + var i; + var len = cl.length; + + for (i = 0; i < len; i++) { + if (cl[i] === child) { + return i; + } + } + return -1; + }, + removeChildAt:function (pos) { + var cl = this.childrenList; + var rm; + if (-1 !== pos && pos>=0 && pos= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Math.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + /** + * Destroys this ActorContainer. + * The process falls down recursively for each contained Actor into this ActorContainer. + * + * @return this + */ + destroy:function () { + var cl = this.childrenList; + for (var i = cl.length - 1; i >= 0; i--) { + cl[i].destroy(); + } + sc_destroy.call(this); + + return this; + }, + /** + * Get number of Actors into this container. + * @return integer indicating the number of children. + */ + getNumChildren:function () { + return this.childrenList.length; + }, + getNumActiveChildren:function () { + return this.activeChildren.length; + }, + /** + * Returns the Actor at the iPosition(th) position. + * @param iPosition an integer indicating the position array. + * @return the CAAT.Foundation.Actor object at position. + */ + getChildAt:function (iPosition) { + return this.childrenList[ iPosition ]; + }, + /** + * Changes an actor's ZOrder. + * @param actor the actor to change ZOrder for + * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the + * last ZOrder Actor. + */ + setZOrder:function (actor, index) { + var actorPos = this.findChild(actor); + // the actor is present + if (-1 !== actorPos) { + var cl = this.childrenList; + // trivial reject. + if (index === actorPos) { + return; + } + + if (index >= cl.length) { + cl.splice(actorPos, 1); + cl.push(actor); + } else { + var nActor = cl.splice(actorPos, 1); + if (index < 0) { + index = 0; + } else if (index > cl.length) { + index = cl.length; + } + + cl.splice(index, 0, nActor[0]); + } + + this.invalidateLayout(); + } + } + } + + } +}); diff --git a/CAAT/src/Foundation/ActorContainerCSS.js b/CAAT/src/Foundation/ActorContainerCSS.js new file mode 100644 index 0000000..48fb1d9 --- /dev/null +++ b/CAAT/src/Foundation/ActorContainerCSS.js @@ -0,0 +1,488 @@ +CAAT.Module({ + defines:"CAAT.Foundation.ActorContainer", + aliases:["CAAT.ActorContainer"], + depends:[ + "CAAT.Foundation.Actor", + "CAAT.Math.Rectangle" + ], + constants:{ + AddHint:{ + CONFORM:1 + } + }, + extendsClass:"CAAT.Foundation.Actor", + extendsWith:function () { + + return { + __init:function () { + this.__super(); + this.childrenList = []; + this.pendingChildrenList = []; + if (typeof hint !== 'undefined') { + this.addHint = hint; + this.boundingBox = new CAAT.Math.Rectangle(); + } + return this; + }, + + childrenList:null, // the list of children contained. + activeChildren:null, + pendingChildrenList:null, + + addHint:0, + boundingBox:null, + runion:new CAAT.Rectangle(), // Watch out. one for every container. + + layoutManager:null, // a layout manager instance. + layoutInvalidated:true, + + + setLayout:function (layout) { + this.layoutManager = layout; + return this; + }, + + setBounds:function (x, y, w, h) { + CAAT.ActorContainer.superclass.setBounds.call(this, x, y, w, h); + if (CAAT.currentDirector && !CAAT.currentDirector.inValidation) { + this.invalidateLayout(); + } + return this; + }, + + __validateLayout:function () { + + this.__validateTree(); + this.layoutInvalidated = false; + }, + + __validateTree:function () { + if (this.layoutManager && this.layoutManager.isInvalidated()) { + + CAAT.currentDirector.inValidation = true; + + this.layoutManager.doLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).__validateLayout(); + } + } + }, + + invalidateLayout:function () { + this.layoutInvalidated = true; + + if (this.layoutManager) { + this.layoutManager.invalidateLayout(this); + + for (var i = 0; i < this.getNumChildren(); i += 1) { + this.getChildAt(i).invalidateLayout(); + } + } + }, + + getLayout:function () { + return this.layoutManager; + }, + + + /** + * Removes all children from this ActorContainer. + * + * @return this + */ + emptyChildren:function () { + this.domElement.innerHTML = ''; + this.childrenList = []; + + return this; + }, + /** + * Private + * Paints this container and every contained children. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + */ + paintActor:function (director, time) { + CAAT.ActorContainer.superclass.paintActor.call(this, director, time); + + for (var actor = this.activeChildren; actor; actor = actor.__next) { + if (actor.visible) { + actor.paintActor(director, time); + } + } + + return true; + }, + /** + * Private. + * Performs the animate method for this ActorContainer and every contained Actor. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @return {boolean} is this actor in active children list ?? + */ + animate:function (director, time) { + + this.activeChildren = null; + var last = null; + + if (false === CAAT.ActorContainer.superclass.animate.call(this, director, time)) { + return false; + } + + this.__validateLayout(); + CAAT.currentDirector.inValidation = false; + + var i, l; + var notActive = []; + + this.size_active = 0; + this.size_total = 0; + + /** + * Incluir los actores pendientes. + * El momento es ahora, antes de procesar ninguno del contenedor. + */ + for (i = 0; i < this.pendingChildrenList.length; i++) { + var child = this.pendingChildrenList[i]; + this.addChild(child); + } + this.pendingChildrenList = []; + + + var cl = this.childrenList; + for (i = 0; i < cl.length; i++) { + var actor = cl[i]; + actor.time = time; + this.size_total += actor.size_total; + if (actor.animate(director, time)) { + if (!this.activeChildren) { + this.activeChildren = actor; + actor.__next = null; + last = actor; + } else { + actor.__next = null; + last.__next = actor; + last = actor; + } + + this.size_active += actor.size_active; + + } else { + if (actor.expired && actor.discardable) { + this.domElement.removeChild(actor.domElement); + actor.destroy(time); + cl.splice(i, 1); + } + } + } + + return true; + }, + /** + * Removes Actors from this ActorContainer which are expired and flagged as Discardable. + * + * @param director the CAAT.Director object instance that contains the Scene the Actor is in. + * @param time an integer indicating the Scene time when the bounding box is to be drawn. + * + * @deprecated + */ + endAnimate:function (director, time) { + }, + + addActorImmediately: function(child,constraint) { + return this.addChildImmediately(child,constraint); + }, + + addActor : function( child, constraint ) { + return this.addChild(child,constraint); + }, + + /** + * Adds an Actor to this Container. + * The Actor will be added ON METHOD CALL, despite the rendering pipeline stage being executed at + * the time of method call. + * + * This method is only used by CAAT.Director's transitionScene. + * + * @param child a CAAT.Actor instance. + * @return this. + */ + addChildImmediately:function (child, constraint) { + return this.addChild(child, constraint); + }, + /** + * Adds an Actor to this ActorContainer. + * The Actor will be added to the container AFTER frame animation, and not on method call time. + * Except the Director and in orther to avoid visual artifacts, the developer SHOULD NOT call this + * method directly. + * + * @param child a CAAT.Actor object instance. + * @return this + */ + addChild:function (child, constraint) { + child.setParent(this); + this.childrenList.push(child); + child.dirty = true; + + if (this.layoutManager) { + this.layoutManager.addChild(child, constraint); + this.invalidateLayout(); + } else { + /** + * if Conforming size, recalc new bountainer size. + */ + if (this.addHint === CAAT.ActorContainer.AddHint.CONFORM) { + this.recalcSize(); + } + } + + return this; + }, + + /** + * Recalc this container size by computin the union of every children bounding box. + */ + recalcSize:function () { + var bb = this.boundingBox; + bb.setEmpty(); + var cl = this.childrenList; + var ac; + for (var i = 0; i < cl.length; i++) { + ac = cl[i]; + this.runion.setBounds( + ac.x < 0 ? 0 : ac.x, + ac.y < 0 ? 0 : ac.y, + ac.width, + ac.height); + bb.unionRectangle(this.runion); + } + this.setSize(bb.x1, bb.y1); + + return this; + }, + + /** + * Add a child element and make it active in the next frame. + * @param child {CAAT.Actor} + */ + addChildDelayed:function (child) { + this.pendingChildrenList.push(child); + return this; + }, + /** + * Adds an Actor to this ActorContainer. + * + * @param child a CAAT.Actor object instance. + * + * @return this + */ + addChildAt:function (child, index) { + + if (index <= 0) { + //this.childrenList.unshift(child); // unshift unsupported on IE + child.parent = this; + child.dirty = true; + this.childrenList.splice(0, 0, child); + this.invalidateLayout(); + return this; + } else { + if (index >= this.childrenList.length) { + index = this.childrenList.length; + } + } + + child.setParent(this); + this.childrenList.splice(index, 0, child); + + this.domElement.insertBefore(child.domElement, this.domElement.childNodes[index]); + this.invalidateLayout(); + + child.dirty = true; + + return this; + }, + /** + * Find the first actor with the supplied ID. + * This method is not recommended to be used since executes a linear search. + * @param id + */ + findActorById:function (id) { + var cl = this.childrenList; + for (var i = 0, l = cl.length; i < l; i++) { + var ret= cl[i].findActorById(id); + if (null!=ret) { + return ret; + } + } + + return null; + }, + + /** + * Private + * Gets a contained Actor z-index on this ActorContainer. + * + * @param child a CAAT.Actor object instance. + * + * @return an integer indicating the Actor's z-order. + */ + findChild:function (child) { + var i = 0, + len = this.childrenList.length; + for (i = 0; i < len; i++) { + if (this.childrenList[i] === child) { + return i; + } + } + return -1; + }, + + removeChildAt:function (pos) { + var cl = this.childrenList; + var rm; + if (-1 !== pos) { + cl[pos].setParent(null); + rm = cl.splice(pos, 1); + this.invalidateLayout(); + return rm[0]; + } + + return null; + }, + /** + * Removed an Actor form this ActorContainer. + * If the Actor is not contained into this Container, nothing happends. + * + * @param child a CAAT.Actor object instance. + * + * @return this + */ + removeChild:function (child) { + var pos = this.findChild(child); + var ret = this.removeChildAt(pos); + + return ret; + }, + removeFirstChild:function () { + var first = this.childrenList.shift(); + first.setParent(null); + this.invalidateLayout(); + + return first; + }, + removeLastChild:function () { + if (this.childrenList.length) { + var last = this.childrenList.pop(); + last.setParent(null); + this.invalidateLayout(); + return last; + } + + return null; + }, + + /** + * @private + * + * Gets the Actor inside this ActorContainer at a given Screen coordinate. + * + * @param point an object of the form { x: float, y: float } + * + * @return the Actor contained inside this ActorContainer if found, or the ActorContainer itself. + */ + findActorAtPosition:function (point) { + + if (null === CAAT.ActorContainer.superclass.findActorAtPosition.call(this, point)) { + return null; + } + + // z-order + for (var i = this.childrenList.length - 1; i >= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + /** + * Destroys this ActorContainer. + * The process falls down recursively for each contained Actor into this ActorContainer. + * + * @return this + */ + destroy:function () { + for (var i = this.childrenList.length - 1; i >= 0; i--) { + this.childrenList[i].destroy(); + } + CAAT.ActorContainer.superclass.destroy.call(this); + + return this; + }, + /** + * Get number of Actors into this container. + * @return integer indicating the number of children. + */ + getNumChildren:function () { + return this.childrenList.length; + }, + getNumActiveChildren:function () { + return this.activeChildren.length; + }, + /** + * Returns the Actor at the iPosition(th) position. + * @param iPosition an integer indicating the position array. + * @return the CAAT.Actor object at position. + */ + getChildAt:function (iPosition) { + return this.childrenList[ iPosition ]; + }, + /** + * Changes an actor's ZOrder. + * @param actor the actor to change ZOrder for + * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the + * last ZOrder Actor. + */ + setZOrder:function (actor, index) { + var actorPos = this.findChild(actor); + // the actor is present + if (-1 !== actorPos) { + var cl = this.childrenList; + // trivial reject. + if (index === actorPos) { + return; + } + + if (index >= cl.length) { + cl.splice(actorPos, 1); + cl.push(actor); + } else { + var nActor = cl.splice(actorPos, 1); + if (index < 0) { + index = 0; + } else if (index > cl.length) { + index = cl.length; + } + + //this.childrenList.splice( index, 1, nActor ); + cl.splice(index, 0, nActor[0]); + } + + for (var i = 0, l = cl.length; i < l; i++) { + cl[i].domElement.style.zIndex = i; + } + + this.invalidateLayout(); + } + } + } + } +}); diff --git a/CAAT/src/Foundation/Box2D/B2DBodyActor.js b/CAAT/src/Foundation/Box2D/B2DBodyActor.js new file mode 100644 index 0000000..f941fe1 --- /dev/null +++ b/CAAT/src/Foundation/Box2D/B2DBodyActor.js @@ -0,0 +1,297 @@ +CAAT.Module({ + + /** + * @name Box2D + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name B2DBodyActor + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines:"CAAT.Foundation.Box2D.B2DBodyActor", + depends:[ + "CAAT.Foundation.Actor" + ], + aliases : ["CAAT.B2DBodyActor"], + extendsClass:"CAAT.Foundation.Actor", + extendsWith:function () { + + /** + * @lends CAAT + */ + + /** + * Points to Meter ratio value. + * @type {Number} + */ + CAAT.PMR = 64; + + /** + * (As Eemeli Kelokorpi suggested) + * + * Enable Box2D debug renderer. + * + * @param set {boolean} enable or disable + * @param director {CAAT.Foundation.Director} + * @param world {object} box2d world + * @param scale {numner} a scale value. + */ + CAAT.enableBox2DDebug = function (set, director, world, scale) { + + if (set) { + var debugDraw = new Box2D.Dynamics.b2DebugDraw(); + try { + debugDraw.m_sprite.graphics.clear = function () { + }; + } catch (e) { + } + + world.SetDebugDraw(debugDraw); + + debugDraw.SetSprite(director.ctx); + debugDraw.SetDrawScale(scale || CAAT.PMR); + debugDraw.SetFillAlpha(.5); + debugDraw.SetLineThickness(1.0); + debugDraw.SetFlags(0x0001 | 0x0002); + + } else { + world.SetDebugDraw(null); + } + }; + + return { + + /** + * @lends CAAT.Foundation.Box2D.B2DBodyActor.prototype + */ + + /** + * Body restitution. + */ + restitution:.5, + + /** + * Body friction. + */ + friction:.5, + + /** + * Body dentisy + */ + density:1, + + /** + * Dynamic bodies by default + */ + bodyType:Box2D.Dynamics.b2Body.b2_dynamicBody, + + /** + * Box2D body + */ + worldBody:null, + + /** + * Box2D world reference. + */ + world:null, + + /** + * Box2d fixture + */ + worldBodyFixture:null, + + /** + * Box2D body definition. + */ + bodyDef:null, + + /** + * Box2D fixture definition. + */ + fixtureDef:null, + + /** + * BodyData object linked to the box2D body. + */ + bodyData:null, + + /** + * Recycle this actor when the body is not needed anymore ?? + */ + recycle:false, + + __init : function() { + this.__super(); + this.setPositionAnchor(.5,.5); + + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + setPositionAnchored : function(x,y,ax,ay) { + this.x= x; + this.y= y; + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + /** + * set this actor to recycle its body, that is, do not destroy it. + */ + setRecycle:function () { + this.recycle = true; + return this; + }, + destroy:function () { + + CAAT.Foundation.Box2D.B2DBodyActor.superclass.destroy.call(this); + if (this.recycle) { + this.setLocation(-Number.MAX_VALUE, -Number.MAX_VALUE); + this.setAwake(false); + } else { + var body = this.worldBody; + body.DestroyFixture(this.worldBodyFixture); + this.world.DestroyBody(body); + } + + return this; + }, + setAwake:function (bool) { + this.worldBody.SetAwake(bool); + return this; + }, + setSleepingAllowed:function (bool) { + this.worldBody.SetSleepingAllowed(bool); + return this; + }, + setLocation:function (x, y) { + this.worldBody.SetPosition( + new Box2D.Common.Math.b2Vec2( + x / CAAT.PMR, + y / CAAT.PMR)); + return this; + }, + /** + * Set this body's + * density. + * @param d {number} + */ + setDensity:function (d) { + this.density = d; + return this; + }, + + /** + * Set this body's friction. + * @param f {number} + */ + setFriction:function (f) { + this.friction = f; + return this; + }, + + /** + * Set this body's restitution coeficient. + * @param r {number} + */ + setRestitution:function (r) { + this.restitution = r; + return this; + }, + + /** + * Set this body's type: + * @param bodyType {Box2D.Dynamics.b2Body.b2_*} + */ + setBodyType:function (bodyType) { + this.bodyType = bodyType; + return this; + }, + + /** + * Helper method to check whether this js object contains a given property and if it doesn't exist + * create and set it to def value. + * @param obj {object} + * @param prop {string} + * @param def {object} + */ + check:function (obj, prop, def) { + if (!obj[prop]) { + obj[prop] = def; + } + }, + + /** + * Create an actor as a box2D body binding, create it on the given world and with + * the initialization data set in bodyData object. + * @param world {Box2D.Dynamics.b2World} a Box2D world instance + * @param bodyData {object} An object with body info. + */ + createBody:function (world, bodyData) { + + if (bodyData) { + this.check(bodyData, 'density', 1); + this.check(bodyData, 'friction', .5); + this.check(bodyData, 'restitution', .2); + this.check(bodyData, 'bodyType', Box2D.Dynamics.b2Body.b2_staticBody); + this.check(bodyData, 'userData', {}); + this.check(bodyData, 'image', null); + + this.density = bodyData.density; + this.friction = bodyData.friction; + this.restitution = bodyData.restitution; + this.bodyType = bodyData.bodyType; + this.image = bodyData.image; + + } + + this.world = world; + + return this; + }, + + /** + * Get this body's center on screen regardless of its shape. + * This method will return box2d body's centroid. + */ + getCenter:function () { + return this.worldBody.GetPosition(); + }, + + /** + * Get a distance joint's position on pixels. + */ + getDistanceJointLocalAnchor:function () { + return new Box2D.Common.Math.b2Vec2(0,0); + }, + + /** + * Method override to get position and rotation angle from box2d body. + * @param director {CAAT.Director} + * @param time {number} + */ + animate: function(director, time) { + + var pos= this.worldBody.GetPosition(); + + CAAT.Foundation.Actor.prototype.setLocation.call( + this, + CAAT.PMR*pos.x, + CAAT.PMR*pos.y); + + this.setRotation( this.worldBody.GetAngle() ); + + return CAAT.Foundation.Box2D.B2DBodyActor.superclass.animate.call(this,director,time); + } + } + } +}); diff --git a/CAAT/src/Foundation/Box2D/B2DCircularBody.js b/CAAT/src/Foundation/Box2D/B2DCircularBody.js new file mode 100644 index 0000000..9dd7884 --- /dev/null +++ b/CAAT/src/Foundation/Box2D/B2DCircularBody.js @@ -0,0 +1,98 @@ +CAAT.Module( { + + /** + * @name B2DCircularBody + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Box2D.B2DBodyActor + * @constructor + */ + + defines : "CAAT.Foundation.Box2D.B2DCircularBody", + depends : [ + "CAAT.Foundation.Box2D.B2DBodyActor" + ], + aliases : ["CAAT.B2DCircularBody"], + extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor", + constants : { + + /** + * @lends CAAT.Foundation.Box2D.B2DCircularBody + */ + + createCircularBody : function(world, bodyData) { + if ( bodyData.radius ) this.radius= bodyData.radius; + + var fixDef= new Box2D.Dynamics.b2FixtureDef(); + fixDef.density= bodyData.density; + fixDef.friction= bodyData.friction; + fixDef.restitution= bodyData.restitution; + fixDef.shape = new Box2D.Collision.Shapes.b2CircleShape(bodyData.radius/CAAT.PMR); + + var bodyDef = new Box2D.Dynamics.b2BodyDef(); + bodyDef.type = bodyData.bodyType; + bodyDef.position.Set( bodyData.x/CAAT.PMR, bodyData.y/CAAT.PMR ); + + // link entre cuerpo fisico box2d y caat. + fixDef.userData= bodyData.userData; + bodyDef.userData= bodyData.userData; + + var worldBody= world.CreateBody(bodyDef); + var worldBodyFixture= worldBody.CreateFixture(fixDef); + + if ( bodyData.isSensor ) { + worldBodyFixture.SetSensor(true); + } + + return { + worldBody: worldBody, + worldBodyFixture: worldBodyFixture, + fixDef: fixDef, + bodyDef: bodyDef + }; + } + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.Box2D.B2DCircularBody.prototype + */ + + + /** + * Default radius. + */ + radius: 1, + + /** + * Create a box2d body and link it to this CAAT.Actor instance. + * @param world {Box2D.Dynamics.b2World} a Box2D world instance + * @param bodyData {object} + */ + createBody : function(world, bodyData) { + + var scale= (bodyData.radius || 1); + scale= scale+ (bodyData.bodyDefScaleTolerance || 0)*Math.random(); + bodyData.radius= scale; + + CAAT.Foundation.Box2D.B2DCircularBody.superclass.createBody.call(this,world,bodyData); + var box2D_data= CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(world,bodyData); + + bodyData.userData.actor= this; + + this.worldBody= box2D_data.worldBody; + this.worldBodyFixture= box2D_data.worldBodyFixture; + this.fixtureDef= box2D_data.fixDef; + this.bodyDef= box2D_data.bodyDef; + this.bodyData= bodyData; + + this.setFillStyle(this.worldBodyFixture.IsSensor() ? 'red' : 'green'). + setBackgroundImage(this.image). + setSize(2*bodyData.radius,2*bodyData.radius). + setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE); + + + return this; + } + } + +}); diff --git a/CAAT/src/Foundation/Box2D/B2DPolygonBody.js b/CAAT/src/Foundation/Box2D/B2DPolygonBody.js new file mode 100644 index 0000000..1956af9 --- /dev/null +++ b/CAAT/src/Foundation/Box2D/B2DPolygonBody.js @@ -0,0 +1,178 @@ +CAAT.Module( { + + /** + * @name B2DPolygonBody + * @memberOf CAAT.Foundation.Box2D + * @extends CAAT.Foundation.Box2D.B2DBodyActor + * @constructor + */ + + defines : "CAAT.Foundation.Box2D.B2DPolygonBody", + depends : [ + "CAAT.Foundation.Box2D.B2DBodyActor", + "CAAT.Foundation.SpriteImage" + ], + aliases : ["CAAT.B2DPolygonBody"], + constants: { + + /** + * @lends CAAT.Foundation.Box2D.B2DPolygonBody + */ + + TYPE: { + EDGE: 'edge', + BOX: 'box', + POLYGON:'polygon' + }, + + /** + * Helper function to aid in box2d polygon shaped bodies. + * @param world + * @param bodyData + */ + createPolygonBody : function(world, bodyData) { + var fixDef = new Box2D.Dynamics.b2FixtureDef(); + fixDef.density = bodyData.density; + fixDef.friction = bodyData.friction; + fixDef.restitution = bodyData.restitution; + fixDef.shape = new Box2D.Collision.Shapes.b2PolygonShape(); + + var minx = Number.MAX_VALUE; + var maxx = -Number.MAX_VALUE; + var miny = Number.MAX_VALUE; + var maxy = -Number.MAX_VALUE; + + var vec = []; + + var scale = (bodyData.bodyDefScale || 1); + scale = scale + (bodyData.bodyDefScaleTolerance || 0) * Math.random(); + + for (var i = 0; i < bodyData.bodyDef.length; i++) { + var x = bodyData.bodyDef[i].x * scale; + var y = bodyData.bodyDef[i].y * scale; + if (x < minx) { + minx = x; + } + if (x > maxx) { + maxx = x; + } + if (y < miny) { + miny = y; + } + if (y > maxy) { + maxy = y; + } +/* + x += bodyData.x || 0; + y += bodyData.y || 0; + */ + vec.push(new Box2D.Common.Math.b2Vec2(x / CAAT.PMR, y / CAAT.PMR)); + } + + var boundingBox = [ + {x:minx, y:miny}, + {x:maxx, y:maxy} + ]; + + var bodyDef = new Box2D.Dynamics.b2BodyDef(); + bodyDef.type = bodyData.bodyType; + bodyDef.position.Set( + ((maxx - minx) / 2 + (bodyData.x || 0)) / CAAT.PMR, + ((maxy - miny) / 2 + (bodyData.y || 0)) / CAAT.PMR ); + + if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) { + + var v0= new Box2D.Common.Math.b2Vec2(vec[0].x, vec[0].y ); + var v1= new Box2D.Common.Math.b2Vec2(vec[1].x-vec[0].x, vec[1].y-vec[0].y ); + + bodyDef.position.Set(v0.x, v0.y); + fixDef.shape.SetAsEdge(new Box2D.Common.Math.b2Vec2(0,0), v1); + + + } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.BOX) { + + fixDef.shape.SetAsBox( + (maxx - minx) / 2 / CAAT.PMR, + (maxy - miny) / 2 / CAAT.PMR); + + } else if (bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.POLYGON ) { + + fixDef.shape.SetAsArray(vec, vec.length); + + } else { + throw 'Unkown bodyData polygonType: '+bodyData.polygonType; + } + + // link entre cuerpo fisico box2d y caat. + fixDef.userData = bodyData.userData; + bodyDef.userData = bodyData.userData; + + var worldBody = world.CreateBody(bodyDef); + var worldBodyFixture = worldBody.CreateFixture(fixDef); + + + if (bodyData.isSensor) { + worldBodyFixture.SetSensor(true); + } + + return { + worldBody: worldBody, + worldBodyFixture: worldBodyFixture, + fixDef: fixDef, + bodyDef: bodyDef, + boundingBox: boundingBox + }; + } + }, + extendsClass : "CAAT.Foundation.Box2D.B2DBodyActor", + extendsWith : { + + /** + * @lends CAAT.Foundation.Box2D.B2DPolygonBody.prototype + */ + + /** + * Measured body's bounding box. + */ + boundingBox: null, + + /** + * Get on-screen distance joint coordinate. + */ + getDistanceJointLocalAnchor : function() { + var b= this.worldBody; + var poly= b.GetFixtureList().GetShape().GetLocalCenter(); + return poly; + }, + + /** + * Create a box2d body and link it to this CAAT.Actor. + * @param world {Box2D.Dynamics.b2World} + * @param bodyData {object} + */ + createBody : function(world, bodyData) { + CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,world,bodyData); + + var box2D_data= CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(world,bodyData); + + bodyData.userData.actor = this; + + this.worldBody= box2D_data.worldBody; + this.worldBodyFixture= box2D_data.worldBodyFixture; + this.fixtureDef= box2D_data.fixDef; + this.bodyDef= box2D_data.bodyDef; + this.bodyData= bodyData; + this.boundingBox= box2D_data.boundingBox; + + this.setBackgroundImage( bodyData.image ). + setSize( + box2D_data.boundingBox[1].x-box2D_data.boundingBox[0].x+1, + box2D_data.boundingBox[1].y-box2D_data.boundingBox[0].y+1 ). + setFillStyle( box2D_data.worldBodyFixture.IsSensor() ? '#0f0' : '#f00'). + setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE); + + return this; + } + } + +}); diff --git a/CAAT/src/Foundation/Director.js b/CAAT/src/Foundation/Director.js new file mode 100644 index 0000000..242b72d --- /dev/null +++ b/CAAT/src/Foundation/Director.js @@ -0,0 +1,3052 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Director + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.ActorContainer + * + * @constructor + */ + + defines:"CAAT.Foundation.Director", + aliases:["CAAT.Director"], + extendsClass:"CAAT.Foundation.ActorContainer", + depends:[ + "CAAT.Core.Class", + "CAAT.Core.Constants", + + "CAAT.Foundation.ActorContainer", + "CAAT.Module.Audio.AudioManager", + "CAAT.Module.Runtime.BrowserInfo", + "CAAT.Module.Debug.Debug", + "CAAT.Math.Point", + "CAAT.Math.Rectangle", + "CAAT.Math.Matrix", + "CAAT.Foundation.Timer.TimerManager", + "CAAT.Foundation.Actor", + "CAAT.Foundation.Scene", + "CAAT.Event.AnimationLoop", + "CAAT.Event.Input", + "CAAT.Event.KeyEvent", + "CAAT.Event.MouseEvent", + "CAAT.Event.TouchEvent", + + "CAAT.WebGL.Program", + "CAAT.WebGL.ColorProgram", + "CAAT.WebGL.TextureProgram", + "CAAT.WebGL.GLU", + + "CAAT.Module.TexturePacker.TexturePageManager" + ], + constants:{ + /** + * @lends CAAT.Foundation.Director + */ + + /** @const @type {number} */ RENDER_MODE_CONTINUOUS:1, // redraw every frame + /** @const @type {number} */ RENDER_MODE_DIRTY:2, // suitable for evented CAAT. + + /** @const @type {number} */ CLEAR_DIRTY_RECTS:1, + /** @const @type {number} */ CLEAR_ALL:true, + /** @const @type {number} */ CLEAR_NONE:false, + + /** @const @type {number} */ RESIZE_NONE:1, + /** @const @type {number} */ RESIZE_WIDTH:2, + /** @const @type {number} */ RESIZE_HEIGHT:4, + /** @const @type {number} */ RESIZE_BOTH:8, + /** @const @type {number} */ RESIZE_PROPORTIONAL:16 + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Foundation.Director.prototype + */ + + __init:function () { + this.__super(); + + this.browserInfo = CAAT.Module.Runtime.BrowserInfo; + this.audioManager = new CAAT.Module.Audio.AudioManager().initialize(8); + this.scenes = []; + this.imagesCache= []; + + // input related variables initialization + this.mousePoint = new CAAT.Math.Point(0, 0, 0); + this.prevMousePoint = new CAAT.Math.Point(0, 0, 0); + this.screenMousePoint = new CAAT.Math.Point(0, 0, 0); + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + + this.cDirtyRects = []; + this.sDirtyRects = []; + this.dirtyRects = []; + for (var i = 0; i < 64; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + this.dirtyRectsIndex = 0; + this.touches = {}; + + this.timerManager = new CAAT.Foundation.Timer.TimerManager(); + this.__map= {}; + + return this; + }, + + /** + * flag indicating debug mode. It will draw affedted screen areas. + * @type {boolean} + */ + debug:false, + + /** + * Set CAAT render mode. Right now, this takes no effect. + */ + renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS, + + /** + * This method will be called before rendering any director scene. + * Use this method to calculate your physics for example. + * @private + */ + onRenderStart:null, + + /** + * This method will be called after rendering any director scene. + * Use this method to clean your physics forces for example. + * @private + */ + onRenderEnd:null, + + // input related attributes + /** + * mouse coordinate related to canvas 0,0 coord. + * @private + */ + mousePoint:null, + + /** + * previous mouse position cache. Needed for drag events. + * @private + */ + prevMousePoint:null, + + /** + * screen mouse coordinates. + * @private + */ + screenMousePoint:null, + + /** + * is the left mouse button pressed ?. + * Needed to handle dragging. + */ + isMouseDown:false, + + /** + * director's last actor receiving input. + * Needed to set capture for dragging events. + */ + lastSelectedActor:null, + + /** + * is input in drag mode ? + */ + dragging:false, + + // other attributes + + /** + * This director scene collection. + * @type {Array.} + */ + scenes:null, + + /** + * The current Scene. This and only this will receive events. + */ + currentScene:null, + + /** + * The canvas the Director draws on. + * @private + */ + canvas:null, + + /** + * This director´s canvas rendering context. + */ + ctx:null, + + /** + * director time. + * @private + */ + time:0, + + /** + * global director timeline. + * @private + */ + timeline:0, + + /** + * An array of JSON elements of the form { id:string, image:Image } + */ + imagesCache:null, + + /** + * this director´s audio manager. + * @private + */ + audioManager:null, + + /** + * Clear screen strategy: + * CAAT.Foundation.Director.CLEAR_NONE : director won´t clear the background. + * CAAT.Foundation.Director.CLEAR_DIRTY_RECTS : clear only affected actors screen area. + * CAAT.Foundation.Director.CLEAR_ALL : clear the whole canvas object. + */ + clear: CAAT.Foundation.Director.CLEAR_ALL, + + /** + * if CAAT.CACHE_SCENE_ON_CHANGE is set, this scene will hold a cached copy of the exiting scene. + * @private + */ + transitionScene:null, + + /** + * Some browser related information. + */ + browserInfo:null, + + /** + * 3d context + * @private + */ + gl:null, + + /** + * is WebGL enabled as renderer ? + * @private + */ + glEnabled:false, + + /** + * if webGL is on, CAAT will texture pack all images transparently. + * @private + */ + glTextureManager:null, + + /** + * The only GLSL program for webGL + * @private + */ + glTtextureProgram:null, + glColorProgram:null, + + /** + * webGL projection matrix + * @private + */ + pMatrix:null, // projection matrix + + /** + * webGL vertex array + * @private + */ + coords:null, // Float32Array + + /** + * webGL vertex indices. + * @private + */ + coordsIndex:0, + + /** + * webGL uv texture indices + * @private + */ + uv:null, + uvIndex:0, + + /** + * draw tris front_to_back or back_to_front ? + * @private + */ + front_to_back:false, + + /** + * statistics object + */ + statistics:{ + size_total:0, + size_active:0, + size_dirtyRects:0, + draws:0, + size_discarded_by_dirty_rects:0 + }, + + /** + * webGL current texture page. This minimizes webGL context changes. + * @private + */ + currentTexturePage:0, + + /** + * webGL current shader opacity. + * BUGBUG: change this by vertex colors. + * @private + */ + currentOpacity:1, + + /** + * if CAAT.NO_RAF is set (no request animation frame), this value is the setInterval returned + * id. + * @private + */ + intervalId:null, + + /** + * Rendered frames counter. + */ + frameCounter:0, + + /** + * Window resize strategy. + * see CAAT.Foundation.Director.RESIZE_* constants. + * @private + */ + resize:1, + + /** + * Callback when the window is resized. + */ + onResizeCallback:null, + + /** + * Calculated gesture event scale. + * @private + */ + __gestureScale:0, + + /** + * Calculated gesture event rotation. + * @private + */ + __gestureRotation:0, + + /** + * Dirty rects cache. + * An array of CAAT.Math.Rectangle object. + * @private + */ + dirtyRects:null, // dirty rects cache. + + /** + * current dirty rects. + * @private + */ + cDirtyRects:null, // dirty rects cache. + + /** + * Currently used dirty rects. + * @private + */ + sDirtyRects:null, // scheduled dirty rects. + + /** + * Number of currently allocated dirty rects. + * @private + */ + dirtyRectsIndex:0, + + /** + * Dirty rects enabled ?? + * @private + */ + dirtyRectsEnabled:false, + + /** + * Number of dirty rects. + * @private + */ + nDirtyRects:0, + + /** + * Dirty rects count debug info. + * @private + */ + drDiscarded:0, // discarded by dirty rects. + + /** + * Is this director stopped ? + */ + stopped:false, // is stopped, this director will do nothing. + + /** + * currently unused. + * Intended to run caat in evented mode. + * @private + */ + needsRepaint:false, + + /** + * Touches information. Associate touch.id with an actor and original touch info. + * @private + */ + touches:null, + + /** + * Director´s timer manager. + * Each scene has a timerManager as well. + * The difference is the scope. Director´s timers will always be checked whereas scene´ timers + * will only be scheduled/checked when the scene is director´ current scene. + * @private + */ + timerManager:null, + + /** + * Retina display deicePixels/backingStorePixels ratio + * @private + */ + SCREEN_RATIO : 1, + + __map : null, + + clean:function () { + this.scenes = null; + this.currentScene = null; + this.imagesCache = null; + this.audioManager = null; + this.isMouseDown = false; + this.lastSelectedActor = null; + this.dragging = false; + this.__gestureScale = 0; + this.__gestureRotation = 0; + this.dirty = true; + this.dirtyRects = null; + this.cDirtyRects = null; + this.dirtyRectsIndex = 0; + this.dirtyRectsEnabled = false; + this.nDirtyRects = 0; + this.onResizeCallback = null; + this.__map= {}; + return this; + }, + + cancelPlay : function(id) { + return this.audioManager.cancelPlay(id); + }, + + cancelPlayByChannel : function(audioObject) { + return this.audioManager.cancelPlayByChannel(audioObject); + }, + + setAudioFormatExtensions : function( extensions ) { + this.audioManager.setAudioFormatExtensions(extensions); + return this; + }, + + setValueForKey : function( key, value ) { + this.__map[key]= value; + return this; + }, + + getValueForKey : function( key ) { + return this.__map[key]; + }, + + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + requestRepaint:function () { + this.needsRepaint = true; + }, + + getCurrentScene:function () { + return this.currentScene; + }, + + checkDebug:function () { + if (!navigator.isCocoonJS && CAAT.DEBUG) { + var dd = new CAAT.Module.Debug.Debug().initialize(this.width, 60); + this.debugInfo = dd.debugInfo.bind(dd); + } + }, + getRenderType:function () { + return this.glEnabled ? 'WEBGL' : 'CANVAS'; + }, + windowResized:function (w, h) { + var c = CAAT.Foundation.Director; + switch (this.resize) { + case c.RESIZE_WIDTH: + this.setBounds(0, 0, w, this.height); + break; + case c.RESIZE_HEIGHT: + this.setBounds(0, 0, this.width, h); + break; + case c.RESIZE_BOTH: + this.setBounds(0, 0, w, h); + break; + case c.RESIZE_PROPORTIONAL: + this.setScaleProportional(w, h); + break; + } + + if (this.glEnabled) { + this.glReset(); + } + + if (this.onResizeCallback) { + this.onResizeCallback(this, w, h); + } + + }, + setScaleProportional:function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + + this.canvas.width = this.referenceWidth * factor; + this.canvas.height = this.referenceHeight * factor; + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + this.setScaleAnchored(factor * this.scaleX, factor * this.scaleY, 0, 0); +// this.setScaleAnchored(factor, factor, 0, 0); + + if (this.glEnabled) { + this.glReset(); + } + }, + /** + * Enable window resize events and set redimension policy. A callback functio could be supplied + * to be notified on a Director redimension event. This is necessary in the case you set a redim + * policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their + * children scenes are resized to fit the new area. But scenes content is not resized, and have + * no option of knowing so uless an onResizeCallback function is supplied. + * + * @param mode {number} RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE. + * @param onResizeCallback {function(director{CAAT.Director}, width{integer}, height{integer})} a callback + * to notify on canvas resize. + */ + enableResizeEvents:function (mode, onResizeCallback) { + var dd= CAAT.Foundation.Director; + if (mode === dd.RESIZE_BOTH || mode === dd.RESIZE_WIDTH || mode === dd.RESIZE_HEIGHT || mode === dd.RESIZE_PROPORTIONAL) { + this.referenceWidth = this.width; + this.referenceHeight = this.height; + this.resize = mode; + CAAT.registerResizeListener(this); + this.onResizeCallback = onResizeCallback; + this.windowResized(window.innerWidth, window.innerHeight); + } else { + CAAT.unregisterResizeListener(this); + this.onResizeCallback = null; + } + + return this; + }, + + __setupRetina : function() { + + if ( CAAT.RETINA_DISPLAY_ENABLED ) { + + // The world is full of opensource awesomeness. + // + // Source: http://www.html5rocks.com/en/tutorials/canvas/hidpi/ + // + var devicePixelRatio= CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio; + var backingStoreRatio = this.ctx.webkitBackingStorePixelRatio || + this.ctx.mozBackingStorePixelRatio || + this.ctx.msBackingStorePixelRatio || + this.ctx.oBackingStorePixelRatio || + this.ctx.backingStorePixelRatio || + 1; + + var ratio = devicePixelRatio / backingStoreRatio; + + if (devicePixelRatio !== backingStoreRatio) { + + var oldWidth = this.canvas.width; + var oldHeight = this.canvas.height; + + this.canvas.width = oldWidth * ratio; + this.canvas.height = oldHeight * ratio; + + this.canvas.style.width = oldWidth + 'px'; + this.canvas.style.height = oldHeight + 'px'; + + this.setScaleAnchored( ratio, ratio, 0, 0 ); + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + this.SCREEN_RATIO= ratio; + } else { + this.setScaleAnchored( 1, 1, 0, 0 ); + } + + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, this.width, this.height); + } + }, + + /** + * Set this director's bounds as well as its contained scenes. + * @param x {number} ignored, will be 0. + * @param y {number} ignored, will be 0. + * @param w {number} director width. + * @param h {number} director height. + * + * @return this + */ + setBounds:function (x, y, w, h) { + + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + + if ( this.canvas.width!==w ) { + this.canvas.width = w; + } + + if ( this.canvas.height!==h ) { + this.canvas.height = h; + } + + this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + + this.__setupRetina(); + + if (this.glEnabled) { + this.glReset(); + } + + return this; + }, + /** + * This method performs Director initialization. Must be called once. + * If the canvas parameter is not set, it will create a Canvas itself, + * and the developer must explicitly add the canvas to the desired DOM position. + * This method will also set the Canvas dimension to the specified values + * by width and height parameters. + * + * @param width {number} a canvas width + * @param height {number} a canvas height + * @param canvas {HTMLCanvasElement=} An optional Canvas object. + * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + * and want events delivered to the correct element. + * + * @return this + */ + initialize:function (width, height, canvas, proxy) { + if ( typeof canvas!=="undefined" ) { + if ( isString(canvas) ) { + canvas= document.getElementById(canvas); + } else if ( !(canvas instanceof HTMLCanvasElement ) ) { + console.log("Canvas is a: "+canvas+" ???"); + } + } + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + this.canvas = canvas; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.setBounds(0, 0, width, height); + this.enableEvents(proxy); + + this.timeline = new Date().getTime(); + + // transition scene + if (CAAT.CACHE_SCENE_ON_CHANGE) { + this.transitionScene = new CAAT.Foundation.Scene().setBounds(0, 0, width, height); + var transitionCanvas = document.createElement('canvas'); + transitionCanvas.width = width; + transitionCanvas.height = height; + var transitionImageActor = new CAAT.Foundation.Actor().setBackgroundImage(transitionCanvas); + this.transitionScene.ctx = transitionCanvas.getContext('2d'); + this.transitionScene.addChildImmediately(transitionImageActor); + this.transitionScene.setEaseListener(this); + } + + this.checkDebug(); + + return this; + }, + glReset:function () { + this.pMatrix = CAAT.WebGL.GLU.makeOrtho(0, this.referenceWidth, this.referenceHeight, 0, -1, 1); + this.gl.viewport(0, 0, this.canvas.width, this.canvas.height); + this.glColorProgram.setMatrixUniform(this.pMatrix); + this.glTextureProgram.setMatrixUniform(this.pMatrix); + this.gl.viewportWidth = this.canvas.width; + this.gl.viewportHeight = this.canvas.height; + }, + /** + * Experimental. + * Initialize a gl enabled director. + */ + initializeGL:function (width, height, canvas, proxy) { + + if (!canvas) { + canvas = document.createElement('canvas'); + document.body.appendChild(canvas); + } + + canvas.width = width; + canvas.height = height; + + if (typeof proxy === 'undefined') { + proxy = canvas; + } + + this.referenceWidth = width; + this.referenceHeight = height; + + var i; + + try { + this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); + this.gl.viewportWidth = width; + this.gl.viewportHeight = height; + CAAT.GLRENDER = true; + } catch (e) { + } + + if (this.gl) { + this.canvas = canvas; + this.setBounds(0, 0, width, height); + + this.enableEvents(canvas); + this.timeline = new Date().getTime(); + + this.glColorProgram = new CAAT.WebGL.ColorProgram(this.gl).create().initialize(); + this.glTextureProgram = new CAAT.WebGL.TextureProgram(this.gl).create().initialize(); + this.glTextureProgram.useProgram(); + this.glReset(); + + var maxTris = 512; + this.coords = new Float32Array(maxTris * 12); + this.uv = new Float32Array(maxTris * 8); + + this.gl.clearColor(0.0, 0.0, 0.0, 255); + + if (this.front_to_back) { + this.gl.clearDepth(1.0); + this.gl.enable(this.gl.DEPTH_TEST); + this.gl.depthFunc(this.gl.LESS); + } else { + this.gl.disable(this.gl.DEPTH_TEST); + } + + this.gl.enable(this.gl.BLEND); +// Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); + this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); + this.glEnabled = true; + + this.checkDebug(); + } else { + // fallback to non gl enabled canvas. + return this.initialize(width, height, canvas); + } + + return this; + }, + /** + * Creates an initializes a Scene object. + * @return {CAAT.Scene} + */ + createScene:function () { + var scene = new CAAT.Scene(); + this.addScene(scene); + return scene; + }, + setImagesCache:function (imagesCache, tpW, tpH) { + + if (!imagesCache || !imagesCache.length ) { + return this; + } + + var i; + + if (null !== this.glTextureManager) { + this.glTextureManager.deletePages(); + this.glTextureManager = null; + } + + // delete previous image identifiers + if (this.imagesCache) { + var ids = []; + for (i = 0; i < this.imagesCache.length; i++) { + ids.push(this.imagesCache[i].id); + } + + for (i = 0; i < ids.length; i++) { + delete this.imagesCache[ ids[i] ]; + } + } + + this.imagesCache = imagesCache; + + if (imagesCache) { + for (i = 0; i < imagesCache.length; i++) { + this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; + } + } + + this.tpW = tpW || 2048; + this.tpH = tpH || 2048; + + this.updateGLPages(); + + return this; + }, + updateGLPages:function () { + if (this.glEnabled) { + + this.glTextureManager = new CAAT.Module.TexturePacker.TexturePageManager(); + this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); + + this.currentTexturePage = this.glTextureManager.pages[0]; + this.glTextureProgram.setTexture(this.currentTexturePage.texture); + } + }, + setGLTexturePage:function (tp) { + this.currentTexturePage = tp; + this.glTextureProgram.setTexture(tp.texture); + return this; + }, + /** + * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this + * function will try to recreate the whole GL texture pages. + * If many handcrafted images are to be added to the director, some performance can be achieved by calling + * director.addImage(id,image,false) many times and a final call with + * director.addImage(id,image,true) to finally command the director to create texture pages. + * + * @param id {string|object} an identitifier to retrieve the image with + * @param image {Image|HTMLCanvasElement} image to add to cache + * @param noUpdateGL {!boolean} unless otherwise stated, the director will + * try to recreate the texture pages. + */ + addImage:function (id, image, noUpdateGL) { + if (this.getImage(id)) { +// for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === id) { + this.imagesCache[i].image = image; + break; + } + } + this.imagesCache[ id ] = image; + } else { + this.imagesCache.push({ id:id, image:image }); + this.imagesCache[id] = image; + } + + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + deleteImage:function (id, noUpdateGL) { + for (var i = 0; i < this.imagesCache.length; i++) { + if (this.imagesCache[i].id === id) { + delete this.imagesCache[id]; + this.imagesCache.splice(i, 1); + break; + } + } + if (!!!noUpdateGL) { + this.updateGLPages(); + } + }, + setGLCurrentOpacity:function (opacity) { + this.currentOpacity = opacity; + this.glTextureProgram.setAlpha(opacity); + }, + /** + * Render buffered elements. + * @param vertex + * @param coordsIndex + * @param uv + */ + glRender:function (vertex, coordsIndex, uv) { + + vertex = vertex || this.coords; + uv = uv || this.uv; + coordsIndex = coordsIndex || this.coordsIndex; + + var gl = this.gl; + + var numTris = coordsIndex / 12 * 2; + var numVertices = coordsIndex / 3; + + this.glTextureProgram.updateVertexBuffer(vertex); + this.glTextureProgram.updateUVBuffer(uv); + + gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); + + }, + glFlush:function () { + if (this.coordsIndex !== 0) { + this.glRender(this.coords, this.coordsIndex, this.uv); + } + this.coordsIndex = 0; + this.uvIndex = 0; + + this.statistics.draws++; + }, + + findActorAtPosition:function (point) { + + // z-order + var cl = this.childrenList; + for (var i = cl.length - 1; i >= 0; i--) { + var child = this.childrenList[i]; + + var np = new CAAT.Math.Point(point.x, point.y, 0); + var contained = child.findActorAtPosition(np); + if (null !== contained) { + return contained; + } + } + + return this; + }, + + /** + * + * Reset statistics information. + * + * @private + */ + resetStats:function () { + this.statistics.size_total = 0; + this.statistics.size_active = 0; + this.statistics.draws = 0; + this.statistics.size_discarded_by_dirty_rects = 0; + }, + + /** + * This is the entry point for the animation system of the Director. + * The director is fed with the elapsed time value to maintain a virtual timeline. + * This virtual timeline will provide each Scene with its own virtual timeline, and will only + * feed time when the Scene is the current Scene, or is being switched. + * + * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be + * set up as a single clip area. + * + * @param time {number} integer indicating the elapsed time between two consecutive frames of the + * Director. + */ + render:function (time) { + + if (this.currentScene && this.currentScene.isPaused()) { + return; + } + + this.time += time; + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + var tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + + this.animate(this, this.time); + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + /** + * draw director active scenes. + */ + var ne = this.childrenList.length; + var i, tt, c; + var ctx = this.ctx; + + if (this.glEnabled) { + + this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); + this.coordsIndex = 0; + this.uvIndex = 0; + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + c.paintActorGL(this, tt); + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + } + + } + } + + this.glFlush(); + + } else { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + + ctx.save(); + if (this.dirtyRectsEnabled) { + this.modelViewMatrix.transformRenderingContext(ctx); + + if (!CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + ctx.clip(); + } else { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + } else if (this.clear === CAAT.Foundation.Director.CLEAR_ALL) { + ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); + } + + for (i = 0; i < ne; i++) { + c = this.childrenList[i]; + + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + ctx.save(); + + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + if (!CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled) { + if (this.nDirtyRects) { + c.paintActor(this, tt); + } + } else { + c.paintActor(this, tt); + } + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + ctx.restore(); + + if (CAAT.DEBUGAABB) { + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + this.modelViewMatrix.transformRenderingContextSet(ctx); + c.drawScreenBoundingBox(this, tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + } + + } + } + + if (this.nDirtyRects > 0 && (!navigator.isCocoonJS && CAAT.DEBUG) && CAAT.DEBUG_DIRTYRECTS) { + ctx.beginPath(); + this.nDirtyRects = 0; + var dr = this.cDirtyRects; + for (i = 0; i < dr.length; i++) { + var drr = dr[i]; + if (!drr.isEmpty()) { + ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0)); + this.nDirtyRects++; + } + } + + ctx.clip(); + ctx.fillStyle = 'rgba(160,255,150,.4)'; + ctx.fillRect(0, 0, this.canvas.width, this.canvas.height); + } + + ctx.restore(); + } + + this.frameCounter++; + }, + + inDirtyRect:function (actor) { + + if (!this.dirtyRectsEnabled || CAAT.DEBUG_DIRTYRECTS) { + return true; + } + + var dr = this.cDirtyRects; + var i; + var aabb = actor.AABB; + + for (i = 0; i < dr.length; i++) { + if (dr[i].intersects(aabb)) { + return true; + } + } + + this.statistics.size_discarded_by_dirty_rects += actor.size_total; + return false; + }, + + /** + * A director is a very special kind of actor. + * Its animation routine simple sets its modelViewMatrix in case some transformation's been + * applied. + * No behaviors are allowed for Director instances. + * @param director {CAAT.Director} redundant reference to CAAT.Director itself + * @param time {number} director time. + */ + animate:function (director, time) { + + this.timerManager.checkTimers(time); + + this.setModelViewMatrix(this); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + this.setScreenBounds(); + + this.dirty = false; + this.invalid = false; + this.dirtyRectsIndex = -1; + this.cDirtyRects= []; + + var cl = this.childrenList; + var cli; + var i, l; + + + if (this.dirtyRectsEnabled) { + var sdr = this.sDirtyRects; + if (sdr.length) { + for (i = 0, l = sdr.length; i < l; i++) { + this.addDirtyRect(sdr[i]); + } + this.sDirtyRects = []; + } + } + + for (i = 0; i < cl.length; i++) { + cli = cl[i]; + var tt = cli.time - cli.start_time; + cli.animate(this, tt); + } + + this.timerManager.removeExpiredTimers(); + + return this; + }, + + /** + * This method is used when asynchronous operations must produce some dirty rectangle painting. + * This means that every operation out of the regular CAAT loop must add dirty rect operations + * by calling this method. + * For example setVisible() and remove. + * @param rectangle + */ + scheduleDirtyRect:function (rectangle) { + this.sDirtyRects.push(rectangle); + }, + /** + * Add a rectangle to the list of dirty screen areas which should be redrawn. + * This is the opposite method to clear the whole screen and repaint everything again. + * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this + * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or + * even lowers performance under others, so it is a developer choice to activate them via a call to + * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). + * + * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping + * rectangles will be removed and intersecting ones will be unioned. + * + * Before calling this method, check if this.dirtyRectsEnabled is true. + * + * @param rectangle {CAAT.Rectangle} + */ + addDirtyRect:function (rectangle) { + + if (rectangle.isEmpty()) { + return; + } + + var i, dr, j, drj; + var cdr = this.cDirtyRects; + + for (i = 0; i < cdr.length; i++) { + dr = cdr[i]; + if (!dr.isEmpty() && dr.intersects(rectangle)) { + var intersected = true; + while (intersected) { + dr.unionRectangle(rectangle); + + for (j = 0; j < cdr.length; j++) { + if (j !== i) { + drj = cdr[j]; + if (!drj.isEmpty() && drj.intersects(dr)) { + dr.unionRectangle(drj); + drj.setEmpty(); + break; + } + } + } + + if (j == cdr.length) { + intersected = false; + } + } + + for (j = 0; j < cdr.length; j++) { + if (cdr[j].isEmpty()) { + cdr.splice(j, 1); + } + } + + return; + } + } + + this.dirtyRectsIndex++; + + if (this.dirtyRectsIndex >= this.dirtyRects.length) { + for (i = 0; i < 32; i++) { + this.dirtyRects.push(new CAAT.Math.Rectangle()); + } + } + + var r = this.dirtyRects[ this.dirtyRectsIndex ]; + + r.x = rectangle.x; + r.y = rectangle.y; + r.x1 = rectangle.x1; + r.y1 = rectangle.y1; + r.width = rectangle.width; + r.height = rectangle.height; + + this.cDirtyRects.push(r); + + }, + /** + * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of + * another Scene (transitionScene). So instead of drawing two scenes while transitioning from + * one to another, first of all an scene is drawn to offscreen, and that image is translated. + *

            + * Until the creation of this method, both scenes where drawn while transitioning with + * its performance penalty since drawing two scenes could be twice as expensive than drawing + * only one. + *

            + * Though a high performance increase, we should keep an eye on memory consumption. + * + * @param ctx a canvas.getContext('2d') instnce. + * @param scene {CAAT.Foundation.Scene} the scene to draw offscreen. + */ + renderToContext:function (ctx, scene) { + /** + * draw actors on scene. + */ + if (scene.isInAnimationFrame(this.time)) { + ctx.setTransform(1, 0, 0, 1, 0, 0); + + ctx.globalAlpha = 1; + ctx.globalCompositeOperation = 'source-over'; + ctx.clearRect(0, 0, this.width, this.height); + + var octx = this.ctx; + + this.ctx = ctx; + ctx.save(); + + /** + * to draw an scene to an offscreen canvas, we have to: + * 1.- save diector's world model view matrix + * 2.- set no transformation on director since we want the offscreen to + * be drawn 1:1. + * 3.- set world dirty flag, so that the scene will recalculate its matrices + * 4.- animate the scene + * 5.- paint the scene + * 6.- restore world model view matrix. + */ + var matmv = this.modelViewMatrix; + var matwmv = this.worldModelViewMatrix; + this.worldModelViewMatrix = new CAAT.Math.Matrix(); + this.modelViewMatrix = this.worldModelViewMatrix; + this.wdirty = true; + scene.animate(this, scene.time); + if (scene.onRenderStart) { + scene.onRenderStart(scene.time); + } + scene.paintActor(this, scene.time); + if (scene.onRenderEnd) { + scene.onRenderEnd(scene.time); + } + this.worldModelViewMatrix = matwmv; + this.modelViewMatrix = matmv; + + ctx.restore(); + + this.ctx = octx; + } + }, + /** + * Add a new Scene to Director's Scene list. By adding a Scene to the Director + * does not mean it will be immediately visible, you should explicitly call either + *

              + *
            • easeIn + *
            • easeInOut + *
            • easeInOutRandom + *
            • setScene + *
            • or any of the scene switching methods + *
            + * + * @param scene {CAAT.Foundation.Scene} + */ + addScene:function (scene) { + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + }, + + /** + * Private + * Gets a contained Scene index on this Director. + * + * @param scene a CAAT.Foundation.Scene object instance. + * + * @return {number} + */ + findScene:function (scene) { + var sl = this.scenes; + var i; + var len = sl.length; + + for (i = 0; i < len; i++) { + if (sl[i] === scene) { + return i; + } + } + return -1; + }, + + /** + * Private + * Removes a scene from this director. + * + * @param scene a CAAT.Foundation.Scene object instance or scene index. + * + * @return {number} + */ + removeScene: function(scene) { + if (typeof scene == 'number') { + this.scenes.splice(scene, 1); + } else { + var idx = this.findScene(scene); + if (idx > 0) { + this.scenes.splice(idx, 1); + } + } + }, + /** + * Get the number of scenes contained in the Director. + * @return {number} the number of scenes contained in the Director. + */ + getNumScenes:function () { + return this.scenes.length; + }, + /** + * This method offers full control over the process of switching between any given two Scenes. + * To apply this method, you must specify the type of transition to apply for each Scene and + * the anchor to keep the Scene pinned at. + *

            + * The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype: + *

              + *
            • EASE_ROTATION + *
            • EASE_SCALE + *
            • EASE_TRANSLATION + *
            + * + *

            + * The anchor will be any of these values defined in CAAT.Foundation.Actor: + *

              + *
            • ANCHOR_CENTER + *
            • ANCHOR_TOP + *
            • ANCHOR_BOTTOM + *
            • ANCHOR_LEFT + *
            • ANCHOR_RIGHT + *
            • ANCHOR_TOP_LEFT + *
            • ANCHOR_TOP_RIGHT + *
            • ANCHOR_BOTTOM_LEFT + *
            • ANCHOR_BOTTOM_RIGHT + *
            + * + *

            + * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the + * point by which the scene will scaled. + * + * @param inSceneIndex integer indicating the Scene index to bring in to the Director. + * @param typein integer indicating the type of transition to apply to the bringing in Scene. + * @param anchorin integer indicating the anchor of the bringing in Scene. + * @param outSceneIndex integer indicating the Scene index to take away from the Director. + * @param typeout integer indicating the type of transition to apply to the taking away in Scene. + * @param anchorout integer indicating the anchor of the taking away Scene. + * @param time inteter indicating the time to perform the process of switchihg between Scene object + * in milliseconds. + * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to + * the scenes. + * @param interpolatorIn CAAT.Behavior.Interpolator object to apply to entering scene. + * @param interpolatorOut CAAT.Behavior.Interpolator object to apply to exiting scene. + */ + easeInOut:function (inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { + + if (inSceneIndex === this.getCurrentSceneIndex()) { + return; + } + + var ssin = this.scenes[ inSceneIndex ]; + var sout = this.scenes[ outSceneIndex ]; + + if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) { + this.renderToContext(this.transitionScene.ctx, sout); + sout = this.transitionScene; + } + + ssin.setExpired(false); + sout.setExpired(false); + + ssin.mouseEnabled = false; + sout.mouseEnabled = false; + + ssin.resetTransform(); + sout.resetTransform(); + + ssin.setLocation(0, 0); + sout.setLocation(0, 0); + + ssin.alpha = 1; + sout.alpha = 1; + + if (typein === CAAT.Foundation.Scene.EASE_ROTATION) { + ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); + } else if (typein === CAAT.Foundation.Scene.EASE_SCALE) { + ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); + } else { + ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); + } + + if (typeout === CAAT.Foundation.Scene.EASE_ROTATION) { + sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); + } else if (typeout === CAAT.Foundation.Scene.EASE_SCALE) { + sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); + } else { + sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); + } + + this.childrenList = []; + + sout.goOut(ssin); + ssin.getIn(sout); + + this.addChild(sout); + this.addChild(ssin); + }, + /** + * This method will switch between two given Scene indexes (ie, take away scene number 2, + * and bring in scene number 5). + *

            + * It will randomly choose for each Scene the type of transition to apply and the anchor + * point of each transition type. + *

            + * It will also set for different kind of transitions the following interpolators: + *

              + *
            • EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. + *
            • EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 + *
            • EASE_TRANSLATION -> BounceOutInterpolator + *
            + * + *

            + * The fps parameter will set the animation quality. Higher values, + * means CAAT will try to render more frames in the same second (at the + * expense of cpu power at least until hardware accelerated canvas rendering + * context are available). A value of 60 is a high frame rate and should not be exceeded. + * + */ + renderFrame:function () { + + CAAT.currentDirector = this; + + if (this.stopped) { + return; + } + + var t = new Date().getTime(), + delta = t - this.timeline; + + /* + check for massive frame time. if for example the current browser tab is minified or taken out of + foreground, the system will account for a bit time interval. minify that impact by lowering down + the elapsed time (virtual timelines FTW) + */ + if (delta > 500) { + delta = 500; + } + + if (this.onRenderStart) { + this.onRenderStart(delta); + } + + this.render(delta); + + if (this.debugInfo) { + this.debugInfo(this.statistics); + } + + this.timeline = t; + + if (this.onRenderEnd) { + this.onRenderEnd(delta); + } + + this.needsRepaint = false; + }, + + /** + * If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement. + */ + resetTimeline:function () { + this.timeline = new Date().getTime(); + }, + + endLoop:function () { + }, + /** + * This method states whether the director must clear background before rendering + * each frame. + * + * The clearing method could be: + * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. + * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled + * will have their areas redrawn. + * + CAAT.Director.CLEAR_NONE. clears nothing. + * + * @param clear {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} + * @return this. + */ + setClear:function (clear) { + this.clear = clear; + if (this.clear === CAAT.Foundation.Director.CLEAR_DIRTY_RECTS) { + this.dirtyRectsEnabled = true; + } else { + this.dirtyRectsEnabled= false; + } + return this; + }, + /** + * Get this Director's AudioManager instance. + * @return {CAAT.AudioManager} the AudioManager instance. + */ + getAudioManager:function () { + return this.audioManager; + }, + /** + * Acculumate dom elements position to properly offset on-screen mouse/touch events. + * @param node + */ + cumulateOffset:function (node, parent, prop) { + var left = prop + 'Left'; + var top = prop + 'Top'; + var x = 0, y = 0, style; + + while (navigator.browser !== 'iOS' && node && node.style) { + if (node.currentStyle) { + style = node.currentStyle['position']; + } else { + style = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); + style = style ? style.getPropertyValue('position') : null; + } + +// if (!/^(relative|absolute|fixed)$/.test(style)) { + if (!/^(fixed)$/.test(style)) { + x += node[left]; + y += node[top]; + node = node[parent]; + } else { + break; + } + } + + return { + x:x, + y:y, + style:style + }; + }, + getOffset:function (node) { + var res = this.cumulateOffset(node, 'offsetParent', 'offset'); + if (res.style === 'fixed') { + var res2 = this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); + return { + x:res.x + res2.x, + y:res.y + res2.y + }; + } + + return { + x:res.x, + y:res.y + }; + }, + /** + * Normalize input event coordinates to be related to (0,0) canvas position. + * @param point {CAAT.Math.Point} canvas coordinate. + * @param e {MouseEvent} a mouse event from an input event. + */ + getCanvasCoord:function (point, e) { + + var pt = new CAAT.Math.Point(); + var posx = 0; + var posy = 0; + if (!e) e = window.event; + + if (e.pageX || e.pageY) { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) { + posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; + posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; + } + + var offset = this.getOffset(this.canvas); + + posx -= offset.x; + posy -= offset.y; + + posx*= this.SCREEN_RATIO; + posy*= this.SCREEN_RATIO; + + ////////////// + // transformar coordenada inversamente con affine transform de director. + + pt.x = posx; + pt.y = posy; + if (!this.modelViewMatrixI) { + this.modelViewMatrix.getInverse(this.modelViewMatrixI); + } + this.modelViewMatrixI.transformCoord(pt); + posx = pt.x; + posy = pt.y + + point.set(posx, posy); + this.screenMousePoint.set(posx, posy); + + }, + + __mouseDownHandler:function (e) { + + /* + was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no + button was presses. Then, send a mouseUp for the previos actor, and return; + */ + if (this.dragging && this.lastSelectedActor) { + this.__mouseUpHandler(e); + return; + } + + this.getCanvasCoord(this.mousePoint, e); + this.isMouseDown = true; + var lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + var pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseDown( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y))); + } + + this.lastSelectedActor = lactor; + }, + + __mouseUpHandler:function (e) { + + this.isMouseDown = false; + this.getCanvasCoord(this.mousePoint, e); + + var pos = null; + var lactor = this.lastSelectedActor; + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + if (lactor.actionPerformed && lactor.contains(pos.x, pos.y)) { + lactor.actionPerformed(e) + } + + lactor.mouseUp( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + + if (!this.dragging && null !== lactor) { + if (lactor.contains(pos.x, pos.y)) { + lactor.mouseClick( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time)); + } + } + + this.dragging = false; + this.in_ = false; +// CAAT.setCursor('default'); + }, + + __mouseMoveHandler:function (e) { + //this.getCanvasCoord(this.mousePoint, e); + + var lactor; + var pos; + + var ct = this.currentScene ? this.currentScene.time : 0; + + // drag + + if (this.isMouseDown && null!==this.lastSelectedActor) { + + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + // check for mouse move threshold. + if (!this.dragging) { + if (Math.abs(this.prevMousePoint.x - pos.x) < CAAT.DRAG_THRESHOLD_X && + Math.abs(this.prevMousePoint.y - pos.y) < CAAT.DRAG_THRESHOLD_Y) { + return; + } + } + + this.dragging = true; + + var px = lactor.x; + var py = lactor.y; + lactor.mouseDrag( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + new CAAT.Math.Point( + this.screenMousePoint.x, + this.screenMousePoint.y), + ct)); + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + /** + * Element has not moved after drag, so treat it as a button. + */ + if (px === lactor.x && py === lactor.y) { + + var contains = lactor.contains(pos.x, pos.y); + + if (this.in_ && !contains) { + lactor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = false; + } + + if (!this.in_ && contains) { + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + this.in_ = true; + } + } + + return; + } + + // mouse move. + this.in_ = true; + + lactor = this.findActorAtPosition(this.mousePoint); + + // cambiamos de actor. + if (lactor !== this.lastSelectedActor) { + if (null !== this.lastSelectedActor) { + + pos = this.lastSelectedActor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + this.lastSelectedActor.mouseExit( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + ct)); + } + + if (null !== lactor) { + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + lactor.mouseEnter( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + } + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + if (null !== lactor) { + + lactor.mouseMove( + new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + ct)); + } + + this.prevMousePoint.x = pos.x; + this.prevMousePoint.y = pos.y; + + this.lastSelectedActor = lactor; + }, + + __mouseOutHandler:function (e) { + + if (this.dragging) { + return; + } + + if (null !== this.lastSelectedActor) { + + this.getCanvasCoord(this.mousePoint, e); + var pos = new CAAT.Math.Point(this.mousePoint.x, this.mousePoint.y, 0); + this.lastSelectedActor.viewToModel(pos); + + var ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time); + + this.lastSelectedActor.mouseExit(ev); + this.lastSelectedActor.mouseOut(ev); + if (!this.dragging) { + this.lastSelectedActor = null; + } + } else { + this.isMouseDown = false; + this.in_ = false; + + } + + }, + + __mouseOverHandler:function (e) { + + if (this.dragging) { + return; + } + + var lactor; + var pos, ev; + + if (null == this.lastSelectedActor) { + lactor = this.findActorAtPosition(this.mousePoint); + + if (null !== lactor) { + + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene ? this.currentScene.time : 0); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + } + + this.lastSelectedActor = lactor; + } else { + lactor = this.lastSelectedActor; + pos = lactor.viewToModel( + new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + + ev = new CAAT.Event.MouseEvent().init( + pos.x, + pos.y, + e, + lactor, + this.screenMousePoint, + this.currentScene.time); + + lactor.mouseOver(ev); + lactor.mouseEnter(ev); + + } + }, + + __mouseDBLClickHandler:function (e) { + + this.getCanvasCoord(this.mousePoint, e); + if (null !== this.lastSelectedActor) { + /* + var pos = this.lastSelectedActor.viewToModel( + new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); + */ + this.lastSelectedActor.mouseDblClick( + new CAAT.Event.MouseEvent().init( + this.mousePoint.x, + this.mousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + /** + * Same as mouseDown but not preventing event. + * Will only take care of first touch. + * @param e + */ + __touchStartHandler:function (e) { + + if (e.target === this.canvas) { + e.preventDefault(); + e.returnValue = false; + + e = e.targetTouches[0]; + + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + return; + } + + this.touching = true; + + this.__mouseDownHandler(e); + } + }, + + __touchEndHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + e = e.changedTouches[0]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, e); + + this.touching = false; + + this.__mouseUpHandler(e); + } + }, + + __touchMoveHandler:function (e) { + + if (this.touching) { + e.preventDefault(); + e.returnValue = false; + + if (this.gesturing) { + return; + } + + for (var i = 0; i < e.targetTouches.length; i++) { + var ee = e.targetTouches[i]; + var mp = this.mousePoint; + this.getCanvasCoord(mp, ee); + this.__mouseMoveHandler(ee); + } + } + }, + + __gestureStart:function (scale, rotation) { + this.gesturing = true; + this.__gestureRotation = this.lastSelectedActor.rotationAngle; + this.__gestureSX = this.lastSelectedActor.scaleX - 1; + this.__gestureSY = this.lastSelectedActor.scaleY - 1; + }, + + __gestureChange:function (scale, rotation) { + if (typeof scale === 'undefined' || typeof rotation === 'undefined') { + return; + } + + if (this.lastSelectedActor !== null && this.lastSelectedActor.isGestureEnabled()) { + this.lastSelectedActor.setRotation(rotation * Math.PI / 180 + this.__gestureRotation); + + this.lastSelectedActor.setScale( + this.__gestureSX + scale, + this.__gestureSY + scale); + } + + }, + + __gestureEnd:function (scale, rotation) { + this.gesturing = false; + this.__gestureRotation = 0; + this.__gestureScale = 0; + }, + + __touchEndHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i, j; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var _touch = e.changedTouches[i]; + var id = _touch.identifier; + recent.push(id); + } + + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + if (this.touches[ touchId ]) { + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addChangedTouch(this.touches[ touchId ].touch); + } + } + + /** + * remove ended touch info. + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + delete this.touches[id]; + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchEnd(touch); + } + }, + + __touchMoveHandlerMT:function (e) { + + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + + if (this.touches[ id ]) { + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + + var actor = this.touches[ id ].actor; + mp = actor.viewToModel(mp); + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchMove(touch); + } + }, + + __touchCancelHandleMT:function (e) { + this.__touchEndHandlerMT(e); + }, + + __touchStartHandlerMT:function (e) { + e.preventDefault(); + e.returnValue = false; + + var i; + var recent = []; + var allInCanvas = true; + + /** + * extrae actores afectados, y coordenadas relativas para ellos. + * crear una coleccion touch-id : { actor, touch-event } + */ + for (i = 0; i < e.changedTouches.length; i++) { + var touch = e.changedTouches[i]; + var id = touch.identifier; + var mp = this.mousePoint; + this.getCanvasCoord(mp, touch); + if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) { + allInCanvas = false; + continue; + } + + var actor = this.findActorAtPosition(mp); + if (actor !== null) { + mp = actor.viewToModel(mp); + + if (!this.touches[ id ]) { + + this.touches[ id ] = { + actor:actor, + touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor) + }; + + recent.push(id); + } + + } + } + + /** + * para los touch identificados, extraer que actores se han afectado. + * crear eventos con la info de touch para cada uno. + */ + + var actors = {}; + for (i = 0; i < recent.length; i++) { + var touchId = recent[ i ]; + var actor = this.touches[ touchId ].actor; + + if (!actors[actor.id]) { + actors[actor.id] = { + actor:actor, + touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time) + }; + } + + var ev = actors[ actor.id ].touch; + ev.addTouch(this.touches[ touchId ].touch); + ev.addChangedTouch(this.touches[ touchId ].touch); + } + + /** + * notificar a todos los actores. + */ + for (var pr in actors) { + var data = actors[pr]; + var actor = data.actor; + var touch = data.touch; + + for (var actorId in this.touches) { + var tt = this.touches[actorId] + if (tt.actor.id === actor.id) { + touch.addTouch(tt.touch); + } + } + + actor.touchStart(touch); + } + + }, + + __findTouchFirstActor:function () { + + var t = Number.MAX_VALUE; + var actor = null; + for (var pr in this.touches) { + + var touch = this.touches[pr]; + + if (touch.touch.time && touch.touch.time < t && touch.actor.isGestureEnabled()) { + actor = touch.actor; + t = touch.touch.time; + } + } + return actor; + }, + + __gesturedActor:null, + __touchGestureStartHandleMT:function (e) { + var actor = this.__findTouchFirstActor(); + + if (actor !== null && actor.isGestureEnabled()) { + this.__gesturedActor = actor; + this.__gestureRotation = actor.rotationAngle; + this.__gestureSX = actor.scaleX - 1; + this.__gestureSY = actor.scaleY - 1; + + + actor.gestureStart( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + }, + + __touchGestureEndHandleMT:function (e) { + + if (null !== this.__gesturedActor && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureEnd( + e.rotation * Math.PI / 180, + e.scale + this.__gestureSX, + e.scale + this.__gestureSY); + } + + this.__gestureRotation = 0; + this.__gestureScale = 0; + + + }, + + __touchGestureChangeHandleMT:function (e) { + + if (this.__gesturedActor !== null && this.__gesturedActor.isGestureEnabled()) { + this.__gesturedActor.gestureChange( + e.rotation * Math.PI / 180, + this.__gestureSX + e.scale, + this.__gestureSY + e.scale); + } + }, + + + addHandlers:function (canvas) { + + var me = this; + + window.addEventListener('mouseup', function (e) { + if (me.touching) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseUpHandler(e); + + me.touching = false; + } + }, false); + + window.addEventListener('mousedown', function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + me.touching = true; + + me.__mouseDownHandler(e); + } + }, false); + + window.addEventListener('mouseover', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseOverHandler(e); + } + }, false); + + window.addEventListener('mouseout', function (e) { + if (e.target === canvas && !me.dragging) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + me.__mouseOutHandler(e); + } + }, false); + + window.addEventListener('mousemove', function (e) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (!me.dragging && ( mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height )) { + return; + } + me.__mouseMoveHandler(e); + }, false); + + window.addEventListener("dblclick", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); + var mp = me.mousePoint; + me.getCanvasCoord(mp, e); + if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) { + return; + } + + me.__mouseDBLClickHandler(e); + } + }, false); + + if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MOUSE) { + canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); + canvas.addEventListener("gesturestart", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureStart(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gestureend", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureEnd(e.scale, e.rotation); + } + }, false); + canvas.addEventListener("gesturechange", function (e) { + if (e.target === canvas) { + e.preventDefault(); + e.returnValue = false; + me.__gestureChange(e.scale, e.rotation); + } + }, false); + } else if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MULTITOUCH) { + canvas.addEventListener("touchstart", this.__touchStartHandlerMT.bind(this), false); + canvas.addEventListener("touchmove", this.__touchMoveHandlerMT.bind(this), false); + canvas.addEventListener("touchend", this.__touchEndHandlerMT.bind(this), false); + canvas.addEventListener("touchcancel", this.__touchCancelHandleMT.bind(this), false); + + canvas.addEventListener("gesturestart", this.__touchGestureStartHandleMT.bind(this), false); + canvas.addEventListener("gestureend", this.__touchGestureEndHandleMT.bind(this), false); + canvas.addEventListener("gesturechange", this.__touchGestureChangeHandleMT.bind(this), false); + } + + }, + + enableEvents:function (onElement) { + CAAT.RegisterDirector(this); + this.in_ = false; + this.createEventHandler(onElement); + }, + + createEventHandler:function (onElement) { + //var canvas= this.canvas; + this.in_ = false; + //this.addHandlers(canvas); + this.addHandlers(onElement); + } + } + }, + + onCreate:function () { + + if (typeof CAAT.__CSS__!=="undefined") { + + CAAT.Foundation.Director.prototype.clip = true; + CAAT.Foundation.Director.prototype.glEnabled = false; + + CAAT.Foundation.Director.prototype.getRenderType = function () { + return 'CSS'; + }; + + CAAT.Foundation.Director.prototype.setScaleProportional = function (w, h) { + + var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight); + this.setScaleAnchored(factor, factor, 0, 0); + + this.eventHandler.style.width = '' + this.referenceWidth + 'px'; + this.eventHandler.style.height = '' + this.referenceHeight + 'px'; + }; + + CAAT.Foundation.Director.prototype.setBounds = function (x, y, w, h) { + CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h); + for (var i = 0; i < this.scenes.length; i++) { + this.scenes[i].setBounds(0, 0, w, h); + } + this.eventHandler.style.width = w + 'px'; + this.eventHandler.style.height = h + 'px'; + + return this; + }; + + /** + * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most + * div in the document hierarchy (z-index 999999). + * @param width + * @param height + * @param domElement + * @param proxy + */ + CAAT.Foundation.Director.prototype.initialize = function (width, height, domElement, proxy) { + + this.timeline = new Date().getTime(); + this.domElement = domElement; + this.style('position', 'absolute'); + this.style('width', '' + width + 'px'); + this.style('height', '' + height + 'px'); + this.style('overflow', 'hidden'); + + this.enableEvents(domElement); + + this.setBounds(0, 0, width, height); + + this.checkDebug(); + return this; + }; + + CAAT.Foundation.Director.prototype.render = function (time) { + + this.time += time; + this.animate(this, time); + + /** + * draw director active scenes. + */ + var i, l, tt; + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.resetStats(); + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time) && !c.isPaused()) { + tt = c.time - c.start_time; + c.timerManager.checkTimers(tt); + c.timerManager.removeExpiredTimers(); + } + } + + for (i = 0, l = this.childrenList.length; i < l; i++) { + var c = this.childrenList[i]; + if (c.isInAnimationFrame(this.time)) { + tt = c.time - c.start_time; + if (c.onRenderStart) { + c.onRenderStart(tt); + } + + c.paintActor(this, tt); + + if (c.onRenderEnd) { + c.onRenderEnd(tt); + } + + if (!c.isPaused()) { + c.time += time; + } + + if (!navigator.isCocoonJS && CAAT.DEBUG) { + this.statistics.size_discarded_by_dirtyRects += this.drDiscarded; + this.statistics.size_total += c.size_total; + this.statistics.size_active += c.size_active; + this.statistics.size_dirtyRects = this.nDirtyRects; + + } + + } + } + + this.frameCounter++; + }; + + CAAT.Foundation.Director.prototype.addScene = function (scene) { + scene.setVisible(true); + scene.setBounds(0, 0, this.width, this.height); + this.scenes.push(scene); + scene.setEaseListener(this); + if (null === this.currentScene) { + this.setScene(0); + } + + this.domElement.appendChild(scene.domElement); + }; + + CAAT.Foundation.Director.prototype.emptyScenes = function () { + this.scenes = []; + this.domElement.innerHTML = ''; + this.createEventHandler(); + }; + + CAAT.Foundation.Director.prototype.setClear = function (clear) { + return this; + }; + + CAAT.Foundation.Director.prototype.createEventHandler = function () { + this.eventHandler = document.createElement('div'); + this.domElement.appendChild(this.eventHandler); + + this.eventHandler.style.position = 'absolute'; + this.eventHandler.style.left = '0'; + this.eventHandler.style.top = '0'; + this.eventHandler.style.zIndex = 999999; + this.eventHandler.style.width = '' + this.width + 'px'; + this.eventHandler.style.height = '' + this.height + 'px'; + + this.canvas = this.eventHandler; + this.in_ = false; + + this.addHandlers(this.canvas); + }; + + CAAT.Foundation.Director.prototype.inDirtyRect = function () { + return true; + } + } + } +}); diff --git a/CAAT/src/Foundation/Scene.js b/CAAT/src/Foundation/Scene.js new file mode 100644 index 0000000..9c7c426 --- /dev/null +++ b/CAAT/src/Foundation/Scene.js @@ -0,0 +1,598 @@ +/** + * See LICENSE file. + * + */ + +CAAT.Module({ + + /** + * @name Scene + * @memberOf CAAT.Foundation + * @extends CAAT.Foundation.ActorContainer + * + * @constructor + * + */ + + defines:"CAAT.Foundation.Scene", + depends: [ + "CAAT.Math.Point", + "CAAT.Math.Matrix", + "CAAT.PathUtil.Path", + "CAAT.Behavior.GenericBehavior", + "CAAT.Behavior.ContainerBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.AlphaBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.PathBehavior", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.Timer.TimerManager" + ], + aliases:["CAAT.Scene"], + extendsClass:"CAAT.Foundation.ActorContainer", + constants:{ + /** + * @lends CAAT.Foundation.Scene + */ + + /** @const @type {number} */ EASE_ROTATION:1, // Constant values to identify the type of Scene transition + /** @const @type {number} */ EASE_SCALE:2, // to perform on Scene switching by the Director. + /** @const @type {number} */ EASE_TRANSLATE:3 + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Foundation.Scene.prototype + */ + + __init:function () { + this.__super(); + this.timerManager = new CAAT.TimerManager(); + this.fillStyle = null; + this.isGlobalAlpha = true; + return this; + }, + + /** + * Behavior container used uniquely for Scene switching. + * @type {CAAT.Behavior.ContainerBehavior} + * @private + */ + easeContainerBehaviour:null, + + /** + * Array of container behaviour events observer. + * @private + */ + easeContainerBehaviourListener:null, + + /** + * When Scene switching, this boolean identifies whether the Scene is being brought in, or taken away. + * @type {boolean} + * @private + */ + easeIn:false, + + + /** + * is this scene paused ? + * @type {boolean} + * @private + */ + paused:false, + + /** + * This scene´s timer manager. + * @type {CAAT.Foundation.Timer.TimerManager} + * @private + */ + timerManager:null, + + isPaused:function () { + return this.paused; + }, + + setPaused:function (paused) { + this.paused = paused; + }, + + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + setTimeout:function (duration, callback_timeout, callback_tick, callback_cancel) { + return this.timerManager.createTimer(this.time, duration, callback_timeout, callback_tick, callback_cancel, this); + }, + + /** + * Helper method to manage alpha transparency fading on Scene switch by the Director. + * @param time {number} time in milliseconds then fading will taableIne. + * @param isIn {boolean} whether this Scene is being brought in. + * + * @private + */ + createAlphaBehaviour:function (time, isIn) { + var ab = new CAAT.Behavior.AlphaBehavior(); + ab.setFrameTime(0, time); + ab.startAlpha = isIn ? 0 : 1; + ab.endAlpha = isIn ? 1 : 0; + this.easeContainerBehaviour.addBehavior(ab); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslationIn:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, true, interpolator); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time {number} time in milliseconds for the Scene to be taken away. + * @param alpha {boolean} fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslationOut:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, false, interpolator); + }, + /** + * This method will setup Scene behaviours to switch an Scene via a translation. + * The anchor value can only be + *

            + * These are the default values, and could not be changed by now. + * This method in final instance delegates the process to easeInOutMethod. + * + * @see easeInOutMethod. + * + * @param inIndex integer indicating the entering scene index. + * @param outIndex integer indicating the exiting scene index. + * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. + * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. + */ + easeInOutRandom:function (inIndex, outIndex, time, alpha) { + + var pin = Math.random(); + var pout = Math.random(); + + var typeIn; + var interpolatorIn; + + if (pin < 0.33) { + typeIn = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorIn = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pin < 0.66) { + typeIn = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorIn = new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4); + } else { + typeIn = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorIn = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + var typeOut; + var interpolatorOut; + + if (pout < 0.33) { + typeOut = CAAT.Foundation.Scene.EASE_ROTATION; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4); + } else if (pout < 0.66) { + typeOut = CAAT.Foundation.Scene.EASE_SCALE; + interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4); + } else { + typeOut = CAAT.Foundation.Scene.EASE_TRANSLATE; + interpolatorOut = new CAAT.Behavior.Interpolator().createBounceOutInterpolator(); + } + + this.easeInOut( + inIndex, + typeIn, + (Math.random() * 8.99) >> 0, + + outIndex, + typeOut, + (Math.random() * 8.99) >> 0, + + time, + alpha, + + interpolatorIn, + interpolatorOut); + + }, + /** + * This method changes Director's current Scene to the scene index indicated by + * inSceneIndex parameter. The Scene running in the director won't be eased out. + * + * @see {CAAT.Interpolator} + * @see {CAAT.Actor} + * @see {CAAT.Scene} + * + * @param inSceneIndex integer indicating the new Scene to set as current. + * @param type integer indicating the type of transition to apply to bring the new current + * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, + * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. + * @param time integer indicating how much time in milliseconds the Scene entrance will take. + * @param alpha boolean indicating whether alpha transparency fading will be applied to the + * entereing Scene. + * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of + * CAAT.Actor.prototype.ANCHOR_* values. + * @param interpolator an CAAT.Interpolator object indicating the interpolation function to + * apply. + */ + easeIn:function (inSceneIndex, type, time, alpha, anchor, interpolator) { + var sin = this.scenes[ inSceneIndex ]; + if (type === CAAT.Foundation.Scene.EASE_ROTATION) { + sin.easeRotationIn(time, alpha, anchor, interpolator); + } else if (type === CAAT.Foundation.Scene.EASE_SCALE) { + sin.easeScaleIn(0, time, alpha, anchor, interpolator); + } else { + sin.easeTranslationIn(time, alpha, anchor, interpolator); + } + this.childrenList = []; + this.addChild(sin); + + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + sin.mouseEnabled = false; + sin.setExpired(false); + }, + /** + * Changes (or sets) the current Director scene to the index + * parameter. There will be no transition on scene change. + * @param scene {number or scene object} an integer indicating the index of the target Scene or the target Scene itself + * to be shown. + */ + setScene:function (scene) { + var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene); + var sin = this.scenes[ sceneIndex ]; + this.childrenList = []; + this.addChild(sin); + this.currentScene = sin; + + sin.setExpired(false); + sin.mouseEnabled = true; + sin.resetTransform(); + sin.setLocation(0, 0); + sin.alpha = 1; + + sin.getIn(); + sin.activated(); + }, + /** + * This method will change the current Scene by the Scene indicated as parameter. + * It will apply random values for anchor and transition type. + * @see easeInOutRandom + * + * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. + * @param time {number} an integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToScene:function (iNewSceneIndex, time, alpha, transition) { + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (!transition) { + this.setScene(iNewSceneIndex); + } + else { + this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToPrevScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex - 1); + } + else { + this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); + } + }, + /** + * Sets the previous Scene in sequence as the current Scene. + * @see switchToScene. + * + * @param time {number} integer indicating the time the Scene transition will take. + * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. + * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. + */ + switchToNextScene:function (time, alpha, transition) { + + var currentSceneIndex = this.getSceneIndex(this.currentScene); + + if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { + return; + } + + if (!transition) { + this.setScene(currentSceneIndex + 1); + } + else { + this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); + } + }, + mouseEnter:function (mouseEvent) { + }, + mouseExit:function (mouseEvent) { + }, + mouseMove:function (mouseEvent) { + }, + mouseDown:function (mouseEvent) { + }, + mouseUp:function (mouseEvent) { + }, + mouseDrag:function (mouseEvent) { + }, + /** + * Scene easing listener. Notifies scenes when they're about to be activated (set as current + * director's scene). + * + * @param scene {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director. + * @param b_easeIn {boolean} scene enters or exits ? + */ + easeEnd:function (scene, b_easeIn) { + // scene is going out + if (!b_easeIn) { + + scene.setExpired(true); + } else { + this.currentScene = scene; + this.currentScene.activated(); + } + + scene.mouseEnabled = true; + scene.emptyBehaviorList(); + }, + /** + * Return the index for a given Scene object contained in the Director. + * @param scene {CAAT.Foundation.Scene} + */ + getSceneIndex:function (scene) { + for (var i = 0; i < this.scenes.length; i++) { + if (this.scenes[i] === scene) { + return i; + } + } + return -1; + }, + /** + * Get a concrete director's scene. + * @param index {number} an integer indicating the scene index. + * @return {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob. + */ + getScene:function (index) { + return this.scenes[index]; + }, + getSceneById : function(id) { + for( var i=0; iimagesCache + * where you can store a JSON of the form + * [ { id: imageId, image: imageObject } ]. + * This structure will be used as a resources cache. + * There's a CAAT.Module.ImagePreloader class to preload resources and + * generate this structure on loading finalization. + * + * @param sId {object} an String identifying a resource. + */ + getImage:function (sId) { + var ret = this.imagesCache[sId]; + if (ret) { + return ret; + } + + //for (var i = 0; i < this.imagesCache.length; i++) { + for( var i in this.imagesCache ) { + if (this.imagesCache[i].id === sId) { + return this.imagesCache[i].image; + } + } + + return null; + }, + musicPlay: function(id) { + return this.audioManager.playMusic(id); + }, + musicStop : function() { + this.audioManager.stopMusic(); + }, + /** + * Adds an audio to the cache. + * + * @see CAAT.Module.Audio.AudioManager.addAudio + * @return this + */ + addAudio:function (id, url) { + this.audioManager.addAudio(id, url); + return this; + }, + /** + * Plays the audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + */ + audioPlay:function (id) { + return this.audioManager.play(id); + }, + /** + * Loops an audio instance identified by the id. + * @param id {object} the object used to store a sound in the audioCache. + * + * @return {HTMLElement|null} the value from audioManager.loop + */ + audioLoop:function (id) { + return this.audioManager.loop(id); + }, + endSound:function () { + return this.audioManager.endSound(); + }, + setSoundEffectsEnabled:function (enabled) { + return this.audioManager.setSoundEffectsEnabled(enabled); + }, + setMusicEnabled:function (enabled) { + return this.audioManager.setMusicEnabled(enabled); + }, + isMusicEnabled:function () { + return this.audioManager.isMusicEnabled(); + }, + isSoundEffectsEnabled:function () { + return this.audioManager.isSoundEffectsEnabled(); + }, + setVolume:function (id, volume) { + return this.audioManager.setVolume(id, volume); + }, + /** + * Removes Director's scenes. + */ + emptyScenes:function () { + this.scenes = []; + }, + /** + * Adds an scene to this Director. + * @param scene {CAAT.Foundation.Scene} a scene object. + */ + addChild:function (scene) { + scene.parent = this; + this.childrenList.push(scene); + }, + /** + * @Deprecated use CAAT.loop instead. + * @param fps + * @param callback + * @param callback2 + */ + loop:function (fps, callback, callback2) { + if (callback2) { + this.onRenderStart = callback; + this.onRenderEnd = callback2; + } else if (callback) { + this.onRenderEnd = callback; + } + CAAT.loop(); + }, + /** + * Starts the director animation.If no scene is explicitly selected, the current Scene will + * be the first scene added to the Director. + *

          • CAAT.Actor.ANCHOR_LEFT + *
          • CAAT.Actor.ANCHOR_RIGHT + *
          • CAAT.Actor.ANCHOR_TOP + *
          • CAAT.Actor.ANCHOR_BOTTOM + * if any other value is specified, any of the previous ones will be applied. + * + * @param time {number} time in milliseconds for the Scene. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {numnber} Scene switch anchor. + * @param isIn {boolean} whether the scene will be brought in. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + */ + easeTranslation:function (time, alpha, anchor, isIn, interpolator) { + + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + this.easeIn = isIn; + + var pb = new CAAT.Behavior.PathBehavior(); + if (interpolator) { + pb.setInterpolator(interpolator); + } + + pb.setFrameTime(0, time); + + // BUGBUG anchors: 1..4 + if (anchor < 1) { + anchor = 1; + } else if (anchor > 4) { + anchor = 4; + } + + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, -this.height + 1, 0, 0)); + this.setPosition(0,-this.height+1); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, -this.height + 1)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, this.height - 1, 0, 0)); + this.setPosition(0,this.height-1); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, 0, this.height - 1)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(-this.width + 1, 0, 0, 0)); + this.setPosition(-this.width+1,0); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, -this.width + 1, 0)); + this.setPosition(0,0); + } + break; + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + if (isIn) { + pb.setPath(new CAAT.PathUtil.Path().setLinear(this.width - 1, 0, 0, 0)); + this.setPosition(this.width-1,0); + } else { + pb.setPath(new CAAT.PathUtil.Path().setLinear(0, 0, this.width - 1, 0)); + this.setPosition(0,0); + } + break; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + this.easeContainerBehaviour.addBehavior(pb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Called from CAAT.Foundation.Director to bring in a Scene. + * A helper method for easeScale. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + */ + easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Foundation.Director to take away a Scene. + * A helper method for easeScale. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + **/ + easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Foundation.Director to bring in ot take away an Scene. + * @param time {number} time in milliseconds for the Scene to be brought in. + * @param alpha {boolean} whether fading will be applied to the Scene. + * @param anchor {number} Scene switch anchor. + * @param interpolator {CAAT.Behavior.Interpolator} how to apply to the Scene transition. + * @param starttime {number} scene time milliseconds from which the behavior will be applied. + * @param isIn boolean indicating whether the Scene is being brought in. + */ + easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var x = 0; + var y = 0; + var x2 = 0; + var y2 = 0; + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_CENTER: + x2 = 1; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + x = 1; + x2 = 1; + y = 0; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + y = 1; + y2 = 1; + x = 0; + x2 = 1; + break; + default: + alert('scale anchor ?? ' + anchor); + } + + if (!isIn) { + var tmp; + tmp = x; + x = x2; + x2 = tmp; + + tmp = y; + y = y2; + y2 = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var sb = new CAAT.Behavior.ScaleBehavior(). + setFrameTime(starttime, time). + setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + sb.setInterpolator(interpolator); + } + + this.easeContainerBehaviour.addBehavior(sb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Overriden method to disallow default behavior. + * Do not use directly. + */ + addBehavior:function (behaviour) { + return this; + }, + /** + * Called from CAAT.Director to use Rotations for bringing in. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationIn:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to use Rotations for taking Scenes away. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationOut:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. + * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param isIn boolean indicating whehter the Scene is brought in. + */ + easeRotation:function (time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var start = 0; + var end = 0; + + if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { + anchor = CAAT.Foundation.Actor.ANCHOR_TOP; + } + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + start = Math.PI * (Math.random() < 0.5 ? 1 : -1); + break; + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); + break; + default: + alert('rot anchor ?? ' + anchor); + } + + if (false === isIn) { + var tmp = start; + start = end; + end = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var rb = new CAAT.Behavior.RotateBehavior(). + setFrameTime(0, time). + setValues(start, end, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + rb.setInterpolator(interpolator); + } + this.easeContainerBehaviour.addBehavior(rb); + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Registers a listener for listen for transitions events. + * Al least, the Director registers himself as Scene easing transition listener. + * When the transition is done, it restores the Scene's capability of receiving events. + * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form + * behaviorExpired( caat_behaviour, time, actor); + */ + setEaseListener:function (listener) { + this.easeContainerBehaviourListener = listener; + }, + /** + * Private. + * listener for the Scene's easeContainerBehaviour. + * @param actor + */ + behaviorExpired:function (actor) { + this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); + }, + /** + * This method should be overriden in case the developer wants to do some special actions when + * the scene has just been brought in. + */ + activated:function () { + }, + /** + * Scenes, do not expire the same way Actors do. + * It simply will be set expired=true, but the frameTime won't be modified. + */ + setExpired:function (bExpired) { + this.expired = bExpired; + }, + /** + * An scene by default does not paint anything because has not fillStyle set. + * @param director + * @param time + */ + paint:function (director, time) { + + if (this.fillStyle) { + var ctx = director.ctx; + ctx.fillStyle = this.fillStyle; + ctx.fillRect(0, 0, this.width, this.height); + } + }, + /** + * Find a pointed actor at position point. + * This method tries lo find the correctly pointed actor in two different ways. + * + first of all, if inputList is defined, it will look for an actor in it. + * + if no inputList is defined, it will traverse the scene graph trying to find a pointed actor. + * @param point + */ + findActorAtPosition:function (point) { + var i, j; + + var p = new CAAT.Math.Point(); + + if (this.inputList) { + var il = this.inputList; + for (i = 0; i < il.length; i++) { + var ill = il[i]; + for (j = 0; j < ill.length; j++) { + if ( ill[j].visible ) { + p.set(point.x, point.y); + var modelViewMatrixI = ill[j].worldModelViewMatrix.getInverse(); + modelViewMatrixI.transformCoord(p); + if (ill[j].contains(p.x, p.y)) { + return ill[j]; + } + } + } + } + } + + p.set(point.x, point.y); + return CAAT.Foundation.Scene.superclass.findActorAtPosition.call(this, p); + }, + + /** + * Enable a number of input lists. + * These lists are set in case the developer doesn't want the to traverse the scene graph to find the pointed + * actor. The lists are a shortcut whete the developer can set what actors to look for input at first instance. + * The system will traverse the whole lists in order trying to find a pointed actor. + * + * Elements are added to each list either in head or tail. + * + * @param size number of lists. + */ + enableInputList:function (size) { + this.inputList = []; + for (var i = 0; i < size; i++) { + this.inputList.push([]); + } + + return this; + }, + + /** + * Add an actor to a given inputList. + * @param actor an actor instance + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists. + * @param position the position on the selected inputList to add the actor at. This value will be + * clamped to the number of available lists. + */ + addActorToInputList:function (actor, index, position) { + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + var il = this.inputList[index]; + + if (typeof position === "undefined" || position >= il.length) { + il.push(actor); + } else if (position <= 0) { + il.unshift(actor); + } else { + il.splice(position, 0, actor); + } + + return this; + }, + + /** + * Remove all elements from an input list. + * @param index the inputList index to add the actor to. This value will be clamped to the number of + * available lists so take care when emptying a non existant inputList index since you could end up emptying + * an undesired input list. + */ + emptyInputList:function (index) { + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + this.inputList[index] = []; + return this; + }, + + /** + * remove an actor from a given input list index. + * If no index is supplied, the actor will be removed from every input list. + * @param actor + * @param index an optional input list index. This value will be clamped to the number of + * available lists. + */ + removeActorFromInputList:function (actor, index) { + if (typeof index === "undefined") { + var i, j; + for (i = 0; i < this.inputList.length; i++) { + var il = this.inputList[i]; + for (j = 0; j < il.length; j++) { + if (il[j] == actor) { + il.splice(j, 1); + } + } + } + return this; + } + + if (index < 0) index = 0; else if (index >= this.inputList.length) index = this.inputList.length - 1; + var il = this.inputList[index]; + for (j = 0; j < il.length; j++) { + if (il[j] == actor) { + il.splice(j, 1); + } + } + + return this; + }, + + getIn : function( out_scene ) { + + }, + + goOut : function( in_scene ) { + + } + + } + } + + +}); diff --git a/CAAT/src/Foundation/SpriteImage.js b/CAAT/src/Foundation/SpriteImage.js new file mode 100644 index 0000000..ff37a70 --- /dev/null +++ b/CAAT/src/Foundation/SpriteImage.js @@ -0,0 +1,1165 @@ +/** + * See LICENSE file. + * + * TODO: allow set of margins, spacing, etc. to define subimages. + * + **/ + +CAAT.Module({ + + /** + * @name SpriteImage + * @memberOf CAAT.Foundation + * @constructor + */ + + + defines : "CAAT.Foundation.SpriteImage", + aliases : ["CAAT.SpriteImage"], + depends : [ + "CAAT.Foundation.SpriteImageHelper", + "CAAT.Foundation.SpriteImageAnimationHelper", + "CAAT.Math.Rectangle" + ], + constants:{ + /** + * @lends CAAT.Foundation.SpriteImage + */ + + /** @const @type {number} */ TR_NONE:0, // constants used to determine how to draw the sprite image, + /** @const @type {number} */ TR_FLIP_HORIZONTAL:1, + /** @const @type {number} */ TR_FLIP_VERTICAL:2, + /** @const @type {number} */ TR_FLIP_ALL:3, + /** @const @type {number} */ TR_FIXED_TO_SIZE:4, + /** @const @type {number} */ TR_FIXED_WIDTH_TO_SIZE:6, + /** @const @type {number} */ TR_TILE:5 + }, + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.SpriteImage.prototype + */ + + __init:function () { + this.paint = this.paintN; + this.setAnimationImageIndex([0]); + this.mapInfo = {}; + this.animationsMap= {}; + + if ( arguments.length===1 ) { + this.initialize.call(this, arguments[0], 1, 1); + } else if ( arguments.length===3 ) { + this.initialize.apply(this, arguments); + } + return this; + }, + + /** + * an Array defining the sprite frame sequence + */ + animationImageIndex:null, + + /** + * Previous animation frame time. + */ + prevAnimationTime:-1, + + /** + * how much Scene time to take before changing an Sprite frame. + */ + changeFPS:1000, + + /** + * any of the TR_* constants. + */ + transformation:0, + + /** + * the current sprite frame + */ + spriteIndex:0, + + /** + * current index of sprite frames array. + */ + prevIndex:0, // + + /** + * current animation name + */ + currentAnimation: null, + + /** + * Image to get frames from. + */ + image:null, + + /** + * Number of rows + */ + rows:1, + + /** + * Number of columns. + */ + columns:1, + + /** + * This sprite image image´s width + */ + width:0, + + /** + * This sprite image image´s width + */ + height:0, + + /** + * For each element in the sprite image array, its size. + */ + singleWidth:0, + + /** + * For each element in the sprite image array, its height. + */ + singleHeight:0, + + scaleX:1, + scaleY:1, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetX:0, + + /** + * Displacement offset to get the sub image from. Useful to make images shift. + */ + offsetY:0, + + /** + * When nesting sprite images, this value is the star X position of this sprite image in the parent. + */ + parentOffsetX:0, // para especificar una subimagen dentro un textmap. + + /** + * When nesting sprite images, this value is the star Y position of this sprite image in the parent. + */ + parentOffsetY:0, + + /** + * The actor this sprite image belongs to. + */ + ownerActor:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages calculated definition map. + */ + mapInfo:null, + + /** + * If the sprite image is defined out of a JSON object (sprite packer for example), this is + * the subimages original definition map. + */ + map:null, + + /** + * This property allows to have multiple different animations defined for one actor. + * see demo31 for a sample. + */ + animationsMap : null, + + /** + * When an animation sequence ends, this callback function will be called. + */ + callback : null, // on end animation callback + + /** + * pending: refactor -> font scale to a font object. + */ + fontScale : 1, + + getOwnerActor : function() { + return this.ownerActor; + }, + + /** + * Add an animation to this sprite image. + * An animation is defines by an array of pretend-to-be-played sprite sequence. + * + * @param name {string} animation name. + * @param array {Array} the sprite animation sequence array. It can be defined + * as number array for Grid-like sprite images or strings for a map-like sprite + * image. + * @param time {number} change animation sequence every 'time' ms. + * @param callback {function({SpriteImage},{string}} a callback function to invoke when the sprite + * animation sequence has ended. + */ + addAnimation : function( name, array, time, callback ) { + this.animationsMap[name]= new CAAT.Foundation.SpriteImageAnimationHelper(array,time,callback); + return this; + }, + + setAnimationEndCallback : function(f) { + this.callback= f; + }, + + /** + * Start playing a SpriteImage animation. + * If it does not exist, nothing happens. + * @param name + */ + playAnimation : function(name) { + if (name===this.currentAnimation) { + return this; + } + + var animation= this.animationsMap[name]; + if ( !animation ) { + return this; + } + + this.currentAnimation= name; + + this.setAnimationImageIndex( animation.animation ); + this.changeFPS= animation.time; + this.callback= animation.onEndPlayCallback; + + return this; + }, + + setOwner:function (actor) { + this.ownerActor = actor; + return this; + }, + getRows:function () { + return this.rows; + }, + getColumns:function () { + return this.columns; + }, + + getWidth:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.width; + }, + + getHeight:function () { + var el = this.mapInfo[this.spriteIndex]; + return el.height; + }, + + getWrappedImageWidth:function () { + return this.image.width; + }, + + getWrappedImageHeight:function () { + return this.image.height; + }, + + /** + * Get a reference to the same image information (rows, columns, image and uv cache) of this + * SpriteImage. This means that re-initializing this objects image info (that is, calling initialize + * method) will change all reference's image information at the same time. + */ + getRef:function () { + var ret = new CAAT.Foundation.SpriteImage(); + ret.image = this.image; + ret.rows = this.rows; + ret.columns = this.columns; + ret.width = this.width; + ret.height = this.height; + ret.singleWidth = this.singleWidth; + ret.singleHeight = this.singleHeight; + ret.mapInfo = this.mapInfo; + ret.offsetX = this.offsetX; + ret.offsetY = this.offsetY; + ret.scaleX = this.scaleX; + ret.scaleY = this.scaleY; + ret.animationsMap= this.animationsMap; + ret.parentOffsetX= this.parentOffsetX; + ret.parentOffsetY= this.parentOffsetY; + + ret.scaleFont= this.scaleFont; + + return ret; + }, + /** + * Set horizontal displacement to draw image. Positive values means drawing the image more to the + * right. + * @param x {number} + * @return this + */ + setOffsetX:function (x) { + this.offsetX = x; + return this; + }, + /** + * Set vertical displacement to draw image. Positive values means drawing the image more to the + * bottom. + * @param y {number} + * @return this + */ + setOffsetY:function (y) { + this.offsetY = y; + return this; + }, + setOffset:function (x, y) { + this.offsetX = x; + this.offsetY = y; + return this; + }, + /** + * Initialize a grid of subimages out of a given image. + * @param image {HTMLImageElement|Image} an image object. + * @param rows {number} number of rows. + * @param columns {number} number of columns + * + * @return this + */ + initialize:function (image, rows, columns) { + + if (!image) { + console.log("Null image for SpriteImage."); + } + + if ( isString(image) ) { + image= CAAT.currentDirector.getImage(image); + } + + this.parentOffsetX= 0; + this.parentOffsetY= 0; + + this.rows = rows; + this.columns = columns; + + if ( image instanceof CAAT.Foundation.SpriteImage || image instanceof CAAT.SpriteImage ) { + this.image = image.image; + var sihelper= image.mapInfo[0]; + this.width= sihelper.width; + this.height= sihelper.height; + + this.parentOffsetX= sihelper.x; + this.parentOffsetY= sihelper.y; + + this.width= image.mapInfo[0].width; + this.height= image.mapInfo[0].height; + + } else { + this.image = image; + this.width = image.width; + this.height = image.height; + this.mapInfo = {}; + + } + + this.singleWidth = Math.floor(this.width / columns); + this.singleHeight = Math.floor(this.height / rows); + + var i, sx0, sy0; + var helper; + + if (image.__texturePage) { + image.__du = this.singleWidth / image.__texturePage.width; + image.__dv = this.singleHeight / image.__texturePage.height; + + + var w = this.singleWidth; + var h = this.singleHeight; + var mod = this.columns; + if (image.inverted) { + var t = w; + w = h; + h = t; + mod = this.rows; + } + + var xt = this.image.__tx; + var yt = this.image.__ty; + + var tp = this.image.__texturePage; + + for (i = 0; i < rows * columns; i++) { + + + var c = ((i % mod) >> 0); + var r = ((i / mod) >> 0); + + var u = xt + c * w; // esquina izq x + var v = yt + r * h; + + var u1 = u + w; + var v1 = v + h; + + helper = new CAAT.Foundation.SpriteImageHelper(u, v, (u1 - u), (v1 - v), tp.width, tp.height).setGL( + u / tp.width, + v / tp.height, + u1 / tp.width, + v1 / tp.height); + + this.mapInfo[i] = helper; + } + + } else { + for (i = 0; i < rows * columns; i++) { + sx0 = ((i % this.columns) | 0) * this.singleWidth + this.parentOffsetX; + sy0 = ((i / this.columns) | 0) * this.singleHeight + this.parentOffsetY; + + helper = new CAAT.Foundation.SpriteImageHelper(sx0, sy0, this.singleWidth, this.singleHeight, image.width, image.height); + this.mapInfo[i] = helper; + } + } + + return this; + }, + + /** + * Create elements as director.getImage values. + * Create as much as elements defined in this sprite image. + * The elements will be named prefix+ + * @param prefix + */ + addElementsAsImages : function( prefix ) { + for( var i in this.mapInfo ) { + var si= new CAAT.Foundation.SpriteImage().initialize( this.image, 1, 1 ); + si.addElement(0, this.mapInfo[i]); + si.setSpriteIndex(0); + CAAT.currentDirector.addImage( prefix+i, si ); + } + }, + + copy : function( other ) { + this.initialize(other,1,1); + this.mapInfo= other.mapInfo; + return this; + }, + + /** + * Must be used to draw actor background and the actor should have setClip(true) so that the image tiles + * properly. + * @param director + * @param time + * @param x + * @param y + */ + paintTiled:function (director, time, x, y) { + + // PENDING: study using a pattern + + var el = this.mapInfo[this.spriteIndex]; + + var r = new CAAT.Math.Rectangle(); + this.ownerActor.AABB.intersect(director.AABB, r); + + var w = this.getWidth(); + var h = this.getHeight(); + var xoff = (this.offsetX - this.ownerActor.x) % w; + if (xoff > 0) { + xoff = xoff - w; + } + var yoff = (this.offsetY - this.ownerActor.y) % h; + if (yoff > 0) { + yoff = yoff - h; + } + + var nw = (((r.width - xoff) / w) >> 0) + 1; + var nh = (((r.height - yoff) / h) >> 0) + 1; + var i, j; + var ctx = director.ctx; + + for (i = 0; i < nh; i++) { + for (j = 0; j < nw; j++) { + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (r.x - this.ownerActor.x + xoff + j * el.width) >> 0, (r.y - this.ownerActor.y + yoff + i * el.height) >> 0, + el.width, el.height); + } + } + }, + + /** + * Draws the subimage pointed by imageIndex horizontally inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedH:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate(((0.5 + x) | 0) + el.width, (0.5 + y) | 0); + ctx.translate((x | 0) + el.width, y | 0); + ctx.scale(-1, 1); + + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex both horizontal and vertically inverted. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintInvertedHV:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + var ctx = director.ctx; + ctx.save(); + //ctx.translate((x + 0.5) | 0, (0.5 + y + el.height) | 0); + ctx.translate(x | 0, (y + el.height) | 0); + ctx.scale(1, -1); + ctx.translate(el.width, 0); + ctx.scale(-1, 1); + + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + this.offsetX >> 0, this.offsetY >> 0, + el.width, el.height); + + ctx.restore(); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintN:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + paintAtRect:function (director, time, x, y, w, h) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + w, h); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaledWidth:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, el.height); + + return this; + }, + paintChunk:function (ctx, dx, dy, x, y, w, h) { + ctx.drawImage(this.image, x, y, w, h, dx, dy, w, h); + }, + paintTile:function (ctx, index, x, y) { + var el = this.mapInfo[index]; + ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + el.width, el.height); + + return this; + }, + /** + * Draws the subimage pointed by imageIndex scaled to the size of w and h. + * @param director {CAAT.Foundation.Director} + * @param time {number} scene time. + * @param x {number} x position in canvas to draw the image. + * @param y {number} y position in canvas to draw the image. + * + * @return this + */ + paintScaled:function (director, time, x, y) { + + var el = this.mapInfo[this.spriteIndex]; + + director.ctx.drawImage( + this.image, + el.x, el.y, + el.width, el.height, + (this.offsetX + x) >> 0, (this.offsetY + y) >> 0, + this.ownerActor.width, this.ownerActor.height); + + return this; + }, + getCurrentSpriteImageCSSPosition:function () { + var el = this.mapInfo[this.spriteIndex]; + + var x = -(el.x + this.parentOffsetX - this.offsetX); + var y = -(el.y + this.parentOffsetY - this.offsetY); + + return '' + x + 'px ' + + y + 'px ' + + (this.ownerActor.transformation === CAAT.Foundation.SpriteImage.TR_TILE ? 'repeat' : 'no-repeat'); + }, + /** + * Get the number of subimages in this compoundImage + * @return {number} + */ + getNumImages:function () { + return this.rows * this.columns; + }, + + setUV:function (uvBuffer, uvIndex) { + var im = this.image; + + if (!im.__texturePage) { + return; + } + + var index = uvIndex; + var sIndex = this.spriteIndex; + var el = this.mapInfo[this.spriteIndex]; + + var u = el.u; + var v = el.v; + var u1 = el.u1; + var v1 = el.v1; + if (this.offsetX || this.offsetY) { + var w = this.ownerActor.width; + var h = this.ownerActor.height; + + var tp = im.__texturePage; + + var _u = -this.offsetX / tp.width; + var _v = -this.offsetY / tp.height; + var _u1 = (w - this.offsetX) / tp.width; + var _v1 = (h - this.offsetY) / tp.height; + + u = _u + im.__u; + v = _v + im.__v; + u1 = _u1 + im.__u; + v1 = _v1 + im.__v; + } + + if (im.inverted) { + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v; + } else { + uvBuffer[index++] = u; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v; + + uvBuffer[index++] = u1; + uvBuffer[index++] = v1; + + uvBuffer[index++] = u; + uvBuffer[index++] = v1; + } + }, + /** + * Set the elapsed time needed to change the image index. + * @param fps an integer indicating the time in milliseconds to change. + * @return this + */ + setChangeFPS:function (fps) { + this.changeFPS = fps; + return this; + }, + /** + * Set the transformation to apply to the Sprite image. + * Any value of + *
          • TR_NONE + *
          • TR_FLIP_HORIZONTAL + *
          • TR_FLIP_VERTICAL + *
          • TR_FLIP_ALL + * + * @param transformation an integer indicating one of the previous values. + * @return this + */ + setSpriteTransformation:function (transformation) { + this.transformation = transformation; + var v = CAAT.Foundation.SpriteImage; + switch (transformation) { + case v.TR_FLIP_HORIZONTAL: + this.paint = this.paintInvertedH; + break; + case v.TR_FLIP_VERTICAL: + this.paint = this.paintInvertedV; + break; + case v.TR_FLIP_ALL: + this.paint = this.paintInvertedHV; + break; + case v.TR_FIXED_TO_SIZE: + this.paint = this.paintScaled; + break; + case v.TR_FIXED_WIDTH_TO_SIZE: + this.paint = this.paintScaledWidth; + break; + case v.TR_TILE: + this.paint = this.paintTiled; + break; + default: + this.paint = this.paintN; + } + this.ownerActor.invalidate(); + return this; + }, + + resetAnimationTime:function () { + this.prevAnimationTime = -1; + return this; + }, + + /** + * Set the sprite animation images index. This method accepts an array of objects which define indexes to + * subimages inside this sprite image. + * If the SpriteImage is instantiated by calling the method initialize( image, rows, cols ), the value of + * aAnimationImageIndex should be an array of numbers, which define the indexes into an array of subimages + * with size rows*columns. + * If the method InitializeFromMap( image, map ) is called, the value for aAnimationImageIndex is expected + * to be an array of strings which are the names of the subobjects contained in the map object. + * + * @param aAnimationImageIndex an array indicating the Sprite's frames. + */ + setAnimationImageIndex:function (aAnimationImageIndex) { + this.animationImageIndex = aAnimationImageIndex; + this.spriteIndex = aAnimationImageIndex[0]; + this.prevAnimationTime = -1; + + return this; + }, + setSpriteIndex:function (index) { + this.spriteIndex = index; + return this; + }, + + /** + * Draws the sprite image calculated and stored in spriteIndex. + * + * @param time {number} Scene time when the bounding box is to be drawn. + */ + setSpriteIndexAtTime:function (time) { + + if (this.animationImageIndex.length > 1) { + if (this.prevAnimationTime === -1) { + this.prevAnimationTime = time; + + //thanks Phloog and ghthor, well spotted. + this.spriteIndex = this.animationImageIndex[0]; + this.prevIndex= 0; + this.ownerActor.invalidate(); + } + else { + var ttime = time; + ttime -= this.prevAnimationTime; + ttime /= this.changeFPS; + ttime %= this.animationImageIndex.length; + var idx = Math.floor(ttime); +// if ( this.spriteIndex!==idx ) { + + if ( idx" : { + * id : {number}, + * height : {number}, + * xoffset : {number}, + * letter : {string}, + * yoffset : {number}, + * width : {number}, + * xadvance: {number}, + * y : {number}, + * x : {number} + * } + */ + initializeAsGlyphDesigner:function (image, map) { + this.initialize(image, 1, 1); + + var key; + var helper; + var count = 0; + + for (key in map) { + var value = map[key]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(value.x) + this.parentOffsetX, + parseFloat(value.y) + this.parentOffsetX, + parseFloat(value.width), + parseFloat(value.height), + image.width, + image.height + ); + + helper.xoffset = typeof value.xoffset === 'undefined' ? 0 : value.xoffset; + helper.yoffset = typeof value.yoffset === 'undefined' ? 0 : value.yoffset; + helper.xadvance = typeof value.xadvance === 'undefined' ? value.width : value.xadvance; + + this.mapInfo[key] = helper; + + // set a default spriteIndex + if (!count) { + this.setAnimationImageIndex([key]); + } + + count++; + } + + return this; + + }, + + + initializeAsFontMap:function (image, chars) { + this.initialize(image, 1, 1); + + var helper; + var x = 0; + + for (var i = 0; i < chars.length; i++) { + var value = chars[i]; + + helper = new CAAT.Foundation.SpriteImageHelper( + parseFloat(x) + this.parentOffsetX, + 0 + this.parentOffsetY, + parseFloat(value.width), + image.height, + image.width, + image.height + ); + + helper.xoffset = 0; + helper.yoffset = 0; + helper.xadvance = value.width; + + + x += value.width; + + this.mapInfo[chars[i].c] = helper; + + // set a default spriteIndex + if (!i) { + this.setAnimationImageIndex([chars[i].c]); + } + } + + return this; + }, + + /** + * This method creates a font sprite image based on a proportional font + * It assumes the font is evenly spaced in the image + * Example: + * var font = new CAAT.SpriteImage().initializeAsMonoTypeFontMap( + * director.getImage('numbers'), + * "0123456789" + * ); + */ + + initializeAsMonoTypeFontMap:function (image, chars) { + var map = []; + var charArr = chars.split(""); + + var w = image.width / charArr.length >> 0; + + for (var i = 0; i < charArr.length; i++) { + map.push({c:charArr[i], width:w }); + } + + return this.initializeAsFontMap(image, map); + }, + + stringWidth:function (str) { + var i, l, w = 0, charInfo; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w += charInfo.xadvance * this.fontScale; + } + } + + return w; + }, + + stringHeight:function () { + if (this.fontHeight) { + return this.fontHeight * this.fontScale; + } + + var y = 0; + for (var i in this.mapInfo) { + var mi = this.mapInfo[i]; + + var h = mi.height + mi.yoffset; + if (h > y) { + y = h; + } + } + + this.fontHeight = y; + return this.fontHeight * this.fontScale; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + + for (i = 0; i < str.length; i++) { + charInfo = this.mapInfo[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, charInfo.y, + w, charInfo.height, + + x + charInfo.xoffset* this.fontScale, y + charInfo.yoffset* this.fontScale, + w* this.fontScale, charInfo.height* this.fontScale); + } + x += charInfo.xadvance* this.fontScale; + } + } + }, + + getFontData : function() { + var as= (this.stringHeight() *.8)>>0; + return { + height : this.stringHeight(), + ascent : as, + descent: this.stringHeight() - as + }; + + } + + } + } +}); diff --git a/CAAT/src/Foundation/SpriteImageAnimationHelper.js b/CAAT/src/Foundation/SpriteImageAnimationHelper.js new file mode 100644 index 0000000..ed9f817 --- /dev/null +++ b/CAAT/src/Foundation/SpriteImageAnimationHelper.js @@ -0,0 +1,47 @@ +CAAT.Module({ + + /** + * + * Define an animation frame sequence, name it and supply with a callback which be called when the + * sequence ends playing. + * + * @name SpriteImageAnimationHelper + * @memberOf CAAT.Foundation + * @constructor + */ + + defines : "CAAT.Foundation.SpriteImageAnimationHelper", + extendsWith : function() { + return { + + /** + * @lends CAAT.Foundation.SpriteImageAnimationHelper.prototype + */ + + __init : function( animation, time, onEndPlayCallback ) { + this.animation= animation; + this.time= time; + this.onEndPlayCallback= onEndPlayCallback; + return this; + }, + + /** + * A sequence of integer values defining a frame animation. + * For example [1,2,3,4,3,2,3,4,3,2] + * Array. + */ + animation : null, + + /** + * Time between any two animation frames. + */ + time : 0, + + /** + * Call this callback function when the sequence ends. + */ + onEndPlayCallback : null + + } + } +}); \ No newline at end of file diff --git a/CAAT/src/Foundation/SpriteImageHelper.js b/CAAT/src/Foundation/SpriteImageHelper.js new file mode 100644 index 0000000..780efac --- /dev/null +++ b/CAAT/src/Foundation/SpriteImageHelper.js @@ -0,0 +1,50 @@ +CAAT.Module( { + + /** + * Define a drawable sub-image inside a bigger image as an independant drawable item. + * + * @name SpriteImageHelper + * @memberOf CAAT.Foundation + * @constructor + * + * + * + */ + + + defines : "CAAT.Foundation.SpriteImageHelper", + + extendsWith : { + + /** + * @lends CAAT.Foundation.SpriteImageHelper.prototype + */ + + __init : function (x, y, w, h, iw, ih) { + this.x = parseFloat(x); + this.y = parseFloat(y); + this.width = parseFloat(w); + this.height = parseFloat(h); + + this.setGL(x / iw, y / ih, (x + w - 1) / iw, (y + h - 1) / ih); + return this; + }, + + x:0, + y:0, + width:0, + height:0, + u:0, + v:0, + u1:0, + v1:0, + + setGL:function (u, v, u1, v1) { + this.u = u; + this.v = v; + this.u1 = u1; + this.v1 = v1; + return this; + } + } +}); diff --git a/CAAT/src/Foundation/Timer/TimerManager.js b/CAAT/src/Foundation/Timer/TimerManager.js new file mode 100644 index 0000000..5aa4610 --- /dev/null +++ b/CAAT/src/Foundation/Timer/TimerManager.js @@ -0,0 +1,133 @@ +/** + * See LICENSE file. + */ +CAAT.Module({ + + /** + * @name Timer + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name TimerManager + * @memberOf CAAT.Foundation.Timer + * @constructor + */ + + defines : "CAAT.Foundation.Timer.TimerManager", + aliases : ["CAAT.TimerManager"], + depends : [ + "CAAT.Foundation.Timer.TimerTask" + ], + extendsWith : { + + /** + * @lends CAAT.Foundation.Timer.TimerManager.prototype + */ + + __init:function () { + this.timerList = []; + return this; + }, + + /** + * Collection of registered timers. + * @type {CAAT.Foundation.Timer.TimerManager} + * @private + */ + timerList:null, + + /** + * Index sequence to idenfity registered timers. + * @private + */ + timerSequence:0, + + /** + * Check and apply timers in frame time. + * @param time {number} the current Scene time. + */ + checkTimers:function (time) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (!tl[i].remove) { + tl[i].checkTask(time); + } + i--; + } + }, + /** + * Make sure the timertask is contained in the timer task list by adding it to the list in case it + * is not contained. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return this + */ + ensureTimerTask:function (timertask) { + if (!this.hasTimer(timertask)) { + this.timerList.push(timertask); + } + return this; + }, + /** + * Check whether the timertask is in this scene's timer task list. + * @param timertask {CAAT.Foundation.Timer.TimerTask}. + * @return {boolean} a boolean indicating whether the timertask is in this scene or not. + */ + hasTimer:function (timertask) { + var tl = this.timerList; + var i = tl.length - 1; + while (i >= 0) { + if (tl[i] === timertask) { + return true; + } + i--; + } + + return false; + }, + /** + * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene + * is taken out of the Director the timer task is paused, and resumed on Scene restoration. + * + * @param startTime {number} an integer indicating the scene time this task must start executing at. + * @param duration {number} an integer indicating the timerTask duration. + * @param callback_timeout {function} timer on timeout callback function. + * @param callback_tick {function} timer on tick callback function. + * @param callback_cancel {function} timer on cancel callback function. + * + * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. + */ + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel, scene) { + + var tt = new CAAT.Foundation.Timer.TimerTask().create( + startTime, + duration, + callback_timeout, + callback_tick, + callback_cancel); + + tt.taskId = this.timerSequence++; + tt.sceneTime = scene.time; + tt.owner = this; + tt.scene = scene; + + this.timerList.push(tt); + + return tt; + }, + /** + * Removes expired timers. This method must not be called directly. + */ + removeExpiredTimers:function () { + var i; + var tl = this.timerList; + for (i = 0; i < tl.length; i++) { + if (tl[i].remove) { + tl.splice(i, 1); + } + } + } + } +}); diff --git a/CAAT/src/Foundation/Timer/TimerTask.js b/CAAT/src/Foundation/Timer/TimerTask.js new file mode 100644 index 0000000..89fcdf6 --- /dev/null +++ b/CAAT/src/Foundation/Timer/TimerTask.js @@ -0,0 +1,137 @@ +CAAT.Module( { + + /** + * @name TimerTask + * @memberOf CAAT.Foundation.Timer + * @constructor + */ + + defines : "CAAT.Foundation.Timer.TimerTask", + aliases : ["CAAT.TimerTask"], + extendsWith : { + + /** + * @lends CAAT.Foundation.Timer.TimerTask.prototype + */ + + /** + * Timer start time. Relative to Scene or Director time, depending who owns this TimerTask. + */ + startTime: 0, + + /** + * Timer duration. + */ + duration: 0, + + /** + * This callback will be called only once, when the timer expires. + */ + callback_timeout: null, + + /** + * This callback will be called whenever the timer is checked in time. + */ + callback_tick: null, + + /** + * This callback will be called when the timer is cancelled. + */ + callback_cancel: null, + + /** + * What TimerManager instance owns this task. + */ + owner: null, + + /** + * Scene or director instance that owns this TimerTask owner. + */ + scene: null, // scene or director instance + + /** + * An arbitrry id. + */ + taskId: 0, + + /** + * Remove this timer task on expiration/cancellation ? + */ + remove: false, + + /** + * Create a TimerTask. + * The taskId will be set by the scene. + * @param startTime {number} an integer indicating TimerTask enable time. + * @param duration {number} an integer indicating TimerTask duration. + * @param callback_timeout {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on timeout callback function. + * @param callback_tick {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on tick callback function. + * @param callback_cancel {function( sceneTime {number}, timertaskTime{number}, timertask {CAAT.TimerTask} )} on cancel callback function. + * + * @return this + */ + create: function( startTime, duration, callback_timeout, callback_tick, callback_cancel ) { + this.startTime= startTime; + this.duration= duration; + this.callback_timeout= callback_timeout; + this.callback_tick= callback_tick; + this.callback_cancel= callback_cancel; + return this; + }, + /** + * Performs TimerTask operation. The task will check whether it is in frame time, and will + * either notify callback_timeout or callback_tick. + * + * @param time {number} an integer indicating scene time. + * @return this + * + * @protected + * + */ + checkTask : function(time) { + var ttime= time; + ttime-= this.startTime; + if ( ttime>=this.duration ) { + this.remove= true; + if( this.callback_timeout ) { + this.callback_timeout( time, ttime, this ); + } + } else { + if ( this.callback_tick ) { + this.callback_tick( time, ttime, this ); + } + } + return this; + }, + remainingTime : function() { + return this.duration - (this.scene.time-this.startTime); + }, + /** + * Reschedules this TimerTask by changing its startTime to current scene's time. + * @param time {number} an integer indicating scene time. + * @return this + */ + reset : function( time ) { + this.remove= false; + this.startTime= time; + this.owner.ensureTimerTask(this); + return this; + }, + /** + * Cancels this timer by removing it on scene's next frame. The function callback_cancel will + * be called. + * @return this + */ + cancel : function() { + this.remove= true; + if ( null!=this.callback_cancel ) { + this.callback_cancel( this.scene.time, this.scene.time-this.startTime, this ); + } + return this; + }, + addTime : function( time ) { + this.duration+= time; + return this; + } + } +}); diff --git a/CAAT/src/Foundation/UI/Dock.js b/CAAT/src/Foundation/UI/Dock.js new file mode 100644 index 0000000..34d4aff --- /dev/null +++ b/CAAT/src/Foundation/UI/Dock.js @@ -0,0 +1,382 @@ +/** + * See LICENSE file. + * + * In this file we'll be adding every useful Actor that is specific for certain purpose. + * + * + CAAT.Dock: a docking container that zooms in/out its actors. + * + */ + +CAAT.Module( { + + /** + * @name UI + * @memberOf CAAT.Foundation + * @namespace + */ + + /** + * @name Dock + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.Dock", + aliases : ["CAAT.Dock"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer", + "CAAT.Behavior.GenericBehavior" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Dock + */ + + /** + * @const + */ + OP_LAYOUT_BOTTOM: 0, + /** + * @const + */ + OP_LAYOUT_TOP: 1, + /** + * @const + */ + OP_LAYOUT_LEFT: 2, + /** + * @const + */ + OP_LAYOUT_RIGHT: 3 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Dock.prototype + */ + + /** + * scene the actor is in. + */ + scene: null, + + /** + * resetting dimension timer task. + */ + ttask: null, + + /** + * min contained actor size. + */ + minSize: 0, + + /** + * max contained actor size + */ + maxSize: 0, + + /** + * aproximated number of elements affected. + */ + range: 2, + + /** + * Any value from CAAT.Foundation.Dock.UI.OP_LAYOUT_* + */ + layoutOp: 0, + + initialize : function(scene) { + this.scene= scene; + return this; + }, + /** + * Set the number of elements that will be affected (zoomed) when the mouse is inside the component. + * @param range {number} a number. Defaults to 2. + */ + setApplicationRange : function( range ) { + this.range= range; + return this; + }, + /** + * Set layout orientation. Choose from + *
              + *
            • CAAT.Dock.OP_LAYOUT_BOTTOM + *
            • CAAT.Dock.OP_LAYOUT_TOP + *
            • CAAT.Dock.OP_LAYOUT_BOTTOM + *
            • CAAT.Dock.OP_LAYOUT_RIGHT + *
            + * By default, the layou operation is OP_LAYOUT_BOTTOM, that is, elements zoom bottom anchored. + * + * @param lo {number} one of CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_TOP, + * CAAT.Dock.OP_LAYOUT_BOTTOM, CAAT.Dock.OP_LAYOUT_RIGHT. + * + * @return this + */ + setLayoutOp : function( lo ) { + this.layoutOp= lo; + return this; + }, + /** + * + * Set maximum and minimum size of docked elements. By default, every contained actor will be + * of 'min' size, and will be scaled up to 'max' size. + * + * @param min {number} + * @param max {number} + * @return this + */ + setSizes : function( min, max ) { + this.minSize= min; + this.maxSize= max; + + for( var i=0; isetLayoutOp
            . + * + * @private + */ + layout : function() { + var i,actor; + + var c= CAAT.Foundation.UI.Dock; + + if ( this.layoutOp===c.OP_LAYOUT_BOTTOM || this.layoutOp===c.OP_LAYOUT_TOP ) { + + var currentWidth=0, currentX=0; + + for( i=0; i index + this.range) { + wwidth = this.minSize; + } else if (i === index) { + wwidth = this.maxSize; + } else if (i < index) { + wwidth= + this.minSize + + (this.maxSize-this.minSize) * + (Math.cos((i - index - across + 1) / this.range * Math.PI) + 1) / + 2; + } else { + wwidth= + this.minSize + + (this.maxSize-this.minSize)* + (Math.cos( (i - index - across) / this.range * Math.PI) + 1) / + 2; + } + + actor.height= wwidth; + actor.width= wwidth; + } + + this.layout(); + }, + /** + * Perform the process of exiting the docking element, that is, animate elements to the minimum + * size. + * + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseExit : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + } + + var me= this; + this.ttask= this.scene.createTimer( + this.scene.time, + 100, + function timeout(sceneTime, time, timerTask) { + me.actorNotPointed(); + }, + null, + null); + }, + /** + * Perform the beginning of docking elements. + * @param mouseEvent {CAAT.MouseEvent} a CAAT.MouseEvent object. + * + * @private + */ + actorMouseEnter : function(mouseEvent) { + if ( null!==this.ttask ) { + this.ttask.cancel(); + this.ttask= null; + } + }, + /** + * Adds an actor to Dock. + *

            + * Be aware that actor mouse functions must be set prior to calling this method. The Dock actor + * needs set his own actor input events functions for mouseEnter, mouseExit and mouseMove and + * will then chain to the original methods set by the developer. + * + * @param actor {CAAT.Actor} a CAAT.Actor instance. + * + * @return this + */ + addChild : function(actor) { + var me= this; + + actor.__Dock_mouseEnter= actor.mouseEnter; + actor.__Dock_mouseExit= actor.mouseExit; + actor.__Dock_mouseMove= actor.mouseMove; + + /** + * @ignore + * @param mouseEvent + */ + actor.mouseEnter= function(mouseEvent) { + me.actorMouseEnter(mouseEvent); + this.__Dock_mouseEnter(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseExit= function(mouseEvent) { + me.actorMouseExit(mouseEvent); + this.__Dock_mouseExit(mouseEvent); + }; + /** + * @ignore + * @param mouseEvent + */ + actor.mouseMove= function(mouseEvent) { + me.actorPointed( mouseEvent.point.x, mouseEvent.point.y, mouseEvent.source ); + this.__Dock_mouseMove(mouseEvent); + }; + + actor.width= this.minSize; + actor.height= this.minSize; + + return CAAT.Foundation.UI.Dock.superclass.addChild.call(this,actor); + } + } + +}); diff --git a/CAAT/src/Foundation/UI/IMActor.js b/CAAT/src/Foundation/UI/IMActor.js new file mode 100644 index 0000000..44b48aa --- /dev/null +++ b/CAAT/src/Foundation/UI/IMActor.js @@ -0,0 +1,66 @@ +CAAT.Module({ + + /** + * @name IMActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.IMActor", + depends : [ + "CAAT.Foundation.Actor", + "CAAT.Module.ImageProcessor.ImageProcessor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.IMActor.prototype + */ + + /** + * Image processing interface. + * @type { } + */ + imageProcessor: null, + + /** + * Calculate another image processing frame every this milliseconds. + */ + changeTime: 100, + + /** + * Last scene time this actor calculated a frame. + */ + lastApplicationTime: -1, + + /** + * Set the image processor. + * + * @param im {CAAT.ImageProcessor} a CAAT.ImageProcessor instance. + */ + setImageProcessor : function(im) { + this.imageProcessor= im; + return this; + }, + /** + * Call image processor to update image every time milliseconds. + * @param time an integer indicating milliseconds to elapse before updating the frame. + */ + setImageProcessingTime : function( time ) { + this.changeTime= time; + return this; + }, + paint : function( director, time ) { + if ( time-this.lastApplicationTime>this.changeTime ) { + this.imageProcessor.apply( director, time ); + this.lastApplicationTime= time; + } + + var ctx= director.ctx; + this.imageProcessor.paint( director, time ); + } + } + +}); diff --git a/CAAT/src/Foundation/UI/InterpolatorActor.js b/CAAT/src/Foundation/UI/InterpolatorActor.js new file mode 100644 index 0000000..640168e --- /dev/null +++ b/CAAT/src/Foundation/UI/InterpolatorActor.js @@ -0,0 +1,118 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module( { + + /** + * @name InterpolatorActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.InterpolatorActor", + aliases : ["CAAT.InterpolatorActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.InterpolatorActor.prototype + */ + + /** + * The interpolator instance to draw. + * @type {CAAT.Behavior.Interpolator} + */ + interpolator: null, + + /** + * This interpolator´s contour. + * @type {Array.} + */ + contour: null, // interpolator contour cache + + /** + * Number of samples to calculate a contour. + */ + S: 50, // contour samples. + + /** + * padding when drawing the interpolator. + */ + gap: 5, // border size in pixels. + + /** + * Sets a padding border size. By default is 5 pixels. + * @param gap {number} border size in pixels. + * @return this + */ + setGap : function( gap ) { + this.gap= gap; + return this; + }, + /** + * Sets the CAAT.Interpolator instance to draw. + * + * @param interpolator a CAAT.Interpolator instance. + * @param size an integer indicating the number of polyline segments so draw to show the CAAT.Interpolator + * instance. + * + * @return this + */ + setInterpolator : function( interpolator, size ) { + this.interpolator= interpolator; + this.contour= interpolator.getContour(size || this.S); + + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Director} + * @param time {number} scene time. + */ + paint : function( director, time ) { + + CAAT.InterpolatorActor.superclass.paint.call(this,director,time); + + if ( this.backgroundImage ) { + return this; + } + + if ( this.interpolator ) { + + var canvas= director.ctx; + + var xs= (this.width-2*this.gap); + var ys= (this.height-2*this.gap); + + canvas.beginPath(); + canvas.moveTo( + this.gap + xs*this.contour[0].x, + -this.gap + this.height - ys*this.contour[0].y); + + for( var i=1; i>0)+1)*ts; + }, + + setFillStyle : function( style ) { + this.fill= style; + }, + + setStrokeStyle : function( style ) { + this.stroke= style; + }, + + setStrokeSize : function( size ) { + this.strokeSize= size; + }, + + setAlignment : function( alignment ) { + this.alignment= alignment; + }, + + setFontSize : function( size ) { + if ( size!==this.fontSize ) { + this.fontSize= size; + this.__setFont(); + } + } + }; + + /** + * This class keeps track of styles, images, and the current applied style. + */ + var renderContext= function() { + this.text= ""; + return this; + }; + + renderContext.prototype= { + + x : 0, + y : 0, + width : 0, + text : null, + + crcs : null, // current rendering context style + rcs : null, // rendering content styles stack + + styles : null, + images : null, + + lines : null, + + documentHeight : 0, + + anchorStack : null, + + __nextLine : function() { + this.x= 0; + this.currentLine= new DocumentLine( + CAAT.Module.Font.Font.getFontMetrics( this.crcs.sfont) ); + this.lines.push( this.currentLine ); + }, + + /** + * + * @param image {CAAT.SpriteImage} + * @param r {number=} + * @param c {number=} + * @private + */ + __image : function( image, r, c ) { + + + var image_width; + + if ( typeof r!=="undefined" && typeof c!=="undefined" ) { + image_width= image.getWidth(); + } else { + image_width= ( image instanceof CAAT.Foundation.SpriteImage ) ? image.getWidth() : image.getWrappedImageWidth(); + } + + // la imagen cabe en este sitio. + if ( this.width ) { + if ( image_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + this.currentLine.addElementImage( new DocumentElementImage( + this.x, + image, + r, + c, + this.crcs.clone(), + this.__getCurrentAnchor() ) ); + + this.x+= image_width; + }, + + __text : function() { + + if ( this.text.length===0 ) { + return; + } + + var text_width= this.ctx.measureText(this.text).width; + + // la palabra cabe en este sitio. + if ( this.width ) { + if ( text_width + this.x > this.width && this.x>0 ) { + this.__nextLine(); + } + } + + //this.crcs.text( this.text, this.x, this.y ); + this.currentLine.addElement( new DocumentElementText( + this.text, + this.x, + text_width, + 0, //this.crcs.__getProperty("fontSize"), calculated later + this.crcs.clone(), + this.__getCurrentAnchor() ) ) ; + + this.x+= text_width; + + this.text=""; + }, + + fchar : function( _char ) { + + if ( _char===' ' ) { + + this.__text(); + + this.x+= this.ctx.measureText(_char).width; + if ( this.width ) { + if ( this.x > this.width ) { + this.__nextLine(); + } + } + } else { + this.text+= _char; + } + }, + + end : function() { + if ( this.text.length>0 ) { + this.__text(); + } + + var y=0; + var lastLineEstimatedDescent= 0; + for( var i=0; i>0; + } + + this.lines[i].setY(y); + } + + this.documentHeight= y + lastLineEstimatedDescent; + }, + + getDocumentHeight : function() { + return this.documentHeight; + }, + + __getCurrentAnchor : function() { + if ( this.anchorStack.length ) { + return this.anchorStack[ this.anchorStack.length-1 ]; + } + + return null; + }, + + __resetAppliedStyles : function() { + this.rcs= []; + this.__pushDefaultStyles(); + }, + + __pushDefaultStyles : function() { + this.crcs= new renderContextStyle(this.ctx).setDefault( this.styles["default"] ); + this.rcs.push( this.crcs ); + }, + + __pushStyle : function( style ) { + var pcrcs= this.crcs; + this.crcs= new renderContextStyle(this.ctx); + this.crcs.chain= pcrcs; + this.crcs.setStyle( style ); + this.crcs.applyStyle( ); + + this.rcs.push( this.crcs ); + }, + + __popStyle : function() { + // make sure you don't remove default style. + if ( this.rcs.length>1 ) { + this.rcs.pop(); + this.crcs= this.rcs[ this.rcs.length-1 ]; + this.crcs.applyStyle(); + } + }, + + __popAnchor : function() { + if ( this.anchorStack.length> 0 ) { + this.anchorStack.pop(); + } + }, + + __pushAnchor : function( anchor ) { + this.anchorStack.push( anchor ); + }, + + start : function( ctx, styles, images, width ) { + this.x=0; + this.y=0; + this.width= typeof width!=="undefined" ? width : 0; + this.ctx= ctx; + this.lines= []; + this.styles= styles; + this.images= images; + this.anchorStack= []; + + this.__resetAppliedStyles(); + this.__nextLine(); + + }, + + setTag : function( tag ) { + + var pairs, style; + + this.__text(); + + tag= tag.toLowerCase(); + if ( tag==='b' ) { + this.crcs.setBold( true ); + } else if ( tag==='/b' ) { + this.crcs.setBold( false ); + } else if ( tag==='i' ) { + this.crcs.setItalic( true ); + } else if ( tag==='/i' ) { + this.crcs.setItalic( false ); + } else if ( tag==='stroked' ) { + this.crcs.setStroked( true ); + } else if ( tag==='/stroked' ) { + this.crcs.setStroked( false ); + } else if ( tag==='filled' ) { + this.crcs.setFilled( true ); + } else if ( tag==='/filled' ) { + this.crcs.setFilled( false ); + } else if ( tag==='tab' ) { + this.x= this.crcs.getTabPos( this.x ); + } else if ( tag==='br' ) { + this.__nextLine(); + } else if ( tag==='/a' ) { + this.__popAnchor(); + } else if ( tag==='/style' ) { + if ( this.rcs.length>1 ) { + this.__popStyle(); + } else { + /** + * underflow pop de estilos. eres un cachondo. + */ + } + } else { + if ( tag.indexOf("fillcolor")===0 ) { + pairs= tag.split("="); + this.crcs.setFillStyle( pairs[1] ); + } else if ( tag.indexOf("strokecolor")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeStyle( pairs[1] ); + } else if ( tag.indexOf("strokesize")===0 ) { + pairs= tag.split("="); + this.crcs.setStrokeSize( pairs[1]|0 ); + } else if ( tag.indexOf("fontsize")===0 ) { + pairs= tag.split("="); + this.crcs.setFontSize( pairs[1]|0 ); + } else if ( tag.indexOf("style")===0 ) { + pairs= tag.split("="); + style= this.styles[ pairs[1] ]; + if ( style ) { + this.__pushStyle( style ); + } + } else if ( tag.indexOf("image")===0) { + pairs= tag.split("=")[1].split(","); + var image= pairs[0]; + if ( this.images[image] ) { + var r= 0, c=0; + if ( pairs.length>=3 ) { + r= pairs[1]|0; + c= pairs[2]|0; + } + this.__image( this.images[image], r, c ); + } else if (CAAT.currentDirector.getImage(image) ) { + this.__image( CAAT.currentDirector.getImage(image) ); + } + } else if ( tag.indexOf("a=")===0 ) { + pairs= tag.split("="); + this.__pushAnchor( pairs[1] ); + } + } + } + }; + + /** + * Abstract document element. + * The document contains a collection of DocumentElementText and DocumentElementImage. + * @param anchor + * @param style + */ + var DocumentElement= function( anchor, style ) { + this.link= anchor; + this.style= style; + return this; + }; + + DocumentElement.prototype= { + x : null, + y : null, + width : null, + height : null, + + style : null, + + link : null, + + isLink : function() { + return this.link; + }, + + setLink : function( link ) { + this.link= link; + return this; + }, + + getLink : function() { + return this.link; + }, + + contains : function(x,y) { + return false; + } + + }; + + /** + * This class represents an image in the document. + * @param x + * @param image + * @param r + * @param c + * @param style + * @param anchor + */ + var DocumentElementImage= function( x, image, r, c, style, anchor ) { + + DocumentElementImage.superclass.constructor.call(this, anchor, style); + + this.x= x; + this.image= image; + this.row= r; + this.column= c; + this.width= image.getWidth(); + this.height= image.getHeight(); + + if ( this.image instanceof CAAT.SpriteImage || this.image instanceof CAAT.Foundation.SpriteImage ) { + + if ( typeof r==="undefined" || typeof c==="undefined" ) { + this.spriteIndex= 0; + } else { + this.spriteIndex= r*image.columns+c; + } + this.paint= this.paintSI; + } + + return this; + }; + + DocumentElementImage.prototype= { + image : null, + row : null, + column : null, + spriteIndex : null, + + paint : function( ctx ) { + this.style.image( ctx ); + ctx.drawImage( this.image, this.x, -this.height+1); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + paintSI : function( ctx ) { + this.style.image( ctx ); + this.image.setSpriteIndex( this.spriteIndex ); + this.image.paint( { ctx: ctx }, 0, this.x, -this.height+1 ); + if ( DEBUG ) { + ctx.strokeRect( this.x, -this.height+1, this.width, this.height ); + } + }, + + getHeight : function() { + return this.image instanceof CAAT.Foundation.SpriteImage ? this.image.getHeight() : this.image.height; + }, + + getFontMetrics : function() { + return null; + }, + + contains : function(x,y) { + return x>=this.x && x<=this.x+this.width && y>=this.y && y= this.x && x<=this.x+this.width && + y>= this.y && y<= this.y+this.height; + }, + + setYPosition : function( baseline ) { + this.bl= baseline; + this.y= baseline - this.fm.ascent; + } + }; + + extend( DocumentElementImage, DocumentElement ); + extend( DocumentElementText, DocumentElement ); + + /** + * This class represents a document line. + * It contains a collection of DocumentElement objects. + */ + var DocumentLine= function( defaultFontMetrics ) { + this.elements= []; + this.defaultFontMetrics= defaultFontMetrics; + return this; + }; + + DocumentLine.prototype= { + elements : null, + width : 0, + height : 0, + defaultHeight : 0, // default line height in case it is empty. + y : 0, + x : 0, + alignment : null, + + baselinePos : 0, + + addElement : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + this.alignment= element.style.__getProperty("alignment"); + }, + + addElementImage : function( element ) { + this.width= Math.max( this.width, element.x + element.width ); + this.height= Math.max( this.height, element.height ); + this.elements.push( element ); + }, + + getHeight : function() { + return this.height; + }, + + setY : function( y ) { + this.y= y; + }, + + getY : function() { + return this.y; + }, + + paint : function( ctx ) { + ctx.save(); + ctx.translate(this.x,this.y + this.baselinePos ); + + for( var i=0; i= JUSTIFY_RATIO && this.elements.length>1 ) { + var remaining= width - this.width; + + var forEachElement= (remaining/(this.elements.length-1))|0; + for( j=1; j biggestFont.ascent ) { + biggestFont= fm; + } + } + } else { // no FontMetrics, it is an image. + if (!biggestImage) { + biggestImage= elem; + } else { + if ( elem.getHeight() > elem.getHeight() ) { + biggestImage= elem; + } + } + } + } + + this.baselinePos= Math.max( + biggestFont ? biggestFont.ascent : this.defaultFontMetrics.ascent, + biggestImage ? biggestImage.getHeight() : this.defaultFontMetrics.ascent ); + this.height= this.baselinePos + (biggestFont!=null ? biggestFont.descent : this.defaultFontMetrics.descent ); + + for( i=0; i' and see whether it matches a tag + tag_closes_at_pos= text.indexOf('>', i+1); + if ( -1!==tag_closes_at_pos ) { + tag= text.substr( i+1, tag_closes_at_pos-i-1 ); + if ( tag.indexOf("<")!==-1 ) { + this.rc.fchar( _char ); + i+=1; + } else { + this.rc.setTag( tag ); + i= tag_closes_at_pos+1; + } + } + } else { + this.rc.fchar( _char ); + i+= 1; + } + } + + this.rc.end(); + this.lines= this.rc.lines; + + this.__calculateDocumentDimension( typeof width==="undefined" ? 0 : width ); + this.setLinesAlignment(); + + ctx.restore(); + + this.setPreferredSize( this.documentWidth, this.documentHeight ); + this.invalidateLayout(); + + this.setDocumentPosition(); + + if ( cached ) { + this.cacheAsBitmap(0,cached); + } + + if ( this.matchTextSize ) { + this.width= this.preferredSize.width; + this.height= this.preferredSize.height; + } + + return this; + }, + + setVerticalAlignment : function( align ) { + this.valignment= align; + this.setDocumentPosition(); + return this; + }, + + setHorizontalAlignment : function( align ) { + this.halignment= align; + this.setDocumentPosition(); + return this; + }, + + setDocumentPosition : function( halign, valign ) { + + if ( typeof halign!=="undefined" ) { + this.setHorizontalAlignment(halign); + } + if ( typeof valign!=="undefined" ) { + this.setVerticalAlignment(valign); + } + + var xo=0, yo=0; + + if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + yo= (this.height - this.documentHeight )/2; + } else if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM ) { + yo= this.height - this.documentHeight; + } + + if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) { + xo= (this.width - this.documentWidth )/2; + } else if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT ) { + xo= this.width - this.documentWidth; + } + + this.documentX= xo; + this.documentY= yo; + }, + + __calculateDocumentDimension : function( suggestedWidth ) { + var i; + var y= 0; + + this.documentWidth= 0; + this.documentHeight= 0; + for( i=0; i=x && line.y+line.height>=y ) { + return line.__getElementAt( x - line.x, y - line.y ); + } + } + + return null; + }, + + mouseExit : function(e) { + CAAT.setCursor( "default"); + }, + + mouseMove : function(e) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem && elem.getLink() ) { + CAAT.setCursor( "pointer"); + } else { + CAAT.setCursor( "default"); + } + }, + + mouseClick : function(e) { + if ( this.clickCallback ) { + var elem= this.__getDocumentElementAt(e.x, e.y); + if ( elem.getLink() ) { + this.clickCallback( elem.getLink() ); + } + } + }, + + setClickCallback : function( callback ) { + this.clickCallback= callback; + return this; + } + } + + } + +}); diff --git a/CAAT/src/Foundation/UI/Layout/BorderLayout.js b/CAAT/src/Foundation/UI/Layout/BorderLayout.js new file mode 100644 index 0000000..e4841d4 --- /dev/null +++ b/CAAT/src/Foundation/UI/Layout/BorderLayout.js @@ -0,0 +1,218 @@ +CAAT.Module( { + + /** + * @name BorderLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.BorderLayout", + aliases : ["CAAT.UI.BorderLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.BorderLayout.prototype + */ + + + __init : function() { + this.__super(); + return this; + }, + + /** + * An actor to position left. + */ + left : null, + + /** + * An actor to position right. + */ + right : null, + + /** + * An actor to position top. + */ + top : null, + + /** + * An actor to position botton. + */ + bottom : null, + + /** + * An actor to position center. + */ + center : null, + + addChild : function( child, constraint ) { + + if ( typeof constraint==="undefined" ) { + constraint="center"; + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.addChild.call( this, child, constraint ); + + if ( constraint==="left" ) { + this.left= child; + } else if ( constraint==="right" ) { + this.right= child; + } else if ( constraint==="top" ) { + this.top= child; + } else if ( constraint==="bottom" ) { + this.bottom= child; + } else { + //"center" + this.center= child; + } + }, + + removeChild : function( child ) { + if ( this.center===child ) { + this.center=null; + } else if ( this.left===child ) { + this.left= null; + } else if ( this.right===child ) { + this.right= null; + } else if ( this.top===child ) { + this.top= null; + } else if ( this.bottom===child ) { + this.bottom= null; + } + }, + + __getChild : function( constraint ) { + if ( constraint==="center" ) { + return this.center; + } else if ( constraint==="left" ) { + return this.left; + } else if ( constraint==="right" ) { + return this.right; + } else if ( constraint==="top" ) { + return this.top; + } else if ( constraint==="bottom" ) { + return this.bottom; + } + }, + + getMinimumLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Math.Dimension(); + + if ((c=this.__getChild("right")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("left")) != null) { + d = c.getMinimumSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getMinimumSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getMinimumSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + getPreferredLayoutSize : function( container ) { + var c, d; + var dim= new CAAT.Dimension(); + + if ((c=this.__getChild("left")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("right")) != null) { + d = c.getPreferredSize(); + dim.width += d.width + this.hgap; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("center")) != null) { + d = c.getPreferredSize(); + dim.width += d.width; + dim.height = Math.max(d.height, dim.height); + } + if ((c=this.__getChild("top")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + d = c.getPreferredSize(); + dim.width = Math.max(d.width, dim.width); + dim.height += d.height + this.vgap; + } + + dim.width += this.padding.left + this.padding.right; + dim.height += this.padding.top + this.padding.bottom; + + return dim; + }, + + doLayout : function( container ) { + + var top = this.padding.top; + var bottom = container.height - this.padding.bottom; + var left = this.padding.left; + var right = container.width - this.padding.right; + var c, d; + + if ((c=this.__getChild("top")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, top, right - left, d.height); + top += d.height + this.vgap; + } + if ((c=this.__getChild("bottom")) != null) { + c.setSize(right - left, c.height); + d = c.getPreferredSize(); + c.setBounds(left, bottom - d.height, right - left, d.height); + bottom -= d.height + this.vgap; + } + if ((c=this.__getChild("right")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(right - d.width, top, d.width, bottom - top); + right -= d.width + this.hgap; + } + if ((c=this.__getChild("left")) != null) { + c.setSize(c.width, bottom - top); + d = c.getPreferredSize(); + c.setBounds(left, top, d.width, bottom - top); + left += d.width + this.hgap; + } + if ((c=this.__getChild("center")) != null) { + c.setBounds(left, top, right - left, bottom - top); + } + + CAAT.Foundation.UI.Layout.BorderLayout.superclass.doLayout.call(this, container); + } + + + } + +}); diff --git a/CAAT/src/Foundation/UI/Layout/BoxLayout.js b/CAAT/src/Foundation/UI/Layout/BoxLayout.js new file mode 100644 index 0000000..82ca1fe --- /dev/null +++ b/CAAT/src/Foundation/UI/Layout/BoxLayout.js @@ -0,0 +1,247 @@ +CAAT.Module({ + + /** + * @name BoxLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines:"CAAT.Foundation.UI.Layout.BoxLayout", + aliases:["CAAT.UI.BoxLayout"], + depends:[ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass:"CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith:function () { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.BoxLayout.prototype + */ + + /** + * Stack elements in this axis. + * @type {CAAT.Foundation.UI.Layout.LayoutManager} + */ + axis:CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y, + + /** + * Vertical alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + valign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + /** + * Horizontal alignment. + * @type {CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT} + */ + halign:CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER, + + setAxis:function (axis) { + this.axis = axis; + this.invalidateLayout(); + return this; + }, + + setHorizontalAlignment:function (align) { + this.halign = align; + this.invalidateLayout(); + return this; + }, + + setVerticalAlignment:function (align) { + this.valign = align; + this.invalidateLayout(); + return this; + }, + + doLayout:function (container) { + + if (this.axis === CAAT.Foundation.UI.Layout.LayoutManager.AXIS.Y) { + this.doLayoutVertical(container); + } else { + this.doLayoutHorizontal(container); + } + + CAAT.Foundation.UI.Layout.BoxLayout.superclass.doLayout.call(this, container); + }, + + doLayoutHorizontal:function (container) { + + var computedW = 0, computedH = 0; + var yoffset = 0, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedH < actor.height) { + computedH = actor.height; + } + + computedW += actor.width; + if (i > 0) { + computedW += this.hgap; + } + } + } + + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - computedW - this.padding.right; + break; + default: + xoffset = (container.width - computedW) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - this.padding.bottom - actor.height; + break; + default: + yoffset = (container.height - actor.height) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + xoffset += actor.width + this.hgap; + } + } + + }, + + __setActorPosition:function (actor, xoffset, yoffset) { + if (this.animated) { + if (this.newChildren.indexOf(actor) !== -1) { + actor.setPosition(xoffset, yoffset); + actor.setScale(0, 0); + actor.scaleTo(1, 1, 500, 0, .5, .5, this.newElementInterpolator); + } else { + actor.moveTo(xoffset, yoffset, 500, 0, this.moveElementInterpolator); + } + } else { + actor.setPosition(xoffset, yoffset); + } + }, + + doLayoutVertical:function (container) { + + var computedW = 0, computedH = 0; + var yoffset, xoffset; + var i, l, actor; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + if (computedW < actor.width) { + computedW = actor.width; + } + + computedH += actor.height; + if (i > 0) { + computedH += this.vgap; + } + } + } + + switch (this.valign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP: + yoffset = this.padding.top; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM: + yoffset = container.height - computedH - this.padding.bottom; + break; + default: + yoffset = (container.height - computedH) / 2; + } + + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + switch (this.halign) { + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT: + xoffset = this.padding.left; + break; + case CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT: + xoffset = container.width - this.padding.right - actor.width; + break; + default: + xoffset = (container.width - actor.width) / 2; + } + + this.__setActorPosition(actor, xoffset, yoffset); + + yoffset += actor.height + this.vgap; + } + } + }, + + getPreferredLayoutSize:function (container) { + + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getPreferredSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + }, + + getMinimumLayoutSize:function (container) { + var dim = new CAAT.Math.Dimension(); + var computedW = 0, computedH = 0; + var i, l; + + // calculamos ancho y alto de los elementos. + for (i = 0, l = container.getNumChildren(); i < l; i += 1) { + + var actor = container.getChildAt(i); + if (!actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame(CAAT.getCurrentSceneTime())) { + var ps = actor.getMinimumSize(); + + if (computedH < ps.height) { + computedH = ps.height; + } + computedW += ps.width; + } + } + + dim.width = computedW; + dim.height = computedH; + + return dim; + } + } + } +}); diff --git a/CAAT/src/Foundation/UI/Layout/GridLayout.js b/CAAT/src/Foundation/UI/Layout/GridLayout.js new file mode 100644 index 0000000..d89a13d --- /dev/null +++ b/CAAT/src/Foundation/UI/Layout/GridLayout.js @@ -0,0 +1,178 @@ +CAAT.Module( { + + /** + * @name GridLayout + * @memberOf CAAT.Foundation.UI.Layout + * @extends CAAT.Foundation.UI.Layout.LayoutManager + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.GridLayout", + aliases : ["CAAT.UI.GridLayout"], + depends : [ + "CAAT.Foundation.UI.Layout.LayoutManager", + "CAAT.Math.Dimension" + ], + extendsClass : "CAAT.Foundation.UI.Layout.LayoutManager", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.Layout.GridLayout.prototype + */ + + __init : function( rows, columns ) { + this.__super(); + this.rows= rows; + this.columns= columns; + + return this; + }, + + /** + * Layout elements using this number of rows. + */ + rows : 0, + + /** + * Layout elements using this number of columns. + */ + columns : 2, + + doLayout : function( container ) { + + var actors= []; + for( var i=0; i 0) { + ncols = Math.floor( (nactors + nrows - 1) / nrows ); + } else { + nrows = Math.floor( (nactors + ncols - 1) / ncols ); + } + + var totalGapsWidth = (ncols - 1) * this.hgap; + var widthWOInsets = container.width - (this.padding.left + this.padding.right); + var widthOnComponent = Math.floor( (widthWOInsets - totalGapsWidth) / ncols ); + var extraWidthAvailable = Math.floor( (widthWOInsets - (widthOnComponent * ncols + totalGapsWidth)) / 2 ); + + var totalGapsHeight = (nrows - 1) * this.vgap; + var heightWOInsets = container.height - (this.padding.top + this.padding.bottom); + var heightOnComponent = Math.floor( (heightWOInsets - totalGapsHeight) / nrows ); + var extraHeightAvailable = Math.floor( (heightWOInsets - (heightOnComponent * nrows + totalGapsHeight)) / 2 ); + + for (var c = 0, x = this.padding.left + extraWidthAvailable; c < ncols ; c++, x += widthOnComponent + this.hgap) { + for (var r = 0, y = this.padding.top + extraHeightAvailable; r < nrows ; r++, y += heightOnComponent + this.vgap) { + var i = r * ncols + c; + if (i < actors.length) { + var child= actors[i]; + if ( !child.preventLayout && child.isVisible() && child.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + if ( !this.animated ) { + child.setBounds( + x + (widthOnComponent-child.width)/2, + y, + widthOnComponent, + heightOnComponent); + } else { + if ( child.width!==widthOnComponent || child.height!==heightOnComponent ) { + child.setSize(widthOnComponent, heightOnComponent); + if ( this.newChildren.indexOf( child ) !==-1 ) { + child.setPosition( + x + (widthOnComponent-child.width)/2, + y ); + child.setScale(0.01,0.01); + child.scaleTo( 1,1, 500, 0,.5,.5, this.newElementInterpolator ); + } else { + child.moveTo( + x + (widthOnComponent-child.width)/2, + y, + 500, + 0, + this.moveElementInterpolator ); + } + } + } + } + } + } + } + + CAAT.Foundation.UI.Layout.GridLayout.superclass.doLayout.call(this, container); + }, + + getMinimumLayoutSize : function( container ) { + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getMinimumSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + }, + + getPreferredLayoutSize : function( container ) { + + var nrows = this.rows; + var ncols = this.columns; + var nchildren= container.getNumChildren(); + var w=0, h=0, i; + + if (nrows > 0) { + ncols = Math.ceil( (nchildren + nrows - 1) / nrows ); + } else { + nrows = Math.ceil( (nchildren + ncols - 1) / ncols ); + } + + for ( i= 0; i < nchildren; i+=1 ) { + var actor= container.getChildAt(i); + if ( !actor.preventLayout && actor.isVisible() && actor.isInAnimationFrame( CAAT.getCurrentSceneTime() ) ) { + var d = actor.getPreferredSize(); + if (w < d.width) { + w = d.width; + } + if (h < d.height) { + h = d.height; + } + } + } + + return new CAAT.Math.Dimension( + this.padding.left + this.padding.right + ncols * w + (ncols - 1) * this.hgap, + this.padding.top + this.padding.bottom + nrows * h + (nrows - 1) * this.vgap + ); + } + + } +}); diff --git a/CAAT/src/Foundation/UI/Layout/LayoutManager.js b/CAAT/src/Foundation/UI/Layout/LayoutManager.js new file mode 100644 index 0000000..c528666 --- /dev/null +++ b/CAAT/src/Foundation/UI/Layout/LayoutManager.js @@ -0,0 +1,179 @@ +CAAT.Module( { + + /** + * @name Layout + * @memberOf CAAT.Foundation.UI + * @namespace + */ + + /** + * @name LayoutManager + * @memberOf CAAT.Foundation.UI.Layout + * @constructor + */ + + defines : "CAAT.Foundation.UI.Layout.LayoutManager", + aliases : ["CAAT.UI.LayoutManager"], + depends : [ + "CAAT.Behavior.Interpolator" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager + */ + + /** + * @enum {number} + */ + AXIS: { + X : 0, + Y : 1 + }, + + /** + * @enum {number} + */ + ALIGNMENT : { + LEFT : 0, + RIGHT: 1, + CENTER: 2, + TOP: 3, + BOTTOM: 4, + JUSTIFY:5 + } + + }, + extendsWith : function() { + + return { + + /** + * @lends CAAT.Foundation.UI.Layout.LayoutManager.prototype + */ + + + __init : function( ) { + + this.newChildren= []; + this.padding= { + left: 2, + right: 2, + top: 2, + bottom: 2 + }; + + return this; + }, + + /** + * If animation enabled, new element interpolator. + */ + newElementInterpolator : new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1,.7), + + /** + * If animation enabled, relayout elements interpolator. + */ + moveElementInterpolator : new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(2), + + /** + * Defines insets: + * @type {{ left, right, top, botton }} + */ + padding : null, + + /** + * Needs relayout ?? + */ + invalid : true, + + /** + * Horizontal gap between children. + */ + hgap : 2, + + /** + * Vertical gap between children. + */ + vgap : 2, + + /** + * Animate on adding/removing elements. + */ + animated : false, + + /** + * pending to be laid-out actors. + */ + newChildren : null, + + setAnimated : function( animate ) { + this.animated= animate; + return this; + }, + + setHGap : function( gap ) { + this.hgap= gap; + this.invalidateLayout(); + return this; + }, + + setVGap : function( gap ) { + this.vgap= gap; + this.invalidateLayout(); + return this; + }, + + setAllPadding : function( s ) { + this.padding.left= s; + this.padding.right= s; + this.padding.top= s; + this.padding.bottom= s; + this.invalidateLayout(); + return this; + }, + + setPadding : function( l,r, t,b ) { + this.padding.left= l; + this.padding.right= r; + this.padding.top= t; + this.padding.bottom= b; + this.invalidateLayout(); + return this; + }, + + addChild : function( child, constraints ) { + this.newChildren.push( child ); + }, + + removeChild : function( child ) { + + }, + + doLayout : function( container ) { + this.newChildren= []; + this.invalid= false; + }, + + invalidateLayout : function( container ) { + this.invalid= true; + }, + + getMinimumLayoutSize : function( container ) { + + }, + + getPreferredLayoutSize : function(container ) { + + }, + + isValid : function() { + return !this.invalid; + }, + + isInvalidated : function() { + return this.invalid; + } + } + } +}); diff --git a/CAAT/src/Foundation/UI/PathActor.js b/CAAT/src/Foundation/UI/PathActor.js new file mode 100644 index 0000000..e520a74 --- /dev/null +++ b/CAAT/src/Foundation/UI/PathActor.js @@ -0,0 +1,159 @@ +/** + * See LICENSE file. + * + * An actor to show the path and its handles in the scene graph. + * + **/ +CAAT.Module( { + + /** + * @name PathActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.Actor + * @constructor + */ + + defines : "CAAT.Foundation.UI.PathActor", + aliases : ["CAAT.PathActor"], + depends : [ + "CAAT.Foundation.Actor" + ], + extendsClass : "CAAT.Foundation.Actor", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.PathActor.prototype + */ + + /** + * Path to draw. + * @type {CAAT.PathUtil.Path} + */ + path : null, + + /** + * Calculated path´s bounding box. + */ + pathBoundingRectangle : null, + + /** + * draw the bounding rectangle too ? + */ + bOutline : false, + + /** + * Outline the path in this color. + */ + outlineColor : 'black', + + /** + * If the path is interactive, some handlers are shown to modify the path. + * This callback function will be called when the path is interactively changed. + */ + onUpdateCallback : null, + + /** + * Set this path as interactive. + */ + interactive : false, + + /** + * Return the contained path. + * @return {CAAT.Path} + */ + getPath : function() { + return this.path; + }, + + /** + * Sets the path to manage. + * @param path {CAAT.PathUtil.PathSegment} + * @return this + */ + setPath : function(path) { + this.path= path; + if ( path!=null ) { + this.pathBoundingRectangle= path.getBoundingBox(); + this.setInteractive( this.interactive ); + } + return this; + }, + /** + * Paint this actor. + * @param director {CAAT.Foundation.Director} + * @param time {number}. Scene time. + */ + paint : function(director, time) { + + CAAT.Foundation.UI.PathActor.superclass.paint.call( this, director, time ); + + if ( !this.path ) { + return; + } + + var ctx= director.ctx; + + ctx.strokeStyle='#000'; + this.path.paint(director, this.interactive); + + if ( this.bOutline ) { + ctx.strokeStyle= this.outlineColor; + ctx.strokeRect( + this.pathBoundingRectangle.x, + this.pathBoundingRectangle.y, + this.pathBoundingRectangle.width, + this.pathBoundingRectangle.height + ); + } + }, + /** + * Enables/disables drawing of the contained path's bounding box. + * @param show {boolean} whether to show the bounding box + * @param color {=string} optional parameter defining the path's bounding box stroke style. + */ + showBoundingBox : function(show, color) { + this.bOutline= show; + if ( show && color ) { + this.outlineColor= color; + } + return this; + }, + /** + * Set the contained path as interactive. This means it can be changed on the fly by manipulation + * of its control points. + * @param interactive + */ + setInteractive : function(interactive) { + this.interactive= interactive; + if ( this.path ) { + this.path.setInteractive(interactive); + } + return this; + }, + setOnUpdateCallback : function( fn ) { + this.onUpdateCallback= fn; + return this; + }, + /** + * Route mouse dragging functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDrag : function(mouseEvent) { + this.path.drag(mouseEvent.point.x, mouseEvent.point.y, this.onUpdateCallback); + }, + /** + * Route mouse down functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseDown : function(mouseEvent) { + this.path.press(mouseEvent.point.x, mouseEvent.point.y); + }, + /** + * Route mouse up functionality to the contained path. + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseUp : function(mouseEvent) { + this.path.release(); + } + } +}); diff --git a/CAAT/src/Foundation/UI/ShapeActor.js b/CAAT/src/Foundation/UI/ShapeActor.js new file mode 100644 index 0000000..a151e62 --- /dev/null +++ b/CAAT/src/Foundation/UI/ShapeActor.js @@ -0,0 +1,227 @@ +CAAT.Module({ + + /** + * @name ShapeActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.ShapeActor", + aliases : ["CAAT.ShapeActor"], + extendsClass : "CAAT.Foundation.ActorContainer", + depends : [ + "CAAT.Foundation.ActorContainer" + ], + constants : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor + */ + + /** @const */ SHAPE_CIRCLE: 0, // Constants to describe different shapes. + /** @const */ SHAPE_RECTANGLE:1 + }, + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.ShapeActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + + /** + * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default, + * so if no explicit call to setShape was made, nothing would be drawn. + */ + this.setShape( CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ); + return this; + }, + + /** + * Define this actor shape: rectangle or circle + */ + shape: 0, // shape type. One of the constant SHAPE_* values + + /** + * Set this shape composite operation when drawing it. + */ + compositeOp: null, // a valid canvas rendering context string describing compositeOps. + + /** + * Stroke the shape with this line width. + */ + lineWidth: 1, + + /** + * Stroke the shape with this line cap. + */ + lineCap: null, + + /** + * Stroke the shape with this line Join. + */ + lineJoin: null, + + /** + * Stroke the shape with this line mitter limit. + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets shape type. + * No check for parameter validity is performed. + * Set paint method according to the shape. + * @param iShape an integer with any of the SHAPE_* constants. + * @return this + */ + setShape : function(iShape) { + this.shape= iShape; + this.paint= this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE ? + this.paintCircle : + this.paintRectangle; + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * Draws the shape. + * Applies the values of fillStype, strokeStyle, compositeOp, etc. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director,time) { + }, + /** + * @private + * Draws a circle. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintCircle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2- this.lineWidth/2, 0, 2*Math.PI, false ); + ctx.stroke(); + } + }, + /** + * + * Private + * Draws a Rectangle. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paintRectangle : function(director,time) { + + if ( this.cached ) { + CAAT.Foundation.ActorContainer.prototype.paint.call( this, director, time ); + return; + } + + var ctx= director.ctx; + + ctx.lineWidth= this.lineWidth; + + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + if ( null!==this.fillStyle ) { + ctx.fillStyle= this.fillStyle; + ctx.beginPath(); + ctx.fillRect(0,0,this.width,this.height); + ctx.fill(); + } + + if ( null!==this.strokeStyle ) { + ctx.strokeStyle= this.strokeStyle; + ctx.beginPath(); + ctx.strokeRect(0,0,this.width,this.height); + ctx.stroke(); + } + } + } + +}); diff --git a/CAAT/src/Foundation/UI/StarActor.js b/CAAT/src/Foundation/UI/StarActor.js new file mode 100644 index 0000000..b7ac388 --- /dev/null +++ b/CAAT/src/Foundation/UI/StarActor.js @@ -0,0 +1,229 @@ +CAAT.Module( { + + /** + * @name StarActor + * @memberOf CAAT.Foundation.UI + * @extends CAAT.Foundation.ActorContainer + * @constructor + */ + + defines : "CAAT.Foundation.UI.StarActor", + aliases : ["CAAT.StarActor"], + depends : [ + "CAAT.Foundation.ActorContainer" + ], + extendsClass : "CAAT.Foundation.ActorContainer", + extendsWith : { + + /** + * @lends CAAT.Foundation.UI.StarActor.prototype + */ + + __init : function() { + this.__super(); + this.compositeOp= 'source-over'; + return this; + }, + + /** + * Number of star peaks. + */ + nPeaks: 0, + + /** + * Maximum radius. + */ + maxRadius: 0, + + /** + * Minimum radius. + */ + minRadius: 0, + + /** + * Staring angle in radians. + */ + initialAngle: 0, + + /** + * Draw the star with this composite operation. + */ + compositeOp: null, + + /** + * + */ + lineWidth: 1, + + /** + * + */ + lineCap: null, + + /** + * + */ + lineJoin: null, + + /** + * + */ + miterLimit: null, + + /** + * + * @param l {number>0} + */ + setLineWidth : function(l) { + this.lineWidth= l; + return this; + }, + /** + * + * @param lc {string{butt|round|square}} + */ + setLineCap : function(lc) { + this.lineCap= lc; + return this; + }, + /** + * + * @param lj {string{bevel|round|miter}} + */ + setLineJoin : function(lj) { + this.lineJoin= lj; + return this; + }, + /** + * + * @param ml {integer>0} + */ + setMiterLimit : function(ml) { + this.miterLimit= ml; + return this; + }, + getLineCap : function() { + return this.lineCap; + }, + getLineJoin : function() { + return this.lineJoin; + }, + getMiterLimit : function() { + return this.miterLimit; + }, + getLineWidth : function() { + return this.lineWidth; + }, + /** + * Sets whether the star will be color filled. + * @param filled {boolean} + * @deprecated + */ + setFilled : function( filled ) { + return this; + }, + /** + * Sets whether the star will be outlined. + * @param outlined {boolean} + * @deprecated + */ + setOutlined : function( outlined ) { + return this; + }, + /** + * Sets the composite operation to apply on shape drawing. + * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. + * @return this + */ + setCompositeOp : function(compositeOp){ + this.compositeOp= compositeOp; + return this; + }, + /** + * + * @param angle {number} number in radians. + */ + setInitialAngle : function(angle) { + this.initialAngle= angle; + return this; + }, + /** + * Initialize the star values. + *

            + * The star actor will be of size 2*maxRadius. + * + * @param nPeaks {number} number of star points. + * @param maxRadius {number} maximum star radius + * @param minRadius {number} minimum star radius + * + * @return this + */ + initialize : function(nPeaks, maxRadius, minRadius) { + this.setSize( 2*maxRadius, 2*maxRadius ); + + this.nPeaks= nPeaks; + this.maxRadius= maxRadius; + this.minRadius= minRadius; + + return this; + }, + /** + * Paint the star. + * + * @param director {CAAT.Director} + * @param timer {number} + */ + paint : function(director, timer) { + + var ctx= director.ctx; + var centerX= this.width/2; + var centerY= this.height/2; + var r1= this.maxRadius; + var r2= this.minRadius; + var ix= centerX + r1*Math.cos(this.initialAngle); + var iy= centerY + r1*Math.sin(this.initialAngle); + + ctx.lineWidth= this.lineWidth; + if ( this.lineCap ) { + ctx.lineCap= this.lineCap; + } + if ( this.lineJoin ) { + ctx.lineJoin= this.lineJoin; + } + if ( this.miterLimit ) { + ctx.miterLimit= this.miterLimit; + } + + ctx.globalCompositeOperation= this.compositeOp; + + ctx.beginPath(); + ctx.moveTo(ix,iy); + + for( var i=1; i>0; + this.fontData= { + height : this.font.singleHeight, + ascent : as, + descent: this.font.singleHeight - as + }; +*/ + return this; + } + + if ( this.font instanceof CAAT.Module.Font.Font ) { + this.textWidth= this.font.stringWidth( this.text ); + this.textHeight=this.font.stringHeight(); + this.width= this.textWidth; + this.height= this.textHeight; + this.fontData= this.font.getFontData(); + return this; + } + + var ctx= director.ctx; + + ctx.save(); + ctx.font= this.font; + + this.textWidth= ctx.measureText( this.text ).width; + if (this.width===0) { + this.width= this.textWidth; + } +/* + var pos= this.font.indexOf("px"); + if (-1===pos) { + pos= this.font.indexOf("pt"); + } + if ( -1===pos ) { + // no pt or px, so guess a size: 32. why not ? + this.textHeight= 32; + } else { + var s = this.font.substring(0, pos ); + this.textHeight= parseInt(s,10); + } +*/ + + this.textHeight= this.fontData.height; + this.setSize( this.textWidth, this.textHeight ); + + ctx.restore(); + + return this; + }, + + __calcFontData : function() { + this.fontData= CAAT.Module.Font.Font.getFontMetrics( this.font ); + }, + + /** + * Custom paint method for TextActor instances. + * If the path attribute is set, the text will be drawn traversing the path. + * + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + paint : function(director, time) { + + if (!this.text) { + return; + } + + CAAT.Foundation.UI.TextActor.superclass.paint.call(this, director, time ); + + if ( this.cached ) { + // cacheAsBitmap sets this actor's background image as a representation of itself. + // So if after drawing the background it was cached, we're done. + return; + } + + if ( null===this.text) { + return; + } + + if ( this.textWidth===0 || this.textHeight===0 ) { + this.calcTextSize(director); + } + + var ctx= director.ctx; + + if ( this.font instanceof CAAT.Module.Font.Font || this.font instanceof CAAT.Foundation.SpriteImage ) { + this.drawSpriteText(director,time); + return; + } + + if( null!==this.font ) { + ctx.font= this.font; + } + + /** + * always draw text with middle or bottom, top is buggy in FF. + * @type {String} + */ + ctx.textBaseline="alphabetic"; + + if (null===this.path) { + + if ( null!==this.textAlign ) { + ctx.textAlign= this.textAlign; + } + + var tx=0; + if ( this.textAlign==='center') { + tx= (this.width/2)|0; + } else if ( this.textAlign==='right' ) { + tx= this.width; + } + + if ( this.fill ) { + if ( null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + ctx.fillText( this.text, tx, this.fontData.ascent ); + } + + if ( this.outline ) { + if (null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + ctx.lineWidth= this.lineWidth; + ctx.beginPath(); + ctx.strokeText( this.text, tx, this.fontData.ascent ); + } + } + else { + this.drawOnPath(director,time); + } + }, + /** + * Private. + * Draw the text traversing a path. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawOnPath : function(director, time) { + + var ctx= director.ctx; + + if ( this.fill && null!==this.textFillStyle ) { + ctx.fillStyle= this.textFillStyle; + } + + if ( this.outline && null!==this.outlineColor ) { + ctx.strokeStyle= this.outlineColor; + } + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i>0, p0.y>>0 ); + } else { + ctx.translate( p0.x, p0.y ); + } + ctx.rotate( angle ); + if ( this.fill ) { + ctx.fillText(caracter,0,0); + } + if ( this.outline ) { + ctx.beginPath(); + ctx.lineWidth= this.lineWidth; + ctx.strokeText(caracter,0,0); + } + + ctx.restore(); + + textWidth+= charWidth; + } + }, + + /** + * Private. + * Draw the text using a sprited font instead of a canvas font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteText: function(director, time) { + if (null===this.path) { + this.font.drawText( this.text, director.ctx, 0, 0); + } else { + this.drawSpriteTextOnPath(director, time); + } + }, + + /** + * Private. + * Draw the text traversing a path using a sprited font. + * @param director a valid CAAT.Director instance. + * @param time an integer with the Scene time the Actor is being drawn. + */ + drawSpriteTextOnPath: function(director, time) { + var context= director.ctx; + + var textWidth=this.sign * this.pathInterpolator.getPosition( + (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; + var p0= new CAAT.Math.Point(0,0,0); + var p1= new CAAT.Math.Point(0,0,0); + + for( var i=0; i= 0) { + if (!this.timerList[i].remove) { + this.timerList[i].checkTask(time); + } + i--; + } + }, + /** + * Make sure the timertask is contained in the timer task list by adding it to the list in case it + * is not contained. + * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. + * @return this + */ + ensureTimerTask:function (timertask) { + if (!this.hasTimer(timertask)) { + this.timerList.push(timertask); + } + return this; + }, + /** + * Check whether the timertask is in this scene's timer task list. + * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. + * @return {boolean} a boolean indicating whether the timertask is in this scene or not. + */ + hasTimer:function (timertask) { + var i = this.timerList.length - 1; + while (i >= 0) { + if (this.timerList[i] === timertask) { + return true; + } + i--; + } + + return false; + }, + /** + * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene + * is taken out of the Director the timer task is paused, and resumed on Scene restoration. + * + * @param startTime {number} an integer indicating the scene time this task must start executing at. + * @param duration {number} an integer indicating the timerTask duration. + * @param callback_timeout {function} timer on timeout callback function. + * @param callback_tick {function} timer on tick callback function. + * @param callback_cancel {function} timer on cancel callback function. + * + * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. + */ + createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { + + var tt = new CAAT.TimerTask().create( + startTime, + duration, + callback_timeout, + callback_tick, + callback_cancel); + + tt.taskId = this.timerSequence++; + tt.sceneTime = this.time; + tt.scene = this; + + this.timerList.push(tt); + + return tt; + }, + /** + * Removes expired timers. This method must not be called directly. + */ + removeExpiredTimers:function () { + var i; + for (i = 0; i < this.timerList.length; i++) { + if (this.timerList[i].remove) { + this.timerList.splice(i, 1); + } + } + }, + /** + * Scene animation method. + * It extendsClass Container's base behavior by adding timer control. + * @param director {CAAT.Director} a CAAT.Director instance. + * @param time {number} an integer indicating the Scene time the animation is being performed at. + */ +// animate:function (director, time) { +// this.checkTimers(time); +// CAAT.Scene.superclass.animate.call(this, director, time); +// this.removeExpiredTimers(); +// }, + /** + * Helper method to manage alpha transparency fading on Scene switch by the Director. + * @param time {number} integer indicating the time in milliseconds the fading will take. + * @param isIn {boolean} boolean indicating whether this Scene in the switch process is + * being brought in. + * + * @private + */ + createAlphaBehaviour:function (time, isIn) { + var ab = new CAAT.AlphaBehavior(); + ab.setFrameTime(0, time); + ab.startAlpha = isIn ? 0 : 1; + ab.endAlpha = isIn ? 1 : 0; + this.easeContainerBehaviour.addBehavior(ab); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslationIn:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, true, interpolator); + }, + /** + * Called from CAAT.Director to bring in an Scene. + * A helper method for easeTranslation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslationOut:function (time, alpha, anchor, interpolator) { + this.easeTranslation(time, alpha, anchor, false, interpolator); + }, + /** + * This method will setup Scene behaviours to switch an Scene via a translation. + * The anchor value can only be + *

          • CAAT.Actor.ANCHOR_LEFT + *
          • CAAT.Actor.ANCHOR_RIGHT + *
          • CAAT.Actor.ANCHOR_TOP + *
          • CAAT.Actor.ANCHOR_BOTTOM + * if any other value is specified, any of the previous ones will be applied. + * + * @param time integer indicating time in milliseconds for the Scene. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param isIn boolean indicating whether the scene will be brought in. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeTranslation:function (time, alpha, anchor, isIn, interpolator) { + + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + this.easeIn = isIn; + + var pb = new CAAT.Behavior.PathBehavior(); + if (interpolator) { + pb.setInterpolator(interpolator); + } + + pb.setFrameTime(0, time); + + // BUGBUG anchors: 1..4 + if (anchor < 1) { + anchor = 1; + } else if (anchor > 4) { + anchor = 4; + } + + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(0, -this.height, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, 0, -this.height)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(0, this.height, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, 0, this.height)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(-this.width, 0, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, -this.width, 0)); + } + break; + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + if (isIn) { + pb.setPath(new CAAT.Path().setLinear(this.width, 0, 0, 0)); + } else { + pb.setPath(new CAAT.Path().setLinear(0, 0, this.width, 0)); + } + break; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + this.easeContainerBehaviour.addBehavior(pb); + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + var start = pb.path.startCurvePosition(); + this.setLocation(start.x, start.y); + + this.emptyBehaviorList(); + CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Called from CAAT.Director to bring in a Scene. + * A helper method for easeScale. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + */ + easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to take away a Scene. + * A helper method for easeScale. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator instance to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + */ + easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { + this.easeScale(starttime, time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to bring in ot take away an Scene. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. + * @param isIn boolean indicating whether the Scene is being brought in. + */ + easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.ContainerBehavior(); + + var x = 0; + var y = 0; + var x2 = 0; + var y2 = 0; + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_CENTER: + x2 = 1; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + x = 1; + x2 = 1; + y = 0; + y2 = 1; + break; + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + y = 1; + y2 = 1; + x = 0; + x2 = 1; + break; + default: + alert('scale anchor ?? ' + anchor); + } + + if (!isIn) { + var tmp; + tmp = x; + x = x2; + x2 = tmp; + + tmp = y; + y = y2; + y2 = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var sb = new CAAT.ScaleBehavior(). + setFrameTime(starttime, time). + setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + sb.setInterpolator(interpolator); + } + + this.easeContainerBehaviour.addBehavior(sb); + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Overriden method to disallow default behavior. + * Do not use directly. + */ + addBehavior:function (behaviour) { + return this; + }, + /** + * Called from CAAT.Director to use Rotations for bringing in. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationIn:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, true, interpolator); + this.easeIn = true; + }, + /** + * Called from CAAT.Director to use Rotations for taking Scenes away. + * This method is a Helper for the method easeRotation. + * @param time integer indicating time in milliseconds for the Scene to be taken away. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + */ + easeRotationOut:function (time, alpha, anchor, interpolator) { + this.easeRotation(time, alpha, anchor, false, interpolator); + this.easeIn = false; + }, + /** + * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. + * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. + * @param alpha boolean indicating whether fading will be applied to the Scene. + * @param anchor integer indicating the Scene switch anchor. + * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. + * @param isIn boolean indicating whehter the Scene is brought in. + */ + easeRotation:function (time, alpha, anchor, isIn, interpolator) { + this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); + + var start = 0; + var end = 0; + + if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { + anchor = CAAT.Foundation.Actor.ANCHOR_TOP; + } + + switch (anchor) { + case CAAT.Foundation.Actor.ANCHOR_TOP: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM: + case CAAT.Foundation.Actor.ANCHOR_LEFT: + case CAAT.Foundation.Actor.ANCHOR_RIGHT: + start = Math.PI * (Math.random() < 0.5 ? 1 : -1); + break; + case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: + case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: + case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: + start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); + break; + default: + alert('rot anchor ?? ' + anchor); + } + + if (false === isIn) { + var tmp = start; + start = end; + end = tmp; + } + + if (alpha) { + this.createAlphaBehaviour(time, isIn); + } + + var anchorPercent = this.getAnchorPercent(anchor); + var rb = new CAAT.Behavior.RotateBehavior(). + setFrameTime(0, time). + setValues(start, end, anchorPercent.x, anchorPercent.y); + + if (interpolator) { + rb.setInterpolator(interpolator); + } + this.easeContainerBehaviour.addBehavior(rb); + + + this.easeContainerBehaviour.setFrameTime(this.time, time); + this.easeContainerBehaviour.addListener(this); + + this.emptyBehaviorList(); + CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); + }, + /** + * Registers a listener for listen for transitions events. + * Al least, the Director registers himself as Scene easing transition listener. + * When the transition is done, it restores the Scene's capability of receiving events. + * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form + * behaviorExpired( caat_behaviour, time, actor); + */ + setEaseListener:function (listener) { + this.easeContainerBehaviourListener = listener; + }, + /** + * Private. + * listener for the Scene's easeContainerBehaviour. + * @param actor + */ + behaviorExpired:function (actor) { + this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); + }, + /** + * This method should be overriden in case the developer wants to do some special actions when + * the scene has just been brought in. + */ + activated:function () { + }, + /** + * Scenes, do not expire the same way Actors do. + * It simply will be set expired=true, but the frameTime won't be modified. + * WARN: the parameter here is treated as boolean, not number. + */ + setExpired:function (bExpired) { + this.expired = bExpired; + this.style('display', bExpired ? 'none' : 'block'); + }, + /** + * An scene by default does not paint anything because has not fillStyle set. + * @param director + * @param time + */ + paint:function (director, time) { + }, + + getIn : function( out_scene ) { + + }, + + goOut : function( in_scene ) { + + } + } + } +}); \ No newline at end of file diff --git a/CAAT/src/Lib/Box2dWeb-2.1.a.3.js b/CAAT/src/Lib/Box2dWeb-2.1.a.3.js new file mode 100755 index 0000000..cb5e30c --- /dev/null +++ b/CAAT/src/Lib/Box2dWeb-2.1.a.3.js @@ -0,0 +1,10866 @@ +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ +var Box2D = {}; + +(function (a2j, undefined) { + + if(!(Object.prototype.defineProperty instanceof Function) + && Object.prototype.__defineGetter__ instanceof Function + && Object.prototype.__defineSetter__ instanceof Function) + { + Object.defineProperty = function(obj, p, cfg) { + if(cfg.get instanceof Function) + obj.__defineGetter__(p, cfg.get); + if(cfg.set instanceof Function) + obj.__defineSetter__(p, cfg.set); + } + } + + function emptyFn() {}; + a2j.inherit = function(cls, base) { + var tmpCtr = cls; + emptyFn.prototype = base.prototype; + cls.prototype = new emptyFn; + cls.prototype.constructor = tmpCtr; + }; + + a2j.generateCallback = function generateCallback(context, cb) { + return function () { + cb.apply(context, arguments); + }; + }; + + a2j.NVector = function NVector(length) { + if (length === undefined) length = 0; + var tmp = new Array(length || 0); + for (var i = 0; i < length; ++i) + tmp[i] = 0; + return tmp; + }; + + a2j.is = function is(o1, o2) { + if (o1 === null) return false; + if ((o2 instanceof Function) && (o1 instanceof o2)) return true; + if ((o1.constructor.__implements != undefined) && (o1.constructor.__implements[o2])) return true; + return false; + }; + + a2j.parseUInt = function(v) { + return Math.abs(parseInt(v)); + } + +})(Box2D); + +//#TODO remove assignments from global namespace +var Vector = Array; +var Vector_a2j_Number = Box2D.NVector; +//package structure +if (typeof(Box2D) === "undefined") Box2D = {}; +if (typeof(Box2D.Collision) === "undefined") Box2D.Collision = {}; +if (typeof(Box2D.Collision.Shapes) === "undefined") Box2D.Collision.Shapes = {}; +if (typeof(Box2D.Common) === "undefined") Box2D.Common = {}; +if (typeof(Box2D.Common.Math) === "undefined") Box2D.Common.Math = {}; +if (typeof(Box2D.Dynamics) === "undefined") Box2D.Dynamics = {}; +if (typeof(Box2D.Dynamics.Contacts) === "undefined") Box2D.Dynamics.Contacts = {}; +if (typeof(Box2D.Dynamics.Controllers) === "undefined") Box2D.Dynamics.Controllers = {}; +if (typeof(Box2D.Dynamics.Joints) === "undefined") Box2D.Dynamics.Joints = {}; +//pre-definitions +(function () { + Box2D.Collision.IBroadPhase = 'Box2D.Collision.IBroadPhase'; + + function b2AABB() { + b2AABB.b2AABB.apply(this, arguments); + }; + Box2D.Collision.b2AABB = b2AABB; + + function b2Bound() { + b2Bound.b2Bound.apply(this, arguments); + }; + Box2D.Collision.b2Bound = b2Bound; + + function b2BoundValues() { + b2BoundValues.b2BoundValues.apply(this, arguments); + if (this.constructor === b2BoundValues) this.b2BoundValues.apply(this, arguments); + }; + Box2D.Collision.b2BoundValues = b2BoundValues; + + function b2Collision() { + b2Collision.b2Collision.apply(this, arguments); + }; + Box2D.Collision.b2Collision = b2Collision; + + function b2ContactID() { + b2ContactID.b2ContactID.apply(this, arguments); + if (this.constructor === b2ContactID) this.b2ContactID.apply(this, arguments); + }; + Box2D.Collision.b2ContactID = b2ContactID; + + function b2ContactPoint() { + b2ContactPoint.b2ContactPoint.apply(this, arguments); + }; + Box2D.Collision.b2ContactPoint = b2ContactPoint; + + function b2Distance() { + b2Distance.b2Distance.apply(this, arguments); + }; + Box2D.Collision.b2Distance = b2Distance; + + function b2DistanceInput() { + b2DistanceInput.b2DistanceInput.apply(this, arguments); + }; + Box2D.Collision.b2DistanceInput = b2DistanceInput; + + function b2DistanceOutput() { + b2DistanceOutput.b2DistanceOutput.apply(this, arguments); + }; + Box2D.Collision.b2DistanceOutput = b2DistanceOutput; + + function b2DistanceProxy() { + b2DistanceProxy.b2DistanceProxy.apply(this, arguments); + }; + Box2D.Collision.b2DistanceProxy = b2DistanceProxy; + + function b2DynamicTree() { + b2DynamicTree.b2DynamicTree.apply(this, arguments); + if (this.constructor === b2DynamicTree) this.b2DynamicTree.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTree = b2DynamicTree; + + function b2DynamicTreeBroadPhase() { + b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreeBroadPhase = b2DynamicTreeBroadPhase; + + function b2DynamicTreeNode() { + b2DynamicTreeNode.b2DynamicTreeNode.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreeNode = b2DynamicTreeNode; + + function b2DynamicTreePair() { + b2DynamicTreePair.b2DynamicTreePair.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreePair = b2DynamicTreePair; + + function b2Manifold() { + b2Manifold.b2Manifold.apply(this, arguments); + if (this.constructor === b2Manifold) this.b2Manifold.apply(this, arguments); + }; + Box2D.Collision.b2Manifold = b2Manifold; + + function b2ManifoldPoint() { + b2ManifoldPoint.b2ManifoldPoint.apply(this, arguments); + if (this.constructor === b2ManifoldPoint) this.b2ManifoldPoint.apply(this, arguments); + }; + Box2D.Collision.b2ManifoldPoint = b2ManifoldPoint; + + function b2Point() { + b2Point.b2Point.apply(this, arguments); + }; + Box2D.Collision.b2Point = b2Point; + + function b2RayCastInput() { + b2RayCastInput.b2RayCastInput.apply(this, arguments); + if (this.constructor === b2RayCastInput) this.b2RayCastInput.apply(this, arguments); + }; + Box2D.Collision.b2RayCastInput = b2RayCastInput; + + function b2RayCastOutput() { + b2RayCastOutput.b2RayCastOutput.apply(this, arguments); + }; + Box2D.Collision.b2RayCastOutput = b2RayCastOutput; + + function b2Segment() { + b2Segment.b2Segment.apply(this, arguments); + }; + Box2D.Collision.b2Segment = b2Segment; + + function b2SeparationFunction() { + b2SeparationFunction.b2SeparationFunction.apply(this, arguments); + }; + Box2D.Collision.b2SeparationFunction = b2SeparationFunction; + + function b2Simplex() { + b2Simplex.b2Simplex.apply(this, arguments); + if (this.constructor === b2Simplex) this.b2Simplex.apply(this, arguments); + }; + Box2D.Collision.b2Simplex = b2Simplex; + + function b2SimplexCache() { + b2SimplexCache.b2SimplexCache.apply(this, arguments); + }; + Box2D.Collision.b2SimplexCache = b2SimplexCache; + + function b2SimplexVertex() { + b2SimplexVertex.b2SimplexVertex.apply(this, arguments); + }; + Box2D.Collision.b2SimplexVertex = b2SimplexVertex; + + function b2TimeOfImpact() { + b2TimeOfImpact.b2TimeOfImpact.apply(this, arguments); + }; + Box2D.Collision.b2TimeOfImpact = b2TimeOfImpact; + + function b2TOIInput() { + b2TOIInput.b2TOIInput.apply(this, arguments); + }; + Box2D.Collision.b2TOIInput = b2TOIInput; + + function b2WorldManifold() { + b2WorldManifold.b2WorldManifold.apply(this, arguments); + if (this.constructor === b2WorldManifold) this.b2WorldManifold.apply(this, arguments); + }; + Box2D.Collision.b2WorldManifold = b2WorldManifold; + + function ClipVertex() { + ClipVertex.ClipVertex.apply(this, arguments); + }; + Box2D.Collision.ClipVertex = ClipVertex; + + function Features() { + Features.Features.apply(this, arguments); + }; + Box2D.Collision.Features = Features; + + function b2CircleShape() { + b2CircleShape.b2CircleShape.apply(this, arguments); + if (this.constructor === b2CircleShape) this.b2CircleShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2CircleShape = b2CircleShape; + + function b2EdgeChainDef() { + b2EdgeChainDef.b2EdgeChainDef.apply(this, arguments); + if (this.constructor === b2EdgeChainDef) this.b2EdgeChainDef.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2EdgeChainDef = b2EdgeChainDef; + + function b2EdgeShape() { + b2EdgeShape.b2EdgeShape.apply(this, arguments); + if (this.constructor === b2EdgeShape) this.b2EdgeShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2EdgeShape = b2EdgeShape; + + function b2MassData() { + b2MassData.b2MassData.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2MassData = b2MassData; + + function b2PolygonShape() { + b2PolygonShape.b2PolygonShape.apply(this, arguments); + if (this.constructor === b2PolygonShape) this.b2PolygonShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2PolygonShape = b2PolygonShape; + + function b2Shape() { + b2Shape.b2Shape.apply(this, arguments); + if (this.constructor === b2Shape) this.b2Shape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2Shape = b2Shape; + Box2D.Common.b2internal = 'Box2D.Common.b2internal'; + + function b2Color() { + b2Color.b2Color.apply(this, arguments); + if (this.constructor === b2Color) this.b2Color.apply(this, arguments); + }; + Box2D.Common.b2Color = b2Color; + + function b2Settings() { + b2Settings.b2Settings.apply(this, arguments); + }; + Box2D.Common.b2Settings = b2Settings; + + function b2Mat22() { + b2Mat22.b2Mat22.apply(this, arguments); + if (this.constructor === b2Mat22) this.b2Mat22.apply(this, arguments); + }; + Box2D.Common.Math.b2Mat22 = b2Mat22; + + function b2Mat33() { + b2Mat33.b2Mat33.apply(this, arguments); + if (this.constructor === b2Mat33) this.b2Mat33.apply(this, arguments); + }; + Box2D.Common.Math.b2Mat33 = b2Mat33; + + function b2Math() { + b2Math.b2Math.apply(this, arguments); + }; + Box2D.Common.Math.b2Math = b2Math; + + function b2Sweep() { + b2Sweep.b2Sweep.apply(this, arguments); + }; + Box2D.Common.Math.b2Sweep = b2Sweep; + + function b2Transform() { + b2Transform.b2Transform.apply(this, arguments); + if (this.constructor === b2Transform) this.b2Transform.apply(this, arguments); + }; + Box2D.Common.Math.b2Transform = b2Transform; + + function b2Vec2() { + b2Vec2.b2Vec2.apply(this, arguments); + if (this.constructor === b2Vec2) this.b2Vec2.apply(this, arguments); + }; + Box2D.Common.Math.b2Vec2 = b2Vec2; + + function b2Vec3() { + b2Vec3.b2Vec3.apply(this, arguments); + if (this.constructor === b2Vec3) this.b2Vec3.apply(this, arguments); + }; + Box2D.Common.Math.b2Vec3 = b2Vec3; + + function b2Body() { + b2Body.b2Body.apply(this, arguments); + if (this.constructor === b2Body) this.b2Body.apply(this, arguments); + }; + Box2D.Dynamics.b2Body = b2Body; + + function b2BodyDef() { + b2BodyDef.b2BodyDef.apply(this, arguments); + if (this.constructor === b2BodyDef) this.b2BodyDef.apply(this, arguments); + }; + Box2D.Dynamics.b2BodyDef = b2BodyDef; + + function b2ContactFilter() { + b2ContactFilter.b2ContactFilter.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactFilter = b2ContactFilter; + + function b2ContactImpulse() { + b2ContactImpulse.b2ContactImpulse.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactImpulse = b2ContactImpulse; + + function b2ContactListener() { + b2ContactListener.b2ContactListener.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactListener = b2ContactListener; + + function b2ContactManager() { + b2ContactManager.b2ContactManager.apply(this, arguments); + if (this.constructor === b2ContactManager) this.b2ContactManager.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactManager = b2ContactManager; + + function b2DebugDraw() { + b2DebugDraw.b2DebugDraw.apply(this, arguments); + if (this.constructor === b2DebugDraw) this.b2DebugDraw.apply(this, arguments); + }; + Box2D.Dynamics.b2DebugDraw = b2DebugDraw; + + function b2DestructionListener() { + b2DestructionListener.b2DestructionListener.apply(this, arguments); + }; + Box2D.Dynamics.b2DestructionListener = b2DestructionListener; + + function b2FilterData() { + b2FilterData.b2FilterData.apply(this, arguments); + }; + Box2D.Dynamics.b2FilterData = b2FilterData; + + function b2Fixture() { + b2Fixture.b2Fixture.apply(this, arguments); + if (this.constructor === b2Fixture) this.b2Fixture.apply(this, arguments); + }; + Box2D.Dynamics.b2Fixture = b2Fixture; + + function b2FixtureDef() { + b2FixtureDef.b2FixtureDef.apply(this, arguments); + if (this.constructor === b2FixtureDef) this.b2FixtureDef.apply(this, arguments); + }; + Box2D.Dynamics.b2FixtureDef = b2FixtureDef; + + function b2Island() { + b2Island.b2Island.apply(this, arguments); + if (this.constructor === b2Island) this.b2Island.apply(this, arguments); + }; + Box2D.Dynamics.b2Island = b2Island; + + function b2TimeStep() { + b2TimeStep.b2TimeStep.apply(this, arguments); + }; + Box2D.Dynamics.b2TimeStep = b2TimeStep; + + function b2World() { + b2World.b2World.apply(this, arguments); + if (this.constructor === b2World) this.b2World.apply(this, arguments); + }; + Box2D.Dynamics.b2World = b2World; + + function b2CircleContact() { + b2CircleContact.b2CircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2CircleContact = b2CircleContact; + + function b2Contact() { + b2Contact.b2Contact.apply(this, arguments); + if (this.constructor === b2Contact) this.b2Contact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2Contact = b2Contact; + + function b2ContactConstraint() { + b2ContactConstraint.b2ContactConstraint.apply(this, arguments); + if (this.constructor === b2ContactConstraint) this.b2ContactConstraint.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactConstraint = b2ContactConstraint; + + function b2ContactConstraintPoint() { + b2ContactConstraintPoint.b2ContactConstraintPoint.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactConstraintPoint = b2ContactConstraintPoint; + + function b2ContactEdge() { + b2ContactEdge.b2ContactEdge.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactEdge = b2ContactEdge; + + function b2ContactFactory() { + b2ContactFactory.b2ContactFactory.apply(this, arguments); + if (this.constructor === b2ContactFactory) this.b2ContactFactory.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactFactory = b2ContactFactory; + + function b2ContactRegister() { + b2ContactRegister.b2ContactRegister.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactRegister = b2ContactRegister; + + function b2ContactResult() { + b2ContactResult.b2ContactResult.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactResult = b2ContactResult; + + function b2ContactSolver() { + b2ContactSolver.b2ContactSolver.apply(this, arguments); + if (this.constructor === b2ContactSolver) this.b2ContactSolver.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactSolver = b2ContactSolver; + + function b2EdgeAndCircleContact() { + b2EdgeAndCircleContact.b2EdgeAndCircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2EdgeAndCircleContact = b2EdgeAndCircleContact; + + function b2NullContact() { + b2NullContact.b2NullContact.apply(this, arguments); + if (this.constructor === b2NullContact) this.b2NullContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2NullContact = b2NullContact; + + function b2PolyAndCircleContact() { + b2PolyAndCircleContact.b2PolyAndCircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolyAndCircleContact = b2PolyAndCircleContact; + + function b2PolyAndEdgeContact() { + b2PolyAndEdgeContact.b2PolyAndEdgeContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolyAndEdgeContact = b2PolyAndEdgeContact; + + function b2PolygonContact() { + b2PolygonContact.b2PolygonContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolygonContact = b2PolygonContact; + + function b2PositionSolverManifold() { + b2PositionSolverManifold.b2PositionSolverManifold.apply(this, arguments); + if (this.constructor === b2PositionSolverManifold) this.b2PositionSolverManifold.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PositionSolverManifold = b2PositionSolverManifold; + + function b2BuoyancyController() { + b2BuoyancyController.b2BuoyancyController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2BuoyancyController = b2BuoyancyController; + + function b2ConstantAccelController() { + b2ConstantAccelController.b2ConstantAccelController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ConstantAccelController = b2ConstantAccelController; + + function b2ConstantForceController() { + b2ConstantForceController.b2ConstantForceController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ConstantForceController = b2ConstantForceController; + + function b2Controller() { + b2Controller.b2Controller.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2Controller = b2Controller; + + function b2ControllerEdge() { + b2ControllerEdge.b2ControllerEdge.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ControllerEdge = b2ControllerEdge; + + function b2GravityController() { + b2GravityController.b2GravityController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2GravityController = b2GravityController; + + function b2TensorDampingController() { + b2TensorDampingController.b2TensorDampingController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2TensorDampingController = b2TensorDampingController; + + function b2DistanceJoint() { + b2DistanceJoint.b2DistanceJoint.apply(this, arguments); + if (this.constructor === b2DistanceJoint) this.b2DistanceJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2DistanceJoint = b2DistanceJoint; + + function b2DistanceJointDef() { + b2DistanceJointDef.b2DistanceJointDef.apply(this, arguments); + if (this.constructor === b2DistanceJointDef) this.b2DistanceJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2DistanceJointDef = b2DistanceJointDef; + + function b2FrictionJoint() { + b2FrictionJoint.b2FrictionJoint.apply(this, arguments); + if (this.constructor === b2FrictionJoint) this.b2FrictionJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2FrictionJoint = b2FrictionJoint; + + function b2FrictionJointDef() { + b2FrictionJointDef.b2FrictionJointDef.apply(this, arguments); + if (this.constructor === b2FrictionJointDef) this.b2FrictionJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2FrictionJointDef = b2FrictionJointDef; + + function b2GearJoint() { + b2GearJoint.b2GearJoint.apply(this, arguments); + if (this.constructor === b2GearJoint) this.b2GearJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2GearJoint = b2GearJoint; + + function b2GearJointDef() { + b2GearJointDef.b2GearJointDef.apply(this, arguments); + if (this.constructor === b2GearJointDef) this.b2GearJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2GearJointDef = b2GearJointDef; + + function b2Jacobian() { + b2Jacobian.b2Jacobian.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2Jacobian = b2Jacobian; + + function b2Joint() { + b2Joint.b2Joint.apply(this, arguments); + if (this.constructor === b2Joint) this.b2Joint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2Joint = b2Joint; + + function b2JointDef() { + b2JointDef.b2JointDef.apply(this, arguments); + if (this.constructor === b2JointDef) this.b2JointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2JointDef = b2JointDef; + + function b2JointEdge() { + b2JointEdge.b2JointEdge.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2JointEdge = b2JointEdge; + + function b2LineJoint() { + b2LineJoint.b2LineJoint.apply(this, arguments); + if (this.constructor === b2LineJoint) this.b2LineJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2LineJoint = b2LineJoint; + + function b2LineJointDef() { + b2LineJointDef.b2LineJointDef.apply(this, arguments); + if (this.constructor === b2LineJointDef) this.b2LineJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2LineJointDef = b2LineJointDef; + + function b2MouseJoint() { + b2MouseJoint.b2MouseJoint.apply(this, arguments); + if (this.constructor === b2MouseJoint) this.b2MouseJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2MouseJoint = b2MouseJoint; + + function b2MouseJointDef() { + b2MouseJointDef.b2MouseJointDef.apply(this, arguments); + if (this.constructor === b2MouseJointDef) this.b2MouseJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2MouseJointDef = b2MouseJointDef; + + function b2PrismaticJoint() { + b2PrismaticJoint.b2PrismaticJoint.apply(this, arguments); + if (this.constructor === b2PrismaticJoint) this.b2PrismaticJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PrismaticJoint = b2PrismaticJoint; + + function b2PrismaticJointDef() { + b2PrismaticJointDef.b2PrismaticJointDef.apply(this, arguments); + if (this.constructor === b2PrismaticJointDef) this.b2PrismaticJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PrismaticJointDef = b2PrismaticJointDef; + + function b2PulleyJoint() { + b2PulleyJoint.b2PulleyJoint.apply(this, arguments); + if (this.constructor === b2PulleyJoint) this.b2PulleyJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PulleyJoint = b2PulleyJoint; + + function b2PulleyJointDef() { + b2PulleyJointDef.b2PulleyJointDef.apply(this, arguments); + if (this.constructor === b2PulleyJointDef) this.b2PulleyJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PulleyJointDef = b2PulleyJointDef; + + function b2RevoluteJoint() { + b2RevoluteJoint.b2RevoluteJoint.apply(this, arguments); + if (this.constructor === b2RevoluteJoint) this.b2RevoluteJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2RevoluteJoint = b2RevoluteJoint; + + function b2RevoluteJointDef() { + b2RevoluteJointDef.b2RevoluteJointDef.apply(this, arguments); + if (this.constructor === b2RevoluteJointDef) this.b2RevoluteJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2RevoluteJointDef = b2RevoluteJointDef; + + function b2WeldJoint() { + b2WeldJoint.b2WeldJoint.apply(this, arguments); + if (this.constructor === b2WeldJoint) this.b2WeldJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2WeldJoint = b2WeldJoint; + + function b2WeldJointDef() { + b2WeldJointDef.b2WeldJointDef.apply(this, arguments); + if (this.constructor === b2WeldJointDef) this.b2WeldJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2WeldJointDef = b2WeldJointDef; +})(); //definitions +Box2D.postDefs = []; +(function () { + var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + b2AABB.b2AABB = function () { + this.lowerBound = new b2Vec2(); + this.upperBound = new b2Vec2(); + }; + b2AABB.prototype.IsValid = function () { + var dX = this.upperBound.x - this.lowerBound.x; + var dY = this.upperBound.y - this.lowerBound.y; + var valid = dX >= 0.0 && dY >= 0.0; + valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid(); + return valid; + } + b2AABB.prototype.GetCenter = function () { + return new b2Vec2((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2); + } + b2AABB.prototype.GetExtents = function () { + return new b2Vec2((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2); + } + b2AABB.prototype.Contains = function (aabb) { + var result = true; + result = result && this.lowerBound.x <= aabb.lowerBound.x; + result = result && this.lowerBound.y <= aabb.lowerBound.y; + result = result && aabb.upperBound.x <= this.upperBound.x; + result = result && aabb.upperBound.y <= this.upperBound.y; + return result; + } + b2AABB.prototype.RayCast = function (output, input) { + var tmin = (-Number.MAX_VALUE); + var tmax = Number.MAX_VALUE; + var pX = input.p1.x; + var pY = input.p1.y; + var dX = input.p2.x - input.p1.x; + var dY = input.p2.y - input.p1.y; + var absDX = Math.abs(dX); + var absDY = Math.abs(dY); + var normal = output.normal; + var inv_d = 0; + var t1 = 0; + var t2 = 0; + var t3 = 0; + var s = 0; { + if (absDX < Number.MIN_VALUE) { + if (pX < this.lowerBound.x || this.upperBound.x < pX) return false; + } + else { + inv_d = 1.0 / dX; + t1 = (this.lowerBound.x - pX) * inv_d; + t2 = (this.upperBound.x - pX) * inv_d; + s = (-1.0); + if (t1 > t2) { + t3 = t1; + t1 = t2; + t2 = t3; + s = 1.0; + } + if (t1 > tmin) { + normal.x = s; + normal.y = 0; + tmin = t1; + } + tmax = Math.min(tmax, t2); + if (tmin > tmax) return false; + } + } { + if (absDY < Number.MIN_VALUE) { + if (pY < this.lowerBound.y || this.upperBound.y < pY) return false; + } + else { + inv_d = 1.0 / dY; + t1 = (this.lowerBound.y - pY) * inv_d; + t2 = (this.upperBound.y - pY) * inv_d; + s = (-1.0); + if (t1 > t2) { + t3 = t1; + t1 = t2; + t2 = t3; + s = 1.0; + } + if (t1 > tmin) { + normal.y = s; + normal.x = 0; + tmin = t1; + } + tmax = Math.min(tmax, t2); + if (tmin > tmax) return false; + } + } + output.fraction = tmin; + return true; + } + b2AABB.prototype.TestOverlap = function (other) { + var d1X = other.lowerBound.x - this.upperBound.x; + var d1Y = other.lowerBound.y - this.upperBound.y; + var d2X = this.lowerBound.x - other.upperBound.x; + var d2Y = this.lowerBound.y - other.upperBound.y; + if (d1X > 0.0 || d1Y > 0.0) return false; + if (d2X > 0.0 || d2Y > 0.0) return false; + return true; + } + b2AABB.Combine = function (aabb1, aabb2) { + var aabb = new b2AABB(); + aabb.Combine(aabb1, aabb2); + return aabb; + } + b2AABB.prototype.Combine = function (aabb1, aabb2) { + this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x); + this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y); + this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x); + this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y); + } + b2Bound.b2Bound = function () {}; + b2Bound.prototype.IsLower = function () { + return (this.value & 1) == 0; + } + b2Bound.prototype.IsUpper = function () { + return (this.value & 1) == 1; + } + b2Bound.prototype.Swap = function (b) { + var tempValue = this.value; + var tempProxy = this.proxy; + var tempStabbingCount = this.stabbingCount; + this.value = b.value; + this.proxy = b.proxy; + this.stabbingCount = b.stabbingCount; + b.value = tempValue; + b.proxy = tempProxy; + b.stabbingCount = tempStabbingCount; + } + b2BoundValues.b2BoundValues = function () {}; + b2BoundValues.prototype.b2BoundValues = function () { + this.lowerValues = new Vector_a2j_Number(); + this.lowerValues[0] = 0.0; + this.lowerValues[1] = 0.0; + this.upperValues = new Vector_a2j_Number(); + this.upperValues[0] = 0.0; + this.upperValues[1] = 0.0; + } + b2Collision.b2Collision = function () {}; + b2Collision.ClipSegmentToLine = function (vOut, vIn, normal, offset) { + if (offset === undefined) offset = 0; + var cv; + var numOut = 0; + cv = vIn[0]; + var vIn0 = cv.v; + cv = vIn[1]; + var vIn1 = cv.v; + var distance0 = normal.x * vIn0.x + normal.y * vIn0.y - offset; + var distance1 = normal.x * vIn1.x + normal.y * vIn1.y - offset; + if (distance0 <= 0.0) vOut[numOut++].Set(vIn[0]); + if (distance1 <= 0.0) vOut[numOut++].Set(vIn[1]); + if (distance0 * distance1 < 0.0) { + var interp = distance0 / (distance0 - distance1); + cv = vOut[numOut]; + var tVec = cv.v; + tVec.x = vIn0.x + interp * (vIn1.x - vIn0.x); + tVec.y = vIn0.y + interp * (vIn1.y - vIn0.y); + cv = vOut[numOut]; + var cv2; + if (distance0 > 0.0) { + cv2 = vIn[0]; + cv.id = cv2.id; + } + else { + cv2 = vIn[1]; + cv.id = cv2.id; + }++numOut; + } + return numOut; + } + b2Collision.EdgeSeparation = function (poly1, xf1, edge1, poly2, xf2) { + if (edge1 === undefined) edge1 = 0; + var count1 = parseInt(poly1.m_vertexCount); + var vertices1 = poly1.m_vertices; + var normals1 = poly1.m_normals; + var count2 = parseInt(poly2.m_vertexCount); + var vertices2 = poly2.m_vertices; + var tMat; + var tVec; + tMat = xf1.R; + tVec = normals1[edge1]; + var normal1WorldX = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var normal1WorldY = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + var normal1X = (tMat.col1.x * normal1WorldX + tMat.col1.y * normal1WorldY); + var normal1Y = (tMat.col2.x * normal1WorldX + tMat.col2.y * normal1WorldY); + var index = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) { + tVec = vertices2[i]; + var dot = tVec.x * normal1X + tVec.y * normal1Y; + if (dot < minDot) { + minDot = dot; + index = i; + } + } + tVec = vertices1[edge1]; + tMat = xf1.R; + var v1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var v1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = vertices2[index]; + tMat = xf2.R; + var v2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var v2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + v2X -= v1X; + v2Y -= v1Y; + var separation = v2X * normal1WorldX + v2Y * normal1WorldY; + return separation; + } + b2Collision.FindMaxSeparation = function (edgeIndex, poly1, xf1, poly2, xf2) { + var count1 = parseInt(poly1.m_vertexCount); + var normals1 = poly1.m_normals; + var tVec; + var tMat; + tMat = xf2.R; + tVec = poly2.m_centroid; + var dX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var dY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf1.R; + tVec = poly1.m_centroid; + dX -= xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + dY -= xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dLocal1X = (dX * xf1.R.col1.x + dY * xf1.R.col1.y); + var dLocal1Y = (dX * xf1.R.col2.x + dY * xf1.R.col2.y); + var edge = 0; + var maxDot = (-Number.MAX_VALUE); + for (var i = 0; i < count1; ++i) { + tVec = normals1[i]; + var dot = (tVec.x * dLocal1X + tVec.y * dLocal1Y); + if (dot > maxDot) { + maxDot = dot; + edge = i; + } + } + var s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); + var prevEdge = parseInt(edge - 1 >= 0 ? edge - 1 : count1 - 1); + var sPrev = b2Collision.EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2); + var nextEdge = parseInt(edge + 1 < count1 ? edge + 1 : 0); + var sNext = b2Collision.EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2); + var bestEdge = 0; + var bestSeparation = 0; + var increment = 0; + if (sPrev > s && sPrev > sNext) { + increment = (-1); + bestEdge = prevEdge; + bestSeparation = sPrev; + } + else if (sNext > s) { + increment = 1; + bestEdge = nextEdge; + bestSeparation = sNext; + } + else { + edgeIndex[0] = edge; + return s; + } + while (true) { + if (increment == (-1)) edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1; + else edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); + if (s > bestSeparation) { + bestEdge = edge; + bestSeparation = s; + } + else { + break; + } + } + edgeIndex[0] = bestEdge; + return bestSeparation; + } + b2Collision.FindIncidentEdge = function (c, poly1, xf1, edge1, poly2, xf2) { + if (edge1 === undefined) edge1 = 0; + var count1 = parseInt(poly1.m_vertexCount); + var normals1 = poly1.m_normals; + var count2 = parseInt(poly2.m_vertexCount); + var vertices2 = poly2.m_vertices; + var normals2 = poly2.m_normals; + var tMat; + var tVec; + tMat = xf1.R; + tVec = normals1[edge1]; + var normal1X = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var normal1Y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + var tX = (tMat.col1.x * normal1X + tMat.col1.y * normal1Y); + normal1Y = (tMat.col2.x * normal1X + tMat.col2.y * normal1Y); + normal1X = tX; + var index = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) { + tVec = normals2[i]; + var dot = (normal1X * tVec.x + normal1Y * tVec.y); + if (dot < minDot) { + minDot = dot; + index = i; + } + } + var tClip; + var i1 = parseInt(index); + var i2 = parseInt(i1 + 1 < count2 ? i1 + 1 : 0); + tClip = c[0]; + tVec = vertices2[i1]; + tMat = xf2.R; + tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tClip.id.features.referenceEdge = edge1; + tClip.id.features.incidentEdge = i1; + tClip.id.features.incidentVertex = 0; + tClip = c[1]; + tVec = vertices2[i2]; + tMat = xf2.R; + tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tClip.id.features.referenceEdge = edge1; + tClip.id.features.incidentEdge = i2; + tClip.id.features.incidentVertex = 1; + } + b2Collision.MakeClipPointVector = function () { + var r = new Vector(2); + r[0] = new ClipVertex(); + r[1] = new ClipVertex(); + return r; + } + b2Collision.CollidePolygons = function (manifold, polyA, xfA, polyB, xfB) { + var cv; + manifold.m_pointCount = 0; + var totalRadius = polyA.m_radius + polyB.m_radius; + var edgeA = 0; + b2Collision.s_edgeAO[0] = edgeA; + var separationA = b2Collision.FindMaxSeparation(b2Collision.s_edgeAO, polyA, xfA, polyB, xfB); + edgeA = b2Collision.s_edgeAO[0]; + if (separationA > totalRadius) return; + var edgeB = 0; + b2Collision.s_edgeBO[0] = edgeB; + var separationB = b2Collision.FindMaxSeparation(b2Collision.s_edgeBO, polyB, xfB, polyA, xfA); + edgeB = b2Collision.s_edgeBO[0]; + if (separationB > totalRadius) return; + var poly1; + var poly2; + var xf1; + var xf2; + var edge1 = 0; + var flip = 0; + var k_relativeTol = 0.98; + var k_absoluteTol = 0.001; + var tMat; + if (separationB > k_relativeTol * separationA + k_absoluteTol) { + poly1 = polyB; + poly2 = polyA; + xf1 = xfB; + xf2 = xfA; + edge1 = edgeB; + manifold.m_type = b2Manifold.e_faceB; + flip = 1; + } + else { + poly1 = polyA; + poly2 = polyB; + xf1 = xfA; + xf2 = xfB; + edge1 = edgeA; + manifold.m_type = b2Manifold.e_faceA; + flip = 0; + } + var incidentEdge = b2Collision.s_incidentEdge; + b2Collision.FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); + var count1 = parseInt(poly1.m_vertexCount); + var vertices1 = poly1.m_vertices; + var local_v11 = vertices1[edge1]; + var local_v12; + if (edge1 + 1 < count1) { + local_v12 = vertices1[parseInt(edge1 + 1)]; + } + else { + local_v12 = vertices1[0]; + } + var localTangent = b2Collision.s_localTangent; + localTangent.Set(local_v12.x - local_v11.x, local_v12.y - local_v11.y); + localTangent.Normalize(); + var localNormal = b2Collision.s_localNormal; + localNormal.x = localTangent.y; + localNormal.y = (-localTangent.x); + var planePoint = b2Collision.s_planePoint; + planePoint.Set(0.5 * (local_v11.x + local_v12.x), 0.5 * (local_v11.y + local_v12.y)); + var tangent = b2Collision.s_tangent; + tMat = xf1.R; + tangent.x = (tMat.col1.x * localTangent.x + tMat.col2.x * localTangent.y); + tangent.y = (tMat.col1.y * localTangent.x + tMat.col2.y * localTangent.y); + var tangent2 = b2Collision.s_tangent2; + tangent2.x = (-tangent.x); + tangent2.y = (-tangent.y); + var normal = b2Collision.s_normal; + normal.x = tangent.y; + normal.y = (-tangent.x); + var v11 = b2Collision.s_v11; + var v12 = b2Collision.s_v12; + v11.x = xf1.position.x + (tMat.col1.x * local_v11.x + tMat.col2.x * local_v11.y); + v11.y = xf1.position.y + (tMat.col1.y * local_v11.x + tMat.col2.y * local_v11.y); + v12.x = xf1.position.x + (tMat.col1.x * local_v12.x + tMat.col2.x * local_v12.y); + v12.y = xf1.position.y + (tMat.col1.y * local_v12.x + tMat.col2.y * local_v12.y); + var frontOffset = normal.x * v11.x + normal.y * v11.y; + var sideOffset1 = (-tangent.x * v11.x) - tangent.y * v11.y + totalRadius; + var sideOffset2 = tangent.x * v12.x + tangent.y * v12.y + totalRadius; + var clipPoints1 = b2Collision.s_clipPoints1; + var clipPoints2 = b2Collision.s_clipPoints2; + var np = 0; + np = b2Collision.ClipSegmentToLine(clipPoints1, incidentEdge, tangent2, sideOffset1); + if (np < 2) return; + np = b2Collision.ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2); + if (np < 2) return; + manifold.m_localPlaneNormal.SetV(localNormal); + manifold.m_localPoint.SetV(planePoint); + var pointCount = 0; + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; ++i) { + cv = clipPoints2[i]; + var separation = normal.x * cv.v.x + normal.y * cv.v.y - frontOffset; + if (separation <= totalRadius) { + var cp = manifold.m_points[pointCount]; + tMat = xf2.R; + var tX = cv.v.x - xf2.position.x; + var tY = cv.v.y - xf2.position.y; + cp.m_localPoint.x = (tX * tMat.col1.x + tY * tMat.col1.y); + cp.m_localPoint.y = (tX * tMat.col2.x + tY * tMat.col2.y); + cp.m_id.Set(cv.id); + cp.m_id.features.flip = flip; + ++pointCount; + } + } + manifold.m_pointCount = pointCount; + } + b2Collision.CollideCircles = function (manifold, circle1, xf1, circle2, xf2) { + manifold.m_pointCount = 0; + var tMat; + var tVec; + tMat = xf1.R; + tVec = circle1.m_p; + var p1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var p1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + tVec = circle2.m_p; + var p2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var p2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var distSqr = dX * dX + dY * dY; + var radius = circle1.m_radius + circle2.m_radius; + if (distSqr > radius * radius) { + return; + } + manifold.m_type = b2Manifold.e_circles; + manifold.m_localPoint.SetV(circle1.m_p); + manifold.m_localPlaneNormal.SetZero(); + manifold.m_pointCount = 1; + manifold.m_points[0].m_localPoint.SetV(circle2.m_p); + manifold.m_points[0].m_id.key = 0; + } + b2Collision.CollidePolygonAndCircle = function (manifold, polygon, xf1, circle, xf2) { + manifold.m_pointCount = 0; + var tPoint; + var dX = 0; + var dY = 0; + var positionX = 0; + var positionY = 0; + var tVec; + var tMat; + tMat = xf2.R; + tVec = circle.m_p; + var cX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var cY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + dX = cX - xf1.position.x; + dY = cY - xf1.position.y; + tMat = xf1.R; + var cLocalX = (dX * tMat.col1.x + dY * tMat.col1.y); + var cLocalY = (dX * tMat.col2.x + dY * tMat.col2.y); + var dist = 0; + var normalIndex = 0; + var separation = (-Number.MAX_VALUE); + var radius = polygon.m_radius + circle.m_radius; + var vertexCount = parseInt(polygon.m_vertexCount); + var vertices = polygon.m_vertices; + var normals = polygon.m_normals; + for (var i = 0; i < vertexCount; ++i) { + tVec = vertices[i]; + dX = cLocalX - tVec.x; + dY = cLocalY - tVec.y; + tVec = normals[i]; + var s = tVec.x * dX + tVec.y * dY; + if (s > radius) { + return; + } + if (s > separation) { + separation = s; + normalIndex = i; + } + } + var vertIndex1 = parseInt(normalIndex); + var vertIndex2 = parseInt(vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0); + var v1 = vertices[vertIndex1]; + var v2 = vertices[vertIndex2]; + if (separation < Number.MIN_VALUE) { + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.SetV(normals[normalIndex]); + manifold.m_localPoint.x = 0.5 * (v1.x + v2.x); + manifold.m_localPoint.y = 0.5 * (v1.y + v2.y); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + return; + } + var u1 = (cLocalX - v1.x) * (v2.x - v1.x) + (cLocalY - v1.y) * (v2.y - v1.y); + var u2 = (cLocalX - v2.x) * (v1.x - v2.x) + (cLocalY - v2.y) * (v1.y - v2.y); + if (u1 <= 0.0) { + if ((cLocalX - v1.x) * (cLocalX - v1.x) + (cLocalY - v1.y) * (cLocalY - v1.y) > radius * radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = cLocalX - v1.x; + manifold.m_localPlaneNormal.y = cLocalY - v1.y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.SetV(v1); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + else if (u2 <= 0) { + if ((cLocalX - v2.x) * (cLocalX - v2.x) + (cLocalY - v2.y) * (cLocalY - v2.y) > radius * radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = cLocalX - v2.x; + manifold.m_localPlaneNormal.y = cLocalY - v2.y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.SetV(v2); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + else { + var faceCenterX = 0.5 * (v1.x + v2.x); + var faceCenterY = 0.5 * (v1.y + v2.y); + separation = (cLocalX - faceCenterX) * normals[vertIndex1].x + (cLocalY - faceCenterY) * normals[vertIndex1].y; + if (separation > radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = normals[vertIndex1].x; + manifold.m_localPlaneNormal.y = normals[vertIndex1].y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.Set(faceCenterX, faceCenterY); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + } + b2Collision.TestOverlap = function (a, b) { + var t1 = b.lowerBound; + var t2 = a.upperBound; + var d1X = t1.x - t2.x; + var d1Y = t1.y - t2.y; + t1 = a.lowerBound; + t2 = b.upperBound; + var d2X = t1.x - t2.x; + var d2Y = t1.y - t2.y; + if (d1X > 0.0 || d1Y > 0.0) return false; + if (d2X > 0.0 || d2Y > 0.0) return false; + return true; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Collision.s_incidentEdge = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_clipPoints1 = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_clipPoints2 = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_edgeAO = new Vector_a2j_Number(1); + Box2D.Collision.b2Collision.s_edgeBO = new Vector_a2j_Number(1); + Box2D.Collision.b2Collision.s_localTangent = new b2Vec2(); + Box2D.Collision.b2Collision.s_localNormal = new b2Vec2(); + Box2D.Collision.b2Collision.s_planePoint = new b2Vec2(); + Box2D.Collision.b2Collision.s_normal = new b2Vec2(); + Box2D.Collision.b2Collision.s_tangent = new b2Vec2(); + Box2D.Collision.b2Collision.s_tangent2 = new b2Vec2(); + Box2D.Collision.b2Collision.s_v11 = new b2Vec2(); + Box2D.Collision.b2Collision.s_v12 = new b2Vec2(); + Box2D.Collision.b2Collision.b2CollidePolyTempVec = new b2Vec2(); + Box2D.Collision.b2Collision.b2_nullFeature = 0x000000ff; + }); + b2ContactID.b2ContactID = function () { + this.features = new Features(); + }; + b2ContactID.prototype.b2ContactID = function () { + this.features._m_id = this; + } + b2ContactID.prototype.Set = function (id) { + this.key = id._key; + } + b2ContactID.prototype.Copy = function () { + var id = new b2ContactID(); + id.key = this.key; + return id; + } + Object.defineProperty(b2ContactID.prototype, 'key', { + enumerable: false, + configurable: true, + get: function () { + return this._key; + } + }); + Object.defineProperty(b2ContactID.prototype, 'key', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._key = value; + this.features._referenceEdge = this._key & 0x000000ff; + this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff; + this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff; + this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff; + } + }); + b2ContactPoint.b2ContactPoint = function () { + this.position = new b2Vec2(); + this.velocity = new b2Vec2(); + this.normal = new b2Vec2(); + this.id = new b2ContactID(); + }; + b2Distance.b2Distance = function () {}; + b2Distance.Distance = function (output, cache, input) { + ++b2Distance.b2_gjkCalls; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var transformA = input.transformA; + var transformB = input.transformB; + var simplex = b2Distance.s_simplex; + simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB); + var vertices = simplex.m_vertices; + var k_maxIters = 20; + var saveA = b2Distance.s_saveA; + var saveB = b2Distance.s_saveB; + var saveCount = 0; + var closestPoint = simplex.GetClosestPoint(); + var distanceSqr1 = closestPoint.LengthSquared(); + var distanceSqr2 = distanceSqr1; + var i = 0; + var p; + var iter = 0; + while (iter < k_maxIters) { + saveCount = simplex.m_count; + for (i = 0; + i < saveCount; i++) { + saveA[i] = vertices[i].indexA; + saveB[i] = vertices[i].indexB; + } + switch (simplex.m_count) { + case 1: + break; + case 2: + simplex.Solve2(); + break; + case 3: + simplex.Solve3(); + break; + default: + b2Settings.b2Assert(false); + } + if (simplex.m_count == 3) { + break; + } + p = simplex.GetClosestPoint(); + distanceSqr2 = p.LengthSquared(); + if (distanceSqr2 > distanceSqr1) {} + distanceSqr1 = distanceSqr2; + var d = simplex.GetSearchDirection(); + if (d.LengthSquared() < Number.MIN_VALUE * Number.MIN_VALUE) { + break; + } + var vertex = vertices[simplex.m_count]; + vertex.indexA = proxyA.GetSupport(b2Math.MulTMV(transformA.R, d.GetNegative())); + vertex.wA = b2Math.MulX(transformA, proxyA.GetVertex(vertex.indexA)); + vertex.indexB = proxyB.GetSupport(b2Math.MulTMV(transformB.R, d)); + vertex.wB = b2Math.MulX(transformB, proxyB.GetVertex(vertex.indexB)); + vertex.w = b2Math.SubtractVV(vertex.wB, vertex.wA); + ++iter; + ++b2Distance.b2_gjkIters; + var duplicate = false; + for (i = 0; + i < saveCount; i++) { + if (vertex.indexA == saveA[i] && vertex.indexB == saveB[i]) { + duplicate = true; + break; + } + } + if (duplicate) { + break; + }++simplex.m_count; + } + b2Distance.b2_gjkMaxIters = b2Math.Max(b2Distance.b2_gjkMaxIters, iter); + simplex.GetWitnessPoints(output.pointA, output.pointB); + output.distance = b2Math.SubtractVV(output.pointA, output.pointB).Length(); + output.iterations = iter; + simplex.WriteCache(cache); + if (input.useRadii) { + var rA = proxyA.m_radius; + var rB = proxyB.m_radius; + if (output.distance > rA + rB && output.distance > Number.MIN_VALUE) { + output.distance -= rA + rB; + var normal = b2Math.SubtractVV(output.pointB, output.pointA); + normal.Normalize(); + output.pointA.x += rA * normal.x; + output.pointA.y += rA * normal.y; + output.pointB.x -= rB * normal.x; + output.pointB.y -= rB * normal.y; + } + else { + p = new b2Vec2(); + p.x = .5 * (output.pointA.x + output.pointB.x); + p.y = .5 * (output.pointA.y + output.pointB.y); + output.pointA.x = output.pointB.x = p.x; + output.pointA.y = output.pointB.y = p.y; + output.distance = 0.0; + } + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Distance.s_simplex = new b2Simplex(); + Box2D.Collision.b2Distance.s_saveA = new Vector_a2j_Number(3); + Box2D.Collision.b2Distance.s_saveB = new Vector_a2j_Number(3); + }); + b2DistanceInput.b2DistanceInput = function () {}; + b2DistanceOutput.b2DistanceOutput = function () { + this.pointA = new b2Vec2(); + this.pointB = new b2Vec2(); + }; + b2DistanceProxy.b2DistanceProxy = function () {}; + b2DistanceProxy.prototype.Set = function (shape) { + switch (shape.GetType()) { + case b2Shape.e_circleShape: + { + var circle = (shape instanceof b2CircleShape ? shape : null); + this.m_vertices = new Vector(1, true); + this.m_vertices[0] = circle.m_p; + this.m_count = 1; + this.m_radius = circle.m_radius; + } + break; + case b2Shape.e_polygonShape: + { + var polygon = (shape instanceof b2PolygonShape ? shape : null); + this.m_vertices = polygon.m_vertices; + this.m_count = polygon.m_vertexCount; + this.m_radius = polygon.m_radius; + } + break; + default: + b2Settings.b2Assert(false); + } + } + b2DistanceProxy.prototype.GetSupport = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_count; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return bestIndex; + } + b2DistanceProxy.prototype.GetSupportVertex = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_count; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return this.m_vertices[bestIndex]; + } + b2DistanceProxy.prototype.GetVertexCount = function () { + return this.m_count; + } + b2DistanceProxy.prototype.GetVertex = function (index) { + if (index === undefined) index = 0; + b2Settings.b2Assert(0 <= index && index < this.m_count); + return this.m_vertices[index]; + } + b2DynamicTree.b2DynamicTree = function () {}; + b2DynamicTree.prototype.b2DynamicTree = function () { + this.m_root = null; + this.m_freeList = null; + this.m_path = 0; + this.m_insertionCount = 0; + } + b2DynamicTree.prototype.CreateProxy = function (aabb, userData) { + var node = this.AllocateNode(); + var extendX = b2Settings.b2_aabbExtension; + var extendY = b2Settings.b2_aabbExtension; + node.aabb.lowerBound.x = aabb.lowerBound.x - extendX; + node.aabb.lowerBound.y = aabb.lowerBound.y - extendY; + node.aabb.upperBound.x = aabb.upperBound.x + extendX; + node.aabb.upperBound.y = aabb.upperBound.y + extendY; + node.userData = userData; + this.InsertLeaf(node); + return node; + } + b2DynamicTree.prototype.DestroyProxy = function (proxy) { + this.RemoveLeaf(proxy); + this.FreeNode(proxy); + } + b2DynamicTree.prototype.MoveProxy = function (proxy, aabb, displacement) { + b2Settings.b2Assert(proxy.IsLeaf()); + if (proxy.aabb.Contains(aabb)) { + return false; + } + this.RemoveLeaf(proxy); + var extendX = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.x > 0 ? displacement.x : (-displacement.x)); + var extendY = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.y > 0 ? displacement.y : (-displacement.y)); + proxy.aabb.lowerBound.x = aabb.lowerBound.x - extendX; + proxy.aabb.lowerBound.y = aabb.lowerBound.y - extendY; + proxy.aabb.upperBound.x = aabb.upperBound.x + extendX; + proxy.aabb.upperBound.y = aabb.upperBound.y + extendY; + this.InsertLeaf(proxy); + return true; + } + b2DynamicTree.prototype.Rebalance = function (iterations) { + if (iterations === undefined) iterations = 0; + if (this.m_root == null) return; + for (var i = 0; i < iterations; i++) { + var node = this.m_root; + var bit = 0; + while (node.IsLeaf() == false) { + node = (this.m_path >> bit) & 1 ? node.child2 : node.child1; + bit = (bit + 1) & 31; + }++this.m_path; + this.RemoveLeaf(node); + this.InsertLeaf(node); + } + } + b2DynamicTree.prototype.GetFatAABB = function (proxy) { + return proxy.aabb; + } + b2DynamicTree.prototype.GetUserData = function (proxy) { + return proxy.userData; + } + b2DynamicTree.prototype.Query = function (callback, aabb) { + if (this.m_root == null) return; + var stack = new Vector(); + var count = 0; + stack[count++] = this.m_root; + while (count > 0) { + var node = stack[--count]; + if (node.aabb.TestOverlap(aabb)) { + if (node.IsLeaf()) { + var proceed = callback(node); + if (!proceed) return; + } + else { + stack[count++] = node.child1; + stack[count++] = node.child2; + } + } + } + } + b2DynamicTree.prototype.RayCast = function (callback, input) { + if (this.m_root == null) return; + var p1 = input.p1; + var p2 = input.p2; + var r = b2Math.SubtractVV(p1, p2); + r.Normalize(); + var v = b2Math.CrossFV(1.0, r); + var abs_v = b2Math.AbsV(v); + var maxFraction = input.maxFraction; + var segmentAABB = new b2AABB(); + var tX = 0; + var tY = 0; { + tX = p1.x + maxFraction * (p2.x - p1.x); + tY = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = Math.min(p1.x, tX); + segmentAABB.lowerBound.y = Math.min(p1.y, tY); + segmentAABB.upperBound.x = Math.max(p1.x, tX); + segmentAABB.upperBound.y = Math.max(p1.y, tY); + } + var stack = new Vector(); + var count = 0; + stack[count++] = this.m_root; + while (count > 0) { + var node = stack[--count]; + if (node.aabb.TestOverlap(segmentAABB) == false) { + continue; + } + var c = node.aabb.GetCenter(); + var h = node.aabb.GetExtents(); + var separation = Math.abs(v.x * (p1.x - c.x) + v.y * (p1.y - c.y)) - abs_v.x * h.x - abs_v.y * h.y; + if (separation > 0.0) continue; + if (node.IsLeaf()) { + var subInput = new b2RayCastInput(); + subInput.p1 = input.p1; + subInput.p2 = input.p2; + subInput.maxFraction = input.maxFraction; + maxFraction = callback(subInput, node); + if (maxFraction == 0.0) return; + if (maxFraction > 0.0) { + tX = p1.x + maxFraction * (p2.x - p1.x); + tY = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = Math.min(p1.x, tX); + segmentAABB.lowerBound.y = Math.min(p1.y, tY); + segmentAABB.upperBound.x = Math.max(p1.x, tX); + segmentAABB.upperBound.y = Math.max(p1.y, tY); + } + } + else { + stack[count++] = node.child1; + stack[count++] = node.child2; + } + } + } + b2DynamicTree.prototype.AllocateNode = function () { + if (this.m_freeList) { + var node = this.m_freeList; + this.m_freeList = node.parent; + node.parent = null; + node.child1 = null; + node.child2 = null; + return node; + } + return new b2DynamicTreeNode(); + } + b2DynamicTree.prototype.FreeNode = function (node) { + node.parent = this.m_freeList; + this.m_freeList = node; + } + b2DynamicTree.prototype.InsertLeaf = function (leaf) { + ++this.m_insertionCount; + if (this.m_root == null) { + this.m_root = leaf; + this.m_root.parent = null; + return; + } + var center = leaf.aabb.GetCenter(); + var sibling = this.m_root; + if (sibling.IsLeaf() == false) { + do { + var child1 = sibling.child1; + var child2 = sibling.child2; + var norm1 = Math.abs((child1.aabb.lowerBound.x + child1.aabb.upperBound.x) / 2 - center.x) + Math.abs((child1.aabb.lowerBound.y + child1.aabb.upperBound.y) / 2 - center.y); + var norm2 = Math.abs((child2.aabb.lowerBound.x + child2.aabb.upperBound.x) / 2 - center.x) + Math.abs((child2.aabb.lowerBound.y + child2.aabb.upperBound.y) / 2 - center.y); + if (norm1 < norm2) { + sibling = child1; + } + else { + sibling = child2; + } + } + while (sibling.IsLeaf() == false) + } + var node1 = sibling.parent; + var node2 = this.AllocateNode(); + node2.parent = node1; + node2.userData = null; + node2.aabb.Combine(leaf.aabb, sibling.aabb); + if (node1) { + if (sibling.parent.child1 == sibling) { + node1.child1 = node2; + } + else { + node1.child2 = node2; + } + node2.child1 = sibling; + node2.child2 = leaf; + sibling.parent = node2; + leaf.parent = node2; + do { + if (node1.aabb.Contains(node2.aabb)) break; + node1.aabb.Combine(node1.child1.aabb, node1.child2.aabb); + node2 = node1; + node1 = node1.parent; + } + while (node1) + } + else { + node2.child1 = sibling; + node2.child2 = leaf; + sibling.parent = node2; + leaf.parent = node2; + this.m_root = node2; + } + } + b2DynamicTree.prototype.RemoveLeaf = function (leaf) { + if (leaf == this.m_root) { + this.m_root = null; + return; + } + var node2 = leaf.parent; + var node1 = node2.parent; + var sibling; + if (node2.child1 == leaf) { + sibling = node2.child2; + } + else { + sibling = node2.child1; + } + if (node1) { + if (node1.child1 == node2) { + node1.child1 = sibling; + } + else { + node1.child2 = sibling; + } + sibling.parent = node1; + this.FreeNode(node2); + while (node1) { + var oldAABB = node1.aabb; + node1.aabb = b2AABB.Combine(node1.child1.aabb, node1.child2.aabb); + if (oldAABB.Contains(node1.aabb)) break; + node1 = node1.parent; + } + } + else { + this.m_root = sibling; + sibling.parent = null; + this.FreeNode(node2); + } + } + b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase = function () { + this.m_tree = new b2DynamicTree(); + this.m_moveBuffer = new Vector(); + this.m_pairBuffer = new Vector(); + this.m_pairCount = 0; + }; + b2DynamicTreeBroadPhase.prototype.CreateProxy = function (aabb, userData) { + var proxy = this.m_tree.CreateProxy(aabb, userData); + ++this.m_proxyCount; + this.BufferMove(proxy); + return proxy; + } + b2DynamicTreeBroadPhase.prototype.DestroyProxy = function (proxy) { + this.UnBufferMove(proxy); + --this.m_proxyCount; + this.m_tree.DestroyProxy(proxy); + } + b2DynamicTreeBroadPhase.prototype.MoveProxy = function (proxy, aabb, displacement) { + var buffer = this.m_tree.MoveProxy(proxy, aabb, displacement); + if (buffer) { + this.BufferMove(proxy); + } + } + b2DynamicTreeBroadPhase.prototype.TestOverlap = function (proxyA, proxyB) { + var aabbA = this.m_tree.GetFatAABB(proxyA); + var aabbB = this.m_tree.GetFatAABB(proxyB); + return aabbA.TestOverlap(aabbB); + } + b2DynamicTreeBroadPhase.prototype.GetUserData = function (proxy) { + return this.m_tree.GetUserData(proxy); + } + b2DynamicTreeBroadPhase.prototype.GetFatAABB = function (proxy) { + return this.m_tree.GetFatAABB(proxy); + } + b2DynamicTreeBroadPhase.prototype.GetProxyCount = function () { + return this.m_proxyCount; + } + b2DynamicTreeBroadPhase.prototype.UpdatePairs = function (callback) { + var __this = this; + __this.m_pairCount = 0; + var i = 0, + queryProxy; + for (i = 0; + i < __this.m_moveBuffer.length; ++i) { + queryProxy = __this.m_moveBuffer[i]; + + function QueryCallback(proxy) { + if (proxy == queryProxy) return true; + if (__this.m_pairCount == __this.m_pairBuffer.length) { + __this.m_pairBuffer[__this.m_pairCount] = new b2DynamicTreePair(); + } + var pair = __this.m_pairBuffer[__this.m_pairCount]; + pair.proxyA = proxy < queryProxy ? proxy : queryProxy; + pair.proxyB = proxy >= queryProxy ? proxy : queryProxy;++__this.m_pairCount; + return true; + }; + var fatAABB = __this.m_tree.GetFatAABB(queryProxy); + __this.m_tree.Query(QueryCallback, fatAABB); + } + __this.m_moveBuffer.length = 0; + for (var i = 0; i < __this.m_pairCount;) { + var primaryPair = __this.m_pairBuffer[i]; + var userDataA = __this.m_tree.GetUserData(primaryPair.proxyA); + var userDataB = __this.m_tree.GetUserData(primaryPair.proxyB); + callback(userDataA, userDataB); + ++i; + while (i < __this.m_pairCount) { + var pair = __this.m_pairBuffer[i]; + if (pair.proxyA != primaryPair.proxyA || pair.proxyB != primaryPair.proxyB) { + break; + }++i; + } + } + } + b2DynamicTreeBroadPhase.prototype.Query = function (callback, aabb) { + this.m_tree.Query(callback, aabb); + } + b2DynamicTreeBroadPhase.prototype.RayCast = function (callback, input) { + this.m_tree.RayCast(callback, input); + } + b2DynamicTreeBroadPhase.prototype.Validate = function () {} + b2DynamicTreeBroadPhase.prototype.Rebalance = function (iterations) { + if (iterations === undefined) iterations = 0; + this.m_tree.Rebalance(iterations); + } + b2DynamicTreeBroadPhase.prototype.BufferMove = function (proxy) { + this.m_moveBuffer[this.m_moveBuffer.length] = proxy; + } + b2DynamicTreeBroadPhase.prototype.UnBufferMove = function (proxy) { + var i = parseInt(this.m_moveBuffer.indexOf(proxy)); + this.m_moveBuffer.splice(i, 1); + } + b2DynamicTreeBroadPhase.prototype.ComparePairs = function (pair1, pair2) { + return 0; + } + b2DynamicTreeBroadPhase.__implements = {}; + b2DynamicTreeBroadPhase.__implements[IBroadPhase] = true; + b2DynamicTreeNode.b2DynamicTreeNode = function () { + this.aabb = new b2AABB(); + }; + b2DynamicTreeNode.prototype.IsLeaf = function () { + return this.child1 == null; + } + b2DynamicTreePair.b2DynamicTreePair = function () {}; + b2Manifold.b2Manifold = function () { + this.m_pointCount = 0; + }; + b2Manifold.prototype.b2Manifold = function () { + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2ManifoldPoint(); + } + this.m_localPlaneNormal = new b2Vec2(); + this.m_localPoint = new b2Vec2(); + } + b2Manifold.prototype.Reset = function () { + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Reset(); + } + this.m_localPlaneNormal.SetZero(); + this.m_localPoint.SetZero(); + this.m_type = 0; + this.m_pointCount = 0; + } + b2Manifold.prototype.Set = function (m) { + this.m_pointCount = m.m_pointCount; + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Set(m.m_points[i]); + } + this.m_localPlaneNormal.SetV(m.m_localPlaneNormal); + this.m_localPoint.SetV(m.m_localPoint); + this.m_type = m.m_type; + } + b2Manifold.prototype.Copy = function () { + var copy = new b2Manifold(); + copy.Set(this); + return copy; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Manifold.e_circles = 0x0001; + Box2D.Collision.b2Manifold.e_faceA = 0x0002; + Box2D.Collision.b2Manifold.e_faceB = 0x0004; + }); + b2ManifoldPoint.b2ManifoldPoint = function () { + this.m_localPoint = new b2Vec2(); + this.m_id = new b2ContactID(); + }; + b2ManifoldPoint.prototype.b2ManifoldPoint = function () { + this.Reset(); + } + b2ManifoldPoint.prototype.Reset = function () { + this.m_localPoint.SetZero(); + this.m_normalImpulse = 0.0; + this.m_tangentImpulse = 0.0; + this.m_id.key = 0; + } + b2ManifoldPoint.prototype.Set = function (m) { + this.m_localPoint.SetV(m.m_localPoint); + this.m_normalImpulse = m.m_normalImpulse; + this.m_tangentImpulse = m.m_tangentImpulse; + this.m_id.Set(m.m_id); + } + b2Point.b2Point = function () { + this.p = new b2Vec2(); + }; + b2Point.prototype.Support = function (xf, vX, vY) { + if (vX === undefined) vX = 0; + if (vY === undefined) vY = 0; + return this.p; + } + b2Point.prototype.GetFirstVertex = function (xf) { + return this.p; + } + b2RayCastInput.b2RayCastInput = function () { + this.p1 = new b2Vec2(); + this.p2 = new b2Vec2(); + }; + b2RayCastInput.prototype.b2RayCastInput = function (p1, p2, maxFraction) { + if (p1 === undefined) p1 = null; + if (p2 === undefined) p2 = null; + if (maxFraction === undefined) maxFraction = 1; + if (p1) this.p1.SetV(p1); + if (p2) this.p2.SetV(p2); + this.maxFraction = maxFraction; + } + b2RayCastOutput.b2RayCastOutput = function () { + this.normal = new b2Vec2(); + }; + b2Segment.b2Segment = function () { + this.p1 = new b2Vec2(); + this.p2 = new b2Vec2(); + }; + b2Segment.prototype.TestSegment = function (lambda, normal, segment, maxLambda) { + if (maxLambda === undefined) maxLambda = 0; + var s = segment.p1; + var rX = segment.p2.x - s.x; + var rY = segment.p2.y - s.y; + var dX = this.p2.x - this.p1.x; + var dY = this.p2.y - this.p1.y; + var nX = dY; + var nY = (-dX); + var k_slop = 100.0 * Number.MIN_VALUE; + var denom = (-(rX * nX + rY * nY)); + if (denom > k_slop) { + var bX = s.x - this.p1.x; + var bY = s.y - this.p1.y; + var a = (bX * nX + bY * nY); + if (0.0 <= a && a <= maxLambda * denom) { + var mu2 = (-rX * bY) + rY * bX; + if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { + a /= denom; + var nLen = Math.sqrt(nX * nX + nY * nY); + nX /= nLen; + nY /= nLen; + lambda[0] = a; + normal.Set(nX, nY); + return true; + } + } + } + return false; + } + b2Segment.prototype.Extend = function (aabb) { + this.ExtendForward(aabb); + this.ExtendBackward(aabb); + } + b2Segment.prototype.ExtendForward = function (aabb) { + var dX = this.p2.x - this.p1.x; + var dY = this.p2.y - this.p1.y; + var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p1.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p1.x) / dX : Number.POSITIVE_INFINITY, + dY > 0 ? (aabb.upperBound.y - this.p1.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p1.y) / dY : Number.POSITIVE_INFINITY); + this.p2.x = this.p1.x + dX * lambda; + this.p2.y = this.p1.y + dY * lambda; + } + b2Segment.prototype.ExtendBackward = function (aabb) { + var dX = (-this.p2.x) + this.p1.x; + var dY = (-this.p2.y) + this.p1.y; + var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p2.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p2.x) / dX : Number.POSITIVE_INFINITY, + dY > 0 ? (aabb.upperBound.y - this.p2.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p2.y) / dY : Number.POSITIVE_INFINITY); + this.p1.x = this.p2.x + dX * lambda; + this.p1.y = this.p2.y + dY * lambda; + } + b2SeparationFunction.b2SeparationFunction = function () { + this.m_localPoint = new b2Vec2(); + this.m_axis = new b2Vec2(); + }; + b2SeparationFunction.prototype.Initialize = function (cache, proxyA, transformA, proxyB, transformB) { + this.m_proxyA = proxyA; + this.m_proxyB = proxyB; + var count = parseInt(cache.count); + b2Settings.b2Assert(0 < count && count < 3); + var localPointA; + var localPointA1; + var localPointA2; + var localPointB; + var localPointB1; + var localPointB2; + var pointAX = 0; + var pointAY = 0; + var pointBX = 0; + var pointBY = 0; + var normalX = 0; + var normalY = 0; + var tMat; + var tVec; + var s = 0; + var sgn = 0; + if (count == 1) { + this.m_type = b2SeparationFunction.e_points; + localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_axis.x = pointBX - pointAX; + this.m_axis.y = pointBY - pointAY; + this.m_axis.Normalize(); + } + else if (cache.indexB[0] == cache.indexB[1]) { + this.m_type = b2SeparationFunction.e_faceA; + localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); + localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + this.m_localPoint.x = 0.5 * (localPointA1.x + localPointA2.x); + this.m_localPoint.y = 0.5 * (localPointA1.y + localPointA2.y); + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); + this.m_axis.Normalize(); + tVec = this.m_axis; + tMat = transformA.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + s = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else if (cache.indexA[0] == cache.indexA[0]) { + this.m_type = b2SeparationFunction.e_faceB; + localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); + localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); + localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + this.m_localPoint.x = 0.5 * (localPointB1.x + localPointB2.x); + this.m_localPoint.y = 0.5 * (localPointB1.y + localPointB2.y); + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); + this.m_axis.Normalize(); + tVec = this.m_axis; + tMat = transformB.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + s = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else { + localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); + localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); + localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); + var pA = b2Math.MulX(transformA, localPointA); + var dA = b2Math.MulMV(transformA.R, b2Math.SubtractVV(localPointA2, localPointA1)); + var pB = b2Math.MulX(transformB, localPointB); + var dB = b2Math.MulMV(transformB.R, b2Math.SubtractVV(localPointB2, localPointB1)); + var a = dA.x * dA.x + dA.y * dA.y; + var e = dB.x * dB.x + dB.y * dB.y; + var r = b2Math.SubtractVV(dB, dA); + var c = dA.x * r.x + dA.y * r.y; + var f = dB.x * r.x + dB.y * r.y; + var b = dA.x * dB.x + dA.y * dB.y; + var denom = a * e - b * b; + s = 0.0; + if (denom != 0.0) { + s = b2Math.Clamp((b * f - c * e) / denom, 0.0, 1.0); + } + var t = (b * s + f) / e; + if (t < 0.0) { + t = 0.0; + s = b2Math.Clamp((b - c) / a, 0.0, 1.0); + } + localPointA = new b2Vec2(); + localPointA.x = localPointA1.x + s * (localPointA2.x - localPointA1.x); + localPointA.y = localPointA1.y + s * (localPointA2.y - localPointA1.y); + localPointB = new b2Vec2(); + localPointB.x = localPointB1.x + s * (localPointB2.x - localPointB1.x); + localPointB.y = localPointB1.y + s * (localPointB2.y - localPointB1.y); + if (s == 0.0 || s == 1.0) { + this.m_type = b2SeparationFunction.e_faceB; + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); + this.m_axis.Normalize(); + this.m_localPoint = localPointB; + tVec = this.m_axis; + tMat = transformB.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + sgn = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else { + this.m_type = b2SeparationFunction.e_faceA; + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); + this.m_localPoint = localPointA; + tVec = this.m_axis; + tMat = transformA.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + sgn = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + } + } + b2SeparationFunction.prototype.Evaluate = function (transformA, transformB) { + var axisA; + var axisB; + var localPointA; + var localPointB; + var pointA; + var pointB; + var seperation = 0; + var normal; + switch (this.m_type) { + case b2SeparationFunction.e_points: + { + axisA = b2Math.MulTMV(transformA.R, this.m_axis); + axisB = b2Math.MulTMV(transformB.R, this.m_axis.GetNegative()); + localPointA = this.m_proxyA.GetSupportVertex(axisA); + localPointB = this.m_proxyB.GetSupportVertex(axisB); + pointA = b2Math.MulX(transformA, localPointA); + pointB = b2Math.MulX(transformB, localPointB); + seperation = (pointB.x - pointA.x) * this.m_axis.x + (pointB.y - pointA.y) * this.m_axis.y; + return seperation; + } + case b2SeparationFunction.e_faceA: + { + normal = b2Math.MulMV(transformA.R, this.m_axis); + pointA = b2Math.MulX(transformA, this.m_localPoint); + axisB = b2Math.MulTMV(transformB.R, normal.GetNegative()); + localPointB = this.m_proxyB.GetSupportVertex(axisB); + pointB = b2Math.MulX(transformB, localPointB); + seperation = (pointB.x - pointA.x) * normal.x + (pointB.y - pointA.y) * normal.y; + return seperation; + } + case b2SeparationFunction.e_faceB: + { + normal = b2Math.MulMV(transformB.R, this.m_axis); + pointB = b2Math.MulX(transformB, this.m_localPoint); + axisA = b2Math.MulTMV(transformA.R, normal.GetNegative()); + localPointA = this.m_proxyA.GetSupportVertex(axisA); + pointA = b2Math.MulX(transformA, localPointA); + seperation = (pointA.x - pointB.x) * normal.x + (pointA.y - pointB.y) * normal.y; + return seperation; + } + default: + b2Settings.b2Assert(false); + return 0.0; + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2SeparationFunction.e_points = 0x01; + Box2D.Collision.b2SeparationFunction.e_faceA = 0x02; + Box2D.Collision.b2SeparationFunction.e_faceB = 0x04; + }); + b2Simplex.b2Simplex = function () { + this.m_v1 = new b2SimplexVertex(); + this.m_v2 = new b2SimplexVertex(); + this.m_v3 = new b2SimplexVertex(); + this.m_vertices = new Vector(3); + }; + b2Simplex.prototype.b2Simplex = function () { + this.m_vertices[0] = this.m_v1; + this.m_vertices[1] = this.m_v2; + this.m_vertices[2] = this.m_v3; + } + b2Simplex.prototype.ReadCache = function (cache, proxyA, transformA, proxyB, transformB) { + b2Settings.b2Assert(0 <= cache.count && cache.count <= 3); + var wALocal; + var wBLocal; + this.m_count = cache.count; + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; i++) { + var v = vertices[i]; + v.indexA = cache.indexA[i]; + v.indexB = cache.indexB[i]; + wALocal = proxyA.GetVertex(v.indexA); + wBLocal = proxyB.GetVertex(v.indexB); + v.wA = b2Math.MulX(transformA, wALocal); + v.wB = b2Math.MulX(transformB, wBLocal); + v.w = b2Math.SubtractVV(v.wB, v.wA); + v.a = 0; + } + if (this.m_count > 1) { + var metric1 = cache.metric; + var metric2 = this.GetMetric(); + if (metric2 < .5 * metric1 || 2.0 * metric1 < metric2 || metric2 < Number.MIN_VALUE) { + this.m_count = 0; + } + } + if (this.m_count == 0) { + v = vertices[0]; + v.indexA = 0; + v.indexB = 0; + wALocal = proxyA.GetVertex(0); + wBLocal = proxyB.GetVertex(0); + v.wA = b2Math.MulX(transformA, wALocal); + v.wB = b2Math.MulX(transformB, wBLocal); + v.w = b2Math.SubtractVV(v.wB, v.wA); + this.m_count = 1; + } + } + b2Simplex.prototype.WriteCache = function (cache) { + cache.metric = this.GetMetric(); + cache.count = Box2D.parseUInt(this.m_count); + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; i++) { + cache.indexA[i] = Box2D.parseUInt(vertices[i].indexA); + cache.indexB[i] = Box2D.parseUInt(vertices[i].indexB); + } + } + b2Simplex.prototype.GetSearchDirection = function () { + switch (this.m_count) { + case 1: + return this.m_v1.w.GetNegative(); + case 2: + { + var e12 = b2Math.SubtractVV(this.m_v2.w, this.m_v1.w); + var sgn = b2Math.CrossVV(e12, this.m_v1.w.GetNegative()); + if (sgn > 0.0) { + return b2Math.CrossFV(1.0, e12); + } + else { + return b2Math.CrossVF(e12, 1.0); + } + } + default: + b2Settings.b2Assert(false); + return new b2Vec2(); + } + } + b2Simplex.prototype.GetClosestPoint = function () { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + return new b2Vec2(); + case 1: + return this.m_v1.w; + case 2: + return new b2Vec2(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y); + default: + b2Settings.b2Assert(false); + return new b2Vec2(); + } + } + b2Simplex.prototype.GetWitnessPoints = function (pA, pB) { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + break; + case 1: + pA.SetV(this.m_v1.wA); + pB.SetV(this.m_v1.wB); + break; + case 2: + pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x; + pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y; + pB.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x; + pB.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y; + break; + case 3: + pB.x = pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x; + pB.y = pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y; + break; + default: + b2Settings.b2Assert(false); + break; + } + } + b2Simplex.prototype.GetMetric = function () { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + return 0.0; + case 1: + return 0.0; + case 2: + return b2Math.SubtractVV(this.m_v1.w, this.m_v2.w).Length(); + case 3: + return b2Math.CrossVV(b2Math.SubtractVV(this.m_v2.w, this.m_v1.w), b2Math.SubtractVV(this.m_v3.w, this.m_v1.w)); + default: + b2Settings.b2Assert(false); + return 0.0; + } + } + b2Simplex.prototype.Solve2 = function () { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var e12 = b2Math.SubtractVV(w2, w1); + var d12_2 = (-(w1.x * e12.x + w1.y * e12.y)); + if (d12_2 <= 0.0) { + this.m_v1.a = 1.0; + this.m_count = 1; + return; + } + var d12_1 = (w2.x * e12.x + w2.y * e12.y); + if (d12_1 <= 0.0) { + this.m_v2.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v2); + return; + } + var inv_d12 = 1.0 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + } + b2Simplex.prototype.Solve3 = function () { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var w3 = this.m_v3.w; + var e12 = b2Math.SubtractVV(w2, w1); + var w1e12 = b2Math.Dot(w1, e12); + var w2e12 = b2Math.Dot(w2, e12); + var d12_1 = w2e12; + var d12_2 = (-w1e12); + var e13 = b2Math.SubtractVV(w3, w1); + var w1e13 = b2Math.Dot(w1, e13); + var w3e13 = b2Math.Dot(w3, e13); + var d13_1 = w3e13; + var d13_2 = (-w1e13); + var e23 = b2Math.SubtractVV(w3, w2); + var w2e23 = b2Math.Dot(w2, e23); + var w3e23 = b2Math.Dot(w3, e23); + var d23_1 = w3e23; + var d23_2 = (-w2e23); + var n123 = b2Math.CrossVV(e12, e13); + var d123_1 = n123 * b2Math.CrossVV(w2, w3); + var d123_2 = n123 * b2Math.CrossVV(w3, w1); + var d123_3 = n123 * b2Math.CrossVV(w1, w2); + if (d12_2 <= 0.0 && d13_2 <= 0.0) { + this.m_v1.a = 1.0; + this.m_count = 1; + return; + } + if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) { + var inv_d12 = 1.0 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + return; + } + if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) { + var inv_d13 = 1.0 / (d13_1 + d13_2); + this.m_v1.a = d13_1 * inv_d13; + this.m_v3.a = d13_2 * inv_d13; + this.m_count = 2; + this.m_v2.Set(this.m_v3); + return; + } + if (d12_1 <= 0.0 && d23_2 <= 0.0) { + this.m_v2.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v2); + return; + } + if (d13_1 <= 0.0 && d23_1 <= 0.0) { + this.m_v3.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v3); + return; + } + if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) { + var inv_d23 = 1.0 / (d23_1 + d23_2); + this.m_v2.a = d23_1 * inv_d23; + this.m_v3.a = d23_2 * inv_d23; + this.m_count = 2; + this.m_v1.Set(this.m_v3); + return; + } + var inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3); + this.m_v1.a = d123_1 * inv_d123; + this.m_v2.a = d123_2 * inv_d123; + this.m_v3.a = d123_3 * inv_d123; + this.m_count = 3; + } + b2SimplexCache.b2SimplexCache = function () { + this.indexA = new Vector_a2j_Number(3); + this.indexB = new Vector_a2j_Number(3); + }; + b2SimplexVertex.b2SimplexVertex = function () {}; + b2SimplexVertex.prototype.Set = function (other) { + this.wA.SetV(other.wA); + this.wB.SetV(other.wB); + this.w.SetV(other.w); + this.a = other.a; + this.indexA = other.indexA; + this.indexB = other.indexB; + } + b2TimeOfImpact.b2TimeOfImpact = function () {}; + b2TimeOfImpact.TimeOfImpact = function (input) { + ++b2TimeOfImpact.b2_toiCalls; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var sweepA = input.sweepA; + var sweepB = input.sweepB; + b2Settings.b2Assert(sweepA.t0 == sweepB.t0); + b2Settings.b2Assert(1.0 - sweepA.t0 > Number.MIN_VALUE); + var radius = proxyA.m_radius + proxyB.m_radius; + var tolerance = input.tolerance; + var alpha = 0.0; + var k_maxIterations = 1000; + var iter = 0; + var target = 0.0; + b2TimeOfImpact.s_cache.count = 0; + b2TimeOfImpact.s_distanceInput.useRadii = false; + for (;;) { + sweepA.GetTransform(b2TimeOfImpact.s_xfA, alpha); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, alpha); + b2TimeOfImpact.s_distanceInput.proxyA = proxyA; + b2TimeOfImpact.s_distanceInput.proxyB = proxyB; + b2TimeOfImpact.s_distanceInput.transformA = b2TimeOfImpact.s_xfA; + b2TimeOfImpact.s_distanceInput.transformB = b2TimeOfImpact.s_xfB; + b2Distance.Distance(b2TimeOfImpact.s_distanceOutput, b2TimeOfImpact.s_cache, b2TimeOfImpact.s_distanceInput); + if (b2TimeOfImpact.s_distanceOutput.distance <= 0.0) { + alpha = 1.0; + break; + } + b2TimeOfImpact.s_fcn.Initialize(b2TimeOfImpact.s_cache, proxyA, b2TimeOfImpact.s_xfA, proxyB, b2TimeOfImpact.s_xfB); + var separation = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (separation <= 0.0) { + alpha = 1.0; + break; + } + if (iter == 0) { + if (separation > radius) { + target = b2Math.Max(radius - tolerance, 0.75 * radius); + } + else { + target = b2Math.Max(separation - tolerance, 0.02 * radius); + } + } + if (separation - target < 0.5 * tolerance) { + if (iter == 0) { + alpha = 1.0; + break; + } + break; + } + var newAlpha = alpha; { + var x1 = alpha; + var x2 = 1.0; + var f1 = separation; + sweepA.GetTransform(b2TimeOfImpact.s_xfA, x2); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, x2); + var f2 = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (f2 >= target) { + alpha = 1.0; + break; + } + var rootIterCount = 0; + for (;;) { + var x = 0; + if (rootIterCount & 1) { + x = x1 + (target - f1) * (x2 - x1) / (f2 - f1); + } + else { + x = 0.5 * (x1 + x2); + } + sweepA.GetTransform(b2TimeOfImpact.s_xfA, x); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, x); + var f = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (b2Math.Abs(f - target) < 0.025 * tolerance) { + newAlpha = x; + break; + } + if (f > target) { + x1 = x; + f1 = f; + } + else { + x2 = x; + f2 = f; + }++rootIterCount; + ++b2TimeOfImpact.b2_toiRootIters; + if (rootIterCount == 50) { + break; + } + } + b2TimeOfImpact.b2_toiMaxRootIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxRootIters, rootIterCount); + } + if (newAlpha < (1.0 + 100.0 * Number.MIN_VALUE) * alpha) { + break; + } + alpha = newAlpha; + iter++; + ++b2TimeOfImpact.b2_toiIters; + if (iter == k_maxIterations) { + break; + } + } + b2TimeOfImpact.b2_toiMaxIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxIters, iter); + return alpha; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2TimeOfImpact.b2_toiCalls = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiRootIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters = 0; + Box2D.Collision.b2TimeOfImpact.s_cache = new b2SimplexCache(); + Box2D.Collision.b2TimeOfImpact.s_distanceInput = new b2DistanceInput(); + Box2D.Collision.b2TimeOfImpact.s_xfA = new b2Transform(); + Box2D.Collision.b2TimeOfImpact.s_xfB = new b2Transform(); + Box2D.Collision.b2TimeOfImpact.s_fcn = new b2SeparationFunction(); + Box2D.Collision.b2TimeOfImpact.s_distanceOutput = new b2DistanceOutput(); + }); + b2TOIInput.b2TOIInput = function () { + this.proxyA = new b2DistanceProxy(); + this.proxyB = new b2DistanceProxy(); + this.sweepA = new b2Sweep(); + this.sweepB = new b2Sweep(); + }; + b2WorldManifold.b2WorldManifold = function () { + this.m_normal = new b2Vec2(); + }; + b2WorldManifold.prototype.b2WorldManifold = function () { + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2Vec2(); + } + } + b2WorldManifold.prototype.Initialize = function (manifold, xfA, radiusA, xfB, radiusB) { + if (radiusA === undefined) radiusA = 0; + if (radiusB === undefined) radiusB = 0; + if (manifold.m_pointCount == 0) { + return; + } + var i = 0; + var tVec; + var tMat; + var normalX = 0; + var normalY = 0; + var planePointX = 0; + var planePointY = 0; + var clipPointX = 0; + var clipPointY = 0; + switch (manifold.m_type) { + case b2Manifold.e_circles: + { + tMat = xfA.R; + tVec = manifold.m_localPoint; + var pointAX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var pointAY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfB.R; + tVec = manifold.m_points[0].m_localPoint; + var pointBX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var pointBY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + var dX = pointBX - pointAX; + var dY = pointBY - pointAY; + var d2 = dX * dX + dY * dY; + if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { + var d = Math.sqrt(d2); + this.m_normal.x = dX / d; + this.m_normal.y = dY / d; + } + else { + this.m_normal.x = 1; + this.m_normal.y = 0; + } + var cAX = pointAX + radiusA * this.m_normal.x; + var cAY = pointAY + radiusA * this.m_normal.y; + var cBX = pointBX - radiusB * this.m_normal.x; + var cBY = pointBY - radiusB * this.m_normal.y; + this.m_points[0].x = 0.5 * (cAX + cBX); + this.m_points[0].y = 0.5 * (cAY + cBY); + } + break; + case b2Manifold.e_faceA: + { + tMat = xfA.R; + tVec = manifold.m_localPlaneNormal; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfA.R; + tVec = manifold.m_localPoint; + planePointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + planePointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_normal.x = normalX; + this.m_normal.y = normalY; + for (i = 0; + i < manifold.m_pointCount; i++) { + tMat = xfB.R; + tVec = manifold.m_points[i].m_localPoint; + clipPointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + clipPointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_points[i].x = clipPointX + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalX; + this.m_points[i].y = clipPointY + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalY; + } + } + break; + case b2Manifold.e_faceB: + { + tMat = xfB.R; + tVec = manifold.m_localPlaneNormal; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfB.R; + tVec = manifold.m_localPoint; + planePointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + planePointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_normal.x = (-normalX); + this.m_normal.y = (-normalY); + for (i = 0; + i < manifold.m_pointCount; i++) { + tMat = xfA.R; + tVec = manifold.m_points[i].m_localPoint; + clipPointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + clipPointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_points[i].x = clipPointX + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalX; + this.m_points[i].y = clipPointY + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalY; + } + } + break; + } + } + ClipVertex.ClipVertex = function () { + this.v = new b2Vec2(); + this.id = new b2ContactID(); + }; + ClipVertex.prototype.Set = function (other) { + this.v.SetV(other.v); + this.id.Set(other.id); + } + Features.Features = function () {}; + Object.defineProperty(Features.prototype, 'referenceEdge', { + enumerable: false, + configurable: true, + get: function () { + return this._referenceEdge; + } + }); + Object.defineProperty(Features.prototype, 'referenceEdge', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._referenceEdge = value; + this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceEdge & 0x000000ff); + } + }); + Object.defineProperty(Features.prototype, 'incidentEdge', { + enumerable: false, + configurable: true, + get: function () { + return this._incidentEdge; + } + }); + Object.defineProperty(Features.prototype, 'incidentEdge', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._incidentEdge = value; + this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00); + } + }); + Object.defineProperty(Features.prototype, 'incidentVertex', { + enumerable: false, + configurable: true, + get: function () { + return this._incidentVertex; + } + }); + Object.defineProperty(Features.prototype, 'incidentVertex', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._incidentVertex = value; + this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000); + } + }); + Object.defineProperty(Features.prototype, 'flip', { + enumerable: false, + configurable: true, + get: function () { + return this._flip; + } + }); + Object.defineProperty(Features.prototype, 'flip', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._flip = value; + this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000); + } + }); +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + Box2D.inherit(b2CircleShape, Box2D.Collision.Shapes.b2Shape); + b2CircleShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2CircleShape.b2CircleShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + this.m_p = new b2Vec2(); + }; + b2CircleShape.prototype.Copy = function () { + var s = new b2CircleShape(); + s.Set(this); + return s; + } + b2CircleShape.prototype.Set = function (other) { + this.__super.Set.call(this, other); + if (Box2D.is(other, b2CircleShape)) { + var other2 = (other instanceof b2CircleShape ? other : null); + this.m_p.SetV(other2.m_p); + } + } + b2CircleShape.prototype.TestPoint = function (transform, p) { + var tMat = transform.R; + var dX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var dY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + dX = p.x - dX; + dY = p.y - dY; + return (dX * dX + dY * dY) <= this.m_radius * this.m_radius; + } + b2CircleShape.prototype.RayCast = function (output, input, transform) { + var tMat = transform.R; + var positionX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var positionY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + var sX = input.p1.x - positionX; + var sY = input.p1.y - positionY; + var b = (sX * sX + sY * sY) - this.m_radius * this.m_radius; + var rX = input.p2.x - input.p1.x; + var rY = input.p2.y - input.p1.y; + var c = (sX * rX + sY * rY); + var rr = (rX * rX + rY * rY); + var sigma = c * c - rr * b; + if (sigma < 0.0 || rr < Number.MIN_VALUE) { + return false; + } + var a = (-(c + Math.sqrt(sigma))); + if (0.0 <= a && a <= input.maxFraction * rr) { + a /= rr; + output.fraction = a; + output.normal.x = sX + a * rX; + output.normal.y = sY + a * rY; + output.normal.Normalize(); + return true; + } + return false; + } + b2CircleShape.prototype.ComputeAABB = function (aabb, transform) { + var tMat = transform.R; + var pX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var pY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + aabb.lowerBound.Set(pX - this.m_radius, pY - this.m_radius); + aabb.upperBound.Set(pX + this.m_radius, pY + this.m_radius); + } + b2CircleShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + massData.mass = density * b2Settings.b2_pi * this.m_radius * this.m_radius; + massData.center.SetV(this.m_p); + massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + (this.m_p.x * this.m_p.x + this.m_p.y * this.m_p.y)); + } + b2CircleShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var p = b2Math.MulX(xf, this.m_p); + var l = (-(b2Math.Dot(normal, p) - offset)); + if (l < (-this.m_radius) + Number.MIN_VALUE) { + return 0; + } + if (l > this.m_radius) { + c.SetV(p); + return Math.PI * this.m_radius * this.m_radius; + } + var r2 = this.m_radius * this.m_radius; + var l2 = l * l; + var area = r2 * (Math.asin(l / this.m_radius) + Math.PI / 2) + l * Math.sqrt(r2 - l2); + var com = (-2 / 3 * Math.pow(r2 - l2, 1.5) / area); + c.x = p.x + normal.x * com; + c.y = p.y + normal.y * com; + return area; + } + b2CircleShape.prototype.GetLocalPosition = function () { + return this.m_p; + } + b2CircleShape.prototype.SetLocalPosition = function (position) { + this.m_p.SetV(position); + } + b2CircleShape.prototype.GetRadius = function () { + return this.m_radius; + } + b2CircleShape.prototype.SetRadius = function (radius) { + if (radius === undefined) radius = 0; + this.m_radius = radius; + } + b2CircleShape.prototype.b2CircleShape = function (radius) { + if (radius === undefined) radius = 0; + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_circleShape; + this.m_radius = radius; + } + b2EdgeChainDef.b2EdgeChainDef = function () {}; + b2EdgeChainDef.prototype.b2EdgeChainDef = function () { + this.vertexCount = 0; + this.isALoop = true; + this.vertices = []; + } + Box2D.inherit(b2EdgeShape, Box2D.Collision.Shapes.b2Shape); + b2EdgeShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2EdgeShape.b2EdgeShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + this.s_supportVec = new b2Vec2(); + this.m_v1 = new b2Vec2(); + this.m_v2 = new b2Vec2(); + this.m_coreV1 = new b2Vec2(); + this.m_coreV2 = new b2Vec2(); + this.m_normal = new b2Vec2(); + this.m_direction = new b2Vec2(); + this.m_cornerDir1 = new b2Vec2(); + this.m_cornerDir2 = new b2Vec2(); + }; + b2EdgeShape.prototype.TestPoint = function (transform, p) { + return false; + } + b2EdgeShape.prototype.RayCast = function (output, input, transform) { + var tMat; + var rX = input.p2.x - input.p1.x; + var rY = input.p2.y - input.p1.y; + tMat = transform.R; + var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); + var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); + var nX = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y) - v1Y; + var nY = (-(transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y) - v1X)); + var k_slop = 100.0 * Number.MIN_VALUE; + var denom = (-(rX * nX + rY * nY)); + if (denom > k_slop) { + var bX = input.p1.x - v1X; + var bY = input.p1.y - v1Y; + var a = (bX * nX + bY * nY); + if (0.0 <= a && a <= input.maxFraction * denom) { + var mu2 = (-rX * bY) + rY * bX; + if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { + a /= denom; + output.fraction = a; + var nLen = Math.sqrt(nX * nX + nY * nY); + output.normal.x = nX / nLen; + output.normal.y = nY / nLen; + return true; + } + } + } + return false; + } + b2EdgeShape.prototype.ComputeAABB = function (aabb, transform) { + var tMat = transform.R; + var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); + var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); + var v2X = transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y); + var v2Y = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y); + if (v1X < v2X) { + aabb.lowerBound.x = v1X; + aabb.upperBound.x = v2X; + } + else { + aabb.lowerBound.x = v2X; + aabb.upperBound.x = v1X; + } + if (v1Y < v2Y) { + aabb.lowerBound.y = v1Y; + aabb.upperBound.y = v2Y; + } + else { + aabb.lowerBound.y = v2Y; + aabb.upperBound.y = v1Y; + } + } + b2EdgeShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + massData.mass = 0; + massData.center.SetV(this.m_v1); + massData.I = 0; + } + b2EdgeShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var v0 = new b2Vec2(normal.x * offset, normal.y * offset); + var v1 = b2Math.MulX(xf, this.m_v1); + var v2 = b2Math.MulX(xf, this.m_v2); + var d1 = b2Math.Dot(normal, v1) - offset; + var d2 = b2Math.Dot(normal, v2) - offset; + if (d1 > 0) { + if (d2 > 0) { + return 0; + } + else { + v1.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; + v1.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; + } + } + else { + if (d2 > 0) { + v2.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; + v2.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; + } + else {} + } + c.x = (v0.x + v1.x + v2.x) / 3; + c.y = (v0.y + v1.y + v2.y) / 3; + return 0.5 * ((v1.x - v0.x) * (v2.y - v0.y) - (v1.y - v0.y) * (v2.x - v0.x)); + } + b2EdgeShape.prototype.GetLength = function () { + return this.m_length; + } + b2EdgeShape.prototype.GetVertex1 = function () { + return this.m_v1; + } + b2EdgeShape.prototype.GetVertex2 = function () { + return this.m_v2; + } + b2EdgeShape.prototype.GetCoreVertex1 = function () { + return this.m_coreV1; + } + b2EdgeShape.prototype.GetCoreVertex2 = function () { + return this.m_coreV2; + } + b2EdgeShape.prototype.GetNormalVector = function () { + return this.m_normal; + } + b2EdgeShape.prototype.GetDirectionVector = function () { + return this.m_direction; + } + b2EdgeShape.prototype.GetCorner1Vector = function () { + return this.m_cornerDir1; + } + b2EdgeShape.prototype.GetCorner2Vector = function () { + return this.m_cornerDir2; + } + b2EdgeShape.prototype.Corner1IsConvex = function () { + return this.m_cornerConvex1; + } + b2EdgeShape.prototype.Corner2IsConvex = function () { + return this.m_cornerConvex2; + } + b2EdgeShape.prototype.GetFirstVertex = function (xf) { + var tMat = xf.R; + return new b2Vec2(xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y), xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y)); + } + b2EdgeShape.prototype.GetNextEdge = function () { + return this.m_nextEdge; + } + b2EdgeShape.prototype.GetPrevEdge = function () { + return this.m_prevEdge; + } + b2EdgeShape.prototype.Support = function (xf, dX, dY) { + if (dX === undefined) dX = 0; + if (dY === undefined) dY = 0; + var tMat = xf.R; + var v1X = xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y); + var v1Y = xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y); + var v2X = xf.position.x + (tMat.col1.x * this.m_coreV2.x + tMat.col2.x * this.m_coreV2.y); + var v2Y = xf.position.y + (tMat.col1.y * this.m_coreV2.x + tMat.col2.y * this.m_coreV2.y); + if ((v1X * dX + v1Y * dY) > (v2X * dX + v2Y * dY)) { + this.s_supportVec.x = v1X; + this.s_supportVec.y = v1Y; + } + else { + this.s_supportVec.x = v2X; + this.s_supportVec.y = v2Y; + } + return this.s_supportVec; + } + b2EdgeShape.prototype.b2EdgeShape = function (v1, v2) { + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_edgeShape; + this.m_prevEdge = null; + this.m_nextEdge = null; + this.m_v1 = v1; + this.m_v2 = v2; + this.m_direction.Set(this.m_v2.x - this.m_v1.x, this.m_v2.y - this.m_v1.y); + this.m_length = this.m_direction.Normalize(); + this.m_normal.Set(this.m_direction.y, (-this.m_direction.x)); + this.m_coreV1.Set((-b2Settings.b2_toiSlop * (this.m_normal.x - this.m_direction.x)) + this.m_v1.x, (-b2Settings.b2_toiSlop * (this.m_normal.y - this.m_direction.y)) + this.m_v1.y); + this.m_coreV2.Set((-b2Settings.b2_toiSlop * (this.m_normal.x + this.m_direction.x)) + this.m_v2.x, (-b2Settings.b2_toiSlop * (this.m_normal.y + this.m_direction.y)) + this.m_v2.y); + this.m_cornerDir1 = this.m_normal; + this.m_cornerDir2.Set((-this.m_normal.x), (-this.m_normal.y)); + } + b2EdgeShape.prototype.SetPrevEdge = function (edge, core, cornerDir, convex) { + this.m_prevEdge = edge; + this.m_coreV1 = core; + this.m_cornerDir1 = cornerDir; + this.m_cornerConvex1 = convex; + } + b2EdgeShape.prototype.SetNextEdge = function (edge, core, cornerDir, convex) { + this.m_nextEdge = edge; + this.m_coreV2 = core; + this.m_cornerDir2 = cornerDir; + this.m_cornerConvex2 = convex; + } + b2MassData.b2MassData = function () { + this.mass = 0.0; + this.center = new b2Vec2(0, 0); + this.I = 0.0; + }; + Box2D.inherit(b2PolygonShape, Box2D.Collision.Shapes.b2Shape); + b2PolygonShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2PolygonShape.b2PolygonShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + }; + b2PolygonShape.prototype.Copy = function () { + var s = new b2PolygonShape(); + s.Set(this); + return s; + } + b2PolygonShape.prototype.Set = function (other) { + this.__super.Set.call(this, other); + if (Box2D.is(other, b2PolygonShape)) { + var other2 = (other instanceof b2PolygonShape ? other : null); + this.m_centroid.SetV(other2.m_centroid); + this.m_vertexCount = other2.m_vertexCount; + this.Reserve(this.m_vertexCount); + for (var i = 0; i < this.m_vertexCount; i++) { + this.m_vertices[i].SetV(other2.m_vertices[i]); + this.m_normals[i].SetV(other2.m_normals[i]); + } + } + } + b2PolygonShape.prototype.SetAsArray = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var v = new Vector(); + var i = 0, + tVec; + for (i = 0; + i < vertices.length; ++i) { + tVec = vertices[i]; + v.push(tVec); + } + this.SetAsVector(v, vertexCount); + } + b2PolygonShape.AsArray = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsArray(vertices, vertexCount); + return polygonShape; + } + b2PolygonShape.prototype.SetAsVector = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + if (vertexCount == 0) vertexCount = vertices.length; + b2Settings.b2Assert(2 <= vertexCount); + this.m_vertexCount = vertexCount; + this.Reserve(vertexCount); + var i = 0; + for (i = 0; + i < this.m_vertexCount; i++) { + this.m_vertices[i].SetV(vertices[i]); + } + for (i = 0; + i < this.m_vertexCount; ++i) { + var i1 = parseInt(i); + var i2 = parseInt(i + 1 < this.m_vertexCount ? i + 1 : 0); + var edge = b2Math.SubtractVV(this.m_vertices[i2], this.m_vertices[i1]); + b2Settings.b2Assert(edge.LengthSquared() > Number.MIN_VALUE); + this.m_normals[i].SetV(b2Math.CrossVF(edge, 1.0)); + this.m_normals[i].Normalize(); + } + this.m_centroid = b2PolygonShape.ComputeCentroid(this.m_vertices, this.m_vertexCount); + } + b2PolygonShape.AsVector = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsVector(vertices, vertexCount); + return polygonShape; + } + b2PolygonShape.prototype.SetAsBox = function (hx, hy) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + this.m_vertexCount = 4; + this.Reserve(4); + this.m_vertices[0].Set((-hx), (-hy)); + this.m_vertices[1].Set(hx, (-hy)); + this.m_vertices[2].Set(hx, hy); + this.m_vertices[3].Set((-hx), hy); + this.m_normals[0].Set(0.0, (-1.0)); + this.m_normals[1].Set(1.0, 0.0); + this.m_normals[2].Set(0.0, 1.0); + this.m_normals[3].Set((-1.0), 0.0); + this.m_centroid.SetZero(); + } + b2PolygonShape.AsBox = function (hx, hy) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsBox(hx, hy); + return polygonShape; + } + b2PolygonShape.prototype.SetAsOrientedBox = function (hx, hy, center, angle) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + if (center === undefined) center = null; + if (angle === undefined) angle = 0.0; + this.m_vertexCount = 4; + this.Reserve(4); + this.m_vertices[0].Set((-hx), (-hy)); + this.m_vertices[1].Set(hx, (-hy)); + this.m_vertices[2].Set(hx, hy); + this.m_vertices[3].Set((-hx), hy); + this.m_normals[0].Set(0.0, (-1.0)); + this.m_normals[1].Set(1.0, 0.0); + this.m_normals[2].Set(0.0, 1.0); + this.m_normals[3].Set((-1.0), 0.0); + this.m_centroid = center; + var xf = new b2Transform(); + xf.position = center; + xf.R.Set(angle); + for (var i = 0; i < this.m_vertexCount; ++i) { + this.m_vertices[i] = b2Math.MulX(xf, this.m_vertices[i]); + this.m_normals[i] = b2Math.MulMV(xf.R, this.m_normals[i]); + } + } + b2PolygonShape.AsOrientedBox = function (hx, hy, center, angle) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + if (center === undefined) center = null; + if (angle === undefined) angle = 0.0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsOrientedBox(hx, hy, center, angle); + return polygonShape; + } + b2PolygonShape.prototype.SetAsEdge = function (v1, v2) { + this.m_vertexCount = 2; + this.Reserve(2); + this.m_vertices[0].SetV(v1); + this.m_vertices[1].SetV(v2); + this.m_centroid.x = 0.5 * (v1.x + v2.x); + this.m_centroid.y = 0.5 * (v1.y + v2.y); + this.m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(v2, v1), 1.0); + this.m_normals[0].Normalize(); + this.m_normals[1].x = (-this.m_normals[0].x); + this.m_normals[1].y = (-this.m_normals[0].y); + } + b2PolygonShape.AsEdge = function (v1, v2) { + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsEdge(v1, v2); + return polygonShape; + } + b2PolygonShape.prototype.TestPoint = function (xf, p) { + var tVec; + var tMat = xf.R; + var tX = p.x - xf.position.x; + var tY = p.y - xf.position.y; + var pLocalX = (tX * tMat.col1.x + tY * tMat.col1.y); + var pLocalY = (tX * tMat.col2.x + tY * tMat.col2.y); + for (var i = 0; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + tX = pLocalX - tVec.x; + tY = pLocalY - tVec.y; + tVec = this.m_normals[i]; + var dot = (tVec.x * tX + tVec.y * tY); + if (dot > 0.0) { + return false; + } + } + return true; + } + b2PolygonShape.prototype.RayCast = function (output, input, transform) { + var lower = 0.0; + var upper = input.maxFraction; + var tX = 0; + var tY = 0; + var tMat; + var tVec; + tX = input.p1.x - transform.position.x; + tY = input.p1.y - transform.position.y; + tMat = transform.R; + var p1X = (tX * tMat.col1.x + tY * tMat.col1.y); + var p1Y = (tX * tMat.col2.x + tY * tMat.col2.y); + tX = input.p2.x - transform.position.x; + tY = input.p2.y - transform.position.y; + tMat = transform.R; + var p2X = (tX * tMat.col1.x + tY * tMat.col1.y); + var p2Y = (tX * tMat.col2.x + tY * tMat.col2.y); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var index = parseInt((-1)); + for (var i = 0; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + tX = tVec.x - p1X; + tY = tVec.y - p1Y; + tVec = this.m_normals[i]; + var numerator = (tVec.x * tX + tVec.y * tY); + var denominator = (tVec.x * dX + tVec.y * dY); + if (denominator == 0.0) { + if (numerator < 0.0) { + return false; + } + } + else { + if (denominator < 0.0 && numerator < lower * denominator) { + lower = numerator / denominator; + index = i; + } + else if (denominator > 0.0 && numerator < upper * denominator) { + upper = numerator / denominator; + } + } + if (upper < lower - Number.MIN_VALUE) { + return false; + } + } + if (index >= 0) { + output.fraction = lower; + tMat = transform.R; + tVec = this.m_normals[index]; + output.normal.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + output.normal.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + return true; + } + return false; + } + b2PolygonShape.prototype.ComputeAABB = function (aabb, xf) { + var tMat = xf.R; + var tVec = this.m_vertices[0]; + var lowerX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var lowerY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var upperX = lowerX; + var upperY = lowerY; + for (var i = 1; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + var vX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var vY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + lowerX = lowerX < vX ? lowerX : vX; + lowerY = lowerY < vY ? lowerY : vY; + upperX = upperX > vX ? upperX : vX; + upperY = upperY > vY ? upperY : vY; + } + aabb.lowerBound.x = lowerX - this.m_radius; + aabb.lowerBound.y = lowerY - this.m_radius; + aabb.upperBound.x = upperX + this.m_radius; + aabb.upperBound.y = upperY + this.m_radius; + } + b2PolygonShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + if (this.m_vertexCount == 2) { + massData.center.x = 0.5 * (this.m_vertices[0].x + this.m_vertices[1].x); + massData.center.y = 0.5 * (this.m_vertices[0].y + this.m_vertices[1].y); + massData.mass = 0.0; + massData.I = 0.0; + return; + } + var centerX = 0.0; + var centerY = 0.0; + var area = 0.0; + var I = 0.0; + var p1X = 0.0; + var p1Y = 0.0; + var k_inv3 = 1.0 / 3.0; + for (var i = 0; i < this.m_vertexCount; ++i) { + var p2 = this.m_vertices[i]; + var p3 = i + 1 < this.m_vertexCount ? this.m_vertices[parseInt(i + 1)] : this.m_vertices[0]; + var e1X = p2.x - p1X; + var e1Y = p2.y - p1Y; + var e2X = p3.x - p1X; + var e2Y = p3.y - p1Y; + var D = e1X * e2Y - e1Y * e2X; + var triangleArea = 0.5 * D;area += triangleArea; + centerX += triangleArea * k_inv3 * (p1X + p2.x + p3.x); + centerY += triangleArea * k_inv3 * (p1Y + p2.y + p3.y); + var px = p1X; + var py = p1Y; + var ex1 = e1X; + var ey1 = e1Y; + var ex2 = e2X; + var ey2 = e2Y; + var intx2 = k_inv3 * (0.25 * (ex1 * ex1 + ex2 * ex1 + ex2 * ex2) + (px * ex1 + px * ex2)) + 0.5 * px * px; + var inty2 = k_inv3 * (0.25 * (ey1 * ey1 + ey2 * ey1 + ey2 * ey2) + (py * ey1 + py * ey2)) + 0.5 * py * py;I += D * (intx2 + inty2); + } + massData.mass = density * area; + centerX *= 1.0 / area; + centerY *= 1.0 / area; + massData.center.Set(centerX, centerY); + massData.I = density * I; + } + b2PolygonShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var normalL = b2Math.MulTMV(xf.R, normal); + var offsetL = offset - b2Math.Dot(normal, xf.position); + var depths = new Vector_a2j_Number(); + var diveCount = 0; + var intoIndex = parseInt((-1)); + var outoIndex = parseInt((-1)); + var lastSubmerged = false; + var i = 0; + for (i = 0; + i < this.m_vertexCount; ++i) { + depths[i] = b2Math.Dot(normalL, this.m_vertices[i]) - offsetL; + var isSubmerged = depths[i] < (-Number.MIN_VALUE); + if (i > 0) { + if (isSubmerged) { + if (!lastSubmerged) { + intoIndex = i - 1; + diveCount++; + } + } + else { + if (lastSubmerged) { + outoIndex = i - 1; + diveCount++; + } + } + } + lastSubmerged = isSubmerged; + } + switch (diveCount) { + case 0: + if (lastSubmerged) { + var md = new b2MassData(); + this.ComputeMass(md, 1); + c.SetV(b2Math.MulX(xf, md.center)); + return md.mass; + } + else { + return 0; + } + break; + case 1: + if (intoIndex == (-1)) { + intoIndex = this.m_vertexCount - 1; + } + else { + outoIndex = this.m_vertexCount - 1; + } + break; + } + var intoIndex2 = parseInt((intoIndex + 1) % this.m_vertexCount); + var outoIndex2 = parseInt((outoIndex + 1) % this.m_vertexCount); + var intoLamdda = (0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]); + var outoLamdda = (0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]); + var intoVec = new b2Vec2(this.m_vertices[intoIndex].x * (1 - intoLamdda) + this.m_vertices[intoIndex2].x * intoLamdda, this.m_vertices[intoIndex].y * (1 - intoLamdda) + this.m_vertices[intoIndex2].y * intoLamdda); + var outoVec = new b2Vec2(this.m_vertices[outoIndex].x * (1 - outoLamdda) + this.m_vertices[outoIndex2].x * outoLamdda, this.m_vertices[outoIndex].y * (1 - outoLamdda) + this.m_vertices[outoIndex2].y * outoLamdda); + var area = 0; + var center = new b2Vec2(); + var p2 = this.m_vertices[intoIndex2]; + var p3; + i = intoIndex2; + while (i != outoIndex2) { + i = (i + 1) % this.m_vertexCount; + if (i == outoIndex2) p3 = outoVec; + else p3 = this.m_vertices[i]; + var triangleArea = 0.5 * ((p2.x - intoVec.x) * (p3.y - intoVec.y) - (p2.y - intoVec.y) * (p3.x - intoVec.x)); + area += triangleArea; + center.x += triangleArea * (intoVec.x + p2.x + p3.x) / 3; + center.y += triangleArea * (intoVec.y + p2.y + p3.y) / 3; + p2 = p3; + } + center.Multiply(1 / area); + c.SetV(b2Math.MulX(xf, center)); + return area; + } + b2PolygonShape.prototype.GetVertexCount = function () { + return this.m_vertexCount; + } + b2PolygonShape.prototype.GetVertices = function () { + return this.m_vertices; + } + b2PolygonShape.prototype.GetNormals = function () { + return this.m_normals; + } + b2PolygonShape.prototype.GetSupport = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_vertexCount; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return bestIndex; + } + b2PolygonShape.prototype.GetSupportVertex = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_vertexCount; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return this.m_vertices[bestIndex]; + } + b2PolygonShape.prototype.Validate = function () { + return false; + } + b2PolygonShape.prototype.b2PolygonShape = function () { + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_polygonShape; + this.m_centroid = new b2Vec2(); + this.m_vertices = new Vector(); + this.m_normals = new Vector(); + } + b2PolygonShape.prototype.Reserve = function (count) { + if (count === undefined) count = 0; + for (var i = parseInt(this.m_vertices.length); i < count; i++) { + this.m_vertices[i] = new b2Vec2(); + this.m_normals[i] = new b2Vec2(); + } + } + b2PolygonShape.ComputeCentroid = function (vs, count) { + if (count === undefined) count = 0; + var c = new b2Vec2(); + var area = 0.0; + var p1X = 0.0; + var p1Y = 0.0; + var inv3 = 1.0 / 3.0; + for (var i = 0; i < count; ++i) { + var p2 = vs[i]; + var p3 = i + 1 < count ? vs[parseInt(i + 1)] : vs[0]; + var e1X = p2.x - p1X; + var e1Y = p2.y - p1Y; + var e2X = p3.x - p1X; + var e2Y = p3.y - p1Y; + var D = (e1X * e2Y - e1Y * e2X); + var triangleArea = 0.5 * D;area += triangleArea; + c.x += triangleArea * inv3 * (p1X + p2.x + p3.x); + c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y); + } + c.x *= 1.0 / area; + c.y *= 1.0 / area; + return c; + } + b2PolygonShape.ComputeOBB = function (obb, vs, count) { + if (count === undefined) count = 0; + var i = 0; + var p = new Vector(count + 1); + for (i = 0; + i < count; ++i) { + p[i] = vs[i]; + } + p[count] = p[0]; + var minArea = Number.MAX_VALUE; + for (i = 1; + i <= count; ++i) { + var root = p[parseInt(i - 1)]; + var uxX = p[i].x - root.x; + var uxY = p[i].y - root.y; + var length = Math.sqrt(uxX * uxX + uxY * uxY); + uxX /= length; + uxY /= length; + var uyX = (-uxY); + var uyY = uxX; + var lowerX = Number.MAX_VALUE; + var lowerY = Number.MAX_VALUE; + var upperX = (-Number.MAX_VALUE); + var upperY = (-Number.MAX_VALUE); + for (var j = 0; j < count; ++j) { + var dX = p[j].x - root.x; + var dY = p[j].y - root.y; + var rX = (uxX * dX + uxY * dY); + var rY = (uyX * dX + uyY * dY); + if (rX < lowerX) lowerX = rX; + if (rY < lowerY) lowerY = rY; + if (rX > upperX) upperX = rX; + if (rY > upperY) upperY = rY; + } + var area = (upperX - lowerX) * (upperY - lowerY); + if (area < 0.95 * minArea) { + minArea = area; + obb.R.col1.x = uxX; + obb.R.col1.y = uxY; + obb.R.col2.x = uyX; + obb.R.col2.y = uyY; + var centerX = 0.5 * (lowerX + upperX); + var centerY = 0.5 * (lowerY + upperY); + var tMat = obb.R; + obb.center.x = root.x + (tMat.col1.x * centerX + tMat.col2.x * centerY); + obb.center.y = root.y + (tMat.col1.y * centerX + tMat.col2.y * centerY); + obb.extents.x = 0.5 * (upperX - lowerX); + obb.extents.y = 0.5 * (upperY - lowerY); + } + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.Shapes.b2PolygonShape.s_mat = new b2Mat22(); + }); + b2Shape.b2Shape = function () {}; + b2Shape.prototype.Copy = function () { + return null; + } + b2Shape.prototype.Set = function (other) { + this.m_radius = other.m_radius; + } + b2Shape.prototype.GetType = function () { + return this.m_type; + } + b2Shape.prototype.TestPoint = function (xf, p) { + return false; + } + b2Shape.prototype.RayCast = function (output, input, transform) { + return false; + } + b2Shape.prototype.ComputeAABB = function (aabb, xf) {} + b2Shape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + } + b2Shape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + return 0; + } + b2Shape.TestOverlap = function (shape1, transform1, shape2, transform2) { + var input = new b2DistanceInput(); + input.proxyA = new b2DistanceProxy(); + input.proxyA.Set(shape1); + input.proxyB = new b2DistanceProxy(); + input.proxyB.Set(shape2); + input.transformA = transform1; + input.transformB = transform2; + input.useRadii = true; + var simplexCache = new b2SimplexCache(); + simplexCache.count = 0; + var output = new b2DistanceOutput(); + b2Distance.Distance(output, simplexCache, input); + return output.distance < 10.0 * Number.MIN_VALUE; + } + b2Shape.prototype.b2Shape = function () { + this.m_type = b2Shape.e_unknownShape; + this.m_radius = b2Settings.b2_linearSlop; + } + Box2D.postDefs.push(function () { + Box2D.Collision.Shapes.b2Shape.e_unknownShape = parseInt((-1)); + Box2D.Collision.Shapes.b2Shape.e_circleShape = 0; + Box2D.Collision.Shapes.b2Shape.e_polygonShape = 1; + Box2D.Collision.Shapes.b2Shape.e_edgeShape = 2; + Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount = 3; + Box2D.Collision.Shapes.b2Shape.e_hitCollide = 1; + Box2D.Collision.Shapes.b2Shape.e_missCollide = 0; + Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide = parseInt((-1)); + }); +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3; + + b2Color.b2Color = function () { + this._r = 0; + this._g = 0; + this._b = 0; + }; + b2Color.prototype.b2Color = function (rr, gg, bb) { + if (rr === undefined) rr = 0; + if (gg === undefined) gg = 0; + if (bb === undefined) bb = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + b2Color.prototype.Set = function (rr, gg, bb) { + if (rr === undefined) rr = 0; + if (gg === undefined) gg = 0; + if (bb === undefined) bb = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + Object.defineProperty(b2Color.prototype, 'r', { + enumerable: false, + configurable: true, + set: function (rr) { + if (rr === undefined) rr = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'g', { + enumerable: false, + configurable: true, + set: function (gg) { + if (gg === undefined) gg = 0; + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'b', { + enumerable: false, + configurable: true, + set: function (bb) { + if (bb === undefined) bb = 0; + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'color', { + enumerable: false, + configurable: true, + get: function () { + return (this._r << 16) | (this._g << 8) | (this._b); + } + }); + b2Settings.b2Settings = function () {}; + b2Settings.b2MixFriction = function (friction1, friction2) { + if (friction1 === undefined) friction1 = 0; + if (friction2 === undefined) friction2 = 0; + return Math.sqrt(friction1 * friction2); + } + b2Settings.b2MixRestitution = function (restitution1, restitution2) { + if (restitution1 === undefined) restitution1 = 0; + if (restitution2 === undefined) restitution2 = 0; + return restitution1 > restitution2 ? restitution1 : restitution2; + } + b2Settings.b2Assert = function (a) { + if (!a) { + throw "Assertion Failed"; + } + } + Box2D.postDefs.push(function () { + Box2D.Common.b2Settings.VERSION = "2.1alpha"; + Box2D.Common.b2Settings.USHRT_MAX = 0x0000ffff; + Box2D.Common.b2Settings.b2_pi = Math.PI; + Box2D.Common.b2Settings.b2_maxManifoldPoints = 2; + Box2D.Common.b2Settings.b2_aabbExtension = 0.1; + Box2D.Common.b2Settings.b2_aabbMultiplier = 2.0; + Box2D.Common.b2Settings.b2_polygonRadius = 2.0 * b2Settings.b2_linearSlop; + Box2D.Common.b2Settings.b2_linearSlop = 0.005; + Box2D.Common.b2Settings.b2_angularSlop = 2.0 / 180.0 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_toiSlop = 8.0 * b2Settings.b2_linearSlop; + Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland = 32; + Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland = 32; + Box2D.Common.b2Settings.b2_velocityThreshold = 1.0; + Box2D.Common.b2Settings.b2_maxLinearCorrection = 0.2; + Box2D.Common.b2Settings.b2_maxAngularCorrection = 8.0 / 180.0 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_maxTranslation = 2.0; + Box2D.Common.b2Settings.b2_maxTranslationSquared = b2Settings.b2_maxTranslation * b2Settings.b2_maxTranslation; + Box2D.Common.b2Settings.b2_maxRotation = 0.5 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_maxRotationSquared = b2Settings.b2_maxRotation * b2Settings.b2_maxRotation; + Box2D.Common.b2Settings.b2_contactBaumgarte = 0.2; + Box2D.Common.b2Settings.b2_timeToSleep = 0.5; + Box2D.Common.b2Settings.b2_linearSleepTolerance = 0.01; + Box2D.Common.b2Settings.b2_angularSleepTolerance = 2.0 / 180.0 * b2Settings.b2_pi; + }); +})(); +(function () { + var b2AABB = Box2D.Collision.b2AABB, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3; + + b2Mat22.b2Mat22 = function () { + this.col1 = new b2Vec2(); + this.col2 = new b2Vec2(); + }; + b2Mat22.prototype.b2Mat22 = function () { + this.SetIdentity(); + } + b2Mat22.FromAngle = function (angle) { + if (angle === undefined) angle = 0; + var mat = new b2Mat22(); + mat.Set(angle); + return mat; + } + b2Mat22.FromVV = function (c1, c2) { + var mat = new b2Mat22(); + mat.SetVV(c1, c2); + return mat; + } + b2Mat22.prototype.Set = function (angle) { + if (angle === undefined) angle = 0; + var c = Math.cos(angle); + var s = Math.sin(angle); + this.col1.x = c; + this.col2.x = (-s); + this.col1.y = s; + this.col2.y = c; + } + b2Mat22.prototype.SetVV = function (c1, c2) { + this.col1.SetV(c1); + this.col2.SetV(c2); + } + b2Mat22.prototype.Copy = function () { + var mat = new b2Mat22(); + mat.SetM(this); + return mat; + } + b2Mat22.prototype.SetM = function (m) { + this.col1.SetV(m.col1); + this.col2.SetV(m.col2); + } + b2Mat22.prototype.AddM = function (m) { + this.col1.x += m.col1.x; + this.col1.y += m.col1.y; + this.col2.x += m.col2.x; + this.col2.y += m.col2.y; + } + b2Mat22.prototype.SetIdentity = function () { + this.col1.x = 1.0; + this.col2.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 1.0; + } + b2Mat22.prototype.SetZero = function () { + this.col1.x = 0.0; + this.col2.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 0.0; + } + b2Mat22.prototype.GetAngle = function () { + return Math.atan2(this.col1.y, this.col1.x); + } + b2Mat22.prototype.GetInverse = function (out) { + var a = this.col1.x; + var b = this.col2.x; + var c = this.col1.y; + var d = this.col2.y; + var det = a * d - b * c; + if (det != 0.0) { + det = 1.0 / det; + } + out.col1.x = det * d; + out.col2.x = (-det * b); + out.col1.y = (-det * c); + out.col2.y = det * a; + return out; + } + b2Mat22.prototype.Solve = function (out, bX, bY) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + var a11 = this.col1.x; + var a12 = this.col2.x; + var a21 = this.col1.y; + var a22 = this.col2.y; + var det = a11 * a22 - a12 * a21; + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (a22 * bX - a12 * bY); + out.y = det * (a11 * bY - a21 * bX); + return out; + } + b2Mat22.prototype.Abs = function () { + this.col1.Abs(); + this.col2.Abs(); + } + b2Mat33.b2Mat33 = function () { + this.col1 = new b2Vec3(); + this.col2 = new b2Vec3(); + this.col3 = new b2Vec3(); + }; + b2Mat33.prototype.b2Mat33 = function (c1, c2, c3) { + if (c1 === undefined) c1 = null; + if (c2 === undefined) c2 = null; + if (c3 === undefined) c3 = null; + if (!c1 && !c2 && !c3) { + this.col1.SetZero(); + this.col2.SetZero(); + this.col3.SetZero(); + } + else { + this.col1.SetV(c1); + this.col2.SetV(c2); + this.col3.SetV(c3); + } + } + b2Mat33.prototype.SetVVV = function (c1, c2, c3) { + this.col1.SetV(c1); + this.col2.SetV(c2); + this.col3.SetV(c3); + } + b2Mat33.prototype.Copy = function () { + return new b2Mat33(this.col1, this.col2, this.col3); + } + b2Mat33.prototype.SetM = function (m) { + this.col1.SetV(m.col1); + this.col2.SetV(m.col2); + this.col3.SetV(m.col3); + } + b2Mat33.prototype.AddM = function (m) { + this.col1.x += m.col1.x; + this.col1.y += m.col1.y; + this.col1.z += m.col1.z; + this.col2.x += m.col2.x; + this.col2.y += m.col2.y; + this.col2.z += m.col2.z; + this.col3.x += m.col3.x; + this.col3.y += m.col3.y; + this.col3.z += m.col3.z; + } + b2Mat33.prototype.SetIdentity = function () { + this.col1.x = 1.0; + this.col2.x = 0.0; + this.col3.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 1.0; + this.col3.y = 0.0; + this.col1.z = 0.0; + this.col2.z = 0.0; + this.col3.z = 1.0; + } + b2Mat33.prototype.SetZero = function () { + this.col1.x = 0.0; + this.col2.x = 0.0; + this.col3.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 0.0; + this.col3.y = 0.0; + this.col1.z = 0.0; + this.col2.z = 0.0; + this.col3.z = 0.0; + } + b2Mat33.prototype.Solve22 = function (out, bX, bY) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + var a11 = this.col1.x; + var a12 = this.col2.x; + var a21 = this.col1.y; + var a22 = this.col2.y; + var det = a11 * a22 - a12 * a21; + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (a22 * bX - a12 * bY); + out.y = det * (a11 * bY - a21 * bX); + return out; + } + b2Mat33.prototype.Solve33 = function (out, bX, bY, bZ) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + if (bZ === undefined) bZ = 0; + var a11 = this.col1.x; + var a21 = this.col1.y; + var a31 = this.col1.z; + var a12 = this.col2.x; + var a22 = this.col2.y; + var a32 = this.col2.z; + var a13 = this.col3.x; + var a23 = this.col3.y; + var a33 = this.col3.z; + var det = a11 * (a22 * a33 - a32 * a23) + a21 * (a32 * a13 - a12 * a33) + a31 * (a12 * a23 - a22 * a13); + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (bX * (a22 * a33 - a32 * a23) + bY * (a32 * a13 - a12 * a33) + bZ * (a12 * a23 - a22 * a13)); + out.y = det * (a11 * (bY * a33 - bZ * a23) + a21 * (bZ * a13 - bX * a33) + a31 * (bX * a23 - bY * a13)); + out.z = det * (a11 * (a22 * bZ - a32 * bY) + a21 * (a32 * bX - a12 * bZ) + a31 * (a12 * bY - a22 * bX)); + return out; + } + b2Math.b2Math = function () {}; + b2Math.IsValid = function (x) { + if (x === undefined) x = 0; + return isFinite(x); + } + b2Math.Dot = function (a, b) { + return a.x * b.x + a.y * b.y; + } + b2Math.CrossVV = function (a, b) { + return a.x * b.y - a.y * b.x; + } + b2Math.CrossVF = function (a, s) { + if (s === undefined) s = 0; + var v = new b2Vec2(s * a.y, (-s * a.x)); + return v; + } + b2Math.CrossFV = function (s, a) { + if (s === undefined) s = 0; + var v = new b2Vec2((-s * a.y), s * a.x); + return v; + } + b2Math.MulMV = function (A, v) { + var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y); + return u; + } + b2Math.MulTMV = function (A, v) { + var u = new b2Vec2(b2Math.Dot(v, A.col1), b2Math.Dot(v, A.col2)); + return u; + } + b2Math.MulX = function (T, v) { + var a = b2Math.MulMV(T.R, v); + a.x += T.position.x; + a.y += T.position.y; + return a; + } + b2Math.MulXT = function (T, v) { + var a = b2Math.SubtractVV(v, T.position); + var tX = (a.x * T.R.col1.x + a.y * T.R.col1.y); + a.y = (a.x * T.R.col2.x + a.y * T.R.col2.y); + a.x = tX; + return a; + } + b2Math.AddVV = function (a, b) { + var v = new b2Vec2(a.x + b.x, a.y + b.y); + return v; + } + b2Math.SubtractVV = function (a, b) { + var v = new b2Vec2(a.x - b.x, a.y - b.y); + return v; + } + b2Math.Distance = function (a, b) { + var cX = a.x - b.x; + var cY = a.y - b.y; + return Math.sqrt(cX * cX + cY * cY); + } + b2Math.DistanceSquared = function (a, b) { + var cX = a.x - b.x; + var cY = a.y - b.y; + return (cX * cX + cY * cY); + } + b2Math.MulFV = function (s, a) { + if (s === undefined) s = 0; + var v = new b2Vec2(s * a.x, s * a.y); + return v; + } + b2Math.AddMM = function (A, B) { + var C = b2Mat22.FromVV(b2Math.AddVV(A.col1, B.col1), b2Math.AddVV(A.col2, B.col2)); + return C; + } + b2Math.MulMM = function (A, B) { + var C = b2Mat22.FromVV(b2Math.MulMV(A, B.col1), b2Math.MulMV(A, B.col2)); + return C; + } + b2Math.MulTMM = function (A, B) { + var c1 = new b2Vec2(b2Math.Dot(A.col1, B.col1), b2Math.Dot(A.col2, B.col1)); + var c2 = new b2Vec2(b2Math.Dot(A.col1, B.col2), b2Math.Dot(A.col2, B.col2)); + var C = b2Mat22.FromVV(c1, c2); + return C; + } + b2Math.Abs = function (a) { + if (a === undefined) a = 0; + return a > 0.0 ? a : (-a); + } + b2Math.AbsV = function (a) { + var b = new b2Vec2(b2Math.Abs(a.x), b2Math.Abs(a.y)); + return b; + } + b2Math.AbsM = function (A) { + var B = b2Mat22.FromVV(b2Math.AbsV(A.col1), b2Math.AbsV(A.col2)); + return B; + } + b2Math.Min = function (a, b) { + if (a === undefined) a = 0; + if (b === undefined) b = 0; + return a < b ? a : b; + } + b2Math.MinV = function (a, b) { + var c = new b2Vec2(b2Math.Min(a.x, b.x), b2Math.Min(a.y, b.y)); + return c; + } + b2Math.Max = function (a, b) { + if (a === undefined) a = 0; + if (b === undefined) b = 0; + return a > b ? a : b; + } + b2Math.MaxV = function (a, b) { + var c = new b2Vec2(b2Math.Max(a.x, b.x), b2Math.Max(a.y, b.y)); + return c; + } + b2Math.Clamp = function (a, low, high) { + if (a === undefined) a = 0; + if (low === undefined) low = 0; + if (high === undefined) high = 0; + return a < low ? low : a > high ? high : a; + } + b2Math.ClampV = function (a, low, high) { + return b2Math.MaxV(low, b2Math.MinV(a, high)); + } + b2Math.Swap = function (a, b) { + var tmp = a[0]; + a[0] = b[0]; + b[0] = tmp; + } + b2Math.Random = function () { + return Math.random() * 2 - 1; + } + b2Math.RandomRange = function (lo, hi) { + if (lo === undefined) lo = 0; + if (hi === undefined) hi = 0; + var r = Math.random(); + r = (hi - lo) * r + lo; + return r; + } + b2Math.NextPowerOfTwo = function (x) { + if (x === undefined) x = 0; + x |= (x >> 1) & 0x7FFFFFFF; + x |= (x >> 2) & 0x3FFFFFFF; + x |= (x >> 4) & 0x0FFFFFFF; + x |= (x >> 8) & 0x00FFFFFF; + x |= (x >> 16) & 0x0000FFFF; + return x + 1; + } + b2Math.IsPowerOfTwo = function (x) { + if (x === undefined) x = 0; + var result = x > 0 && (x & (x - 1)) == 0; + return result; + } + Box2D.postDefs.push(function () { + Box2D.Common.Math.b2Math.b2Vec2_zero = new b2Vec2(0.0, 0.0); + Box2D.Common.Math.b2Math.b2Mat22_identity = b2Mat22.FromVV(new b2Vec2(1.0, 0.0), new b2Vec2(0.0, 1.0)); + Box2D.Common.Math.b2Math.b2Transform_identity = new b2Transform(b2Math.b2Vec2_zero, b2Math.b2Mat22_identity); + }); + b2Sweep.b2Sweep = function () { + this.localCenter = new b2Vec2(); + this.c0 = new b2Vec2; + this.c = new b2Vec2(); + }; + b2Sweep.prototype.Set = function (other) { + this.localCenter.SetV(other.localCenter); + this.c0.SetV(other.c0); + this.c.SetV(other.c); + this.a0 = other.a0; + this.a = other.a; + this.t0 = other.t0; + } + b2Sweep.prototype.Copy = function () { + var copy = new b2Sweep(); + copy.localCenter.SetV(this.localCenter); + copy.c0.SetV(this.c0); + copy.c.SetV(this.c); + copy.a0 = this.a0; + copy.a = this.a; + copy.t0 = this.t0; + return copy; + } + b2Sweep.prototype.GetTransform = function (xf, alpha) { + if (alpha === undefined) alpha = 0; + xf.position.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; + xf.position.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; + var angle = (1.0 - alpha) * this.a0 + alpha * this.a; + xf.R.Set(angle); + var tMat = xf.R; + xf.position.x -= (tMat.col1.x * this.localCenter.x + tMat.col2.x * this.localCenter.y); + xf.position.y -= (tMat.col1.y * this.localCenter.x + tMat.col2.y * this.localCenter.y); + } + b2Sweep.prototype.Advance = function (t) { + if (t === undefined) t = 0; + if (this.t0 < t && 1.0 - this.t0 > Number.MIN_VALUE) { + var alpha = (t - this.t0) / (1.0 - this.t0); + this.c0.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; + this.c0.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; + this.a0 = (1.0 - alpha) * this.a0 + alpha * this.a; + this.t0 = t; + } + } + b2Transform.b2Transform = function () { + this.position = new b2Vec2; + this.R = new b2Mat22(); + }; + b2Transform.prototype.b2Transform = function (pos, r) { + if (pos === undefined) pos = null; + if (r === undefined) r = null; + if (pos) { + this.position.SetV(pos); + this.R.SetM(r); + } + } + b2Transform.prototype.Initialize = function (pos, r) { + this.position.SetV(pos); + this.R.SetM(r); + } + b2Transform.prototype.SetIdentity = function () { + this.position.SetZero(); + this.R.SetIdentity(); + } + b2Transform.prototype.Set = function (x) { + this.position.SetV(x.position); + this.R.SetM(x.R); + } + b2Transform.prototype.GetAngle = function () { + return Math.atan2(this.R.col1.y, this.R.col1.x); + } + b2Vec2.b2Vec2 = function () {}; + b2Vec2.prototype.b2Vec2 = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + this.x = x_; + this.y = y_; + } + b2Vec2.prototype.SetZero = function () { + this.x = 0.0; + this.y = 0.0; + } + b2Vec2.prototype.Set = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + this.x = x_; + this.y = y_; + } + b2Vec2.prototype.SetV = function (v) { + this.x = v.x; + this.y = v.y; + } + b2Vec2.prototype.GetNegative = function () { + return new b2Vec2((-this.x), (-this.y)); + } + b2Vec2.prototype.NegativeSelf = function () { + this.x = (-this.x); + this.y = (-this.y); + } + b2Vec2.Make = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + return new b2Vec2(x_, y_); + } + b2Vec2.prototype.Copy = function () { + return new b2Vec2(this.x, this.y); + } + b2Vec2.prototype.Add = function (v) { + this.x += v.x; + this.y += v.y; + } + b2Vec2.prototype.Subtract = function (v) { + this.x -= v.x; + this.y -= v.y; + } + b2Vec2.prototype.Multiply = function (a) { + if (a === undefined) a = 0; + this.x *= a; + this.y *= a; + } + b2Vec2.prototype.MulM = function (A) { + var tX = this.x; + this.x = A.col1.x * tX + A.col2.x * this.y; + this.y = A.col1.y * tX + A.col2.y * this.y; + } + b2Vec2.prototype.MulTM = function (A) { + var tX = b2Math.Dot(this, A.col1); + this.y = b2Math.Dot(this, A.col2); + this.x = tX; + } + b2Vec2.prototype.CrossVF = function (s) { + if (s === undefined) s = 0; + var tX = this.x; + this.x = s * this.y; + this.y = (-s * tX); + } + b2Vec2.prototype.CrossFV = function (s) { + if (s === undefined) s = 0; + var tX = this.x; + this.x = (-s * this.y); + this.y = s * tX; + } + b2Vec2.prototype.MinV = function (b) { + this.x = this.x < b.x ? this.x : b.x; + this.y = this.y < b.y ? this.y : b.y; + } + b2Vec2.prototype.MaxV = function (b) { + this.x = this.x > b.x ? this.x : b.x; + this.y = this.y > b.y ? this.y : b.y; + } + b2Vec2.prototype.Abs = function () { + if (this.x < 0) this.x = (-this.x); + if (this.y < 0) this.y = (-this.y); + } + b2Vec2.prototype.Length = function () { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + b2Vec2.prototype.LengthSquared = function () { + return (this.x * this.x + this.y * this.y); + } + b2Vec2.prototype.Normalize = function () { + var length = Math.sqrt(this.x * this.x + this.y * this.y); + if (length < Number.MIN_VALUE) { + return 0.0; + } + var invLength = 1.0 / length; + this.x *= invLength; + this.y *= invLength; + return length; + } + b2Vec2.prototype.IsValid = function () { + return b2Math.IsValid(this.x) && b2Math.IsValid(this.y); + } + b2Vec3.b2Vec3 = function () {}; + b2Vec3.prototype.b2Vec3 = function (x, y, z) { + if (x === undefined) x = 0; + if (y === undefined) y = 0; + if (z === undefined) z = 0; + this.x = x; + this.y = y; + this.z = z; + } + b2Vec3.prototype.SetZero = function () { + this.x = this.y = this.z = 0.0; + } + b2Vec3.prototype.Set = function (x, y, z) { + if (x === undefined) x = 0; + if (y === undefined) y = 0; + if (z === undefined) z = 0; + this.x = x; + this.y = y; + this.z = z; + } + b2Vec3.prototype.SetV = function (v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + } + b2Vec3.prototype.GetNegative = function () { + return new b2Vec3((-this.x), (-this.y), (-this.z)); + } + b2Vec3.prototype.NegativeSelf = function () { + this.x = (-this.x); + this.y = (-this.y); + this.z = (-this.z); + } + b2Vec3.prototype.Copy = function () { + return new b2Vec3(this.x, this.y, this.z); + } + b2Vec3.prototype.Add = function (v) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + } + b2Vec3.prototype.Subtract = function (v) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + } + b2Vec3.prototype.Multiply = function (a) { + if (a === undefined) a = 0; + this.x *= a; + this.y *= a; + this.z *= a; + } +})(); +(function () { + var b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, + b2Contact = Box2D.Dynamics.Contacts.b2Contact, + b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, + b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, + b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, + b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, + b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, + b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, + b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, + b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, + b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, + b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, + b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, + b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, + b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, + b2Controller = Box2D.Dynamics.Controllers.b2Controller, + b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, + b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, + b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, + b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, + b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, + b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, + b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, + b2Joint = Box2D.Dynamics.Joints.b2Joint, + b2JointDef = Box2D.Dynamics.Joints.b2JointDef, + b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, + b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, + b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, + b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, + b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, + b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, + b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, + b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, + b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, + b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, + b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, + b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, + b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef; + + b2Body.b2Body = function () { + this.m_xf = new b2Transform(); + this.m_sweep = new b2Sweep(); + this.m_linearVelocity = new b2Vec2(); + this.m_force = new b2Vec2(); + }; + b2Body.prototype.connectEdges = function (s1, s2, angle1) { + if (angle1 === undefined) angle1 = 0; + var angle2 = Math.atan2(s2.GetDirectionVector().y, s2.GetDirectionVector().x); + var coreOffset = Math.tan((angle2 - angle1) * 0.5); + var core = b2Math.MulFV(coreOffset, s2.GetDirectionVector()); + core = b2Math.SubtractVV(core, s2.GetNormalVector()); + core = b2Math.MulFV(b2Settings.b2_toiSlop, core); + core = b2Math.AddVV(core, s2.GetVertex1()); + var cornerDir = b2Math.AddVV(s1.GetDirectionVector(), s2.GetDirectionVector()); + cornerDir.Normalize(); + var convex = b2Math.Dot(s1.GetDirectionVector(), s2.GetNormalVector()) > 0.0; + s1.SetNextEdge(s2, core, cornerDir, convex); + s2.SetPrevEdge(s1, core, cornerDir, convex); + return angle2; + } + b2Body.prototype.CreateFixture = function (def) { + if (this.m_world.IsLocked() == true) { + return null; + } + var fixture = new b2Fixture(); + fixture.Create(this, this.m_xf, def); + if (this.m_flags & b2Body.e_activeFlag) { + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + fixture.CreateProxy(broadPhase, this.m_xf); + } + fixture.m_next = this.m_fixtureList; + this.m_fixtureList = fixture; + ++this.m_fixtureCount; + fixture.m_body = this; + if (fixture.m_density > 0.0) { + this.ResetMassData(); + } + this.m_world.m_flags |= b2World.e_newFixture; + return fixture; + } + b2Body.prototype.CreateFixture2 = function (shape, density) { + if (density === undefined) density = 0.0; + var def = new b2FixtureDef(); + def.shape = shape; + def.density = density; + return this.CreateFixture(def); + } + b2Body.prototype.DestroyFixture = function (fixture) { + if (this.m_world.IsLocked() == true) { + return; + } + var node = this.m_fixtureList; + var ppF = null; + var found = false; + while (node != null) { + if (node == fixture) { + if (ppF) ppF.m_next = fixture.m_next; + else this.m_fixtureList = fixture.m_next; + found = true; + break; + } + ppF = node; + node = node.m_next; + } + var edge = this.m_contactList; + while (edge) { + var c = edge.contact; + edge = edge.next; + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + if (fixture == fixtureA || fixture == fixtureB) { + this.m_world.m_contactManager.Destroy(c); + } + } + if (this.m_flags & b2Body.e_activeFlag) { + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + fixture.DestroyProxy(broadPhase); + } + else {} + fixture.Destroy(); + fixture.m_body = null; + fixture.m_next = null; + --this.m_fixtureCount; + this.ResetMassData(); + } + b2Body.prototype.SetPositionAndAngle = function (position, angle) { + if (angle === undefined) angle = 0; + var f; + if (this.m_world.IsLocked() == true) { + return; + } + this.m_xf.R.Set(angle); + this.m_xf.position.SetV(position); + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_sweep.c.x += this.m_xf.position.x; + this.m_sweep.c.y += this.m_xf.position.y; + this.m_sweep.c0.SetV(this.m_sweep.c); + this.m_sweep.a0 = this.m_sweep.a = angle; + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.Synchronize(broadPhase, this.m_xf, this.m_xf); + } + this.m_world.m_contactManager.FindNewContacts(); + } + b2Body.prototype.SetTransform = function (xf) { + this.SetPositionAndAngle(xf.position, xf.GetAngle()); + } + b2Body.prototype.GetTransform = function () { + return this.m_xf; + } + b2Body.prototype.GetPosition = function () { + return this.m_xf.position; + } + b2Body.prototype.SetPosition = function (position) { + this.SetPositionAndAngle(position, this.GetAngle()); + } + b2Body.prototype.GetAngle = function () { + return this.m_sweep.a; + } + b2Body.prototype.SetAngle = function (angle) { + if (angle === undefined) angle = 0; + this.SetPositionAndAngle(this.GetPosition(), angle); + } + b2Body.prototype.GetWorldCenter = function () { + return this.m_sweep.c; + } + b2Body.prototype.GetLocalCenter = function () { + return this.m_sweep.localCenter; + } + b2Body.prototype.SetLinearVelocity = function (v) { + if (this.m_type == b2Body.b2_staticBody) { + return; + } + this.m_linearVelocity.SetV(v); + } + b2Body.prototype.GetLinearVelocity = function () { + return this.m_linearVelocity; + } + b2Body.prototype.SetAngularVelocity = function (omega) { + if (omega === undefined) omega = 0; + if (this.m_type == b2Body.b2_staticBody) { + return; + } + this.m_angularVelocity = omega; + } + b2Body.prototype.GetAngularVelocity = function () { + return this.m_angularVelocity; + } + b2Body.prototype.GetDefinition = function () { + var bd = new b2BodyDef(); + bd.type = this.GetType(); + bd.allowSleep = (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; + bd.angle = this.GetAngle(); + bd.angularDamping = this.m_angularDamping; + bd.angularVelocity = this.m_angularVelocity; + bd.fixedRotation = (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; + bd.bullet = (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; + bd.awake = (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; + bd.linearDamping = this.m_linearDamping; + bd.linearVelocity.SetV(this.GetLinearVelocity()); + bd.position = this.GetPosition(); + bd.userData = this.GetUserData(); + return bd; + } + b2Body.prototype.ApplyForce = function (force, point) { + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_force.x += force.x; + this.m_force.y += force.y; + this.m_torque += ((point.x - this.m_sweep.c.x) * force.y - (point.y - this.m_sweep.c.y) * force.x); + } + b2Body.prototype.ApplyTorque = function (torque) { + if (torque === undefined) torque = 0; + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_torque += torque; + } + b2Body.prototype.ApplyImpulse = function (impulse, point) { + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_linearVelocity.x += this.m_invMass * impulse.x; + this.m_linearVelocity.y += this.m_invMass * impulse.y; + this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x); + } + b2Body.prototype.Split = function (callback) { + var linearVelocity = this.GetLinearVelocity().Copy(); + var angularVelocity = this.GetAngularVelocity(); + var center = this.GetWorldCenter(); + var body1 = this; + var body2 = this.m_world.CreateBody(this.GetDefinition()); + var prev; + for (var f = body1.m_fixtureList; f;) { + if (callback(f)) { + var next = f.m_next; + if (prev) { + prev.m_next = next; + } + else { + body1.m_fixtureList = next; + } + body1.m_fixtureCount--; + f.m_next = body2.m_fixtureList; + body2.m_fixtureList = f; + body2.m_fixtureCount++; + f.m_body = body2; + f = next; + } + else { + prev = f; + f = f.m_next; + } + } + body1.ResetMassData(); + body2.ResetMassData(); + var center1 = body1.GetWorldCenter(); + var center2 = body2.GetWorldCenter(); + var velocity1 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center))); + var velocity2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center))); + body1.SetLinearVelocity(velocity1); + body2.SetLinearVelocity(velocity2); + body1.SetAngularVelocity(angularVelocity); + body2.SetAngularVelocity(angularVelocity); + body1.SynchronizeFixtures(); + body2.SynchronizeFixtures(); + return body2; + } + b2Body.prototype.Merge = function (other) { + var f; + for (f = other.m_fixtureList; + f;) { + var next = f.m_next; + other.m_fixtureCount--; + f.m_next = this.m_fixtureList; + this.m_fixtureList = f; + this.m_fixtureCount++; + f.m_body = body2; + f = next; + } + body1.m_fixtureCount = 0; + var body1 = this; + var body2 = other; + var center1 = body1.GetWorldCenter(); + var center2 = body2.GetWorldCenter(); + var velocity1 = body1.GetLinearVelocity().Copy(); + var velocity2 = body2.GetLinearVelocity().Copy(); + var angular1 = body1.GetAngularVelocity(); + var angular = body2.GetAngularVelocity(); + body1.ResetMassData(); + this.SynchronizeFixtures(); + } + b2Body.prototype.GetMass = function () { + return this.m_mass; + } + b2Body.prototype.GetInertia = function () { + return this.m_I; + } + b2Body.prototype.GetMassData = function (data) { + data.mass = this.m_mass; + data.I = this.m_I; + data.center.SetV(this.m_sweep.localCenter); + } + b2Body.prototype.SetMassData = function (massData) { + b2Settings.b2Assert(this.m_world.IsLocked() == false); + if (this.m_world.IsLocked() == true) { + return; + } + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + this.m_invMass = 0.0; + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_mass = massData.mass; + if (this.m_mass <= 0.0) { + this.m_mass = 1.0; + } + this.m_invMass = 1.0 / this.m_mass; + if (massData.I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { + this.m_I = massData.I - this.m_mass * (massData.center.x * massData.center.x + massData.center.y * massData.center.y); + this.m_invI = 1.0 / this.m_I; + } + var oldCenter = this.m_sweep.c.Copy(); + this.m_sweep.localCenter.SetV(massData.center); + this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); + this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); + } + b2Body.prototype.ResetMassData = function () { + this.m_mass = 0.0; + this.m_invMass = 0.0; + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_sweep.localCenter.SetZero(); + if (this.m_type == b2Body.b2_staticBody || this.m_type == b2Body.b2_kinematicBody) { + return; + } + var center = b2Vec2.Make(0, 0); + for (var f = this.m_fixtureList; f; f = f.m_next) { + if (f.m_density == 0.0) { + continue; + } + var massData = f.GetMassData(); + this.m_mass += massData.mass; + center.x += massData.center.x * massData.mass; + center.y += massData.center.y * massData.mass; + this.m_I += massData.I; + } + if (this.m_mass > 0.0) { + this.m_invMass = 1.0 / this.m_mass; + center.x *= this.m_invMass; + center.y *= this.m_invMass; + } + else { + this.m_mass = 1.0; + this.m_invMass = 1.0; + } + if (this.m_I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { + this.m_I -= this.m_mass * (center.x * center.x + center.y * center.y); + this.m_I *= this.m_inertiaScale; + b2Settings.b2Assert(this.m_I > 0); + this.m_invI = 1.0 / this.m_I; + } + else { + this.m_I = 0.0; + this.m_invI = 0.0; + } + var oldCenter = this.m_sweep.c.Copy(); + this.m_sweep.localCenter.SetV(center); + this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); + this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); + } + b2Body.prototype.GetWorldPoint = function (localPoint) { + var A = this.m_xf.R; + var u = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); + u.x += this.m_xf.position.x; + u.y += this.m_xf.position.y; + return u; + } + b2Body.prototype.GetWorldVector = function (localVector) { + return b2Math.MulMV(this.m_xf.R, localVector); + } + b2Body.prototype.GetLocalPoint = function (worldPoint) { + return b2Math.MulXT(this.m_xf, worldPoint); + } + b2Body.prototype.GetLocalVector = function (worldVector) { + return b2Math.MulTMV(this.m_xf.R, worldVector); + } + b2Body.prototype.GetLinearVelocityFromWorldPoint = function (worldPoint) { + return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); + } + b2Body.prototype.GetLinearVelocityFromLocalPoint = function (localPoint) { + var A = this.m_xf.R; + var worldPoint = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); + worldPoint.x += this.m_xf.position.x; + worldPoint.y += this.m_xf.position.y; + return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); + } + b2Body.prototype.GetLinearDamping = function () { + return this.m_linearDamping; + } + b2Body.prototype.SetLinearDamping = function (linearDamping) { + if (linearDamping === undefined) linearDamping = 0; + this.m_linearDamping = linearDamping; + } + b2Body.prototype.GetAngularDamping = function () { + return this.m_angularDamping; + } + b2Body.prototype.SetAngularDamping = function (angularDamping) { + if (angularDamping === undefined) angularDamping = 0; + this.m_angularDamping = angularDamping; + } + b2Body.prototype.SetType = function (type) { + if (type === undefined) type = 0; + if (this.m_type == type) { + return; + } + this.m_type = type; + this.ResetMassData(); + if (this.m_type == b2Body.b2_staticBody) { + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0.0; + } + this.SetAwake(true); + this.m_force.SetZero(); + this.m_torque = 0.0; + for (var ce = this.m_contactList; ce; ce = ce.next) { + ce.contact.FlagForFiltering(); + } + } + b2Body.prototype.GetType = function () { + return this.m_type; + } + b2Body.prototype.SetBullet = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_bulletFlag; + } + else { + this.m_flags &= ~b2Body.e_bulletFlag; + } + } + b2Body.prototype.IsBullet = function () { + return (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; + } + b2Body.prototype.SetSleepingAllowed = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_allowSleepFlag; + } + else { + this.m_flags &= ~b2Body.e_allowSleepFlag; + this.SetAwake(true); + } + } + b2Body.prototype.SetAwake = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_awakeFlag; + this.m_sleepTime = 0.0; + } + else { + this.m_flags &= ~b2Body.e_awakeFlag; + this.m_sleepTime = 0.0; + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0.0; + this.m_force.SetZero(); + this.m_torque = 0.0; + } + } + b2Body.prototype.IsAwake = function () { + return (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; + } + b2Body.prototype.SetFixedRotation = function (fixed) { + if (fixed) { + this.m_flags |= b2Body.e_fixedRotationFlag; + } + else { + this.m_flags &= ~b2Body.e_fixedRotationFlag; + } + this.ResetMassData(); + } + b2Body.prototype.IsFixedRotation = function () { + return (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; + } + b2Body.prototype.SetActive = function (flag) { + if (flag == this.IsActive()) { + return; + } + var broadPhase; + var f; + if (flag) { + this.m_flags |= b2Body.e_activeFlag; + broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.CreateProxy(broadPhase, this.m_xf); + } + } + else { + this.m_flags &= ~b2Body.e_activeFlag; + broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.DestroyProxy(broadPhase); + } + var ce = this.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_world.m_contactManager.Destroy(ce0.contact); + } + this.m_contactList = null; + } + } + b2Body.prototype.IsActive = function () { + return (this.m_flags & b2Body.e_activeFlag) == b2Body.e_activeFlag; + } + b2Body.prototype.IsSleepingAllowed = function () { + return (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; + } + b2Body.prototype.GetFixtureList = function () { + return this.m_fixtureList; + } + b2Body.prototype.GetJointList = function () { + return this.m_jointList; + } + b2Body.prototype.GetControllerList = function () { + return this.m_controllerList; + } + b2Body.prototype.GetContactList = function () { + return this.m_contactList; + } + b2Body.prototype.GetNext = function () { + return this.m_next; + } + b2Body.prototype.GetUserData = function () { + return this.m_userData; + } + b2Body.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Body.prototype.GetWorld = function () { + return this.m_world; + } + b2Body.prototype.b2Body = function (bd, world) { + this.m_flags = 0; + if (bd.bullet) { + this.m_flags |= b2Body.e_bulletFlag; + } + if (bd.fixedRotation) { + this.m_flags |= b2Body.e_fixedRotationFlag; + } + if (bd.allowSleep) { + this.m_flags |= b2Body.e_allowSleepFlag; + } + if (bd.awake) { + this.m_flags |= b2Body.e_awakeFlag; + } + if (bd.active) { + this.m_flags |= b2Body.e_activeFlag; + } + this.m_world = world; + this.m_xf.position.SetV(bd.position); + this.m_xf.R.Set(bd.angle); + this.m_sweep.localCenter.SetZero(); + this.m_sweep.t0 = 1.0; + this.m_sweep.a0 = this.m_sweep.a = bd.angle; + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_sweep.c.x += this.m_xf.position.x; + this.m_sweep.c.y += this.m_xf.position.y; + this.m_sweep.c0.SetV(this.m_sweep.c); + this.m_jointList = null; + this.m_controllerList = null; + this.m_contactList = null; + this.m_controllerCount = 0; + this.m_prev = null; + this.m_next = null; + this.m_linearVelocity.SetV(bd.linearVelocity); + this.m_angularVelocity = bd.angularVelocity; + this.m_linearDamping = bd.linearDamping; + this.m_angularDamping = bd.angularDamping; + this.m_force.Set(0.0, 0.0); + this.m_torque = 0.0; + this.m_sleepTime = 0.0; + this.m_type = bd.type; + if (this.m_type == b2Body.b2_dynamicBody) { + this.m_mass = 1.0; + this.m_invMass = 1.0; + } + else { + this.m_mass = 0.0; + this.m_invMass = 0.0; + } + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_inertiaScale = bd.inertiaScale; + this.m_userData = bd.userData; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + } + b2Body.prototype.SynchronizeFixtures = function () { + var xf1 = b2Body.s_xf1; + xf1.R.Set(this.m_sweep.a0); + var tMat = xf1.R; + var tVec = this.m_sweep.localCenter; + xf1.position.x = this.m_sweep.c0.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + xf1.position.y = this.m_sweep.c0.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var f; + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.Synchronize(broadPhase, xf1, this.m_xf); + } + } + b2Body.prototype.SynchronizeTransform = function () { + this.m_xf.R.Set(this.m_sweep.a); + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_xf.position.x = this.m_sweep.c.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_xf.position.y = this.m_sweep.c.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + } + b2Body.prototype.ShouldCollide = function (other) { + if (this.m_type != b2Body.b2_dynamicBody && other.m_type != b2Body.b2_dynamicBody) { + return false; + } + for (var jn = this.m_jointList; jn; jn = jn.next) { + if (jn.other == other) if (jn.joint.m_collideConnected == false) { + return false; + } + } + return true; + } + b2Body.prototype.Advance = function (t) { + if (t === undefined) t = 0; + this.m_sweep.Advance(t); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_sweep.a = this.m_sweep.a0; + this.SynchronizeTransform(); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2Body.s_xf1 = new b2Transform(); + Box2D.Dynamics.b2Body.e_islandFlag = 0x0001; + Box2D.Dynamics.b2Body.e_awakeFlag = 0x0002; + Box2D.Dynamics.b2Body.e_allowSleepFlag = 0x0004; + Box2D.Dynamics.b2Body.e_bulletFlag = 0x0008; + Box2D.Dynamics.b2Body.e_fixedRotationFlag = 0x0010; + Box2D.Dynamics.b2Body.e_activeFlag = 0x0020; + Box2D.Dynamics.b2Body.b2_staticBody = 0; + Box2D.Dynamics.b2Body.b2_kinematicBody = 1; + Box2D.Dynamics.b2Body.b2_dynamicBody = 2; + }); + b2BodyDef.b2BodyDef = function () { + this.position = new b2Vec2(); + this.linearVelocity = new b2Vec2(); + }; + b2BodyDef.prototype.b2BodyDef = function () { + this.userData = null; + this.position.Set(0.0, 0.0); + this.angle = 0.0; + this.linearVelocity.Set(0, 0); + this.angularVelocity = 0.0; + this.linearDamping = 0.0; + this.angularDamping = 0.0; + this.allowSleep = true; + this.awake = true; + this.fixedRotation = false; + this.bullet = false; + this.type = b2Body.b2_staticBody; + this.active = true; + this.inertiaScale = 1.0; + } + b2ContactFilter.b2ContactFilter = function () {}; + b2ContactFilter.prototype.ShouldCollide = function (fixtureA, fixtureB) { + var filter1 = fixtureA.GetFilterData(); + var filter2 = fixtureB.GetFilterData(); + if (filter1.groupIndex == filter2.groupIndex && filter1.groupIndex != 0) { + return filter1.groupIndex > 0; + } + var collide = (filter1.maskBits & filter2.categoryBits) != 0 && (filter1.categoryBits & filter2.maskBits) != 0; + return collide; + } + b2ContactFilter.prototype.RayCollide = function (userData, fixture) { + if (!userData) return true; + return this.ShouldCollide((userData instanceof b2Fixture ? userData : null), fixture); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactFilter.b2_defaultFilter = new b2ContactFilter(); + }); + b2ContactImpulse.b2ContactImpulse = function () { + this.normalImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + this.tangentImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + }; + b2ContactListener.b2ContactListener = function () {}; + b2ContactListener.prototype.BeginContact = function (contact) {} + b2ContactListener.prototype.EndContact = function (contact) {} + b2ContactListener.prototype.PreSolve = function (contact, oldManifold) {} + b2ContactListener.prototype.PostSolve = function (contact, impulse) {} + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactListener.b2_defaultListener = new b2ContactListener(); + }); + b2ContactManager.b2ContactManager = function () {}; + b2ContactManager.prototype.b2ContactManager = function () { + this.m_world = null; + this.m_contactCount = 0; + this.m_contactFilter = b2ContactFilter.b2_defaultFilter; + this.m_contactListener = b2ContactListener.b2_defaultListener; + this.m_contactFactory = new b2ContactFactory(this.m_allocator); + this.m_broadPhase = new b2DynamicTreeBroadPhase(); + } + b2ContactManager.prototype.AddPair = function (proxyUserDataA, proxyUserDataB) { + var fixtureA = (proxyUserDataA instanceof b2Fixture ? proxyUserDataA : null); + var fixtureB = (proxyUserDataB instanceof b2Fixture ? proxyUserDataB : null); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA == bodyB) return; + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + var fA = edge.contact.GetFixtureA(); + var fB = edge.contact.GetFixtureB(); + if (fA == fixtureA && fB == fixtureB) return; + if (fA == fixtureB && fB == fixtureA) return; + } + edge = edge.next; + } + if (bodyB.ShouldCollide(bodyA) == false) { + return; + } + if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { + return; + } + var c = this.m_contactFactory.Create(fixtureA, fixtureB); + fixtureA = c.GetFixtureA(); + fixtureB = c.GetFixtureB(); + bodyA = fixtureA.m_body; + bodyB = fixtureB.m_body; + c.m_prev = null; + c.m_next = this.m_world.m_contactList; + if (this.m_world.m_contactList != null) { + this.m_world.m_contactList.m_prev = c; + } + this.m_world.m_contactList = c; + c.m_nodeA.contact = c; + c.m_nodeA.other = bodyB; + c.m_nodeA.prev = null; + c.m_nodeA.next = bodyA.m_contactList; + if (bodyA.m_contactList != null) { + bodyA.m_contactList.prev = c.m_nodeA; + } + bodyA.m_contactList = c.m_nodeA; + c.m_nodeB.contact = c; + c.m_nodeB.other = bodyA; + c.m_nodeB.prev = null; + c.m_nodeB.next = bodyB.m_contactList; + if (bodyB.m_contactList != null) { + bodyB.m_contactList.prev = c.m_nodeB; + } + bodyB.m_contactList = c.m_nodeB; + ++this.m_world.m_contactCount; + return; + } + b2ContactManager.prototype.FindNewContacts = function () { + this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this, this.AddPair)); + } + b2ContactManager.prototype.Destroy = function (c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (c.IsTouching()) { + this.m_contactListener.EndContact(c); + } + if (c.m_prev) { + c.m_prev.m_next = c.m_next; + } + if (c.m_next) { + c.m_next.m_prev = c.m_prev; + } + if (c == this.m_world.m_contactList) { + this.m_world.m_contactList = c.m_next; + } + if (c.m_nodeA.prev) { + c.m_nodeA.prev.next = c.m_nodeA.next; + } + if (c.m_nodeA.next) { + c.m_nodeA.next.prev = c.m_nodeA.prev; + } + if (c.m_nodeA == bodyA.m_contactList) { + bodyA.m_contactList = c.m_nodeA.next; + } + if (c.m_nodeB.prev) { + c.m_nodeB.prev.next = c.m_nodeB.next; + } + if (c.m_nodeB.next) { + c.m_nodeB.next.prev = c.m_nodeB.prev; + } + if (c.m_nodeB == bodyB.m_contactList) { + bodyB.m_contactList = c.m_nodeB.next; + } + this.m_contactFactory.Destroy(c); + --this.m_contactCount; + } + b2ContactManager.prototype.Collide = function () { + var c = this.m_world.m_contactList; + while (c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA.IsAwake() == false && bodyB.IsAwake() == false) { + c = c.GetNext(); + continue; + } + if (c.m_flags & b2Contact.e_filterFlag) { + if (bodyB.ShouldCollide(bodyA) == false) { + var cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { + cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + c.m_flags &= ~b2Contact.e_filterFlag; + } + var proxyA = fixtureA.m_proxy; + var proxyB = fixtureB.m_proxy; + var overlap = this.m_broadPhase.TestOverlap(proxyA, proxyB); + if (overlap == false) { + cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + c.Update(this.m_contactListener); + c = c.GetNext(); + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactManager.s_evalCP = new b2ContactPoint(); + }); + b2DebugDraw.b2DebugDraw = function () {}; + b2DebugDraw.prototype.b2DebugDraw = function () {} + b2DebugDraw.prototype.SetFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.GetFlags = function () {} + b2DebugDraw.prototype.AppendFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.ClearFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.SetSprite = function (sprite) {} + b2DebugDraw.prototype.GetSprite = function () {} + b2DebugDraw.prototype.SetDrawScale = function (drawScale) { + if (drawScale === undefined) drawScale = 0; + } + b2DebugDraw.prototype.GetDrawScale = function () {} + b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { + if (lineThickness === undefined) lineThickness = 0; + } + b2DebugDraw.prototype.GetLineThickness = function () {} + b2DebugDraw.prototype.SetAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + } + b2DebugDraw.prototype.GetAlpha = function () {} + b2DebugDraw.prototype.SetFillAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + } + b2DebugDraw.prototype.GetFillAlpha = function () {} + b2DebugDraw.prototype.SetXFormScale = function (xformScale) { + if (xformScale === undefined) xformScale = 0; + } + b2DebugDraw.prototype.GetXFormScale = function () {} + b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { + if (vertexCount === undefined) vertexCount = 0; + } + b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { + if (vertexCount === undefined) vertexCount = 0; + } + b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { + if (radius === undefined) radius = 0; + } + b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { + if (radius === undefined) radius = 0; + } + b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) {} + b2DebugDraw.prototype.DrawTransform = function (xf) {} + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2DebugDraw.e_shapeBit = 0x0001; + Box2D.Dynamics.b2DebugDraw.e_jointBit = 0x0002; + Box2D.Dynamics.b2DebugDraw.e_aabbBit = 0x0004; + Box2D.Dynamics.b2DebugDraw.e_pairBit = 0x0008; + Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit = 0x0010; + Box2D.Dynamics.b2DebugDraw.e_controllerBit = 0x0020; + }); + b2DestructionListener.b2DestructionListener = function () {}; + b2DestructionListener.prototype.SayGoodbyeJoint = function (joint) {} + b2DestructionListener.prototype.SayGoodbyeFixture = function (fixture) {} + b2FilterData.b2FilterData = function () { + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + }; + b2FilterData.prototype.Copy = function () { + var copy = new b2FilterData(); + copy.categoryBits = this.categoryBits; + copy.maskBits = this.maskBits; + copy.groupIndex = this.groupIndex; + return copy; + } + b2Fixture.b2Fixture = function () { + this.m_filter = new b2FilterData(); + }; + b2Fixture.prototype.GetType = function () { + return this.m_shape.GetType(); + } + b2Fixture.prototype.GetShape = function () { + return this.m_shape; + } + b2Fixture.prototype.SetSensor = function (sensor) { + if (this.m_isSensor == sensor) return; + this.m_isSensor = sensor; + if (this.m_body == null) return; + var edge = this.m_body.GetContactList(); + while (edge) { + var contact = edge.contact; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + if (fixtureA == this || fixtureB == this) contact.SetSensor(fixtureA.IsSensor() || fixtureB.IsSensor()); + edge = edge.next; + } + } + b2Fixture.prototype.IsSensor = function () { + return this.m_isSensor; + } + b2Fixture.prototype.SetFilterData = function (filter) { + this.m_filter = filter.Copy(); + if (this.m_body) return; + var edge = this.m_body.GetContactList(); + while (edge) { + var contact = edge.contact; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + if (fixtureA == this || fixtureB == this) contact.FlagForFiltering(); + edge = edge.next; + } + } + b2Fixture.prototype.GetFilterData = function () { + return this.m_filter.Copy(); + } + b2Fixture.prototype.GetBody = function () { + return this.m_body; + } + b2Fixture.prototype.GetNext = function () { + return this.m_next; + } + b2Fixture.prototype.GetUserData = function () { + return this.m_userData; + } + b2Fixture.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Fixture.prototype.TestPoint = function (p) { + return this.m_shape.TestPoint(this.m_body.GetTransform(), p); + } + b2Fixture.prototype.RayCast = function (output, input) { + return this.m_shape.RayCast(output, input, this.m_body.GetTransform()); + } + b2Fixture.prototype.GetMassData = function (massData) { + if (massData === undefined) massData = null; + if (massData == null) { + massData = new b2MassData(); + } + this.m_shape.ComputeMass(massData, this.m_density); + return massData; + } + b2Fixture.prototype.SetDensity = function (density) { + if (density === undefined) density = 0; + this.m_density = density; + } + b2Fixture.prototype.GetDensity = function () { + return this.m_density; + } + b2Fixture.prototype.GetFriction = function () { + return this.m_friction; + } + b2Fixture.prototype.SetFriction = function (friction) { + if (friction === undefined) friction = 0; + this.m_friction = friction; + } + b2Fixture.prototype.GetRestitution = function () { + return this.m_restitution; + } + b2Fixture.prototype.SetRestitution = function (restitution) { + if (restitution === undefined) restitution = 0; + this.m_restitution = restitution; + } + b2Fixture.prototype.GetAABB = function () { + return this.m_aabb; + } + b2Fixture.prototype.b2Fixture = function () { + this.m_aabb = new b2AABB(); + this.m_userData = null; + this.m_body = null; + this.m_next = null; + this.m_shape = null; + this.m_density = 0.0; + this.m_friction = 0.0; + this.m_restitution = 0.0; + } + b2Fixture.prototype.Create = function (body, xf, def) { + this.m_userData = def.userData; + this.m_friction = def.friction; + this.m_restitution = def.restitution; + this.m_body = body; + this.m_next = null; + this.m_filter = def.filter.Copy(); + this.m_isSensor = def.isSensor; + this.m_shape = def.shape.Copy(); + this.m_density = def.density; + } + b2Fixture.prototype.Destroy = function () { + this.m_shape = null; + } + b2Fixture.prototype.CreateProxy = function (broadPhase, xf) { + this.m_shape.ComputeAABB(this.m_aabb, xf); + this.m_proxy = broadPhase.CreateProxy(this.m_aabb, this); + } + b2Fixture.prototype.DestroyProxy = function (broadPhase) { + if (this.m_proxy == null) { + return; + } + broadPhase.DestroyProxy(this.m_proxy); + this.m_proxy = null; + } + b2Fixture.prototype.Synchronize = function (broadPhase, transform1, transform2) { + if (!this.m_proxy) return; + var aabb1 = new b2AABB(); + var aabb2 = new b2AABB(); + this.m_shape.ComputeAABB(aabb1, transform1); + this.m_shape.ComputeAABB(aabb2, transform2); + this.m_aabb.Combine(aabb1, aabb2); + var displacement = b2Math.SubtractVV(transform2.position, transform1.position); + broadPhase.MoveProxy(this.m_proxy, this.m_aabb, displacement); + } + b2FixtureDef.b2FixtureDef = function () { + this.filter = new b2FilterData(); + }; + b2FixtureDef.prototype.b2FixtureDef = function () { + this.shape = null; + this.userData = null; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.filter.categoryBits = 0x0001; + this.filter.maskBits = 0xFFFF; + this.filter.groupIndex = 0; + this.isSensor = false; + } + b2Island.b2Island = function () {}; + b2Island.prototype.b2Island = function () { + this.m_bodies = new Vector(); + this.m_contacts = new Vector(); + this.m_joints = new Vector(); + } + b2Island.prototype.Initialize = function (bodyCapacity, contactCapacity, jointCapacity, allocator, listener, contactSolver) { + if (bodyCapacity === undefined) bodyCapacity = 0; + if (contactCapacity === undefined) contactCapacity = 0; + if (jointCapacity === undefined) jointCapacity = 0; + var i = 0; + this.m_bodyCapacity = bodyCapacity; + this.m_contactCapacity = contactCapacity; + this.m_jointCapacity = jointCapacity; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_allocator = allocator; + this.m_listener = listener; + this.m_contactSolver = contactSolver; + for (i = this.m_bodies.length; + i < bodyCapacity; i++) + this.m_bodies[i] = null; + for (i = this.m_contacts.length; + i < contactCapacity; i++) + this.m_contacts[i] = null; + for (i = this.m_joints.length; + i < jointCapacity; i++) + this.m_joints[i] = null; + } + b2Island.prototype.Clear = function () { + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + } + b2Island.prototype.Solve = function (step, gravity, allowSleep) { + var i = 0; + var j = 0; + var b; + var joint; + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() != b2Body.b2_dynamicBody) continue; + b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x); + b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y); + b.m_angularVelocity += step.dt * b.m_invI * b.m_torque; + b.m_linearVelocity.Multiply(b2Math.Clamp(1.0 - step.dt * b.m_linearDamping, 0.0, 1.0)); + b.m_angularVelocity *= b2Math.Clamp(1.0 - step.dt * b.m_angularDamping, 0.0, 1.0); + } + this.m_contactSolver.Initialize(step, this.m_contacts, this.m_contactCount, this.m_allocator); + var contactSolver = this.m_contactSolver; + contactSolver.InitVelocityConstraints(step); + for (i = 0; + i < this.m_jointCount; ++i) { + joint = this.m_joints[i]; + joint.InitVelocityConstraints(step); + } + for (i = 0; + i < step.velocityIterations; ++i) { + for (j = 0; + j < this.m_jointCount; ++j) { + joint = this.m_joints[j]; + joint.SolveVelocityConstraints(step); + } + contactSolver.SolveVelocityConstraints(); + } + for (i = 0; + i < this.m_jointCount; ++i) { + joint = this.m_joints[i]; + joint.FinalizeVelocityConstraints(); + } + contactSolver.FinalizeVelocityConstraints(); + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) continue; + var translationX = step.dt * b.m_linearVelocity.x; + var translationY = step.dt * b.m_linearVelocity.y; + if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { + b.m_linearVelocity.Normalize(); + b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * step.inv_dt; + b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * step.inv_dt; + } + var rotation = step.dt * b.m_angularVelocity; + if (rotation * rotation > b2Settings.b2_maxRotationSquared) { + if (b.m_angularVelocity < 0.0) { + b.m_angularVelocity = (-b2Settings.b2_maxRotation * step.inv_dt); + } + else { + b.m_angularVelocity = b2Settings.b2_maxRotation * step.inv_dt; + } + } + b.m_sweep.c0.SetV(b.m_sweep.c); + b.m_sweep.a0 = b.m_sweep.a; + b.m_sweep.c.x += step.dt * b.m_linearVelocity.x; + b.m_sweep.c.y += step.dt * b.m_linearVelocity.y; + b.m_sweep.a += step.dt * b.m_angularVelocity; + b.SynchronizeTransform(); + } + for (i = 0; + i < step.positionIterations; ++i) { + var contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + var jointsOkay = true; + for (j = 0; + j < this.m_jointCount; ++j) { + joint = this.m_joints[j]; + var jointOkay = joint.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + jointsOkay = jointsOkay && jointOkay; + } + if (contactsOkay && jointsOkay) { + break; + } + } + this.Report(contactSolver.m_constraints); + if (allowSleep) { + var minSleepTime = Number.MAX_VALUE; + var linTolSqr = b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance; + var angTolSqr = b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance; + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + if ((b.m_flags & b2Body.e_allowSleepFlag) == 0) { + b.m_sleepTime = 0.0; + minSleepTime = 0.0; + } + if ((b.m_flags & b2Body.e_allowSleepFlag) == 0 || b.m_angularVelocity * b.m_angularVelocity > angTolSqr || b2Math.Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) { + b.m_sleepTime = 0.0; + minSleepTime = 0.0; + } + else { + b.m_sleepTime += step.dt; + minSleepTime = b2Math.Min(minSleepTime, b.m_sleepTime); + } + } + if (minSleepTime >= b2Settings.b2_timeToSleep) { + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + b.SetAwake(false); + } + } + } + } + b2Island.prototype.SolveTOI = function (subStep) { + var i = 0; + var j = 0; + this.m_contactSolver.Initialize(subStep, this.m_contacts, this.m_contactCount, this.m_allocator); + var contactSolver = this.m_contactSolver; + for (i = 0; + i < this.m_jointCount; ++i) { + this.m_joints[i].InitVelocityConstraints(subStep); + } + for (i = 0; + i < subStep.velocityIterations; ++i) { + contactSolver.SolveVelocityConstraints(); + for (j = 0; + j < this.m_jointCount; ++j) { + this.m_joints[j].SolveVelocityConstraints(subStep); + } + } + for (i = 0; + i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) continue; + var translationX = subStep.dt * b.m_linearVelocity.x; + var translationY = subStep.dt * b.m_linearVelocity.y; + if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { + b.m_linearVelocity.Normalize(); + b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * subStep.inv_dt; + b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * subStep.inv_dt; + } + var rotation = subStep.dt * b.m_angularVelocity; + if (rotation * rotation > b2Settings.b2_maxRotationSquared) { + if (b.m_angularVelocity < 0.0) { + b.m_angularVelocity = (-b2Settings.b2_maxRotation * subStep.inv_dt); + } + else { + b.m_angularVelocity = b2Settings.b2_maxRotation * subStep.inv_dt; + } + } + b.m_sweep.c0.SetV(b.m_sweep.c); + b.m_sweep.a0 = b.m_sweep.a; + b.m_sweep.c.x += subStep.dt * b.m_linearVelocity.x; + b.m_sweep.c.y += subStep.dt * b.m_linearVelocity.y; + b.m_sweep.a += subStep.dt * b.m_angularVelocity; + b.SynchronizeTransform(); + } + var k_toiBaumgarte = 0.75; + for (i = 0; + i < subStep.positionIterations; ++i) { + var contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte); + var jointsOkay = true; + for (j = 0; + j < this.m_jointCount; ++j) { + var jointOkay = this.m_joints[j].SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + jointsOkay = jointsOkay && jointOkay; + } + if (contactsOkay && jointsOkay) { + break; + } + } + this.Report(contactSolver.m_constraints); + } + b2Island.prototype.Report = function (constraints) { + if (this.m_listener == null) { + return; + } + for (var i = 0; i < this.m_contactCount; ++i) { + var c = this.m_contacts[i]; + var cc = constraints[i]; + for (var j = 0; j < cc.pointCount; ++j) { + b2Island.s_impulse.normalImpulses[j] = cc.points[j].normalImpulse; + b2Island.s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse; + } + this.m_listener.PostSolve(c, b2Island.s_impulse); + } + } + b2Island.prototype.AddBody = function (body) { + body.m_islandIndex = this.m_bodyCount; + this.m_bodies[this.m_bodyCount++] = body; + } + b2Island.prototype.AddContact = function (contact) { + this.m_contacts[this.m_contactCount++] = contact; + } + b2Island.prototype.AddJoint = function (joint) { + this.m_joints[this.m_jointCount++] = joint; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2Island.s_impulse = new b2ContactImpulse(); + }); + b2TimeStep.b2TimeStep = function () {}; + b2TimeStep.prototype.Set = function (step) { + this.dt = step.dt; + this.inv_dt = step.inv_dt; + this.positionIterations = step.positionIterations; + this.velocityIterations = step.velocityIterations; + this.warmStarting = step.warmStarting; + } + b2World.b2World = function () { + this.s_stack = new Vector(); + this.m_contactManager = new b2ContactManager(); + this.m_contactSolver = new b2ContactSolver(); + this.m_island = new b2Island(); + }; + b2World.prototype.b2World = function (gravity, doSleep) { + this.m_destructionListener = null; + this.m_debugDraw = null; + this.m_bodyList = null; + this.m_contactList = null; + this.m_jointList = null; + this.m_controllerList = null; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_controllerCount = 0; + b2World.m_warmStarting = true; + b2World.m_continuousPhysics = true; + this.m_allowSleep = doSleep; + this.m_gravity = gravity; + this.m_inv_dt0 = 0.0; + this.m_contactManager.m_world = this; + var bd = new b2BodyDef(); + this.m_groundBody = this.CreateBody(bd); + } + b2World.prototype.SetDestructionListener = function (listener) { + this.m_destructionListener = listener; + } + b2World.prototype.SetContactFilter = function (filter) { + this.m_contactManager.m_contactFilter = filter; + } + b2World.prototype.SetContactListener = function (listener) { + this.m_contactManager.m_contactListener = listener; + } + b2World.prototype.SetDebugDraw = function (debugDraw) { + this.m_debugDraw = debugDraw; + } + b2World.prototype.SetBroadPhase = function (broadPhase) { + var oldBroadPhase = this.m_contactManager.m_broadPhase; + this.m_contactManager.m_broadPhase = broadPhase; + for (var b = this.m_bodyList; b; b = b.m_next) { + for (var f = b.m_fixtureList; f; f = f.m_next) { + f.m_proxy = broadPhase.CreateProxy(oldBroadPhase.GetFatAABB(f.m_proxy), f); + } + } + } + b2World.prototype.Validate = function () { + this.m_contactManager.m_broadPhase.Validate(); + } + b2World.prototype.GetProxyCount = function () { + return this.m_contactManager.m_broadPhase.GetProxyCount(); + } + b2World.prototype.CreateBody = function (def) { + if (this.IsLocked() == true) { + return null; + } + var b = new b2Body(def, this); + b.m_prev = null; + b.m_next = this.m_bodyList; + if (this.m_bodyList) { + this.m_bodyList.m_prev = b; + } + this.m_bodyList = b; + ++this.m_bodyCount; + return b; + } + b2World.prototype.DestroyBody = function (b) { + if (this.IsLocked() == true) { + return; + } + var jn = b.m_jointList; + while (jn) { + var jn0 = jn; + jn = jn.next; + if (this.m_destructionListener) { + this.m_destructionListener.SayGoodbyeJoint(jn0.joint); + } + this.DestroyJoint(jn0.joint); + } + var coe = b.m_controllerList; + while (coe) { + var coe0 = coe; + coe = coe.nextController; + coe0.controller.RemoveBody(b); + } + var ce = b.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_contactManager.Destroy(ce0.contact); + } + b.m_contactList = null; + var f = b.m_fixtureList; + while (f) { + var f0 = f; + f = f.m_next; + if (this.m_destructionListener) { + this.m_destructionListener.SayGoodbyeFixture(f0); + } + f0.DestroyProxy(this.m_contactManager.m_broadPhase); + f0.Destroy(); + } + b.m_fixtureList = null; + b.m_fixtureCount = 0; + if (b.m_prev) { + b.m_prev.m_next = b.m_next; + } + if (b.m_next) { + b.m_next.m_prev = b.m_prev; + } + if (b == this.m_bodyList) { + this.m_bodyList = b.m_next; + }--this.m_bodyCount; + } + b2World.prototype.CreateJoint = function (def) { + var j = b2Joint.Create(def, null); + j.m_prev = null; + j.m_next = this.m_jointList; + if (this.m_jointList) { + this.m_jointList.m_prev = j; + } + this.m_jointList = j; + ++this.m_jointCount; + j.m_edgeA.joint = j; + j.m_edgeA.other = j.m_bodyB; + j.m_edgeA.prev = null; + j.m_edgeA.next = j.m_bodyA.m_jointList; + if (j.m_bodyA.m_jointList) j.m_bodyA.m_jointList.prev = j.m_edgeA; + j.m_bodyA.m_jointList = j.m_edgeA; + j.m_edgeB.joint = j; + j.m_edgeB.other = j.m_bodyA; + j.m_edgeB.prev = null; + j.m_edgeB.next = j.m_bodyB.m_jointList; + if (j.m_bodyB.m_jointList) j.m_bodyB.m_jointList.prev = j.m_edgeB; + j.m_bodyB.m_jointList = j.m_edgeB; + var bodyA = def.bodyA; + var bodyB = def.bodyB; + if (def.collideConnected == false) { + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + edge.contact.FlagForFiltering(); + } + edge = edge.next; + } + } + return j; + } + b2World.prototype.DestroyJoint = function (j) { + var collideConnected = j.m_collideConnected; + if (j.m_prev) { + j.m_prev.m_next = j.m_next; + } + if (j.m_next) { + j.m_next.m_prev = j.m_prev; + } + if (j == this.m_jointList) { + this.m_jointList = j.m_next; + } + var bodyA = j.m_bodyA; + var bodyB = j.m_bodyB; + bodyA.SetAwake(true); + bodyB.SetAwake(true); + if (j.m_edgeA.prev) { + j.m_edgeA.prev.next = j.m_edgeA.next; + } + if (j.m_edgeA.next) { + j.m_edgeA.next.prev = j.m_edgeA.prev; + } + if (j.m_edgeA == bodyA.m_jointList) { + bodyA.m_jointList = j.m_edgeA.next; + } + j.m_edgeA.prev = null; + j.m_edgeA.next = null; + if (j.m_edgeB.prev) { + j.m_edgeB.prev.next = j.m_edgeB.next; + } + if (j.m_edgeB.next) { + j.m_edgeB.next.prev = j.m_edgeB.prev; + } + if (j.m_edgeB == bodyB.m_jointList) { + bodyB.m_jointList = j.m_edgeB.next; + } + j.m_edgeB.prev = null; + j.m_edgeB.next = null; + b2Joint.Destroy(j, null); + --this.m_jointCount; + if (collideConnected == false) { + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + edge.contact.FlagForFiltering(); + } + edge = edge.next; + } + } + } + b2World.prototype.AddController = function (c) { + c.m_next = this.m_controllerList; + c.m_prev = null; + this.m_controllerList = c; + c.m_world = this; + this.m_controllerCount++; + return c; + } + b2World.prototype.RemoveController = function (c) { + if (c.m_prev) c.m_prev.m_next = c.m_next; + if (c.m_next) c.m_next.m_prev = c.m_prev; + if (this.m_controllerList == c) this.m_controllerList = c.m_next; + this.m_controllerCount--; + } + b2World.prototype.CreateController = function (controller) { + if (controller.m_world != this) throw new Error("Controller can only be a member of one world"); + controller.m_next = this.m_controllerList; + controller.m_prev = null; + if (this.m_controllerList) this.m_controllerList.m_prev = controller; + this.m_controllerList = controller; + ++this.m_controllerCount; + controller.m_world = this; + return controller; + } + b2World.prototype.DestroyController = function (controller) { + controller.Clear(); + if (controller.m_next) controller.m_next.m_prev = controller.m_prev; + if (controller.m_prev) controller.m_prev.m_next = controller.m_next; + if (controller == this.m_controllerList) this.m_controllerList = controller.m_next; + --this.m_controllerCount; + } + b2World.prototype.SetWarmStarting = function (flag) { + b2World.m_warmStarting = flag; + } + b2World.prototype.SetContinuousPhysics = function (flag) { + b2World.m_continuousPhysics = flag; + } + b2World.prototype.GetBodyCount = function () { + return this.m_bodyCount; + } + b2World.prototype.GetJointCount = function () { + return this.m_jointCount; + } + b2World.prototype.GetContactCount = function () { + return this.m_contactCount; + } + b2World.prototype.SetGravity = function (gravity) { + this.m_gravity = gravity; + } + b2World.prototype.GetGravity = function () { + return this.m_gravity; + } + b2World.prototype.GetGroundBody = function () { + return this.m_groundBody; + } + b2World.prototype.Step = function (dt, velocityIterations, positionIterations) { + if (dt === undefined) dt = 0; + if (velocityIterations === undefined) velocityIterations = 0; + if (positionIterations === undefined) positionIterations = 0; + if (this.m_flags & b2World.e_newFixture) { + this.m_contactManager.FindNewContacts(); + this.m_flags &= ~b2World.e_newFixture; + } + this.m_flags |= b2World.e_locked; + var step = b2World.s_timestep2; + step.dt = dt; + step.velocityIterations = velocityIterations; + step.positionIterations = positionIterations; + if (dt > 0.0) { + step.inv_dt = 1.0 / dt; + } + else { + step.inv_dt = 0.0; + } + step.dtRatio = this.m_inv_dt0 * dt; + step.warmStarting = b2World.m_warmStarting; + this.m_contactManager.Collide(); + if (step.dt > 0.0) { + this.Solve(step); + } + if (b2World.m_continuousPhysics && step.dt > 0.0) { + this.SolveTOI(step); + } + if (step.dt > 0.0) { + this.m_inv_dt0 = step.inv_dt; + } + this.m_flags &= ~b2World.e_locked; + } + b2World.prototype.ClearForces = function () { + for (var body = this.m_bodyList; body; body = body.m_next) { + body.m_force.SetZero(); + body.m_torque = 0.0; + } + } + b2World.prototype.DrawDebugData = function () { + if (this.m_debugDraw == null) { + return; + } + this.m_debugDraw.m_sprite.graphics.clear(); + var flags = this.m_debugDraw.GetFlags(); + var i = 0; + var b; + var f; + var s; + var j; + var bp; + var invQ = new b2Vec2; + var x1 = new b2Vec2; + var x2 = new b2Vec2; + var xf; + var b1 = new b2AABB(); + var b2 = new b2AABB(); + var vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; + var color = new b2Color(0, 0, 0); + if (flags & b2DebugDraw.e_shapeBit) { + for (b = this.m_bodyList; + b; b = b.m_next) { + xf = b.m_xf; + for (f = b.GetFixtureList(); + f; f = f.m_next) { + s = f.GetShape(); + if (b.IsActive() == false) { + color.Set(0.5, 0.5, 0.3); + this.DrawShape(s, xf, color); + } + else if (b.GetType() == b2Body.b2_staticBody) { + color.Set(0.5, 0.9, 0.5); + this.DrawShape(s, xf, color); + } + else if (b.GetType() == b2Body.b2_kinematicBody) { + color.Set(0.5, 0.5, 0.9); + this.DrawShape(s, xf, color); + } + else if (b.IsAwake() == false) { + color.Set(0.6, 0.6, 0.6); + this.DrawShape(s, xf, color); + } + else { + color.Set(0.9, 0.7, 0.7); + this.DrawShape(s, xf, color); + } + } + } + } + if (flags & b2DebugDraw.e_jointBit) { + for (j = this.m_jointList; + j; j = j.m_next) { + this.DrawJoint(j); + } + } + if (flags & b2DebugDraw.e_controllerBit) { + for (var c = this.m_controllerList; c; c = c.m_next) { + c.Draw(this.m_debugDraw); + } + } + if (flags & b2DebugDraw.e_pairBit) { + color.Set(0.3, 0.9, 0.9); + for (var contact = this.m_contactManager.m_contactList; contact; contact = contact.GetNext()) { + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + var cA = fixtureA.GetAABB().GetCenter(); + var cB = fixtureB.GetAABB().GetCenter(); + this.m_debugDraw.DrawSegment(cA, cB, color); + } + } + if (flags & b2DebugDraw.e_aabbBit) { + bp = this.m_contactManager.m_broadPhase; + vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; + for (b = this.m_bodyList; + b; b = b.GetNext()) { + if (b.IsActive() == false) { + continue; + } + for (f = b.GetFixtureList(); + f; f = f.GetNext()) { + var aabb = bp.GetFatAABB(f.m_proxy); + vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); + vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); + vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); + vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); + this.m_debugDraw.DrawPolygon(vs, 4, color); + } + } + } + if (flags & b2DebugDraw.e_centerOfMassBit) { + for (b = this.m_bodyList; + b; b = b.m_next) { + xf = b2World.s_xf; + xf.R = b.m_xf.R; + xf.position = b.GetWorldCenter(); + this.m_debugDraw.DrawTransform(xf); + } + } + } + b2World.prototype.QueryAABB = function (callback, aabb) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + return callback(broadPhase.GetUserData(proxy)); + }; + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.QueryShape = function (callback, shape, transform) { + var __this = this; + if (transform === undefined) transform = null; + if (transform == null) { + transform = new b2Transform(); + transform.SetIdentity(); + } + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); + if (b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform())) return callback(fixture); + return true; + }; + var aabb = new b2AABB(); + shape.ComputeAABB(aabb, transform); + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.QueryPoint = function (callback, p) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); + if (fixture.TestPoint(p)) return callback(fixture); + return true; + }; + var aabb = new b2AABB(); + aabb.lowerBound.Set(p.x - b2Settings.b2_linearSlop, p.y - b2Settings.b2_linearSlop); + aabb.upperBound.Set(p.x + b2Settings.b2_linearSlop, p.y + b2Settings.b2_linearSlop); + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.RayCast = function (callback, point1, point2) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + var output = new b2RayCastOutput; + + function RayCastWrapper(input, proxy) { + var userData = broadPhase.GetUserData(proxy); + var fixture = (userData instanceof b2Fixture ? userData : null); + var hit = fixture.RayCast(output, input); + if (hit) { + var fraction = output.fraction; + var point = new b2Vec2((1.0 - fraction) * point1.x + fraction * point2.x, (1.0 - fraction) * point1.y + fraction * point2.y); + return callback(fixture, point, output.normal, fraction); + } + return input.maxFraction; + }; + var input = new b2RayCastInput(point1, point2); + broadPhase.RayCast(RayCastWrapper, input); + } + b2World.prototype.RayCastOne = function (point1, point2) { + var __this = this; + var result; + + function RayCastOneWrapper(fixture, point, normal, fraction) { + if (fraction === undefined) fraction = 0; + result = fixture; + return fraction; + }; + __this.RayCast(RayCastOneWrapper, point1, point2); + return result; + } + b2World.prototype.RayCastAll = function (point1, point2) { + var __this = this; + var result = new Vector(); + + function RayCastAllWrapper(fixture, point, normal, fraction) { + if (fraction === undefined) fraction = 0; + result[result.length] = fixture; + return 1; + }; + __this.RayCast(RayCastAllWrapper, point1, point2); + return result; + } + b2World.prototype.GetBodyList = function () { + return this.m_bodyList; + } + b2World.prototype.GetJointList = function () { + return this.m_jointList; + } + b2World.prototype.GetContactList = function () { + return this.m_contactList; + } + b2World.prototype.IsLocked = function () { + return (this.m_flags & b2World.e_locked) > 0; + } + b2World.prototype.Solve = function (step) { + var b; + for (var controller = this.m_controllerList; controller; controller = controller.m_next) { + controller.Step(step); + } + var island = this.m_island; + island.Initialize(this.m_bodyCount, this.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener, this.m_contactSolver); + for (b = this.m_bodyList; + b; b = b.m_next) { + b.m_flags &= ~b2Body.e_islandFlag; + } + for (var c = this.m_contactList; c; c = c.m_next) { + c.m_flags &= ~b2Contact.e_islandFlag; + } + for (var j = this.m_jointList; j; j = j.m_next) { + j.m_islandFlag = false; + } + var stackSize = parseInt(this.m_bodyCount); + var stack = this.s_stack; + for (var seed = this.m_bodyList; seed; seed = seed.m_next) { + if (seed.m_flags & b2Body.e_islandFlag) { + continue; + } + if (seed.IsAwake() == false || seed.IsActive() == false) { + continue; + } + if (seed.GetType() == b2Body.b2_staticBody) { + continue; + } + island.Clear(); + var stackCount = 0; + stack[stackCount++] = seed; + seed.m_flags |= b2Body.e_islandFlag; + while (stackCount > 0) { + b = stack[--stackCount]; + island.AddBody(b); + if (b.IsAwake() == false) { + b.SetAwake(true); + } + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + var other; + for (var ce = b.m_contactList; ce; ce = ce.next) { + if (ce.contact.m_flags & b2Contact.e_islandFlag) { + continue; + } + if (ce.contact.IsSensor() == true || ce.contact.IsEnabled() == false || ce.contact.IsTouching() == false) { + continue; + } + island.AddContact(ce.contact); + ce.contact.m_flags |= b2Contact.e_islandFlag; + other = ce.other; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + for (var jn = b.m_jointList; jn; jn = jn.next) { + if (jn.joint.m_islandFlag == true) { + continue; + } + other = jn.other; + if (other.IsActive() == false) { + continue; + } + island.AddJoint(jn.joint); + jn.joint.m_islandFlag = true; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + } + island.Solve(step, this.m_gravity, this.m_allowSleep); + for (var i = 0; i < island.m_bodyCount; ++i) { + b = island.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) { + b.m_flags &= ~b2Body.e_islandFlag; + } + } + } + for (i = 0; + i < stack.length; ++i) { + if (!stack[i]) break; + stack[i] = null; + } + for (b = this.m_bodyList; + b; b = b.m_next) { + if (b.IsAwake() == false || b.IsActive() == false) { + continue; + } + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + b.SynchronizeFixtures(); + } + this.m_contactManager.FindNewContacts(); + } + b2World.prototype.SolveTOI = function (step) { + var b; + var fA; + var fB; + var bA; + var bB; + var cEdge; + var j; + var island = this.m_island; + island.Initialize(this.m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, this.m_contactManager.m_contactListener, this.m_contactSolver); + var queue = b2World.s_queue; + for (b = this.m_bodyList; + b; b = b.m_next) { + b.m_flags &= ~b2Body.e_islandFlag; + b.m_sweep.t0 = 0.0; + } + var c; + for (c = this.m_contactList; + c; c = c.m_next) { + c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); + } + for (j = this.m_jointList; + j; j = j.m_next) { + j.m_islandFlag = false; + } + for (;;) { + var minContact = null; + var minTOI = 1.0; + for (c = this.m_contactList; + c; c = c.m_next) { + if (c.IsSensor() == true || c.IsEnabled() == false || c.IsContinuous() == false) { + continue; + } + var toi = 1.0; + if (c.m_flags & b2Contact.e_toiFlag) { + toi = c.m_toi; + } + else { + fA = c.m_fixtureA; + fB = c.m_fixtureB; + bA = fA.m_body; + bB = fB.m_body; + if ((bA.GetType() != b2Body.b2_dynamicBody || bA.IsAwake() == false) && (bB.GetType() != b2Body.b2_dynamicBody || bB.IsAwake() == false)) { + continue; + } + var t0 = bA.m_sweep.t0; + if (bA.m_sweep.t0 < bB.m_sweep.t0) { + t0 = bB.m_sweep.t0; + bA.m_sweep.Advance(t0); + } + else if (bB.m_sweep.t0 < bA.m_sweep.t0) { + t0 = bA.m_sweep.t0; + bB.m_sweep.Advance(t0); + } + toi = c.ComputeTOI(bA.m_sweep, bB.m_sweep); + b2Settings.b2Assert(0.0 <= toi && toi <= 1.0); + if (toi > 0.0 && toi < 1.0) { + toi = (1.0 - toi) * t0 + toi; + if (toi > 1) toi = 1; + } + c.m_toi = toi; + c.m_flags |= b2Contact.e_toiFlag; + } + if (Number.MIN_VALUE < toi && toi < minTOI) { + minContact = c; + minTOI = toi; + } + } + if (minContact == null || 1.0 - 100.0 * Number.MIN_VALUE < minTOI) { + break; + } + fA = minContact.m_fixtureA; + fB = minContact.m_fixtureB; + bA = fA.m_body; + bB = fB.m_body; + b2World.s_backupA.Set(bA.m_sweep); + b2World.s_backupB.Set(bB.m_sweep); + bA.Advance(minTOI); + bB.Advance(minTOI); + minContact.Update(this.m_contactManager.m_contactListener); + minContact.m_flags &= ~b2Contact.e_toiFlag; + if (minContact.IsSensor() == true || minContact.IsEnabled() == false) { + bA.m_sweep.Set(b2World.s_backupA); + bB.m_sweep.Set(b2World.s_backupB); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + continue; + } + if (minContact.IsTouching() == false) { + continue; + } + var seed = bA; + if (seed.GetType() != b2Body.b2_dynamicBody) { + seed = bB; + } + island.Clear(); + var queueStart = 0; + var queueSize = 0; + queue[queueStart + queueSize++] = seed; + seed.m_flags |= b2Body.e_islandFlag; + while (queueSize > 0) { + b = queue[queueStart++]; + --queueSize; + island.AddBody(b); + if (b.IsAwake() == false) { + b.SetAwake(true); + } + if (b.GetType() != b2Body.b2_dynamicBody) { + continue; + } + for (cEdge = b.m_contactList; + cEdge; cEdge = cEdge.next) { + if (island.m_contactCount == island.m_contactCapacity) { + break; + } + if (cEdge.contact.m_flags & b2Contact.e_islandFlag) { + continue; + } + if (cEdge.contact.IsSensor() == true || cEdge.contact.IsEnabled() == false || cEdge.contact.IsTouching() == false) { + continue; + } + island.AddContact(cEdge.contact); + cEdge.contact.m_flags |= b2Contact.e_islandFlag; + var other = cEdge.other; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + if (other.GetType() != b2Body.b2_staticBody) { + other.Advance(minTOI); + other.SetAwake(true); + } + queue[queueStart + queueSize] = other; + ++queueSize; + other.m_flags |= b2Body.e_islandFlag; + } + for (var jEdge = b.m_jointList; jEdge; jEdge = jEdge.next) { + if (island.m_jointCount == island.m_jointCapacity) continue; + if (jEdge.joint.m_islandFlag == true) continue; + other = jEdge.other; + if (other.IsActive() == false) { + continue; + } + island.AddJoint(jEdge.joint); + jEdge.joint.m_islandFlag = true; + if (other.m_flags & b2Body.e_islandFlag) continue; + if (other.GetType() != b2Body.b2_staticBody) { + other.Advance(minTOI); + other.SetAwake(true); + } + queue[queueStart + queueSize] = other; + ++queueSize; + other.m_flags |= b2Body.e_islandFlag; + } + } + var subStep = b2World.s_timestep; + subStep.warmStarting = false; + subStep.dt = (1.0 - minTOI) * step.dt; + subStep.inv_dt = 1.0 / subStep.dt; + subStep.dtRatio = 0.0; + subStep.velocityIterations = step.velocityIterations; + subStep.positionIterations = step.positionIterations; + island.SolveTOI(subStep); + var i = 0; + for (i = 0; + i < island.m_bodyCount; ++i) { + b = island.m_bodies[i]; + b.m_flags &= ~b2Body.e_islandFlag; + if (b.IsAwake() == false) { + continue; + } + if (b.GetType() != b2Body.b2_dynamicBody) { + continue; + } + b.SynchronizeFixtures(); + for (cEdge = b.m_contactList; + cEdge; cEdge = cEdge.next) { + cEdge.contact.m_flags &= ~b2Contact.e_toiFlag; + } + } + for (i = 0; + i < island.m_contactCount; ++i) { + c = island.m_contacts[i]; + c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); + } + for (i = 0; + i < island.m_jointCount; ++i) { + j = island.m_joints[i]; + j.m_islandFlag = false; + } + this.m_contactManager.FindNewContacts(); + } + } + b2World.prototype.DrawJoint = function (joint) { + var b1 = joint.GetBodyA(); + var b2 = joint.GetBodyB(); + var xf1 = b1.m_xf; + var xf2 = b2.m_xf; + var x1 = xf1.position; + var x2 = xf2.position; + var p1 = joint.GetAnchorA(); + var p2 = joint.GetAnchorB(); + var color = b2World.s_jointColor; + switch (joint.m_type) { + case b2Joint.e_distanceJoint: + this.m_debugDraw.DrawSegment(p1, p2, color); + break; + case b2Joint.e_pulleyJoint: + { + var pulley = ((joint instanceof b2PulleyJoint ? joint : null)); + var s1 = pulley.GetGroundAnchorA(); + var s2 = pulley.GetGroundAnchorB(); + this.m_debugDraw.DrawSegment(s1, p1, color); + this.m_debugDraw.DrawSegment(s2, p2, color); + this.m_debugDraw.DrawSegment(s1, s2, color); + } + break; + case b2Joint.e_mouseJoint: + this.m_debugDraw.DrawSegment(p1, p2, color); + break; + default: + if (b1 != this.m_groundBody) this.m_debugDraw.DrawSegment(x1, p1, color); + this.m_debugDraw.DrawSegment(p1, p2, color); + if (b2 != this.m_groundBody) this.m_debugDraw.DrawSegment(x2, p2, color); + } + } + b2World.prototype.DrawShape = function (shape, xf, color) { + switch (shape.m_type) { + case b2Shape.e_circleShape: + { + var circle = ((shape instanceof b2CircleShape ? shape : null)); + var center = b2Math.MulX(xf, circle.m_p); + var radius = circle.m_radius; + var axis = xf.R.col1; + this.m_debugDraw.DrawSolidCircle(center, radius, axis, color); + } + break; + case b2Shape.e_polygonShape: + { + var i = 0; + var poly = ((shape instanceof b2PolygonShape ? shape : null)); + var vertexCount = parseInt(poly.GetVertexCount()); + var localVertices = poly.GetVertices(); + var vertices = new Vector(vertexCount); + for (i = 0; + i < vertexCount; ++i) { + vertices[i] = b2Math.MulX(xf, localVertices[i]); + } + this.m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color); + } + break; + case b2Shape.e_edgeShape: + { + var edge = (shape instanceof b2EdgeShape ? shape : null); + this.m_debugDraw.DrawSegment(b2Math.MulX(xf, edge.GetVertex1()), b2Math.MulX(xf, edge.GetVertex2()), color); + } + break; + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2World.s_timestep2 = new b2TimeStep(); + Box2D.Dynamics.b2World.s_xf = new b2Transform(); + Box2D.Dynamics.b2World.s_backupA = new b2Sweep(); + Box2D.Dynamics.b2World.s_backupB = new b2Sweep(); + Box2D.Dynamics.b2World.s_timestep = new b2TimeStep(); + Box2D.Dynamics.b2World.s_queue = new Vector(); + Box2D.Dynamics.b2World.s_jointColor = new b2Color(0.5, 0.8, 0.8); + Box2D.Dynamics.b2World.e_newFixture = 0x0001; + Box2D.Dynamics.b2World.e_locked = 0x0002; + }); +})(); +(function () { + var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, + b2Contact = Box2D.Dynamics.Contacts.b2Contact, + b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, + b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, + b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, + b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, + b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, + b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, + b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, + b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, + b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, + b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, + b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, + b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, + b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + Box2D.inherit(b2CircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2CircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2CircleContact.b2CircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2CircleContact.Create = function (allocator) { + return new b2CircleContact(); + } + b2CircleContact.Destroy = function (contact, allocator) {} + b2CircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2CircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + b2Collision.CollideCircles(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2CircleShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2Contact.b2Contact = function () { + this.m_nodeA = new b2ContactEdge(); + this.m_nodeB = new b2ContactEdge(); + this.m_manifold = new b2Manifold(); + this.m_oldManifold = new b2Manifold(); + }; + b2Contact.prototype.GetManifold = function () { + return this.m_manifold; + } + b2Contact.prototype.GetWorldManifold = function (worldManifold) { + var bodyA = this.m_fixtureA.GetBody(); + var bodyB = this.m_fixtureB.GetBody(); + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + worldManifold.Initialize(this.m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius); + } + b2Contact.prototype.IsTouching = function () { + return (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; + } + b2Contact.prototype.IsContinuous = function () { + return (this.m_flags & b2Contact.e_continuousFlag) == b2Contact.e_continuousFlag; + } + b2Contact.prototype.SetSensor = function (sensor) { + if (sensor) { + this.m_flags |= b2Contact.e_sensorFlag; + } + else { + this.m_flags &= ~b2Contact.e_sensorFlag; + } + } + b2Contact.prototype.IsSensor = function () { + return (this.m_flags & b2Contact.e_sensorFlag) == b2Contact.e_sensorFlag; + } + b2Contact.prototype.SetEnabled = function (flag) { + if (flag) { + this.m_flags |= b2Contact.e_enabledFlag; + } + else { + this.m_flags &= ~b2Contact.e_enabledFlag; + } + } + b2Contact.prototype.IsEnabled = function () { + return (this.m_flags & b2Contact.e_enabledFlag) == b2Contact.e_enabledFlag; + } + b2Contact.prototype.GetNext = function () { + return this.m_next; + } + b2Contact.prototype.GetFixtureA = function () { + return this.m_fixtureA; + } + b2Contact.prototype.GetFixtureB = function () { + return this.m_fixtureB; + } + b2Contact.prototype.FlagForFiltering = function () { + this.m_flags |= b2Contact.e_filterFlag; + } + b2Contact.prototype.b2Contact = function () {} + b2Contact.prototype.Reset = function (fixtureA, fixtureB) { + if (fixtureA === undefined) fixtureA = null; + if (fixtureB === undefined) fixtureB = null; + this.m_flags = b2Contact.e_enabledFlag; + if (!fixtureA || !fixtureB) { + this.m_fixtureA = null; + this.m_fixtureB = null; + return; + } + if (fixtureA.IsSensor() || fixtureB.IsSensor()) { + this.m_flags |= b2Contact.e_sensorFlag; + } + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { + this.m_flags |= b2Contact.e_continuousFlag; + } + this.m_fixtureA = fixtureA; + this.m_fixtureB = fixtureB; + this.m_manifold.m_pointCount = 0; + this.m_prev = null; + this.m_next = null; + this.m_nodeA.contact = null; + this.m_nodeA.prev = null; + this.m_nodeA.next = null; + this.m_nodeA.other = null; + this.m_nodeB.contact = null; + this.m_nodeB.prev = null; + this.m_nodeB.next = null; + this.m_nodeB.other = null; + } + b2Contact.prototype.Update = function (listener) { + var tManifold = this.m_oldManifold; + this.m_oldManifold = this.m_manifold; + this.m_manifold = tManifold; + this.m_flags |= b2Contact.e_enabledFlag; + var touching = false; + var wasTouching = (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; + var bodyA = this.m_fixtureA.m_body; + var bodyB = this.m_fixtureB.m_body; + var aabbOverlap = this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb); + if (this.m_flags & b2Contact.e_sensorFlag) { + if (aabbOverlap) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + var xfA = bodyA.GetTransform(); + var xfB = bodyB.GetTransform(); + touching = b2Shape.TestOverlap(shapeA, xfA, shapeB, xfB); + } + this.m_manifold.m_pointCount = 0; + } + else { + if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { + this.m_flags |= b2Contact.e_continuousFlag; + } + else { + this.m_flags &= ~b2Contact.e_continuousFlag; + } + if (aabbOverlap) { + this.Evaluate(); + touching = this.m_manifold.m_pointCount > 0; + for (var i = 0; i < this.m_manifold.m_pointCount; ++i) { + var mp2 = this.m_manifold.m_points[i]; + mp2.m_normalImpulse = 0.0; + mp2.m_tangentImpulse = 0.0; + var id2 = mp2.m_id; + for (var j = 0; j < this.m_oldManifold.m_pointCount; ++j) { + var mp1 = this.m_oldManifold.m_points[j]; + if (mp1.m_id.key == id2.key) { + mp2.m_normalImpulse = mp1.m_normalImpulse; + mp2.m_tangentImpulse = mp1.m_tangentImpulse; + break; + } + } + } + } + else { + this.m_manifold.m_pointCount = 0; + } + if (touching != wasTouching) { + bodyA.SetAwake(true); + bodyB.SetAwake(true); + } + } + if (touching) { + this.m_flags |= b2Contact.e_touchingFlag; + } + else { + this.m_flags &= ~b2Contact.e_touchingFlag; + } + if (wasTouching == false && touching == true) { + listener.BeginContact(this); + } + if (wasTouching == true && touching == false) { + listener.EndContact(this); + } + if ((this.m_flags & b2Contact.e_sensorFlag) == 0) { + listener.PreSolve(this, this.m_oldManifold); + } + } + b2Contact.prototype.Evaluate = function () {} + b2Contact.prototype.ComputeTOI = function (sweepA, sweepB) { + b2Contact.s_input.proxyA.Set(this.m_fixtureA.GetShape()); + b2Contact.s_input.proxyB.Set(this.m_fixtureB.GetShape()); + b2Contact.s_input.sweepA = sweepA; + b2Contact.s_input.sweepB = sweepB; + b2Contact.s_input.tolerance = b2Settings.b2_linearSlop; + return b2TimeOfImpact.TimeOfImpact(b2Contact.s_input); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag = 0x0001; + Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag = 0x0002; + Box2D.Dynamics.Contacts.b2Contact.e_islandFlag = 0x0004; + Box2D.Dynamics.Contacts.b2Contact.e_toiFlag = 0x0008; + Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag = 0x0010; + Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag = 0x0020; + Box2D.Dynamics.Contacts.b2Contact.e_filterFlag = 0x0040; + Box2D.Dynamics.Contacts.b2Contact.s_input = new b2TOIInput(); + }); + b2ContactConstraint.b2ContactConstraint = function () { + this.localPlaneNormal = new b2Vec2(); + this.localPoint = new b2Vec2(); + this.normal = new b2Vec2(); + this.normalMass = new b2Mat22(); + this.K = new b2Mat22(); + }; + b2ContactConstraint.prototype.b2ContactConstraint = function () { + this.points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.points[i] = new b2ContactConstraintPoint(); + } + } + b2ContactConstraintPoint.b2ContactConstraintPoint = function () { + this.localPoint = new b2Vec2(); + this.rA = new b2Vec2(); + this.rB = new b2Vec2(); + }; + b2ContactEdge.b2ContactEdge = function () {}; + b2ContactFactory.b2ContactFactory = function () {}; + b2ContactFactory.prototype.b2ContactFactory = function (allocator) { + this.m_allocator = allocator; + this.InitializeRegisters(); + } + b2ContactFactory.prototype.AddType = function (createFcn, destroyFcn, type1, type2) { + if (type1 === undefined) type1 = 0; + if (type2 === undefined) type2 = 0; + this.m_registers[type1][type2].createFcn = createFcn; + this.m_registers[type1][type2].destroyFcn = destroyFcn; + this.m_registers[type1][type2].primary = true; + if (type1 != type2) { + this.m_registers[type2][type1].createFcn = createFcn; + this.m_registers[type2][type1].destroyFcn = destroyFcn; + this.m_registers[type2][type1].primary = false; + } + } + b2ContactFactory.prototype.InitializeRegisters = function () { + this.m_registers = new Vector(b2Shape.e_shapeTypeCount); + for (var i = 0; i < b2Shape.e_shapeTypeCount; i++) { + this.m_registers[i] = new Vector(b2Shape.e_shapeTypeCount); + for (var j = 0; j < b2Shape.e_shapeTypeCount; j++) { + this.m_registers[i][j] = new b2ContactRegister(); + } + } + this.AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape); + this.AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape); + this.AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape); + this.AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape); + this.AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape); + } + b2ContactFactory.prototype.Create = function (fixtureA, fixtureB) { + var type1 = parseInt(fixtureA.GetType()); + var type2 = parseInt(fixtureB.GetType()); + var reg = this.m_registers[type1][type2]; + var c; + if (reg.pool) { + c = reg.pool; + reg.pool = c.m_next; + reg.poolCount--; + c.Reset(fixtureA, fixtureB); + return c; + } + var createFcn = reg.createFcn; + if (createFcn != null) { + if (reg.primary) { + c = createFcn(this.m_allocator); + c.Reset(fixtureA, fixtureB); + return c; + } + else { + c = createFcn(this.m_allocator); + c.Reset(fixtureB, fixtureA); + return c; + } + } + else { + return null; + } + } + b2ContactFactory.prototype.Destroy = function (contact) { + if (contact.m_manifold.m_pointCount > 0) { + contact.m_fixtureA.m_body.SetAwake(true); + contact.m_fixtureB.m_body.SetAwake(true); + } + var type1 = parseInt(contact.m_fixtureA.GetType()); + var type2 = parseInt(contact.m_fixtureB.GetType()); + var reg = this.m_registers[type1][type2]; + if (true) { + reg.poolCount++; + contact.m_next = reg.pool; + reg.pool = contact; + } + var destroyFcn = reg.destroyFcn; + destroyFcn(contact, this.m_allocator); + } + b2ContactRegister.b2ContactRegister = function () {}; + b2ContactResult.b2ContactResult = function () { + this.position = new b2Vec2(); + this.normal = new b2Vec2(); + this.id = new b2ContactID(); + }; + b2ContactSolver.b2ContactSolver = function () { + this.m_step = new b2TimeStep(); + this.m_constraints = new Vector(); + }; + b2ContactSolver.prototype.b2ContactSolver = function () {} + b2ContactSolver.prototype.Initialize = function (step, contacts, contactCount, allocator) { + if (contactCount === undefined) contactCount = 0; + var contact; + this.m_step.Set(step); + this.m_allocator = allocator; + var i = 0; + var tVec; + var tMat; + this.m_constraintCount = contactCount; + while (this.m_constraints.length < this.m_constraintCount) { + this.m_constraints[this.m_constraints.length] = new b2ContactConstraint(); + } + for (i = 0; + i < contactCount; ++i) { + contact = contacts[i]; + var fixtureA = contact.m_fixtureA; + var fixtureB = contact.m_fixtureB; + var shapeA = fixtureA.m_shape; + var shapeB = fixtureB.m_shape; + var radiusA = shapeA.m_radius; + var radiusB = shapeB.m_radius; + var bodyA = fixtureA.m_body; + var bodyB = fixtureB.m_body; + var manifold = contact.GetManifold(); + var friction = b2Settings.b2MixFriction(fixtureA.GetFriction(), fixtureB.GetFriction()); + var restitution = b2Settings.b2MixRestitution(fixtureA.GetRestitution(), fixtureB.GetRestitution()); + var vAX = bodyA.m_linearVelocity.x; + var vAY = bodyA.m_linearVelocity.y; + var vBX = bodyB.m_linearVelocity.x; + var vBY = bodyB.m_linearVelocity.y; + var wA = bodyA.m_angularVelocity; + var wB = bodyB.m_angularVelocity; + b2Settings.b2Assert(manifold.m_pointCount > 0); + b2ContactSolver.s_worldManifold.Initialize(manifold, bodyA.m_xf, radiusA, bodyB.m_xf, radiusB); + var normalX = b2ContactSolver.s_worldManifold.m_normal.x; + var normalY = b2ContactSolver.s_worldManifold.m_normal.y; + var cc = this.m_constraints[i]; + cc.bodyA = bodyA; + cc.bodyB = bodyB; + cc.manifold = manifold; + cc.normal.x = normalX; + cc.normal.y = normalY; + cc.pointCount = manifold.m_pointCount; + cc.friction = friction; + cc.restitution = restitution; + cc.localPlaneNormal.x = manifold.m_localPlaneNormal.x; + cc.localPlaneNormal.y = manifold.m_localPlaneNormal.y; + cc.localPoint.x = manifold.m_localPoint.x; + cc.localPoint.y = manifold.m_localPoint.y; + cc.radius = radiusA + radiusB; + cc.type = manifold.m_type; + for (var k = 0; k < cc.pointCount; ++k) { + var cp = manifold.m_points[k]; + var ccp = cc.points[k]; + ccp.normalImpulse = cp.m_normalImpulse; + ccp.tangentImpulse = cp.m_tangentImpulse; + ccp.localPoint.SetV(cp.m_localPoint); + var rAX = ccp.rA.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyA.m_sweep.c.x; + var rAY = ccp.rA.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyA.m_sweep.c.y; + var rBX = ccp.rB.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyB.m_sweep.c.x; + var rBY = ccp.rB.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyB.m_sweep.c.y; + var rnA = rAX * normalY - rAY * normalX; + var rnB = rBX * normalY - rBY * normalX; + rnA *= rnA; + rnB *= rnB; + var kNormal = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rnA + bodyB.m_invI * rnB; + ccp.normalMass = 1.0 / kNormal; + var kEqualized = bodyA.m_mass * bodyA.m_invMass + bodyB.m_mass * bodyB.m_invMass; + kEqualized += bodyA.m_mass * bodyA.m_invI * rnA + bodyB.m_mass * bodyB.m_invI * rnB; + ccp.equalizedMass = 1.0 / kEqualized; + var tangentX = normalY; + var tangentY = (-normalX); + var rtA = rAX * tangentY - rAY * tangentX; + var rtB = rBX * tangentY - rBY * tangentX; + rtA *= rtA; + rtB *= rtB; + var kTangent = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rtA + bodyB.m_invI * rtB; + ccp.tangentMass = 1.0 / kTangent; + ccp.velocityBias = 0.0; + var tX = vBX + ((-wB * rBY)) - vAX - ((-wA * rAY)); + var tY = vBY + (wB * rBX) - vAY - (wA * rAX); + var vRel = cc.normal.x * tX + cc.normal.y * tY; + if (vRel < (-b2Settings.b2_velocityThreshold)) { + ccp.velocityBias += (-cc.restitution * vRel); + } + } + if (cc.pointCount == 2) { + var ccp1 = cc.points[0]; + var ccp2 = cc.points[1]; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var rn1A = ccp1.rA.x * normalY - ccp1.rA.y * normalX; + var rn1B = ccp1.rB.x * normalY - ccp1.rB.y * normalX; + var rn2A = ccp2.rA.x * normalY - ccp2.rA.y * normalX; + var rn2B = ccp2.rB.x * normalY - ccp2.rB.y * normalX; + var k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B; + var k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B; + var k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B; + var k_maxConditionNumber = 100.0; + if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) { + cc.K.col1.Set(k11, k12); + cc.K.col2.Set(k12, k22); + cc.K.GetInverse(cc.normalMass); + } + else { + cc.pointCount = 1; + } + } + } + } + b2ContactSolver.prototype.InitVelocityConstraints = function (step) { + var tVec; + var tVec2; + var tMat; + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var normalX = c.normal.x; + var normalY = c.normal.y; + var tangentX = normalY; + var tangentY = (-normalX); + var tX = 0; + var j = 0; + var tCount = 0; + if (step.warmStarting) { + tCount = c.pointCount; + for (j = 0; + j < tCount; ++j) { + var ccp = c.points[j]; + ccp.normalImpulse *= step.dtRatio; + ccp.tangentImpulse *= step.dtRatio; + var PX = ccp.normalImpulse * normalX + ccp.tangentImpulse * tangentX; + var PY = ccp.normalImpulse * normalY + ccp.tangentImpulse * tangentY; + bodyA.m_angularVelocity -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + bodyA.m_linearVelocity.x -= invMassA * PX; + bodyA.m_linearVelocity.y -= invMassA * PY; + bodyB.m_angularVelocity += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + bodyB.m_linearVelocity.x += invMassB * PX; + bodyB.m_linearVelocity.y += invMassB * PY; + } + } + else { + tCount = c.pointCount; + for (j = 0; + j < tCount; ++j) { + var ccp2 = c.points[j]; + ccp2.normalImpulse = 0.0; + ccp2.tangentImpulse = 0.0; + } + } + } + } + b2ContactSolver.prototype.SolveVelocityConstraints = function () { + var j = 0; + var ccp; + var rAX = 0; + var rAY = 0; + var rBX = 0; + var rBY = 0; + var dvX = 0; + var dvY = 0; + var vn = 0; + var vt = 0; + var lambda = 0; + var maxFriction = 0; + var newImpulse = 0; + var PX = 0; + var PY = 0; + var dX = 0; + var dY = 0; + var P1X = 0; + var P1Y = 0; + var P2X = 0; + var P2Y = 0; + var tMat; + var tVec; + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var wA = bodyA.m_angularVelocity; + var wB = bodyB.m_angularVelocity; + var vA = bodyA.m_linearVelocity; + var vB = bodyB.m_linearVelocity; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var normalX = c.normal.x; + var normalY = c.normal.y; + var tangentX = normalY; + var tangentY = (-normalX); + var friction = c.friction; + var tX = 0; + for (j = 0; + j < c.pointCount; j++) { + ccp = c.points[j]; + dvX = vB.x - wB * ccp.rB.y - vA.x + wA * ccp.rA.y; + dvY = vB.y + wB * ccp.rB.x - vA.y - wA * ccp.rA.x; + vt = dvX * tangentX + dvY * tangentY; + lambda = ccp.tangentMass * (-vt); + maxFriction = friction * ccp.normalImpulse; + newImpulse = b2Math.Clamp(ccp.tangentImpulse + lambda, (-maxFriction), maxFriction); + lambda = newImpulse - ccp.tangentImpulse; + PX = lambda * tangentX; + PY = lambda * tangentY; + vA.x -= invMassA * PX; + vA.y -= invMassA * PY; + wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + vB.x += invMassB * PX; + vB.y += invMassB * PY; + wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + ccp.tangentImpulse = newImpulse; + } + var tCount = parseInt(c.pointCount); + if (c.pointCount == 1) { + ccp = c.points[0]; + dvX = vB.x + ((-wB * ccp.rB.y)) - vA.x - ((-wA * ccp.rA.y)); + dvY = vB.y + (wB * ccp.rB.x) - vA.y - (wA * ccp.rA.x); + vn = dvX * normalX + dvY * normalY; + lambda = (-ccp.normalMass * (vn - ccp.velocityBias)); + newImpulse = ccp.normalImpulse + lambda; + newImpulse = newImpulse > 0 ? newImpulse : 0.0; + lambda = newImpulse - ccp.normalImpulse; + PX = lambda * normalX; + PY = lambda * normalY; + vA.x -= invMassA * PX; + vA.y -= invMassA * PY; + wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + vB.x += invMassB * PX; + vB.y += invMassB * PY; + wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + ccp.normalImpulse = newImpulse; + } + else { + var cp1 = c.points[0]; + var cp2 = c.points[1]; + var aX = cp1.normalImpulse; + var aY = cp2.normalImpulse; + var dv1X = vB.x - wB * cp1.rB.y - vA.x + wA * cp1.rA.y; + var dv1Y = vB.y + wB * cp1.rB.x - vA.y - wA * cp1.rA.x; + var dv2X = vB.x - wB * cp2.rB.y - vA.x + wA * cp2.rA.y; + var dv2Y = vB.y + wB * cp2.rB.x - vA.y - wA * cp2.rA.x; + var vn1 = dv1X * normalX + dv1Y * normalY; + var vn2 = dv2X * normalX + dv2Y * normalY; + var bX = vn1 - cp1.velocityBias; + var bY = vn2 - cp2.velocityBias; + tMat = c.K; + bX -= tMat.col1.x * aX + tMat.col2.x * aY; + bY -= tMat.col1.y * aX + tMat.col2.y * aY; + var k_errorTol = 0.001; + for (;;) { + tMat = c.normalMass; + var xX = (-(tMat.col1.x * bX + tMat.col2.x * bY)); + var xY = (-(tMat.col1.y * bX + tMat.col2.y * bY)); + if (xX >= 0.0 && xY >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = (-cp1.normalMass * bX); + xY = 0.0; + vn1 = 0.0; + vn2 = c.K.col1.y * xX + bY; + if (xX >= 0.0 && vn2 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = 0.0; + xY = (-cp2.normalMass * bY); + vn1 = c.K.col2.x * xY + bX; + vn2 = 0.0; + if (xY >= 0.0 && vn1 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = 0.0; + xY = 0.0; + vn1 = bX; + vn2 = bY; + if (vn1 >= 0.0 && vn2 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + break; + } + } + bodyA.m_angularVelocity = wA; + bodyB.m_angularVelocity = wB; + } + } + b2ContactSolver.prototype.FinalizeVelocityConstraints = function () { + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var m = c.manifold; + for (var j = 0; j < c.pointCount; ++j) { + var point1 = m.m_points[j]; + var point2 = c.points[j]; + point1.m_normalImpulse = point2.normalImpulse; + point1.m_tangentImpulse = point2.tangentImpulse; + } + } + } + b2ContactSolver.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var minSeparation = 0.0; + for (var i = 0; i < this.m_constraintCount; i++) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var invMassA = bodyA.m_mass * bodyA.m_invMass; + var invIA = bodyA.m_mass * bodyA.m_invI; + var invMassB = bodyB.m_mass * bodyB.m_invMass; + var invIB = bodyB.m_mass * bodyB.m_invI; + b2ContactSolver.s_psm.Initialize(c); + var normal = b2ContactSolver.s_psm.m_normal; + for (var j = 0; j < c.pointCount; j++) { + var ccp = c.points[j]; + var point = b2ContactSolver.s_psm.m_points[j]; + var separation = b2ContactSolver.s_psm.m_separations[j]; + var rAX = point.x - bodyA.m_sweep.c.x; + var rAY = point.y - bodyA.m_sweep.c.y; + var rBX = point.x - bodyB.m_sweep.c.x; + var rBY = point.y - bodyB.m_sweep.c.y; + minSeparation = minSeparation < separation ? minSeparation : separation; + var C = b2Math.Clamp(baumgarte * (separation + b2Settings.b2_linearSlop), (-b2Settings.b2_maxLinearCorrection), 0.0); + var impulse = (-ccp.equalizedMass * C); + var PX = impulse * normal.x; + var PY = impulse * normal.y;bodyA.m_sweep.c.x -= invMassA * PX; + bodyA.m_sweep.c.y -= invMassA * PY; + bodyA.m_sweep.a -= invIA * (rAX * PY - rAY * PX); + bodyA.SynchronizeTransform(); + bodyB.m_sweep.c.x += invMassB * PX; + bodyB.m_sweep.c.y += invMassB * PY; + bodyB.m_sweep.a += invIB * (rBX * PY - rBY * PX); + bodyB.SynchronizeTransform(); + } + } + return minSeparation > (-1.5 * b2Settings.b2_linearSlop); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold = new b2WorldManifold(); + Box2D.Dynamics.Contacts.b2ContactSolver.s_psm = new b2PositionSolverManifold(); + }); + Box2D.inherit(b2EdgeAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2EdgeAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2EdgeAndCircleContact.b2EdgeAndCircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2EdgeAndCircleContact.Create = function (allocator) { + return new b2EdgeAndCircleContact(); + } + b2EdgeAndCircleContact.Destroy = function (contact, allocator) {} + b2EdgeAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2EdgeAndCircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + this.b2CollideEdgeAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2EdgeShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2EdgeAndCircleContact.prototype.b2CollideEdgeAndCircle = function (manifold, edge, xf1, circle, xf2) {} + Box2D.inherit(b2NullContact, Box2D.Dynamics.Contacts.b2Contact); + b2NullContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2NullContact.b2NullContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2NullContact.prototype.b2NullContact = function () { + this.__super.b2Contact.call(this); + } + b2NullContact.prototype.Evaluate = function () {} + Box2D.inherit(b2PolyAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolyAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolyAndCircleContact.b2PolyAndCircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolyAndCircleContact.Create = function (allocator) { + return new b2PolyAndCircleContact(); + } + b2PolyAndCircleContact.Destroy = function (contact, allocator) {} + b2PolyAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); + b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape); + } + b2PolyAndCircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.m_body; + var bB = this.m_fixtureB.m_body; + b2Collision.CollidePolygonAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + Box2D.inherit(b2PolyAndEdgeContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolyAndEdgeContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolyAndEdgeContact.b2PolyAndEdgeContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolyAndEdgeContact.Create = function (allocator) { + return new b2PolyAndEdgeContact(); + } + b2PolyAndEdgeContact.Destroy = function (contact, allocator) {} + b2PolyAndEdgeContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); + b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_edgeShape); + } + b2PolyAndEdgeContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + this.b2CollidePolyAndEdge(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2EdgeShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2PolyAndEdgeContact.prototype.b2CollidePolyAndEdge = function (manifold, polygon, xf1, edge, xf2) {} + Box2D.inherit(b2PolygonContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolygonContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolygonContact.b2PolygonContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolygonContact.Create = function (allocator) { + return new b2PolygonContact(); + } + b2PolygonContact.Destroy = function (contact, allocator) {} + b2PolygonContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2PolygonContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + b2Collision.CollidePolygons(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2PolygonShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2PositionSolverManifold.b2PositionSolverManifold = function () {}; + b2PositionSolverManifold.prototype.b2PositionSolverManifold = function () { + this.m_normal = new b2Vec2(); + this.m_separations = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2Vec2(); + } + } + b2PositionSolverManifold.prototype.Initialize = function (cc) { + b2Settings.b2Assert(cc.pointCount > 0); + var i = 0; + var clipPointX = 0; + var clipPointY = 0; + var tMat; + var tVec; + var planePointX = 0; + var planePointY = 0; + switch (cc.type) { + case b2Manifold.e_circles: + { + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPoint; + var pointAX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var pointAY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyB.m_xf.R; + tVec = cc.points[0].localPoint; + var pointBX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var pointBY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dX = pointBX - pointAX; + var dY = pointBY - pointAY; + var d2 = dX * dX + dY * dY; + if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { + var d = Math.sqrt(d2); + this.m_normal.x = dX / d; + this.m_normal.y = dY / d; + } + else { + this.m_normal.x = 1.0; + this.m_normal.y = 0.0; + } + this.m_points[0].x = 0.5 * (pointAX + pointBX); + this.m_points[0].y = 0.5 * (pointAY + pointBY); + this.m_separations[0] = dX * this.m_normal.x + dY * this.m_normal.y - cc.radius; + } + break; + case b2Manifold.e_faceA: + { + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPlaneNormal; + this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPoint; + planePointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + planePointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyB.m_xf.R; + for (i = 0; + i < cc.pointCount; ++i) { + tVec = cc.points[i].localPoint; + clipPointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + clipPointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; + this.m_points[i].x = clipPointX; + this.m_points[i].y = clipPointY; + } + } + break; + case b2Manifold.e_faceB: + { + tMat = cc.bodyB.m_xf.R; + tVec = cc.localPlaneNormal; + this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = cc.bodyB.m_xf.R; + tVec = cc.localPoint; + planePointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + planePointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyA.m_xf.R; + for (i = 0; + i < cc.pointCount; ++i) { + tVec = cc.points[i].localPoint; + clipPointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + clipPointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; + this.m_points[i].Set(clipPointX, clipPointY); + } + this.m_normal.x *= (-1); + this.m_normal.y *= (-1); + } + break; + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA = new b2Vec2(); + Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB = new b2Vec2(); + }); +})(); +(function () { + var b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController, + b2ConstantAccelController = Box2D.Dynamics.Controllers.b2ConstantAccelController, + b2ConstantForceController = Box2D.Dynamics.Controllers.b2ConstantForceController, + b2Controller = Box2D.Dynamics.Controllers.b2Controller, + b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, + b2GravityController = Box2D.Dynamics.Controllers.b2GravityController, + b2TensorDampingController = Box2D.Dynamics.Controllers.b2TensorDampingController; + + Box2D.inherit(b2BuoyancyController, Box2D.Dynamics.Controllers.b2Controller); + b2BuoyancyController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2BuoyancyController.b2BuoyancyController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.normal = new b2Vec2(0, (-1)); + this.offset = 0; + this.density = 0; + this.velocity = new b2Vec2(0, 0); + this.linearDrag = 2; + this.angularDrag = 1; + this.useDensity = false; + this.useWorldGravity = true; + this.gravity = null; + }; + b2BuoyancyController.prototype.Step = function (step) { + if (!this.m_bodyList) return; + if (this.useWorldGravity) { + this.gravity = this.GetWorld().GetGravity().Copy(); + } + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (body.IsAwake() == false) { + continue; + } + var areac = new b2Vec2(); + var massc = new b2Vec2(); + var area = 0.0; + var mass = 0.0; + for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { + var sc = new b2Vec2(); + var sarea = fixture.GetShape().ComputeSubmergedArea(this.normal, this.offset, body.GetTransform(), sc); + area += sarea; + areac.x += sarea * sc.x; + areac.y += sarea * sc.y; + var shapeDensity = 0; + if (this.useDensity) { + shapeDensity = 1; + } + else { + shapeDensity = 1; + } + mass += sarea * shapeDensity; + massc.x += sarea * sc.x * shapeDensity; + massc.y += sarea * sc.y * shapeDensity; + } + areac.x /= area; + areac.y /= area; + massc.x /= mass; + massc.y /= mass; + if (area < Number.MIN_VALUE) continue; + var buoyancyForce = this.gravity.GetNegative(); + buoyancyForce.Multiply(this.density * area); + body.ApplyForce(buoyancyForce, massc); + var dragForce = body.GetLinearVelocityFromWorldPoint(areac); + dragForce.Subtract(this.velocity); + dragForce.Multiply((-this.linearDrag * area)); + body.ApplyForce(dragForce, areac); + body.ApplyTorque((-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag)); + } + } + b2BuoyancyController.prototype.Draw = function (debugDraw) { + var r = 1000; + var p1 = new b2Vec2(); + var p2 = new b2Vec2(); + p1.x = this.normal.x * this.offset + this.normal.y * r; + p1.y = this.normal.y * this.offset - this.normal.x * r; + p2.x = this.normal.x * this.offset - this.normal.y * r; + p2.y = this.normal.y * this.offset + this.normal.x * r; + var color = new b2Color(0, 0, 1); + debugDraw.DrawSegment(p1, p2, color); + } + Box2D.inherit(b2ConstantAccelController, Box2D.Dynamics.Controllers.b2Controller); + b2ConstantAccelController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2ConstantAccelController.b2ConstantAccelController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.A = new b2Vec2(0, 0); + }; + b2ConstantAccelController.prototype.Step = function (step) { + var smallA = new b2Vec2(this.A.x * step.dt, this.A.y * step.dt); + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + smallA.x, body.GetLinearVelocity().y + smallA.y)); + } + } + Box2D.inherit(b2ConstantForceController, Box2D.Dynamics.Controllers.b2Controller); + b2ConstantForceController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2ConstantForceController.b2ConstantForceController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.F = new b2Vec2(0, 0); + }; + b2ConstantForceController.prototype.Step = function (step) { + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.ApplyForce(this.F, body.GetWorldCenter()); + } + } + b2Controller.b2Controller = function () {}; + b2Controller.prototype.Step = function (step) {} + b2Controller.prototype.Draw = function (debugDraw) {} + b2Controller.prototype.AddBody = function (body) { + var edge = new b2ControllerEdge(); + edge.controller = this; + edge.body = body; + edge.nextBody = this.m_bodyList; + edge.prevBody = null; + this.m_bodyList = edge; + if (edge.nextBody) edge.nextBody.prevBody = edge; + this.m_bodyCount++; + edge.nextController = body.m_controllerList; + edge.prevController = null; + body.m_controllerList = edge; + if (edge.nextController) edge.nextController.prevController = edge; + body.m_controllerCount++; + } + b2Controller.prototype.RemoveBody = function (body) { + var edge = body.m_controllerList; + while (edge && edge.controller != this) + edge = edge.nextController; + if (edge.prevBody) edge.prevBody.nextBody = edge.nextBody; + if (edge.nextBody) edge.nextBody.prevBody = edge.prevBody; + if (edge.nextController) edge.nextController.prevController = edge.prevController; + if (edge.prevController) edge.prevController.nextController = edge.nextController; + if (this.m_bodyList == edge) this.m_bodyList = edge.nextBody; + if (body.m_controllerList == edge) body.m_controllerList = edge.nextController; + body.m_controllerCount--; + this.m_bodyCount--; + } + b2Controller.prototype.Clear = function () { + while (this.m_bodyList) + this.RemoveBody(this.m_bodyList.body); + } + b2Controller.prototype.GetNext = function () { + return this.m_next; + } + b2Controller.prototype.GetWorld = function () { + return this.m_world; + } + b2Controller.prototype.GetBodyList = function () { + return this.m_bodyList; + } + b2ControllerEdge.b2ControllerEdge = function () {}; + Box2D.inherit(b2GravityController, Box2D.Dynamics.Controllers.b2Controller); + b2GravityController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2GravityController.b2GravityController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.G = 1; + this.invSqr = true; + }; + b2GravityController.prototype.Step = function (step) { + var i = null; + var body1 = null; + var p1 = null; + var mass1 = 0; + var j = null; + var body2 = null; + var p2 = null; + var dx = 0; + var dy = 0; + var r2 = 0; + var f = null; + if (this.invSqr) { + for (i = this.m_bodyList; + i; i = i.nextBody) { + body1 = i.body; + p1 = body1.GetWorldCenter(); + mass1 = body1.GetMass(); + for (j = this.m_bodyList; + j != i; j = j.nextBody) { + body2 = j.body; + p2 = body2.GetWorldCenter(); + dx = p2.x - p1.x; + dy = p2.y - p1.y; + r2 = dx * dx + dy * dy; + if (r2 < Number.MIN_VALUE) continue; + f = new b2Vec2(dx, dy); + f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.GetMass()); + if (body1.IsAwake()) body1.ApplyForce(f, p1); + f.Multiply((-1)); + if (body2.IsAwake()) body2.ApplyForce(f, p2); + } + } + } + else { + for (i = this.m_bodyList; + i; i = i.nextBody) { + body1 = i.body; + p1 = body1.GetWorldCenter(); + mass1 = body1.GetMass(); + for (j = this.m_bodyList; + j != i; j = j.nextBody) { + body2 = j.body; + p2 = body2.GetWorldCenter(); + dx = p2.x - p1.x; + dy = p2.y - p1.y; + r2 = dx * dx + dy * dy; + if (r2 < Number.MIN_VALUE) continue; + f = new b2Vec2(dx, dy); + f.Multiply(this.G / r2 * mass1 * body2.GetMass()); + if (body1.IsAwake()) body1.ApplyForce(f, p1); + f.Multiply((-1)); + if (body2.IsAwake()) body2.ApplyForce(f, p2); + } + } + } + } + Box2D.inherit(b2TensorDampingController, Box2D.Dynamics.Controllers.b2Controller); + b2TensorDampingController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2TensorDampingController.b2TensorDampingController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.T = new b2Mat22(); + this.maxTimestep = 0; + }; + b2TensorDampingController.prototype.SetAxisAligned = function (xDamping, yDamping) { + if (xDamping === undefined) xDamping = 0; + if (yDamping === undefined) yDamping = 0; + this.T.col1.x = (-xDamping); + this.T.col1.y = 0; + this.T.col2.x = 0; + this.T.col2.y = (-yDamping); + if (xDamping > 0 || yDamping > 0) { + this.maxTimestep = 1 / Math.max(xDamping, yDamping); + } + else { + this.maxTimestep = 0; + } + } + b2TensorDampingController.prototype.Step = function (step) { + var timestep = step.dt; + if (timestep <= Number.MIN_VALUE) return; + if (timestep > this.maxTimestep && this.maxTimestep > 0) timestep = this.maxTimestep; + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) { + continue; + } + var damping = body.GetWorldVector(b2Math.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity()))); + body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + damping.x * timestep, body.GetLinearVelocity().y + damping.y * timestep)); + } + } +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, + b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, + b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, + b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, + b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, + b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, + b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, + b2Joint = Box2D.Dynamics.Joints.b2Joint, + b2JointDef = Box2D.Dynamics.Joints.b2JointDef, + b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, + b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, + b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, + b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, + b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, + b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, + b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, + b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, + b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, + b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, + b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, + b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, + b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World; + + Box2D.inherit(b2DistanceJoint, Box2D.Dynamics.Joints.b2Joint); + b2DistanceJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2DistanceJoint.b2DistanceJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_u = new b2Vec2(); + }; + b2DistanceJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2DistanceJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2DistanceJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_u.x, inv_dt * this.m_impulse * this.m_u.y); + } + b2DistanceJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2DistanceJoint.prototype.GetLength = function () { + return this.m_length; + } + b2DistanceJoint.prototype.SetLength = function (length) { + if (length === undefined) length = 0; + this.m_length = length; + } + b2DistanceJoint.prototype.GetFrequency = function () { + return this.m_frequencyHz; + } + b2DistanceJoint.prototype.SetFrequency = function (hz) { + if (hz === undefined) hz = 0; + this.m_frequencyHz = hz; + } + b2DistanceJoint.prototype.GetDampingRatio = function () { + return this.m_dampingRatio; + } + b2DistanceJoint.prototype.SetDampingRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_dampingRatio = ratio; + } + b2DistanceJoint.prototype.b2DistanceJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_length = def.length; + this.m_frequencyHz = def.frequencyHz; + this.m_dampingRatio = def.dampingRatio; + this.m_impulse = 0.0; + this.m_gamma = 0.0; + this.m_bias = 0.0; + } + b2DistanceJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + this.m_u.x = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + this.m_u.y = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var length = Math.sqrt(this.m_u.x * this.m_u.x + this.m_u.y * this.m_u.y); + if (length > b2Settings.b2_linearSlop) { + this.m_u.Multiply(1.0 / length); + } + else { + this.m_u.SetZero(); + } + var cr1u = (r1X * this.m_u.y - r1Y * this.m_u.x); + var cr2u = (r2X * this.m_u.y - r2Y * this.m_u.x); + var invMass = bA.m_invMass + bA.m_invI * cr1u * cr1u + bB.m_invMass + bB.m_invI * cr2u * cr2u; + this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0; + if (this.m_frequencyHz > 0.0) { + var C = length - this.m_length; + var omega = 2.0 * Math.PI * this.m_frequencyHz; + var d = 2.0 * this.m_mass * this.m_dampingRatio * omega; + var k = this.m_mass * omega * omega; + this.m_gamma = step.dt * (d + step.dt * k); + this.m_gamma = this.m_gamma != 0.0 ? 1 / this.m_gamma : 0.0; + this.m_bias = C * step.dt * k * this.m_gamma; + this.m_mass = invMass + this.m_gamma; + this.m_mass = this.m_mass != 0.0 ? 1.0 / this.m_mass : 0.0; + } + if (step.warmStarting) { + this.m_impulse *= step.dtRatio; + var PX = this.m_impulse * this.m_u.x; + var PY = this.m_impulse * this.m_u.y; + bA.m_linearVelocity.x -= bA.m_invMass * PX; + bA.m_linearVelocity.y -= bA.m_invMass * PY; + bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_linearVelocity.x += bB.m_invMass * PX; + bB.m_linearVelocity.y += bB.m_invMass * PY; + bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); + } + else { + this.m_impulse = 0.0; + } + } + b2DistanceJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + var v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + var v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + var v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + var Cdot = (this.m_u.x * (v2X - v1X) + this.m_u.y * (v2Y - v1Y)); + var impulse = (-this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse)); + this.m_impulse += impulse; + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + bA.m_linearVelocity.x -= bA.m_invMass * PX; + bA.m_linearVelocity.y -= bA.m_invMass * PY; + bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_linearVelocity.x += bB.m_invMass * PX; + bB.m_linearVelocity.y += bB.m_invMass * PY; + bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); + } + b2DistanceJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var tMat; + if (this.m_frequencyHz > 0.0) { + return true; + } + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var length = Math.sqrt(dX * dX + dY * dY); + dX /= length; + dY /= length; + var C = length - this.m_length; + C = b2Math.Clamp(C, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + var impulse = (-this.m_mass * C); + this.m_u.Set(dX, dY); + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + bA.m_sweep.c.x -= bA.m_invMass * PX; + bA.m_sweep.c.y -= bA.m_invMass * PY; + bA.m_sweep.a -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_sweep.c.x += bB.m_invMass * PX; + bB.m_sweep.c.y += bB.m_invMass * PY; + bB.m_sweep.a += bB.m_invI * (r2X * PY - r2Y * PX); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return b2Math.Abs(C) < b2Settings.b2_linearSlop; + } + Box2D.inherit(b2DistanceJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2DistanceJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2DistanceJointDef.b2DistanceJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2DistanceJointDef.prototype.b2DistanceJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_distanceJoint; + this.length = 1.0; + this.frequencyHz = 0.0; + this.dampingRatio = 0.0; + } + b2DistanceJointDef.prototype.Initialize = function (bA, bB, anchorA, anchorB) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchorA)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchorB)); + var dX = anchorB.x - anchorA.x; + var dY = anchorB.y - anchorA.y; + this.length = Math.sqrt(dX * dX + dY * dY); + this.frequencyHz = 0.0; + this.dampingRatio = 0.0; + } + Box2D.inherit(b2FrictionJoint, Box2D.Dynamics.Joints.b2Joint); + b2FrictionJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2FrictionJoint.b2FrictionJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchorA = new b2Vec2(); + this.m_localAnchorB = new b2Vec2(); + this.m_linearMass = new b2Mat22(); + this.m_linearImpulse = new b2Vec2(); + }; + b2FrictionJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); + } + b2FrictionJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); + } + b2FrictionJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_linearImpulse.x, inv_dt * this.m_linearImpulse.y); + } + b2FrictionJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_angularImpulse; + } + b2FrictionJoint.prototype.SetMaxForce = function (force) { + if (force === undefined) force = 0; + this.m_maxForce = force; + } + b2FrictionJoint.prototype.GetMaxForce = function () { + return this.m_maxForce; + } + b2FrictionJoint.prototype.SetMaxTorque = function (torque) { + if (torque === undefined) torque = 0; + this.m_maxTorque = torque; + } + b2FrictionJoint.prototype.GetMaxTorque = function () { + return this.m_maxTorque; + } + b2FrictionJoint.prototype.b2FrictionJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchorA.SetV(def.localAnchorA); + this.m_localAnchorB.SetV(def.localAnchorB); + this.m_linearMass.SetZero(); + this.m_angularMass = 0.0; + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0.0; + this.m_maxForce = def.maxForce; + this.m_maxTorque = def.maxTorque; + } + b2FrictionJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + var K = new b2Mat22(); + K.col1.x = mA + mB; + K.col2.x = 0.0; + K.col1.y = 0.0; + K.col2.y = mA + mB; + K.col1.x += iA * rAY * rAY; + K.col2.x += (-iA * rAX * rAY); + K.col1.y += (-iA * rAX * rAY); + K.col2.y += iA * rAX * rAX; + K.col1.x += iB * rBY * rBY; + K.col2.x += (-iB * rBX * rBY); + K.col1.y += (-iB * rBX * rBY); + K.col2.y += iB * rBX * rBX; + K.GetInverse(this.m_linearMass); + this.m_angularMass = iA + iB; + if (this.m_angularMass > 0.0) { + this.m_angularMass = 1.0 / this.m_angularMass; + } + if (step.warmStarting) { + this.m_linearImpulse.x *= step.dtRatio; + this.m_linearImpulse.y *= step.dtRatio; + this.m_angularImpulse *= step.dtRatio; + var P = this.m_linearImpulse; + bA.m_linearVelocity.x -= mA * P.x; + bA.m_linearVelocity.y -= mA * P.y; + bA.m_angularVelocity -= iA * (rAX * P.y - rAY * P.x + this.m_angularImpulse); + bB.m_linearVelocity.x += mB * P.x; + bB.m_linearVelocity.y += mB * P.y; + bB.m_angularVelocity += iB * (rBX * P.y - rBY * P.x + this.m_angularImpulse); + } + else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0.0; + } + } + b2FrictionJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var vA = bA.m_linearVelocity; + var wA = bA.m_angularVelocity; + var vB = bB.m_linearVelocity; + var wB = bB.m_angularVelocity; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var maxImpulse = 0; { + var Cdot = wB - wA; + var impulse = (-this.m_angularMass * Cdot); + var oldImpulse = this.m_angularImpulse; + maxImpulse = step.dt * this.m_maxTorque; + this.m_angularImpulse = b2Math.Clamp(this.m_angularImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_angularImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + } { + var CdotX = vB.x - wB * rBY - vA.x + wA * rAY; + var CdotY = vB.y + wB * rBX - vA.y - wA * rAX; + var impulseV = b2Math.MulMV(this.m_linearMass, new b2Vec2((-CdotX), (-CdotY))); + var oldImpulseV = this.m_linearImpulse.Copy(); + this.m_linearImpulse.Add(impulseV); + maxImpulse = step.dt * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.Multiply(maxImpulse); + } + impulseV = b2Math.SubtractVV(this.m_linearImpulse, oldImpulseV); + vA.x -= mA * impulseV.x; + vA.y -= mA * impulseV.y; + wA -= iA * (rAX * impulseV.y - rAY * impulseV.x); + vB.x += mB * impulseV.x; + vB.y += mB * impulseV.y; + wB += iB * (rBX * impulseV.y - rBY * impulseV.x); + } + bA.m_angularVelocity = wA; + bB.m_angularVelocity = wB; + } + b2FrictionJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return true; + } + Box2D.inherit(b2FrictionJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2FrictionJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2FrictionJointDef.b2FrictionJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2FrictionJointDef.prototype.b2FrictionJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_frictionJoint; + this.maxForce = 0.0; + this.maxTorque = 0.0; + } + b2FrictionJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); + } + Box2D.inherit(b2GearJoint, Box2D.Dynamics.Joints.b2Joint); + b2GearJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2GearJoint.b2GearJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_groundAnchor1 = new b2Vec2(); + this.m_groundAnchor2 = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_J = new b2Jacobian(); + }; + b2GearJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2GearJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2GearJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_J.linearB.x, inv_dt * this.m_impulse * this.m_J.linearB.y); + } + b2GearJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + var tMat = this.m_bodyB.m_xf.R; + var rX = this.m_localAnchor1.x - this.m_bodyB.m_sweep.localCenter.x; + var rY = this.m_localAnchor1.y - this.m_bodyB.m_sweep.localCenter.y; + var tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + var PX = this.m_impulse * this.m_J.linearB.x; + var PY = this.m_impulse * this.m_J.linearB.y; + return inv_dt * (this.m_impulse * this.m_J.angularB - rX * PY + rY * PX); + } + b2GearJoint.prototype.GetRatio = function () { + return this.m_ratio; + } + b2GearJoint.prototype.SetRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_ratio = ratio; + } + b2GearJoint.prototype.b2GearJoint = function (def) { + this.__super.b2Joint.call(this, def); + var type1 = parseInt(def.joint1.m_type); + var type2 = parseInt(def.joint2.m_type); + this.m_revolute1 = null; + this.m_prismatic1 = null; + this.m_revolute2 = null; + this.m_prismatic2 = null; + var coordinate1 = 0; + var coordinate2 = 0; + this.m_ground1 = def.joint1.GetBodyA(); + this.m_bodyA = def.joint1.GetBodyB(); + if (type1 == b2Joint.e_revoluteJoint) { + this.m_revolute1 = (def.joint1 instanceof b2RevoluteJoint ? def.joint1 : null); + this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1); + this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2); + coordinate1 = this.m_revolute1.GetJointAngle(); + } + else { + this.m_prismatic1 = (def.joint1 instanceof b2PrismaticJoint ? def.joint1 : null); + this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1); + this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2); + coordinate1 = this.m_prismatic1.GetJointTranslation(); + } + this.m_ground2 = def.joint2.GetBodyA(); + this.m_bodyB = def.joint2.GetBodyB(); + if (type2 == b2Joint.e_revoluteJoint) { + this.m_revolute2 = (def.joint2 instanceof b2RevoluteJoint ? def.joint2 : null); + this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1); + this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2); + coordinate2 = this.m_revolute2.GetJointAngle(); + } + else { + this.m_prismatic2 = (def.joint2 instanceof b2PrismaticJoint ? def.joint2 : null); + this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1); + this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2); + coordinate2 = this.m_prismatic2.GetJointTranslation(); + } + this.m_ratio = def.ratio; + this.m_constant = coordinate1 + this.m_ratio * coordinate2; + this.m_impulse = 0.0; + } + b2GearJoint.prototype.InitVelocityConstraints = function (step) { + var g1 = this.m_ground1; + var g2 = this.m_ground2; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var ugX = 0; + var ugY = 0; + var rX = 0; + var rY = 0; + var tMat; + var tVec; + var crug = 0; + var tX = 0; + var K = 0.0; + this.m_J.SetZero(); + if (this.m_revolute1) { + this.m_J.angularA = (-1.0); + K += bA.m_invI; + } + else { + tMat = g1.m_xf.R; + tVec = this.m_prismatic1.m_localXAxis1; + ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = bA.m_xf.R; + rX = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + rY = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + crug = rX * ugY - rY * ugX; + this.m_J.linearA.Set((-ugX), (-ugY)); + this.m_J.angularA = (-crug); + K += bA.m_invMass + bA.m_invI * crug * crug; + } + if (this.m_revolute2) { + this.m_J.angularB = (-this.m_ratio); + K += this.m_ratio * this.m_ratio * bB.m_invI; + } + else { + tMat = g2.m_xf.R; + tVec = this.m_prismatic2.m_localXAxis1; + ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = bB.m_xf.R; + rX = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + rY = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + crug = rX * ugY - rY * ugX; + this.m_J.linearB.Set((-this.m_ratio * ugX), (-this.m_ratio * ugY)); + this.m_J.angularB = (-this.m_ratio * crug); + K += this.m_ratio * this.m_ratio * (bB.m_invMass + bB.m_invI * crug * crug); + } + this.m_mass = K > 0.0 ? 1.0 / K : 0.0; + if (step.warmStarting) { + bA.m_linearVelocity.x += bA.m_invMass * this.m_impulse * this.m_J.linearA.x; + bA.m_linearVelocity.y += bA.m_invMass * this.m_impulse * this.m_J.linearA.y; + bA.m_angularVelocity += bA.m_invI * this.m_impulse * this.m_J.angularA; + bB.m_linearVelocity.x += bB.m_invMass * this.m_impulse * this.m_J.linearB.x; + bB.m_linearVelocity.y += bB.m_invMass * this.m_impulse * this.m_J.linearB.y; + bB.m_angularVelocity += bB.m_invI * this.m_impulse * this.m_J.angularB; + } + else { + this.m_impulse = 0.0; + } + } + b2GearJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var Cdot = this.m_J.Compute(bA.m_linearVelocity, bA.m_angularVelocity, bB.m_linearVelocity, bB.m_angularVelocity); + var impulse = (-this.m_mass * Cdot); + this.m_impulse += impulse; + bA.m_linearVelocity.x += bA.m_invMass * impulse * this.m_J.linearA.x; + bA.m_linearVelocity.y += bA.m_invMass * impulse * this.m_J.linearA.y; + bA.m_angularVelocity += bA.m_invI * impulse * this.m_J.angularA; + bB.m_linearVelocity.x += bB.m_invMass * impulse * this.m_J.linearB.x; + bB.m_linearVelocity.y += bB.m_invMass * impulse * this.m_J.linearB.y; + bB.m_angularVelocity += bB.m_invI * impulse * this.m_J.angularB; + } + b2GearJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var linearError = 0.0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var coordinate1 = 0; + var coordinate2 = 0; + if (this.m_revolute1) { + coordinate1 = this.m_revolute1.GetJointAngle(); + } + else { + coordinate1 = this.m_prismatic1.GetJointTranslation(); + } + if (this.m_revolute2) { + coordinate2 = this.m_revolute2.GetJointAngle(); + } + else { + coordinate2 = this.m_prismatic2.GetJointTranslation(); + } + var C = this.m_constant - (coordinate1 + this.m_ratio * coordinate2); + var impulse = (-this.m_mass * C); + bA.m_sweep.c.x += bA.m_invMass * impulse * this.m_J.linearA.x; + bA.m_sweep.c.y += bA.m_invMass * impulse * this.m_J.linearA.y; + bA.m_sweep.a += bA.m_invI * impulse * this.m_J.angularA; + bB.m_sweep.c.x += bB.m_invMass * impulse * this.m_J.linearB.x; + bB.m_sweep.c.y += bB.m_invMass * impulse * this.m_J.linearB.y; + bB.m_sweep.a += bB.m_invI * impulse * this.m_J.angularB; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return linearError < b2Settings.b2_linearSlop; + } + Box2D.inherit(b2GearJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2GearJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2GearJointDef.b2GearJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + }; + b2GearJointDef.prototype.b2GearJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_gearJoint; + this.joint1 = null; + this.joint2 = null; + this.ratio = 1.0; + } + b2Jacobian.b2Jacobian = function () { + this.linearA = new b2Vec2(); + this.linearB = new b2Vec2(); + }; + b2Jacobian.prototype.SetZero = function () { + this.linearA.SetZero(); + this.angularA = 0.0; + this.linearB.SetZero(); + this.angularB = 0.0; + } + b2Jacobian.prototype.Set = function (x1, a1, x2, a2) { + if (a1 === undefined) a1 = 0; + if (a2 === undefined) a2 = 0; + this.linearA.SetV(x1); + this.angularA = a1; + this.linearB.SetV(x2); + this.angularB = a2; + } + b2Jacobian.prototype.Compute = function (x1, a1, x2, a2) { + if (a1 === undefined) a1 = 0; + if (a2 === undefined) a2 = 0; + return (this.linearA.x * x1.x + this.linearA.y * x1.y) + this.angularA * a1 + (this.linearB.x * x2.x + this.linearB.y * x2.y) + this.angularB * a2; + } + b2Joint.b2Joint = function () { + this.m_edgeA = new b2JointEdge(); + this.m_edgeB = new b2JointEdge(); + this.m_localCenterA = new b2Vec2(); + this.m_localCenterB = new b2Vec2(); + }; + b2Joint.prototype.GetType = function () { + return this.m_type; + } + b2Joint.prototype.GetAnchorA = function () { + return null; + } + b2Joint.prototype.GetAnchorB = function () { + return null; + } + b2Joint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return null; + } + b2Joint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2Joint.prototype.GetBodyA = function () { + return this.m_bodyA; + } + b2Joint.prototype.GetBodyB = function () { + return this.m_bodyB; + } + b2Joint.prototype.GetNext = function () { + return this.m_next; + } + b2Joint.prototype.GetUserData = function () { + return this.m_userData; + } + b2Joint.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Joint.prototype.IsActive = function () { + return this.m_bodyA.IsActive() && this.m_bodyB.IsActive(); + } + b2Joint.Create = function (def, allocator) { + var joint = null; + switch (def.type) { + case b2Joint.e_distanceJoint: + { + joint = new b2DistanceJoint((def instanceof b2DistanceJointDef ? def : null)); + } + break; + case b2Joint.e_mouseJoint: + { + joint = new b2MouseJoint((def instanceof b2MouseJointDef ? def : null)); + } + break; + case b2Joint.e_prismaticJoint: + { + joint = new b2PrismaticJoint((def instanceof b2PrismaticJointDef ? def : null)); + } + break; + case b2Joint.e_revoluteJoint: + { + joint = new b2RevoluteJoint((def instanceof b2RevoluteJointDef ? def : null)); + } + break; + case b2Joint.e_pulleyJoint: + { + joint = new b2PulleyJoint((def instanceof b2PulleyJointDef ? def : null)); + } + break; + case b2Joint.e_gearJoint: + { + joint = new b2GearJoint((def instanceof b2GearJointDef ? def : null)); + } + break; + case b2Joint.e_lineJoint: + { + joint = new b2LineJoint((def instanceof b2LineJointDef ? def : null)); + } + break; + case b2Joint.e_weldJoint: + { + joint = new b2WeldJoint((def instanceof b2WeldJointDef ? def : null)); + } + break; + case b2Joint.e_frictionJoint: + { + joint = new b2FrictionJoint((def instanceof b2FrictionJointDef ? def : null)); + } + break; + default: + break; + } + return joint; + } + b2Joint.Destroy = function (joint, allocator) {} + b2Joint.prototype.b2Joint = function (def) { + b2Settings.b2Assert(def.bodyA != def.bodyB); + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_bodyA = def.bodyA; + this.m_bodyB = def.bodyB; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + } + b2Joint.prototype.InitVelocityConstraints = function (step) {} + b2Joint.prototype.SolveVelocityConstraints = function (step) {} + b2Joint.prototype.FinalizeVelocityConstraints = function () {} + b2Joint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return false; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2Joint.e_unknownJoint = 0; + Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint = 1; + Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint = 2; + Box2D.Dynamics.Joints.b2Joint.e_distanceJoint = 3; + Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint = 4; + Box2D.Dynamics.Joints.b2Joint.e_mouseJoint = 5; + Box2D.Dynamics.Joints.b2Joint.e_gearJoint = 6; + Box2D.Dynamics.Joints.b2Joint.e_lineJoint = 7; + Box2D.Dynamics.Joints.b2Joint.e_weldJoint = 8; + Box2D.Dynamics.Joints.b2Joint.e_frictionJoint = 9; + Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit = 0; + Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit = 1; + Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit = 2; + Box2D.Dynamics.Joints.b2Joint.e_equalLimits = 3; + }); + b2JointDef.b2JointDef = function () {}; + b2JointDef.prototype.b2JointDef = function () { + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.bodyA = null; + this.bodyB = null; + this.collideConnected = false; + } + b2JointEdge.b2JointEdge = function () {}; + Box2D.inherit(b2LineJoint, Box2D.Dynamics.Joints.b2Joint); + b2LineJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2LineJoint.b2LineJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_localXAxis1 = new b2Vec2(); + this.m_localYAxis1 = new b2Vec2(); + this.m_axis = new b2Vec2(); + this.m_perp = new b2Vec2(); + this.m_K = new b2Mat22(); + this.m_impulse = new b2Vec2(); + }; + b2LineJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2LineJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2LineJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y)); + } + b2LineJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.y; + } + b2LineJoint.prototype.GetJointTranslation = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var p1 = bA.GetWorldPoint(this.m_localAnchor1); + var p2 = bB.GetWorldPoint(this.m_localAnchor2); + var dX = p2.x - p1.x; + var dY = p2.y - p1.y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var translation = axis.x * dX + axis.y * dY; + return translation; + } + b2LineJoint.prototype.GetJointSpeed = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var v1 = bA.m_linearVelocity; + var v2 = bB.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var w2 = bB.m_angularVelocity; + var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + return speed; + } + b2LineJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2LineJoint.prototype.EnableLimit = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + } + b2LineJoint.prototype.GetLowerLimit = function () { + return this.m_lowerTranslation; + } + b2LineJoint.prototype.GetUpperLimit = function () { + return this.m_upperTranslation; + } + b2LineJoint.prototype.SetLimits = function (lower, upper) { + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_lowerTranslation = lower; + this.m_upperTranslation = upper; + } + b2LineJoint.prototype.IsMotorEnabled = function () { + return this.m_enableMotor; + } + b2LineJoint.prototype.EnableMotor = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + b2LineJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2LineJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2LineJoint.prototype.SetMaxMotorForce = function (force) { + if (force === undefined) force = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorForce = force; + } + b2LineJoint.prototype.GetMaxMotorForce = function () { + return this.m_maxMotorForce; + } + b2LineJoint.prototype.GetMotorForce = function () { + return this.m_motorImpulse; + } + b2LineJoint.prototype.b2LineJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_localXAxis1.SetV(def.localAxisA); + this.m_localYAxis1.x = (-this.m_localXAxis1.y); + this.m_localYAxis1.y = this.m_localXAxis1.x; + this.m_impulse.SetZero(); + this.m_motorMass = 0.0; + this.m_motorImpulse = 0.0; + this.m_lowerTranslation = def.lowerTranslation; + this.m_upperTranslation = def.upperTranslation; + this.m_maxMotorForce = def.maxMotorForce; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_axis.SetZero(); + this.m_perp.SetZero(); + } + b2LineJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + this.m_localCenterA.SetV(bA.GetLocalCenter()); + this.m_localCenterB.SetV(bB.GetLocalCenter()); + var xf1 = bA.GetTransform(); + var xf2 = bB.GetTransform(); + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + this.m_invMassA = bA.m_invMass; + this.m_invMassB = bB.m_invMass; + this.m_invIA = bA.m_invI; + this.m_invIB = bB.m_invI; { + this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; + this.m_motorMass = this.m_motorMass > Number.MIN_VALUE ? 1.0 / this.m_motorMass : 0.0; + } { + this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var m1 = this.m_invMassA; + var m2 = this.m_invMassB; + var i1 = this.m_invIA; + var i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + } + if (this.m_enableLimit) { + var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointTransition <= this.m_lowerTranslation) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_limitState = b2Joint.e_atLowerLimit; + this.m_impulse.y = 0.0; + } + } + else if (jointTransition >= this.m_upperTranslation) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_limitState = b2Joint.e_atUpperLimit; + this.m_impulse.y = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.y = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x; + var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y; + var L1 = this.m_impulse.x * this.m_s1 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a1; + var L2 = this.m_impulse.x * this.m_s2 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a2; + bA.m_linearVelocity.x -= this.m_invMassA * PX; + bA.m_linearVelocity.y -= this.m_invMassA * PY; + bA.m_angularVelocity -= this.m_invIA * L1; + bB.m_linearVelocity.x += this.m_invMassB * PX; + bB.m_linearVelocity.y += this.m_invMassB * PY; + bB.m_angularVelocity += this.m_invIB * L2; + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2LineJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var PX = 0; + var PY = 0; + var L1 = 0; + var L2 = 0; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorForce; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + PX = impulse * this.m_axis.x; + PY = impulse * this.m_axis.y; + L1 = impulse * this.m_a1; + L2 = impulse * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + var Cdot1 = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var f1 = this.m_impulse.Copy(); + var df = this.m_K.Solve(new b2Vec2(), (-Cdot1), (-Cdot2)); + this.m_impulse.Add(df); + if (this.m_limitState == b2Joint.e_atLowerLimit) { + this.m_impulse.y = b2Math.Max(this.m_impulse.y, 0.0); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + this.m_impulse.y = b2Math.Min(this.m_impulse.y, 0.0); + } + var b = (-Cdot1) - (this.m_impulse.y - f1.y) * this.m_K.col2.x; + var f2r = 0; + if (this.m_K.col1.x != 0.0) { + f2r = b / this.m_K.col1.x + f1.x; + } + else { + f2r = f1.x; + } + this.m_impulse.x = f2r; + df.x = this.m_impulse.x - f1.x; + df.y = this.m_impulse.y - f1.y; + PX = df.x * this.m_perp.x + df.y * this.m_axis.x; + PY = df.x * this.m_perp.y + df.y * this.m_axis.y; + L1 = df.x * this.m_s1 + df.y * this.m_a1; + L2 = df.x * this.m_s2 + df.y * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + else { + var df2 = 0; + if (this.m_K.col1.x != 0.0) { + df2 = ((-Cdot1)) / this.m_K.col1.x; + } + else { + df2 = 0.0; + } + this.m_impulse.x += df2; + PX = df2 * this.m_perp.x; + PY = df2 * this.m_perp.y; + L1 = df2 * this.m_s1; + L2 = df2 * this.m_s2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2LineJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var limitC = 0; + var oldLimitImpulse = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var c1 = bA.m_sweep.c; + var a1 = bA.m_sweep.a; + var c2 = bB.m_sweep.c; + var a2 = bB.m_sweep.a; + var tMat; + var tX = 0; + var m1 = 0; + var m2 = 0; + var i1 = 0; + var i2 = 0; + var linearError = 0.0; + var angularError = 0.0; + var active = false; + var C2 = 0.0; + var R1 = b2Mat22.FromAngle(a1); + var R2 = b2Mat22.FromAngle(a2); + tMat = R1; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = R2; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = c2.x + r2X - c1.x - r1X; + var dY = c2.y + r2Y - c1.y - r1Y; + if (this.m_enableLimit) { + this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + var translation = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + linearError = b2Math.Abs(translation); + active = true; + } + else if (translation <= this.m_lowerTranslation) { + C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + linearError = this.m_lowerTranslation - translation; + active = true; + } + else if (translation >= this.m_upperTranslation) { + C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); + linearError = translation - this.m_upperTranslation; + active = true; + } + } + this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var impulse = new b2Vec2(); + var C1 = this.m_perp.x * dX + this.m_perp.y * dY; + linearError = b2Math.Max(linearError, b2Math.Abs(C1)); + angularError = 0.0; + if (active) { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + this.m_K.Solve(impulse, (-C1), (-C2)); + } + else { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + var impulse1 = 0; + if (k11 != 0.0) { + impulse1 = ((-C1)) / k11; + } + else { + impulse1 = 0.0; + } + impulse.x = impulse1; + impulse.y = 0.0; + } + var PX = impulse.x * this.m_perp.x + impulse.y * this.m_axis.x; + var PY = impulse.x * this.m_perp.y + impulse.y * this.m_axis.y; + var L1 = impulse.x * this.m_s1 + impulse.y * this.m_a1; + var L2 = impulse.x * this.m_s2 + impulse.y * this.m_a2; + c1.x -= this.m_invMassA * PX; + c1.y -= this.m_invMassA * PY; + a1 -= this.m_invIA * L1; + c2.x += this.m_invMassB * PX; + c2.y += this.m_invMassB * PY; + a2 += this.m_invIB * L2; + bA.m_sweep.a = a1; + bB.m_sweep.a = a2; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2LineJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2LineJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2LineJointDef.b2LineJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + this.localAxisA = new b2Vec2(); + }; + b2LineJointDef.prototype.b2LineJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_lineJoint; + this.localAxisA.Set(1.0, 0.0); + this.enableLimit = false; + this.lowerTranslation = 0.0; + this.upperTranslation = 0.0; + this.enableMotor = false; + this.maxMotorForce = 0.0; + this.motorSpeed = 0.0; + } + b2LineJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.localAxisA = this.bodyA.GetLocalVector(axis); + } + Box2D.inherit(b2MouseJoint, Box2D.Dynamics.Joints.b2Joint); + b2MouseJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2MouseJoint.b2MouseJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.K = new b2Mat22(); + this.K1 = new b2Mat22(); + this.K2 = new b2Mat22(); + this.m_localAnchor = new b2Vec2(); + this.m_target = new b2Vec2(); + this.m_impulse = new b2Vec2(); + this.m_mass = new b2Mat22(); + this.m_C = new b2Vec2(); + }; + b2MouseJoint.prototype.GetAnchorA = function () { + return this.m_target; + } + b2MouseJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor); + } + b2MouseJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2MouseJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2MouseJoint.prototype.GetTarget = function () { + return this.m_target; + } + b2MouseJoint.prototype.SetTarget = function (target) { + if (this.m_bodyB.IsAwake() == false) { + this.m_bodyB.SetAwake(true); + } + this.m_target = target; + } + b2MouseJoint.prototype.GetMaxForce = function () { + return this.m_maxForce; + } + b2MouseJoint.prototype.SetMaxForce = function (maxForce) { + if (maxForce === undefined) maxForce = 0; + this.m_maxForce = maxForce; + } + b2MouseJoint.prototype.GetFrequency = function () { + return this.m_frequencyHz; + } + b2MouseJoint.prototype.SetFrequency = function (hz) { + if (hz === undefined) hz = 0; + this.m_frequencyHz = hz; + } + b2MouseJoint.prototype.GetDampingRatio = function () { + return this.m_dampingRatio; + } + b2MouseJoint.prototype.SetDampingRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_dampingRatio = ratio; + } + b2MouseJoint.prototype.b2MouseJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_target.SetV(def.target); + var tX = this.m_target.x - this.m_bodyB.m_xf.position.x; + var tY = this.m_target.y - this.m_bodyB.m_xf.position.y; + var tMat = this.m_bodyB.m_xf.R; + this.m_localAnchor.x = (tX * tMat.col1.x + tY * tMat.col1.y); + this.m_localAnchor.y = (tX * tMat.col2.x + tY * tMat.col2.y); + this.m_maxForce = def.maxForce; + this.m_impulse.SetZero(); + this.m_frequencyHz = def.frequencyHz; + this.m_dampingRatio = def.dampingRatio; + this.m_beta = 0.0; + this.m_gamma = 0.0; + } + b2MouseJoint.prototype.InitVelocityConstraints = function (step) { + var b = this.m_bodyB; + var mass = b.GetMass(); + var omega = 2.0 * Math.PI * this.m_frequencyHz; + var d = 2.0 * mass * this.m_dampingRatio * omega; + var k = mass * omega * omega; + this.m_gamma = step.dt * (d + step.dt * k); + this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0.0; + this.m_beta = step.dt * k * this.m_gamma; + var tMat;tMat = b.m_xf.R; + var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; + var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; + var tX = (tMat.col1.x * rX + tMat.col2.x * rY);rY = (tMat.col1.y * rX + tMat.col2.y * rY); + rX = tX; + var invMass = b.m_invMass; + var invI = b.m_invI;this.K1.col1.x = invMass; + this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; + this.K1.col2.y = invMass; + this.K2.col1.x = invI * rY * rY; + this.K2.col2.x = (-invI * rX * rY); + this.K2.col1.y = (-invI * rX * rY); + this.K2.col2.y = invI * rX * rX; + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.col1.x += this.m_gamma; + this.K.col2.y += this.m_gamma; + this.K.GetInverse(this.m_mass); + this.m_C.x = b.m_sweep.c.x + rX - this.m_target.x; + this.m_C.y = b.m_sweep.c.y + rY - this.m_target.y; + b.m_angularVelocity *= 0.98; + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + b.m_linearVelocity.x += invMass * this.m_impulse.x; + b.m_linearVelocity.y += invMass * this.m_impulse.y; + b.m_angularVelocity += invI * (rX * this.m_impulse.y - rY * this.m_impulse.x); + } + b2MouseJoint.prototype.SolveVelocityConstraints = function (step) { + var b = this.m_bodyB; + var tMat; + var tX = 0; + var tY = 0; + tMat = b.m_xf.R; + var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; + var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; + tX = (tMat.col1.x * rX + tMat.col2.x * rY); + rY = (tMat.col1.y * rX + tMat.col2.y * rY); + rX = tX; + var CdotX = b.m_linearVelocity.x + ((-b.m_angularVelocity * rY)); + var CdotY = b.m_linearVelocity.y + (b.m_angularVelocity * rX); + tMat = this.m_mass; + tX = CdotX + this.m_beta * this.m_C.x + this.m_gamma * this.m_impulse.x; + tY = CdotY + this.m_beta * this.m_C.y + this.m_gamma * this.m_impulse.y; + var impulseX = (-(tMat.col1.x * tX + tMat.col2.x * tY)); + var impulseY = (-(tMat.col1.y * tX + tMat.col2.y * tY)); + var oldImpulseX = this.m_impulse.x; + var oldImpulseY = this.m_impulse.y; + this.m_impulse.x += impulseX; + this.m_impulse.y += impulseY; + var maxImpulse = step.dt * this.m_maxForce; + if (this.m_impulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_impulse.Multiply(maxImpulse / this.m_impulse.Length()); + } + impulseX = this.m_impulse.x - oldImpulseX; + impulseY = this.m_impulse.y - oldImpulseY; + b.m_linearVelocity.x += b.m_invMass * impulseX; + b.m_linearVelocity.y += b.m_invMass * impulseY; + b.m_angularVelocity += b.m_invI * (rX * impulseY - rY * impulseX); + } + b2MouseJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return true; + } + Box2D.inherit(b2MouseJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2MouseJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2MouseJointDef.b2MouseJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.target = new b2Vec2(); + }; + b2MouseJointDef.prototype.b2MouseJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_mouseJoint; + this.maxForce = 0.0; + this.frequencyHz = 5.0; + this.dampingRatio = 0.7; + } + Box2D.inherit(b2PrismaticJoint, Box2D.Dynamics.Joints.b2Joint); + b2PrismaticJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2PrismaticJoint.b2PrismaticJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_localXAxis1 = new b2Vec2(); + this.m_localYAxis1 = new b2Vec2(); + this.m_axis = new b2Vec2(); + this.m_perp = new b2Vec2(); + this.m_K = new b2Mat33(); + this.m_impulse = new b2Vec3(); + }; + b2PrismaticJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2PrismaticJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2PrismaticJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y)); + } + b2PrismaticJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.y; + } + b2PrismaticJoint.prototype.GetJointTranslation = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var p1 = bA.GetWorldPoint(this.m_localAnchor1); + var p2 = bB.GetWorldPoint(this.m_localAnchor2); + var dX = p2.x - p1.x; + var dY = p2.y - p1.y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var translation = axis.x * dX + axis.y * dY; + return translation; + } + b2PrismaticJoint.prototype.GetJointSpeed = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var v1 = bA.m_linearVelocity; + var v2 = bB.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var w2 = bB.m_angularVelocity; + var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + return speed; + } + b2PrismaticJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2PrismaticJoint.prototype.EnableLimit = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + } + b2PrismaticJoint.prototype.GetLowerLimit = function () { + return this.m_lowerTranslation; + } + b2PrismaticJoint.prototype.GetUpperLimit = function () { + return this.m_upperTranslation; + } + b2PrismaticJoint.prototype.SetLimits = function (lower, upper) { + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_lowerTranslation = lower; + this.m_upperTranslation = upper; + } + b2PrismaticJoint.prototype.IsMotorEnabled = function () { + return this.m_enableMotor; + } + b2PrismaticJoint.prototype.EnableMotor = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + b2PrismaticJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2PrismaticJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2PrismaticJoint.prototype.SetMaxMotorForce = function (force) { + if (force === undefined) force = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorForce = force; + } + b2PrismaticJoint.prototype.GetMotorForce = function () { + return this.m_motorImpulse; + } + b2PrismaticJoint.prototype.b2PrismaticJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_localXAxis1.SetV(def.localAxisA); + this.m_localYAxis1.x = (-this.m_localXAxis1.y); + this.m_localYAxis1.y = this.m_localXAxis1.x; + this.m_refAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_motorMass = 0.0; + this.m_motorImpulse = 0.0; + this.m_lowerTranslation = def.lowerTranslation; + this.m_upperTranslation = def.upperTranslation; + this.m_maxMotorForce = def.maxMotorForce; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_axis.SetZero(); + this.m_perp.SetZero(); + } + b2PrismaticJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + this.m_localCenterA.SetV(bA.GetLocalCenter()); + this.m_localCenterB.SetV(bB.GetLocalCenter()); + var xf1 = bA.GetTransform(); + var xf2 = bB.GetTransform(); + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + this.m_invMassA = bA.m_invMass; + this.m_invMassB = bB.m_invMass; + this.m_invIA = bA.m_invI; + this.m_invIB = bB.m_invI; { + this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; + if (this.m_motorMass > Number.MIN_VALUE) this.m_motorMass = 1.0 / this.m_motorMass; + } { + this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var m1 = this.m_invMassA; + var m2 = this.m_invMassB; + var i1 = this.m_invIA; + var i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; + this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = i1 + i2; + this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; + this.m_K.col3.x = this.m_K.col1.z; + this.m_K.col3.y = this.m_K.col2.z; + this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + } + if (this.m_enableLimit) { + var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointTransition <= this.m_lowerTranslation) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_limitState = b2Joint.e_atLowerLimit; + this.m_impulse.z = 0.0; + } + } + else if (jointTransition >= this.m_upperTranslation) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_limitState = b2Joint.e_atUpperLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x; + var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y; + var L1 = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1; + var L2 = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2; + bA.m_linearVelocity.x -= this.m_invMassA * PX; + bA.m_linearVelocity.y -= this.m_invMassA * PY; + bA.m_angularVelocity -= this.m_invIA * L1; + bB.m_linearVelocity.x += this.m_invMassB * PX; + bB.m_linearVelocity.y += this.m_invMassB * PY; + bB.m_angularVelocity += this.m_invIB * L2; + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2PrismaticJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var PX = 0; + var PY = 0; + var L1 = 0; + var L2 = 0; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorForce; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + PX = impulse * this.m_axis.x; + PY = impulse * this.m_axis.y; + L1 = impulse * this.m_a1; + L2 = impulse * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + var Cdot1X = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; + var Cdot1Y = w2 - w1; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var f1 = this.m_impulse.Copy(); + var df = this.m_K.Solve33(new b2Vec3(), (-Cdot1X), (-Cdot1Y), (-Cdot2)); + this.m_impulse.Add(df); + if (this.m_limitState == b2Joint.e_atLowerLimit) { + this.m_impulse.z = b2Math.Max(this.m_impulse.z, 0.0); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + this.m_impulse.z = b2Math.Min(this.m_impulse.z, 0.0); + } + var bX = (-Cdot1X) - (this.m_impulse.z - f1.z) * this.m_K.col3.x; + var bY = (-Cdot1Y) - (this.m_impulse.z - f1.z) * this.m_K.col3.y; + var f2r = this.m_K.Solve22(new b2Vec2(), bX, bY); + f2r.x += f1.x; + f2r.y += f1.y; + this.m_impulse.x = f2r.x; + this.m_impulse.y = f2r.y; + df.x = this.m_impulse.x - f1.x; + df.y = this.m_impulse.y - f1.y; + df.z = this.m_impulse.z - f1.z; + PX = df.x * this.m_perp.x + df.z * this.m_axis.x; + PY = df.x * this.m_perp.y + df.z * this.m_axis.y; + L1 = df.x * this.m_s1 + df.y + df.z * this.m_a1; + L2 = df.x * this.m_s2 + df.y + df.z * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + else { + var df2 = this.m_K.Solve22(new b2Vec2(), (-Cdot1X), (-Cdot1Y)); + this.m_impulse.x += df2.x; + this.m_impulse.y += df2.y; + PX = df2.x * this.m_perp.x; + PY = df2.x * this.m_perp.y; + L1 = df2.x * this.m_s1 + df2.y; + L2 = df2.x * this.m_s2 + df2.y; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2PrismaticJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var limitC = 0; + var oldLimitImpulse = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var c1 = bA.m_sweep.c; + var a1 = bA.m_sweep.a; + var c2 = bB.m_sweep.c; + var a2 = bB.m_sweep.a; + var tMat; + var tX = 0; + var m1 = 0; + var m2 = 0; + var i1 = 0; + var i2 = 0; + var linearError = 0.0; + var angularError = 0.0; + var active = false; + var C2 = 0.0; + var R1 = b2Mat22.FromAngle(a1); + var R2 = b2Mat22.FromAngle(a2); + tMat = R1; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = R2; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = c2.x + r2X - c1.x - r1X; + var dY = c2.y + r2Y - c1.y - r1Y; + if (this.m_enableLimit) { + this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + var translation = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + linearError = b2Math.Abs(translation); + active = true; + } + else if (translation <= this.m_lowerTranslation) { + C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + linearError = this.m_lowerTranslation - translation; + active = true; + } + else if (translation >= this.m_upperTranslation) { + C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); + linearError = translation - this.m_upperTranslation; + active = true; + } + } + this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var impulse = new b2Vec3(); + var C1X = this.m_perp.x * dX + this.m_perp.y * dY; + var C1Y = a2 - a1 - this.m_refAngle; + linearError = b2Math.Max(linearError, b2Math.Abs(C1X)); + angularError = b2Math.Abs(C1Y); + if (active) { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; + this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = i1 + i2; + this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; + this.m_K.col3.x = this.m_K.col1.z; + this.m_K.col3.y = this.m_K.col2.z; + this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + this.m_K.Solve33(impulse, (-C1X), (-C1Y), (-C2)); + } + else { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + var k12 = i1 * this.m_s1 + i2 * this.m_s2; + var k22 = i1 + i2; + this.m_K.col1.Set(k11, k12, 0.0); + this.m_K.col2.Set(k12, k22, 0.0); + var impulse1 = this.m_K.Solve22(new b2Vec2(), (-C1X), (-C1Y)); + impulse.x = impulse1.x; + impulse.y = impulse1.y; + impulse.z = 0.0; + } + var PX = impulse.x * this.m_perp.x + impulse.z * this.m_axis.x; + var PY = impulse.x * this.m_perp.y + impulse.z * this.m_axis.y; + var L1 = impulse.x * this.m_s1 + impulse.y + impulse.z * this.m_a1; + var L2 = impulse.x * this.m_s2 + impulse.y + impulse.z * this.m_a2; + c1.x -= this.m_invMassA * PX; + c1.y -= this.m_invMassA * PY; + a1 -= this.m_invIA * L1; + c2.x += this.m_invMassB * PX; + c2.y += this.m_invMassB * PY; + a2 += this.m_invIB * L2; + bA.m_sweep.a = a1; + bB.m_sweep.a = a2; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2PrismaticJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2PrismaticJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2PrismaticJointDef.b2PrismaticJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + this.localAxisA = new b2Vec2(); + }; + b2PrismaticJointDef.prototype.b2PrismaticJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_prismaticJoint; + this.localAxisA.Set(1.0, 0.0); + this.referenceAngle = 0.0; + this.enableLimit = false; + this.lowerTranslation = 0.0; + this.upperTranslation = 0.0; + this.enableMotor = false; + this.maxMotorForce = 0.0; + this.motorSpeed = 0.0; + } + b2PrismaticJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.localAxisA = this.bodyA.GetLocalVector(axis); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + Box2D.inherit(b2PulleyJoint, Box2D.Dynamics.Joints.b2Joint); + b2PulleyJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2PulleyJoint.b2PulleyJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_groundAnchor1 = new b2Vec2(); + this.m_groundAnchor2 = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_u1 = new b2Vec2(); + this.m_u2 = new b2Vec2(); + }; + b2PulleyJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2PulleyJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2PulleyJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_u2.x, inv_dt * this.m_impulse * this.m_u2.y); + } + b2PulleyJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2PulleyJoint.prototype.GetGroundAnchorA = function () { + var a = this.m_ground.m_xf.position.Copy(); + a.Add(this.m_groundAnchor1); + return a; + } + b2PulleyJoint.prototype.GetGroundAnchorB = function () { + var a = this.m_ground.m_xf.position.Copy(); + a.Add(this.m_groundAnchor2); + return a; + } + b2PulleyJoint.prototype.GetLength1 = function () { + var p = this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var dX = p.x - sX; + var dY = p.y - sY; + return Math.sqrt(dX * dX + dY * dY); + } + b2PulleyJoint.prototype.GetLength2 = function () { + var p = this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + var dX = p.x - sX; + var dY = p.y - sY; + return Math.sqrt(dX * dX + dY * dY); + } + b2PulleyJoint.prototype.GetRatio = function () { + return this.m_ratio; + } + b2PulleyJoint.prototype.b2PulleyJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_ground = this.m_bodyA.m_world.m_groundBody; + this.m_groundAnchor1.x = def.groundAnchorA.x - this.m_ground.m_xf.position.x; + this.m_groundAnchor1.y = def.groundAnchorA.y - this.m_ground.m_xf.position.y; + this.m_groundAnchor2.x = def.groundAnchorB.x - this.m_ground.m_xf.position.x; + this.m_groundAnchor2.y = def.groundAnchorB.y - this.m_ground.m_xf.position.y; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_ratio = def.ratio; + this.m_constant = def.lengthA + this.m_ratio * def.lengthB; + this.m_maxLength1 = b2Math.Min(def.maxLengthA, this.m_constant - this.m_ratio * b2PulleyJoint.b2_minPulleyLength); + this.m_maxLength2 = b2Math.Min(def.maxLengthB, (this.m_constant - b2PulleyJoint.b2_minPulleyLength) / this.m_ratio); + this.m_impulse = 0.0; + this.m_limitImpulse1 = 0.0; + this.m_limitImpulse2 = 0.0; + } + b2PulleyJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + var length1 = this.m_u1.Length(); + var length2 = this.m_u2.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.Multiply(1.0 / length1); + } + else { + this.m_u1.SetZero(); + } + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.Multiply(1.0 / length2); + } + else { + this.m_u2.SetZero(); + } + var C = this.m_constant - length1 - this.m_ratio * length2; + if (C > 0.0) { + this.m_state = b2Joint.e_inactiveLimit; + this.m_impulse = 0.0; + } + else { + this.m_state = b2Joint.e_atUpperLimit; + } + if (length1 < this.m_maxLength1) { + this.m_limitState1 = b2Joint.e_inactiveLimit; + this.m_limitImpulse1 = 0.0; + } + else { + this.m_limitState1 = b2Joint.e_atUpperLimit; + } + if (length2 < this.m_maxLength2) { + this.m_limitState2 = b2Joint.e_inactiveLimit; + this.m_limitImpulse2 = 0.0; + } + else { + this.m_limitState2 = b2Joint.e_atUpperLimit; + } + var cr1u1 = r1X * this.m_u1.y - r1Y * this.m_u1.x; + var cr2u2 = r2X * this.m_u2.y - r2Y * this.m_u2.x; + this.m_limitMass1 = bA.m_invMass + bA.m_invI * cr1u1 * cr1u1; + this.m_limitMass2 = bB.m_invMass + bB.m_invI * cr2u2 * cr2u2; + this.m_pulleyMass = this.m_limitMass1 + this.m_ratio * this.m_ratio * this.m_limitMass2; + this.m_limitMass1 = 1.0 / this.m_limitMass1; + this.m_limitMass2 = 1.0 / this.m_limitMass2; + this.m_pulleyMass = 1.0 / this.m_pulleyMass; + if (step.warmStarting) { + this.m_impulse *= step.dtRatio; + this.m_limitImpulse1 *= step.dtRatio; + this.m_limitImpulse2 *= step.dtRatio; + var P1X = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.x; + var P1Y = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.y; + var P2X = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.x; + var P2Y = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.y; + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + else { + this.m_impulse = 0.0; + this.m_limitImpulse1 = 0.0; + this.m_limitImpulse2 = 0.0; + } + } + b2PulleyJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var v1X = 0; + var v1Y = 0; + var v2X = 0; + var v2Y = 0; + var P1X = 0; + var P1Y = 0; + var P2X = 0; + var P2Y = 0; + var Cdot = 0; + var impulse = 0; + var oldImpulse = 0; + if (this.m_state == b2Joint.e_atUpperLimit) { + v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)) - this.m_ratio * (this.m_u2.x * v2X + this.m_u2.y * v2Y); + impulse = this.m_pulleyMass * ((-Cdot)); + oldImpulse = this.m_impulse; + this.m_impulse = b2Math.Max(0.0, this.m_impulse + impulse); + impulse = this.m_impulse - oldImpulse; + P1X = (-impulse * this.m_u1.x); + P1Y = (-impulse * this.m_u1.y); + P2X = (-this.m_ratio * impulse * this.m_u2.x); + P2Y = (-this.m_ratio * impulse * this.m_u2.y); + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + if (this.m_limitState1 == b2Joint.e_atUpperLimit) { + v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)); + impulse = (-this.m_limitMass1 * Cdot); + oldImpulse = this.m_limitImpulse1; + this.m_limitImpulse1 = b2Math.Max(0.0, this.m_limitImpulse1 + impulse); + impulse = this.m_limitImpulse1 - oldImpulse; + P1X = (-impulse * this.m_u1.x); + P1Y = (-impulse * this.m_u1.y); + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + } + if (this.m_limitState2 == b2Joint.e_atUpperLimit) { + v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + Cdot = (-(this.m_u2.x * v2X + this.m_u2.y * v2Y)); + impulse = (-this.m_limitMass2 * Cdot); + oldImpulse = this.m_limitImpulse2; + this.m_limitImpulse2 = b2Math.Max(0.0, this.m_limitImpulse2 + impulse); + impulse = this.m_limitImpulse2 - oldImpulse; + P2X = (-impulse * this.m_u2.x); + P2Y = (-impulse * this.m_u2.y); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + } + b2PulleyJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + var r1X = 0; + var r1Y = 0; + var r2X = 0; + var r2Y = 0; + var p1X = 0; + var p1Y = 0; + var p2X = 0; + var p2Y = 0; + var length1 = 0; + var length2 = 0; + var C = 0; + var impulse = 0; + var oldImpulse = 0; + var oldLimitPositionImpulse = 0; + var tX = 0; + var linearError = 0.0; + if (this.m_state == b2Joint.e_atUpperLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + p1X = bA.m_sweep.c.x + r1X; + p1Y = bA.m_sweep.c.y + r1Y; + p2X = bB.m_sweep.c.x + r2X; + p2Y = bB.m_sweep.c.y + r2Y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + length1 = this.m_u1.Length(); + length2 = this.m_u2.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.Multiply(1.0 / length1); + } + else { + this.m_u1.SetZero(); + } + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.Multiply(1.0 / length2); + } + else { + this.m_u2.SetZero(); + } + C = this.m_constant - length1 - this.m_ratio * length2; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_pulleyMass * C); + p1X = (-impulse * this.m_u1.x); + p1Y = (-impulse * this.m_u1.y); + p2X = (-this.m_ratio * impulse * this.m_u2.x); + p2Y = (-this.m_ratio * impulse * this.m_u2.y); + bA.m_sweep.c.x += bA.m_invMass * p1X; + bA.m_sweep.c.y += bA.m_invMass * p1Y; + bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); + bB.m_sweep.c.x += bB.m_invMass * p2X; + bB.m_sweep.c.y += bB.m_invMass * p2Y; + bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } + if (this.m_limitState1 == b2Joint.e_atUpperLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + p1X = bA.m_sweep.c.x + r1X; + p1Y = bA.m_sweep.c.y + r1Y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + length1 = this.m_u1.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.x *= 1.0 / length1; + this.m_u1.y *= 1.0 / length1; + } + else { + this.m_u1.SetZero(); + } + C = this.m_maxLength1 - length1; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_limitMass1 * C); + p1X = (-impulse * this.m_u1.x); + p1Y = (-impulse * this.m_u1.y); + bA.m_sweep.c.x += bA.m_invMass * p1X; + bA.m_sweep.c.y += bA.m_invMass * p1Y; + bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); + bA.SynchronizeTransform(); + } + if (this.m_limitState2 == b2Joint.e_atUpperLimit) { + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + p2X = bB.m_sweep.c.x + r2X; + p2Y = bB.m_sweep.c.y + r2Y; + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + length2 = this.m_u2.Length(); + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.x *= 1.0 / length2; + this.m_u2.y *= 1.0 / length2; + } + else { + this.m_u2.SetZero(); + } + C = this.m_maxLength2 - length2; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_limitMass2 * C); + p2X = (-impulse * this.m_u2.x); + p2Y = (-impulse * this.m_u2.y); + bB.m_sweep.c.x += bB.m_invMass * p2X; + bB.m_sweep.c.y += bB.m_invMass * p2Y; + bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); + bB.SynchronizeTransform(); + } + return linearError < b2Settings.b2_linearSlop; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength = 2.0; + }); + Box2D.inherit(b2PulleyJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2PulleyJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2PulleyJointDef.b2PulleyJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.groundAnchorA = new b2Vec2(); + this.groundAnchorB = new b2Vec2(); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2PulleyJointDef.prototype.b2PulleyJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_pulleyJoint; + this.groundAnchorA.Set((-1.0), 1.0); + this.groundAnchorB.Set(1.0, 1.0); + this.localAnchorA.Set((-1.0), 0.0); + this.localAnchorB.Set(1.0, 0.0); + this.lengthA = 0.0; + this.maxLengthA = 0.0; + this.lengthB = 0.0; + this.maxLengthB = 0.0; + this.ratio = 1.0; + this.collideConnected = true; + } + b2PulleyJointDef.prototype.Initialize = function (bA, bB, gaA, gaB, anchorA, anchorB, r) { + if (r === undefined) r = 0; + this.bodyA = bA; + this.bodyB = bB; + this.groundAnchorA.SetV(gaA); + this.groundAnchorB.SetV(gaB); + this.localAnchorA = this.bodyA.GetLocalPoint(anchorA); + this.localAnchorB = this.bodyB.GetLocalPoint(anchorB); + var d1X = anchorA.x - gaA.x; + var d1Y = anchorA.y - gaA.y; + this.lengthA = Math.sqrt(d1X * d1X + d1Y * d1Y); + var d2X = anchorB.x - gaB.x; + var d2Y = anchorB.y - gaB.y; + this.lengthB = Math.sqrt(d2X * d2X + d2Y * d2Y); + this.ratio = r; + var C = this.lengthA + this.ratio * this.lengthB; + this.maxLengthA = C - this.ratio * b2PulleyJoint.b2_minPulleyLength; + this.maxLengthB = (C - b2PulleyJoint.b2_minPulleyLength) / this.ratio; + } + Box2D.inherit(b2RevoluteJoint, Box2D.Dynamics.Joints.b2Joint); + b2RevoluteJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2RevoluteJoint.b2RevoluteJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.K = new b2Mat22(); + this.K1 = new b2Mat22(); + this.K2 = new b2Mat22(); + this.K3 = new b2Mat22(); + this.impulse3 = new b2Vec3(); + this.impulse2 = new b2Vec2(); + this.reduced = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_impulse = new b2Vec3(); + this.m_mass = new b2Mat33(); + }; + b2RevoluteJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2RevoluteJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2RevoluteJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2RevoluteJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.z; + } + b2RevoluteJoint.prototype.GetJointAngle = function () { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle; + } + b2RevoluteJoint.prototype.GetJointSpeed = function () { + return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity; + } + b2RevoluteJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2RevoluteJoint.prototype.EnableLimit = function (flag) { + this.m_enableLimit = flag; + } + b2RevoluteJoint.prototype.GetLowerLimit = function () { + return this.m_lowerAngle; + } + b2RevoluteJoint.prototype.GetUpperLimit = function () { + return this.m_upperAngle; + } + b2RevoluteJoint.prototype.SetLimits = function (lower, upper) { + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_lowerAngle = lower; + this.m_upperAngle = upper; + } + b2RevoluteJoint.prototype.IsMotorEnabled = function () { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + return this.m_enableMotor; + } + b2RevoluteJoint.prototype.EnableMotor = function (flag) { + this.m_enableMotor = flag; + } + b2RevoluteJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2RevoluteJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2RevoluteJoint.prototype.SetMaxMotorTorque = function (torque) { + if (torque === undefined) torque = 0; + this.m_maxMotorTorque = torque; + } + b2RevoluteJoint.prototype.GetMotorTorque = function () { + return this.m_maxMotorTorque; + } + b2RevoluteJoint.prototype.b2RevoluteJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_referenceAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + this.m_lowerAngle = def.lowerAngle; + this.m_upperAngle = def.upperAngle; + this.m_maxMotorTorque = def.maxMotorTorque; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + } + b2RevoluteJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + if (this.m_enableMotor || this.m_enableLimit) {} + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var m1 = bA.m_invMass; + var m2 = bB.m_invMass; + var i1 = bA.m_invI; + var i2 = bB.m_invI; + this.m_mass.col1.x = m1 + m2 + r1Y * r1Y * i1 + r2Y * r2Y * i2; + this.m_mass.col2.x = (-r1Y * r1X * i1) - r2Y * r2X * i2; + this.m_mass.col3.x = (-r1Y * i1) - r2Y * i2; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = m1 + m2 + r1X * r1X * i1 + r2X * r2X * i2; + this.m_mass.col3.y = r1X * i1 + r2X * i2; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = i1 + i2; + this.m_motorMass = 1.0 / (i1 + i2); + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (this.m_enableLimit) { + var jointAngle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + if (b2Math.Abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * b2Settings.b2_angularSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointAngle <= this.m_lowerAngle) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_impulse.z = 0.0; + } + this.m_limitState = b2Joint.e_atLowerLimit; + } + else if (jointAngle >= this.m_upperAngle) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_impulse.z = 0.0; + } + this.m_limitState = b2Joint.e_atUpperLimit; + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x; + var PY = this.m_impulse.y; + bA.m_linearVelocity.x -= m1 * PX; + bA.m_linearVelocity.y -= m1 * PY; + bA.m_angularVelocity -= i1 * ((r1X * PY - r1Y * PX) + this.m_motorImpulse + this.m_impulse.z); + bB.m_linearVelocity.x += m2 * PX; + bB.m_linearVelocity.y += m2 * PY; + bB.m_angularVelocity += i2 * ((r2X * PY - r2Y * PX) + this.m_motorImpulse + this.m_impulse.z); + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2RevoluteJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + var newImpulse = 0; + var r1X = 0; + var r1Y = 0; + var r2X = 0; + var r2Y = 0; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var m1 = bA.m_invMass; + var m2 = bB.m_invMass; + var i1 = bA.m_invI; + var i2 = bB.m_invI; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = w2 - w1 - this.m_motorSpeed; + var impulse = this.m_motorMass * ((-Cdot)); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + w1 -= i1 * impulse; + w2 += i2 * impulse; + } + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var Cdot1X = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); + var Cdot1Y = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); + var Cdot2 = w2 - w1; + this.m_mass.Solve33(this.impulse3, (-Cdot1X), (-Cdot1Y), (-Cdot2)); + if (this.m_limitState == b2Joint.e_equalLimits) { + this.m_impulse.Add(this.impulse3); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) { + newImpulse = this.m_impulse.z + this.impulse3.z; + if (newImpulse < 0.0) { + this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); + this.impulse3.x = this.reduced.x; + this.impulse3.y = this.reduced.y; + this.impulse3.z = (-this.m_impulse.z); + this.m_impulse.x += this.reduced.x; + this.m_impulse.y += this.reduced.y; + this.m_impulse.z = 0.0; + } + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + newImpulse = this.m_impulse.z + this.impulse3.z; + if (newImpulse > 0.0) { + this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); + this.impulse3.x = this.reduced.x; + this.impulse3.y = this.reduced.y; + this.impulse3.z = (-this.m_impulse.z); + this.m_impulse.x += this.reduced.x; + this.m_impulse.y += this.reduced.y; + this.m_impulse.z = 0.0; + } + } + v1.x -= m1 * this.impulse3.x; + v1.y -= m1 * this.impulse3.y; + w1 -= i1 * (r1X * this.impulse3.y - r1Y * this.impulse3.x + this.impulse3.z); + v2.x += m2 * this.impulse3.x; + v2.y += m2 * this.impulse3.y; + w2 += i2 * (r2X * this.impulse3.y - r2Y * this.impulse3.x + this.impulse3.z); + } + else { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var CdotX = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); + var CdotY = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); + this.m_mass.Solve22(this.impulse2, (-CdotX), (-CdotY)); + this.m_impulse.x += this.impulse2.x; + this.m_impulse.y += this.impulse2.y; + v1.x -= m1 * this.impulse2.x; + v1.y -= m1 * this.impulse2.y; + w1 -= i1 * (r1X * this.impulse2.y - r1Y * this.impulse2.x); + v2.x += m2 * this.impulse2.x; + v2.y += m2 * this.impulse2.y; + w2 += i2 * (r2X * this.impulse2.y - r2Y * this.impulse2.x); + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2RevoluteJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var oldLimitImpulse = 0; + var C = 0; + var tMat; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var angularError = 0.0; + var positionError = 0.0; + var tX = 0; + var impulseX = 0; + var impulseY = 0; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var angle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + var limitImpulse = 0.0; + if (this.m_limitState == b2Joint.e_equalLimits) { + C = b2Math.Clamp(angle - this.m_lowerAngle, (-b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection); + limitImpulse = (-this.m_motorMass * C); + angularError = b2Math.Abs(C); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) { + C = angle - this.m_lowerAngle; + angularError = (-C); + C = b2Math.Clamp(C + b2Settings.b2_angularSlop, (-b2Settings.b2_maxAngularCorrection), 0.0); + limitImpulse = (-this.m_motorMass * C); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + C = angle - this.m_upperAngle; + angularError = C; + C = b2Math.Clamp(C - b2Settings.b2_angularSlop, 0.0, b2Settings.b2_maxAngularCorrection); + limitImpulse = (-this.m_motorMass * C); + } + bA.m_sweep.a -= bA.m_invI * limitImpulse; + bB.m_sweep.a += bB.m_invI * limitImpulse; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } { + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var CLengthSquared = CX * CX + CY * CY; + var CLength = Math.sqrt(CLengthSquared); + positionError = CLength; + var invMass1 = bA.m_invMass; + var invMass2 = bB.m_invMass; + var invI1 = bA.m_invI; + var invI2 = bB.m_invI; + var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; + if (CLengthSquared > k_allowedStretch * k_allowedStretch) { + var uX = CX / CLength; + var uY = CY / CLength; + var k = invMass1 + invMass2; + var m = 1.0 / k; + impulseX = m * ((-CX)); + impulseY = m * ((-CY)); + var k_beta = 0.5; + bA.m_sweep.c.x -= k_beta * invMass1 * impulseX; + bA.m_sweep.c.y -= k_beta * invMass1 * impulseY; + bB.m_sweep.c.x += k_beta * invMass2 * impulseX; + bB.m_sweep.c.y += k_beta * invMass2 * impulseY; + CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + } + this.K1.col1.x = invMass1 + invMass2; + this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; + this.K1.col2.y = invMass1 + invMass2; + this.K2.col1.x = invI1 * r1Y * r1Y; + this.K2.col2.x = (-invI1 * r1X * r1Y); + this.K2.col1.y = (-invI1 * r1X * r1Y); + this.K2.col2.y = invI1 * r1X * r1X; + this.K3.col1.x = invI2 * r2Y * r2Y; + this.K3.col2.x = (-invI2 * r2X * r2Y); + this.K3.col1.y = (-invI2 * r2X * r2Y); + this.K3.col2.y = invI2 * r2X * r2X; + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.AddM(this.K3); + this.K.Solve(b2RevoluteJoint.tImpulse, (-CX), (-CY)); + impulseX = b2RevoluteJoint.tImpulse.x; + impulseY = b2RevoluteJoint.tImpulse.y; + bA.m_sweep.c.x -= bA.m_invMass * impulseX; + bA.m_sweep.c.y -= bA.m_invMass * impulseY; + bA.m_sweep.a -= bA.m_invI * (r1X * impulseY - r1Y * impulseX); + bB.m_sweep.c.x += bB.m_invMass * impulseX; + bB.m_sweep.c.y += bB.m_invMass * impulseY; + bB.m_sweep.a += bB.m_invI * (r2X * impulseY - r2Y * impulseX); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse = new b2Vec2(); + }); + Box2D.inherit(b2RevoluteJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2RevoluteJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2RevoluteJointDef.b2RevoluteJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2RevoluteJointDef.prototype.b2RevoluteJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_revoluteJoint; + this.localAnchorA.Set(0.0, 0.0); + this.localAnchorB.Set(0.0, 0.0); + this.referenceAngle = 0.0; + this.lowerAngle = 0.0; + this.upperAngle = 0.0; + this.maxMotorTorque = 0.0; + this.motorSpeed = 0.0; + this.enableLimit = false; + this.enableMotor = false; + } + b2RevoluteJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + Box2D.inherit(b2WeldJoint, Box2D.Dynamics.Joints.b2Joint); + b2WeldJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2WeldJoint.b2WeldJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchorA = new b2Vec2(); + this.m_localAnchorB = new b2Vec2(); + this.m_impulse = new b2Vec3(); + this.m_mass = new b2Mat33(); + }; + b2WeldJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); + } + b2WeldJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); + } + b2WeldJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2WeldJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.z; + } + b2WeldJoint.prototype.b2WeldJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchorA.SetV(def.localAnchorA); + this.m_localAnchorB.SetV(def.localAnchorB); + this.m_referenceAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_mass = new b2Mat33(); + } + b2WeldJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; + this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; + this.m_mass.col3.x = (-rAY * iA) - rBY * iB; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; + this.m_mass.col3.y = rAX * iA + rBX * iB; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = iA + iB; + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_impulse.z *= step.dtRatio; + bA.m_linearVelocity.x -= mA * this.m_impulse.x; + bA.m_linearVelocity.y -= mA * this.m_impulse.y; + bA.m_angularVelocity -= iA * (rAX * this.m_impulse.y - rAY * this.m_impulse.x + this.m_impulse.z); + bB.m_linearVelocity.x += mB * this.m_impulse.x; + bB.m_linearVelocity.y += mB * this.m_impulse.y; + bB.m_angularVelocity += iB * (rBX * this.m_impulse.y - rBY * this.m_impulse.x + this.m_impulse.z); + } + else { + this.m_impulse.SetZero(); + } + } + b2WeldJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var vA = bA.m_linearVelocity; + var wA = bA.m_angularVelocity; + var vB = bB.m_linearVelocity; + var wB = bB.m_angularVelocity; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var Cdot1X = vB.x - wB * rBY - vA.x + wA * rAY; + var Cdot1Y = vB.y + wB * rBX - vA.y - wA * rAX; + var Cdot2 = wB - wA; + var impulse = new b2Vec3(); + this.m_mass.Solve33(impulse, (-Cdot1X), (-Cdot1Y), (-Cdot2)); + this.m_impulse.Add(impulse); + vA.x -= mA * impulse.x; + vA.y -= mA * impulse.y; + wA -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); + vB.x += mB * impulse.x; + vB.y += mB * impulse.y; + wB += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); + bA.m_angularVelocity = wA; + bB.m_angularVelocity = wB; + } + b2WeldJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + var C1X = bB.m_sweep.c.x + rBX - bA.m_sweep.c.x - rAX; + var C1Y = bB.m_sweep.c.y + rBY - bA.m_sweep.c.y - rAY; + var C2 = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; + var positionError = Math.sqrt(C1X * C1X + C1Y * C1Y); + var angularError = b2Math.Abs(C2); + if (positionError > k_allowedStretch) { + iA *= 1.0; + iB *= 1.0; + } + this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; + this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; + this.m_mass.col3.x = (-rAY * iA) - rBY * iB; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; + this.m_mass.col3.y = rAX * iA + rBX * iB; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = iA + iB; + var impulse = new b2Vec3(); + this.m_mass.Solve33(impulse, (-C1X), (-C1Y), (-C2)); + bA.m_sweep.c.x -= mA * impulse.x; + bA.m_sweep.c.y -= mA * impulse.y; + bA.m_sweep.a -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); + bB.m_sweep.c.x += mB * impulse.x; + bB.m_sweep.c.y += mB * impulse.y; + bB.m_sweep.a += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2WeldJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2WeldJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2WeldJointDef.b2WeldJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2WeldJointDef.prototype.b2WeldJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_weldJoint; + this.referenceAngle = 0.0; + } + b2WeldJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } +})(); +(function () { + var b2DebugDraw = Box2D.Dynamics.b2DebugDraw; + b2DebugDraw.b2DebugDraw = function () { + this.m_drawScale = 1.0; + this.m_lineThickness = 1.0; + this.m_alpha = 1.0; + this.m_fillAlpha = 1.0; + this.m_xformScale = 1.0; + var __this = this; + //#WORKAROUND + this.m_sprite = { + graphics: { + clear: function () { + __this.m_ctx.clearRect(0, 0, __this.m_ctx.canvas.width, __this.m_ctx.canvas.height) + } + } + }; + }; + b2DebugDraw.prototype._color = function (color, alpha) { + return "rgba(" + ((color & 0xFF0000) >> 16) + "," + ((color & 0xFF00) >> 8) + "," + (color & 0xFF) + "," + alpha + ")"; + }; + b2DebugDraw.prototype.b2DebugDraw = function () { + this.m_drawFlags = 0; + }; + b2DebugDraw.prototype.SetFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags = flags; + }; + b2DebugDraw.prototype.GetFlags = function () { + return this.m_drawFlags; + }; + b2DebugDraw.prototype.AppendFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags |= flags; + }; + b2DebugDraw.prototype.ClearFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags &= ~flags; + }; + b2DebugDraw.prototype.SetSprite = function (sprite) { + this.m_ctx = sprite; + }; + b2DebugDraw.prototype.GetSprite = function () { + return this.m_ctx; + }; + b2DebugDraw.prototype.SetDrawScale = function (drawScale) { + if (drawScale === undefined) drawScale = 0; + this.m_drawScale = drawScale; + }; + b2DebugDraw.prototype.GetDrawScale = function () { + return this.m_drawScale; + }; + b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { + if (lineThickness === undefined) lineThickness = 0; + this.m_lineThickness = lineThickness; + this.m_ctx.strokeWidth = lineThickness; + }; + b2DebugDraw.prototype.GetLineThickness = function () { + return this.m_lineThickness; + }; + b2DebugDraw.prototype.SetAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + this.m_alpha = alpha; + }; + b2DebugDraw.prototype.GetAlpha = function () { + return this.m_alpha; + }; + b2DebugDraw.prototype.SetFillAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + this.m_fillAlpha = alpha; + }; + b2DebugDraw.prototype.GetFillAlpha = function () { + return this.m_fillAlpha; + }; + b2DebugDraw.prototype.SetXFormScale = function (xformScale) { + if (xformScale === undefined) xformScale = 0; + this.m_xformScale = xformScale; + }; + b2DebugDraw.prototype.GetXFormScale = function () { + return this.m_xformScale; + }; + b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { + if (!vertexCount) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + for (var i = 1; i < vertexCount; i++) { + s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); + } + s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { + if (!vertexCount) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.fillStyle = this._color(color.color, this.m_fillAlpha); + s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + for (var i = 1; i < vertexCount; i++) { + s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); + } + s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + s.closePath(); + s.fill(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { + if (!radius) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.arc(center.x * drawScale, center.y * drawScale, radius * drawScale, 0, Math.PI * 2, true); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { + if (!radius) return; + var s = this.m_ctx, + drawScale = this.m_drawScale, + cx = center.x * drawScale, + cy = center.y * drawScale; + s.moveTo(0, 0); + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.fillStyle = this._color(color.color, this.m_fillAlpha); + s.arc(cx, cy, radius * drawScale, 0, Math.PI * 2, true); + s.moveTo(cx, cy); + s.lineTo((center.x + axis.x * radius) * drawScale, (center.y + axis.y * radius) * drawScale); + s.closePath(); + s.fill(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) { + var s = this.m_ctx, + drawScale = this.m_drawScale; + s.strokeStyle = this._color(color.color, this.m_alpha); + s.beginPath(); + s.moveTo(p1.x * drawScale, p1.y * drawScale); + s.lineTo(p2.x * drawScale, p2.y * drawScale); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawTransform = function (xf) { + var s = this.m_ctx, + drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(0xff0000, this.m_alpha); + s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); + s.lineTo((xf.position.x + this.m_xformScale * xf.R.col1.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col1.y) * drawScale); + + s.strokeStyle = this._color(0xff00, this.m_alpha); + s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); + s.lineTo((xf.position.x + this.m_xformScale * xf.R.col2.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col2.y) * drawScale); + s.closePath(); + s.stroke(); + }; +})(); //post-definitions +var i; +for (i = 0; i < Box2D.postDefs.length; ++i) Box2D.postDefs[i](); +delete Box2D.postDefs; \ No newline at end of file diff --git a/CAAT/src/Lib/MoMa.js b/CAAT/src/Lib/MoMa.js new file mode 100644 index 0000000..f50ca77 --- /dev/null +++ b/CAAT/src/Lib/MoMa.js @@ -0,0 +1,786 @@ +(function(global) { + + String.prototype.endsWith= function(suffix) { + return this.indexOf(suffix, this.length - suffix.length) !== -1; + }; + + Function.prototype.bind = Function.prototype.bind || function () { + var fn = this; // the function + var args = Array.prototype.slice.call(arguments); // copy the arguments. + var obj = args.shift(); // first parameter will be context 'this' + return function () { + return fn.apply( + obj, + args.concat(Array.prototype.slice.call(arguments))); + } + }; + + isArray = function (input) { + return typeof(input) == 'object' && (input instanceof Array); + }; + isString = function (input) { + return typeof(input) == 'string'; + }; + isFunction = function( input ) { + return typeof input == "function" + } + + var initializing = false; + + // The base Class implementation (does nothing) + var Class = function () { + }; + + // Create a new Class that inherits from this class + Class.extend = function (extendingProt, constants, name, aliases, flags) { + + var _super = this.prototype; + + // Instantiate a base class (but only create the instance, + // don't run the init constructor) + initializing = true; + var prototype = new this(); + initializing = false; + + // The dummy class constructor + function CAATClass() { + // All construction is actually done in the init method + if (!initializing && this.__init) { + this.__init.apply(this, arguments); + } + } + + // Populate our constructed prototype object + CAATClass.prototype = prototype; + // Enforce the constructor to be what we expect + CAATClass.prototype.constructor = CAATClass; + CAATClass.superclass = _super; + // And make this class extendable + CAATClass.extend = Class.extend; + + assignNamespace( name, CAATClass ); + if ( constants ) { + for( var constant in constants ) { + if ( constants.hasOwnProperty(constant) ) { + CAATClass[ constant ]= constants[constant]; + } + } + } + + if ( aliases ) { + if ( !isArray(aliases) ) { + aliases= [aliases]; + } + for( var i=0; i NOT solved.") + ); + }, + + removeDependency : function( modulename ) { + for( var i=0; i Can't extend non-existant class: "+this.baseClass ); + return; + } + + c= c.extend( + this.extendWith, + this.constants, + this.name, + this.aliases, + { decorated : this.decorated } ); + + } else { + c= Class.extend( + this.extendWith, + this.constants, + this.name, + this.aliases, + { decorated : this.decorated } ); + } + + console.log("Created module: "+this.name); + + if ( this.callback ) { + this.callback(); + } + + } + }; + + var ScriptFile= function(path, module) { + this.path= path; + this.module= module; + return this; + } + + ScriptFile.prototype= { + path : null, + processed: false, + module: null, + + setProcessed : function() { + this.processed= true; + }, + + isProcessed : function() { + return this.processed; + } + }; + + var ModuleManager= function() { + this.nodes= []; + this.loadedFiles= []; + this.path= {}; + this.solveListener= []; + this.orderedSolvedModules= []; + this.readyListener= []; + + return this; + }; + + ModuleManager.baseURL= ""; + ModuleManager.modulePath= {}; + ModuleManager.sortedModulePath= []; + + ModuleManager.prototype= { + + nodes: null, // built nodes. + loadedFiles:null, // list of loaded files. avoid loading each file more than once + solveListener: null, // listener for a module solved + readyListener: null, // listener for all modules solved + orderedSolvedModules: null, // order in which modules where solved. + + addSolvedListener : function( modulename, callback ) { + this.solveListener.push( { + name : modulename, + callback : callback + }); + }, + + solved : function( module ) { + var i; + + for( i=0; i "+obj.defines+" onPrecreation"); + try { + obj.onPreCreate(); + } catch(e) { + console.log(" -> catched "+e+" on module "+obj.defines+" preCreation."); + } + } + + if (!obj.depends ) { + obj.depends= []; + } + + var dependencies= obj.depends; + + if ( dependencies ) { + if ( !isArray(dependencies) ) { + dependencies= [ dependencies ]; + obj.depends= dependencies; + } + } + + // elimina dependencias ya resueltas en otras cargas. + i=0; + while( i=}, // dependencies class names + * extendsClass{string}, // class to extend from + * extensdWith{object}, // actual prototype to extend + * aliases{Array}, // other class names + * onCreation{function=} // optional callback to call after class creation. + * onPreCreation{function=} // optional callback to call after namespace class creation. + * } + */ + MoMa.Module= function loadModule(obj) { + + if (!obj.defines) { + console.error("Bad module definition: "+obj); + return; + } + + ensureNamespace(obj.defines); + + mm.module( obj ); + + }; + + MoMa.ModuleManager= {}; + + MoMa.ModuleManager.baseURL= function(baseURL) { + + if ( !baseURL ) { + return MoMa.Module; + } + + if (!baseURL.endsWith("/") ) { + baseURL= baseURL + "/"; + } + + ModuleManager.baseURL= baseURL; + return MoMa.ModuleManager; + }; + + MoMa.ModuleManager.setModulePath= function( module, path ) { + + if ( !path.endsWith("/") ) { + path= path + "/"; + } + + if ( !ModuleManager.modulePath[module] ) { + ModuleManager.modulePath[ module ]= path; + + ModuleManager.sortedModulePath.push( module ); + ModuleManager.sortedModulePath.sort( function(a,b) { + return a + * @param p1 + * @param p2 + * @param p3 + */ + setCurve:function (p0, p1, p2, p3) { + + this.coordlist = []; + this.coordlist.push(p0); + this.coordlist.push(p1); + this.coordlist.push(p2); + this.coordlist.push(p3); + + this.update(); + + return this; + }, + /** + * Paint the contour by solving again the entire curve. + * @param director {CAAT.Director} + */ + paint:function (director) { + + var x1, y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; + + var ctx = director.ctx; + + ctx.save(); + ctx.beginPath(); + ctx.moveTo(x1, y1); + + var point = new CAAT.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + ctx.stroke(); + ctx.restore(); + + CAAT.Math.CatmullRom.superclass.paint.call(this, director); + }, + /** + * Solves the curve for any given parameter t. + * @param point {CAAT.Point} the point to store the solved value on the curve. + * @param t {number} a number in the range 0..1 + */ + solve:function (point, t) { + var c = this.coordlist; + + // Handy from CAKE. Thanks. + var af = ((-t + 2) * t - 1) * t * 0.5 + var bf = (((3 * t - 5) * t) * t + 2) * 0.5 + var cf = ((-3 * t + 4) * t + 1) * t * 0.5 + var df = ((t - 1) * t * t) * 0.5 + + point.x = c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y = c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; + + return point; + + }, + + applyAsPath:function (director) { + + var ctx = director.ctx; + + var point = new CAAT.Math.Point(); + + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(point, t); + ctx.lineTo(point.x, point.y); + } + + return this; + }, + + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 2 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 1 ]; + } + } + } +}); diff --git a/CAAT/src/Math/Curve.js b/CAAT/src/Math/Curve.js new file mode 100644 index 0000000..926777b --- /dev/null +++ b/CAAT/src/Math/Curve.js @@ -0,0 +1,202 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Curve + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Curve", + depends:["CAAT.Math.Point"], + extendsWith:function () { + + return { + + /** + * @lends CAAT.Math.Curve.prototype + */ + + /** + * A collection of CAAT.Math.Point objects. + */ + coordlist:null, + + /** + * Minimun solver step. + */ + k:0.05, + + /** + * Curve length. + */ + length:-1, + + /** + * If this segments belongs to an interactive path, the handlers will be this size. + */ + HANDLE_SIZE:20, + + /** + * Draw interactive handlers ? + */ + drawHandles:true, + + /** + * Paint the curve control points. + * @param director {CAAT.Director} + */ + paint:function (director) { + if (false === this.drawHandles) { + return; + } + + var cl = this.coordlist; + var ctx = director.ctx; + + // control points + ctx.save(); + ctx.beginPath(); + + ctx.strokeStyle = '#a0a0a0'; + ctx.moveTo(cl[0].x, cl[0].y); + ctx.lineTo(cl[1].x, cl[1].y); + ctx.stroke(); + if (this.cubic) { + ctx.moveTo(cl[2].x, cl[2].y); + ctx.lineTo(cl[3].x, cl[3].y); + ctx.stroke(); + } + + + ctx.globalAlpha = 0.5; + for (var i = 0; i < this.coordlist.length; i++) { + ctx.fillStyle = '#7f7f00'; + var w = this.HANDLE_SIZE / 2; + ctx.beginPath(); + ctx.arc(cl[i].x, cl[i].y, w, 0, 2 * Math.PI, false); + ctx.fill(); + } + + ctx.restore(); + }, + /** + * Signal the curve has been modified and recalculate curve length. + */ + update:function () { + this.calcLength(); + }, + /** + * This method must be overriden by subclasses. It is called whenever the curve must be solved for some time=t. + * The t parameter must be in the range 0..1 + * @param point {CAAT.Point} to store curve solution for t. + * @param t {number} + * @return {CAAT.Point} the point parameter. + */ + solve:function (point, t) { + }, + /** + * Get an array of points defining the curve contour. + * @param numSamples {number} number of segments to get. + */ + getContour:function (numSamples) { + var contour = [], i; + + for (i = 0; i <= numSamples; i++) { + var point = new CAAT.Math.Point(); + this.solve(point, i / numSamples); + contour.push(point); + } + + return contour; + }, + /** + * Calculates a curve bounding box. + * + * @param rectangle {CAAT.Rectangle} a rectangle to hold the bounding box. + * @return {CAAT.Rectangle} the rectangle parameter. + */ + getBoundingBox:function (rectangle) { + if (!rectangle) { + rectangle = new CAAT.Math.Rectangle(); + } + + // thanks yodesoft.com for spotting the first point is out of the BB + rectangle.setEmpty(); + rectangle.union(this.coordlist[0].x, this.coordlist[0].y); + + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + rectangle.union(pt.x, pt.y); + } + + return rectangle; + }, + /** + * Calculate the curve length by incrementally solving the curve every substep=CAAT.Curve.k. This value defaults + * to .05 so at least 20 iterations will be performed. + * + * @return {number} the approximate curve length. + */ + calcLength:function () { + var x1, y1; + x1 = this.coordlist[0].x; + y1 = this.coordlist[0].y; + var llength = 0; + var pt = new CAAT.Math.Point(); + for (var t = this.k; t <= 1 + this.k; t += this.k) { + this.solve(pt, t); + llength += Math.sqrt((pt.x - x1) * (pt.x - x1) + (pt.y - y1) * (pt.y - y1)); + x1 = pt.x; + y1 = pt.y; + } + + this.length = llength; + return llength; + }, + /** + * Return the cached curve length. + * @return {number} the cached curve length. + */ + getLength:function () { + return this.length; + }, + /** + * Return the first curve control point. + * @return {CAAT.Point} + */ + endCurvePosition:function () { + return this.coordlist[ this.coordlist.length - 1 ]; + }, + /** + * Return the last curve control point. + * @return {CAAT.Point} + */ + startCurvePosition:function () { + return this.coordlist[ 0 ]; + }, + + setPoints:function (points) { + }, + + setPoint:function (point, index) { + if (index >= 0 && index < this.coordlist.length) { + this.coordlist[index] = point; + } + }, + /** + * + * @param director <=CAAT.Director> + */ + applyAsPath:function (director) { + } + } + } + +}); + diff --git a/CAAT/src/Math/Dimension.js b/CAAT/src/Math/Dimension.js new file mode 100644 index 0000000..5f26fda --- /dev/null +++ b/CAAT/src/Math/Dimension.js @@ -0,0 +1,36 @@ +CAAT.Module({ + + /** + * @name Dimension + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Dimension", + aliases:["CAAT.Dimension"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Dimension.prototype + */ + + /** + * Width dimension. + */ + width:0, + + /** + * Height dimension. + */ + height:0, + + __init:function (w, h) { + this.width = w; + this.height = h; + return this; + } + } + } +}); diff --git a/CAAT/src/Math/Matrix.js b/CAAT/src/Math/Matrix.js new file mode 100644 index 0000000..51cfcad --- /dev/null +++ b/CAAT/src/Math/Matrix.js @@ -0,0 +1,424 @@ +/** + * See LICENSE file. + * + **/ + + +CAAT.Module({ + + /** + * @name Matrix + * @memberOf CAAT.Math + * @constructor + */ + + + defines:"CAAT.Math.Matrix", + depends:["CAAT.Math.Point"], + aliases:["CAAT.Matrix"], + onCreate : function() { + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Math.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Math.Matrix.prototype.transformRenderingContextSet_NoClamp; + }, + constants : { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + setCoordinateClamping : function( clamp ) { + if ( clamp ) { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_Clamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_Clamp; + } else { + CAAT.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContext= CAAT.Matrix.prototype.transformRenderingContext_NoClamp; + CAAT.Math.Matrix.prototype.transformRenderingContextSet= CAAT.Matrix.prototype.transformRenderingContextSet_NoClamp; + } + }, + /** + * Create a scale matrix. + * @param scalex {number} x scale magnitude. + * @param scaley {number} y scale magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + scale:function (scalex, scaley) { + var m = new CAAT.Math.Matrix(); + + m.matrix[0] = scalex; + m.matrix[4] = scaley; + + return m; + }, + /** + * Create a new rotation matrix and set it up for the specified angle in radians. + * @param angle {number} + * @return {CAAT.Matrix} a matrix object. + * + * @static + */ + rotate:function (angle) { + var m = new CAAT.Math.Matrix(); + m.setRotation(angle); + return m; + }, + /** + * Create a translation matrix. + * @param x {number} x translation magnitude. + * @param y {number} y translation magnitude. + * + * @return {CAAT.Matrix} a matrix object. + * @static + * + */ + translate:function (x, y) { + var m = new CAAT.Math.Matrix(); + + m.matrix[2] = x; + m.matrix[5] = y; + + return m; + } + }, + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix.prototype + */ + + /** + * An array of 9 numbers. + */ + matrix:null, + + __init:function () { + this.matrix = [ + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 ]; + + if (typeof Float32Array !== "undefined") { + this.matrix = new Float32Array(this.matrix); + } + + return this; + }, + + /** + * Transform a point by this matrix. The parameter point will be modified with the transformation values. + * @param point {CAAT.Point}. + * @return {CAAT.Point} the parameter point. + */ + transformCoord:function (point) { + var x = point.x; + var y = point.y; + + var tm = this.matrix; + + point.x = x * tm[0] + y * tm[1] + tm[2]; + point.y = x * tm[3] + y * tm[4] + tm[5]; + + return point; + }, + + setRotation:function (angle) { + + this.identity(); + + var tm = this.matrix; + var c = Math.cos(angle); + var s = Math.sin(angle); + tm[0] = c; + tm[1] = -s; + tm[3] = s; + tm[4] = c; + + return this; + }, + + setScale:function (scalex, scaley) { + this.identity(); + + this.matrix[0] = scalex; + this.matrix[4] = scaley; + + return this; + }, + + /** + * Sets this matrix as a translation matrix. + * @param x + * @param y + */ + setTranslate:function (x, y) { + this.identity(); + + this.matrix[2] = x; + this.matrix[5] = y; + + return this; + }, + /** + * Copy into this matrix the given matrix values. + * @param matrix {CAAT.Matrix} + * @return this + */ + copy:function (matrix) { + matrix = matrix.matrix; + + var tmatrix = this.matrix; + tmatrix[0] = matrix[0]; + tmatrix[1] = matrix[1]; + tmatrix[2] = matrix[2]; + tmatrix[3] = matrix[3]; + tmatrix[4] = matrix[4]; + tmatrix[5] = matrix[5]; + tmatrix[6] = matrix[6]; + tmatrix[7] = matrix[7]; + tmatrix[8] = matrix[8]; + + return this; + }, + /** + * Set this matrix to the identity matrix. + * @return this + */ + identity:function () { + + var m = this.matrix; + m[0] = 1.0; + m[1] = 0.0; + m[2] = 0.0; + + m[3] = 0.0; + m[4] = 1.0; + m[5] = 0.0; + + m[6] = 0.0; + m[7] = 0.0; + m[8] = 1.0; + + return this; + }, + /** + * Multiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + multiply:function (m) { + + var tm = this.matrix; + var mm = m.matrix; + + var tm0 = tm[0]; + var tm1 = tm[1]; + var tm2 = tm[2]; + var tm3 = tm[3]; + var tm4 = tm[4]; + var tm5 = tm[5]; + var tm6 = tm[6]; + var tm7 = tm[7]; + var tm8 = tm[8]; + + var mm0 = mm[0]; + var mm1 = mm[1]; + var mm2 = mm[2]; + var mm3 = mm[3]; + var mm4 = mm[4]; + var mm5 = mm[5]; + var mm6 = mm[6]; + var mm7 = mm[7]; + var mm8 = mm[8]; + + tm[0] = tm0 * mm0 + tm1 * mm3 + tm2 * mm6; + tm[1] = tm0 * mm1 + tm1 * mm4 + tm2 * mm7; + tm[2] = tm0 * mm2 + tm1 * mm5 + tm2 * mm8; + tm[3] = tm3 * mm0 + tm4 * mm3 + tm5 * mm6; + tm[4] = tm3 * mm1 + tm4 * mm4 + tm5 * mm7; + tm[5] = tm3 * mm2 + tm4 * mm5 + tm5 * mm8; + tm[6] = tm6 * mm0 + tm7 * mm3 + tm8 * mm6; + tm[7] = tm6 * mm1 + tm7 * mm4 + tm8 * mm7; + tm[8] = tm6 * mm2 + tm7 * mm5 + tm8 * mm8; + + return this; + }, + /** + * Premultiply this matrix by a given matrix. + * @param m {CAAT.Matrix} + * @return this + */ + premultiply:function (m) { + + var m00 = m.matrix[0] * this.matrix[0] + m.matrix[1] * this.matrix[3] + m.matrix[2] * this.matrix[6]; + var m01 = m.matrix[0] * this.matrix[1] + m.matrix[1] * this.matrix[4] + m.matrix[2] * this.matrix[7]; + var m02 = m.matrix[0] * this.matrix[2] + m.matrix[1] * this.matrix[5] + m.matrix[2] * this.matrix[8]; + + var m10 = m.matrix[3] * this.matrix[0] + m.matrix[4] * this.matrix[3] + m.matrix[5] * this.matrix[6]; + var m11 = m.matrix[3] * this.matrix[1] + m.matrix[4] * this.matrix[4] + m.matrix[5] * this.matrix[7]; + var m12 = m.matrix[3] * this.matrix[2] + m.matrix[4] * this.matrix[5] + m.matrix[5] * this.matrix[8]; + + var m20 = m.matrix[6] * this.matrix[0] + m.matrix[7] * this.matrix[3] + m.matrix[8] * this.matrix[6]; + var m21 = m.matrix[6] * this.matrix[1] + m.matrix[7] * this.matrix[4] + m.matrix[8] * this.matrix[7]; + var m22 = m.matrix[6] * this.matrix[2] + m.matrix[7] * this.matrix[5] + m.matrix[8] * this.matrix[8]; + + this.matrix[0] = m00; + this.matrix[1] = m01; + this.matrix[2] = m02; + + this.matrix[3] = m10; + this.matrix[4] = m11; + this.matrix[5] = m12; + + this.matrix[6] = m20; + this.matrix[7] = m21; + this.matrix[8] = m22; + + + return this; + }, + /** + * Creates a new inverse matrix from this matrix. + * @return {CAAT.Matrix} an inverse matrix. + */ + getInverse:function (out) { + var tm = this.matrix; + + var m00 = tm[0]; + var m01 = tm[1]; + var m02 = tm[2]; + var m10 = tm[3]; + var m11 = tm[4]; + var m12 = tm[5]; + var m20 = tm[6]; + var m21 = tm[7]; + var m22 = tm[8]; + + var newMatrix = out || new CAAT.Math.Matrix(); + + var determinant = m00 * (m11 * m22 - m21 * m12) - m10 * (m01 * m22 - m21 * m02) + m20 * (m01 * m12 - m11 * m02); + if (determinant === 0) { + return null; + } + + var m = newMatrix.matrix; + + m[0] = m11 * m22 - m12 * m21; + m[1] = m02 * m21 - m01 * m22; + m[2] = m01 * m12 - m02 * m11; + + m[3] = m12 * m20 - m10 * m22; + m[4] = m00 * m22 - m02 * m20; + m[5] = m02 * m10 - m00 * m12; + + m[6] = m10 * m21 - m11 * m20; + m[7] = m01 * m20 - m00 * m21; + m[8] = m00 * m11 - m01 * m10; + + newMatrix.multiplyScalar(1 / determinant); + + return newMatrix; + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i; + + for (i = 0; i < 9; i++) { + this.matrix[i] *= scalar; + } + + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_NoClamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_NoClamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContextSet_Clamp:function (ctx) { + var m = this.matrix; + ctx.setTransform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + /** + * + * @param ctx + */ + transformRenderingContext_Clamp:function (ctx) { + var m = this.matrix; + ctx.transform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0); + return this; + }, + + setModelViewMatrix:function ( x, y, sx, sy, r ) { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + mm = this.matrix; + + mm0 = 1; + mm1 = 0; + mm3 = 0; + mm4 = 1; + + mm2 = x; + mm5 = y; + + c = Math.cos(r); + s = Math.sin(r); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm0 = mm0 * this.scaleX; + mm1 = mm1 * this.scaleY; + mm3 = mm3 * this.scaleX; + mm4 = mm4 * this.scaleY; + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + } + } + } +}); diff --git a/CAAT/src/Math/Matrix3.js b/CAAT/src/Math/Matrix3.js new file mode 100644 index 0000000..00f6854 --- /dev/null +++ b/CAAT/src/Math/Matrix3.js @@ -0,0 +1,545 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Matrix3 + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Matrix3", + aliases:["CAAT.Matrix3"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Matrix3.prototype + */ + + /** + * An Array of 4 Array of 4 numbers. + */ + matrix:null, + + /** + * An array of 16 numbers. + */ + fmatrix:null, + + __init:function () { + this.matrix = [ + [1, 0, 0, 0], + [0, 1, 0, 0], + [0, 0, 1, 0], + [0, 0, 0, 1] + ]; + + this.fmatrix = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + + return this; + }, + + transformCoord:function (point) { + var x = point.x; + var y = point.y; + var z = point.z; + + point.x = x * this.matrix[0][0] + y * this.matrix[0][1] + z * this.matrix[0][2] + this.matrix[0][3]; + point.y = x * this.matrix[1][0] + y * this.matrix[1][1] + z * this.matrix[1][2] + this.matrix[1][3]; + point.z = x * this.matrix[2][0] + y * this.matrix[2][1] + z * this.matrix[2][2] + this.matrix[2][3]; + + return point; + }, + initialize:function (x0, y0, z0, x1, y1, z1, x2, y2, z2) { + this.identity(); + this.matrix[0][0] = x0; + this.matrix[0][1] = y0; + this.matrix[0][2] = z0; + + this.matrix[1][0] = x1; + this.matrix[1][1] = y1; + this.matrix[1][2] = z1; + + this.matrix[2][0] = x2; + this.matrix[2][1] = y2; + this.matrix[2][2] = z2; + + return this; + }, + initWithMatrix:function (matrixData) { + this.matrix = matrixData; + return this; + }, + flatten:function () { + var d = this.fmatrix; + var s = this.matrix; + d[ 0] = s[0][0]; + d[ 1] = s[1][0]; + d[ 2] = s[2][0]; + d[ 3] = s[3][0]; + + d[ 4] = s[0][1]; + d[ 5] = s[1][1]; + d[ 6] = s[2][1]; + d[ 7] = s[2][1]; + + d[ 8] = s[0][2]; + d[ 9] = s[1][2]; + d[10] = s[2][2]; + d[11] = s[3][2]; + + d[12] = s[0][3]; + d[13] = s[1][3]; + d[14] = s[2][3]; + d[15] = s[3][3]; + + return this.fmatrix; + }, + + /** + * Set this matrix to identity matrix. + * @return this + */ + identity:function () { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = (i === j) ? 1.0 : 0.0; + } + } + + return this; + }, + /** + * Get this matri'x internal representation data. The bakced structure is a 4x4 array of number. + */ + getMatrix:function () { + return this.matrix; + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xy axis. + * + * @param xy {Number} radians to rotate. + * + * @return this + */ + rotateXY:function (xy) { + return this.rotate(xy, 0, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate around + * xz axis. + * + * @param xz {Number} radians to rotate. + * + * @return this + */ + rotateXZ:function (xz) { + return this.rotate(0, xz, 0); + }, + /** + * Multiply this matrix by a created rotation matrix. The rotation matrix is set up to rotate aroind + * yz axis. + * + * @param yz {Number} radians to rotate. + * + * @return this + */ + rotateYZ:function (yz) { + return this.rotate(0, 0, yz); + }, + /** + * + * @param xy + * @param xz + * @param yz + */ + setRotate:function (xy, xz, yz) { + var m = this.rotate(xy, xz, yz); + this.copy(m); + return this; + }, + /** + * Creates a matrix to represent arbitrary rotations around the given planes. + * @param xy {number} radians to rotate around xy plane. + * @param xz {number} radians to rotate around xz plane. + * @param yz {number} radians to rotate around yz plane. + * + * @return {CAAT.Matrix3} a newly allocated matrix. + * @static + */ + rotate:function (xy, xz, yz) { + var res = new CAAT.Math.Matrix3(); + var s, c, m; + + if (xy !== 0) { + m = new CAAT.Math.Math.Matrix3(); + s = Math.sin(xy); + c = Math.cos(xy); + m.matrix[1][1] = c; + m.matrix[1][2] = -s; + m.matrix[2][1] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (xz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(xz); + c = Math.cos(xz); + m.matrix[0][0] = c; + m.matrix[0][2] = -s; + m.matrix[2][0] = s; + m.matrix[2][2] = c; + res.multiply(m); + } + + if (yz !== 0) { + m = new CAAT.Math.Matrix3(); + s = Math.sin(yz); + c = Math.cos(yz); + m.matrix[0][0] = c; + m.matrix[0][1] = -s; + m.matrix[1][0] = s; + m.matrix[1][1] = c; + res.multiply(m); + } + + return res; + }, + /** + * Creates a new matrix being a copy of this matrix. + * @return {CAAT.Matrix3} a newly allocated matrix object. + */ + getClone:function () { + var m = new CAAT.Math.Matrix3(); + m.copy(this); + return m; + }, + /** + * Multiplies this matrix by another matrix. + * + * @param n {CAAT.Matrix3} a CAAT.Matrix3 object. + * @return this + */ + multiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20 + n03 * m30; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21 + n03 * m31; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22 + n03 * m32; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03 * m33; + + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20 + n13 * m30; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21 + n13 * m31; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22 + n13 * m32; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13 * m33; + + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20 + n23 * m30; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21 + n23 * m31; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22 + n23 * m32; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23 * m33; + + return this; + }, + /** + * Pre multiplies this matrix by a given matrix. + * + * @param m {CAAT.Matrix3} a CAAT.Matrix3 object. + * + * @return this + */ + premultiply:function (m) { + var n = this.getClone(); + + var nm = n.matrix; + var n00 = nm[0][0]; + var n01 = nm[0][1]; + var n02 = nm[0][2]; + var n03 = nm[0][3]; + + var n10 = nm[1][0]; + var n11 = nm[1][1]; + var n12 = nm[1][2]; + var n13 = nm[1][3]; + + var n20 = nm[2][0]; + var n21 = nm[2][1]; + var n22 = nm[2][2]; + var n23 = nm[2][3]; + + var n30 = nm[3][0]; + var n31 = nm[3][1]; + var n32 = nm[3][2]; + var n33 = nm[3][3]; + + var mm = m.matrix; + var m00 = mm[0][0]; + var m01 = mm[0][1]; + var m02 = mm[0][2]; + var m03 = mm[0][3]; + + var m10 = mm[1][0]; + var m11 = mm[1][1]; + var m12 = mm[1][2]; + var m13 = mm[1][3]; + + var m20 = mm[2][0]; + var m21 = mm[2][1]; + var m22 = mm[2][2]; + var m23 = mm[2][3]; + + var m30 = mm[3][0]; + var m31 = mm[3][1]; + var m32 = mm[3][2]; + var m33 = mm[3][3]; + + this.matrix[0][0] = n00 * m00 + n01 * m10 + n02 * m20; + this.matrix[0][1] = n00 * m01 + n01 * m11 + n02 * m21; + this.matrix[0][2] = n00 * m02 + n01 * m12 + n02 * m22; + this.matrix[0][3] = n00 * m03 + n01 * m13 + n02 * m23 + n03; + this.matrix[1][0] = n10 * m00 + n11 * m10 + n12 * m20; + this.matrix[1][1] = n10 * m01 + n11 * m11 + n12 * m21; + this.matrix[1][2] = n10 * m02 + n11 * m12 + n12 * m22; + this.matrix[1][3] = n10 * m03 + n11 * m13 + n12 * m23 + n13; + this.matrix[2][0] = n20 * m00 + n21 * m10 + n22 * m20; + this.matrix[2][1] = n20 * m01 + n21 * m11 + n22 * m21; + this.matrix[2][2] = n20 * m02 + n21 * m12 + n22 * m22; + this.matrix[2][3] = n20 * m03 + n21 * m13 + n22 * m23 + n23; + + return this; + }, + /** + * Set this matrix translation values to be the given parameters. + * + * @param x {number} x component of translation point. + * @param y {number} y component of translation point. + * @param z {number} z component of translation point. + * + * @return this + */ + setTranslate:function (x, y, z) { + this.identity(); + this.matrix[0][3] = x; + this.matrix[1][3] = y; + this.matrix[2][3] = z; + return this; + }, + /** + * Create a translation matrix. + * @param x {number} + * @param y {number} + * @param z {number} + * @return {CAAT.Matrix3} a new matrix. + */ + translate:function (x, y, z) { + var m = new CAAT.Math.Matrix3(); + m.setTranslate(x, y, z); + return m; + }, + setScale:function (sx, sy, sz) { + this.identity(); + this.matrix[0][0] = sx; + this.matrix[1][1] = sy; + this.matrix[2][2] = sz; + return this; + }, + scale:function (sx, sy, sz) { + var m = new CAAT.Math.Matrix3(); + m.setScale(sx, sy, sz); + return m; + }, + /** + * Set this matrix as the rotation matrix around the given axes. + * @param xy {number} radians of rotation around z axis. + * @param xz {number} radians of rotation around y axis. + * @param yz {number} radians of rotation around x axis. + * + * @return this + */ + rotateModelView:function (xy, xz, yz) { + var sxy = Math.sin(xy); + var sxz = Math.sin(xz); + var syz = Math.sin(yz); + var cxy = Math.cos(xy); + var cxz = Math.cos(xz); + var cyz = Math.cos(yz); + + this.matrix[0][0] = cxz * cxy; + this.matrix[0][1] = -cxz * sxy; + this.matrix[0][2] = sxz; + this.matrix[0][3] = 0; + this.matrix[1][0] = syz * sxz * cxy + sxy * cyz; + this.matrix[1][1] = cyz * cxy - syz * sxz * sxy; + this.matrix[1][2] = -syz * cxz; + this.matrix[1][3] = 0; + this.matrix[2][0] = syz * sxy - cyz * sxz * cxy; + this.matrix[2][1] = cyz * sxz * sxy + syz * cxy; + this.matrix[2][2] = cyz * cxz; + this.matrix[2][3] = 0; + this.matrix[3][0] = 0; + this.matrix[3][1] = 0; + this.matrix[3][2] = 0; + this.matrix[3][3] = 1; + + return this; + }, + /** + * Copy a given matrix values into this one's. + * @param m {CAAT.Matrix} a matrix + * + * @return this + */ + copy:function (m) { + for (var i = 0; i < 4; i++) { + for (var j = 0; j < 4; j++) { + this.matrix[i][j] = m.matrix[i][j]; + } + } + + return this; + }, + /** + * Calculate this matrix's determinant. + * @return {number} matrix determinant. + */ + calculateDeterminant:function () { + + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + return m14 * m22 * m33 * m41 + + m12 * m24 * m33 * m41 + + m14 * m23 * m31 * m42 + + m13 * m24 * m31 * m42 + + + m13 * m21 * m34 * m42 + + m11 * m23 * m34 * m42 + + m14 * m21 * m32 * m43 + + m11 * m24 * m32 * m43 + + + m13 * m22 * m31 * m44 + + m12 * m23 * m31 * m44 + + m12 * m21 * m33 * m44 + + m11 * m22 * m33 * m44 + + + m14 * m23 * m32 * m41 - + m13 * m24 * m32 * m41 - + m13 * m22 * m34 * m41 - + m12 * m23 * m34 * m41 - + + m14 * m21 * m33 * m42 - + m11 * m24 * m33 * m42 - + m14 * m22 * m31 * m43 - + m12 * m24 * m31 * m43 - + + m12 * m21 * m34 * m43 - + m11 * m22 * m34 * m43 - + m13 * m21 * m32 * m44 - + m11 * m23 * m32 * m44; + }, + /** + * Return a new matrix which is this matrix's inverse matrix. + * @return {CAAT.Matrix3} a new matrix. + */ + getInverse:function () { + var mm = this.matrix; + var m11 = mm[0][0], m12 = mm[0][1], m13 = mm[0][2], m14 = mm[0][3], + m21 = mm[1][0], m22 = mm[1][1], m23 = mm[1][2], m24 = mm[1][3], + m31 = mm[2][0], m32 = mm[2][1], m33 = mm[2][2], m34 = mm[2][3], + m41 = mm[3][0], m42 = mm[3][1], m43 = mm[3][2], m44 = mm[3][3]; + + var m2 = new CAAT.Math.Matrix3(); + m2.matrix[0][0] = m23 * m34 * m42 + m24 * m32 * m43 + m22 * m33 * m44 - m24 * m33 * m42 - m22 * m34 * m43 - m23 * m32 * m44; + m2.matrix[0][1] = m14 * m33 * m42 + m12 * m34 * m43 + m13 * m32 * m44 - m12 * m33 * m44 - m13 * m34 * m42 - m14 * m32 * m43; + m2.matrix[0][2] = m13 * m24 * m42 + m12 * m23 * m44 + m14 * m22 * m43 - m12 * m24 * m43 - m13 * m22 * m44 - m14 * m23 * m42; + m2.matrix[0][3] = m14 * m23 * m32 + m12 * m24 * m33 + m13 * m22 * m34 - m13 * m24 * m32 - m14 * m22 * m33 - m12 * m23 * m34; + + m2.matrix[1][0] = m24 * m33 * m41 + m21 * m34 * m43 + m23 * m31 * m44 - m23 * m34 * m41 - m24 * m31 * m43 - m21 * m33 * m44; + m2.matrix[1][1] = m13 * m34 * m41 + m14 * m31 * m43 + m11 * m33 * m44 - m14 * m33 * m41 - m11 * m34 * m43 - m13 * m31 * m44; + m2.matrix[1][2] = m14 * m23 * m41 + m11 * m24 * m43 + m13 * m21 * m44 - m13 * m24 * m41 - m14 * m21 * m43 - m11 * m23 * m44; + m2.matrix[1][3] = m13 * m24 * m31 + m14 * m21 * m33 + m11 * m23 * m34 - m14 * m23 * m31 - m11 * m24 * m33 - m13 * m21 * m34; + + m2.matrix[2][0] = m22 * m34 * m41 + m24 * m31 * m42 + m21 * m32 * m44 - m24 * m32 * m41 - m21 * m34 * m42 - m22 * m31 * m44; + m2.matrix[2][1] = m14 * m32 * m41 + m11 * m34 * m42 + m12 * m31 * m44 - m11 * m32 * m44 - m12 * m34 * m41 - m14 * m31 * m42; + m2.matrix[2][2] = m13 * m24 * m41 + m14 * m21 * m42 + m11 * m22 * m44 - m14 * m22 * m41 - m11 * m24 * m42 - m12 * m21 * m44; + m2.matrix[2][3] = m14 * m22 * m31 + m11 * m24 * m32 + m12 * m21 * m34 - m11 * m22 * m34 - m12 * m24 * m31 - m14 * m21 * m32; + + m2.matrix[3][0] = m23 * m32 * m41 + m21 * m33 * m42 + m22 * m31 * m43 - m22 * m33 * m41 - m23 * m31 * m42 - m21 * m32 * m43; + m2.matrix[3][1] = m12 * m33 * m41 + m13 * m31 * m42 + m11 * m32 * m43 - m13 * m32 * m41 - m11 * m33 * m42 - m12 * m31 * m43; + m2.matrix[3][2] = m13 * m22 * m41 + m11 * m23 * m42 + m12 * m21 * m43 - m11 * m22 * m43 - m12 * m23 * m41 - m13 * m21 * m42; + m2.matrix[3][3] = m12 * m23 * m31 + m13 * m21 * m32 + m11 * m22 * m33 - m13 * m22 * m31 - m11 * m23 * m32 - m12 * m21 * m33; + + return m2.multiplyScalar(1 / this.calculateDeterminant()); + }, + /** + * Multiply this matrix by a scalar. + * @param scalar {number} scalar value + * + * @return this + */ + multiplyScalar:function (scalar) { + var i, j; + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { + this.matrix[i][j] *= scalar; + } + } + + return this; + } + + } + } + +}); diff --git a/CAAT/src/Math/Point.js b/CAAT/src/Math/Point.js new file mode 100644 index 0000000..b8d9557 --- /dev/null +++ b/CAAT/src/Math/Point.js @@ -0,0 +1,235 @@ +/** + * See LICENSE file. + * + **/ +CAAT.Module({ + + /** + * @name Point + * @memberOf CAAT.Math + * @constructor + */ + + defines:"CAAT.Math.Point", + aliases:["CAAT.Point"], + extendsWith:function () { + return { + + /** + * @lends CAAT.Math.Point.prototype + */ + + + /** + * point x coordinate. + */ + x:0, + + /** + * point y coordinate. + */ + y:0, + + /** + * point z coordinate. + */ + z:0, + + __init:function (xpos, ypos, zpos) { + this.x = xpos; + this.y = ypos; + this.z = zpos || 0; + return this; + }, + + /** + * Sets this point coordinates. + * @param x {number} + * @param y {number} + * @param z {number=} + * + * @return this + */ + set:function (x, y, z) { + this.x = x; + this.y = y; + this.z = z || 0; + return this; + }, + /** + * Create a new CAAT.Point equal to this one. + * @return {CAAT.Point} + */ + clone:function () { + var p = new CAAT.Math.Point(this.x, this.y, this.z); + return p; + }, + /** + * Translate this point to another position. The final point will be (point.x+x, point.y+y) + * @param x {number} + * @param y {number} + * + * @return this + */ + translate:function (x, y, z) { + this.x += x; + this.y += y; + this.z += z; + + return this; + }, + /** + * Translate this point to another point. + * @param aPoint {CAAT.Point} + * @return this + */ + translatePoint:function (aPoint) { + this.x += aPoint.x; + this.y += aPoint.y; + this.z += aPoint.z; + return this; + }, + /** + * Substract a point from this one. + * @param aPoint {CAAT.Point} + * @return this + */ + subtract:function (aPoint) { + this.x -= aPoint.x; + this.y -= aPoint.y; + this.z -= aPoint.z; + return this; + }, + /** + * Multiply this point by a scalar. + * @param factor {number} + * @return this + */ + multiply:function (factor) { + this.x *= factor; + this.y *= factor; + this.z *= factor; + return this; + }, + /** + * Rotate this point by an angle. The rotation is held by (0,0) coordinate as center. + * @param angle {number} + * @return this + */ + rotate:function (angle) { + var x = this.x, y = this.y; + this.x = x * Math.cos(angle) - Math.sin(angle) * y; + this.y = x * Math.sin(angle) + Math.cos(angle) * y; + this.z = 0; + return this; + }, + /** + * + * @param angle {number} + * @return this + */ + setAngle:function (angle) { + var len = this.getLength(); + this.x = Math.cos(angle) * len; + this.y = Math.sin(angle) * len; + this.z = 0; + return this; + }, + /** + * + * @param length {number} + * @return this + */ + setLength:function (length) { + var len = this.getLength(); + if (len)this.multiply(length / len); + else this.x = this.y = this.z = length; + return this; + }, + /** + * Normalize this point, that is, both set coordinates proportionally to values raning 0..1 + * @return this + */ + normalize:function () { + var len = this.getLength(); + this.x /= len; + this.y /= len; + this.z /= len; + return this; + }, + /** + * Return the angle from -Pi to Pi of this point. + * @return {number} + */ + getAngle:function () { + return Math.atan2(this.y, this.x); + }, + /** + * Set this point coordinates proportinally to a maximum value. + * @param max {number} + * @return this + */ + limit:function (max) { + var aLenthSquared = this.getLengthSquared(); + if (aLenthSquared + 0.01 > max * max) { + var aLength = Math.sqrt(aLenthSquared); + this.x = (this.x / aLength) * max; + this.y = (this.y / aLength) * max; + this.z = (this.z / aLength) * max; + } + return this; + }, + /** + * Get this point's lenght. + * @return {number} + */ + getLength:function () { + var length = Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + if (length < 0.005 && length > -0.005) return 0.000001; + return length; + + }, + /** + * Get this point's squared length. + * @return {number} + */ + getLengthSquared:function () { + var lengthSquared = this.x * this.x + this.y * this.y + this.z * this.z; + if (lengthSquared < 0.005 && lengthSquared > -0.005) return 0; + return lengthSquared; + }, + /** + * Get the distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistance:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ); + }, + /** + * Get the squared distance between two points. + * @param point {CAAT.Point} + * @return {number} + */ + getDistanceSquared:function (point) { + var deltaX = this.x - point.x; + var deltaY = this.y - point.y; + var deltaZ = this.z - point.z; + return deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ; + }, + /** + * Get a string representation. + * @return {string} + */ + toString:function () { + return "(CAAT.Math.Point)" + + " x:" + String(Math.round(Math.floor(this.x * 10)) / 10) + + " y:" + String(Math.round(Math.floor(this.y * 10)) / 10) + + " z:" + String(Math.round(Math.floor(this.z * 10)) / 10); + } + } + } +}); diff --git a/CAAT/src/Math/Rectangle.js b/CAAT/src/Math/Rectangle.js new file mode 100644 index 0000000..e0f1978 --- /dev/null +++ b/CAAT/src/Math/Rectangle.js @@ -0,0 +1,218 @@ +/** + * See LICENSE file. + * + */ + + +CAAT.Module( { + + /** + * @name Rectangle + * @memberOf CAAT.Math + * @constructor + */ + + + defines: "CAAT.Math.Rectangle", + aliases: ["CAAT.Rectangle"], + extendsWith: function() { + return { + + /** + * @lends CAAT.Math.Rectangle.prototype + */ + + __init : function( x,y,w,h ) { + if ( arguments.length!==4 ) { + this.setEmpty(); + } else { + this.setLocation(x,y); + this.setDimension(w,h); + } + }, + + /** + * Rectangle x position. + */ + x: 0, + + /** + * Rectangle y position. + */ + y: 0, + + /** + * Rectangle x1 position. + */ + x1: 0, + + /** + * Rectangle y1 position. + */ + y1: 0, + + /** + * Rectangle width. + */ + width: -1, + + /** + * Rectangle height. + */ + height: -1, + + setEmpty : function() { + this.width= -1; + this.height= -1; + this.x= 0; + this.y= 0; + this.x1= 0; + this.y1= 0; + return this; + }, + /** + * Set this rectangle's location. + * @param x {number} + * @param y {number} + */ + setLocation: function( x,y ) { + this.x= x; + this.y= y; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + /** + * Set this rectangle's dimension. + * @param w {number} + * @param h {number} + */ + setDimension : function( w,h ) { + this.width= w; + this.height= h; + this.x1= this.x+this.width; + this.y1= this.y+this.height; + return this; + }, + setBounds : function( x,y,w,h ) { + this.setLocation( x, y ); + this.setDimension( w, h ); + return this; + }, + /** + * Return whether the coordinate is inside this rectangle. + * @param px {number} + * @param py {number} + * + * @return {boolean} + */ + contains : function(px,py) { + //return px>=0 && px=0 && py=this.x && px=this.y && pythis.y1 ) { + this.y1= py; + } + if ( px>this.x1 ){ + this.x1= px; + } + + this.width= this.x1-this.x; + this.height= this.y1-this.y; + }, + unionRectangle : function( rectangle ) { + this.union( rectangle.x , rectangle.y ); + this.union( rectangle.x1, rectangle.y ); + this.union( rectangle.x, rectangle.y1 ); + this.union( rectangle.x1, rectangle.y1 ); + return this; + }, + intersects : function( r ) { + if ( r.isEmpty() || this.isEmpty() ) { + return false; + } + + if ( r.x1<= this.x ) { + return false; + } + if ( r.x >= this.x1 ) { + return false; + } + if ( r.y1<= this.y ) { + return false; + } + + return r.y < this.y1; + }, + + intersectsRect : function( x,y,w,h ) { + if ( -1===w || -1===h ) { + return false; + } + + var x1= x+w-1; + var y1= y+h-1; + + if ( x1< this.x ) { + return false; + } + if ( x > this.x1 ) { + return false; + } + if ( y1< this.y ) { + return false; + } + return y <= this.y1; + + }, + + intersect : function( i, r ) { + if ( typeof r==='undefined' ) { + r= new CAAT.Math.Rectangle(); + } + + r.x= Math.max( this.x, i.x ); + r.y= Math.max( this.y, i.y ); + r.x1=Math.min( this.x1, i.x1 ); + r.y1=Math.min( this.y1, i.y1 ); + r.width= r.x1-r.x; + r.height=r.y1-r.y; + + return r; + } + } + } +}); diff --git a/CAAT/src/Modules/Audio/AudioManager.js b/CAAT/src/Modules/Audio/AudioManager.js new file mode 100644 index 0000000..ee2d145 --- /dev/null +++ b/CAAT/src/Modules/Audio/AudioManager.js @@ -0,0 +1,562 @@ +/** + * See LICENSE file. + * + * Sound implementation. + */ + +CAAT.Module({ + + /** + * @name Module + * @memberOf CAAT + * @namespace + */ + + /** + * @name Audio + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name AudioManager + * @memberOf CAAT.Module.Audio + * @constructor + */ + + defines:"CAAT.Module.Audio.AudioManager", + extendsWith:function () { + return { + + /** + * @lends CAAT.Module.Audio.AudioManager.prototype + */ + + __init:function () { + this.isFirefox= navigator.userAgent.match(/Firefox/g)!==null; + return this; + }, + + isFirefox : false, + + /** + * The only background music audio channel. + */ + musicChannel: null, + + /** + * Is music enabled ? + */ + musicEnabled:true, + + /** + * Are FX sounds enabled ? + */ + fxEnabled:true, + + /** + * A collection of Audio objects. + */ + audioCache:null, + + /** + * A cache of empty Audio objects. + */ + channels:null, + + /** + * Currently used Audio objects. + */ + workingChannels:null, + + /** + * Currently looping Audio objects. + */ + loopingChannels:[], + + /** + * available formats for audio elements. + * the system will load audio files with the extensions in this preferred order. + */ + audioFormatExtensions : [ + 'ogg', + 'wav', + 'x-wav', + 'mp3' + ], + + currentAudioFormatExtension : 'ogg', + + /** + * Audio formats. + * @dict + */ + audioTypes:{ // supported audio formats. Don't remember where i took them from :S + 'ogg': 'audio/ogg', + 'mp3': 'audio/mpeg;', + 'wav': 'audio/wav', + 'x-wav':'audio/x-wav', + 'mp4': 'audio/mp4"' + }, + + /** + * Initializes the sound subsystem by creating a fixed number of Audio channels. + * Every channel registers a handler for sound playing finalization. If a callback is set, the + * callback function will be called with the associated sound id in the cache. + * + * @param numChannels {number} number of channels to pre-create. 8 by default. + * + * @return this. + */ + initialize:function (numChannels ) { + + this.setAudioFormatExtensions( this.audioFormatExtensions ); + + this.audioCache = []; + this.channels = []; + this.workingChannels = []; + + for (var i = 0; i <= numChannels; i++) { + var channel = document.createElement('audio'); + + if (null !== channel) { + channel.finished = -1; + this.channels.push(channel); + var me = this; + channel.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + var i; + + // remove from workingChannels + for (i = 0; i < me.workingChannels.length; i++) { + if (me.workingChannels[i] === target) { + me.workingChannels.splice(i, 1); + break; + } + } + + if (target.caat_callback) { + target.caat_callback(target.caat_id); + } + + // set back to channels. + me.channels.push(target); + }, + false + ); + } + } + + this.musicChannel= this.channels.pop(); + + return this; + }, + + setAudioFormatExtensions : function( formats ) { + this.audioFormatExtensions= formats; + this.__setCurrentAudioFormatExtension(); + return this; + }, + + __setCurrentAudioFormatExtension : function( ) { + + var audio= new Audio(); + + for( var i= 0, l=this.audioFormatExtensions.length; i + * The audio element can be one of the two forms: + * + *
              + *
            1. Either an HTMLAudioElement/Audio object or a string url. + *
            2. An array of elements of the previous form. + *
            + * + *

            + * When the audio attribute is an array, this function will iterate throught the array elements + * until a suitable audio element to be played is found. When this is the case, the other array + * elements won't be taken into account. The valid form of using this addAudio method will be: + * + *

            + * 1.
            + * addAudio( id, url } ). In this case, if the resource pointed by url is + * not suitable to be played (i.e. a call to the Audio element's canPlayType method return 'no') + * no resource will be added under such id, so no sound will be played when invoking the play(id) + * method. + *

            + * 2.
            + * addAudio( id, dom_audio_tag ). In this case, the same logic than previous case is applied, but + * this time, the parameter url is expected to be an audio tag present in the html file. + *

            + * 3.
            + * addAudio( id, [array_of_url_or_domaudiotag] ). In this case, the function tries to locate a valid + * resource to be played in any of the elements contained in the array. The array element's can + * be any type of case 1 and 2. As soon as a valid resource is found, it will be associated to the + * id in the valid audio resources to be played list. + * + * @return this + */ + addAudio:function (id, array_of_url_or_domnodes, endplaying_callback) { + + if (array_of_url_or_domnodes instanceof Array) { + /* + iterate throught array elements until we can safely add an audio element. + */ + for (var i = 0; i < array_of_url_or_domnodes.length; i++) { + if (this.addAudioElement(id, array_of_url_or_domnodes[i], endplaying_callback)) { + break; + } + } + } else { + this.addAudioElement(id, array_of_url_or_domnodes, endplaying_callback); + } + + return this; + }, + /** + * Returns an audio object. + * @param aId {object} the id associated to the target Audio object. + * @return {object} the HTMLAudioElement addociated to the given id. + */ + getAudio:function (aId) { + for (var i = 0; i < this.audioCache.length; i++) { + if (this.audioCache[i].id === aId) { + return this.audioCache[i].audio; + } + } + + return null; + }, + + stopMusic : function() { + this.musicChannel.pause(); + }, + + playMusic : function(id) { + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio =this.musicChannel; + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, restart music. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + return audio; + } + } + + return this.musicChannel; + }, + + /** + * Set an audio object volume. + * @param id {object} an audio Id + * @param volume {number} volume to set. The volume value is not checked. + * + * @return this + */ + setVolume:function (id, volume) { + var audio = this.getAudio(id); + if (null != audio) { + audio.volume = volume; + } + + return this; + }, + + /** + * Plays an audio file from the cache if any sound channel is available. + * The playing sound will occupy a sound channel and when ends playing will leave + * the channel free for any other sound to be played in. + * @param id {object} an object identifying a sound in the sound cache. + * @return { id: {Object}, audio: {(Audio|HTMLAudioElement)} } + */ + play:function (id) { + if (!this.fxEnabled) { + return null; + } + + var audio = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio && this.channels.length > 0) { + var channel = this.channels.shift(); + channel.src = audio.src; +// channel.load(); + channel.volume = audio.volume; + channel.play(); + this.workingChannels.push(channel); + } else { + console.log("Can't play audio: "+id); + } + + return audio; + }, + + /** + * cancel all instances of a sound identified by id. This id is the value set + * to identify a sound. + * @param id + * @return {*} + */ + cancelPlay : function(id) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + var audio= this.workingChannels[i]; + if ( audio.caat_id===id ) { + audio.pause(); + this.channels.push(audio); + this.workingChannels.splice(i,1); + } + } + + return this; + }, + + /** + * cancel a channel sound + * @param audioObject + * @return {*} + */ + cancelPlayByChannel : function(audioObject) { + + for( var i=0 ; this.workingChannels.length; i++ ) { + if ( this.workingChannels[i]===audioObject ) { + this.channels.push(audioObject); + this.workingChannels.splice(i,1); + return this; + } + } + + return this; + }, + + /** + * This method creates a new AudioChannel to loop the sound with. + * It returns an Audio object so that the developer can cancel the sound loop at will. + * The user must call pause() method to stop playing a loop. + *

            + * Firefox does not honor the loop property, so looping is performed by attending end playing + * event on audio elements. + * + * @return {HTMLElement} an Audio instance if a valid sound id is supplied. Null otherwise + */ + loop:function (id) { + + if (!this.musicEnabled) { + return null; + } + + var audio_in_cache = this.getAudio(id); + // existe el audio, y ademas hay un canal de audio disponible. + if (null !== audio_in_cache) { + var audio = document.createElement('audio'); + if (null !== audio) { + audio.src = audio_in_cache.src; + audio.preload = "auto"; + + if (this.isFirefox) { + audio.addEventListener( + 'ended', + // on sound end, set channel to available channels list. + function (audioEvent) { + var target = audioEvent.target; + target.currentTime = 0; + }, + false + ); + } else { + audio.loop = true; + } + audio.load(); + audio.play(); + this.loopingChannels.push(audio); + return audio; + } + } + + return null; + }, + /** + * Cancel all playing audio channels + * Get back the playing channels to available channel list. + * + * @return this + */ + endSound:function () { + var i; + for (i = 0; i < this.workingChannels.length; i++) { + this.workingChannels[i].pause(); + this.channels.push(this.workingChannels[i]); + } + + for (i = 0; i < this.loopingChannels.length; i++) { + this.loopingChannels[i].pause(); + } + + this.workingChannels= []; + this.loopingChannels= []; + + this.stopMusic(); + + return this; + }, + setSoundEffectsEnabled:function (enable) { + this.fxEnabled = enable; + for (var i = 0; i < this.loopingChannels.length; i++) { + if (enable) { + this.loopingChannels[i].play(); + } else { + this.loopingChannels[i].pause(); + } + } + return this; + }, + isSoundEffectsEnabled:function () { + return this.fxEnabled; + }, + setMusicEnabled:function (enable) { + this.musicEnabled = enable; + this.stopMusic(); + return this; + }, + isMusicEnabled:function () { + return this.musicEnabled; + } + } + } +}); diff --git a/CAAT/src/Modules/CSS/csskeyframehelper.js b/CAAT/src/Modules/CSS/csskeyframehelper.js new file mode 100644 index 0000000..815e7e9 --- /dev/null +++ b/CAAT/src/Modules/CSS/csskeyframehelper.js @@ -0,0 +1,177 @@ +/** + * See LICENSE file. + * + * This object manages CSS3 transitions reflecting applying behaviors. + * + **/ + +(function() { + + /** + * @name CSS + * @memberOf CAAT + * @namespace + */ + + CAAT.CSS= {}; + + /** + * @lends CAAT.CSS + */ + + + /** + * Guess a browser custom prefix. + * @type {*} + */ + CAAT.CSS.PREFIX= (function() { + + var prefix = ""; + var prefixes = ['WebKit', 'Moz', 'O']; + var keyframes= ""; + + // guess this browser vendor prefix. + for (var i = 0; i < prefixes.length; i++) { + if (window[prefixes[i] + 'CSSKeyframeRule']) { + prefix = prefixes[i].toLowerCase(); + break; + } + } + + CAAT.CSS.PROP_ANIMATION= '-'+prefix+'-animation'; + + return prefix; + })(); + + /** + * Apply a given @key-frames animation to a DOM element. + * @param domElement {DOMElement} + * @param name {string} animation name + * @param duration_millis {number} + * @param delay_millis {number} + * @param forever {boolean} + */ + CAAT.CSS.applyKeyframe= function( domElement, name, duration_millis, delay_millis, forever ) { + domElement.style[CAAT.CSS.PROP_ANIMATION]= name+' '+(duration_millis/1000)+'s '+(delay_millis/1000)+'s linear both '+(forever ? 'infinite' : '') ; + }; + + /** + * Remove a @key-frames animation from the stylesheet. + * @param name + */ + CAAT.CSS.unregisterKeyframes= function( name ) { + var index= CAAT.CSS.getCSSKeyframesIndex(name); + if ( null!==index ) { + document.styleSheets[ index.sheetIndex ].deleteRule( index.index ); + } + }; + + /** + * + * @param kfDescriptor {object} + * { + * name{string}, + * behavior{CAAT.Behavior}, + * size{!number}, + * overwrite{boolean} + * } + * } + */ + CAAT.CSS.registerKeyframes= function( kfDescriptor ) { + + var name= kfDescriptor.name; + var behavior= kfDescriptor.behavior; + var size= kfDescriptor.size; + var overwrite= kfDescriptor.overwrite; + + if ( typeof name==='undefined' || typeof behavior==='undefined' ) { + throw 'Keyframes must be defined by a name and a CAAT.Behavior instance.'; + } + + if ( typeof size==='undefined' ) { + size= 100; + } + if ( typeof overwrite==='undefined' ) { + overwrite= false; + } + + // find if keyframes has already a name set. + var cssRulesIndex= CAAT.CSS.getCSSKeyframesIndex(name); + if (null!==cssRulesIndex && !overwrite) { + return; + } + + var keyframesRule= behavior.calculateKeyFramesData(CAAT.CSS.PREFIX, name, size, kfDescriptor.anchorX, kfDescriptor.anchorY ); + + if (document.styleSheets) { + if ( !document.styleSheets.length) { + var s = document.createElement('style'); + s.type="text/css"; + + document.getElementsByTagName('head')[ 0 ].appendChild(s); + } + + if ( null!==cssRulesIndex ) { + document.styleSheets[ cssRulesIndex.sheetIndex ].deleteRule( cssRulesIndex.index ); + } + + var index= cssRulesIndex ? cssRulesIndex.sheetIndex : 0; + document.styleSheets[ index ].insertRule( keyframesRule, 0 ); + } + + return keyframesRule; + }; + + CAAT.CSS.getCSSKeyframesIndex= function(name) { + var ss = document.styleSheets; + for (var i = ss.length - 1; i >= 0; i--) { + try { + var s = ss[i], + rs = s.cssRules ? s.cssRules : + s.rules ? s.rules : + []; + + for (var j = rs.length - 1; j >= 0; j--) { + if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE || + rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) { + + return { + sheetIndex : i, + index: j + }; + } + } + } catch(e) { + } + } + + return null; + }; + + CAAT.CSS.getCSSKeyframes= function(name) { + + var ss = document.styleSheets; + for (var i = ss.length - 1; i >= 0; i--) { + try { + var s = ss[i], + rs = s.cssRules ? s.cssRules : + s.rules ? s.rules : + []; + + for (var j = rs.length - 1; j >= 0; j--) { + if ( ( rs[j].type === window.CSSRule.WEBKIT_KEYFRAMES_RULE || + rs[j].type === window.CSSRule.MOZ_KEYFRAMES_RULE ) && rs[j].name === name) { + + return rs[j]; + } + } + } + catch(e) { + } + } + return null; + }; + + + +})(); diff --git a/CAAT/src/Modules/CircleManager/PackedCircle.js b/CAAT/src/Modules/CircleManager/PackedCircle.js new file mode 100644 index 0000000..f29ca27 --- /dev/null +++ b/CAAT/src/Modules/CircleManager/PackedCircle.js @@ -0,0 +1,197 @@ +/** + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ + */ + +CAAT.Module({ + + /** + * @name CircleManager + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name PackedCircle + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + defines:"CAAT.Module.CircleManager.PackedCircle", + depends:[ + "CAAT.Module.CircleManager.PackedCircle", + "CAAT.Math.Point" + ], + constants:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle + */ + + /** @const */ BOUNDS_RULE_WRAP:1, // Wrap to otherside + /** @const */ BOUNDS_RULE_CONSTRAINT:2, // Constrain within bounds + /** @const */ BOUNDS_RULE_DESTROY:4, // Destroy when it reaches the edge + /** @const */ BOUNDS_RULE_IGNORE:8 // Ignore when reaching bounds + }, + extendsWith:{ + + /** + * @lends CAAT.Module.CircleManager.PackedCircle.prototype + */ + + __init:function () { + this.boundsRule = CAAT.Module.CircleManager.PackedCircle.BOUNDS_RULE_IGNORE; + this.position = new CAAT.Math.Point(0, 0, 0); + this.offset = new CAAT.Math.Point(0, 0, 0); + this.targetPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * + */ + id:0, + + /** + * + */ + delegate:null, + + /** + * + */ + position:null, + + /** + * + */ + offset:null, + + /** + * + */ + targetPosition:null, // Where it wants to go + + /** + * + */ + targetChaseSpeed:0.02, + + /** + * + */ + isFixed:false, + + /** + * + */ + boundsRule:0, + + /** + * + */ + collisionMask:0, + + /** + * + */ + collisionGroup:0, + + containsPoint:function (aPoint) { + var distanceSquared = this.position.getDistanceSquared(aPoint); + return distanceSquared < this.radiusSquared; + }, + + getDistanceSquaredFromPosition:function (aPosition) { + var distanceSquared = this.position.getDistanceSquared(aPosition); + // if it's shorter than either radius, we intersect + return distanceSquared < this.radiusSquared; + }, + + intersects:function (aCircle) { + var distanceSquared = this.position.getDistanceSquared(aCircle.position); + return (distanceSquared < this.radiusSquared || distanceSquared < aCircle.radiusSquared); + }, + + /** + * ACCESSORS + */ + setPosition:function (aPosition) { + this.position = aPosition; + return this; + }, + + setDelegate:function (aDelegate) { + this.delegate = aDelegate; + return this; + }, + + setOffset:function (aPosition) { + this.offset = aPosition; + return this; + }, + + setTargetPosition:function (aTargetPosition) { + this.targetPosition = aTargetPosition; + return this; + }, + + setTargetChaseSpeed:function (aTargetChaseSpeed) { + this.targetChaseSpeed = aTargetChaseSpeed; + return this; + }, + + setIsFixed:function (value) { + this.isFixed = value; + return this; + }, + + setCollisionMask:function (aCollisionMask) { + this.collisionMask = aCollisionMask; + return this; + }, + + setCollisionGroup:function (aCollisionGroup) { + this.collisionGroup = aCollisionGroup; + return this; + }, + + setRadius:function (aRadius) { + this.radius = aRadius; + this.radiusSquared = this.radius * this.radius; + return this; + }, + + initialize:function (overrides) { + if (overrides) { + for (var i in overrides) { + this[i] = overrides[i]; + } + } + + return this; + }, + + dealloc:function () { + this.position = null; + this.offset = null; + this.delegate = null; + this.targetPosition = null; + } + } +}); diff --git a/CAAT/src/Modules/CircleManager/PackedCircleManager.js b/CAAT/src/Modules/CircleManager/PackedCircleManager.js new file mode 100644 index 0000000..7d417c2 --- /dev/null +++ b/CAAT/src/Modules/CircleManager/PackedCircleManager.js @@ -0,0 +1,397 @@ +/** + * + * See LICENSE file. + * + #### ##### ##### #### ### # # ###### ###### ## ## ##### # # ######## ## # # ##### + # # # # ### # # ##### ### ## ## ## # ## # # # # ## # ##### ### ### + ### # # ##### #### # # # ###### ## ######### ##### ##### ##### # ## # # # # # ##### + - + File: + PackedCircle.js + Created By: + Mario Gonzalez + Project : + None + Abstract: + A single packed circle. + Contains a reference to it's div, and information pertaining to it state. + Basic Usage: + http://onedayitwillmake.com/CirclePackJS/ +*/ + +CAAT.Module( { + + + /** + * @name PackedCircleManager + * @memberOf CAAT.Module.CircleManager + * @constructor + */ + + + defines : "CAAT.Module.CircleManager.PackedCircleManager", + depends : [ + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.CircleManager.PackedCircleManager.prototype + * @private + */ + + __init : function() { + this.bounds= new CAAT.Math.Rectangle(); + }, + + /** + * + */ + allCircles: [], + + /** + * + */ + numberOfCollisionPasses: 1, + + /** + * + */ + numberOfTargetingPasses: 0, + + /** + * + */ + bounds: null, + + /** + * Adds a circle to the simulation + * @param aCircle + */ + addCircle: function(aCircle) + { + aCircle.id = this.allCircles.length; + this.allCircles.push(aCircle); + return this; + }, + + /** + * Removes a circle from the simulations + * @param aCircle Circle to remove + */ + removeCircle: function(aCircle) + { + var index = 0, + found = false, + len = this.allCircles.length; + + if(len === 0) { + throw "Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!"; + } + + while (len--) { + if(this.allCircles[len] === aCircle) { + found = true; + index = len; + break; + } + } + + if(!found) { + throw "Could not locate circle in allCircles array!"; + } + + // Remove + this.allCircles[index].dealloc(); + this.allCircles[index] = null; + + return this; + }, + + /** + * Forces all circles to move to where their delegate position is + * Assumes all targets have a 'position' property! + */ + forceCirclesToMatchDelegatePositions: function() + { + var len = this.allCircles.length; + + // push toward target position + for(var n = 0; n < len; n++) + { + var aCircle = this.allCircles[n]; + if(!aCircle || !aCircle.delegate) { + continue; + } + + aCircle.position.set(aCircle.delegate.x + aCircle.offset.x, + aCircle.delegate.y + aCircle.offset.y); + } + }, + + pushAllCirclesTowardTarget: function(aTarget) + { + var v = new CAAT.Math.Point(0,0,0), + circleList = this.allCircles, + len = circleList.length; + + // push toward target position + for(var n = 0; n < this.numberOfTargetingPasses; n++) + { + for(var i = 0; i < len; i++) + { + var c = circleList[i]; + + if(c.isFixed) continue; + + v.x = c.position.x - (c.targetPosition.x+c.offset.x); + v.y = c.position.y - (c.targetPosition.y+c.offset.y); + v.multiply(c.targetChaseSpeed); + + c.position.x -= v.x; + c.position.y -= v.y; + } + } + }, + + /** + * Packs the circles towards the center of the bounds. + * Each circle will have it's own 'targetPosition' later on + */ + handleCollisions: function() + { + this.removeExpiredElements(); + + var v = new CAAT.Math.Point(0,0, 0), + circleList = this.allCircles, + len = circleList.length; + + // Collide circles + for(var n = 0; n < this.numberOfCollisionPasses; n++) + { + for(var i = 0; i < len; i++) + { + var ci = circleList[i]; + + + for (var j = i + 1; j< len; j++) + { + var cj = circleList[j]; + + if( !this.circlesCanCollide(ci, cj) ) continue; // It's us! + + var dx = cj.position.x - ci.position.x, + dy = cj.position.y - ci.position.y; + + // The distance between the two circles radii, but we're also gonna pad it a tiny bit + var r = (ci.radius + cj.radius) * 1.08, + d = ci.position.getDistanceSquared(cj.position); + + /** + * Collision detected! + */ + if (d < (r * r) - 0.02 ) + { + v.x = dx; + v.y = dy; + v.normalize(); + + var inverseForce = (r - Math.sqrt(d)) * 0.5; + v.multiply(inverseForce); + + // Move cj opposite of the collision as long as its not fixed + if(!cj.isFixed) + { + if(ci.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // ADD the velocity + cj.position.translatePoint(v); + } + + // Move ci opposite of the collision as long as its not fixed + if(!ci.isFixed) + { + if(cj.isFixed) + v.multiply(2.2); // Double inverse force to make up for the fact that the other object is fixed + + // SUBTRACT the velocity + ci.position.subtract(v); + } + + // Emit the collision event from each circle, with itself as the first parameter +// if(this.dispatchCollisionEvents && n == this.numberOfCollisionPasses-1) +// { +// this.eventEmitter.emit('collision', cj, ci, v); +// } + } + } + } + } + }, + + handleBoundaryForCircle: function(aCircle, boundsRule) + { +// if(aCircle.boundsRule === true) return; // Ignore if being dragged + + var xpos = aCircle.position.x; + var ypos = aCircle.position.y; + + var radius = aCircle.radius; + var diameter = radius*2; + + // Toggle these on and off, + // Wrap and bounce, are opposite behaviors so pick one or the other for each axis, or bad things will happen. + var wrapXMask = 1 << 0; + var wrapYMask = 1 << 2; + var constrainXMask = 1 << 3; + var constrainYMask = 1 << 4; + var emitEvent = 1 << 5; + + // TODO: Promote to member variable + // Convert to bitmask - Uncomment the one you want, or concact your own :) + // boundsRule = wrapY; // Wrap only Y axis + // boundsRule = wrapX; // Wrap only X axis + // boundsRule = wrapXMask | wrapYMask; // Wrap both X and Y axis + boundsRule = wrapYMask | constrainXMask; // Wrap Y axis, but constrain horizontally + + // Wrap X + if(boundsRule & wrapXMask && xpos-diameter > this.bounds.right) { + aCircle.position.x = this.bounds.left + radius; + } else if(boundsRule & wrapXMask && xpos+diameter < this.bounds.left) { + aCircle.position.x = this.bounds.right - radius; + } + // Wrap Y + if(boundsRule & wrapYMask && ypos-diameter > this.bounds.bottom) { + aCircle.position.y = this.bounds.top - radius; + } else if(boundsRule & wrapYMask && ypos+diameter < this.bounds.top) { + aCircle.position.y = this.bounds.bottom + radius; + } + + // Constrain X + if(boundsRule & constrainXMask && xpos+radius >= this.bounds.right) { + aCircle.position.x = aCircle.position.x = this.bounds.right-radius; + } else if(boundsRule & constrainXMask && xpos-radius < this.bounds.left) { + aCircle.position.x = this.bounds.left + radius; + } + + // Constrain Y + if(boundsRule & constrainYMask && ypos+radius > this.bounds.bottom) { + aCircle.position.y = this.bounds.bottom - radius; + } else if(boundsRule & constrainYMask && ypos-radius < this.bounds.top) { + aCircle.position.y = this.bounds.top + radius; + } + }, + + /** + * Given an x,y position finds circle underneath and sets it to the currently grabbed circle + * @param {Number} xpos An x position + * @param {Number} ypos A y position + * @param {Number} buffer A radiusSquared around the point in question where something is considered to match + */ + getCircleAt: function(xpos, ypos, buffer) + { + var circleList = this.allCircles; + var len = circleList.length; + var grabVector = new CAAT.Math.Point(xpos, ypos, 0); + + // These are set every time a better match i found + var closestCircle = null; + var closestDistance = Number.MAX_VALUE; + + // Loop thru and find the closest match + for(var i = 0; i < len; i++) + { + var aCircle = circleList[i]; + if(!aCircle) continue; + var distanceSquared = aCircle.position.getDistanceSquared(grabVector); + + if(distanceSquared < closestDistance && distanceSquared < aCircle.radiusSquared + buffer) + { + closestDistance = distanceSquared; + closestCircle = aCircle; + } + } + + return closestCircle; + }, + + circlesCanCollide: function(circleA, circleB) + { + if(!circleA || !circleB || circleA===circleB) return false; // one is null (will be deleted next loop), or both point to same obj. +// if(circleA.delegate == null || circleB.delegate == null) return false; // This circle will be removed next loop, it's entity is already removed + +// if(circleA.isFixed & circleB.isFixed) return false; +// if(circleA.delegate .clientID === circleB.delegate.clientID) return false; // Don't let something collide with stuff it owns + + // They dont want to collide +// if((circleA.collisionGroup & circleB.collisionMask) == 0) return false; +// if((circleB.collisionGroup & circleA.collisionMask) == 0) return false; + + return true; + }, +/** + * Accessors + */ + setBounds: function(x, y, w, h) + { + this.bounds.x = x; + this.bounds.y = y; + this.bounds.width = w; + this.bounds.height = h; + }, + + setNumberOfCollisionPasses: function(value) + { + this.numberOfCollisionPasses = value; + return this; + }, + + setNumberOfTargetingPasses: function(value) + { + this.numberOfTargetingPasses = value; + return this; + }, + +/** + * Helpers + */ + sortOnDistanceToTarget: function(circleA, circleB) + { + var valueA = circleA.getDistanceSquaredFromPosition(circleA.targetPosition); + var valueB = circleB.getDistanceSquaredFromPosition(circleA.targetPosition); + var comparisonResult = 0; + + if(valueA > valueB) comparisonResult = -1; + else if(valueA < valueB) comparisonResult = 1; + + return comparisonResult; + }, + +/** + * Memory Management + */ + removeExpiredElements: function() + { + // remove null elements + for (var k = this.allCircles.length; k >= 0; k--) { + if (this.allCircles[k] === null) + this.allCircles.splice(k, 1); + } + }, + + initialize : function(overrides) + { + if (overrides) + { + for (var i in overrides) + { + this[i] = overrides[i]; + } + } + + return this; + } + } +}); diff --git a/CAAT/src/Modules/Collision/Quadtree.js b/CAAT/src/Modules/Collision/Quadtree.js new file mode 100644 index 0000000..4dfd522 --- /dev/null +++ b/CAAT/src/Modules/Collision/Quadtree.js @@ -0,0 +1,130 @@ +/** + * See LICENSE file. + * + * This file contains the definition for objects QuadTree and HashMap. + * Quadtree offers an exact list of collisioning areas, while HashMap offers a list of potentially colliding + * elements. + * Specially suited for static content. + * + **/ + +CAAT.Module({ + + /** + * @name Collision + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name QuadTree + * @memberOf CAAT.Module.Collision + * @constructor + */ + + defines:"CAAT.Module.Collision.QuadTree", + depends:[ + "CAAT.Math.Rectangle" + ], + extendsClass:"CAAT.Math.Rectangle", + extendsWith:function () { + + var QT_MAX_ELEMENTS = 1; + var QT_MIN_WIDTH = 32; + + return { + + /** + * @lends CAAT.Module.Collision.QuadTree.prototype + */ + + /** + * For each quadtree level this keeps the list of overlapping elements. + */ + bgActors:null, + + /** + * For each quadtree, this quadData keeps another 4 quadtrees up to the maximum recursion level. + */ + quadData:null, + + create:function (l, t, r, b, backgroundElements, minWidth, maxElements) { + + if (typeof minWidth === 'undefined') { + minWidth = QT_MIN_WIDTH; + } + if (typeof maxElements === 'undefined') { + maxElements = QT_MAX_ELEMENTS; + } + + var cx = (l + r) / 2; + var cy = (t + b) / 2; + + this.x = l; + this.y = t; + this.x1 = r; + this.y1 = b; + this.width = r - l; + this.height = b - t; + + this.bgActors = this.__getOverlappingActorList(backgroundElements); + + if (this.bgActors.length <= maxElements || this.width <= minWidth) { + return this; + } + + this.quadData = new Array(4); + this.quadData[0] = new CAAT.Module.Collision.QuadTree().create(l, t, cx, cy, this.bgActors); // TL + this.quadData[1] = new CAAT.Module.Collision.QuadTree().create(cx, t, r, cy, this.bgActors); // TR + this.quadData[2] = new CAAT.Module.Collision.QuadTree().create(l, cy, cx, b, this.bgActors); // BL + this.quadData[3] = new CAAT.Module.Collision.QuadTree().create(cx, cy, r, b, this.bgActors); + + return this; + }, + + __getOverlappingActorList:function (actorList) { + var tmpList = []; + for (var i = 0, l = actorList.length; i < l; i++) { + var actor = actorList[i]; + if (this.intersects(actor.AABB)) { + tmpList.push(actor); + } + } + return tmpList; + }, + + /** + * Call this method to thet the list of colliding elements with the parameter rectangle. + * @param rectangle + * @return {Array} + */ + getOverlappingActors:function (rectangle) { + var i, j, l; + var overlappingActors = []; + var qoverlappingActors; + var actors = this.bgActors; + var actor; + + if (this.quadData) { + for (i = 0; i < 4; i++) { + if (this.quadData[i].intersects(rectangle)) { + qoverlappingActors = this.quadData[i].getOverlappingActors(rectangle); + for (j = 0, l = qoverlappingActors.length; j < l; j++) { + overlappingActors.push(qoverlappingActors[j]); + } + } + } + } else { + for (i = 0, l = actors.length; i < l; i++) { + actor = actors[i]; + if (rectangle.intersects(actor.AABB)) { + overlappingActors.push(actor); + } + } + } + + return overlappingActors; + } + } + } +}); diff --git a/CAAT/src/Modules/Collision/SpatialHash.js b/CAAT/src/Modules/Collision/SpatialHash.js new file mode 100644 index 0000000..5679fd8 --- /dev/null +++ b/CAAT/src/Modules/Collision/SpatialHash.js @@ -0,0 +1,239 @@ +CAAT.Module( { + + + /** + * @name SpatialHash + * @memberOf CAAT.Module.Collision + * @constructor + */ + + + defines : "CAAT.Module.Collision.SpatialHash", + aliases : ["CAAT.SpatialHash"], + depends : [ + "CAAT.Math.Rectangle" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Collision.SpatialHash.prototype + */ + + /** + * A collection ob objects to test collision among them. + */ + elements : null, + + /** + * Space width + */ + width : null, + + /** + * Space height + */ + height : null, + + /** + * Rows to partition the space. + */ + rows : null, + + /** + * Columns to partition the space. + */ + columns : null, + + xcache : null, + ycache : null, + xycache : null, + + rectangle : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r0 : null, + + /** + * Spare rectangle to hold temporary calculations. + */ + r1 : null, + + initialize : function( w,h, rows,columns ) { + + var i, j; + + this.elements= []; + for( i=0; i>0 ); + } + + this.ycache= []; + for( i=0; i>0 ); + } + + this.xycache=[]; + for( i=0; i1 ) { // at least 2 elements could collide + this._solveCollisionCell( cell, callback ); + } + } + }, + + _solveCollisionCell : function( cell, callback ) { + var i,j; + + for( i=0; i + * H runs from 0 to 360 degrees
            + * S and V run from 0 to 100 + *

            + * Ported from the excellent java algorithm by Eugene Vishnevsky at: + * http://www.cs.rit.edu/~ncs/color/t_convert.html + * + * @static + */ + hsvToRgb:function (h, s, v) { + var r, g, b, i, f, p, q, t; + + // Make sure our arguments stay in-range + h = Math.max(0, Math.min(360, h)); + s = Math.max(0, Math.min(100, s)); + v = Math.max(0, Math.min(100, v)); + + // We accept saturation and value arguments from 0 to 100 because that's + // how Photoshop represents those values. Internally, however, the + // saturation and value are calculated from a range of 0 to 1. We make + // That conversion here. + s /= 100; + v /= 100; + + if (s === 0) { + // Achromatic (grey) + r = g = b = v; + return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; + } + + h /= 60; // sector 0 to 5 + i = Math.floor(h); + f = h - i; // factorial part of h + p = v * (1 - s); + q = v * (1 - s * f); + t = v * (1 - s * (1 - f)); + + switch (i) { + case 0: + r = v; + g = t; + b = p; + break; + + case 1: + r = q; + g = v; + b = p; + break; + + case 2: + r = p; + g = v; + b = t; + break; + + case 3: + r = p; + g = q; + b = v; + break; + + case 4: + r = t; + g = p; + b = v; + break; + + default: // case 5: + r = v; + g = p; + b = q; + } + + return new CAAT.Module.ColorUtil.Color(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)); + }, + + /** + * Interpolate the color between two given colors. The return value will be a calculated color + * among the two given initial colors which corresponds to the 'step'th color of the 'nsteps' + * calculated colors. + * @param r0 {number} initial color red component. + * @param g0 {number} initial color green component. + * @param b0 {number} initial color blue component. + * @param r1 {number} final color red component. + * @param g1 {number} final color green component. + * @param b1 {number} final color blue component. + * @param nsteps {number} number of colors to calculate including the two given colors. If 16 is passed as value, + * 14 colors plus the two initial ones will be calculated. + * @param step {number} return this color index of all the calculated colors. + * + * @return { {r{number}, g{number}, b{number}} } return an object with the new calculated color components. + * @static + */ + interpolate:function (r0, g0, b0, r1, g1, b1, nsteps, step) { + + var r, g, b; + + if (step <= 0) { + return { + r:r0, + g:g0, + b:b0 + }; + } else if (step >= nsteps) { + return { + r:r1, + g:g1, + b:b1 + }; + } + + r = (r0 + (r1 - r0) / nsteps * step) >> 0; + g = (g0 + (g1 - g0) / nsteps * step) >> 0; + b = (b0 + (b1 - b0) / nsteps * step) >> 0; + + if (r > 255) { + r = 255; + } else if (r < 0) { + r = 0; + } + if (g > 255) { + g = 255; + } else if (g < 0) { + g = 0; + } + if (b > 255) { + b = 255; + } else if (b < 0) { + b = 0; + } + + return { + r:r, + g:g, + b:b + }; + }, + + /** + * Generate a ramp of colors from an array of given colors. + * @param fromColorsArray {[number]} an array of colors. each color is defined by an integer number from which + * color components will be extracted. Be aware of the alpha component since it will also be interpolated for + * new colors. + * @param rampSize {number} number of colors to produce. + * @param returnType {CAAT.ColorUtils.RampEnumeration} a value of CAAT.ColorUtils.RampEnumeration enumeration. + * + * @return { [{number},{number},{number},{number}] } an array of integers each of which represents a color of + * the calculated color ramp. + * + * @static + */ + makeRGBColorRamp:function (fromColorsArray, rampSize, returnType) { + + var ramp = [], nc = fromColorsArray.length - 1, chunk = rampSize / nc, i, j, + na, nr, ng, nb, + c, a0, r0, g0, b0, + c1, a1, r1, g1, b1, + da, dr, dg, db; + + for (i = 0; i < nc; i += 1) { + c = fromColorsArray[i]; + a0 = (c >> 24) & 0xff; + r0 = (c & 0xff0000) >> 16; + g0 = (c & 0xff00) >> 8; + b0 = c & 0xff; + + c1 = fromColorsArray[i + 1]; + a1 = (c1 >> 24) & 0xff; + r1 = (c1 & 0xff0000) >> 16; + g1 = (c1 & 0xff00) >> 8; + b1 = c1 & 0xff; + + da = (a1 - a0) / chunk; + dr = (r1 - r0) / chunk; + dg = (g1 - g0) / chunk; + db = (b1 - b0) / chunk; + + for (j = 0; j < chunk; j += 1) { + na = (a0 + da * j) >> 0; + nr = (r0 + dr * j) >> 0; + ng = (g0 + dg * j) >> 0; + nb = (b0 + db * j) >> 0; + + var re = CAAT.Module.ColorUtil.Color.RampEnumeration; + + switch (returnType) { + case re.RAMP_RGBA: + ramp.push('argb(' + na + ',' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_RGB: + ramp.push('rgb(' + nr + ',' + ng + ',' + nb + ')'); + break; + case re.RAMP_CHANNEL_RGB: + ramp.push(0xff000000 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA: + ramp.push(na << 24 | nr << 16 | ng << 8 | nb); + break; + case re.RAMP_CHANNEL_RGBA_ARRAY: + ramp.push([ nr, ng, nb, na ]); + break; + case re.RAMP_CHANNEL_RGB_ARRAY: + ramp.push([ nr, ng, nb ]); + break; + } + } + } + + return ramp; + + }, + + random:function () { + var a = '0123456789abcdef'; + var c = '#'; + for (var i = 0; i < 3; i++) { + c += a[ (Math.random() * a.length) >> 0 ]; + } + return c; + } + }, + + extendsWith:{ + __init:function (r, g, b) { + this.r = r || 255; + this.g = g || 255; + this.b = b || 255; + return this; + }, + + r:255, + g:255, + b:255, + + /** + * Get color hexadecimal representation. + * @return {string} a string with color hexadecimal representation. + */ + toHex:function () { + // See: http://jsperf.com/rgb-decimal-to-hex/5 + return ('000000' + ((this.r << 16) + (this.g << 8) + this.b).toString(16)).slice(-6); + } + } +}); diff --git a/CAAT/src/Modules/Debug/Debug.js b/CAAT/src/Modules/Debug/Debug.js new file mode 100644 index 0000000..fba2528 --- /dev/null +++ b/CAAT/src/Modules/Debug/Debug.js @@ -0,0 +1,465 @@ +/** + * See LICENSE file. + * + * Get realtime Debug information of CAAT's activity. + * Set CAAT.DEBUG=1 before any CAAT.Director object creation. + * This class creates a DOM node called 'caat-debug' and associated styles + * The debug panel is minimized by default and shows short information. It can be expanded and minimized again by clicking on it + * + */ + +CAAT.Module( { + + /** + * @name Debug + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Debug + * @memberOf CAAT.Module.Debug + * @constructor + */ + + defines : "CAAT.Module.Debug.Debug", + depends : [ + "CAAT.Event.AnimationLoop" + ], + extendsWith : { + + /** + * @lends CAAT.Module.Debug.Debug.prototype + */ + + width: 0, + height: 0, + canvas: null, + ctx: null, + statistics: null, + framerate: null, + textContainer: null, + textFPS: null, + textEntitiesTotal: null, + textEntitiesActive: null, + textDraws: null, + textDrawTime: null, + textRAFTime: null, + textDirtyRects: null, + textDiscardDR: null, + + frameTimeAcc : 0, + frameRAFAcc : 0, + + canDebug: false, + + SCALE: 60, + + debugTpl: + " "+ + "

            "+ + "
            "+ + " CAAT Debug panel "+ + " Performance"+ + " Controls"+ + " "+ + " "+ + " Draw Time: "+ + " 5.46"+ + " ms."+ + " "+ + " "+ + " "+ + " FPS: "+ + " 48"+ + " "+ + "
            "+ + "
            "+ + "
            "+ + " "+ + "
            "+ + " "+ + " "+ + " RAF Time:"+ + " 20.76"+ + " ms."+ + " "+ + " "+ + " "+ + " Entities Total: "+ + " 41"+ + " "+ + " "+ + " "+ + " Entities Active: "+ + " 37"+ + " "+ + " "+ + " "+ + " Draws: "+ + " 0"+ + " "+ + " "+ + " "+ + " DirtyRects: "+ + " 0"+ + " "+ + " "+ + " "+ + " Discard DR: "+ + " 0"+ + " "+ + "
            "+ + "
            "+ + "
            "+ + "
            "+ + "
            "+ + " "+ + " Sound"+ + "
            "+ + "
            "+ + " "+ + " Music"+ + "
            "+ + "
            "+ + " "+ + " AA Bounding Boxes"+ + "
            "+ + "
            "+ + " "+ + " Bounding Boxes"+ + "
            "+ + "
            "+ + " "+ + " Dirty Rects"+ + "
            "+ + "
            "+ + "
            "+ + "
            "+ + "
            ", + + + setScale : function(s) { + this.scale= s; + return this; + }, + + initialize: function(w,h) { + w= window.innerWidth; + + this.width= w; + this.height= h; + + this.framerate = { + refreshInterval: CAAT.FPS_REFRESH || 500, // refresh every ? ms, updating too quickly gives too large rounding errors + frames: 0, // number offrames since last refresh + timeLastRefresh: 0, // When was the framerate counter refreshed last + fps: 0, // current framerate + prevFps: -1, // previously drawn FPS + fpsMin: 1000, // minimum measured framerate + fpsMax: 0 // maximum measured framerate + }; + + var debugContainer= document.getElementById('caat-debug'); + if (!debugContainer) { + var wrap = document.createElement('div'); + wrap.innerHTML=this.debugTpl; + document.body.appendChild(wrap); + + eval( ""+ + " var __x= CAAT;" + + " function initCheck( name, bool, callback ) {"+ + " var elem= document.getElementById(name);"+ + " if ( elem ) {"+ + " elem.className= (bool) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " if ( callback ) {"+ + " elem.addEventListener( \"click\", (function(elem, callback) {"+ + " return function(e) {"+ + " elem.__value= !elem.__value;"+ + " elem.className= (elem.__value) ? \"checkbox_enabled\" : \"checkbox_disabled\";"+ + " callback(e,elem.__value);"+ + " }"+ + " })(elem, callback), false );"+ + " }"+ + " elem.__value= bool;"+ + " }"+ + " }"+ + " function setupTabs() {"+ + " var numTabs=0;"+ + " var elem;"+ + " var elemContent;"+ + " do {"+ + " elem= document.getElementById(\"caat-debug-tab\"+numTabs);"+ + " if ( elem ) {"+ + " elemContent= document.getElementById(\"caat-debug-tab\"+numTabs+\"-content\");"+ + " if ( elemContent ) {"+ + " elemContent.style.display= numTabs===0 ? 'block' : 'none';"+ + " elem.className= numTabs===0 ? \"debug_tab debug_tab_selected\" : \"debug_tab debug_tab_not_selected\";"+ + " elem.addEventListener( \"click\", (function(tabIndex) {"+ + " return function(e) {"+ + " for( var i=0; i this.framerate.timeLastRefresh + this.framerate.refreshInterval ) { + this.framerate.fps = ( ( this.framerate.frames * 1000 ) / ( tt - this.framerate.timeLastRefresh ) ) | 0; + this.framerate.fpsMin = this.framerate.frames > 0 ? Math.min( this.framerate.fpsMin, this.framerate.fps ) : this.framerate.fpsMin; + this.framerate.fpsMax = Math.max( this.framerate.fpsMax, this.framerate.fps ); + + this.textFPS.innerHTML= this.framerate.fps; + + var value= ((this.frameTimeAcc*100/this.framerate.frames)|0)/100; + this.frameTimeAcc=0; + this.textDrawTime.innerHTML= value; + + var value2= ((this.frameRAFAcc*100/this.framerate.frames)|0)/100; + this.frameRAFAcc=0; + this.textRAFTime.innerHTML= value2; + + this.framerate.timeLastRefresh = tt; + this.framerate.frames = 0; + + this.paint(value2); + } + + this.textEntitiesTotal.innerHTML= this.statistics.size_total; + this.textEntitiesActive.innerHTML= this.statistics.size_active; + this.textDirtyRects.innerHTML= this.statistics.size_dirtyRects; + this.textDraws.innerHTML= this.statistics.draws; + this.textDiscardDR.innerHTML= this.statistics.size_discarded_by_dirty_rects; + }, + + paint : function( rafValue ) { + var ctx= this.ctx; + var t=0; + + ctx.drawImage( + this.canvas, + 1, 0, this.width-1, this.height, + 0, 0, this.width-1, this.height ); + + ctx.strokeStyle= 'black'; + ctx.beginPath(); + ctx.moveTo( this.width-.5, 0 ); + ctx.lineTo( this.width-.5, this.height ); + ctx.stroke(); + + ctx.strokeStyle= '#a22'; + ctx.beginPath(); + t= this.height-((20/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + ctx.strokeStyle= '#aa2'; + ctx.beginPath(); + t= this.height-((30/this.SCALE*this.height)>>0)-.5; + ctx.moveTo( .5, t ); + ctx.lineTo( this.width+.5, t ); + ctx.stroke(); + + var fps = Math.min( this.height-(this.framerate.fps/this.SCALE*this.height), 59 ); + if (-1===this.framerate.prevFps) { + this.framerate.prevFps= fps|0; + } + + ctx.strokeStyle= '#0ff';//this.framerate.fps<15 ? 'red' : this.framerate.fps<30 ? 'yellow' : 'green'; + ctx.beginPath(); + ctx.moveTo( this.width, (fps|0)-.5 ); + ctx.lineTo( this.width, this.framerate.prevFps-.5 ); + ctx.stroke(); + + this.framerate.prevFps= fps; + + + var t1= ((this.height-(rafValue/this.SCALE*this.height))>>0)-.5; + ctx.strokeStyle= '#ff0'; + ctx.beginPath(); + ctx.moveTo( this.width, t1 ); + ctx.lineTo( this.width, t1 ); + ctx.stroke(); + } + } + +}); diff --git a/CAAT/src/Modules/Font/Font.js b/CAAT/src/Modules/Font/Font.js new file mode 100644 index 0000000..51328f5 --- /dev/null +++ b/CAAT/src/Modules/Font/Font.js @@ -0,0 +1,379 @@ +/** + * See LICENSE file. + * + **/ + +CAAT.Module({ + + /** + * @name Font + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name Font + * @memberOf CAAT.Module.Font + * @constructor + */ + + defines : "CAAT.Module.Font.Font", + aliases : "CAAT.Font", + depends : [ + "CAAT.Foundation.SpriteImage" + ], + constants: { + + /** + * @lends CAAT.Module.Font.Font + */ + + getFontMetrics:function (font) { + var ret; + if (CAAT.CSS_TEXT_METRICS) { + try { + ret = CAAT.Module.Font.Font.getFontMetricsCSS(font); + return ret; + } catch (e) { + + } + } + + return CAAT.Module.Font.Font.getFontMetricsNoCSS(font); + }, + + getFontMetricsNoCSS:function (font) { + + var re = /(\d+)p[x|t]\s*/i; + var res = re.exec(font); + + var height; + + if (!res) { + height = 32; // no px or pt value in font. assume 32.) + } else { + height = res[1] | 0; + } + + var ascent = height - 1; + var h = (height + height * .2) | 0; + return { + height:h, + ascent:ascent, + descent:h - ascent + } + + }, + + /** + * Totally ripped from: + * + * jQuery (offset function) + * Daniel Earwicker: http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas + * + * @param font + * @return {*} + */ + getFontMetricsCSS:function (font) { + + function offset(elem) { + + var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left; + var doc = elem && elem.ownerDocument; + docElem = doc.documentElement; + + box = elem.getBoundingClientRect(); + //win = getWindow( doc ); + + body = document.body; + win = doc.nodeType === 9 ? doc.defaultView || doc.parentWindow : false; + + clientTop = docElem.clientTop || body.clientTop || 0; + clientLeft = docElem.clientLeft || body.clientLeft || 0; + scrollTop = win.pageYOffset || docElem.scrollTop; + scrollLeft = win.pageXOffset || docElem.scrollLeft; + top = box.top + scrollTop - clientTop; + left = box.left + scrollLeft - clientLeft; + + return { top:top, left:left }; + } + + try { + var text = document.createElement("span"); + text.style.font = font; + text.innerHTML = "Hg"; + + var block = document.createElement("div"); + block.style.display = "inline-block"; + block.style.width = "1px"; + block.style.heigh = "0px"; + + var div = document.createElement("div"); + div.appendChild(text); + div.appendChild(block); + + + var body = document.body; + body.appendChild(div); + + try { + + var result = {}; + + block.style.verticalAlign = 'baseline'; + result.ascent = offset(block).top - offset(text).top; + + block.style.verticalAlign = 'bottom'; + result.height = offset(block).top - offset(text).top; + + result.ascent = Math.ceil(result.ascent); + result.height = Math.ceil(result.height); + + result.descent = result.height - result.ascent; + + return result; + + } finally { + body.removeChild(div); + } + } catch (e) { + return null; + } + } + }, + extendsWith:function () { + + var UNKNOWN_CHAR_WIDTH = 10; + + return { + + /** + * @lends CAAT.Module.Font.Font.prototype + */ + + fontSize:10, + fontSizeUnit:"px", + font:'Sans-Serif', + fontStyle:'', + fillStyle:'#fff', + strokeStyle:null, + strokeSize:1, + padding:0, + image:null, + charMap:null, + + height:0, + ascent:0, + descent:0, + + setPadding:function (padding) { + this.padding = padding; + return this; + }, + + setFontStyle:function (style) { + this.fontStyle = style; + return this; + }, + + setStrokeSize:function (size) { + this.strokeSize = size; + return this; + }, + + setFontSize:function (fontSize) { + this.fontSize = fontSize; + this.fontSizeUnit = 'px'; + return this; + }, + + setFont:function (font) { + this.font = font; + return this; + }, + + setFillStyle:function (style) { + this.fillStyle = style; + return this; + }, + + setStrokeStyle:function (style) { + this.strokeStyle = style; + return this; + }, + + createDefault:function (padding) { + var str = ""; + for (var i = 32; i < 128; i++) { + str = str + String.fromCharCode(i); + } + + return this.create(str, padding); + }, + + create:function (chars, padding) { + + padding = padding | 0; + this.padding = padding; + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + ctx.textBaseline = 'bottom'; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + + var textWidth = 0; + var charWidth = []; + var i; + var x; + var cchar; + + for (i = 0; i < chars.length; i++) { + var cw = Math.max(1, (ctx.measureText(chars.charAt(i)).width >> 0) + 1) + 2 * padding; + charWidth.push(cw); + textWidth += cw; + } + + + var fontMetrics = CAAT.Font.getFontMetrics(ctx.font); + var baseline = "alphabetic", yoffset, canvasheight; + + canvasheight = fontMetrics.height; + this.ascent = fontMetrics.ascent; + this.descent = fontMetrics.descent; + this.height = fontMetrics.height; + yoffset = fontMetrics.ascent; + + canvas.width = textWidth; + canvas.height = canvasheight; + ctx = canvas.getContext('2d'); + + //ctx.textBaseline= 'bottom'; + ctx.textBaseline = baseline; + ctx.font = this.fontStyle + ' ' + this.fontSize + "" + this.fontSizeUnit + " " + this.font; + ctx.fillStyle = this.fillStyle; + ctx.strokeStyle = this.strokeStyle; + + this.charMap = {}; + + x = 0; + for (i = 0; i < chars.length; i++) { + cchar = chars.charAt(i); + ctx.fillText(cchar, x + padding, yoffset); + if (this.strokeStyle) { + ctx.beginPath(); + ctx.lineWidth = this.strokeSize; + ctx.strokeText(cchar, x + padding, yoffset); + } + this.charMap[cchar] = { + x:x + padding, + width:charWidth[i] - 2 * padding, + height: this.height + }; + x += charWidth[i]; + } + + this.image = canvas; + + return this; + }, + + setAsSpriteImage:function () { + var cm = []; + var _index = 0; + for (var i in this.charMap) { + var _char = i; + var charData = this.charMap[i]; + + cm[i] = { + id:_index++, + height:this.height, + xoffset:0, + letter:_char, + yoffset:0, + width:charData.width, + xadvance:charData.width, + x:charData.x, + y:0 + }; + } + + this.spriteImage = new CAAT.Foundation.SpriteImage().initializeAsGlyphDesigner(this.image, cm); + return this; + }, + + getAscent:function () { + return this.ascent; + }, + + getDescent:function () { + return this.descent; + }, + + stringHeight:function () { + return this.height; + }, + + getFontData:function () { + return { + height:this.height, + ascent:this.ascent, + descent:this.descent + }; + }, + + stringWidth:function (str) { + var i, l, w = 0, c; + + for (i = 0, l = str.length; i < l; i++) { + c = this.charMap[ str.charAt(i) ]; + if (c) { + w += c.width; + } else { + w += UNKNOWN_CHAR_WIDTH; + } + } + + return w; + }, + + drawText:function (str, ctx, x, y) { + var i, l, charInfo, w; + var height = this.image.height; + + for (i = 0, l = str.length; i < l; i++) { + charInfo = this.charMap[ str.charAt(i) ]; + if (charInfo) { + w = charInfo.width; + if ( w>0 && charInfo.height>0 ) { + ctx.drawImage( + this.image, + charInfo.x, 0, + w, height, + x, y, + w, height); + } + x += w; + } else { + ctx.strokeStyle = '#f00'; + ctx.strokeRect(x, y, UNKNOWN_CHAR_WIDTH, height); + x += UNKNOWN_CHAR_WIDTH; + } + } + }, + + save:function () { + var str = "image/png"; + var strData = this.image.toDataURL(str); + document.location.href = strData.replace(str, "image/octet-stream"); + }, + + drawSpriteText:function (director, time) { + this.spriteImage.drawSpriteText(director, time); + } + + } + } + +}); + diff --git a/CAAT/src/Modules/Image/ImageProcess/IMBumpMapping.js b/CAAT/src/Modules/Image/ImageProcess/IMBumpMapping.js new file mode 100644 index 0000000..55ef118 --- /dev/null +++ b/CAAT/src/Modules/Image/ImageProcess/IMBumpMapping.js @@ -0,0 +1,267 @@ +CAAT.Module({ + + + /** + * @name IMBumpMapping + * @memberOf CAAT.Module.Image.ImageProcessor + * @extends CAAT.Module.Image.ImageProcessor.ImageProcessor + * @constructor + */ + + + defines : "CAAT.Module.Image.ImageProcess.IMBumpMapping", + depends : [ + "CAAT.Module.Image.ImageProcess.ImageProcessor" + ], + extendsClass : "CAAT.Module.Image.ImageProcess.ImageProcessor", + extendsWith : { + + /** + * @lends CAAT.Module.Image.ImageProcessor.IMBumpMapping.prototype + */ + + // bump + m_avgX: null, + m_avgY: null, + m_tt: null, + phong: null, + + m_radius: 75, + + m_lightcolor: null, + bcolor: false, + lightPosition: [], + + /** + * Initializes internal bump effect data. + * + * @param image {HTMLImageElement} + * @param radius {number} lights radius. + * + * @private + */ + prepareBump : function(image, radius) { + var i,j; + + this.m_radius= (radius ? radius : 75); + + var imageData= this.grabPixels(image); + + this.m_tt= this.makeArray(this.height,0); + for( i=0; i=this.m_radius) { + dx=this.m_radius-1; + } + if (dy>=this.m_radius) { + dy=this.m_radius-1; + } + + var c= this.phong[ dx ] [ dy ]; + var r=0; + var g=0; + var b=0; + + if ( c>=0 ) {// oscurecer + r= (this.m_lightcolor[k][0]*c/128); + g= (this.m_lightcolor[k][1]*c/128); + b= (this.m_lightcolor[k][2]*c/128); + } + else { // blanquear. + c=128+c; + var rr= (this.m_lightcolor[k][0]); + var gg= (this.m_lightcolor[k][1]); + var bb= (this.m_lightcolor[k][2]); + + r= Math.floor(rr+ (255-rr)*c/128); + g= Math.floor(gg+ (255-gg)*c/128); + b= Math.floor(bb+ (255-bb)*c/128); + } + + rrr+=r; + ggg+=g; + bbb+=b; + } + + if ( rrr>255 ) { + rrr=255; + } + if ( ggg>255 ) { + ggg=255; + } + if ( bbb>255 ) { + bbb=255; + } + + var pos= (j+this.m_tt[i])*4; + dstPixels[pos ]= rrr; + dstPixels[pos+1]= ggg; + dstPixels[pos+2]= bbb; + dstPixels[pos+3]= 255; + } + } + }, + /** + * Sets lights color. + * @param colors_rgb_array an array of arrays. Each internal array has three integers defining an RGB color. + * ie: + * [ + * [ 255,0,0 ], + * [ 0,255,0 ] + * ] + * @return this + */ + setLightColors : function( colors_rgb_array ) { + this.m_lightcolor= colors_rgb_array; + this.lightPosition= []; + for( var i=0; i + * This image processor creates a color ramp of 256 elements from the colors of the parameter 'colors'. + * Be aware of color definition since the alpha values count to create the ramp. + * + * @param width {number} + * @param height {number} + * @param colors {Array.} an array of color values. + * + * @return this + */ + initialize : function(width,height,colors) { + CAAT.IMPlasma.superclass.initialize.call(this,width,height); + + this.wavetable= []; + for (var x=0; x<256; x++) { + this.wavetable.push( Math.floor(32 * (1 + Math.cos(x*2 * Math.PI / 256))) ); + } + + this.pos1=Math.floor(255*Math.random()); + this.pos2=Math.floor(255*Math.random()); + this.pos3=Math.floor(255*Math.random()); + this.pos4=Math.floor(255*Math.random()); + + this.m_colorMap= CAAT.Module.ColorUtil.Color.makeRGBColorRamp( + colors!==null ? colors : this.color, + 256, + CAAT.Module.ColorUtil.Color.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY ); + + this.setB(); + + return this; + }, + /** + * Initialize internal plasma structures. Calling repeatedly this method will make the plasma + * look different. + */ + setB : function() { + + this.b1= Math.random()>0.5; + this.b2= Math.random()>0.5; + this.b3= Math.random()>0.5; + this.b4= Math.random()>0.5; + + this.spd1= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1)); + this.spd2= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1)); + this.spd3= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1)); + this.spd4= Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1)); + + this.i1= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1)); + this.i2= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1)); + this.i3= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1)); + this.i4= Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1)); + }, + /** + * Apply image processing to create the plasma and call superclass's apply to make the result + * visible. + * @param director {CAAT.Director} + * @param time {number} + * + * @return this + */ + apply : function(director,time) { + + var v = 0; + this.tpos1 = this.pos1; + this.tpos2 = this.pos2; + + var bi= this.bufferImage; + var cm= this.m_colorMap; + var wt= this.wavetable; + var z; + var cmz; + + for (var x=0; x> 1); + break; + case 2: + hh = this.height - 1; + break; + } + + switch (this.m_alignv) { + case 0: + ww = 0; + break; + case 1: + ww = (this.width >> 1); + break; + case 2: + ww = this.width - 1; + break; + } + + var i = (((this.width >> 1) << 8) - ddx * ww + ddy * hh)&0xffff; + var j = (((this.height >> 1) << 8) - ddy * ww - ddx * hh) & 0xffff; + + var srcwidth= this.sourceImageData.width; + var srcheight= this.sourceImageData.height; + var srcdata= this.sourceImageData.data; + var bi= this.bufferImage; + var dstoff; + var addx; + var addy; + + while (off < this.width * this.height * 4) { + addx = i; + addy = j; + + for (var m = 0; m < this.width; m++) { + dstoff = ((addy >> this.shift) & this.mask) * srcwidth + ((addx >> this.shift) & this.mask); + dstoff <<= 2; + + bi[ off++ ] = srcdata[ dstoff++ ]; + bi[ off++ ] = srcdata[ dstoff++ ]; + bi[ off++ ] = srcdata[ dstoff++ ]; + bi[ off++ ] = srcdata[ dstoff++ ]; + + addx += ddx; + addy += ddy; + + } + + dist += this.distortion; + i -= ddy; + j += ddx - dist; + } + }, + /** + * Perform and apply the rotozoom effect. + * @param director {CAAT.Director} + * @param time {number} + * @return this + */ + applyIM : function(director,time) { + if ( null!==this.sourceImageData ) { + this.rotoZoom(director,time); + } + return CAAT.Module.Image.ImageProcess.IMRotoZoom.superclass.applyIM.call(this,director,time); + }, + /** + * Change the effect's rotation anchor. Call this method repeatedly to make the effect look + * different. + */ + setCenter: function() { + var d = Math.random(); + if (d < 0.33) { + this.m_alignv = 0; + } else if (d < 0.66) { + this.m_alignv = 1; + } else { + this.m_alignv = 2; + } + + d = Math.random(); + if (d < 0.33) { + this.m_alignh = 0; + } else if (d < 0.66) { + this.m_alignh = 1; + } else { + this.m_alignh = 2; + } + } + + } +}); diff --git a/CAAT/src/Modules/Image/ImageProcess/ImageProcessor.js b/CAAT/src/Modules/Image/ImageProcess/ImageProcessor.js new file mode 100644 index 0000000..3b082ea --- /dev/null +++ b/CAAT/src/Modules/Image/ImageProcess/ImageProcessor.js @@ -0,0 +1,199 @@ +CAAT.Module({ + + /** + * @name Image + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name ImageProcessor + * @memberOf CAAT.Module.Image + * @namespace + */ + + /** + * @name ImageProcessor + * @memberOf CAAT.Module.Image.ImageProcessor + * @constructor + */ + + + defines : "CAAT.Module.Image.ImageProcessor.ImageProcessor", + extendsWith : { + + /** + * @lends CAAT.Module.Image.ImageProcessor.ImageProcessor.prototype + */ + + canvas: null, + ctx: null, + width: 0, + height: 0, + imageData: null, + bufferImage:null, + + /** + * Grabs an image pixels. + * + * @param image {HTMLImageElement} + * @return {ImageData} returns an ImageData object with the image representation or null in + * case the pixels can not be grabbed. + * + * @static + */ + grabPixels : function(image) { + var canvas= document.createElement('canvas'); + if ( canvas!==null ) { + canvas.width= image.width; + canvas.height= image.height; + var ctx= canvas.getContext('2d'); + ctx.drawImage(image,0,0); + try { + var imageData= ctx.getImageData(0,0,canvas.width,canvas.height); + return imageData; + } + catch(e) { + CAAT.log('error pixelgrabbing.', image); + return null; + } + } + return null; + }, + /** + * Helper method to create an array. + * + * @param size {number} integer number of elements in the array. + * @param initValue {number} initial array values. + * + * @return {[]} an array of 'initialValue' elements. + * + * @static + */ + makeArray : function(size, initValue) { + var a= []; + + for(var i=0; i} + */ + images: null, + + /** + * notification callback invoked for each image loaded. + */ + notificationCallback: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Start images loading asynchronous process. This method will notify every image loaded event + * and is responsibility of the caller to count the number of loaded images to see if it fits his + * needs. + * + * @param aImages {{ id:{url}, id2:{url}, ...} an object with id/url pairs. + * @param callback_loaded_one_image {function( imageloader {CAAT.ImagePreloader}, counter {number}, images {{ id:{string}, image: {Image}}} )} + * function to call on every image load. + */ + loadImages: function( aImages, callback_loaded_one_image, callback_error ) { + + if (!aImages) { + if (callback_loaded_one_image ) { + callback_loaded_one_image(0,[]); + } + } + + var me= this, i; + this.notificationCallback = callback_loaded_one_image; + this.images= []; + for( i=0; i} + */ + elements: null, + + /** + * elements counter. + */ + imageCounter: 0, + + /** + * Callback finished loading. + */ + cfinished: null, + + /** + * Callback element loaded. + */ + cloaded: null, + + /** + * Callback error loading. + */ + cerrored: null, + + /** + * loaded elements count. + */ + loadedCount: 0, + + baseURL : null, + + addElement : function( id, path ) { + this.elements.push( new descriptor(id,this.baseURL+path,this) ); + return this; + }, + + clear : function() { + for( var i=0; i>= 0; + + var atop = true; + var abottom = true; + var aleft = true; + var aright = true; + if (typeof areas !== 'undefined') { + if (typeof areas.top !== 'undefined') { + atop = areas.top; + } + if (typeof areas.bottom !== 'undefined') { + abottom = areas.bottom; + } + if (typeof areas.left !== 'undefined') { + aleft = areas.left; + } + if (typeof areas.right !== 'undefined') { + aright = areas.right; + } + } + + + var canvas = document.createElement('canvas'); + canvas.width = image.width; + canvas.height = image.height; + var ctx = canvas.getContext('2d'); + + ctx.fillStyle = 'rgba(0,0,0,0)'; + ctx.fillRect(0, 0, image.width, image.height); + ctx.drawImage(image, 0, 0); + + var imageData = ctx.getImageData(0, 0, image.width, image.height); + var data = imageData.data; + + var i, j; + var miny = 0, maxy = canvas.height - 1; + var minx = 0, maxx = canvas.width - 1; + + var alpha = false; + + if (atop) { + for (i = 0; i < canvas.height; i++) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + // i contiene el indice del ultimo scan que no es transparente total. + miny = i; + } + + if (abottom) { + alpha = false; + for (i = canvas.height - 1; i >= miny; i--) { + for (j = 0; j < canvas.width; j++) { + if (data[i * canvas.width * 4 + 3 + j * 4] > threshold) { + alpha = true; + break; + } + } + + if (alpha) { + break; + } + } + maxy = i; + } + + if (aleft) { + alpha = false; + for (j = 0; j < canvas.width; j++) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + minx = j; + } + + if (aright) { + alpha = false; + for (j = canvas.width - 1; j >= minx; j--) { + for (i = miny; i <= maxy; i++) { + if (data[i * canvas.width * 4 + 3 + j * 4 ] > threshold) { + alpha = true; + break; + } + } + if (alpha) { + break; + } + } + maxx = j; + } + + if (0 === minx && 0 === miny && canvas.width - 1 === maxx && canvas.height - 1 === maxy) { + return canvas; + } + + var width = maxx - minx + 1; + var height = maxy - miny + 1; + var id2 = ctx.getImageData(minx, miny, width, height); + + canvas.width = width; + canvas.height = height; + ctx = canvas.getContext('2d'); + ctx.putImageData(id2, 0, 0); + + return canvas; + }, + + + createThumb:function (image, w, h, best_fit) { + w = w || 24; + h = h || 24; + var canvas = document.createElement('canvas'); + canvas.width = w; + canvas.height = h; + var ctx = canvas.getContext('2d'); + + if (best_fit) { + var max = Math.max(image.width, image.height); + var ww = image.width / max * w; + var hh = image.height / max * h; + ctx.drawImage(image, (w - ww) / 2, (h - hh) / 2, ww, hh); + } else { + ctx.drawImage(image, 0, 0, w, h); + } + + return canvas; + } + } + +}) diff --git a/CAAT/src/Modules/Initialization/Template.js b/CAAT/src/Modules/Initialization/Template.js new file mode 100644 index 0000000..082139f --- /dev/null +++ b/CAAT/src/Modules/Initialization/Template.js @@ -0,0 +1,90 @@ +CAAT.Module({ + defines : "CAAT.Module.Initialization.Template", + depends : [ + "CAAT.Foundation.Director", + "CAAT.Module.Preloader.ImagePreloader" + ], + constants: { + init : function( width, height, runHere, imagesURL, onEndLoading ) { + + var canvascontainer= document.getElementById(runHere); + var director; + + if ( CAAT.__CSS__ ) { // css renderer + if ( canvascontainer ) { + if ( false===canvascontainer instanceof HTMLDivElement ) { + canvascontainer= null; + } + } + + if ( canvascontainer===null ) { + canvascontainer= document.createElement('div'); // create a new DIV + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + + } else { + + if ( canvascontainer ) { + if ( canvascontainer instanceof HTMLDivElement ) { + var ncanvascontainer= document.createElement("canvas"); + canvascontainer.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } else if ( false==canvascontainer instanceof HTMLCanvasElement ) { + var ncanvascontainer= document.createElement("canvas"); + document.body.appendChild(ncanvascontainer); + canvascontainer= ncanvascontainer; + } + } else { + canvascontainer= document.createElement('canvas'); + document.body.appendChild(canvascontainer); + } + + director= new CAAT.Foundation.Director(). + initialize( + width||800, + height||600, + canvascontainer); + } + + /** + * Load splash images. It is supossed the splash has some images. + */ + new CAAT.Module.Preloader.ImagePreloader().loadImages( + imagesURL, + function on_load( counter, images ) { + + if ( counter===images.length ) { + + director.emptyScenes(); + director.setImagesCache(images); + + onEndLoading(director); + + /** + * Change this sentence's parameters to play with different entering-scene + * curtains. + * just perform a director.setScene(0) to play first director's scene. + */ + director.easeIn( + 0, + CAAT.Foundation.Scene.EASE_SCALE, + 2000, + false, + CAAT.Foundation.Actor.ANCHOR_CENTER, + new CAAT.Behavior.Interpolator().createElasticOutInterpolator(2.5, .4) ); + + CAAT.loop(60); + + } + } + ); + + } + } +}); diff --git a/CAAT/src/Modules/Initialization/TemplateWithSplash.js b/CAAT/src/Modules/Initialization/TemplateWithSplash.js new file mode 100644 index 0000000..8959de6 --- /dev/null +++ b/CAAT/src/Modules/Initialization/TemplateWithSplash.js @@ -0,0 +1,182 @@ +CAAT.Module({ + defines : "CAAT.Module.Initialization.TemplateWithSplash", + depends : [ + "CAAT.Foundation.Director", + "CAAT.Module.Preloader.ImagePreloader" + ], + constants: { + + init : function( width, height, runHere, minTime, imagesURL, onEndSplash, splash_path, spinner_path ) { + + function createSplashScene(director, showTime, sceneCreationCallback) { + + var spinnerImg= director.getImage('spinner'); + var splashImg= director.getImage('splash'); + var scene= director.createScene(); + var TIME= showTime; + var time= new Date().getTime(); + + if ( splashImg ) { + scene.addChild( + new CAAT.Foundation.Actor(). + setBackgroundImage(splashImg, false). + setBounds(0,0,director.width,director.height). + setImageTransformation( CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE ) + ); + } + + if ( spinnerImg ) { + scene.addChild( + new CAAT.Foundation.Actor(). + setBackgroundImage(spinnerImg). + centerAt( scene.width/2, scene.height/2). + addBehavior( + new CAAT.Behavior.RotateBehavior(). + setValues(0,2*Math.PI). + setFrameTime(0,1000). + setCycle(true) + ) + ); + } + + scene.loadedImage = function(count, images) { + + if ( !images || count===images.length ) { + + var difftime= new Date().getTime()-time; + if ( difftime
          • a ResouceBundle object will honor browser/system locale by searching for these strings in + * the navigator object to define the value of currentLocale: + * + *
              navigator.language + *
                navigator.browserLanguage + *
                  navigator.systemLanguage + *
                    navigator.userLanguage + * + *
                  • the ResouceBundle class will also get defaultLocale value, and set the corresponding key + * as default Locale. + * + *
                  • a call to getString(id,defaultValue) will work as follows: + * + *
                    +             *   1)     will get the value associated in currentLocale[id]
                    +             *   2)     if the value is set, it is returned.
                    +             *   2.1)       else if it is not set, will get the value from defaultLocale[id] (sort of fallback)
                    +             *   3)     if the value of defaultLocale is set, it is returned.
                    +             *   3.1)       else defaultValue is returned.
                    +             * 
                    + * + * @param resourceFile + * @param asynch + * @param onSuccess + * @param onError + * @return {*} + * @private + */ + __init : function( resourceFile, asynch, onSuccess, onError ) { + + this.loadDoc( resourceFile, asynch, onSuccess, onError ); + if ( this.valid ) { + try { + var locale= navigator.language || navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage; + this.__currentLocale= this.localeInfo[locale]; + this.__defaultLocale= this.localeInfo["defaultLocale"]; + + if ( typeof this.__currentLocale==='undefined' ) { + this.__currentLocale= this.__defaultLocale; + } + + if ( !this.__currentLocale ) { + onError("No available default or system defined locale('"+locale+"'"); + } + + this.valid= false; + + } catch(e) { + onError("No default locale"); + this.valid= false; + } + } + + return this; + }, + + /** + * A formated string is a regular string that has embedded holder for string values. + * for example a string like: + * + * "hi this is a $2 $1" + * + * will be after calling __formatString( str, ["string","parameterized"] ); + * + * "hi this is a parameterized string" + * + * IMPORTANT: Holder values start in 1. + * + * @param string {string} a parameterized string + * @param args {object} object whose keys are used to find holders and replace them in string parameter + * @return {string} + * @private + */ + __formatString : function( string, args ) { + + if ( !args ) { + return string; + } + + for( var key in args ) { + string= string.replace("$"+key, args[key]); + } + + return string; + + }, + + /** + * + * @param id {string} a key from the bundle file. + * @param defaultValue {string} default value in case + * @param args {Array.=} optional arguments array in case the returned string is a + * parameterized string. + * + * @return {string} + */ + getString : function(id, defaultValue, args) { + + if ( this.valid ) { + var str= this.__currentLocale[id]; + if ( str ) { + return this.__formatString(str,args); + } else { + + if ( this.__currentLocale!==this.__defaultLocale ) { + str= this.__defaultLocale[id]; + if ( str ) { + return this.__formatString(str,args); + } + } + } + } + + return this.__formatString(defaultValue,args); + }, + + loadDoc : function(resourceFile, asynch, onSuccess, onError ) { + var me= this; + + var req; + if (window.XMLHttpRequest && !(window.ActiveXObject)) { + try { + req = new XMLHttpRequest(); + } catch (e) { + req = null; + onError(e); + } + } else if (window.ActiveXObject) { + try { + req = new ActiveXObject("Msxml2.XMLHTTP"); + } catch (e) { + try { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } catch (e) { + req = null; + onError(e); + } + } + } + + if (req) { + req.onreadystatechange = function () { + if (req.readyState == 4) { + if (req.status == 200) { + try { + me.localeInfo= JSON.parse(req.responseText); + me.valid= true; + onSuccess(me.localeInfo); + } catch(e) { + onError(e); + } + } else { + onError("onReadyStateChange status="+req.status); + } + } + }; + + req.open("GET", resourceFile, false); + req.send(""); + } + } + } + } +}); \ No newline at end of file diff --git a/CAAT/src/Modules/Runtime/BrowserInfo.js b/CAAT/src/Modules/Runtime/BrowserInfo.js new file mode 100644 index 0000000..f1634f7 --- /dev/null +++ b/CAAT/src/Modules/Runtime/BrowserInfo.js @@ -0,0 +1,162 @@ +/** + * + * taken from: http://www.quirksmode.org/js/detect.html + * + * 20101008 Hyperandroid. IE9 seems to identify himself as Explorer and stopped calling himself MSIE. + * Added Explorer description to browser list. Thanks @alteredq for this tip. + * + */ +CAAT.Module({ + + /** + * @name Runtime + * @memberOf CAAT.Module + * @namespace + */ + + /** + * @name BrowserInfo + * @memberOf CAAT.Module.Runtime + * @namespace + */ + + defines:"CAAT.Module.Runtime.BrowserInfo", + + constants: function() { + + /** + * @lends CAAT.Module.Runtime.BrowserInfo + */ + + function searchString(data) { + for (var i = 0; i < data.length; i++) { + var dataString = data[i].string; + var dataProp = data[i].prop; + this.versionSearchString = data[i].versionSearch || data[i].identity; + if (dataString) { + if (dataString.indexOf(data[i].subString) !== -1) + return data[i].identity; + } + else if (dataProp) + return data[i].identity; + } + } + + function searchVersion(dataString) { + var index = dataString.indexOf(this.versionSearchString); + if (index === -1) return; + return parseFloat(dataString.substring(index + this.versionSearchString.length + 1)); + } + + var dataBrowser= [ + { + string:navigator.userAgent, + subString:"Chrome", + identity:"Chrome" + }, + { string:navigator.userAgent, + subString:"OmniWeb", + versionSearch:"OmniWeb/", + identity:"OmniWeb" + }, + { + string:navigator.vendor, + subString:"Apple", + identity:"Safari", + versionSearch:"Version" + }, + { + prop:window.opera, + identity:"Opera" + }, + { + string:navigator.vendor, + subString:"iCab", + identity:"iCab" + }, + { + string:navigator.vendor, + subString:"KDE", + identity:"Konqueror" + }, + { + string:navigator.userAgent, + subString:"Firefox", + identity:"Firefox" + }, + { + string:navigator.vendor, + subString:"Camino", + identity:"Camino" + }, + { // for newer Netscapes (6+) + string:navigator.userAgent, + subString:"Netscape", + identity:"Netscape" + }, + { + string:navigator.userAgent, + subString:"MSIE", + identity:"Explorer", + versionSearch:"MSIE" + }, + { + string:navigator.userAgent, + subString:"Explorer", + identity:"Explorer", + versionSearch:"Explorer" + }, + { + string:navigator.userAgent, + subString:"Gecko", + identity:"Mozilla", + versionSearch:"rv" + }, + { // for older Netscapes (4-) + string:navigator.userAgent, + subString:"Mozilla", + identity:"Netscape", + versionSearch:"Mozilla" + } + ]; + + var dataOS=[ + { + string:navigator.platform, + subString:"Win", + identity:"Windows" + }, + { + string:navigator.platform, + subString:"Mac", + identity:"Mac" + }, + { + string:navigator.userAgent, + subString:"iPhone", + identity:"iPhone/iPod" + }, + { + string:navigator.platform, + subString:"Linux", + identity:"Linux" + } + ]; + + var browser = searchString(dataBrowser) || "An unknown browser"; + var version = searchVersion(navigator.userAgent) || + searchVersion(navigator.appVersion) || + "an unknown version"; + var OS = searchString(dataOS) || "an unknown OS"; + + var DevicePixelRatio = window.devicePixelRatio || 1; + + return { + browser: browser, + version: version, + OS: OS, + DevicePixelRatio : DevicePixelRatio + } + + } +}); diff --git a/CAAT/src/Modules/Skeleton/Bone.js b/CAAT/src/Modules/Skeleton/Bone.js new file mode 100755 index 0000000..98179af --- /dev/null +++ b/CAAT/src/Modules/Skeleton/Bone.js @@ -0,0 +1,507 @@ +/** + * Created with JetBrains WebStorm. + * User: ibon + * Date: 3/21/13 + * Time: 7:51 PM + * To change this template use File | Settings | File Templates. + */ +CAAT.Module({ + + /** + * @name Skeleton + * @memberof CAAT.Module + * @namespace + */ + + /** + * @name Bone + * @memberof CAAT.Module.Skeleton + * @constructor + */ + + defines : "CAAT.Module.Skeleton.Bone", + depends : [ + "CAAT.Behavior.Interpolator", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.ScaleBehavior", + "CAAT.Behavior.ContainerBehavior" + ], + extendsWith : function() { + + + /** + * @lends CAAT.Module.Skeleton.Bone.prototype + */ + + var defPoint = { x: 0, y: 0 }; + var defScale = { scaleX: 1, scaleY: 1 }; + var defAngle = 0; + + var cangle; + var cscale; + var cpoint; + + function fntr(behavior, orgtime, time, actor, value) { + cpoint= value; + } + + function fnsc(behavior, orgtime, time, actor, value) { + cscale= value; + } + + function fnrt(behavior, orgtime, time, actor, value) { + cangle= value; + } + + return { + id : null, + + wx : 0, + wy : 0, + wrotationAngle : 0, + wscaleX : 0, + wscaleY : 0, + + /** + * Bone x position relative parent + * @type number + */ + x : 0, + + /** + * Bone y position relative parent + * @type {number} + */ + y : 0, + + positionAnchorX : 0, + positionAnchorY : 0, + + /** + * Bone rotation angle + * @type {number} + */ + rotationAngle : 0, + rotationAnchorX : 0, + rotationAnchorY : 0.5, + + scaleX : 1, + scaleY : 1, + scaleAnchorX : .5, + scaleAnchorY : .5, + + /** + * Bone size. + * @type number + */ + size : 0, + + /** + * @type CAAT.Math.Matrix + */ + matrix : null, + + /** + * @type CAAT.Math.Matrix + */ + wmatrix : null, + + /** + * @type CAAT.Skeleton.Bone + */ + parent : null, + + /** + * @type CAAT.Behavior.ContainerBehavior + */ + keyframesTranslate : null, + + /** + * @type CAAT.PathUtil.Path + */ + keyframesTranslatePath : null, + + /** + * @type CAAT.Behavior.ContainerBehavior + */ + keyframesScale : null, + + /** + * @type CAAT.Behavior.ContainerBehavior + */ + keyframesRotate : null, + + /** + * @type object + */ + keyframesByAnimation : null, + + currentAnimation : null, + + /** + * @type Array. + */ + children : null, + + behaviorApplicationTime : -1, + + __init : function(id) { + this.id= id; + this.matrix= new CAAT.Math.Matrix(); + this.wmatrix= new CAAT.Math.Matrix(); + this.parent= null; + this.children= []; + + this.keyframesByAnimation = {}; + + return this; + }, + + setBehaviorApplicationTime : function(t) { + this.behaviorApplicationTime= t; + return this; + }, + + __createAnimation : function(name) { + + var keyframesTranslate= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_tr"); + var keyframesScale= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_sc"); + var keyframesRotate= new CAAT.Behavior.ContainerBehavior(true).setCycle(true, true).setId("keyframes_rt"); + + keyframesTranslate.addListener( { behaviorApplied : fntr }); + keyframesScale.addListener( { behaviorApplied : fnsc }); + keyframesRotate.addListener( { behaviorApplied : fnrt }); + + var animData= { + keyframesTranslate : keyframesTranslate, + keyframesScale : keyframesScale, + keyframesRotate : keyframesRotate + }; + + this.keyframesByAnimation[name]= animData; + + return animData; + }, + + __getAnimation : function(name) { + var animation= this.keyframesByAnimation[ name ]; + if (!animation) { + animation= this.__createAnimation(name); + } + + return animation; + }, + + /** + * + * @param parent {CAAT.Skeleton.Bone} + * @returns {*} + */ + __setParent : function( parent ) { + this.parent= parent; + return this; + }, + + addBone : function( bone ) { + this.children.push(bone); + bone.__setParent(this); + return this; + }, + + __noValue : function( keyframes ) { + keyframes.doValueApplication= false; + if ( keyframes instanceof CAAT.Behavior.ContainerBehavior ) { + this.__noValue( keyframes ); + } + }, + + __setInterpolator : function(behavior, curve) { + if (curve && curve!=="stepped") { + behavior.setInterpolator( + new CAAT.Behavior.Interpolator().createQuadricBezierInterpolator( + new CAAT.Math.Point(0,0), + new CAAT.Math.Point(curve[0], curve[1]), + new CAAT.Math.Point(curve[2], curve[3]) + ) + ); + } + }, + + /** + * + * @param name {string} keyframe animation name + * @param angleStart {number} rotation start angle + * @param angleEnd {number} rotation end angle + * @param timeStart {number} keyframe start time + * @param timeEnd {number} keyframe end time + * @param curve {Array.=} 4 numbers definint a quadric bezier info. two first points + * assumed to be 0,0. + */ + addRotationKeyframe : function( name, angleStart, angleEnd, timeStart, timeEnd, curve ) { + + var as= 2*Math.PI*angleStart/360; + var ae= 2*Math.PI*angleEnd/360; + + // minimum distant between two angles. + + if ( as<-Math.PI ) { + if (Math.abs(as+this.rotationAngle)>2*Math.PI) { + as= -(as+Math.PI); + } else { + as= (as+Math.PI); + } + } else if (as > Math.PI) { + as -= 2 * Math.PI; + } + + if ( ae<-Math.PI ) { + + if (Math.abs(ae+this.rotationAngle)>2*Math.PI) { + ae= -(ae+Math.PI); + } else { + ae= (ae+Math.PI); + } + } else if ( ae>Math.PI ) { + ae-=2*Math.PI; + } + + angleStart= -as; + angleEnd= -ae; + + var behavior= new CAAT.Behavior.RotateBehavior(). + setFrameTime( timeStart, timeEnd-timeStart+1). + setValues( angleStart, angleEnd, 0, .5). + setValueApplication(false); + + this.__setInterpolator( behavior, curve ); + + var animation= this.__getAnimation(name); + animation.keyframesRotate.addBehavior(behavior); + }, + + endRotationKeyframes : function(name) { + + }, + + addTranslationKeyframe : function( name, startX, startY, endX, endY, timeStart, timeEnd, curve ) { + var behavior= new CAAT.Behavior.PathBehavior(). + setFrameTime( timeStart, timeEnd-timeStart+1). + setValues( new CAAT.PathUtil.Path(). + setLinear( startX, startY, endX, endY ) + ). + setValueApplication(false); + + this.__setInterpolator( behavior, curve ); + + var animation= this.__getAnimation(name); + animation.keyframesTranslate.addBehavior( behavior ); + }, + + addScaleKeyframe : function( name, scaleX, endScaleX, scaleY, endScaleY, timeStart, timeEnd, curve ) { + var behavior= new CAAT.Behavior.ScaleBehavior(). + setFrameTime( timeStart, timeEnd-timeStart+1). + setValues( scaleX, endScaleX, scaleY, endScaleY ). + setValueApplication(false); + + this.__setInterpolator( behavior, curve ); + + var animation= this.__getAnimation(name); + animation.keyframesScale.addBehavior( behavior ); + }, + + endTranslationKeyframes : function(name) { + + }, + + setSize : function(s) { + this.width= s; + this.height= 0; + }, + + endScaleKeyframes : function(name) { + + }, + + setPosition : function( x, y ) { + this.x= x; + this.y= -y; + return this; + } , + + /** + * default anchor values are for spine tool. + * @param angle {number} + * @param anchorX {number=} + * @param anchorY {number=} + * @returns {*} + */ + setRotateTransform : function( angle, anchorX, anchorY ) { + this.rotationAngle= -angle*2*Math.PI/360; + this.rotationAnchorX= typeof anchorX!=="undefined" ? anchorX : 0; + this.rotationAnchorY= typeof anchorY!=="undefined" ? anchorY : .5; + return this; + }, + + /** + * + * @param sx {number} + * @param sy {number} + * @param anchorX {number=} anchorX: .5 by default + * @param anchorY {number=} anchorY. .5 by default + * @returns {*} + */ + setScaleTransform : function( sx, sy, anchorX, anchorY ) { + this.scaleX= sx; + this.scaleY= sy; + this.scaleAnchorX= typeof anchorX!=="undefined" ? anchorX : .5; + this.scaleAnchorY= typeof anchorY!=="undefined" ? anchorY : .5; + return this; + }, + + + __setModelViewMatrix : function() { + var c, s, _m00, _m01, _m10, _m11; + var mm0, mm1, mm2, mm3, mm4, mm5; + var mm; + + var mm = this.matrix.matrix; + + mm0 = 1; + mm1 = 0; + mm3 = 0; + mm4 = 1; + + mm2 = this.wx - this.positionAnchorX * this.width; + mm5 = this.wy - this.positionAnchorY * this.height; + + if (this.wrotationAngle) { + + var rx = this.rotationAnchorX * this.width; + var ry = this.rotationAnchorY * this.height; + + mm2 += mm0 * rx + mm1 * ry; + mm5 += mm3 * rx + mm4 * ry; + + c = Math.cos(this.wrotationAngle); + s = Math.sin(this.wrotationAngle); + _m00 = mm0; + _m01 = mm1; + _m10 = mm3; + _m11 = mm4; + mm0 = _m00 * c + _m01 * s; + mm1 = -_m00 * s + _m01 * c; + mm3 = _m10 * c + _m11 * s; + mm4 = -_m10 * s + _m11 * c; + + mm2 += -mm0 * rx - mm1 * ry; + mm5 += -mm3 * rx - mm4 * ry; + } + if (this.wscaleX != 1 || this.wscaleY != 1) { + + var sx = this.scaleAnchorX * this.width; + var sy = this.scaleAnchorY * this.height; + + mm2 += mm0 * sx + mm1 * sy; + mm5 += mm3 * sx + mm4 * sy; + + mm0 = mm0 * this.wscaleX; + mm1 = mm1 * this.wscaleY; + mm3 = mm3 * this.wscaleX; + mm4 = mm4 * this.wscaleY; + + mm2 += -mm0 * sx - mm1 * sy; + mm5 += -mm3 * sx - mm4 * sy; + } + + mm[0] = mm0; + mm[1] = mm1; + mm[2] = mm2; + mm[3] = mm3; + mm[4] = mm4; + mm[5] = mm5; + + if (this.parent) { + this.wmatrix.copy(this.parent.wmatrix); + this.wmatrix.multiply(this.matrix); + } else { + this.wmatrix.identity(); + } + }, + + setAnimation : function(name) { + var animation= this.keyframesByAnimation[name]; + if (animation) { + this.keyframesRotate= animation.keyframesRotate; + this.keyframesScale= animation.keyframesScale; + this.keyframesTranslate= animation.keyframesTranslate; + } + + for( var i= 0, l=this.children.length; i=sdkf.start && time<=sdkf.start+sdkf.duration ) { + return this.currentSkinInfo= this.skinInfoByName[ sdkf.name ]; + } + } + + return null; + } + + return this.currentSkinInfo; + }, + + paint : function( ctx, time ) { + + var skinInfo= this.__getCurrentSkinInfo(time); + + if (!skinInfo || !skinInfo.image) { + return; + } + + /* + var w= skinInfo.width*.5; + var h= skinInfo.height*.5; + + ctx.translate(skinInfo.x, skinInfo.y ); + ctx.rotate(skinInfo.angle); + ctx.scale(skinInfo.scaleX, skinInfo.scaleY); + ctx.translate( -w, -h); + */ + + this.worldModelViewMatrix.transformRenderingContextSet(ctx); + skinInfo.matrix.transformRenderingContext( ctx ); + ctx.drawImage( skinInfo.image, 0, 0, skinInfo.image.width, skinInfo.image.height ); + + }, + + setupAnimation : function(time) { + this.setModelViewMatrix(); + this.prepareAABB(time); + this.__setupAttachments(); + }, + + prepareAABB : function(time) { + var skinInfo= this.__getCurrentSkinInfo(time); + var x=0, y=0, w, h; + + if ( skinInfo ) { + w= skinInfo.width; + h= skinInfo.height; + } else { + w= h= 1; + } + + var vv= [ + new CAAT.Math.Point(x,y), + new CAAT.Math.Point(x+w,0), + new CAAT.Math.Point(x+w, y+h), + new CAAT.Math.Point(x, y + h) + ]; + + var AABB= this.AABB; + var vvv; + + /** + * cache the bone+skin matrix for later usage in attachment calculations. + */ + var amatrix= this.skinMatrix; + amatrix.copy( this.worldModelViewMatrix ); + amatrix.multiply( this.currentSkinInfo.matrix ); + + for( var i=0; i xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[1]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[2]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + vvv = vv[3]; + if (vvv.x < xmin) { + xmin = vvv.x; + } + if (vvv.x > xmax) { + xmax = vvv.x; + } + if (vvv.y < ymin) { + ymin = vvv.y; + } + if (vvv.y > ymax) { + ymax = vvv.y; + } + + AABB.x = xmin; + AABB.y = ymin; + AABB.x1 = xmax; + AABB.y1 = ymax; + AABB.width = (xmax - xmin); + AABB.height = (ymax - ymin); + }, + + setModelViewMatrix : function() { + + if (this.parent) { + this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix); + this.worldModelViewMatrix.multiply(this.bone.wmatrix); + + } else { + this.worldModelViewMatrix.identity(); + } + }, + + __setupAttachments : function( ) { + for( var i= 0, l=this.attachments.length; i + */ + slotInfo: null, + + /** + * @type Array. + */ + slotInfoArray: null, + + /** + * @type object + * @map + */ + skinByName: null, + + /** + * @type CAAT.Foundation.Director + */ + director: null, + + /** + * @type boolean + */ + _showBones: false, + + /** + * Currently selected animation play time. + * Zero to make it last for its default value. + * @type number + */ + animationDuration : 0, + + showAABB : false, + bonesActor : null, + + __init: function (director, skeleton) { + this.__super(); + + this.director = director; + this.skeleton = skeleton; + this.slotInfo = {}; + this.slotInfoArray = []; + this.bonesActor= []; + this.skinByName = {}; + + this.setSkin(); + this.setAnimation("default"); + + return this; + }, + + showBones: function (show) { + this._showBones = show; + return this; + }, + + /** + * build an sprite-sheet composed of numSprites elements and organized in rows x columns + * @param numSprites {number} + * @param rows {number=} + * @param columns {number=} + */ + buildSheet : function( numSprites, rows, columns ) { + + var i, j,l; + var AABBs= []; + var maxTime= 1000; // BUGBUG search for animation time. + var ssItemWidth, ssItemHeight; // sprite sheet item width and height + var ssItemMinX= Number.MAX_VALUE, ssItemMinY= Number.MAX_VALUE; + var ssItemMaxOffsetY, ssItemMaxOffsetX; + + // prepare this actor's world model view matrix, but with no position. + var px= this.x; + var py= this.y; + this.x= this.y= 0; + this.setModelViewMatrix(); + + + rows= rows || 1; + columns= columns || 1; + + // calculate all sprite sheet frames aabb. + for( j=0; jssItemWidth ) { + ssItemWidth= AABBs[i].width; + } + if ( AABBs[i].height>ssItemHeight ) { + ssItemHeight= AABBs[i].height; + } + } + ssItemWidth= (ssItemWidth|0)+1; + ssItemHeight= (ssItemHeight|0)+1; + + // calculate every animation offset against biggest animation size. + ssItemMaxOffsetY= -Number.MAX_VALUE; + ssItemMaxOffsetX= -Number.MAX_VALUE; + var offsetMinX=Number.MAX_VALUE, offsetMaxX=-Number.MAX_VALUE; + for( i=0; issItemMaxOffsetY ) { + ssItemMaxOffsetY= offsetY; + } + + if ( offsetX>ssItemMaxOffsetX ) { + ssItemMaxOffsetX= offsetX; + } + } + + + // create a canvas of the neccessary size + var canvas= document.createElement("canvas"); + canvas.width= ssItemWidth * numSprites; + canvas.height= ssItemHeight; + var ctx= canvas.getContext("2d"); + + // draw animation into canvas. + for( j=0; jb.width ? -1 : 0; + } else if ( me.criteria==='height' ) { + return a.heightb.height ? -1 : 0; + } + return aareabarea ? -1 : 0; + }); + + for( i=0; i0 ) { + this.freeChunks.splice( i++,0,{position: lp, size:ls} ); + } + if ( rs>0 ) { + this.freeChunks.splice( i,0,{position: rp, size:rs} ); + } + + return true; + } + } + + return false; + }, + log : function(index) { + if ( 0===this.freeChunks.length ) { + CAAT.log('index '+index+' empty'); + } else { + var str='index '+index; + for( var i=0; ithis.width||height>this.height) { + return null; + } + + // find first fitting point + var i,j,initialPosition= 0; + + while( initialPosition<=this.scanMapHeight-height) { + + // para buscar sitio se buscara un sitio hasta el tamano de alto del trozo. + // mas abajo no va a caber. + + // fitHorizontalPosition es un array con todas las posiciones de este scan donde + // cabe un chunk de tamano width. + var fitHorizontalPositions= null; + var foundPositionOnScan= false; + + for( ; initialPosition<=this.scanMapHeight-height; initialPosition++ ) { + fitHorizontalPositions= this.scanMap[ initialPosition ].findWhereFits( width ); + + // si no es nulo el array de resultados, quiere decir que en alguno de los puntos + // nos cabe un trozo de tamano width. + if ( null!==fitHorizontalPositions && fitHorizontalPositions.length>0 ) { + foundPositionOnScan= true; + break; + } + } + + if ( foundPositionOnScan ) { + // j es el scan donde cabe un trozo de tamano width. + // comprobamos desde este scan que en todos los scan verticales cabe el trozo. + // se comprueba que cabe en alguno de los tamanos que la rutina de busqueda horizontal + // nos ha devuelto antes. + + var minInitialPosition=Number.MAX_VALUE; + for( j=0; j= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[0].x = x; + this.points[0].y = y; + } + + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + + this.updatePath(this.points[1]); + return this; + }, + /** + * An arc starts and ends in the same point. + */ + endCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(this.points[0].x, this.points[0].y); + } else { + + var angle = this.angle * time * (this.cw ? 1 : -1) + this.startAngle; + + this.newPosition.set( + this.points[0].x + this.radius * Math.cos(angle), + this.points[0].y + this.radius * Math.sin(angle) + ); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + if (!this.arcTo) { + ctx.arc(this.points[0].x, this.points[0].y, this.radius, this.startAngle, this.startAngle + this.angle, this.cw); + } else { + ctx.arcTo(this.points[0].x, this.points[0].y, this.points[1].x, this.points[1].y, this.radius); + } + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + for (var i = 0; i < iSize; i++) { + contour.push( + { + x:this.points[0].x + this.radius * Math.cos(i * Math.PI / (iSize / 2)), + y:this.points[0].y + this.radius * Math.sin(i * Math.PI / (iSize / 2)) + } + ); + } + + return contour; + }, + + getPositionFromLength:function (iLength) { + var ratio = iLength / this.length * (this.cw ? 1 : -1); + return this.getPosition(ratio); + /* + this.newPosition.set( + this.points[0].x + this.radius * Math.cos( 2*Math.PI * ratio ), + this.points[0].y + this.radius * Math.sin( 2*Math.PI * ratio ) + ); + return this.newPosition;*/ + }, + + updatePath:function (point) { + + // just move the circle, not modify radius. + if (this.points[1] === point) { + + if (!this.arcTo) { + this.radius = Math.sqrt( + ( this.points[0].x - this.points[1].x ) * ( this.points[0].x - this.points[1].x ) + + ( this.points[0].y - this.points[1].y ) * ( this.points[0].y - this.points[1].y ) + ); + } + + this.length = this.angle * this.radius; + this.startAngle = Math.atan2((this.points[1].y - this.points[0].y), (this.points[1].x - this.points[0].x)); + + } else if (this.points[0] === point) { + this.points[1].set( + this.points[0].x + this.radius * Math.cos(this.startAngle), + this.points[0].y + this.radius * Math.sin(this.startAngle) + ); + } + + this.bbox.setEmpty(); + this.bbox.x = this.points[0].x - this.radius; + this.bbox.y = this.points[0].y - this.radius; + this.bbox.x1 = this.points[0].x + this.radius; + this.bbox.y1 = this.points[0].y + this.radius; + this.bbox.width = 2 * this.radius; + this.bbox.height = 2 * this.radius; + + return this; + } + } + } + +}); diff --git a/CAAT/src/PathUtil/CurvePath.js b/CAAT/src/PathUtil/CurvePath.js new file mode 100644 index 0000000..4ca7375 --- /dev/null +++ b/CAAT/src/PathUtil/CurvePath.js @@ -0,0 +1,205 @@ +/** + * CAAT.CurvePath + */ +CAAT.Module({ + + /** + * @name CurvePath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.CurvePath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Bezier" + ], + aliases:["CAAT.CurvePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + return { + + /** + * @lends CAAT.PathUtil.CurvePath.prototype + */ + + + __init:function () { + this.__super(); + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A CAAT.Math.Curve instance. + */ + curve:null, + + /** + * spare holder for getPosition coordinate return. + * @type {CAAT.Math.Point} + */ + newPosition:null, + + applyAsPath:function (director) { + this.curve.applyAsPath(director); + return this; + }, + setPoint:function (point, index) { + if (this.curve) { + this.curve.setPoint(point, index); + } + }, + /** + * Set this curve segment's points. + * @param points {Array} + */ + setPoints:function (points) { + var curve = new CAAT.Math.Bezier(); + curve.setPoints(points); + this.curve = curve; + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier quadric instance. + * Parameters are quadric coordinates control points. + * + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @return this + */ + setQuadric:function (p0x, p0y, p1x, p1y, p2x, p2y) { + var curve = new CAAT.Math.Bezier(); + curve.setQuadric(p0x, p0y, p1x, p1y, p2x, p2y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * Set the pathSegment as a CAAT.Bezier cubic instance. + * Parameters are cubic coordinates control points. + * @param p0x {number} + * @param p0y {number} + * @param p1x {number} + * @param p1y {number} + * @param p2x {number} + * @param p2y {number} + * @param p3x {number} + * @param p3y {number} + * @return this + */ + setCubic:function (p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y) { + var curve = new CAAT.Math.Bezier(); + curve.setCubic(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y); + this.curve = curve; + this.updatePath(); + + return this; + }, + /** + * @inheritDoc + */ + updatePath:function (point) { + this.curve.update(); + this.length = this.curve.getLength(); + this.curve.getBoundingBox(this.bbox); + return this; + }, + /** + * @inheritDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.curve.solve(this.newPosition, time); + + return this.newPosition; + }, + /** + * Gets the coordinate on the path relative to the path length. + * @param iLength {number} the length at which the coordinate will be taken from. + * @return {CAAT.Point} a CAAT.Point instance with the coordinate on the path corresponding to the + * iLenght parameter relative to segment's length. + */ + getPositionFromLength:function (iLength) { + this.curve.solve(this.newPosition, iLength / this.length); + return this.newPosition; + }, + /** + * Get path segment's first point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.curve.coordlist[0].x; + }, + /** + * Get path segment's last point's y coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.curve.coordlist[this.curve.coordlist.length - 1].x; + }, + /** + * @inheritDoc + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + this.curve.drawHandles = bDrawHandles; + director.ctx.strokeStyle = this.color; + this.curve.paint(director, bDrawHandles); + }, + /** + * @inheritDoc + */ + numControlPoints:function () { + return this.curve.coordlist.length; + }, + /** + * @inheritDoc + * @param index + */ + getControlPoint:function (index) { + return this.curve.coordlist[index]; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.curve.endCurvePosition(); + }, + /** + * @inheritDoc + */ + startCurvePosition:function () { + return this.curve.startCurvePosition(); + }, + /** + * @inheritDoc + * @param iSize + */ + getContour:function (iSize) { + var contour = []; + for (var i = 0; i <= iSize; i++) { + contour.push({x:i / iSize, y:this.getPosition(i / iSize).y}); + } + + return contour; + } + } + } + +}); diff --git a/CAAT/src/PathUtil/LinearPath.js b/CAAT/src/PathUtil/LinearPath.js new file mode 100644 index 0000000..9f8dbc4 --- /dev/null +++ b/CAAT/src/PathUtil/LinearPath.js @@ -0,0 +1,210 @@ +/** + * CAAT.LinearPath + */ +CAAT.Module({ + + + /** + * @name LinearPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.LinearPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point" + ], + aliases:["CAAT.LinearPath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.LinearPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(0, 0, 0); + return this; + }, + + /** + * A collection of points. + * @type {Array.} + */ + points:null, + + /** + * spare holder for getPosition coordinate return. + */ + newPosition:null, + + applyAsPath:function (director) { + // Fixed: Thanks https://github.com/roed + director.ctx.lineTo(this.points[1].x, this.points[1].y); + }, + setPoint:function (point, index) { + if (index === 0) { + this.points[0] = point; + } else if (index === 1) { + this.points[1] = point; + } + }, + /** + * Update this segments length and bounding box info. + */ + updatePath:function (point) { + var x = this.points[1].x - this.points[0].x; + var y = this.points[1].y - this.points[0].y; + this.length = Math.sqrt(x * x + y * y); + + this.bbox.setEmpty(); + this.bbox.union(this.points[0].x, this.points[0].y); + this.bbox.union(this.points[1].x, this.points[1].y); + + return this; + }, + setPoints:function (points) { + this.points[0] = points[0]; + this.points[1] = points[1]; + this.updatePath(); + return this; + }, + /** + * Set this path segment's starting position. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + this.points[0].x = x; + this.points[0].y = y; + this.newPosition.set(x, y); + return this; + }, + /** + * Set this path segment's ending position. + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[1].x = finalX; + this.points[1].y = finalY; + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[1]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + this.newPosition.set( + (this.points[0].x + (this.points[1].x - this.points[0].x) * time), + (this.points[0].y + (this.points[1].y - this.points[0].y) * time)); + + return this.newPosition; + }, + getPositionFromLength:function (len) { + return this.getPosition(len / this.length); + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[1].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.moveTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.stroke(); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + ctx.beginPath(); + this.drawHandle(ctx, this.points[0].x, this.points[0].y); + this.drawHandle(ctx, this.points[1].x, this.points[1].y); + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return 2; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + if (0 === index) { + return this.points[0]; + } else if (1 === index) { + return this.points[1]; + } + }, + /** + * @inheritsDoc + */ + getContour:function (iSize) { + var contour = []; + + contour.push(this.getPosition(0).clone()); + contour.push(this.getPosition(1).clone()); + + return contour; + } + } + } +}); diff --git a/CAAT/src/PathUtil/Path.js b/CAAT/src/PathUtil/Path.js new file mode 100644 index 0000000..4581185 --- /dev/null +++ b/CAAT/src/PathUtil/Path.js @@ -0,0 +1,1167 @@ +CAAT.Module( { + + /** + * @name Path + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines : "CAAT.PathUtil.Path", + aliases : ["CAAT.Path"], + depends : [ + "CAAT.PathUtil.PathSegment", + "CAAT.PathUtil.ArcPath", + "CAAT.PathUtil.CurvePath", + "CAAT.PathUtil.LinearPath", + "CAAT.PathUtil.RectPath", + "CAAT.Math.Bezier", + "CAAT.Math.CatmullRom", + "CAAT.Math.Point", + "CAAT.Math.Matrix" + ], + extendsClass : "CAAT.PathUtil.PathSegment", + extendsWith : { + + /** + * @lends CAAT.PathUtil.Path.prototype + */ + + + __init : function() { + this.__super(); + + this.newPosition= new CAAT.Math.Point(0,0,0); + this.pathSegments= []; + + this.behaviorList= []; + this.matrix= new CAAT.Math.Matrix(); + this.tmpMatrix= new CAAT.Math.Matrix(); + + return this; + }, + + /** + * A collection of PathSegments. + * @type {Array.} + */ + pathSegments: null, // a collection of CAAT.PathSegment instances. + + /** + * For each path segment in this path, the normalized calculated duration. + * precomputed segment duration relative to segment legnth/path length + */ + pathSegmentDurationTime: null, + + /** + * For each path segment in this path, the normalized calculated start time. + * precomputed segment start time relative to segment legnth/path length and duration. + */ + pathSegmentStartTime: null, + + /** + * spare CAAT.Math.Point to return calculated values in the path. + */ + newPosition: null, + + /** + * path length (sum of every segment length) + */ + pathLength: -1, + + /** + * starting path x position + */ + beginPathX: -1, + + /** + * starting path y position + */ + beginPathY: -1, + + /* + last path coordinates position (using when building the path). + */ + trackPathX: -1, + trackPathY: -1, + + /* + needed to drag control points. + */ + ax: -1, + ay: -1, + point: [], + + /** + * Is this path interactive ?. If so, controls points can be moved with a CAAT.Foundation.UI.PathActor. + */ + interactive: true, + + /** + * A list of behaviors to apply to this path. + * A path can be affine transformed to create a different path. + */ + behaviorList: null, + + /* rotation behavior info **/ + + /** + * Path rotation angle. + */ + rb_angle: 0, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorX: .5, + + /** + * Path rotation x anchor. + */ + rb_rotateAnchorY: .5, + + /* scale behavior info **/ + + /** + * Path X scale. + */ + sb_scaleX: 1, + + /** + * Path Y scale. + */ + sb_scaleY: 1, + + /** + * Path scale X anchor. + */ + sb_scaleAnchorX: .5, + + /** + * Path scale Y anchor. + */ + sb_scaleAnchorY: .5, + + /** + * Path translation anchor X. + */ + tAnchorX: 0, + + /** + * Path translation anchor Y. + */ + tAnchorY: 0, + + /* translate behavior info **/ + + /** + * Path translation X. + */ + tb_x: 0, + + /** + * Path translation Y. + */ + tb_y: 0, + + /* behavior affine transformation matrix **/ + + /** + * Path behaviors matrix. + */ + matrix: null, + + /** + * Spare calculation matrix. + */ + tmpMatrix: null, + + /** + * Original Path´s path segments points. + */ + pathPoints: null, + + /** + * Path bounding box width. + */ + width: 0, + + /** + * Path bounding box height. + */ + height: 0, + + /** + * Path bounding box X position. + */ + clipOffsetX : 0, + + /** + * Path bounding box Y position. + */ + clipOffsetY : 0, + + /** + * Is this path closed ? + */ + closed : false, + + /** + * Apply this path as a Canvas context path. + * You must explicitly call context.beginPath + * @param director + * @return {*} + */ + applyAsPath : function(director) { + var ctx= director.ctx; + + director.modelViewMatrix.transformRenderingContext( ctx ); + ctx.globalCompositeOperation= 'source-out'; + ctx.moveTo( + this.getFirstPathSegment().startCurvePosition().x, + this.getFirstPathSegment().startCurvePosition().y + ); + for( var i=0; i + * If a call to any method of the form addTo is called before this calling + * this method, they will assume to start at -1,-1 and probably you'll get the wrong path. + * @param px0 {number} + * @param py0 {number} + * + * @return this + */ + beginPath : function( px0, py0 ) { + this.trackPathX= px0; + this.trackPathY= py0; + this.beginPathX= px0; + this.beginPathY= py0; + return this; + }, + /** + * Close the path by adding a line path segment from the current last path + * coordinate to startCurvePosition coordinate. + *

                    + * This method closes a path by setting its last path segment's last control point + * to be the first path segment's first control point. + *

                    + * This method also sets the path as finished, and calculates all path's information + * such as length and bounding box. + * + * @return this + */ + closePath : function() { + + this.getLastPathSegment().setPoint( + this.getFirstPathSegment().startCurvePosition(), + this.getLastPathSegment().numControlPoints()-1 ); + + + this.trackPathX= this.beginPathX; + this.trackPathY= this.beginPathY; + + this.closed= true; + + this.endPath(); + return this; + }, + /** + * Finishes the process of building the path. It involves calculating each path segments length + * and proportional length related to a normalized path length of 1. + * It also sets current paths length. + * These calculi are needed to traverse the path appropriately. + *

                    + * This method must be called explicitly, except when closing a path (that is, calling the + * method closePath) which calls this method as well. + * + * @return this + */ + endPath : function() { + + this.pathSegmentStartTime=[]; + this.pathSegmentDurationTime= []; + + this.updatePath(); + + return this; + }, + /** + * This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path. + * The returned coordinate is the corresponding to normalizing the path's length to 1, + * and then finding what path segment and what coordinate in that path segment corresponds + * for the input time parameter. + *

                    + * The parameter time must be a value ranging 0..1. + * If not constrained to these values, the parameter will be modulus 1, and then, if less + * than 0, be normalized to 1+time, so that the value always ranges from 0 to 1. + *

                    + * This method is needed when traversing the path throughout a CAAT.Interpolator instance. + * + * + * @param time {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate. + * 1 will return path's end coordinate. + * @param open_contour {boolean=} treat this path as an open contour. It is intended for + * open paths, and interpolators which give values above 1. see tutorial 7.1. + * @link{../../documentation/tutorials/t7-1.html} + * + * @return {CAAT.Foundation.Point} + */ + getPosition : function(time, open_contour) { + + if (open_contour && (time>=1 || time<=0) ) { + + var p0,p1,ratio, angle; + + if ( time>=1 ) { + // these values could be cached. + p0= this.__getPositionImpl( .999 ); + p1= this.endCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= time%1; + + + } else { + // these values could be cached. + p0= this.__getPositionImpl( .001 ); + p1= this.startCurvePosition(); + + angle= Math.atan2( p1.y - p0.y, p1.x - p0.x ); + ratio= -time; + } + + var np= this.newPosition; + var length= this.getLength(); + + np.x = p1.x + (ratio * length)*Math.cos(angle); + np.y = p1.y + (ratio * length)*Math.sin(angle); + + + return np; + } + + return this.__getPositionImpl(time); + }, + + __getPositionImpl : function(time) { + + if ( time>1 || time<0 ) { + time%=1; + } + if ( time<0 ) { + time= 1+time; + } + + var ps= this.pathSegments; + var psst= this.pathSegmentStartTime; + var psdt= this.pathSegmentDurationTime; + var l= 0; + var r= ps.length; + var m; + var np= this.newPosition; + var psstv; + while( l!==r ) { + + m= ((r+l)/2)|0; + psstv= psst[m]; + if ( psstv<=time && time<=psstv+psdt[m]) { + time= psdt[m] ? + (time-psstv)/psdt[m] : + 0; + + // Clamp this segment's time to a maximum since it is relative to the path. + // thanks https://github.com/donaldducky for spotting. + if (time>1) { + time=1; + } else if (time<0 ) { + time= 0; + } + + var pointInPath= ps[m].getPosition(time); + np.x= pointInPath.x; + np.y= pointInPath.y; + return np; + } else if ( time=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + + }, + /** + * Analogously to the method getPosition, this method returns a CAAT.Point instance with + * the coordinate on the path that corresponds to the given length. The input length is + * related to path's length. + * + * @param iLength {number} a float with the target length. + * @return {CAAT.Point} + */ + getPositionFromLength : function(iLength) { + + iLength%=this.getLength(); + if (iLength<0 ) { + iLength+= this.getLength(); + } + + var accLength=0; + + for( var i=0; i0 ) { + this.pathSegmentStartTime[i]= this.pathSegmentStartTime[i-1]+this.pathSegmentDurationTime[i-1]; + } else { + this.pathSegmentStartTime[0]= 0; + } + + this.pathSegments[i].endPath(); + } + + this.extractPathPoints(); + + if ( callback ) { + callback(this); + } + + return this; + + }, + /** + * Sent by a CAAT.PathActor instance object to try to drag a path's control point. + * @param x {number} + * @param y {number} + */ + press: function(x,y) { + if (!this.interactive) { + return; + } + + var HS= CAAT.Math.Curve.prototype.HANDLE_SIZE/2; + for( var i=0; i=point.x-HS && + y>=point.y-HS && + x} + */ + setPoints : function( points ) { + if ( this.points.length===points.length ) { + for( var i=0; i=0 && index} + */ + setPoints:function (points) { + }, + + /** + * Set a point from this path segment. + * @param point {CAAT.Point} + * @param index {integer} a point index. + */ + setPoint:function (point, index) { + }, + + /** + * Get a coordinate on path. + * The parameter time is normalized, that is, its values range from zero to one. + * zero will mean startCurvePosition and one will be endCurvePosition. Other values + * will be a position on the path relative to the path length. if the value is greater that 1, if will be set + * to modulus 1. + * @param time a float with a value between zero and 1 inclusive both. + * + * @return {CAAT.Point} + */ + getPosition:function (time) { + }, + + /** + * Gets Path length. + * @return {number} + */ + getLength:function () { + return this.length; + }, + + /** + * Gets the path bounding box (or the rectangle that contains the whole path). + * @param rectangle a CAAT.Rectangle instance with the bounding box. + * @return {CAAT.Rectangle} + */ + getBoundingBox:function () { + return this.bbox; + }, + + /** + * Gets the number of control points needed to create the path. + * Each PathSegment type can have different control points. + * @return {number} an integer with the number of control points. + */ + numControlPoints:function () { + }, + + /** + * Gets CAAT.Point instance with the 2d position of a control point. + * @param index an integer indicating the desired control point coordinate. + * @return {CAAT.Point} + */ + getControlPoint:function (index) { + }, + + /** + * Instruments the path has finished building, and that no more segments will be added to it. + * You could later add more PathSegments and endPath must be called again. + */ + endPath:function () { + }, + + /** + * Gets a polyline describing the path contour. The contour will be defined by as mush as iSize segments. + * @param iSize an integer indicating the number of segments of the contour polyline. + * + * @return {[CAAT.Point]} + */ + getContour:function (iSize) { + }, + + /** + * Recalculate internal path structures. + */ + updatePath:function (point) { + }, + + /** + * Draw this path using RenderingContext2D drawing primitives. + * The intention is to set a path or pathsegment as a clipping region. + * + * @param ctx {RenderingContext2D} + */ + applyAsPath:function (director) { + }, + + /** + * Transform this path with the given affinetransform matrix. + * @param matrix + */ + transform:function (matrix) { + }, + + drawHandle:function (ctx, x, y) { + + ctx.beginPath(); + ctx.arc( + x, + y, + CAAT.Math.Curve.prototype.HANDLE_SIZE / 2, + 0, + 2 * Math.PI, + false); + ctx.fill(); + } + } + } + +}); diff --git a/CAAT/src/PathUtil/RectPath.js b/CAAT/src/PathUtil/RectPath.js new file mode 100644 index 0000000..31ae9c0 --- /dev/null +++ b/CAAT/src/PathUtil/RectPath.js @@ -0,0 +1,320 @@ +CAAT.Module({ + + /** + * @name RectPath + * @memberOf CAAT.PathUtil + * @extends CAAT.PathUtil.PathSegment + * @constructor + */ + + defines:"CAAT.PathUtil.RectPath", + depends:[ + "CAAT.PathUtil.PathSegment", + "CAAT.Math.Point", + "CAAT.Math.Rectangle" + ], + aliases:["CAAT.RectPath", "CAAT.ShapePath"], + extendsClass:"CAAT.PathUtil.PathSegment", + extendsWith:function () { + + return { + + /** + * @lends CAAT.PathUtil.RectPath.prototype + */ + + __init:function () { + this.__super(); + + this.points = []; + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + this.points.push(new CAAT.Math.Point()); + + this.newPosition = new CAAT.Math.Point(); + + return this; + }, + + /** + * A collection of Points. + * @type {Array.} + */ + points:null, + + /** + * Traverse this path clockwise or counterclockwise (false). + */ + cw:true, + + /** + * spare point for calculations + */ + newPosition:null, + + applyAsPath:function (director) { + var ctx = director.ctx; + + if (this.cw) { + ctx.lineTo(this.points[0].x, this.points[0].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[4].x, this.points[4].y); + } else { + ctx.lineTo(this.points[4].x, this.points[4].y); + ctx.lineTo(this.points[3].x, this.points[3].y); + ctx.lineTo(this.points[2].x, this.points[2].y); + ctx.lineTo(this.points[1].x, this.points[1].y); + ctx.lineTo(this.points[0].x, this.points[0].y); + } + return this; + }, + setPoint:function (point, index) { + if (index >= 0 && index < this.points.length) { + this.points[index] = point; + } + }, + /** + * An array of {CAAT.Point} composed of two points. + * @param points {Array} + */ + setPoints:function (points) { + this.points = []; + this.points.push(points[0]); + this.points.push(new CAAT.Math.Point().set(points[1].x, points[0].y)); + this.points.push(points[1]); + this.points.push(new CAAT.Math.Point().set(points[0].x, points[1].y)); + this.points.push(points[0].clone()); + this.updatePath(); + + return this; + }, + setClockWise:function (cw) { + this.cw = cw !== undefined ? cw : true; + return this; + }, + isClockWise:function () { + return this.cw; + }, + /** + * Set this path segment's starting position. + * This method should not be called again after setFinalPosition has been called. + * @param x {number} + * @param y {number} + */ + setInitialPosition:function (x, y) { + for (var i = 0, l = this.points.length; i < l; i++) { + this.points[i].x = x; + this.points[i].y = y; + } + return this; + }, + /** + * Set a rectangle from points[0] to (finalX, finalY) + * @param finalX {number} + * @param finalY {number} + */ + setFinalPosition:function (finalX, finalY) { + this.points[2].x = finalX; + this.points[2].y = finalY; + + this.points[1].x = finalX; + this.points[1].y = this.points[0].y; + + this.points[3].x = this.points[0].x; + this.points[3].y = finalY; + + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + + this.updatePath(); + return this; + }, + /** + * @inheritDoc + */ + endCurvePosition:function () { + return this.points[4]; + }, + /** + * @inheritsDoc + */ + startCurvePosition:function () { + return this.points[0]; + }, + /** + * @inheritsDoc + */ + getPosition:function (time) { + + if (time > 1 || time < 0) { + time %= 1; + } + if (time < 0) { + time = 1 + time; + } + + if (-1 === this.length) { + this.newPosition.set(0, 0); + } else { + var w = this.bbox.width / this.length; + var h = this.bbox.height / this.length; + var accTime = 0; + var times; + var segments; + var index = 0; + + if (this.cw) { + segments = [0, 1, 2, 3, 4]; + times = [w, h, w, h]; + } else { + segments = [4, 3, 2, 1, 0]; + times = [h, w, h, w]; + } + + while (index < times.length) { + if (accTime + times[index] < time) { + accTime += times[index]; + index++; + } else { + break; + } + } + time -= accTime; + + var p0 = segments[index]; + var p1 = segments[index + 1]; + + // index tiene el indice del segmento en tiempo. + this.newPosition.set( + (this.points[p0].x + (this.points[p1].x - this.points[p0].x) * time / times[index]), + (this.points[p0].y + (this.points[p1].y - this.points[p0].y) * time / times[index])); + } + + return this.newPosition; + }, + /** + * Returns initial path segment point's x coordinate. + * @return {number} + */ + initialPositionX:function () { + return this.points[0].x; + }, + /** + * Returns final path segment point's x coordinate. + * @return {number} + */ + finalPositionX:function () { + return this.points[2].x; + }, + /** + * Draws this path segment on screen. Optionally it can draw handles for every control point, in + * this case, start and ending path segment points. + * @param director {CAAT.Director} + * @param bDrawHandles {boolean} + */ + paint:function (director, bDrawHandles) { + + var ctx = director.ctx; + + ctx.save(); + + ctx.strokeStyle = this.color; + ctx.beginPath(); + ctx.strokeRect( + this.bbox.x, this.bbox.y, + this.bbox.width, this.bbox.height); + + if (bDrawHandles) { + ctx.globalAlpha = 0.5; + ctx.fillStyle = '#7f7f00'; + + for (var i = 0; i < this.points.length; i++) { + this.drawHandle(ctx, this.points[i].x, this.points[i].y); + } + + } + + ctx.restore(); + }, + /** + * Get the number of control points. For this type of path segment, start and + * ending path segment points. Defaults to 2. + * @return {number} + */ + numControlPoints:function () { + return this.points.length; + }, + /** + * @inheritsDoc + */ + getControlPoint:function (index) { + return this.points[index]; + }, + /** + * @inheritsDoc + */ + getContour:function (/*iSize*/) { + var contour = []; + + for (var i = 0; i < this.points.length; i++) { + contour.push(this.points[i]); + } + + return contour; + }, + updatePath:function (point) { + + if (point) { + if (point === this.points[0]) { + this.points[1].y = point.y; + this.points[3].x = point.x; + } else if (point === this.points[1]) { + this.points[0].y = point.y; + this.points[2].x = point.x; + } else if (point === this.points[2]) { + this.points[3].y = point.y; + this.points[1].x = point.x; + } else if (point === this.points[3]) { + this.points[0].x = point.x; + this.points[2].y = point.y; + } + this.points[4].x = this.points[0].x; + this.points[4].y = this.points[0].y; + } + + this.bbox.setEmpty(); + + for (var i = 0; i < 4; i++) { + this.bbox.union(this.points[i].x, this.points[i].y); + } + + this.length = 2 * this.bbox.width + 2 * this.bbox.height; + + this.points[0].x = this.bbox.x; + this.points[0].y = this.bbox.y; + + this.points[1].x = this.bbox.x + this.bbox.width; + this.points[1].y = this.bbox.y; + + this.points[2].x = this.bbox.x + this.bbox.width; + this.points[2].y = this.bbox.y + this.bbox.height; + + this.points[3].x = this.bbox.x; + this.points[3].y = this.bbox.y + this.bbox.height; + + this.points[4].x = this.bbox.x; + this.points[4].y = this.bbox.y; + + return this; + }, + + getPositionFromLength:function (iLength) { + return this.getPosition(iLength / (this.bbox.width * 2 + this.bbox.height * 2)); + } + } + } +}); diff --git a/CAAT/src/PathUtil/SVGPath.js b/CAAT/src/PathUtil/SVGPath.js new file mode 100644 index 0000000..d15e29a --- /dev/null +++ b/CAAT/src/PathUtil/SVGPath.js @@ -0,0 +1,486 @@ +CAAT.Module({ + + /** + *

                    + * This class is a SVG Path parser. + * By calling the method parsePath( svgpath ) an instance of CAAT.PathUtil.Path will be built by parsing + * its contents. + * + *

                    + * See demo32 + * + * @name SVGPath + * @memberOf CAAT.PathUtil + * @constructor + */ + + defines:"CAAT.PathUtil.SVGPath", + depends:[ + "CAAT.PathUtil.Path" + ], + extendsWith:function () { + + var OK = 0; + var EOF = 1; + var NAN = 2; + + function error(pathInfo, c) { + var cpos = c; + if (cpos < 0) { + cpos = 0; + } + console.log("parse error near ..." + pathInfo.substr(cpos, 20)); + } + + return { + + /** + * @lends CAAT.PathUtil.SVGPath.prototype + */ + + + __init:function () { + + }, + + /** + * @private + */ + c:0, + + /** + * @private + */ + bezierInfo:null, + + __skipBlank:function (pathInfo, c) { + var p = pathInfo.charAt(c); + while (c < pathInfo.length && (p == ' ' || p == '\n' || p == '\t' || p == ',')) { + ++c; + var p = pathInfo.charAt(c); + } + + return c; + }, + + __maybeNumber:function (pathInfo, c) { + + if (c < pathInfo.length - 2) { + + var p = pathInfo.charAt(c); + var p1 = pathInfo.charAt(c + 1); + + return p == '-' || + this.__isDigit(p) || + (p === "." && this.__isDigit(p1) ); + } + + return false; + }, + + __isDigit:function (c) { + return c >= "0" && c <= "9"; + }, + + + __getNumber:function (pathInfo, c, v, error) { + c = this.__skipBlank(pathInfo, c); + if (c < pathInfo.length) { + var nc = this.__findNumber(pathInfo, c); + if (nc !== -1) { + v.push(parseFloat(pathInfo.substr(c, nc))); + c = this.__skipBlank(pathInfo, nc); + error.pos = c; + error.result = OK; + return; + } else { + error.result = NAN; + return; + } + } + + error.result = EOF; + }, + + ____getNumbers:function (pathInfo, c, v, n, error) { + + for (var i = 0; i < n; i++) { + this.__getNumber(pathInfo, c, v, error); + if (error.result != OK) { + break; + } else { + c = error.pos; + } + } + + return c; + }, + + + __findNumber:function (pathInfo, c) { + + var p; + + if ((p = pathInfo.charAt(c)) == '-') { + ++c; + } + + if (!this.__isDigit((p = pathInfo.charAt(c)))) { + if ((p = pathInfo.charAt(c)) != '.' || !this.__isDigit(pathInfo.charAt(c + 1))) { + return -1; + } + } + + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + + if ((p = pathInfo.charAt(c)) == '.') { + ++c; + if (!this.__isDigit((p = pathInfo.charAt(c)))) { // asumo un numero [d+]\. como valido. + return c; + } + while (this.__isDigit((p = pathInfo.charAt(c)))) { + ++c; + } + } + + return c; + }, + + __parseMoveTo:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + + if (error.result === OK) { + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.beginPath(numbers[0], numbers[1]); + } else { + return; + } + + if (this.__maybeNumber(pathInfo, c)) { + c = this.parseLine(pathInfo, c, absolute, path, error); + } + + error.pos = c; + }, + + __parseLine:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 2, error); + if (!absolute) { + numbers[0] += path.trackPathX; + numbers[1] += path.trackPathY; + } + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + + __parseLineH:function (pathInfo, c, absolute, path, error) { + + var numbers = []; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[0] += path.trackPathX; + } + numbers[1].push(path.trackPathY); + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseLineV:function (pathInfo, c, absolute, path, error) { + + var numbers = [ path.trackPathX ]; + + do { + c = this.____getNumbers(pathInfo, c, numbers, 1, error); + + if (!absolute) { + numbers[1] += path.trackPathY; + } + + path.addLineTo(numbers[0], numbers[1]); + + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubic:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 6, error); + if (error.result === OK) { + if (!absolute) { + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + v[4] += path.trackPathX; + v[5] += path.trackPathY; + } + + path.addCubicTo(v[0], v[1], v[2], v[3], v[4], v[5]); + + + v.shift(); + v.shift(); + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(pathInfo, c)); + + error.pos = c; + }, + + __parseCubicS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result == OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addCubicTo(x, y, v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseQuadricS:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + } + + var x, y; + + x = this.bezierInfo[2] + (this.bezierInfo[2] - this.bezierInfo[0]); + y = this.bezierInfo[3] + (this.bezierInfo[3] - this.bezierInfo[1]); + + path.addQuadricTo(x, y, v[0], v[1]); + + this.bezierInfo = []; + bezierInfo.push(x); + bezierInfo.push(y); + bezierInfo.push(v[0]); + bezierInfo.push(v[1]); + + + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + + __parseQuadric:function (pathInfo, c, absolute, path, error) { + + var v = []; + + do { + c = this.____getNumbers(pathInfo, c, v, 4, error); + if (error.result === OK) { + if (!absolute) { + + v[0] += path.trackPathX; + v[1] += path.trackPathY; + v[2] += path.trackPathX; + v[3] += path.trackPathY; + } + + path.addQuadricTo(v[0], v[1], v[2], v[3]); + + this.bezierInfo = v; + } else { + return; + } + } while (this.__maybeNumber(c)); + + error.pos = c; + }, + + __parseClosePath:function (pathInfo, c, path, error) { + + path.closePath(); + error.pos= c; + + }, + + /** + * This method will create a CAAT.PathUtil.Path object with as many contours as needed. + * @param pathInfo {string} a SVG path + * @return Array. + */ + parsePath:function (pathInfo) { + + this.c = 0; + this.contours= []; + + var path = new CAAT.PathUtil.Path(); + this.contours.push( path ); + + this.c = this.__skipBlank(pathInfo, this.c); + if (this.c === pathInfo.length) { + return path; + } + + var ret = { + pos:0, + result:0 + } + + while (this.c != pathInfo.length) { + var segment = pathInfo.charAt(this.c); + switch (segment) { + case 'm': + this.__parseMoveTo(pathInfo, this.c + 1, false, path, ret); + break; + case 'M': + this.__parseMoveTo(pathInfo, this.c + 1, true, path, ret); + break; + case 'c': + this.__parseCubic(pathInfo, this.c + 1, false, path, ret); + break; + case 'C': + this.__parseCubic(pathInfo, this.c + 1, true, path, ret); + break; + case 's': + this.__parseCubicS(pathInfo, this.c + 1, false, path, ret); + break; + case 'S': + this.__parseCubicS(pathInfo, this.c + 1, true, path, ret); + break; + case 'q': + this.__parseQuadric(pathInfo, this.c + 1, false, path, ret); + break; + case 'Q': + this.__parseQuadricS(pathInfo, this.c + 1, true, path, ret); + break; + case 't': + this.__parseQuadricS(pathInfo, this.c + 1, false, path, ret); + break; + case 'T': + this.__parseQuadric(pathInfo, this.c + 1, true, path, ret); + break; + case 'l': + this.__parseLine(pathInfo, this.c + 1, false, path, ret); + break; + case 'L': + this.__parseLine(pathInfo, this.c + 1, true, path, ret); + break; + case 'h': + this.__parseLineH(pathInfo, this.c + 1, false, path, ret); + break; + case 'H': + this.__parseLineH(pathInfo, this.c + 1, true, path, ret); + break; + case 'v': + this.__parseLineV(pathInfo, this.c + 1, false, path, ret); + break; + case 'V': + this.__parseLineV(pathInfo, this.c + 1, true, path, ret); + break; + case 'z': + case 'Z': + this.__parseClosePath(pathInfo, this.c + 1, path, ret); + path= new CAAT.PathUtil.Path(); + this.contours.push( path ); + break; + case 0: + break; + default: + error(pathInfo, this.c); + break; + } + + if (ret.result != OK) { + error(pathInfo, this.c); + break; + } else { + this.c = ret.pos; + } + + } // while + + var count= 0; + var fpath= null; + for( var i=0; i .5 || Math.abs(u2 - u0) > .5 || Math.abs(u2 - u1) > .5) { + if (u0 < .5) { + uv[i * 2] += 1; + } + if (u1 < .5) { + uv[i * 2 + 2] += 1; + } + if (u2 < .5) { + uv[i * 2 + 4] += 1; + } + } + if (Math.abs(v0 - v1) > .5 || Math.abs(v2 - v0) > .5 || Math.abs(v2 - v1) > .5) { + if (v0 < .5) { + uv[i * 2 + 1] += 1; + } + if (v1 < .5) { + uv[i * 2 + 3] += 1; + } + if (v2 < .5) { + uv[i * 2 + 5] += 1; + } + } + } + return Object.assign(Object.assign({}, data), { uv, normals: data.vertices }); + } + expand(data, radius) { + for (let i = 0; i < data.numTriangles * 3; i++) { + Vector3T.normalize(data.vertices, i * 3, radius); + } + } + subdivideTriangles(data, numTriangles, subdivisions) { + for (let i = 0; i < subdivisions; i++) { + data = this.subdivideTrianglesImpl(data, numTriangles); + numTriangles = numTriangles * 4; + } + return { + vertices: data, + numTriangles, + uv: null, + index: null, + normals: null, + }; + } + /** + * Subdivide numTriangles. + * data is at least numTriangles*3 length + * @param data + * @param numTriangles + */ + subdivideTrianglesImpl(data, numTriangles) { + if (data.length < numTriangles * 3) { + throw new Error(`Not enough input data`); + } + const newBuffer = []; + for (let i = 0; i < numTriangles; i++) { + const offset = i * 9; // each tri has 3 vertices of xyz + const v0 = Vector3T.create(data, offset); + const v1 = Vector3T.create(data, offset + 3); + const v2 = Vector3T.create(data, offset + 6); + const mv0v1 = Vector3T.middle(v0, v1); + const mv1v2 = Vector3T.middle(v1, v2); + const mv2v0 = Vector3T.middle(v2, v0); + v0.write(newBuffer); + mv0v1.write(newBuffer); + mv2v0.write(newBuffer); + mv0v1.write(newBuffer); + v1.write(newBuffer); + mv1v2.write(newBuffer); + mv1v2.write(newBuffer); + mv2v0.write(newBuffer); + mv0v1.write(newBuffer); + mv2v0.write(newBuffer); + mv1v2.write(newBuffer); + v2.write(newBuffer); + } + return new Float32Array(newBuffer); + } + tessellateFromTetrahedronRec(subdivisions) { + const p1 = Vector3T.createC(0.0, -1.0, 2.0); + const p2 = Vector3T.createC(1.73205081, -1.0, -1.0); + const p3 = Vector3T.createC(-1.73205081, -1.0, -1.0); + const p4 = Vector3T.createC(0.0, 2.0, 0.0); + const store = []; + const index = []; + this.subdivideTrianglesR(store, index, subdivisions, p1, p3, p2); + this.subdivideTrianglesR(store, index, subdivisions, p1, p4, p3); + this.subdivideTrianglesR(store, index, subdivisions, p1, p2, p4); + this.subdivideTrianglesR(store, index, subdivisions, p2, p3, p4); + const vertices = new Float32Array(store.length * 3); + store.forEach((v, i) => { + const l = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); + vertices[i * 3] = v.x / l; + vertices[i * 3 + 1] = v.y / l; + vertices[i * 3 + 2] = v.z / l; + }); + let data = { + vertices, + index: new Uint16Array(index), + uv: null, + normals: vertices, + numTriangles: index.length / 3, + }; + data = this.calculateUVIndexed(data); + return data; + } + calculateUVIndexed(data) { + const uv = new Float32Array(data.vertices.length / 3 * 2); + let uvIndex = 0; + for (let i = 0; i < data.vertices.length / 3; i++) { + uv[uvIndex] = .5 + Math.atan2(data.vertices[i * 3], data.vertices[i * 3 + 2]) / (2 * Math.PI); + uv[uvIndex + 1] = .5 - Math.asin(data.vertices[i * 3 + 1]) / Math.PI; + uvIndex += 2; + } + for (let i = 0; i < data.numTriangles; i++) { + const u0 = uv[data.index[i * 3] * 2]; + const v0 = uv[data.index[i * 3] * 2 + 1]; + const u1 = uv[data.index[i * 3 + 1] * 2]; + const v1 = uv[data.index[i * 3 + 1] * 2 + 1]; + const u2 = uv[data.index[i * 3 + 2] * 2]; + const v2 = uv[data.index[i * 3 + 2] * 2 + 1]; + if (Math.abs(u0 - u1) > .5 || Math.abs(u2 - u0) > .5 || Math.abs(u2 - u1) > .5) { + if (u0 < .5) { + uv[data.index[i * 3] * 2] += 1; + } + if (u1 < .5) { + uv[data.index[i * 3 + 1] * 2] += 1; + } + if (u2 < .5) { + uv[data.index[i * 3 + 2] * 2] += 1; + } + } + if (Math.abs(v0 - v1) > .5 || Math.abs(v2 - v0) > .5 || Math.abs(v2 - v1) > .5) { + if (v0 < .5) { + uv[data.index[i * 3] * 2 + 1] += 1; + } + if (v1 < .5) { + uv[data.index[i * 3 + 1] * 2 + 1] += 1; + } + if (v2 < .5) { + uv[data.index[i * 3 + 2] * 2 + 1] += 1; + } + } + } + return Object.assign(Object.assign({}, data), { uv, normals: data.vertices }); + } + subdivideTrianglesR(store, index, level, v0, v1, v2) { + if (level === 0) { + if (v0.index === -1) { + v0.index = store.length; + store.push(v0); + } + if (v1.index === -1) { + v1.index = store.length; + store.push(v1); + } + if (v2.index === -1) { + v2.index = store.length; + store.push(v2); + } + index.push(v0.index, v1.index, v2.index); + return; + } + const mv0v1 = Vector3T.middle(v0, v1); + const mv1v2 = Vector3T.middle(v1, v2); + const mv2v0 = Vector3T.middle(v2, v0); + this.subdivideTrianglesR(store, index, level - 1, v0, mv0v1, mv2v0); + this.subdivideTrianglesR(store, index, level - 1, mv0v1, v1, mv1v2); + this.subdivideTrianglesR(store, index, level - 1, mv1v2, mv2v0, mv0v1); + this.subdivideTrianglesR(store, index, level - 1, mv2v0, mv1v2, v2); + } +} +exports.default = Sphere; + +},{"../render/geometry/Cube":14}],4:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * A vector 3 is an Float32Array[3] + */ +class Vector3 { + static create() { + return new Float32Array(3); + } + static createFromCoords(x, y, z) { + return Vector3.set(Vector3.create(), x, y, z); + } + static clone(vin) { + return Vector3.createFromCoords(vin[0], vin[1], vin[2]); + } + static set(out, x, y, z) { + out[0] = x; + out[1] = y; + out[2] = z; + return out; + } + static add(out, v0, v1) { + out[0] = v0[0] + v1[0]; + out[1] = v0[1] + v1[1]; + out[2] = v0[2] + v1[2]; + return out; + } + /** + * out = v0 - v1 + * @param out + * @param v0 + * @param v1 + */ + static sub(out, v0, v1) { + out[0] = v0[0] - v1[0]; + out[1] = v0[1] - v1[1]; + out[2] = v0[2] - v1[2]; + return out; + } + static magnitude(v) { + return Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]); + } + static copy(out, v) { + out[0] = v[0]; + out[1] = v[1]; + out[2] = v[2]; + return out; + } + static normalize(out, v) { + const l = Vector3.magnitude(v); + if (l !== 0) { + const ll = 1 / l; + out[0] = v[0] * ll; + out[1] = v[1] * ll; + out[2] = v[2] * ll; + } + return out; + } + static mul(out, v, l) { + out[0] = v[0] * l; + out[1] = v[1] * l; + out[2] = v[2] * l; + return out; + } + /** + * assumes normalized vectors. + */ + static dot(v0, v1) { + return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; + } + static invert(out, v) { + out[0] = v[0] * -1.0; + out[1] = v[1] * -1.0; + out[2] = v[2] * -1.0; + } + static cross(out, a, b) { + out[0] = a[1] * b[2] - a[2] * b[1]; + out[1] = a[2] * b[0] - a[0] * b[2]; + out[2] = a[0] * b[1] - a[1] * b[0]; + return out; + } +} +exports.default = Vector3; + +},{}],5:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Loader = exports.TextResource = exports.ImageResource = exports.ResourceType = void 0; +var ResourceType; +(function (ResourceType) { + ResourceType[ResourceType["Image"] = 0] = "Image"; + ResourceType[ResourceType["Text"] = 1] = "Text"; +})(ResourceType = exports.ResourceType || (exports.ResourceType = {})); +class ImageResource { + constructor(id_, url, onLoaded, onErrored) { + this.type = ResourceType.Image; + const img = new Image(); + img.onload = (e) => { + onLoaded(this); + }; + img.onerror = (e) => { + onErrored(this); + }; + this.id = id_; + this.url = url; + this.image = img; + } + load() { + this.image.src = this.url; + } + get() { + return this.image; + } +} +exports.ImageResource = ImageResource; +class TextResource { + constructor(id_, url, onLoaded, onErrored) { + this.type = ResourceType.Text; + this.id = id_; + this.url = url; + this.xhr = new XMLHttpRequest(); + this.xhr.open("GET", this.url, true); + this.xhr.onload = (ev) => { + if (this.xhr.status != 200) { + this.text = ""; + onErrored(this); + } + else { + this.text = ev.currentTarget ? ev.currentTarget.responseText : ev.target.responseText; + onLoaded(this); + } + }; + this.xhr.onerror = (ev) => { + this.text = ""; + onErrored(this); + }; + } + load() { + console.log(`loading ${this.url}`); + this.xhr.send(); + } + get() { + return this.text; + } +} +exports.TextResource = TextResource; +var LoaderStatus; +(function (LoaderStatus) { + LoaderStatus[LoaderStatus["CREATING"] = 0] = "CREATING"; + LoaderStatus[LoaderStatus["LOADING"] = 1] = "LOADING"; + LoaderStatus[LoaderStatus["DONE"] = 2] = "DONE"; +})(LoaderStatus || (LoaderStatus = {})); +class Loader { + constructor() { + this.numResourcesToLoad = 0; + this.resources = {}; + this.status = LoaderStatus.CREATING; + this.currentLoadedResources = 0; + this.erroredResources = 0; + this.onLoadEnded = null; + } + addImage(url) { + if (typeof url === 'string') { + this.addImageImpl(url); + } + else { + const urls = url; + urls.forEach(u => this.addImageImpl(u)); + } + return this; + } + addText(url) { + if (typeof url === 'string') { + this.addTextImpl(url); + } + else { + const urls = url; + urls.forEach(u => this.addTextImpl(u)); + } + return this; + } + addTextImpl(url) { + if (this.status === LoaderStatus.CREATING) { + let index = url.lastIndexOf('/'); + let id = url.substring(index + 1); // accounts for lastIndexOf===-1 + let endindex = id.lastIndexOf('?'); + if (endindex !== -1) { + id = url.substring(0, endindex); + } + if (this.resources[id] !== void 0) { + console.warn(`${id} has already been added to download list. Skipping`); + } + else { + this.resources[id] = new TextResource(id, url, this.onLoaded.bind(this), this.onErrored.bind(this)); + this.numResourcesToLoad++; + } + } + else { + console.error(`Text Resource not added: ${url}. Bad state.`); + } + } + addImageImpl(url) { + if (this.status === LoaderStatus.CREATING) { + let index = url.lastIndexOf('/'); + let id = url.substring(index + 1); // accounts for lastIndexOf===-1 + let endindex = id.lastIndexOf('?'); + if (endindex !== -1) { + id = url.substring(0, endindex); + } + if (this.resources[id] !== void 0) { + console.warn(`${id} has already been added to download list. Skipping`); + } + else { + this.resources[id] = new ImageResource(id, url, this.onLoaded.bind(this), this.onErrored.bind(this)); + this.numResourcesToLoad++; + } + } + else { + console.error(`HTMLImageElement Resource not added: ${url}. Bad state.`); + } + } + onLoaded(r) { + this.loaded(r); + } + onErrored(r) { + this.erroredResources++; + console.error(`Error loading resource ${r.id}`); + this.loaded(r); + } + loaded(r) { + this.currentLoadedResources++; + if (this.currentLoadedResources === this.numResourcesToLoad) { + this.onLoadEnded(this); + this.status = LoaderStatus.DONE; + } + console.info(`loaded ${r.id} - ${this.currentLoadedResources}/${this.numResourcesToLoad}. Errored: ${this.erroredResources}`); + } + load(cb) { + this.status = LoaderStatus.LOADING; + this.onLoadEnded = cb; + console.info(`About to load ${this.numResourcesToLoad} elements`); + Object.keys(this.resources).forEach(k => this.resources[k].load()); + } + get isError() { + return this.erroredResources !== 0; + } + getText(id) { + return this.resources[id].get(); + } + getImage(id) { + return this.resources[id].get(); + } + getImagesWith(ids) { + const ret = []; + ids.forEach(id => { + const r = this.resources[id]; + if (r !== void 0) { + ret.push(r.get()); + } + }); + return ret; + } + getImages() { + return this.getResourceByType(ResourceType.Image).map((e) => { + return { + image: e.get(), + id: e.id + }; + }); + } + getResourceByType(t) { + const ret = []; + Object.keys(this.resources).forEach(k => { + const r = this.resources[k]; + if (r.type === t) { + ret.push(r); + } + }); + return ret; + } +} +exports.Loader = Loader; + +},{}],6:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * Initialize system. + * Create canvas, get gl2 context, etc. + */ +let Platform = /** @class */ (() => { + class Platform { + static initialize(w, h) { + const c = document.createElement('canvas'); + c.width = w; + c.height = h; + document.body.appendChild(c); + const ctx = c.getContext("webgl2", { + depth: true, + alpha: false, + antialias: false, + premultipliedAlpha: false, + }); + if (ctx) { + Platform.glContext = ctx; + Platform.canvas = c; + } + else { + alert("Webgl2 enabled please."); + } + } + } + Platform.glContext = null; + Platform.canvas = null; + return Platform; +})(); +exports.default = Platform; + +},{}],7:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Vector3_1 = require("../math/Vector3"); +const Matrix4_1 = require("../math/Matrix4"); +const v0 = Vector3_1.default.create(); +const v1 = Vector3_1.default.create(); +function radians(v) { + return v * Math.PI / 180; +} +class Camera { + constructor() { + this.matrix = Matrix4_1.default.create(); + this.viewMatrix = Matrix4_1.default.create(); + this.advanceAmount = 0; + this.strafeAmount = 0; + this.upAmount = 0; + this.yaw = 0; + this.pitch = 0; + this.position = Vector3_1.default.createFromCoords(0, 0, 3); + this.forward = Vector3_1.default.createFromCoords(0, 0, 0); + this.up = Vector3_1.default.createFromCoords(0, 1, 0); + } + static from(c) { + return new Camera().setup(c.position, c.forward, c.up); + } + setup(pos, forward, up) { + Vector3_1.default.copy(this.position, pos); + Vector3_1.default.copy(this.forward, forward); + Vector3_1.default.copy(this.up, up); + Vector3_1.default.normalize(v0, Vector3_1.default.copy(v0, this.forward)); + this.yaw = 180 / Math.PI * Math.atan2(v0[2], v0[0]); + this.pitch = + 180 / Math.PI * Math.asin(v0[1]); + this.sync(); + return this; + } + sync() { + if (this.advanceAmount !== 0) { + this.advance(this.advanceAmount * .25); + } + if (this.strafeAmount !== 0) { + this.strafe(this.strafeAmount * .25); + } + if (this.upAmount !== 0) { + this.moveUp(this.upAmount * .25); + } + Matrix4_1.default.lookAt(this.matrix, this.position, Vector3_1.default.add(v0, this.position, this.forward), this.up); + Matrix4_1.default.viewMatrix(this.viewMatrix, this.matrix); + } + lookAt(x, y, z) { + Vector3_1.default.normalize(this.forward, Vector3_1.default.sub(this.forward, Vector3_1.default.createFromCoords(x, y, z), this.position)); + this.setup(this.position, this.forward, this.up); + } + advance(amount) { + Vector3_1.default.add(this.position, this.position, Vector3_1.default.mul(v0, this.forward, amount)); + } + strafe(amount) { + Vector3_1.default.add(this.position, this.position, Vector3_1.default.mul(v0, Vector3_1.default.normalize(v0, Vector3_1.default.cross(v0, this.forward, this.up)), amount)); + } + moveUp(amount) { + // right + Vector3_1.default.normalize(v0, Vector3_1.default.cross(v0, this.forward, this.up)); + // up + Vector3_1.default.normalize(v1, Vector3_1.default.cross(v1, this.forward, v0)); + Vector3_1.default.add(this.position, this.position, Vector3_1.default.mul(v1, v1, amount)); + } + anglesFrom(ix, iy) { + this.yaw += ix; + this.pitch -= iy; + if (this.pitch > 89) { + this.pitch = 89; + } + if (this.pitch < -89) { + this.pitch = -89; + } + v0[0] = Math.cos(radians(this.pitch)) * Math.cos(radians(this.yaw)); + v0[1] = Math.sin(radians(this.pitch)); + v0[2] = Math.cos(radians(this.pitch)) * Math.sin(radians(this.yaw)); + Vector3_1.default.normalize(this.forward, v0); + this.sync(); + } +} +exports.default = Camera; + +},{"../math/Matrix4":1,"../math/Vector3":4}],8:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Platform_1 = require("../platform/Platform"); +const NullShader_1 = require("./shader/NullShader"); +const Matrix4_1 = require("../math/Matrix4"); +const TextureShader_1 = require("./shader/TextureShader"); +const Vector3_1 = require("../math/Vector3"); +const Camera_1 = require("./Camera"); +const SkyboxShader_1 = require("./shader/SkyboxShader"); +const Cube_1 = require("./geometry/Cube"); +const EnvironmentMapShader_1 = require("./shader/EnvironmentMapShader"); +const Material_1 = require("./Material"); +const Surface_1 = require("./Surface"); +const Mesh_1 = require("./Mesh"); +const Light_1 = require("./Light"); +const Myriahedral_1 = require("./geometry/Myriahedral"); +const Solids_1 = require("./geometry/Solids"); +const Graticule_1 = require("./geometry/Graticule"); +const MaxUnfoldScale = 90; +const N = 64; +let pos = 0; +class Engine { + constructor(w, h) { + this.shader = {}; + this.texture = {}; + this.surface = {}; + this.camera = {}; + this.mesh = {}; + this.light = {}; + this.perspective = Matrix4_1.default.create(); + this.time = 0; + this.matrices = new Float32Array(16 * N * N); + this.matrix = Matrix4_1.default.create(); + this.position = Vector3_1.default.create(); + this.rotation = Vector3_1.default.create(); + this.scale = Vector3_1.default.createFromCoords(1, 1, 1); + this.exy = 0; + this.exz = 0; + this.eyz = 0; + this.unfoldScale = 0; + this.normals = false; + this.cuts = false; + this.folds = false; + this.outline = false; + this.action = 0; + this.longitude = 0; + this.latitude = 0; + this.start = 0; + this.graticules = []; + this.currentGraticuleIndex = -1; + Platform_1.default.initialize(w, h); + this.gl = Platform_1.default.glContext; + this.resize(w, h, true); + // ahemhem + window.engine = this; + } + init() { + const gl = this.gl; + this.currentCamera = new Camera_1.default(); + this.camera["camera0"] = this.currentCamera; + this.shader["null"] = new NullShader_1.default(gl); + this.shader["texture"] = new TextureShader_1.default(gl); + this.shader["textureNoLight"] = new TextureShader_1.default(gl, {}); + this.shader["skybox"] = new SkyboxShader_1.default(gl); + this.shader["reflectiveEnvMap"] = new EnvironmentMapShader_1.EnvironmentMapShader(gl); + this.shader["refractiveEnvMap"] = new EnvironmentMapShader_1.EnvironmentMapShader(gl, true); + this.surface["surface0"] = new Surface_1.default(this, { + width: 256, + height: 256, + attachments: [ + { + renderBufferTarget: gl.DEPTH_STENCIL_ATTACHMENT, + renderBufferInternalFormat: gl.DEPTH24_STENCIL8 + }, + { + renderBufferTarget: gl.COLOR_ATTACHMENT0, + textureDefinition: { + // default. size will be set as Surface size. + } + } + ] + }); + this.mesh["cube2"] = new Cube_1.Cube(this, Material_1.default.Texture(this.getTexture("diffuse"), this.getTexture("specular"), .1, 32), false, N * N); + this.updateInstancingMatrices(); + this.mesh["lightprobe"] = new Cube_1.Cube(this, Material_1.default.Color(new Float32Array([1.0, 0.0, 0.0, 1.0])), false); + this.mesh["cube"] = new Cube_1.Cube(this, Material_1.default.Texture(this.surface["surface0"].texture, this.surface["surface0"].texture, .2, 32), false, N * N); + this.mesh["skybox"] = new Cube_1.Cube(this, Material_1.default.Skybox(this.getTexture("cubemap")), true); + this.buildGraticules(); + this.buildMyriahedrons(); + this.selectGraticule(0); + this.currentCamera.setup([-116.15988159179688, 6.677720546722412, -5.870321273803711], [0.9977958798408508, -0.016972756013274193, 0.06415063887834549], [0, 1, 0]); + this.currentCamera.lookAt(0, 0, 0); + this.light["sun"] = Light_1.default.Directional({ + ambient: [.1, .1, .1], + diffuse: [.5, .5, .5], + specular: [1, 1, 1], + direction: [0, -1, 1] + }); + this.light["point"] = Light_1.default.Point({ + ambient: [.1, .1, .1], + diffuse: [1, 1, 1], + specular: [1, 1, 1], + position: [0, 0, -3] + }); + this.initializeGraphics(); + Platform_1.default.canvas.addEventListener("touchend", (e) => { + const mult = (e.changedTouches[0].pageX < window.innerWidth / 2) ? 1 : -1; + pos += .01 * mult; + this.currentCamera.lookAt(30 * Math.cos(pos), -20, 30 * Math.sin(pos)); + console.log(pos); + }); + } + buildFoldsCutsLines(data, s1, s2, gd) { + const gl = this.gl; + /*****/ + const centers = []; + for (let i = 0; i < data.index.length; i += 3) { + const v0x = data.vertices[data.index[i] * 3]; + const v0y = data.vertices[data.index[i] * 3 + 1]; + const v0z = data.vertices[data.index[i] * 3 + 2]; + const v1x = data.vertices[data.index[i + 1] * 3]; + const v1y = data.vertices[data.index[i + 1] * 3 + 1]; + const v1z = data.vertices[data.index[i + 1] * 3 + 2]; + const v2x = data.vertices[data.index[i + 2] * 3]; + const v2y = data.vertices[data.index[i + 2] * 3 + 1]; + const v2z = data.vertices[data.index[i + 2] * 3 + 2]; + centers.push((v0x + v1x + v2x) / 3); + centers.push((v0y + v1y + v2y) / 3); + centers.push((v0z + v1z + v2z) / 3); + } + const indices = []; + data.folds.forEach(fold => { + indices.push(fold.f0); + indices.push(fold.f1); + }); + if (this.folds) { + const mc = Material_1.default.Color(new Float32Array([1, 0, 1, 1])); + mc.renderMode = gl.POINTS; + gd.foldPoints = new Mesh_1.default().from(this, { + material: mc, + index: new Uint16Array(indices), + vertices: new Float32Array(centers), + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(s2); + const mc2 = Material_1.default.Color(new Float32Array([1, 0, 1, 1])); + mc2.renderMode = gl.LINES; + gd.foldLines = new Mesh_1.default().from(this, { + material: mc2, + index: new Uint16Array(indices), + vertices: new Float32Array(centers), + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(s2); + } + /// cuts + const indicescut = []; + data.cuts.forEach((cut) => { + indicescut.push(cut.vertex0); + indicescut.push(cut.vertex1); + }); + if (this.cuts) { + const mc3 = Material_1.default.Color(new Float32Array([0, 1, 1, 1])); + mc3.renderMode = gl.LINES; + gd.cutLines = new Mesh_1.default().from(this, { + material: mc3, + index: new Uint16Array(indicescut), + vertices: new Float32Array(data.vertices), + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(s2); + const mc4 = Material_1.default.Color(new Float32Array([0, 1, 1, 1])); + mc4.renderMode = gl.POINTS; + gd.cutPoints = new Mesh_1.default().from(this, { + material: mc4, + index: new Uint16Array(indicescut), + vertices: new Float32Array(data.vertices), + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(s2); + } + /*****/ + if (this.normals) { + /// normals + const normals = []; + const indicesnormals = []; + let indexnormals = 0; + for (let i = 0; i < data.index.length; i += 3) { + const x0 = data.vertices[data.index[i + 1] * 3] - data.vertices[data.index[i] * 3]; + const y0 = data.vertices[data.index[i + 1] * 3 + 1] - data.vertices[data.index[i] * 3 + 1]; + const z0 = data.vertices[data.index[i + 1] * 3 + 2] - data.vertices[data.index[i] * 3 + 2]; + const x1 = data.vertices[data.index[i + 2] * 3] - data.vertices[data.index[i] * 3]; + const y1 = data.vertices[data.index[i + 2] * 3 + 1] - data.vertices[data.index[i] * 3 + 1]; + const z1 = data.vertices[data.index[i + 2] * 3 + 2] - data.vertices[data.index[i] * 3 + 2]; + const x = y0 * z1 - z0 * y1; + const y = z0 * x1 - x0 * z1; + const z = x0 * y1 - y0 * x1; + let l = Math.sqrt(x * x + y * y + z * z); + normals.push(x / l, y / l, z / l); + const f = 1.1; + normals.push(x / l * f, y / l * f, z / l * f); + indicesnormals.push(indexnormals++); + indicesnormals.push(indexnormals++); + } + const matnormals = Material_1.default.Color(new Float32Array([1, 1, 1, 1])); + matnormals.renderMode = gl.LINES; + gd.normals = new Mesh_1.default().from(this, { + material: matnormals, + index: new Uint16Array(indicesnormals), + vertices: new Float32Array(normals), + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(s1); + } + } + resize(w, h, force) { + if (force || Platform_1.default.canvas.width !== w || Platform_1.default.canvas.height !== h) { + Platform_1.default.canvas.width = w; + Platform_1.default.canvas.height = h; + this.renderSurfaceSize(w, h); + } + } + renderSurfaceSize(w, h) { + this.renderWidth = w; + this.renderHeight = h; + this.perspective = Matrix4_1.default.perspective(this.perspective, 70 * Math.PI / 180, w / h, 1, 2000); + this.gl.viewport(0, 0, w, h); + } + getShader(s) { + return this.shader[s]; + } + getTexture(s) { + return this.texture[s]; + } + addTexture(name, t) { + this.texture[name] = t; + } + projectionMatrix() { + return this.perspective; + } + cameraMatrix() { + return this.currentCamera.matrix; + } + cameraPosition() { + return this.currentCamera.position; + } + viewMatrix() { + return this.currentCamera.viewMatrix; + } + initializeGraphics() { + this.gl.enable(this.gl.DEPTH_TEST); + this.gl.enable(this.gl.CULL_FACE); + this.gl.clearColor(0, 0, 0, 1); + this.gl.clearDepth(1.0); + this.gl.cullFace(this.gl.BACK); + this.gl.frontFace(this.gl.CCW); + this.gl.enable(this.gl.BLEND); + this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); + } + render(delta) { + // cubemap ambient + // this.surface["surface0"].enableAsTextureTarget(this); + // this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); + // + // this.mesh["cube2"].render(this); + // this.mesh["skybox"].render(this); + // + // this.surface["surface0"].disableAsTextureTarget(this); + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m; + const gl = this.gl; + gl.disable(gl.BLEND); + this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT | this.gl.STENCIL_BUFFER_BIT); + this.currentCamera = this.camera["camera0"]; + this.currentCamera.sync(); + this.updateInstancingMatrices(); + // this.mesh["cube"].renderInstanced(this, this.matrices, N*N); + const light = this.light['point']; + light.setPosition(-100, 50, 40); + const cg = this.currentGraticule; + cg.mesh.euler(this.exy, this.exz, this.eyz); + (_a = cg.outline) === null || _a === void 0 ? void 0 : _a.euler(this.exy, this.exz, this.eyz); + (_b = cg.normals) === null || _b === void 0 ? void 0 : _b.euler(this.exy, this.exz, this.eyz); + (_c = cg.cutLines) === null || _c === void 0 ? void 0 : _c.euler(this.exy, this.exz, this.eyz); + (_d = cg.cutPoints) === null || _d === void 0 ? void 0 : _d.euler(this.exy, this.exz, this.eyz); + (_e = cg.foldLines) === null || _e === void 0 ? void 0 : _e.euler(this.exy, this.exz, this.eyz); + (_f = cg.foldPoints) === null || _f === void 0 ? void 0 : _f.euler(this.exy, this.exz, this.eyz); + cg.mesh.render(this); + if (this.outline) { + (_g = cg.outline) === null || _g === void 0 ? void 0 : _g.render(this); + } + if (this.normals) { + (_h = cg.normals) === null || _h === void 0 ? void 0 : _h.render(this); + } + if (this.cuts) { + (_j = cg.cutLines) === null || _j === void 0 ? void 0 : _j.render(this); + (_k = cg.cutPoints) === null || _k === void 0 ? void 0 : _k.render(this); + } + if (this.folds) { + (_l = cg.foldLines) === null || _l === void 0 ? void 0 : _l.render(this); + (_m = cg.foldPoints) === null || _m === void 0 ? void 0 : _m.render(this); + } + // const moon = this.mesh["moon"]; + // (moon as Mesh).euler(0, (this.time%25000)/25000*2*Math.PI, 0 ); + // moon.render(this); + // light.setPosition( + // 25*Math.cos((this.time%15000)/15000*2*Math.PI), + // 5, + // 25*Math.sin((this.time%15000)/15000*2*Math.PI)); + this.mesh["lightprobe"].setPositionV(light.getPosition()); + this.mesh["lightprobe"].setScale(3); + this.mesh["lightprobe"].getMaterial().definition.color.set(light.getDiffuse()); + const lp = this.mesh["lightprobe"]; + lp.render(this); + this.mesh["skybox"].render(this); + // const p = light.getPosition(); + // this.currentCamera.lookAt(p[0], -p[1], p[2]); + // const angle = ((Date.now() % 30000) / 30000)*2*Math.PI; + // const angle2 = ((Date.now() % 40000) / 40000)*2*Math.PI; + // const r = 10; + // Vector3.set(this.currentCamera.position, + // 0,Math.sin(angle)*3.5 + 5,0); + // this.currentCamera.lookAt( + // r*Math.cos(angle),Math.sin(angle2)*3.5 + 5,r*Math.sin(angle) // from + // ); + // this.currentCamera.sync(); + this.time += delta; + } + updateInstancingMatrices() { + for (let i = 0; i < N * N; i++) { + const row = (i / N) | 0; + const col = i % N; + const tt = 15000; + const t = ((this.time % tt)) / (tt / 2) * Math.PI; + Vector3_1.default.set(this.position, (col - ((N - 1) / 2)) * 3, 20 * Math.sin(2 * Math.PI / N * col + t) * Math.cos(2 * Math.PI / N * row + t), (N / 2 - row) * 3); + Vector3_1.default.set(this.rotation, t, 2 * (t + i) * (i % 2 ? 1 : -1), 0); + // Vector3.set(this.rotation, Math.random()*2*Math.PI, 0, Math.random()*2*Math.PI); + // Vector3.set(this.position, (col - ((N - 1) / 2)) * 3, 0, (row - ((N-1)/2)) * 3); + Vector3_1.default.set(this.scale, 2, 2, 2); + this.matrices.set(Matrix4_1.default.modelMatrix(this.matrix, this.position, this.rotation, this.scale), i * 16); + } + } + mouseEvent(pixelsIncrementX, pixelsIncrementY) { + this.camera["camera0"].anglesFrom(pixelsIncrementX, pixelsIncrementY); + this.camera["camera0"].sync(); + } + updateUnfoldingOutline(data) { + var _a, _b; + (_b = (_a = this.currentGraticule) === null || _a === void 0 ? void 0 : _a.outline) === null || _b === void 0 ? void 0 : _b.remesh(this, data.vertices, data.uv); + } + buildUnfoldingOutline(data) { + const gl = this.gl; + const indices = []; + for (let i = 0; i < data.index.length; i += 3) { + indices.push(data.index[i], data.index[i + 1]); + indices.push(data.index[i + 1], data.index[i + 2]); + indices.push(data.index[i + 2], data.index[i]); + } + const mc = Material_1.default.Color(new Float32Array([1, 1, 1, 1])); + mc.renderMode = gl.LINES; + return new Mesh_1.default().from(this, { + material: mc, + index: new Uint16Array(indices), + vertices: data.vertices, + cullDisabled: true, + uv: null, + normals: null, + }, 1).setScale(30.2); + } + keyboardEvent(key, down) { + var _a, _b; + const c = this.camera["camera0"]; + switch (key) { + case 'w': + c.advanceAmount = down ? 1 : 0; + break; + case 's': + c.advanceAmount = down ? -1 : 0; + break; + case 'a': + c.strafeAmount = down ? -1 : 0; + break; + case 'd': + c.strafeAmount = down ? 1 : 0; + break; + case 'q': + c.upAmount = down ? -1 : 0; + break; + case 'z': + c.upAmount = down ? 1 : 0; + break; + case 'j': + this.exz += Math.PI / 90; + break; + case 'l': + this.exz -= Math.PI / 90; + break; + case 'o': + this.exy -= Math.PI / 90; + break; + case 'k': + this.exy += Math.PI / 90; + break; + case 'i': + this.eyz -= Math.PI / 90; + break; + case 'p': + this.eyz += Math.PI / 90; + break; + case '1': + this.action++; + this.unfoldScale += 1; + if (this.unfoldScale > 90) { + this.unfoldScale = 90; + } + else { + this.unfoldImpl(); + } + break; + case '2': + this.action++; + this.unfoldScale -= 1; + if (this.unfoldScale < 0) { + this.unfoldScale = 0; + } + else { + this.unfoldImpl(); + } + break; + case '0': + if (!down) { + this.normals = !this.normals; + this.foldsCutsInfo(); + } + break; + case '8': + if (!down) { + this.folds = !this.folds; + this.foldsCutsInfo(); + } + break; + case '9': + if (!down) { + this.cuts = !this.cuts; + this.foldsCutsInfo(); + } + break; + case '3': + if (!down) { + this.outline = !this.outline; + this.foldsCutsInfo(); + } + break; + case '4': + // if (!down) { + { + this.longitude++; + this.myriahedral.uv = this.myriahedral.calculateUV(this.longitude / 180 * Math.PI, this.latitude / 180 * Math.PI); + const data = this.myriahedral.getMeshData(); + (_a = this.currentGraticule) === null || _a === void 0 ? void 0 : _a.mesh.remesh(this, data.vertices, data.uv); + } + // } + break; + case '5': + // if (!down) { + { + this.latitude++; + this.myriahedral.uv = this.myriahedral.calculateUV(this.longitude / 180 * Math.PI, this.latitude / 180 * Math.PI); + const data = this.myriahedral.getMeshData(); + (_b = this.currentGraticule) === null || _b === void 0 ? void 0 : _b.mesh.remesh(this, data.vertices, data.uv); + } + // } + break; + case 'f': + if (!down) { + this.action++; + this.fold(() => { + console.log('folded'); + }); + } + break; + case 'u': + if (!down) { + this.action++; + this.unfold(() => { + console.log('unfolded'); + }); + } + break; + case 'g': + this.action++; + if (!down) { + this.nextGraticule(); + } + break; + } + } + buildGraticules() { + this.buildMenuHeader('Graticules'); + Graticule_1.Graticules.forEach(p => { + this.buildGraticule(p); + }); + } + buildGraticule(p) { + const myriahedral = new Myriahedral_1.default().graticule(p); + const data = myriahedral.getMeshData(); + const outline = this.buildUnfoldingOutline(data); + const mesh = new Mesh_1.default().from(this, Object.assign(Object.assign({}, data), { material: Material_1.default.TextureNoLight(this.getTexture("earth"), .6), cullDisabled: true }), 1).setScale(30); + const gr = { + mesh, + myriahedral, + outline, + }; + this.buildFoldsCutsLines(data, 30, 30.5, gr); + this.buildMenuEntry(p.name, this.graticules.length); + this.graticules.push(gr); + } + buildMenuEntry(titleText, index) { + const menu = document.getElementById("menu"); + const menuItem = document.createElement('div'); + const title = document.createElement('span'); + title.innerText = titleText; + title.style.cursor = 'pointer'; + title.style.color = 'white'; + title.style.fontSize = '0.9em'; + title.style.paddingLeft = '15px'; + title.addEventListener('click', () => { + this.selectGraticule(index); + }); + menuItem.appendChild(title); + menu.appendChild(menuItem); + } + buildMenuHeader(titleText) { + const menu = document.getElementById("menu"); + const menuItem = document.createElement('div'); + const br0 = document.createElement('br'); + const br1 = document.createElement('br'); + const title = document.createElement('span'); + title.innerHTML = `${titleText}`; + title.style.fontSize = '1.1em'; + title.style.color = 'white'; + menuItem.appendChild(br0); + menuItem.appendChild(title); + menuItem.appendChild(br1); + menu.appendChild(menuItem); + } + buildMyriahedrons() { + this.buildMenuHeader('Solids'); + const solids = [ + ['Tetrahedron', Solids_1.TetrahedronGeometry], + ['Cube', Solids_1.CubeGeometry], + ['Octahedron', Solids_1.OctahedronGeometry], + ['Icosahedron', Solids_1.IcosahedronGeometry] + ]; + solids.forEach(g => { + this.buildMyriahedron(g); + }); + } + buildMyriahedron(geometry) { + this.buildMenuEntry(geometry[0], this.graticules.length); + const myriahedral = new Myriahedral_1.default().myriahedron({ + name: geometry[1].name, + geometry: geometry[1], + subdivisions: 5, + unfold: true, + normalize: true, + }); + const data1 = myriahedral.getMeshData(); + const outline = this.buildUnfoldingOutline(data1); + const mesh = new Mesh_1.default().from(this, Object.assign(Object.assign({}, data1), { material: Material_1.default.TextureNoLight(this.getTexture("earth"), .6), cullDisabled: true }), 1); + mesh.setScale(30); + this.graticules.push({ + mesh, + myriahedral, + outline, + }); + } + nextGraticule() { + this.selectGraticule(this.currentGraticuleIndex + 1); + } + selectGraticule(i) { + if (i !== this.currentGraticuleIndex) { + this.currentGraticuleIndex = i; + this.fold(() => { + const graticule = this.graticules[this.currentGraticuleIndex]; + this.currentGraticule = graticule; + this.myriahedral = graticule.myriahedral; + this.unfold(() => { + console.log('unfolded'); + }); + }); + } + } + unfold(onUnfoldFinished) { + if (this.myriahedral && this.unfoldScale < MaxUnfoldScale) { + requestAnimationFrame(this.unfoldAnimation.bind(this, onUnfoldFinished, this.action)); + } + else { + onUnfoldFinished(); + } + } + unfoldAnimation(onUnfoldFinished, gi) { + if (gi === this.action) { + this.unfoldScale++; + this.unfoldImpl(); + if (this.unfoldScale < MaxUnfoldScale) { + requestAnimationFrame(this.unfoldAnimation.bind(this, onUnfoldFinished, gi)); + } + else { + onUnfoldFinished(); + } + } + } + fold(onFoldFinished) { + if (this.myriahedral && this.unfoldScale > 0) { + requestAnimationFrame(this.foldAnimation.bind(this, onFoldFinished, this.action)); + } + else { + requestAnimationFrame(onFoldFinished); + } + } + foldAnimation(onFoldFinished, gi) { + if (this.action === gi) { + this.unfoldScale--; + this.unfoldImpl(); + if (this.unfoldScale > 0) { + requestAnimationFrame(this.foldAnimation.bind(this, onFoldFinished, gi)); + } + else { + requestAnimationFrame(onFoldFinished); + } + } + } + unfoldImpl() { + var _a; + this.myriahedral.unfold(this.unfoldScale / MaxUnfoldScale); + const data = this.myriahedral.getMeshData(); + (_a = this.currentGraticule) === null || _a === void 0 ? void 0 : _a.mesh.remesh(this, data.vertices, data.uv); + this.foldsCutsInfo(); + } + foldsCutsInfo(data) { + var _a; + data = data !== null && data !== void 0 ? data : (_a = this.currentGraticule) === null || _a === void 0 ? void 0 : _a.myriahedral.getMeshData(); + this.buildFoldsCutsLines(data, 30, 30.5, this.currentGraticule); + if (this.outline) { + this.updateUnfoldingOutline(data); + } + } +} +exports.default = Engine; + +},{"../math/Matrix4":1,"../math/Vector3":4,"../platform/Platform":6,"./Camera":7,"./Light":9,"./Material":10,"./Mesh":11,"./Surface":12,"./geometry/Cube":14,"./geometry/Graticule":15,"./geometry/Myriahedral":16,"./geometry/Solids":17,"./shader/EnvironmentMapShader":18,"./shader/NullShader":19,"./shader/SkyboxShader":21,"./shader/TextureShader":22}],9:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.PointLight = exports.DirectionalLight = exports.LightType = void 0; +var LightType; +(function (LightType) { + LightType[LightType["DIRECTIONAL"] = 0] = "DIRECTIONAL"; + LightType[LightType["POINT"] = 1] = "POINT"; + LightType[LightType["SPOT"] = 2] = "SPOT"; +})(LightType = exports.LightType || (exports.LightType = {})); +class Light { + constructor(type, li) { + this.enabled = false; + this.type = type; + this.ambient = new Float32Array(li.ambient); + this.diffuse = new Float32Array(li.diffuse); + this.specular = new Float32Array(li.specular); + } + getAmbient() { + return this.ambient; + } + getDiffuse() { + return this.diffuse; + } + getSpecular() { + return this.specular; + } + setAmbient(x, y, z) { + this.set(this.ambient, x, y, z); + } + setDiffuse(x, y, z) { + this.set(this.diffuse, x, y, z); + } + setSpecular(x, y, z) { + this.set(this.specular, x, y, z); + } + set(v, x, y, z) { + v[0] = x; + v[1] = y; + v[2] = z; + } + setEnabled(e) { + this.enabled = e; + } + static Directional(def) { + return new DirectionalLight(def); + } + static Point(def) { + return new PointLight(def); + } +} +exports.default = Light; +class DirectionalLight extends Light { + constructor(li) { + super(LightType.DIRECTIONAL, li); + this.direction = new Float32Array(li.direction); + } + getDirection() { + return this.direction; + } + setDirection(x, y, z) { + this.set(this.direction, x, y, z); + } +} +exports.DirectionalLight = DirectionalLight; +class PointLight extends Light { + constructor(li) { + super(LightType.POINT, li); + this.position = new Float32Array(li.position); + } + getPosition() { + return this.position; + } + setPosition(x, y, z) { + this.set(this.position, x, y, z); + } +} +exports.PointLight = PointLight; + +},{}],10:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MaterialType = void 0; +var MaterialTexture; +(function (MaterialTexture) { + MaterialTexture[MaterialTexture["DIFFUSE"] = 0] = "DIFFUSE"; + MaterialTexture[MaterialTexture["SPECULAR"] = 1] = "SPECULAR"; + MaterialTexture[MaterialTexture["NORMAL"] = 2] = "NORMAL"; + MaterialTexture[MaterialTexture["DISPLACEMENT"] = 3] = "DISPLACEMENT"; +})(MaterialTexture || (MaterialTexture = {})); +var MaterialType; +(function (MaterialType) { + MaterialType[MaterialType["SKYBOX"] = 0] = "SKYBOX"; + MaterialType[MaterialType["TEXTURE"] = 1] = "TEXTURE"; + MaterialType[MaterialType["REFLECTIVE"] = 2] = "REFLECTIVE"; + MaterialType[MaterialType["REFRACTIVE"] = 3] = "REFRACTIVE"; + MaterialType[MaterialType["COLOR"] = 4] = "COLOR"; + MaterialType[MaterialType["TEXTURE_NO_LIGHT"] = 5] = "TEXTURE_NO_LIGHT"; +})(MaterialType = exports.MaterialType || (exports.MaterialType = {})); +class Material { + constructor(t, def) { + this.type = t; + this.definition = def; + } + dispose() { + } + static Reflective(t) { + return new Material(MaterialType.REFLECTIVE, { + diffuse: t, + }); + } + static Refractive(t) { + return new Material(MaterialType.REFRACTIVE, { + diffuse: t, + }); + } + static Skybox(texture) { + return new Material(MaterialType.SKYBOX, { + diffuse: texture, + }); + } + static Texture(diffuse, specular, ambient, shininess) { + return new Material(MaterialType.TEXTURE, { + diffuse, + specular, + ambient, + shininess, + }); + } + static TextureNoLight(diffuse, ambient) { + return new Material(MaterialType.TEXTURE_NO_LIGHT, { + diffuse, + ambient, + }); + } + static Color(color) { + return new Material(MaterialType.COLOR, { + color, + }); + } +} +exports.default = Material; + +},{}],11:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Vector3_1 = require("../math/Vector3"); +const Matrix4_1 = require("../math/Matrix4"); +const Material_1 = require("./Material"); +const SphereTessellator_1 = require("../math/SphereTessellator"); +class Mesh { + constructor() { + this.material = null; + this.shaderInfo = null; + this.position = Vector3_1.default.createFromCoords(0, 0, 0); + this.rotation = Vector3_1.default.createFromCoords(0, 0, 0); + this.scale = Vector3_1.default.createFromCoords(1, 1, 1); + this.transformDirty = true; + this.transform = Matrix4_1.default.create(); + } + dispose(gl) { + this.material.dispose(); + gl.deleteVertexArray(this.shaderInfo.vao); + gl.deleteBuffer(this.shaderInfo.geometryBuffer); + gl.deleteBuffer(this.shaderInfo.indexBuffer); + gl.deleteBuffer(this.shaderInfo.normalBuffer); + gl.deleteBuffer(this.shaderInfo.uvBuffer); + this.shaderInfo.instanceBuffer.dispose(gl); + } + /** + * define a mesh from vertices data, and optionally, vertices indexes. + * + * attrib pointer info will be set consecutively: + * all x,y,z + * all u,v + * + * hence vertexAttribArrayPointer calls will reflect: + * stride of (coords per vertex)*sizeof(FLOAT) = (3*4), offset 0 + * stride of (coords per vertex uv)*sizeof(FLOAT) = (2*4), offset num_vertices * sizeof(FLOAT) + * + */ + from(e, p, instanceCount) { + var _a, _b, _c, _d; + const vertices = p.vertices; + const uv = p.uv; + const index = p.index; + const material = p.material; + this.material = material; + const gl = e.gl; + switch (material.type) { + case Material_1.MaterialType.REFLECTIVE: + this.shaderInfo = e.getShader("reflectiveEnvMap").createVAO(gl, { + vertex: vertices, + normal: (_a = p.normals) !== null && _a !== void 0 ? _a : this.generateNormals(vertices, index), + index, + instanceCount, + cullDisabled: p.cullDisabled, + }, material); + break; + case Material_1.MaterialType.REFRACTIVE: + this.shaderInfo = e.getShader("refractiveEnvMap").createVAO(gl, { + vertex: vertices, + normal: (_b = p.normals) !== null && _b !== void 0 ? _b : this.generateNormals(vertices, index), + index, + instanceCount, + cullDisabled: p.cullDisabled, + }, material); + break; + case Material_1.MaterialType.TEXTURE: + this.shaderInfo = e.getShader("texture").createVAO(gl, { + vertex: vertices, + uv, + normal: (_c = p.normals) !== null && _c !== void 0 ? _c : this.generateNormals(vertices, index), + index, + instanceCount, + cullDisabled: p.cullDisabled, + }, material); + break; + case Material_1.MaterialType.TEXTURE_NO_LIGHT: + this.shaderInfo = e.getShader("textureNoLight").createVAO(gl, { + vertex: vertices, + uv, + normal: (_d = p.normals) !== null && _d !== void 0 ? _d : this.generateNormals(vertices, index), + index, + instanceCount, + cullDisabled: p.cullDisabled, + }, material); + break; + case Material_1.MaterialType.SKYBOX: + this.shaderInfo = e.getShader("skybox").createVAO(gl, { + vertex: vertices, + uv, + index, + instanceCount, + }, material); + break; + case Material_1.MaterialType.COLOR: + this.shaderInfo = e.getShader("null").createVAO(gl, { vertex: vertices, index }, material); + break; + default: + throw new Error(`Unknown material type. ${material}`); + } + return this; + } + remesh(e, vertices, uv) { + const gl = e.gl; + gl.bindVertexArray(this.shaderInfo.vao); + gl.bindBuffer(gl.ARRAY_BUFFER, this.shaderInfo.geometryBuffer); + gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this.shaderInfo.normalBuffer); + gl.bufferData(gl.ARRAY_BUFFER, this.generateNormals(vertices), gl.STATIC_DRAW); + gl.bindBuffer(gl.ARRAY_BUFFER, this.shaderInfo.uvBuffer); + gl.bufferData(gl.ARRAY_BUFFER, uv, gl.STATIC_DRAW); + gl.bindVertexArray(null); + } + generateNormals(vertices, index) { + const v0 = Vector3_1.default.create(); + const v1 = Vector3_1.default.create(); + const v2 = Vector3_1.default.create(); + const v3 = Vector3_1.default.create(); + const v4 = Vector3_1.default.create(); + const v5 = Vector3_1.default.create(); + let normals = new Float32Array(vertices.length); + if (index) { + for (let i = 0; i < index.length; i += 3) { + const v0i = index[i] * 3; + const v1i = index[i + 1] * 3; + const v2i = index[i + 2] * 3; + Vector3_1.default.set(v0, vertices[v0i], vertices[v0i + 1], vertices[v0i + 2]); + Vector3_1.default.set(v1, vertices[v1i], vertices[v1i + 1], vertices[v1i + 2]); + Vector3_1.default.set(v2, vertices[v2i], vertices[v2i + 1], vertices[v2i + 2]); + Vector3_1.default.sub(v3, v0, v1); + Vector3_1.default.sub(v4, v0, v2); + Vector3_1.default.cross(v5, v4, v3); // normal + normals[v0i] += v5[0]; + normals[v0i + 1] += v5[1]; + normals[v0i + 2] += v5[2]; + normals[v1i] += v5[0]; + normals[v1i + 1] += v5[1]; + normals[v1i + 2] += v5[2]; + normals[v2i] += v5[0]; + normals[v2i + 1] += v5[1]; + normals[v2i + 2] += v5[2]; + } + } + else { + for (let i = 0; i < vertices.length; i += 9) { + const v0i = i; + const v1i = i + 3; + const v2i = i + 6; + Vector3_1.default.set(v0, vertices[v0i], vertices[v0i + 1], vertices[v0i + 2]); + Vector3_1.default.set(v1, vertices[v1i], vertices[v1i + 1], vertices[v1i + 2]); + Vector3_1.default.set(v2, vertices[v2i], vertices[v2i + 1], vertices[v2i + 2]); + Vector3_1.default.sub(v3, v1, v0); + Vector3_1.default.sub(v4, v2, v0); + Vector3_1.default.cross(v5, v3, v4); // normal + normals[v0i] += v5[0]; + normals[v0i + 1] += v5[1]; + normals[v0i + 2] += v5[2]; + normals[v1i] += v5[0]; + normals[v1i + 1] += v5[1]; + normals[v1i + 2] += v5[2]; + normals[v2i] += v5[0]; + normals[v2i + 1] += v5[1]; + normals[v2i + 2] += v5[2]; + } + } + // normalize. + for (let i = 0; i < normals.length; i += 3) { + const v = Math.sqrt(normals[i] * normals[i] + normals[i + 1] * normals[i + 1] + normals[i + 2] * normals[i + 2]); + normals[i] /= v; + normals[i + 1] /= v; + normals[i + 2] /= v; + } + return normals; + } + transformMatrix() { + // transformation needs rebuild + if (this.transformDirty) { + Matrix4_1.default.modelMatrix(this.transform, this.position, this.rotation, this.scale); + this.transformDirty = false; + } + return this.transform; + } + render(e) { + this.renderInstanced(e, this.transform, this.shaderInfo.instanceCount); + } + renderInstanced(e, locals, numInstances) { + this.transformMatrix(); + const gl = e.gl; + this.shaderInfo.instanceBuffer && this.shaderInfo.instanceBuffer.updateWith(gl, locals); + this.shaderInfo.shader.render(e, this.shaderInfo, this); + } + getMaterial() { + return this.material; + } + getMatrix() { + return this.transformMatrix(); + } + euler(x, y, z) { + this.rotation[0] = x; + this.rotation[1] = y; + this.rotation[2] = z; + this.transformDirty = true; + return this; + } + setPosition(x, y, z) { + Vector3_1.default.set(this.position, x, y, z); + this.transformDirty = true; + return this; + } + setPositionV(a) { + Vector3_1.default.copy(this.position, a); + this.transformDirty = true; + return this; + } + getPosition() { + return this.position; + } + setScale(s) { + Vector3_1.default.set(this.scale, s, s, s); + this.transformDirty = true; + return this; + } + // + // static tessellateSphereRec(e: Engine, i: TessellationInfo): Mesh { + // // const data = new SphereTessellator().tessellateFromTetrahedronRec(i.subdivisions); + // + // const m = new Myriahedral(i.subdivisions); + // const data = m.getMeshData(); + // + // return new Mesh().from(e, { + // ...data, + // material: i.material, + // cullDisabled: i.cullDisabled, + // }, i.instanceCount ?? 1); + // + // } + static tessellateSphere(e, i) { + var _a; + const data = new SphereTessellator_1.default().tessellateFromTetrahedronRec(i.subdivisions); + return new Mesh().from(e, Object.assign(Object.assign({}, data), { material: i.material, cullDisabled: true }), (_a = i.instanceCount) !== null && _a !== void 0 ? _a : 1); + } + static tessellateSphereFromCube(e, i) { + var _a; + const data = new SphereTessellator_1.default().tessellateFromCube(i.subdivisions); + return new Mesh().from(e, Object.assign(Object.assign({}, data), { material: i.material, cullDisabled: i.cullDisabled }), (_a = i.instanceCount) !== null && _a !== void 0 ? _a : 1); + } +} +exports.default = Mesh; + +},{"../math/Matrix4":1,"../math/SphereTessellator":3,"../math/Vector3":4,"./Material":10}],12:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Texture_1 = require("./Texture"); +const Platform_1 = require("../platform/Platform"); +class Surface { + constructor(e, def) { + this.frameBuffer = null; + this.renderBuffer = null; + this.texture_ = null; + this.definition = def; + this.initialize(e); + } + initialize(e) { + const gl = e.gl; + this.frameBuffer = gl.createFramebuffer(); + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer); + this.renderBuffer = gl.createRenderbuffer(); + gl.bindRenderbuffer(gl.RENDERBUFFER, this.renderBuffer); + this.definition.attachments.forEach(attachment => { + if (attachment.renderBufferTarget >= gl.COLOR_ATTACHMENT0 && attachment.renderBufferTarget <= gl.COLOR_ATTACHMENT15) { + // override texture size with framebuffer size. + attachment.textureDefinition.width = this.definition.width; + attachment.textureDefinition.height = this.definition.height; + this.texture_ = Texture_1.default.initialize(gl, attachment.textureDefinition); + gl.framebufferTexture2D(gl.FRAMEBUFFER, attachment.renderBufferTarget, this.texture_.target, this.texture_.glTexture_, 0); + } + else { + if (this.definition.samples !== void 0) { + gl.renderbufferStorageMultisample(gl.RENDERBUFFER, this.definition.samples, attachment.renderBufferInternalFormat, this.definition.width, this.definition.height); + } + else { + gl.renderbufferStorage(gl.RENDERBUFFER, attachment.renderBufferInternalFormat, this.definition.width, this.definition.height); + } + gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment.renderBufferTarget, gl.RENDERBUFFER, this.renderBuffer); + } + }); + if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) { + throw new Error(`FrameBuffer incomplete.`); + } + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + } + enableAsTextureTarget(e) { + const gl = e.gl; + gl.bindFramebuffer(gl.FRAMEBUFFER, this.frameBuffer); + e.renderSurfaceSize(this.definition.width, this.definition.height); + } + disableAsTextureTarget(e) { + e.gl.bindFramebuffer(e.gl.FRAMEBUFFER, null); + e.renderSurfaceSize(Platform_1.default.canvas.width, Platform_1.default.canvas.height); + } + get texture() { + return this.texture_; + } +} +exports.default = Surface; + +},{"../platform/Platform":6,"./Texture":13}],13:[function(require,module,exports){ +"use strict"; +/** + * Texture uses mipmaps by default. + * + * internal_format and format, are not required to be equal in webgl2. + * Combinations are here: + * https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml + */ +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * A general texture class. + * It honors bitmaps that will be constructed based on the TextureInitialized filter parameter. + */ +class Texture { + constructor() { + this.glTexture_ = null; + this.width = -1; + this.height = -1; + this.target = -1; + } + static initializeCubeMap(gl, elements) { + return Texture.initialize(gl, { + target: gl.TEXTURE_CUBE_MAP, + element: elements, + wrap_mode: gl.CLAMP_TO_EDGE, + minFilter: gl.LINEAR, + internal_format: gl.RGBA, + format: gl.RGBA + }); + } + static initialize(gl, info) { + if (info.target === void 0) { + info.target = gl.TEXTURE_2D; + } + const glTexture_ = gl.createTexture(); + gl.bindTexture(info.target, glTexture_); + const arrayView = info.pixels !== void 0 ? info.pixels : null; + if (info.internal_format === void 0) { + info.internal_format = gl.RGBA; + } + if (info.format === void 0) { + info.format = info.internal_format; + } + if (info.type === void 0) { + info.type = gl.UNSIGNED_BYTE; + } + if (info.element) { + if (Array.isArray(info.element)) { + if (info.target === gl.TEXTURE_CUBE_MAP) { + info.element.forEach((img, index) => { + gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + index, 0, info.internal_format, img.width, img.height, 0, info.format, info.type, img); + }); + } + else { + throw (new Error("Texture type bad: array of images, not cubemap")); + } + } + else { + // not array + const element = info.element; + info.width = element.width; + info.height = element.height; + gl.texImage2D(info.target, info.level || 0, info.internal_format, info.width, info.height, 0, info.format, info.type, element); + } + } + else { + gl.texImage2D(info.target, info.level || 0, info.internal_format, info.width, info.height, 0, info.format, info.type, arrayView); + } + const texture = new Texture(); + texture.glTexture_ = glTexture_; + texture.width = info.width; + texture.height = info.height; + texture.target = info.target; + // default filter if not present + if (info.minFilter === void 0) { + info.minFilter = gl.LINEAR; + } + // generate mipmaps if needed + if (info.minFilter === gl.NEAREST_MIPMAP_NEAREST || + info.minFilter === gl.NEAREST_MIPMAP_LINEAR || + info.minFilter === gl.LINEAR_MIPMAP_NEAREST || + info.minFilter === gl.LINEAR_MIPMAP_LINEAR) { + gl.generateMipmap(info.target); + } + if (info.magFilter === void 0) { + info.magFilter = gl.LINEAR; + } + gl.texParameteri(info.target, gl.TEXTURE_MIN_FILTER, info.minFilter); + gl.texParameteri(info.target, gl.TEXTURE_MAG_FILTER, info.magFilter); + // default wrap mode + if (info.wrap_mode === void 0) { + info.wrap_mode = gl.CLAMP_TO_EDGE; + } + gl.texParameteri(info.target, gl.TEXTURE_WRAP_S, info.wrap_mode); + gl.texParameteri(info.target, gl.TEXTURE_WRAP_T, info.wrap_mode); + if (info.target === gl.TEXTURE_CUBE_MAP) { + gl.texParameteri(info.target, gl.TEXTURE_WRAP_R, info.wrap_mode); + } + gl.bindTexture(texture.target, null); + return texture; + } + bindAsRenderTarget() { + } + bind(gl) { + gl.bindTexture(this.target, this.glTexture_); + } + dispose(gl) { + gl.deleteTexture(this.glTexture_); + } + enableAsUnit(gl, unit) { + gl.activeTexture(gl.TEXTURE0 + unit); + gl.bindTexture(this.target, this.glTexture_); + } +} +exports.default = Texture; + +},{}],14:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Cube = exports.CubeIndices = exports.CubeVertices = void 0; +const Mesh_1 = require("../Mesh"); +exports.CubeVertices = new Float32Array([ + 0.5, -0.5, -0.5, + -0.5, -0.5, -0.5, + -0.5, -0.5, 0.5, + 0.5, -0.5, 0.5, + 0.5, 0.5, -0.5, + -0.5, 0.5, -0.5, + -0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, +]); +const uv = new Float32Array([0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1]); +exports.CubeIndices = new Uint16Array([ + 2, 1, 0, 3, 2, 0, + 3, 0, 4, 7, 3, 4, + 0, 1, 5, 4, 0, 5, + 1, 2, 6, 5, 1, 6, + 2, 3, 7, 6, 2, 7, + 4, 5, 6, 7, 4, 6, +]); +class Cube extends Mesh_1.default { + constructor(e, material, indexed, instanceCount) { + super(); + if (indexed) { + this.buildIndexed(e, material, instanceCount); + } + else { + this.build(e, material, instanceCount); + } + } + buildIndexed(e, material, instanceCount) { + this.from(e, { + vertices: exports.CubeVertices, + uv: uv, + index: exports.CubeIndices, + material + }, instanceCount || 1); + } + build(e, material, instanceCount) { + const vertices = new Float32Array([ + -0.5, -0.5, 0.5, + 0.5, -0.5, 0.5, + 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, + -0.5, 0.5, 0.5, + -0.5, -0.5, 0.5, + -0.5, 0.5, 0.5, + -0.5, 0.5, -0.5, + -0.5, -0.5, -0.5, + -0.5, -0.5, -0.5, + -0.5, -0.5, 0.5, + -0.5, 0.5, 0.5, + -0.5, -0.5, -0.5, + 0.5, -0.5, -0.5, + 0.5, -0.5, 0.5, + 0.5, -0.5, 0.5, + -0.5, -0.5, 0.5, + -0.5, -0.5, -0.5, + 0.5, -0.5, -0.5, + 0.5, 0.5, -0.5, + 0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, + 0.5, -0.5, 0.5, + 0.5, -0.5, -0.5, + 0.5, 0.5, -0.5, + 0.5, -0.5, -0.5, + -0.5, -0.5, -0.5, + -0.5, -0.5, -0.5, + -0.5, 0.5, -0.5, + 0.5, 0.5, -0.5, + 0.5, 0.5, 0.5, + 0.5, 0.5, -0.5, + -0.5, 0.5, -0.5, + -0.5, 0.5, -0.5, + -0.5, 0.5, 0.5, + 0.5, 0.5, 0.5, + ]); + const uv = new Float32Array([ + 0.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 1.0, 1.0, + 0.0, 1.0, + 0.0, 0.0, + 0.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 1.0, 1.0, + 0.0, 1.0, + 0.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 0.0, 1.0, + 0.0, 1.0, + 0.0, 0.0, + 1.0, 0.0, + 1.0, 0.0, + 1.0, 1.0, + 0.0, 1.0, + 0.0, 1.0, + 0.0, 0.0, + 1.0, 0.0, + 0.0, 1.0, + 1.0, 1.0, + 1.0, 0.0, + 1.0, 0.0, + 0.0, 0.0, + 0.0, 1.0, + 0.0, 1.0, + 1.0, 1.0, + 1.0, 0.0, + 1.0, 0.0, + 0.0, 0.0, + 0.0, 1.0 + ]); + this.from(e, { + vertices, + uv, + material, + index: null, + }, instanceCount || 1); + } +} +exports.Cube = Cube; + +},{"../Mesh":11}],15:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Graticule = exports.Graticules = exports.GraticuleType = void 0; +const Myriahedral_1 = require("./Myriahedral"); +var QuadDirection; +(function (QuadDirection) { + QuadDirection[QuadDirection["Left"] = 0] = "Left"; + QuadDirection[QuadDirection["Right"] = 1] = "Right"; + QuadDirection[QuadDirection["Top"] = 2] = "Top"; + QuadDirection[QuadDirection["Down"] = 3] = "Down"; +})(QuadDirection || (QuadDirection = {})); +var GraticuleType; +(function (GraticuleType) { + GraticuleType[GraticuleType["Cylindrical"] = 0] = "Cylindrical"; + GraticuleType[GraticuleType["Conical"] = 1] = "Conical"; + GraticuleType[GraticuleType["Azimutal"] = 2] = "Azimutal"; + GraticuleType[GraticuleType["AzimutalTwoHemispheres"] = 3] = "AzimutalTwoHemispheres"; + GraticuleType[GraticuleType["Polyconical"] = 4] = "Polyconical"; + GraticuleType[GraticuleType["Strip"] = 5] = "Strip"; +})(GraticuleType = exports.GraticuleType || (exports.GraticuleType = {})); +exports.Graticules = [ + { + type: GraticuleType.Cylindrical, + parallels: 11, + name: 'Cylindrical', + }, + { + type: GraticuleType.Conical, + name: 'Conical', + }, + { + type: GraticuleType.Azimutal, + name: 'Azimutal', + }, + { + type: GraticuleType.AzimutalTwoHemispheres, + name: 'Azimutal two hemispheres', + }, + { + type: GraticuleType.Polyconical, + name: 'Polyconical', + }, + { + type: GraticuleType.Strip, + name: 'Strip', + parallels: 14, + } +]; +class Graticule { + constructor() { + this.vertices = []; + this.faces = new Map(); + this.folds = []; + this.parallels = 0; + this.connectedQuads = new Myriahedral_1.MM(); + } + build(p) { + var _a; + this.parallels = (_a = p.parallels) !== null && _a !== void 0 ? _a : 24; + this.buildVerticesAndFaces(); + this.setEdgesFaceIndices(); + this.connectGraticule(p.type); + this.filterOutInvalidFaces(); + return this; + } + connectGraticule(t) { + switch (t) { + case GraticuleType.Azimutal: + this.connectGraticuleAzimutal(); + break; + case GraticuleType.AzimutalTwoHemispheres: + this.connectGraticuleAzimutalTwoHemispheres(); + break; + case GraticuleType.Conical: + this.connectGraticuleConical(); + break; + case GraticuleType.Cylindrical: + this.connectGraticuleCylindrical(); + break; + case GraticuleType.Polyconical: + this.connectGraticulePolyconical(); + break; + case GraticuleType.Strip: + this.connectStrip(); + break; + default: + throw new Error(`unknown graticule type: ${t}`); + } + } + filterOutInvalidFaces() { + this.folds = this.folds.filter(f => { + return f.fromFaceIndex !== null && f.toFaceIndex !== null; + }); + } + connectGraticuleCylindrical() { + this.connectGraticuleCylindricalOrConical((this.parallels / 2) | 0, this.parallels); + } + connectGraticuleConical() { + this.connectGraticuleCylindricalOrConical((this.parallels / 3) | 0, this.parallels); + } + connectGraticuleCylindricalOrConical(row, col) { + this.startFoldsConnections(row, col); + // horizontal connection + for (let j = 0; j <= this.parallels; j++) { + this.connectQuadByDirection(row, col - j, QuadDirection.Left); + this.connectQuadByDirection(row, col + j, QuadDirection.Right); + } + // vertical connections (up) + for (let i = 0; i < row; i++) { + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(row - i, j, QuadDirection.Top); + } + } + // vertical connections (down) + const t1 = this.parallels - row; + for (let i = 0; i < t1; i++) { + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(row + i, j, QuadDirection.Down); + } + } + this.root.parent = null; + } + connectStrip() { + const row = 1; + const col = 0; + this.startFoldsConnections(row, col); + // lines + for (let i = row; i < this.parallels - 1; i++) { + if ((i % 2) === 1) { + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(i, j, QuadDirection.Right); + } + this.connectQuadByDirection(i, this.parallels * 2 - 1, QuadDirection.Down); + } + else { + for (let j = this.parallels * 2 - 1; j > 0; j--) { + this.connectQuadByDirection(i, j, QuadDirection.Left); + } + this.connectQuadByDirection(i, 0, QuadDirection.Down); + } + } + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(row, j, QuadDirection.Top); + this.connectQuadByDirection(this.parallels - 2, j, QuadDirection.Down); + } + this.root.parent = null; + } + connectGraticuleAzimutalTwoHemispheres() { + const mid = (this.parallels / 2) | 0; + this.startFoldsConnections(mid, this.parallels); + for (let i = 0; i < 2 * this.parallels - 1; i++) { + this.connectQuadByDirection(0, i, QuadDirection.Right); + this.connectQuadByDirection(this.parallels - 1, i, QuadDirection.Right); + } + for (let i = 0; i < mid; i++) { + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(mid - i - 1, j, QuadDirection.Top); + this.connectQuadByDirection(mid + i, j, QuadDirection.Down); + } + } + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuad(mid, j); + this.connectQuad(mid - 1, j); + } + this.connectQuadByDirection(mid, this.parallels, QuadDirection.Top); + this.root.parent = null; + } + connectGraticuleAzimutal() { + this.startFoldsConnections(0, 0); + // horizontal first row + for (let i = 0; i < 2 * this.parallels - 1; i++) { + this.connectQuadByDirection(0, i, QuadDirection.Right); + } + for (let i = 0; i < this.parallels - 1; i++) { + for (let j = 0; j < this.parallels * 2; j++) { + this.connectQuadByDirection(i, j, QuadDirection.Down); + } + } + this.root.parent = null; + } + connectGraticulePolyconical() { + const row = Math.floor(this.parallels / 2); + this.startFoldsConnections(row, this.parallels); + for (let i = row; i > 0; i--) { + this.connectQuadByDirection(i, this.parallels, QuadDirection.Top); + } + for (let i = row; i < this.parallels; i++) { + this.connectQuadByDirection(i, this.parallels, QuadDirection.Down); + } + for (let i = 1; i < this.parallels - 1; i++) { + for (let j = this.parallels; j > 0; j--) { + this.connectQuadByDirection(i, j, QuadDirection.Left); + } + for (let j = this.parallels; j < 2 * this.parallels - 1; j++) { + this.connectQuadByDirection(i, j, QuadDirection.Right); + } + } + for (let i = 0; i < this.parallels * 2 - 1; i++) { + this.connectQuadByDirection(0, i, QuadDirection.Right); + this.connectQuadByDirection(this.parallels - 1, i, QuadDirection.Right); + } + } + faceIndexForQuadAt(row, column, d) { + return (row * this.parallels * 2 + column) * 2 + (d !== undefined ? 1 : 0); + } + startFoldsConnections(row, column) { + this.root = this.connectQuad(row, column); + } + getQuadCommonEdge(row, column) { + const o = this.faceIndexForQuadAt(row, column); + return this.faces.get(o).edges[2]; + } + getTriangleEdge(row, column, inc) { + let e; + if (row === 0) { + const o = this.faceIndexForQuadAt(row, column) + 1; + e = this.faces.get(o).edges[0]; + e.faceIndices[1] = o + inc; + } + else if (row === this.parallels - 1) { + const o = this.faceIndexForQuadAt(row, column); + e = this.faces.get(o).edges[1]; + e.faceIndices[1] = o + inc; + } + return e; + } + getTriangleRightEdge(row, column) { + return this.getTriangleEdge(row, column, 2); + } + getTriangleLeftEdge(row, column) { + return this.getTriangleEdge(row, column, -2); + } + getQuadRightEdge(row, column) { + const o = this.faceIndexForQuadAt(row, column); + return this.faces.get(o).edges[1]; + } + getQuadTopEdge(row, column) { + const o = this.faceIndexForQuadAt(row, column); + return this.faces.get(o).edges[0]; + } + getQuadBottomEdge(row, column) { + const o = this.faceIndexForQuadAt(row, column, QuadDirection.Down); + return this.faces.get(o).edges[1]; + } + getQuadLeftEdge(row, column) { + const o = this.faceIndexForQuadAt(row, column, QuadDirection.Left); + return this.faces.get(o).edges[2]; + } + connectQuad(row, column) { + let edge = this.connectedQuads.get(row, column); + if (!edge) { + edge = new Myriahedral_1.FacesEdge(this.getQuadCommonEdge(row, column)); + this.folds.push(edge); + this.connectedQuads.insert(row, column, edge); + } + return edge; + } + connectQuadByDirection(row, column, d) { + const ne = this.foldByDirection(row, column, d); + if (ne) { + this.folds.push(ne); + return ne; + } + else { + console.error('nono'); + } + return undefined; + } + rowWithQuads(r) { + return r > 0 && r < this.parallels - 1; + } + foldByDirection(row, column, d) { + let r; + let nq; + switch (d) { + case QuadDirection.Left: + if (column > 0) { + if (this.rowWithQuads(row)) { + nq = this.connectQuad(row, column - 1); + r = new Myriahedral_1.FacesEdge(this.getQuadLeftEdge(row, column)); + } + else { + r = new Myriahedral_1.FacesEdge(this.getTriangleLeftEdge(row, column)); + } + } + break; + case QuadDirection.Right: + if (column < 2 * this.parallels - 1) { + if (this.rowWithQuads(row)) { + nq = this.connectQuad(row, column + 1); + r = new Myriahedral_1.FacesEdge(this.getQuadRightEdge(row, column)); + } + else { + r = new Myriahedral_1.FacesEdge(this.getTriangleRightEdge(row, column)); + } + } + break; + case QuadDirection.Top: + if (row > 0) { + if (this.rowWithQuads(row - 1)) { + nq = this.connectQuad(row - 1, column); + } + r = new Myriahedral_1.FacesEdge(this.getQuadTopEdge(row, column)); + } + break; + case QuadDirection.Down: + if (row < this.parallels - 1) { + if (this.rowWithQuads(row + 1)) { + nq = this.connectQuad(row + 1, column); + } + r = new Myriahedral_1.FacesEdge(this.getQuadBottomEdge(row, column)); + } + break; + } + if (r) { + r.parent = this.connectedQuads.get(row, column); + if (nq && !nq.parent) { + nq.parent = r; + } + else { + // console.error(`quad fold with parent`); + } + } + return r; + } + static spherical(t, u) { + t *= Math.PI * 2; + u *= Math.PI; + return new Myriahedral_1.Vertex(Math.sin(u) * Math.cos(t), Math.cos(u), Math.sin(u) * Math.sin(t)); + } + buildVerticesAndFaces() { + const rows = this.parallels; + const cols = this.parallels * 2; + const vertexPerRow = cols + 1; + for (let i = 0; i < rows; i++) { + for (let j = 0; j < cols; j++) { + const p0 = Graticule.spherical(j / cols, i / rows); + const p1 = Graticule.spherical((j + 1) / cols, i / rows); + const p2 = Graticule.spherical((j + 1) / cols, (i + 1) / rows); + const p3 = Graticule.spherical(j / cols, (i + 1) / rows); + const fi0 = this.addFace(p0.clone(), p1.clone(), p2.clone()); + fi0.prevVerticesIndices = [ + i * vertexPerRow + j, + i * vertexPerRow + j + 1, + (i + 1) * vertexPerRow + j + 1, + ]; + const fi1 = this.addFace(p0.clone(), p2.clone(), p3.clone()); + fi1.prevVerticesIndices = [ + i * vertexPerRow + j, + (i + 1) * vertexPerRow + j + 1, + (i + 1) * vertexPerRow + j, + ]; + if (fi0[0] !== fi1[0] || fi0[2] !== fi1[1]) { + console.error(`wrong common axis def`); + } + } + } + } + addVertex(v) { + v.index = this.vertices.length; + this.vertices.push(v); + } + addFace(p0, p1, p2) { + this.addVertex(p0); + this.addVertex(p1); + this.addVertex(p2); + const vertices = [p0, p1, p2]; + const fi = { + vertices, + normal: Myriahedral_1.Vertex.normalForVertices(vertices), + id: this.faces.size, + prevId: this.faces.size, + prevVerticesIndices: [p0.index, p1.index, p2.index], + edges: [ + new Myriahedral_1.Edge(p0.index, p1.index), + new Myriahedral_1.Edge(p1.index, p2.index), + new Myriahedral_1.Edge(p2.index, p0.index), + ], + }; + this.faces.set(fi.id, fi); + return fi; + } + setEdgesFaceIndices() { + // edges connections: + const rows = this.parallels; + const cols = this.parallels * 2 * 2; + for (let i = 0; i < rows; i++) { + for (let j = 0; j < cols; j++) { + const faceIndex = j + i * cols; + const faceInfo = this.faces.get(faceIndex); + const edges = faceInfo.edges; + if ((faceIndex % 2) === 0) { + // top edge. Connect to row above+1 + this.edgeFaceIndices(edges[0], faceIndex, j + 1 + (i - 1) * cols); + // right edge. connect to index+2 + this.edgeFaceIndices(edges[1], faceIndex, faceIndex + 3); + // common edge + this.edgeFaceIndices(edges[2], faceIndex, faceIndex + 1); + } + else { + // common edge + this.edgeFaceIndices(edges[0], faceIndex, faceIndex - 1); + // bottom edge + this.edgeFaceIndices(edges[1], faceIndex, j + (i + 1) * cols - 1); + // left edge + this.edgeFaceIndices(edges[2], faceIndex, faceIndex - 3); + } + } + } + } + edgeFaceIndices(edge, i0, i1) { + if (i1 >= 0 && i1 < this.faces.size) { + edge.faceIndices[0] = i0; + edge.faceIndices[1] = i1; + } + } +} +exports.Graticule = Graticule; + +},{"./Myriahedral":16}],16:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MM = exports.FacesEdge = exports.Edge = exports.Vertex = void 0; +const Vector3_1 = require("../../math/Vector3"); +const Quaternion_1 = require("../../math/Quaternion"); +const Graticule_1 = require("./Graticule"); +class Vertex { + constructor(x, y, z) { + this.x = x; + this.y = y; + this.z = z; + this.index = 0; + } + static middle(v0, v1) { + return new Vertex(v0.x + (v1.x - v0.x) / 2., v0.y + (v1.y - v0.y) / 2., v0.z + (v1.z - v0.z) / 2.); + } + normalize() { + const l = 1 / Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); + this.x *= l; + this.y *= l; + this.z *= l; + } + dot(o) { + // assumes normalized. + return this.x * o.x + this.y * o.y + this.z * o.z; + } + clone() { + const v = new Vertex(this.x, this.y, this.z); + v.index = this.index; + return v; + } + copy(o) { + this.x = o.x; + this.y = o.y; + this.z = o.z; + } + equals(o) { + return Math.abs(this.x - o.x) < 1e-9 && + Math.abs(this.y - o.y) < 1e-9 && + Math.abs(this.z - o.z) < 1e-9; + } + static normalForVertices(v) { + const x0 = v[0].x - v[1].x; + const y0 = v[0].y - v[1].y; + const z0 = v[0].z - v[1].z; + const x1 = v[0].x - v[2].x; + const y1 = v[0].y - v[2].y; + const z1 = v[0].z - v[2].z; + const x = y0 * z1 - z0 * y1; + const y = z0 * x1 - x0 * z1; + const z = x0 * y1 - y0 * x1; + const l = Math.sqrt(x * x + y * y + z * z); + if (l === 0) { + // there's no normal. Since we are in an goniometric sphere, this should be fine. + return [v[0].x, v[0].y, v[0].z]; + } + return [x / l, y / l, z / l]; + } +} +exports.Vertex = Vertex; +class Edge { + constructor(vertex0, vertex1) { + this.vertex0 = vertex0; + this.vertex1 = vertex1; + this.w0 = 0; + this.w1 = 0; + this.wc = 0; + this.centerIndex = -1; // when an edge is split during recursive subdivision, + // this is the newly created vertex index. + // edge info: from->to, face index. + // two entries per edge. + this.faceIndices = [null, null]; // polygon index + } + facesDirection(i) { + let v0 = i.fromVertex; + let v1 = i.toVertex; + const index = (v0 === this.vertex0 && v1 === this.vertex1) ? 0 : 1; + this.faceIndices[index] = i.faceIndex; + } + swap() { + [this.faceIndices[0], this.faceIndices[1]] = [this.faceIndices[1], this.faceIndices[0]]; + [this.vertex0, this.vertex1] = [this.vertex1, this.vertex0]; + } +} +exports.Edge = Edge; +let FacesEdge = /** @class */ (() => { + class FacesEdge { + constructor(edge) { + this.edge = edge; + this.children = []; + this.orientationMultiplier = 1; + this.commonAxisVertices = []; + this.wc = -1; + this.id = FacesEdge.__id++; + this.wc = edge.wc; + this.parent = null; + } + get fromFaceIndex() { + return this.edge.faceIndices[0]; + } + get toFaceIndex() { + return this.edge.faceIndices[1]; + } + get v0() { + return this.edge.vertex0; + } + get v1() { + return this.edge.vertex1; + } + swap() { + this.edge.swap(); + } + } + FacesEdge.__id = 0; + return FacesEdge; +})(); +exports.FacesEdge = FacesEdge; +class MM { + constructor() { + this.map = new Map(); + } + insert(k0, k1, v) { + let m = this.map.get(k0); + if (m === undefined) { + m = new Map(); + this.map.set(k0, m); + } + m.set(k1, v); + } + get(k0, k1) { + var _a; + return (_a = this.map.get(k0)) === null || _a === void 0 ? void 0 : _a.get(k1); + } + getI(k0, k1) { + var _a, _b, _c; + return (_b = (_a = this.map.get(k0)) === null || _a === void 0 ? void 0 : _a.get(k1)) !== null && _b !== void 0 ? _b : (_c = this.map.get(k1)) === null || _c === void 0 ? void 0 : _c.get(k0); + } + clone(predicate) { + const clone = new MM(); + this.forEach((v, k0, k1) => { + if (predicate(v, k0, k1)) { + clone.insert(k0, k1, v); + } + }); + return clone; + } + delete(k0, k1) { + var _a; + (_a = this.map.get(k0)) === null || _a === void 0 ? void 0 : _a.delete(k1); + } + forEach(cb) { + this.map.forEach((mm, k0) => { + mm.forEach((e, k1) => { + cb(e, k0, k1); + }); + }); + } + exists(k0, k1) { + var _a; + return ((_a = this.map.get(k0)) === null || _a === void 0 ? void 0 : _a.get(k1)) !== undefined; + } + toArray() { + const a = []; + this.forEach(v => a.push(v)); + return a; + } + size() { + let c = 0; + this.forEach(_ => c++); + return c; + } +} +exports.MM = MM; +const knn = Vector3_1.default.create(); +const knnP0 = Vector3_1.default.create(); +const q0 = Quaternion_1.default.create(); +class Myriahedral { + constructor() { + // MARK: myriahedron subdivision into. + this.subdivisions = 6; + this.edges = new MM(); // v0 -> v1 -> Edge + // MARK: + this.originalVertices = []; + this.vertex = []; + this.index = []; + } + graticule(p) { + this.name = p.name; + const gr = new Graticule_1.Graticule().build(p); + this.vertex = gr.vertices; + this.facesInfo = gr.faces; + this.foldsMST = gr.folds; + this.index = []; + gr.faces.forEach(f => { + f.vertices.forEach(v => { + this.index.push(v.index); + }); + }); + const tunfold = Date.now(); + this.unfoldSetup(false); + console.log(`normalization+retriangulate+unfold time ${Date.now() - tunfold}ms`); + this.folds = this.foldsMST.map(e => { + return { + f0: e.edge.faceIndices[0], + f1: e.edge.faceIndices[1], + }; + }); + this.cuts = []; + return this; + } + myriahedron(p) { + var _a, _b; + this.name = p.name; + if (p.unfold === undefined) { + p.unfold = true; + } + this.miryahedronGeometry = p.geometry; + this.subdivisions = (_a = p.subdivisions) !== null && _a !== void 0 ? _a : 5; + this.buildMyriahedron(p.geometry, (_b = p.normalize) !== null && _b !== void 0 ? _b : true); + // get only actual edges, not the ones used to subdivide. + this.edges = this.edges.clone(v => { + return v.centerIndex === -1; + }); + let tMST = Date.now(); + this.foldsMST = this.calcMST(this.transformVertEdgesToFaceEdges()); + console.log(`MST calc time ${Date.now() - tMST}ms.`); + // FOLDS + // clone this.edges into edgesMST + const edgesMST = this.edges.clone(_ => { + return true; + }); + // CUTS (not needed but beautiful to visualise) + // all non fold edges, are cut. + // folds are face-face edges, so use original vertices edge. + this.foldsMST.forEach(f => { + edgesMST.delete(f.edge.vertex0, f.edge.vertex1); + edgesMST.delete(f.edge.vertex1, f.edge.vertex0); + }); + this.cuts = []; + edgesMST.forEach(v => { + this.cuts.push(v); + }); + if (!p.unfold) { + this.uv = this.calculateUV(); + } + else { + const tunfold = Date.now(); + this.unfoldSetup(true); + console.log(`normalization+retriangulate+unfold time ${Date.now() - tunfold}ms`); + } + this.folds = this.foldsMST.map(e => { + return { + f0: e.edge.faceIndices[0], + f1: e.edge.faceIndices[1], + }; + }); + return this; + } + edgesFromFaces(fs) { + const edges = []; + fs.forEach(f => { + for (let i = 0; i < f.length; i++) { + edges.push([f[i], f[(i + 1) % f.length]]); + } + }); + const edgesMap = new MM(); + edges.forEach(e => { + if (edgesMap.getI(e[0], e[1]) === undefined) { + edgesMap.insert(e[0], e[1], e); + } + }); + const retEdges = []; + edgesMap.forEach(e => { + retEdges.push(e); + }); + return retEdges; + } + buildMyriahedron(geometry, normalize) { + const tbm = Date.now(); + geometry.vertices.forEach(v => { + this.insertVertex(new Vertex(v[0], v[1], v[2])); + }); + if (geometry.edges === undefined) { + geometry.edges = this.edgesFromFaces(geometry.faces); + } + for (const e of geometry.edges) { + this.insertEdge(this.vertex[e[0]], this.vertex[e[1]], 0); + } + geometry.faces.forEach(f => this.recurse(1, f[0], f[1], f[2])); + if (normalize) { + this.normalizeGeometry(); + } + console.log(`myriahedron build time ${Date.now() - tbm}ms`); + } + calcMST(faceEdges) { + const helper = new MM(); // faceid -> faceid -> faceEdge + faceEdges.forEach(e => { + e.wc *= -1; + let f0 = e.edge.faceIndices[0]; + let f1 = e.edge.faceIndices[1]; + helper.insert(f0, f1, e); + helper.insert(f1, f0, e); + }); + const treeFaces = []; + treeFaces.push(faceEdges[0].edge.faceIndices[0]); + const treeFacesSet = new Map(); + treeFacesSet.set(faceEdges[0].edge.faceIndices[0], faceEdges[0]); + const treeEdges = []; + treeEdges.push(faceEdges[0]); + while (treeFacesSet.size !== this.index.length / 3) { + let minFace = -1; + let minEdge = null; + let minWC = Number.MAX_VALUE; + let nextFace = -1; + treeFaces.forEach(face => { + // find minimum wc of any edge outgoing from face edge + helper.map.get(face).forEach((e, faceKey) => { + if (!treeFacesSet.has(faceKey) && e.wc < minWC) { + minEdge = e; + minWC = e.wc; + nextFace = faceKey; + minFace = face; + } + }); + }); + if (minEdge) { + const parent = treeFacesSet.get(minFace); + // is not the same edge in different faces. e.g. `this.parent=this` + if (parent.edge !== minEdge.edge) { + helper.map.get(nextFace).delete(minFace); + helper.map.get(minFace).delete(nextFace); + treeFaces.push(nextFace); + treeEdges.push(minEdge); + if (parent) { + minEdge.parent = parent; + } + } + treeFacesSet.set(nextFace, minEdge); + } + else { + console.error(`no more edges`); + break; + } + } + return treeEdges; + } + // form Edge to EdgeFace. + // EdgeFace keeps a directional Edge information (from face to face) based on + // edge's vertices traversal direction. + // v0 -> v1 -> F0 + // v1 -> v0 -> F1 + transformVertEdgesToFaceEdges() { + this.faceEdges = new MM(); + let degenerated = 0; + this.edges.forEach(edge => { + if (edge.faceIndices[0] !== null && edge.faceIndices[1] !== null) { + this.faceEdges.insert(edge.faceIndices[0], edge.faceIndices[1], new FacesEdge(edge)); + } + else { + degenerated++; + } + }); + console.log(`edges: ${this.edges.size()}, faceEdges: ${this.faceEdges.size()}, degenerated: ${degenerated}`); + return this.faceEdges.toArray(); + } + getMeshData() { + const vertices = new Float32Array(this.vertex.length * 3); + this.vertex.forEach((v, i) => { + vertices[i * 3] = v.x; + vertices[i * 3 + 1] = v.y; + vertices[i * 3 + 2] = v.z; + }); + return { + vertices, + index: this.index !== null ? new Uint16Array(this.index) : null, + uv: this.uv, + folds: this.folds, + cuts: this.cuts, + foldsMST: this.foldsMST, + }; + } + calculateUV(ox, oy) { + const uv = new Float32Array(this.originalVertices.length * 2); + ox = ox !== null && ox !== void 0 ? ox : 0; + oy = oy !== null && oy !== void 0 ? oy : 0; + this.originalVertices.forEach((v, i) => { + uv[i * 2] = .5 + (ox + Math.atan2(v.x, v.z)) / (2 * Math.PI); + uv[i * 2 + 1] = .5 - (oy + Math.asin(v.y)) / Math.PI; + }); + // check for extreme uv offsets. + this.facesInfo.forEach(fi => { + const o0 = fi.vertices[0].index * 2; + const u0 = uv[o0]; + const v0 = uv[o0 + 1]; + const o1 = fi.vertices[1].index * 2; + const u1 = uv[o1]; + const v1 = uv[o1 + 1]; + const o2 = fi.vertices[2].index * 2; + const u2 = uv[o2]; + const v2 = uv[o2 + 1]; + if (Math.abs(u0 - u1) > .5 || Math.abs(u2 - u0) > .5 || Math.abs(u2 - u1) > .5) { + if (u0 < .5) { + uv[o0] += 1; + } + if (u1 < .5) { + uv[o1] += 1; + } + if (u2 < .5) { + uv[o2] += 1; + } + } + if (Math.abs(v0 - v1) > .5 || Math.abs(v2 - v0) > .5 || Math.abs(v2 - v1) > .5) { + if (v0 < .5) { + uv[o0 + 1] += 1; + } + if (v1 < .5) { + uv[o1 + 1] += 1; + } + if (v2 < .5) { + uv[o2 + 1] += 1; + } + } + }); + return uv; + } + insertVertex(v) { + v.index = this.vertex.length; + this.vertex.push(v); + } + insertEdge(v0, v1, level) { + if (this.edges.exists(v0.index, v1.index)) { + console.log(`insert of duplicated edge`); + return; + } + const e = new Edge(v0.index, v1.index); + e.w0 = level; + e.w1 = level; + e.wc = level + 1; + this.edges.insert(v0.index, v1.index, e); + return e; + } + edgesFacesDirection(v0i, v1i, v2i) { + this.edges.getI(v0i, v1i).facesDirection({ + fromVertex: v0i, + toVertex: v1i, + faceIndex: this.index.length / 3 + }); + this.edges.getI(v1i, v2i).facesDirection({ + fromVertex: v1i, + toVertex: v2i, + faceIndex: this.index.length / 3 + }); + this.edges.getI(v2i, v0i).facesDirection({ + fromVertex: v2i, + toVertex: v0i, + faceIndex: this.index.length / 3 + }); + this.index.push(v0i, v1i, v2i); + } + /** + * recurse edges v01-v1i, v1i-v2i, v2i-v0i + * @param level + * @param v0i + * @param v1i + * @param v2i + */ + recurse(level, v0i, v1i, v2i) { + if (level === this.subdivisions) { + this.edgesFacesDirection(v0i, v1i, v2i); + return; + } + const mv0v1 = this.edges.getI(v0i, v1i); + if (mv0v1.centerIndex === -1) { + this.splitEdge(mv0v1); + } + const mv1v2 = this.edges.getI(v1i, v2i); + if (mv1v2.centerIndex === -1) { + this.splitEdge(mv1v2); + } + const mv2v0 = this.edges.getI(v2i, v0i); + if (mv2v0.centerIndex === -1) { + this.splitEdge(mv2v0); + } + this.insertEdge(this.vertex[mv0v1.centerIndex], this.vertex[mv2v0.centerIndex], level); + this.insertEdge(this.vertex[mv0v1.centerIndex], this.vertex[mv1v2.centerIndex], level); + this.insertEdge(this.vertex[mv2v0.centerIndex], this.vertex[mv1v2.centerIndex], level); + this.recurse(level + 1, v0i, mv0v1.centerIndex, mv2v0.centerIndex); + this.recurse(level + 1, mv0v1.centerIndex, v1i, mv1v2.centerIndex); + this.recurse(level + 1, mv1v2.centerIndex, mv2v0.centerIndex, mv0v1.centerIndex); + this.recurse(level + 1, mv2v0.centerIndex, mv1v2.centerIndex, v2i); + } + splitEdge(e) { + const v0v1 = Vertex.middle(this.vertex[e.vertex0], this.vertex[e.vertex1]); + this.insertVertex(v0v1); + e.centerIndex = v0v1.index; + if (!this.edges.getI(e.vertex0, v0v1.index)) { + const e0 = this.insertEdge(this.vertex[e.vertex0], v0v1, 0); + e0.w0 = e.w0; + e0.w1 = e.wc; + e0.wc = (e.w0 + e.wc) / 2; + } + else { + console.error('splitting unknown edge.'); + } + if (!this.edges.getI(v0v1.index, e.vertex1)) { + const e1 = this.insertEdge(v0v1, this.vertex[e.vertex1], 0); + e1.w0 = e.wc; + e1.w1 = e.w1; + e1.wc = (e.wc + e.w1) / 2; + } + else { + console.error('splitting unknown edge.'); + } + } + buildFoldingTree() { + this.roots = this.foldsMST.filter(e => { + return e.parent === null; + }); + if (this.roots.length > 1) { + console.warn(`${this.name} more than one root: ${this.roots.length}`); + } + const root = this.roots[0]; + const processed = new Set(); + processed.add(root.id); + this.buildFoldingTreeImpl(processed, root.fromFaceIndex, root); + this.buildFoldingTreeImpl(processed, root.toFaceIndex, root); + root.swap(); + } + buildFoldingTreeImpl(processed, parent, nodeParent) { + const children = this.foldsMST.filter(f => { + return !processed.has(f.id) && (f.fromFaceIndex === parent || f.toFaceIndex === parent); + }); + children.forEach(f => { + if (!processed.has(f.id)) { + if (f.fromFaceIndex !== parent) { + f.swap(); + } + if (nodeParent !== null) { + nodeParent.children.push(f); + } + f.parent = nodeParent; + processed.add(f.id); + } + }); + children.forEach(c => { + this.buildFoldingTreeImpl(processed, c.toFaceIndex, c); + this.buildFoldingTreeImpl(processed, c.fromFaceIndex, c); + }); + } + normalizeGeometry() { + this.vertex.forEach((v) => { + v.normalize(); + }); + } + checkAllTrianglesComplete(faces) { + let c = 0; + let inc = {}; + faces.forEach((f, faceIndex) => { + if (f.length !== 3) { + c++; + inc[faceIndex] = f; + } + }); + if (c !== 0) { + console.log(inc); + throw new Error(`incomplete faces: ${c}`); + } + } + reTriangulateGeometry() { + const newVertices = []; + const newIndex = []; + const faces = new Map(); // faceId, vertices + const process = (edge, f0) => { + let ar = faces.get(f0); + if (ar === undefined) { + ar = []; + faces.set(f0, ar); + } + if (ar.indexOf(edge) === -1) { + ar.push(edge); + } + }; + const addCut = (c) => { + process(c, c.faceIndices[0]); + process(c, c.faceIndices[1]); + }; + const addFold = (fold) => { + process(fold.edge, fold.fromFaceIndex); + process(fold.edge, fold.toFaceIndex); + }; + this.foldsMST.forEach(fold => { + addFold(fold); + }); + this.cuts.forEach(c => { + addCut(c); + }); + this.checkAllTrianglesComplete(faces); + const faceRemap = new Map(); + this.facesInfo = new Map(); + // build new geometry. + // number of faces is constant. + faces.forEach((edges, faceIndex) => { + const vertices = [ + this.index[faceIndex * 3], + this.index[faceIndex * 3 + 1], + this.index[faceIndex * 3 + 2] + ]; + const nv0 = this.vertex[vertices[0]].clone(); + nv0.index = newVertices.length; + const nv1 = this.vertex[vertices[1]].clone(); + nv1.index = newVertices.length + 1; + const nv2 = this.vertex[vertices[2]].clone(); + nv2.index = newVertices.length + 2; + newVertices.push(nv0, nv1, nv2); + const i = newIndex.length; + newIndex.push(i, i + 1, i + 2); + const ni = (i / 3) | 0; + faceRemap.set(faceIndex, ni); + const originalVertices = [nv0, nv1, nv2]; + // this would work too, but I want debug normal in the center of each face. + // const normal = this.normalForVertices(originalVertices); + const normal = Myriahedral.getCenterPoint(originalVertices, true); + this.facesInfo.set(ni, { + id: ni, + prevId: faceIndex, + edges, + vertices: originalVertices, + prevVerticesIndices: vertices, + normal, + }); + }); + this.edges.forEach(e => { + e.faceIndices[0] = faceRemap.get(e.faceIndices[0]); + e.faceIndices[1] = faceRemap.get(e.faceIndices[1]); + }); + this.vertex = newVertices; + this.index = newIndex; + } + unfoldSetup(needsRetriangulation) { + var _a, _b; + this.buildFoldingTree(); + if (needsRetriangulation) { + this.reTriangulateGeometry(); + } + this.originalVertices = this.vertex; + this.uv = this.calculateUV(); + this.setFoldsOrientations(); + console.log(`Debug info:`); + if (this.miryahedronGeometry) { + console.log(` Original: ${this.miryahedronGeometry.vertices.length}-${this.miryahedronGeometry.faces.length}-${this.miryahedronGeometry.edges.length}`); + } + console.log(` Geometry: ${this.originalVertices.length}-${this.facesInfo.size}`); + console.log(` Folds/Cuts: ${this.foldsMST.length}/${(_b = (_a = this.cuts) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0}`); + } + static getCenterPoint(v, normalize) { + let nx = (v[0].x + v[1].x + v[2].x) / 3; + let ny = (v[0].y + v[1].y + v[2].y) / 3; + let nz = (v[0].z + v[1].z + v[2].z) / 3; + if (normalize) { + const l = 1 / Math.sqrt(nx * nx + ny * ny + nz * nz); + nx *= l; + ny *= l; + nz *= l; + } + return [nx, ny, nz]; + } + setFoldsOrientations() { + this.foldsMST.forEach(fold => this.setupCommonrotationAxisVertices(fold)); + this.setupGeometry(); + this.roots.forEach(root => { + this.calculateOrientations(root); + }); + } + static dot(v0, v1) { + return v0[0] * v1[0] + v0[1] * v1[1] + v0[2] * v1[2]; + } + /** + * Calculate fold angles before/after rotation over common axis to determine what is inwards-outwards. + * We expect the myriahedron to be 100% flat after unfolding process. + */ + calculateOrientations(node) { + node.children.forEach(c => { + this.calculateOrientations(c); + }); + // get starting angle + const n0 = this.facesInfo.get(node.fromFaceIndex).normal; + const n1 = this.facesInfo.get(node.toFaceIndex).normal; + const angle0 = Myriahedral.dot(n0, n1); + // rotate around common axis + this.setupQuaternionFor(node, 1); + const vref = node.commonAxisVertices[0]; + this.facesInfo.get(node.toFaceIndex).vertices.forEach(v => { + Myriahedral.rotateWith(q0, v, vref); + }); + const newN1 = this.normalForFaceIndex(node.toFaceIndex); + // get new angle + const angle1 = Myriahedral.dot(n0, newN1); + // set unfolding orientation + node.orientationMultiplier = (angle1 < angle0) ? -1 : 1; + // restore rotated face vertices + const f = this.facesInfo.get(node.toFaceIndex); + f.vertices.forEach((v, i) => { + f.vertices[i].copy(this.originalVertices[v.index]); + }); + } + setupCommonrotationAxisVertices(fold) { + const fi0 = this.facesInfo.get(fold.fromFaceIndex); + const fi1 = this.facesInfo.get(fold.toFaceIndex); + const rotationEdgeVerticesIndices = fi0.prevVerticesIndices.filter(v => { + return fi1.prevVerticesIndices.indexOf(v) !== -1; // valores comunes + }); + fold.commonAxisVertices = rotationEdgeVerticesIndices.map(v => { + return fi0.vertices[fi0.prevVerticesIndices.indexOf(v)]; + }); + // not the same vertices indices. Graticule uses an ad-hoc triangle pairing process, + // and this might not work as expected. Check for diff points. + if (fold.commonAxisVertices.length !== 2) { + fold.commonAxisVertices = fi0.vertices.filter(v => { + return fi1.vertices.find(v0 => v0.equals(v)); + }); + } + } + unfoldProcess(scale) { + // let t = Date.now(); + this.roots.forEach(f => this.unfoldImpl(f, scale)); + // t = Date.now() - t; + // console.log(`unfold vertices took ${t}ms.`); + } + setupGeometry() { + this.vertex = this.originalVertices.map(v => { + return v.clone(); + }); + this.facesInfo.forEach(f => { + f.vertices.forEach((v, i) => { + f.vertices[i] = this.vertex[v.index]; + }); + f.normal = Vertex.normalForVertices(f.vertices); + }); + } + unfold(scale) { + this.setupGeometry(); + this.unfoldProcess(scale); + this.folds = this.foldsMST.map(e => { + return { + f0: e.edge.faceIndices[0], + f1: e.edge.faceIndices[1], + }; + }); + } + normalForFaceIndex(i) { + return Vertex.normalForVertices(this.facesInfo.get(i).vertices); + } + unfoldImpl(node, scale) { + node.children.forEach(c => { + this.unfoldImpl(c, scale); + }); + this.unfoldNodeRec(node, scale); + } + setupQuaternionFor(node, scale) { + const fi0 = this.facesInfo.get(node.fromFaceIndex); + const fi1 = this.facesInfo.get(node.toFaceIndex); + const N0 = fi0.normal; + const N1 = fi1.normal; + const ac = Math.max(-1, Math.min(1, Myriahedral.dot(N0, N1))); + let diffAngle = scale * + Math.acos(ac) * + node.orientationMultiplier; + const rotationEdgeVertices = node.commonAxisVertices; + knn[0] = rotationEdgeVertices[1].x - rotationEdgeVertices[0].x; + knn[1] = rotationEdgeVertices[1].y - rotationEdgeVertices[0].y; + knn[2] = rotationEdgeVertices[1].z - rotationEdgeVertices[0].z; + const e = Vector3_1.default.normalize(knn, knn); + Quaternion_1.default.fromAxisAndAngle(q0, e, diffAngle); + } + unfoldNodeRec(node, scale) { + this.setupQuaternionFor(node, scale); + this.rotatePointRecQuaterion(node, node.commonAxisVertices[0], q0); + } + rotatePointRecQuaterion(n, vref, q0) { + n.children.forEach(c => { + this.rotatePointRecQuaterion(c, vref, q0); + }); + this.facesInfo.get(n.toFaceIndex).vertices.forEach(v => { + Myriahedral.rotateWith(q0, v, vref); + }); + } + static rotateWith(q0, v, vref) { + knnP0[0] = v.x - vref.x; + knnP0[1] = v.y - vref.y; + knnP0[2] = v.z - vref.z; + const rp0 = Quaternion_1.default.rotate(q0, knnP0); + v.x = rp0[0] + vref.x; + v.y = rp0[1] + vref.y; + v.z = rp0[2] + vref.z; + } +} +exports.default = Myriahedral; + +},{"../../math/Quaternion":2,"../../math/Vector3":4,"./Graticule":15}],17:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.IcosahedronGeometry = exports.CubeGeometry = exports.TetrahedronGeometry = exports.OctahedronGeometry = void 0; +exports.OctahedronGeometry = { + name: 'octahedron', + vertices: [ + [0, 1, 0], + [1, 0, 0], + [0, 0, -1], + [-1, 0, 0], + [0, 0, 1], + [0, -1, 0] + ], + faces: [ + [0, 1, 2], + [0, 2, 3], + [0, 3, 4], + [0, 4, 1], + [5, 2, 1], + [5, 3, 2], + [5, 4, 3], + [5, 1, 4] + ] +}; +exports.TetrahedronGeometry = { + name: 'tetrahedron', + vertices: [ + [0.0, -1.0, 2.0], + [1.73205081, -1.0, -1.0], + [-1.73205081, -1.0, -1.0], + [0.0, 2.0, 0.0], + ], + edges: [[2, 0], [0, 1], [3, 0], [1, 2], [2, 3], [3, 1]], + faces: [ + [0, 2, 1], + [0, 3, 2], + [0, 1, 3], + [1, 2, 3], + ] +}; +exports.CubeGeometry = { + name: 'cube', + vertices: [ + [0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5], + [-0.5, -0.5, 0.5], + [0.5, -0.5, 0.5], + [0.5, 0.5, -0.5], + [-0.5, 0.5, -0.5], + [-0.5, 0.5, 0.5], + [0.5, 0.5, 0.5], + ], + faces: [ + [2, 1, 0], [3, 2, 0], + [3, 0, 4], [7, 3, 4], + [0, 1, 5], [4, 0, 5], + [1, 2, 6], [5, 1, 6], + [2, 3, 7], [6, 2, 7], + [4, 5, 6], [7, 4, 6], + ], + edges: [ + [2, 0], [3, 0], [3, 4], + [0, 1], [4, 0], [0, 5], + [1, 2], [5, 1], [1, 6], + [2, 3], [3, 7], [6, 2], + [2, 7], [4, 5], [5, 6], + [7, 4], [4, 6], [6, 7] + ] +}; +exports.IcosahedronGeometry = { + name: 'icosahedron', + vertices: [ + [-0.26286500, 0, 0.42532500], + [0.26286500, 0, 0.42532500], + [-0.26286500, 0, -0.42532500], + [0.26286500, 0, -0.42532500], + [0, 0.42532500, 0.26286500], + [0, 0.42532500, -0.26286500], + [0, -0.42532500, 0.26286500], + [0, -0.42532500, -0.26286500], + [0.42532500, 0.26286500, 0], + [-0.42532500, 0.26286500, 0], + [0.42532500, -0.26286500, 0], + [-0.42532500, -0.26286500, 0], + ], + faces: [ + [0, 6, 1], + [0, 11, 6], + [1, 4, 0], + [1, 8, 4], + [1, 10, 8], + [2, 5, 3], + [2, 9, 5], + [2, 11, 9], + [3, 7, 2], + [3, 10, 7], + [4, 8, 5], + [4, 9, 0], + [5, 8, 3], + [5, 9, 4], + [6, 10, 1], + [6, 11, 7], + [7, 10, 6], + [7, 11, 2], + [8, 10, 3], + [9, 11, 0] + ] +}; + +},{}],18:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EnvironmentMapShader = void 0; +const Shader_1 = require("./Shader"); +class EnvironmentMapShader extends Shader_1.default { + constructor(gl, refractive) { + super({ + gl, + vertex: `#version 300 es + + precision mediump float; + + layout (location = 0) in vec3 aPosition; + layout (location = 1) in vec3 aNormal; + layout (location = 2) in mat4 aModel; + + uniform mat4 uProjection; + uniform mat4 uModelView; + + out vec3 vNormal; + out vec3 vModelPosition; + + void main() { + vModelPosition = vec3(aModel * vec4(aPosition, 1.0)); + // to cope with non uniform scales (normal matrix) + // bugbug: calculate in cpu, and pass as another instance attribute. + vNormal = mat3(transpose(inverse(aModel)))*aNormal; + gl_Position = uProjection * uModelView * aModel * vec4(aPosition, 1.0); + } + `, + fragment: `#version 300 es + + precision mediump float; + + uniform samplerCube uSkybox; + uniform vec3 uCameraPos; + uniform float uRefractionFactor; + + in vec3 vNormal; + in vec3 vModelPosition; + + out vec4 color; + + #ifdef REFRACTIVE + + + vec4 refraction() { + float ratio = 1.00 / uRefractionFactor; + vec3 I = normalize(vModelPosition-uCameraPos); + vec3 R = refract(I, normalize(vNormal), ratio); + return texture(uSkybox, R); + } + + void main() { + color = refraction(); + } + #else + vec4 reflection() { + vec3 I = normalize(vModelPosition-uCameraPos); + vec3 R = reflect(I, normalize(vNormal)); + return texture(uSkybox, R); + } + + void main() { + color = reflection(); + } + #endif + `, + uniforms: ['uProjection', 'uModelView', 'uSkybox', 'uCameraPos', 'uRefractionFactor'], + attributes: ['aPosition', 'aNormal', 'aModel'], + defines: refractive ? { 'REFRACTIVE': '1' } : {} + }); + if (refractive) { + this.use(); + this.set1F("uRefractionFactor", 1.52); + this.notUse(); + } + } + render(e, info, rc) { + const gl = e.gl; + this.use(); + this.setMatrix4fv("uProjection", false, e.projectionMatrix()); + rc.getMaterial().definition.diffuse.enableAsUnit(gl, 0); + this.set1I("uSkybox", 0); + this.setMatrix4fv("uModelView", false, e.cameraMatrix()); + const cameraPos = e.cameraPosition(); + this.set3F("uCameraPos", cameraPos[0], cameraPos[1], cameraPos[2]); + gl.bindVertexArray(info.vao); + info.instanceBuffer.draw(gl, info.vertexCount, info.instanceCount); + // if (info.indexBuffer !== null) { + // gl.drawElementsInstanced(gl.TRIANGLES, info.vertexCount, gl.UNSIGNED_SHORT, 0, info.instanceCount); + // } else { + // gl.drawArraysInstanced(gl.TRIANGLES, 0, info.vertexCount, info.instanceCount); + // } + gl.bindVertexArray(null); + this.notUse(); + } + createVAO(gl, geometryInfo, material) { + var _a; + const instanceCount = geometryInfo.instanceCount || 1; + const vao = gl.createVertexArray(); + gl.bindVertexArray(vao); + for (let i = 0; i < 5; i++) { + gl.enableVertexAttribArray(i); + } + const glGeometryBuffer = Shader_1.default.createAttributeInfo(gl, 0, geometryInfo.vertex, 12, 0); + const glNormalBuffer = Shader_1.default.createAttributeInfo(gl, 1, geometryInfo.normal, 12, 0); + const glInstancedModelMatrixBuffer = Shader_1.default.createInstancedModelMatrix(gl, instanceCount, 2, !!geometryInfo.index); + let glBufferIndex = null; + let vertexCount = (geometryInfo.vertex.length / 3) | 0; + if (geometryInfo.index !== null) { + glBufferIndex = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, glBufferIndex); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geometryInfo.index, gl.STATIC_DRAW); + vertexCount = geometryInfo.index.length; + } + // restore null vao + gl.bindVertexArray(null); + return { + shader: this, + vao, + geometryBuffer: glGeometryBuffer, + normalBuffer: glNormalBuffer, + instanceBuffer: glInstancedModelMatrixBuffer, + instanceCount: instanceCount, + indexBuffer: glBufferIndex, + vertexCount, + uvBuffer: null, + renderMode: (_a = material.renderMode) !== null && _a !== void 0 ? _a : this._gl.TRIANGLES, + }; + } +} +exports.EnvironmentMapShader = EnvironmentMapShader; + +},{"./Shader":20}],19:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Shader_1 = require("./Shader"); +const Matrix4_1 = require("../../math/Matrix4"); +/** + * just draw geometry in a plain pink color + */ +class NullShader extends Shader_1.default { + constructor(gl) { + super({ + gl, + vertex: `#version 300 es + + precision mediump float; + + layout(location = 0) in vec3 aPosition; + + uniform mat4 uProjection; + uniform mat4 uModelView; + uniform mat4 uModelTransform; + + void main() { + gl_Position = uProjection * uModelView * uModelTransform * vec4(aPosition, 1.0); + gl_PointSize = 5.0; + + } + `, + fragment: `#version 300 es + + precision mediump float; + + uniform vec4 uColor; + + out vec4 color; + + void main() { + color = uColor; + } + `, + attributes: ["aPosition"], + uniforms: ["uProjection", "uModelView", "uModelTransform", "uColor"] + }); + this.setMatrix4fv("uProjection", false, Matrix4_1.default.create()); + this.setMatrix4fv("uModelView", false, Matrix4_1.default.create()); + } + render(e, info, rc) { + const gl = e.gl; + this.use(); + this.setMatrix4fv("uProjection", false, e.projectionMatrix()); + this.setMatrix4fv("uModelView", false, e.cameraMatrix()); + this.setMatrix4fv("uModelTransform", false, rc.getMatrix()); + this.set4FV("uColor", rc.getMaterial().definition.color); + gl.bindVertexArray(info.vao); + if (info.indexBuffer !== null) { + gl.drawElements(info.renderMode, info.vertexCount, gl.UNSIGNED_SHORT, 0); + } + else { + gl.drawArrays(info.renderMode, 0, info.vertexCount); + } + gl.bindVertexArray(null); + this.notUse(); + } + createVAO(gl, geometryInfo, material) { + var _a; + const vao = gl.createVertexArray(); + gl.bindVertexArray(vao); + for (let i = 0; i < 1; i++) { + gl.enableVertexAttribArray(i); + } + const instanceCount = geometryInfo.instanceCount || 1; + const glGeometryBuffer = Shader_1.default.createAttributeInfo(gl, 0, geometryInfo.vertex, 12, 0); + let glBufferIndex = null; + let vertexCount = (geometryInfo.vertex.length / 3) | 0; + if (geometryInfo.index) { + glBufferIndex = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, glBufferIndex); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geometryInfo.index, gl.STATIC_DRAW); + vertexCount = geometryInfo.index.length; + } + gl.bindVertexArray(null); + return { + shader: this, + vao, + instanceCount, + vertexCount, + geometryBuffer: glGeometryBuffer, + normalBuffer: null, + instanceBuffer: null, + indexBuffer: glBufferIndex, + uvBuffer: null, + renderMode: (_a = material.renderMode) !== null && _a !== void 0 ? _a : this._gl.TRIANGLES, + }; + } +} +exports.default = NullShader; + +},{"../../math/Matrix4":1,"./Shader":20}],20:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ModelMatrixInstancingInfo = void 0; +// make instancing batches taking at most MAX_BUFFER_INSTANCE bytes. +const BYTES_PER_INSTANCE = 16 * 4; +const MAX_BUFFER_INSTANCE = 65536; +class ModelMatrixInstancingInfo { + constructor(gl, aid, instanceCount, indexed) { + this.attributeIndex = aid; + this.isIndexed = indexed; + this.buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer); + const fbuffer = new Float32Array(instanceCount * 16); + gl.bufferData(gl.ARRAY_BUFFER, fbuffer, gl.DYNAMIC_DRAW); + this.instanceCount = instanceCount; + } + dispose(gl) { + gl.deleteBuffer(this.buffer); + } + draw(gl, vertexCount, instanceCount) { + instanceCount = Math.min(instanceCount, this.instanceCount); + // batch instances info. + // any mobile gpu would probably limit the buffer to 16k + // any desktop will be ok with 65k instances. + const batches = Math.max(1, ((instanceCount * BYTES_PER_INSTANCE) / MAX_BUFFER_INSTANCE) | 0); + const maxInstancesPerBatch = batches === 0 ? instanceCount : MAX_BUFFER_INSTANCE / BYTES_PER_INSTANCE; + gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer); + for (let i = 0; i < 4; i++) { + gl.enableVertexAttribArray(this.attributeIndex + i); + gl.vertexAttribDivisor(this.attributeIndex + i, 1); + } + for (let j = 0; j < batches; j++) { + const count = j < batches - 1 ? + maxInstancesPerBatch : + instanceCount - (batches - 1) * maxInstancesPerBatch; + for (let i = 0; i < 4; i++) { + gl.vertexAttribPointer(this.attributeIndex + i, 4, gl.FLOAT, false, 64, i * 16 + j * MAX_BUFFER_INSTANCE); + } + if (this.isIndexed) { + gl.drawElementsInstanced(gl.TRIANGLES, vertexCount, gl.UNSIGNED_SHORT, 0, count); + } + else { + gl.drawArraysInstanced(gl.TRIANGLES, 0, vertexCount, count); + } + } + gl.bindBuffer(gl.ARRAY_BUFFER, null); + } + updateWith(gl, locals) { + gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, locals, 0, Math.min(this.instanceCount * 16, locals.length)); + } +} +exports.ModelMatrixInstancingInfo = ModelMatrixInstancingInfo; +/** + * + */ +class Shader { + constructor(init) { + this._uniforms = {}; + this._attributes = {}; + this._shaderProgram = null; + this._gl = init.gl; + this.__init(init); + } + static getShader(gl, type, shader_text) { + let shader = gl.createShader(type); + gl.shaderSource(shader, shader_text); + gl.compileShader(shader); + const res = gl.getShaderInfoLog(shader); + if (res !== null && res !== "") { + console.error(`Shader info log: '${res}' for shader: ${shader_text}`); + } + return shader; + } + static getShaderDef(def, defines, common) { + let ret = ""; + if (Object.prototype.toString.call(def) === "[object Array]") { + ret = def.join('\n'); + } + else { + ret = def; + } + let sdefines = []; + if (defines !== void 0) { + Object.keys(defines).forEach(d => { + sdefines.push(`#define ${d} ${defines[d]}`); + }); + } + const lines = ret.split('\n'); + if (lines[0].startsWith("#version")) { + lines.splice(1, 0, ...sdefines); + } + if (common !== undefined) { + common = `${common}\n`; + } + else { + common = ''; + } + return `${common}${lines.join('\n')}`; + } + __init(shaderDef) { + const gl = this._gl; + this._shaderProgram = gl.createProgram(); + gl.attachShader(this._shaderProgram, Shader.getShader(gl, gl.VERTEX_SHADER, Shader.getShaderDef(shaderDef.vertex, shaderDef.defines, shaderDef.common))); + gl.attachShader(this._shaderProgram, Shader.getShader(gl, gl.FRAGMENT_SHADER, Shader.getShaderDef(shaderDef.fragment, shaderDef.defines, shaderDef.common))); + gl.linkProgram(this._shaderProgram); + gl.useProgram(this._shaderProgram); + this.initializeUniforms(shaderDef.uniforms, gl); + this.initializeAttributes(shaderDef.attributes, gl); + } + initializeAttributes(attributes, gl) { + attributes.forEach(attr => { + const attrid = gl.getAttribLocation(this._shaderProgram, attr); + if (attrid !== -1) { + this._attributes[attr] = attrid; + } + else { + console.error(`Attribute ${attr} unknown in program.`); + } + }); + } + initializeUniforms(uniforms, gl) { + uniforms.forEach(uniform => { + const location = gl.getUniformLocation(this._shaderProgram, uniform); + if (location === null) { + console.error(`Uniform ${uniform} not found in program.`); + } + else { + this._uniforms[uniform] = location; + } + }); + } + use() { + this._gl.useProgram(this._shaderProgram); + Object.keys(this._attributes).forEach(k => this._gl.enableVertexAttribArray(this._attributes[k])); + } + notUse() { + this._gl.useProgram(null); + Object.keys(this._attributes).forEach(k => this._gl.disableVertexAttribArray(this._attributes[k])); + } + set1F(name, v) { + this._gl.uniform1f(this._uniforms[name], v); + } + set2F(name, v0, v1) { + this._gl.uniform2f(this._uniforms[name], v0, v1); + } + set3F(name, v0, v1, v2) { + this._gl.uniform3f(this._uniforms[name], v0, v1, v2); + } + set3FV(name, b) { + this._gl.uniform3fv(this._uniforms[name], b); + } + set4FV(name, b) { + this._gl.uniform4fv(this._uniforms[name], b); + } + set4F(name, v0, v1, v2, v3) { + this._gl.uniform4f(this._uniforms[name], v0, v1, v2, v3); + } + set1I(name, v) { + this._gl.uniform1i(this._uniforms[name], v); + } + set2I(name, v0, v1) { + this._gl.uniform2i(this._uniforms[name], v0, v1); + } + set3I(name, v0, v1, v2) { + this._gl.uniform3i(this._uniforms[name], v0, v1, v2); + } + setMatrix4fv(name, transpose, matrix, srcOffset, srcLength) { + this._gl.uniformMatrix4fv(this._uniforms[name], transpose, matrix, srcOffset, srcLength); + } + static createInstancedModelMatrix(gl, instanceCount, attributeId, indexed) { + return new ModelMatrixInstancingInfo(gl, attributeId, instanceCount, indexed); + } + static createAttributeInfo(gl, attributeId, data, stride, offset) { + const buffer = gl.createBuffer(); + gl.bindBuffer(gl.ARRAY_BUFFER, buffer); + gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); + gl.vertexAttribPointer(attributeId, stride / 4, gl.FLOAT, false, stride, offset); + gl.vertexAttribDivisor(attributeId, 0); + return buffer; + } +} +exports.default = Shader; + +},{}],21:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Shader_1 = require("./Shader"); +/** + * Skybox shader which draws a cubemap onto a cube. + * The cube keeps always on the same position, regardless the camera position. Hence, we get from the camera matrix just + * information regarding transformation, and not translation. + * + * This shader is expected to run the last thing on the renderer. This will speed things up a log, since no extra pixel + * overdraw will be performed. + * To do so, we trick gl_Position and duplicate position.w onto position.z. Thus the projection phase will just make z = 1. + * We thus trick the depth buffer to think the cube is z=1, maximum depth. This will make the depth test fail should any + * other object has been written to the same pixel. + * So the skybox will only render on pixels where there's no previous object. It will also fill depth to maximum value of 1. + * + * We also need to change the depth function to GL_LEQUAL from GL_EQUAL. + */ +class SkyboxShader extends Shader_1.default { + constructor(gl) { + super({ + gl, + vertex: `#version 300 es + + precision mediump float; + + layout (location = 0) in vec3 aPosition; + + out vec3 vTexCoords; + + uniform mat4 uProjection; + uniform mat4 uView; + + void main() { + vTexCoords = aPosition; + vec4 pos = uProjection * uView * vec4(aPosition, 1.0); + gl_Position = pos.xyww; + } + `, + fragment: `#version 300 es + + precision mediump float; + + in vec3 vTexCoords; + out vec4 color; + + uniform samplerCube uSampler; + + void main() { + color = texture(uSampler, vTexCoords); + } + `, + uniforms: ['uProjection', 'uView', 'uSampler'], + attributes: ['aPosition'] + }); + } + createVAO(gl, geometryInfo, material) { + const vao = gl.createVertexArray(); + gl.bindVertexArray(vao); + const glGeometryBuffer = Shader_1.default.createAttributeInfo(gl, 0, geometryInfo.vertex, 12, 0); + let glBufferIndex = gl.createBuffer(); + let vertexCount = geometryInfo.index.length; + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, glBufferIndex); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geometryInfo.index, gl.STATIC_DRAW); + gl.enableVertexAttribArray(0); + gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 12, 0); + gl.vertexAttribDivisor(0, 0); + gl.bindVertexArray(null); + return { + shader: this, + vao, + geometryBuffer: glGeometryBuffer, + vertexCount: vertexCount, + indexBuffer: glBufferIndex, + uvBuffer: null, + instanceBuffer: null, + instanceCount: 1, + normalBuffer: null, + renderMode: this._gl.TRIANGLES, + }; + } + render(e, info, rc) { + const gl = e.gl; + this.use(); + this.setMatrix4fv("uProjection", false, e.projectionMatrix()); + this.setMatrix4fv("uView", false, e.viewMatrix()); + rc.getMaterial().definition.diffuse.enableAsUnit(gl, 0); + this.set1I("uSampler", 0); + gl.depthFunc(gl.LEQUAL); // trick depth + gl.bindVertexArray(info.vao); + // invert cube normals to see from the inside. (we are inside the skybox) + gl.cullFace(gl.FRONT); + gl.drawElements(gl.TRIANGLES, 36, gl.UNSIGNED_SHORT, 0); + gl.cullFace(gl.BACK); + gl.bindVertexArray(null); + gl.depthFunc(gl.LESS); + this.notUse(); + } +} +exports.default = SkyboxShader; + +},{"./Shader":20}],22:[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Shader_1 = require("./Shader"); +const Matrix4_1 = require("../../math/Matrix4"); +/** + * just draw geometry in a plain pink color + */ +class TextureShader extends Shader_1.default { + constructor(gl, defines) { + super({ + gl, + common: `#version 300 es + + precision mediump float; + + // directional lights, + struct Light { + // point light + vec3 position; + float constant; + float linear; + float quadratic; + + // directional light + vec3 direction; + + vec3 ambient; + vec3 diffuse; + vec3 specular; + + // spot light + float cutoff; + }; + + struct Material { + float ambient; + + sampler2D diffuse; + sampler2D specular; + float shininess; + }; + + `, + vertex: ` + layout(location = 0) in vec3 aPosition; + layout(location = 1) in vec2 aTexture; + layout(location = 2) in vec3 aNormal; + layout(location = 4) in mat4 aModel; + + uniform mat4 uProjection; + uniform mat4 uModelView; + uniform Light uLight; + + out vec2 vTexturePos; + out vec3 vNormal; + out vec3 vFragmentPos; + + void main() { + vTexturePos = aTexture; + vNormal = mat3(transpose(inverse(aModel))) * aNormal; // normal matrix + vFragmentPos = (aModel * vec4(aPosition, 1.0)).xyz; + gl_Position = uProjection * uModelView * aModel * vec4(aPosition, 1.0); + } + `, + fragment: ` + + uniform vec3 uViewPos; + uniform Light uLight; + uniform Material uMaterial; + + in vec2 vTexturePos; + in vec3 vNormal; + in vec3 vFragmentPos; + + out vec4 color; + + vec3 getAmbient() { + vec3 diffuseColor = texture(uMaterial.diffuse, vTexturePos).xyz; + return (uLight.ambient + uMaterial.ambient) * diffuseColor; + } + + vec3 getDiffuse(vec3 normal, vec3 lightDir) { + float diff = max(dot(normal, lightDir), 0.0); + vec3 diffuseColor = texture(uMaterial.diffuse, vTexturePos).xyz; + + return diff * uLight.diffuse * diffuseColor; + } + + vec3 getSpecular(vec3 normal, vec3 lightDir) { + float specular = 0.0; + if (dot(normal, lightDir)>0.0) { + vec3 viewDir = normalize(uViewPos - vFragmentPos); + #ifdef PHONG + // phong + vec3 reflect = -reflect(lightDir, normal); + specular = pow(max(dot(viewDir, reflect), 0.0), uMaterial.shininess); + #else + // blinn phong + vec3 halfwayDir = normalize(lightDir + viewDir); + specular = pow(max(dot(normal, halfwayDir), 0.0), uMaterial.shininess); + #endif + } + + return uLight.specular * specular * vec3(texture(uMaterial.specular, vTexturePos)); + } + + vec4 directional() { + vec3 lightDir = normalize(-uLight.direction); + return vec4(0,0,0,0); + } + + vec3 point() { + vec3 norm = normalize(vNormal); + vec3 lightDir = normalize(uLight.position - vFragmentPos); + + vec3 color = getAmbient() + getDiffuse(norm, lightDir) + #ifdef SPECULAR + + getSpecular(norm, lightDir) + #endif + ; + + #ifdef SPECULAR + float distance = length(uLight.position - vFragmentPos); + float attenuation = pow(1.0 / ( uLight.constant + + uLight.linear * distance + + uLight.quadratic * + (distance * distance)), .45); // gamma + + color.xyz = color.xyz * attenuation; + #endif + + color.xyz = pow(color.xyz, vec3(.45)); // gamma + + return color; + } + + void main() { + color = vec4(point(), 1.0); + // color = vec4(vec3(gl_FragCoord.z), 1.0); + } + `, + attributes: ["aPosition", "aTexture", "aNormal", "aModel"], + uniforms: [ + "uProjection", + "uModelView", + "uLight.position", + "uLight.constant", + "uLight.linear", + "uLight.quadratic", + "uLight.direction", + "uLight.ambient", + "uLight.diffuse", + "uLight.specular", + "uMaterial.ambient", + "uMaterial.diffuse", + "uMaterial.specular", + "uMaterial.shininess", + ], + defines: defines !== null && defines !== void 0 ? defines : { + "SPECULAR": "1", + }, + }); + this.light = true; + this.light = defines === undefined; + this.setMatrix4fv("uProjection", false, Matrix4_1.default.create()); + this.setMatrix4fv("uModelView", false, Matrix4_1.default.create()); + this.set3F("uLight.position", 0, 1, 0); + this.set3F("uLight.direction", 0, 1, 0); + this.set3F("uLight.ambient", .2, .2, .2); + this.set3F("uLight.diffuse", .5, .5, .5); + this.set3F("uLight.specular", 1, 1, 1); + // for different point light values decay, check: + // http://wiki.ogre3d.org/tiki-index.php?page=-Point+Light+Attenuation + this.set1F("uLight.constant", 1.0); + this.set1F("uLight.linear", 0.045); + this.set1F("uLight.quadratic", 0.0075); + } + use() { + const gl = this._gl; + gl.useProgram(this._shaderProgram); + } + notUse() { + const gl = this._gl; + for (let i = 0; i < 7; i++) { + gl.vertexAttribDivisor(i, 0); + gl.disableVertexAttribArray(i); + } + gl.useProgram(null); + } + createVAO(gl, geometryInfo, material) { + var _a; + const vao = gl.createVertexArray(); + gl.bindVertexArray(vao); + for (let i = 0; i < 3; i++) { + gl.enableVertexAttribArray(i); + gl.vertexAttribDivisor(i, 0); + } + const instanceCount = geometryInfo.instanceCount || 1; + const glGeometryBuffer = Shader_1.default.createAttributeInfo(gl, 0, geometryInfo.vertex, 12, 0); + const glUVBuffer = Shader_1.default.createAttributeInfo(gl, 1, geometryInfo.uv, 8, 0); + const glNormalBuffer = Shader_1.default.createAttributeInfo(gl, 2, geometryInfo.normal, 12, 0); + const amodelLoc = gl.getAttribLocation(this._shaderProgram, "aModel"); + const glInstancedModelTransformBuffer = Shader_1.default.createInstancedModelMatrix(gl, instanceCount, amodelLoc, !!geometryInfo.index); + let glBufferIndex = null; + let vertexCount = (geometryInfo.vertex.length / 3) | 0; + if (geometryInfo.index) { + glBufferIndex = gl.createBuffer(); + gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, glBufferIndex); + gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, geometryInfo.index, gl.STATIC_DRAW); + vertexCount = geometryInfo.index.length; + } + gl.bindVertexArray(null); + return { + shader: this, + vao, + geometryBuffer: glGeometryBuffer, + uvBuffer: glUVBuffer, + indexBuffer: glBufferIndex, + instanceBuffer: glInstancedModelTransformBuffer, + normalBuffer: glNormalBuffer, + vertexCount: vertexCount, + instanceCount, + backFaceDisabled: geometryInfo.cullDisabled, + renderMode: (_a = material.renderMode) !== null && _a !== void 0 ? _a : this._gl.TRIANGLES, + }; + } + render(e, info, rc) { + const gl = e.gl; + if (info.backFaceDisabled) { + this._gl.disable(this._gl.CULL_FACE); + } + this.use(); + this.setMatrix4fv("uProjection", false, e.projectionMatrix()); + this.setMatrix4fv("uModelView", false, e.cameraMatrix()); + const material = rc.getMaterial().definition; + material.diffuse.enableAsUnit(gl, 0); + this.set1I("uMaterial.diffuse", 0); + this.set1F("uMaterial.ambient", material.ambient); + const light = e.light['point']; + if (this.light) { + material.specular.enableAsUnit(gl, 1); + this.set1I("uMaterial.specular", 1); + this.set1F("uMaterial.shininess", material.shininess); + this.set3FV("uLight.specular", light.getSpecular()); + } + this.set3FV("uLight.diffuse", light.getDiffuse()); + this.set3FV("uLight.position", light.getPosition()); + this.set3FV("uLight.ambient", light.getAmbient()); + this.set3FV("uViewPos", e.cameraPosition()); + gl.bindVertexArray(info.vao); + // if (info.indexBuffer) { + // gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, info.indexBuffer); + // } + info.instanceBuffer.draw(gl, info.vertexCount, info.instanceCount); + gl.bindVertexArray(null); + this.notUse(); + if (info.backFaceDisabled) { + this._gl.enable(this._gl.CULL_FACE); + } + } +} +exports.default = TextureShader; + +},{"../../math/Matrix4":1,"./Shader":20}],"Main":[function(require,module,exports){ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const Engine_1 = require("./render/Engine"); +const Platform_1 = require("./platform/Platform"); +const Texture_1 = require("./render/Texture"); +const Loader_1 = require("./platform/Loader"); +new Loader_1.Loader().addImage([ + "assets/earth.jpg", + "assets/cubemap3/back.png", + "assets/cubemap3/bottom.png", + "assets/cubemap3/front.png", + "assets/cubemap3/left.png", + "assets/cubemap3/right.png", + "assets/cubemap3/top.png", +]).load((l) => { + const e = new Engine_1.default(window.innerWidth, window.innerHeight); + const gl = e.gl; + e.addTexture("earth", Texture_1.default.initialize(gl, { + element: l.getImage("earth.jpg"), + wrap_mode: gl.REPEAT, + minFilter: gl.LINEAR_MIPMAP_LINEAR, + })); + /* + e.addTexture("jupiter", Texture_1.default.initialize(gl, { + element: l.getImage("jupiter.jpg"), + wrap_mode: gl.REPEAT, + minFilter: gl.LINEAR_MIPMAP_LINEAR, + })); + e.addTexture("moon", Texture_1.default.initialize(gl, { + element: l.getImage("moon.jpg"), + wrap_mode: gl.REPEAT, + minFilter: gl.LINEAR_MIPMAP_LINEAR, + })); + e.addTexture("diffuse", Texture_1.default.initialize(gl, { + element: l.getImage("diffuse.png"), + wrap_mode: gl.CLAMP_TO_EDGE, + minFilter: gl.LINEAR_MIPMAP_LINEAR, + })); + e.addTexture("specular", Texture_1.default.initialize(gl, { + element: l.getImage("lava.jpg"), + wrap_mode: gl.CLAMP_TO_EDGE, + minFilter: gl.LINEAR_MIPMAP_LINEAR, + })); + */ + e.addTexture("cubemap", Texture_1.default.initializeCubeMap(gl, l.getImagesWith(["left.png", "right.png", "top.png", "bottom.png", "back.png", "front.png"]))); + e.init(); + window.addEventListener("keydown", (ev) => { + e.keyboardEvent(ev.key, true); + }); + window.addEventListener("keyup", (ev) => { + e.keyboardEvent(ev.key, false); + }); + window.addEventListener("resize", (ev) => { + e.resize(window.innerWidth, window.innerHeight); + }); + Platform_1.default.canvas.onclick = function () { + Platform_1.default.canvas.requestPointerLock(); + }; + document.addEventListener('pointerlockchange', lockChangeAlert, false); + run(); + function lockChangeAlert() { + if (document.pointerLockElement === Platform_1.default.canvas) { + console.log('The pointer lock status is now locked'); + Platform_1.default.canvas.addEventListener("mousemove", updatePosition, false); + } + else { + console.log('The pointer lock status is now unlocked'); + Platform_1.default.canvas.removeEventListener("mousemove", updatePosition, false); + firstPointerLockPosition = true; + } + } + let firstPointerLockPosition = true; + function updatePosition(ev) { + if (firstPointerLockPosition) { + firstPointerLockPosition = false; + } + else { + e.mouseEvent(ev.movementX, ev.movementY); + } + } + function run() { + function loop() { + e.render(16.66); + requestAnimationFrame(loop); + } + requestAnimationFrame(loop); + } +}); + +},{"./platform/Loader":5,"./platform/Platform":6,"./render/Engine":8,"./render/Texture":13}]},{},[]) +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJtYXRoL01hdHJpeDQudHMiLCJtYXRoL1F1YXRlcm5pb24udHMiLCJtYXRoL1NwaGVyZVRlc3NlbGxhdG9yLnRzIiwibWF0aC9WZWN0b3IzLnRzIiwicGxhdGZvcm0vTG9hZGVyLnRzIiwicGxhdGZvcm0vUGxhdGZvcm0udHMiLCJyZW5kZXIvQ2FtZXJhLnRzIiwicmVuZGVyL0VuZ2luZS50cyIsInJlbmRlci9MaWdodC50cyIsInJlbmRlci9NYXRlcmlhbC50cyIsInJlbmRlci9NZXNoLnRzIiwicmVuZGVyL1N1cmZhY2UudHMiLCJyZW5kZXIvVGV4dHVyZS50cyIsInJlbmRlci9nZW9tZXRyeS9DdWJlLnRzIiwicmVuZGVyL2d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ICAgICAgICAgICAgIDBcblx0ICogICAgMCAgICAgICAgICAgICAgICAgICAgcS53wrIrcS54wrItcS55wrItcS56wrIgICAgICAgIDIqcS54KnEueSAtIDIqcS53KnEueiAgICAyKnEueCpxLnogKyAyKnEudypxLnlcblx0ICogICAgMCAgICAgICAgICAgICAgICAgICAgMipxLngqcS55ICsgMipxLncqcS56ICAgIHEud8KyLXEueMKyICsgcS55wrItcS56wrIgICAgMipxLnkqcS56IC0gMipxLncqcS54XG5cdCAqICAgIDAgICAgICAgICAgICAgICAgICAgIDIqcS54KnEueiAtIDIqcS53KnEueSAgICAyKnEueSpxLnogKyAyKnEudypxLnggICAgcS53wrItcS54wrItcS55wrIrcS56wrJcblx0ICovXG5cdHN0YXRpYyB0b01hdHJpeChtOiBGbG9hdDMyQXJyYXksIHE6IEZsb2F0MzJBcnJheSkge1xuXG5cdFx0Y29uc3QgdzIgPSBxW3ddICogcVt3XTtcblxuXHRcdGNvbnN0IHggPSBxW2ldO1xuXHRcdGNvbnN0IHgyID0geCAqIHg7XG5cdFx0Y29uc3QgeSA9IHFbal07XG5cdFx0Y29uc3QgeTIgPSB5ICogeTtcblx0XHRjb25zdCB6ID0gcVtrXTtcblx0XHRjb25zdCB6MiA9IHogKiB6O1xuXG5cdFx0Ly8gcm93IDBcblx0XHRtWzBdID0gdzIgKyB4MiArIHkyICsgejI7XG5cdFx0bVsxXSA9IDA7XG5cdFx0bVsyXSA9IDA7XG5cdFx0bVszXSA9IDA7XG5cblx0XHQvLyByb3cgMVxuXHRcdG1bNF0gPSAwO1xuXHRcdG1bNV0gPSB3MiArIHgyIC0geTIgLSB6Mjtcblx0XHRtWzZdID0gMiAqIHggKiB5IC0gMiAqIHcgKiB6O1xuXHRcdG1bN10gPSAyICogeCAqIHogKyAyICogdyAqIHk7XG5cblx0XHQvLyByb3cgMlxuXHRcdG1bOF0gPSAwO1xuXHRcdG1bOV0gPSAyICogeCAqIHkgKyAyICogdyAqIHo7XG5cdFx0bVsxMF0gPS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biAgICAgICAgICBpZiAodGhpcy5yb3dXaXRoUXVhZHMocm93LTEpKSB7XG4gICAgICAgICAgICBucSA9IHRoaXMuY29ubmVjdFF1YWQocm93IC0gMSwgY29sdW1uKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgciA9IG5ldyBGYWNlc0VkZ2UodGhpcy5nZXRRdWFkVG9wRWRnZShyb3csIGNvbHVtbikpO1xuICAgICAgICB9XG4gICAgICAgIGJyZWFrO1xuICAgICAgY2FzZSBRdWFkRGlyZWN0aW9uLkRvd246XG4gICAgICAgIGlmIChyb3cgPCB0aGlzLnBhcmFsbGVscyAtIDEpIHtcbiAgICAgICAgICBpZiAodGhpcy5yb3dXaXRoUXVhZHMocm93KzEpKSB7XG4gICAgICAgICAgICBucSA9IHRoaXMuY29ubmVjdFF1YWQocm93ICsgMSwgY29sdW1uKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgciA9IG5ldyBGYWNlc0VkZ2UodGhpcy5nZXRRdWFkQm90dG9tRWRnZShyb3csIGNvbHVtbikpO1xuICAgICAgICB9XG4gICAgICAgIGJyZWFrO1xuICAgIH1cblxuICAgIGlmIChyKSB7XG4gICAgICByLnBhcmVudCA9IHRoaXMuY29ubmVjdGVkUXVhZHMuZ2V0KHJvdywgY29sdW1uKTtcbiAgICAgIGlmIChucSAmJiAhbnEucGFyZW50KSB7XG4gICAgICAgIG5xLnBhcmVudCA9IHI7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICAvLyBjb25zb2xlLmVycm9yKGBxdWFkIGZvbGQgd2l0aCBwYXJlbnRgKTtcbiAgICAgIH1cbiAgICB9XG5cbiAgICByZXR1cm4gcjtcbiAgfVxuXG4gIHByaXZhdGUgc3RhdGljIHNwaGVyaWNhbCh0OiBudW1iZXIsIHU6IG51bWJlcikge1xuXG4gICAgdCAqPSBNYXRoLlBJICogMjtcbiAgICB1ICo9IE1hdGguUElcblxuICAgIHJldHVybiBuZXcgVmVydGV4KFxuICAgICAgTWF0aC5zaW4odS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yZW1vdmVFdmVudExpc3RlbmVyKFwibW91c2Vtb3ZlXCIsIHVwZGF0ZVBvc2l0aW9uLCBmYWxzZSk7XG4gICAgICAgICAgICBmaXJzdFBvaW50ZXJMb2NrUG9zaXRpb24gPSB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuICAgIGxldCBmaXJzdFBvaW50ZXJMb2NrUG9zaXRpb24gPSB0cnVlO1xuICAgIGZ1bmN0aW9uIHVwZGF0ZVBvc2l0aW9uKGV2KSB7XG4gICAgICAgIGlmIChmaXJzdFBvaW50ZXJMb2NrUG9zaXRpb24pIHtcbiAgICAgICAgICAgIGZpcnN0UG9pbnRlckxvY2tQb3NpdGlvbiA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgZS5tb3VzZUV2ZW50KGV2Lm1vdmVtZW50WCwgZXYubW92ZW1lbnRZKTtcbiAgICAgICAgfVxuICAgIH1cbiAgICBmdW5jdGlvbiBydW4oKSB7XG4gICAgICAgIGZ1bmN0aW9uIGxvb3AoKSB7XG4gICAgICAgICAgICBlLnJlbmRlcigxNi42Nik7XG4gICAgICAgICAgICByZXF1ZXN0QW5pbWF0aW9uRnJhbWUobG9vcCk7XG4gICAgICAgIH1cbiAgICAgICAgcmVxdWVzdEFuaW1hdGlvbkZyYW1lKGxvb3ApO1xuICAgIH1cbn0pO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9TWFpbi5qcy5tYXAiXX0= + +require('Main'); diff --git a/myriahedral/assets/cubemap3/back.png b/myriahedral/assets/cubemap3/back.png new file mode 100644 index 0000000..c582bbb Binary files /dev/null and b/myriahedral/assets/cubemap3/back.png differ diff --git a/myriahedral/assets/cubemap3/bottom.png b/myriahedral/assets/cubemap3/bottom.png new file mode 100644 index 0000000..b700048 Binary files /dev/null and b/myriahedral/assets/cubemap3/bottom.png differ diff --git a/myriahedral/assets/cubemap3/front.png b/myriahedral/assets/cubemap3/front.png new file mode 100644 index 0000000..27245c0 Binary files /dev/null and b/myriahedral/assets/cubemap3/front.png differ diff --git a/myriahedral/assets/cubemap3/left.png b/myriahedral/assets/cubemap3/left.png new file mode 100644 index 0000000..c438ace Binary files /dev/null and b/myriahedral/assets/cubemap3/left.png differ diff --git a/myriahedral/assets/cubemap3/right.png b/myriahedral/assets/cubemap3/right.png new file mode 100644 index 0000000..5b8d287 Binary files /dev/null and b/myriahedral/assets/cubemap3/right.png differ diff --git a/myriahedral/assets/cubemap3/top.png b/myriahedral/assets/cubemap3/top.png new file mode 100644 index 0000000..f38d636 Binary files /dev/null and b/myriahedral/assets/cubemap3/top.png differ diff --git a/myriahedral/assets/earth.jpg b/myriahedral/assets/earth.jpg new file mode 100644 index 0000000..7dcab8a Binary files /dev/null and b/myriahedral/assets/earth.jpg differ diff --git a/myriahedral/index.html b/myriahedral/index.html new file mode 100644 index 0000000..6676089 --- /dev/null +++ b/myriahedral/index.html @@ -0,0 +1,55 @@ + + + + + Title + + + + + + +

                    + + \ No newline at end of file diff --git a/package.json b/package.json deleted file mode 100644 index e718fab..0000000 --- a/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "hyperandroid.github.io", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [], - "author": "", - "license": "ISC" -}