diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index bfa904a8..0edb0222 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -22,24 +22,24 @@ 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 +Version: 0.6 build: 67 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-12-11 +TIME: 17:13:07 */ -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(); +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(c,a,b,d){if(c){c=new Box2D.Dynamics.b2DebugDraw;try{c.m_sprite.graphics.clear=function(){}}catch(g){}b.SetDebugDraw(c);c.SetSprite(a.ctx);c.SetDrawScale(d||CAAT.PMR);c.SetFillAlpha(0.5);c.SetLineThickness(1);c.SetFlags(3)}else b.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:!1,__init:function(){this.__super();this.setPositionAnchor(0.5,0.5);return this},setPositionAnchor:function(c,a){this.tAnchorY=this.tAnchorX=0.5},setPositionAnchored:function(c,a,b,d){this.x=c;this.y=a;this.tAnchorY=this.tAnchorX=0.5},setRecycle:function(){this.recycle=!0;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(!1);else{var c=this.worldBody;c.DestroyFixture(this.worldBodyFixture);this.world.DestroyBody(c)}return this},setAwake:function(c){this.worldBody.SetAwake(c);return this},setSleepingAllowed:function(c){this.worldBody.SetSleepingAllowed(c);return this},setLocation:function(c,a){this.worldBody.SetPosition(new Box2D.Common.Math.b2Vec2(c/CAAT.PMR,a/CAAT.PMR));return this},setDensity:function(c){this.density=c;return this}, +setFriction:function(c){this.friction=c;return this},setRestitution:function(c){this.restitution=c;return this},setBodyType:function(c){this.bodyType=c;return this},check:function(c,a,b){c[a]||(c[a]=b)},createBody:function(c,a){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=c;return this},getCenter:function(){return this.worldBody.GetPosition()},getDistanceJointLocalAnchor:function(){return new Box2D.Common.Math.b2Vec2(0,0)},animate:function(c,a){var b=this.worldBody.GetPosition();CAAT.Foundation.Actor.prototype.setLocation.call(this,CAAT.PMR*b.x,CAAT.PMR*b.y);this.setRotation(this.worldBody.GetAngle());return CAAT.Foundation.Box2D.B2DBodyActor.superclass.animate.call(this,c,a)}}}}); +CAAT.Module({defines:"CAAT.Foundation.Box2D.B2DCircularBody",depends:["CAAT.Foundation.Box2D.B2DBodyActor"],aliases:["CAAT.B2DCircularBody"],extendsClass:"CAAT.Foundation.Box2D.B2DBodyActor",constants:{createCircularBody:function(c,a){a.radius&&(this.radius=a.radius);var b=new Box2D.Dynamics.b2FixtureDef;b.density=a.density;b.friction=a.friction;b.restitution=a.restitution;b.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);b.userData=a.userData;d.userData=a.userData;var g=c.CreateBody(d),h=g.CreateFixture(b);a.isSensor&&h.SetSensor(!0);return{worldBody:g,worldBodyFixture:h,fixDef:b,bodyDef:d}}},extendsWith:{radius:1,createBody:function(c,a){var b=a.radius||1,b=b+(a.bodyDefScaleTolerance||0)*Math.random();a.radius=b;CAAT.Foundation.Box2D.B2DCircularBody.superclass.createBody.call(this,c,a);b=CAAT.Foundation.Box2D.B2DCircularBody.createCircularBody(c,a);a.userData.actor=this;this.worldBody=b.worldBody; +this.worldBodyFixture=b.worldBodyFixture;this.fixtureDef=b.fixDef;this.bodyDef=b.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(c,a){var b=new Box2D.Dynamics.b2FixtureDef;b.density=a.density;b.friction=a.friction;b.restitution=a.restitution;b.shape=new Box2D.Collision.Shapes.b2PolygonShape;for(var d=Number.MAX_VALUE,g=-Number.MAX_VALUE,h=Number.MAX_VALUE,l=-Number.MAX_VALUE, +e=[],k=a.bodyDefScale||1,k=k+(a.bodyDefScaleTolerance||0)*Math.random(),f=0;fg&&(g=m);nl&&(l=n);e.push(new Box2D.Common.Math.b2Vec2(m/CAAT.PMR,n/CAAT.PMR))}k=[{x:d,y:h},{x:g,y:l}];f=new Box2D.Dynamics.b2BodyDef;f.type=a.bodyType;f.position.Set(((g-d)/2+(a.x||0))/CAAT.PMR,((l-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),b.shape.SetAsEdge(new Box2D.Common.Math.b2Vec2(0,0),e);else if(a.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.BOX)b.shape.SetAsBox((g-d)/2/CAAT.PMR,(l-h)/2/CAAT.PMR);else if(a.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.POLYGON)b.shape.SetAsArray(e,e.length);else throw"Unkown bodyData polygonType: "+a.polygonType;b.userData=a.userData;f.userData=a.userData;e=c.CreateBody(f);d=e.CreateFixture(b); +a.isSensor&&d.SetSensor(!0);return{worldBody:e,worldBodyFixture:d,fixDef:b,bodyDef:f,boundingBox:k}}},extendsClass:"CAAT.Foundation.Box2D.B2DBodyActor",extendsWith:{boundingBox:null,getDistanceJointLocalAnchor:function(){return this.worldBody.GetFixtureList().GetShape().GetLocalCenter()},createBody:function(c,a){CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,c,a);var b=CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(c,a);a.userData.actor=this;this.worldBody=b.worldBody; +this.worldBodyFixture=b.worldBodyFixture;this.fixtureDef=b.fixDef;this.bodyDef=b.bodyDef;this.bodyData=a;this.boundingBox=b.boundingBox;this.setBackgroundImage(a.image).setSize(b.boundingBox[1].x-b.boundingBox[0].x+1,b.boundingBox[1].y-b.boundingBox[0].y+1).setFillStyle(b.worldBodyFixture.IsSensor()?"#0f0":"#f00").setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);return this}}});CAAT.ModuleManager.solveAll(); diff --git a/build/caat-box2d.js b/build/caat-box2d.js index 420e2272..e3b885f5 100644 --- a/build/caat-box2d.js +++ b/build/caat-box2d.js @@ -21,11 +21,11 @@ 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: 5 +Version: 0.6 build: 66 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-12-11 +TIME: 17:13:07 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index 44a6dcd0..ed80004f 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -22,562 +22,561 @@ 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 +Version: 0.6 build: 67 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-12-11 +TIME: 17:13:07 */ -(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 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:!1,module:null,setProcessed:function(){this.processed=!0},isProcessed:function(){return this.processed}};var k=function(){this.nodes=[];this.loadedFiles=[];this.path={};this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};k.baseURL=""; +k.modulePath={};k.sortedModulePath=[];k.symbol={};k.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.")}a.depends|| +(a.depends=[]);(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}}}}); +1,0,0,0,1];"undefined"!==typeof Float32Array&&(this.matrix=new Float32Array(this.matrix));return this},transformCoord:function(a){var b=a.x,c=a.y,d=this.matrix;a.x=b*d[0]+c*d[1]+d[2];a.y=b*d[3]+c*d[4]+d[5];return a},setRotation:function(a){this.identity();var b=this.matrix,c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=-a;b[3]=a;b[4]=c;return this},setScale:function(a,b){this.identity();this.matrix[0]=a;this.matrix[4]=b;return this},setTranslate:function(a,b){this.identity();this.matrix[2]=a;this.matrix[5]= +b;return this},copy:function(a){a=a.matrix;var b=this.matrix;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},identity:function(){var a=this.matrix;a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return this},multiply:function(a){var b=this.matrix,c=a.matrix;a=b[0];var d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],k=b[6],m=b[7],n=b[8],p=c[0],r=c[1],q=c[2],s=c[3],t=c[4],u=c[5],x=c[6],w=c[7],c=c[8];b[0]=a*p+d*s+e*x;b[1]=a*r+d*t+e*w;b[2]=a*q+ +d*u+e*c;b[3]=f*p+g*s+h*x;b[4]=f*r+g*t+h*w;b[5]=f*q+g*u+h*c;b[6]=k*p+m*s+n*x;b[7]=k*r+m*t+n*w;b[8]=k*q+m*u+n*c;return this},premultiply:function(a){var b=a.matrix[0]*this.matrix[1]+a.matrix[1]*this.matrix[4]+a.matrix[2]*this.matrix[7],c=a.matrix[0]*this.matrix[2]+a.matrix[1]*this.matrix[5]+a.matrix[2]*this.matrix[8],d=a.matrix[3]*this.matrix[0]+a.matrix[4]*this.matrix[3]+a.matrix[5]*this.matrix[6],e=a.matrix[3]*this.matrix[1]+a.matrix[4]*this.matrix[4]+a.matrix[5]*this.matrix[7],f=a.matrix[3]*this.matrix[2]+ +a.matrix[4]*this.matrix[5]+a.matrix[5]*this.matrix[8],g=a.matrix[6]*this.matrix[0]+a.matrix[7]*this.matrix[3]+a.matrix[8]*this.matrix[6],h=a.matrix[6]*this.matrix[1]+a.matrix[7]*this.matrix[4]+a.matrix[8]*this.matrix[7],k=a.matrix[6]*this.matrix[2]+a.matrix[7]*this.matrix[5]+a.matrix[8]*this.matrix[8];this.matrix[0]=a.matrix[0]*this.matrix[0]+a.matrix[1]*this.matrix[3]+a.matrix[2]*this.matrix[6];this.matrix[1]=b;this.matrix[2]=c;this.matrix[3]=d;this.matrix[4]=e;this.matrix[5]=f;this.matrix[6]=g; +this.matrix[7]=h;this.matrix[8]=k;return this},getInverse:function(a){var b=this.matrix,c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],k=b[6],m=b[7],b=b[8];a=a||new CAAT.Math.Matrix;var n=c*(g*b-m*h)-f*(d*b-m*e)+k*(d*h-g*e);if(0===n)return null;var p=a.matrix;p[0]=g*b-h*m;p[1]=e*m-d*b;p[2]=d*h-e*g;p[3]=h*k-f*b;p[4]=c*b-e*k;p[5]=e*f-c*h;p[6]=f*m-g*k;p[7]=d*k-c*m;p[8]=c*g-d*f;a.multiplyScalar(1/n);return a},multiplyScalar:function(a){var b;for(b=0;9>b;b++)this.matrix[b]*=a;return this},transformRenderingContextSet_NoClamp:function(a){var b= +this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);return this},transformRenderingContext_NoClamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2],b[5]);return this},transformRenderingContextSet_Clamp:function(a){var b=this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2]>>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,k,m,n;n= +this.matrix;d=1;m=g=0;k=1;c=Math.cos(e);e=Math.sin(e);f=d;h=m;d=(f*c+g*e)*this.scaleX;g=(-f*e+g*c)*this.scaleY;m=(h*c+k*e)*this.scaleX;k=(-h*e+k*c)*this.scaleY;n[0]=d;n[1]=g;n[2]=a;n[3]=m;n[4]=k;n[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}}}}); +d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,k){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]=k;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;4>a;a++)for(var b=0;4>b;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){a=this.rotate(a,b,c);this.copy(a);return this},rotate:function(a, +b,c){var d=new CAAT.Math.Matrix3,e,f;0!==a&&(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));0!==b&&(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));0!==c&&(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],k=b[1][2],m=b[1][3],n=b[2][0],p=b[2][1],r=b[2][2],b=b[2][3],q=a.matrix;a=q[0][0];var s=q[0][1],t=q[0][2],u=q[0][3],x=q[1][0],w=q[1][1],v=q[1][2],z=q[1][3],y=q[2][0],A=q[2][1],B=q[2][2],C=q[2][3],D=q[3][0],E=q[3][1],F=q[3][2],q=q[3][3];this.matrix[0][0]=c*a+d*x+e*y+f*D;this.matrix[0][1]=c*s+d*w+e*A+f*E;this.matrix[0][2]=c*t+d*v+e*B+f*F;this.matrix[0][3]= +c*u+d*z+e*C+f*q;this.matrix[1][0]=g*a+h*x+k*y+m*D;this.matrix[1][1]=g*s+h*w+k*A+m*E;this.matrix[1][2]=g*t+h*v+k*B+m*F;this.matrix[1][3]=g*u+h*z+k*C+m*q;this.matrix[2][0]=n*a+p*x+r*y+b*D;this.matrix[2][1]=n*s+p*w+r*A+b*E;this.matrix[2][2]=n*t+p*v+r*B+b*F;this.matrix[2][3]=n*u+p*z+r*C+b*q;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],k=b[1][2],m=b[1][3],n=b[2][0],p=b[2][1],r=b[2][2],b=b[2][3],q=a.matrix;a=q[0][0];var s= +q[0][1],t=q[0][2],u=q[0][3],x=q[1][0],w=q[1][1],v=q[1][2],z=q[1][3],y=q[2][0],A=q[2][1],B=q[2][2],q=q[2][3];this.matrix[0][0]=c*a+d*x+e*y;this.matrix[0][1]=c*s+d*w+e*A;this.matrix[0][2]=c*t+d*v+e*B;this.matrix[0][3]=c*u+d*z+e*q+f;this.matrix[1][0]=g*a+h*x+k*y;this.matrix[1][1]=g*s+h*w+k*A;this.matrix[1][2]=g*t+h*v+k*B;this.matrix[1][3]=g*u+h*z+k*q+m;this.matrix[2][0]=n*a+p*x+r*y;this.matrix[2][1]=n*s+p*w+r*A;this.matrix[2][2]=n*t+p*v+r*B;this.matrix[2][3]=n*u+p*z+r*q+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;4>b;b++)for(var c=0;4>c;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],k=a[1][3],m=a[2][0],n=a[2][1],p=a[2][2],r=a[2][3],q=a[3][0],s=a[3][1],t=a[3][2],a=a[3][3];return e*g*p*q+c*k*p*q+e*h*m*s+d*k*m*s+d*f*r*s+b*h*r*s+e*f*n*t+b*k*n*t+d*g*m*a+c*h*m*a+c*f*p*a+b*g*p*a+e*h*n*q-d*k*n*q-d*g*r*q-c*h*r*q-e*f*p*s-b*k*p*s-e*g*m*t-c*k*m*t-c*f*r*t-b*g*r*t-d*f*n*a-b*h*n*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],k=a[1][3],m=a[2][0],n=a[2][1],p= +a[2][2],r=a[2][3],q=a[3][0],s=a[3][1],t=a[3][2],a=a[3][3],u=new CAAT.Math.Matrix3;u.matrix[0][0]=h*r*s+k*n*t+g*p*a-k*p*s-g*r*t-h*n*a;u.matrix[0][1]=e*p*s+c*r*t+d*n*a-c*p*a-d*r*s-e*n*t;u.matrix[0][2]=d*k*s+c*h*a+e*g*t-c*k*t-d*g*a-e*h*s;u.matrix[0][3]=e*h*n+c*k*p+d*g*r-d*k*n-e*g*p-c*h*r;u.matrix[1][0]=k*p*q+f*r*t+h*m*a-h*r*q-k*m*t-f*p*a;u.matrix[1][1]=d*r*q+e*m*t+b*p*a-e*p*q-b*r*t-d*m*a;u.matrix[1][2]=e*h*q+b*k*t+d*f*a-d*k*q-e*f*t-b*h*a;u.matrix[1][3]=d*k*m+e*f*p+b*h*r-e*h*m-b*k*p-d*f*r;u.matrix[2][0]= +g*r*q+k*m*s+f*n*a-k*n*q-f*r*s-g*m*a;u.matrix[2][1]=e*n*q+b*r*s+c*m*a-b*n*a-c*r*q-e*m*s;u.matrix[2][2]=d*k*q+e*f*s+b*g*a-e*g*q-b*k*s-c*f*a;u.matrix[2][3]=e*g*m+b*k*n+c*f*r-b*g*r-c*k*m-e*f*n;u.matrix[3][0]=h*n*q+f*p*s+g*m*t-g*p*q-h*m*s-f*n*t;u.matrix[3][1]=c*p*q+d*m*s+b*n*t-d*n*q-b*p*s-c*m*t;u.matrix[3][2]=d*g*q+b*h*s+c*f*t-b*g*t-c*h*q-d*f*s;u.matrix[3][3]=c*h*m+d*f*n+b*g*p-d*g*m-b*h*n-c*f*p;return u.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;4>b;b++)for(c= +0;4>c;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-1a*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 0.005>a&&-0.005a&&-0.005=this.x&&a=this.y&&bthis.y1&&(this.y1=b), +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()||a.x1<=this.x||a.x>=this.x1||a.y1<=this.y?!1:a.ythis.x1||b+d-1c?2*c:1-2*(c-0.5));null!==b&&b&&(c=1-c);return this.interpolated.set(d,c)};return this},createBackOutInterpolator:function(a){this.getPosition=function(b){var c=b;a&&(b=0.5>b?2*b:1-2*(b-0.5));b-=1;return this.interpolated.set(c,b*b*(2.70158*b+1.70158)+1)};return this},createExponentialInInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return this.interpolated.set(d,Math.pow(c,a))};return this},createExponentialOutInterpolator:function(a,b){this.getPosition= +function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return this.interpolated.set(d,1-Math.pow(1-c,a))};return this},createExponentialInOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return 1>2*c?this.interpolated.set(d,Math.pow(2*c,a)/2):this.interpolated.set(d,1-Math.abs(Math.pow(2*c-2,a))/2)};return this},createQuadricBezierInterpolator:function(a,b,c,d){this.getPosition=function(e){var f=e;d&&(e=0.5>e?2*e:1-2*(e-0.5));e=(1-e)*(1-e)*a.y+2*(1-e)*e*b.y+ +e*e*c.y;return this.interpolated.set(f,e)};return this},createCubicBezierInterpolator:function(a,b,c,d,e){this.getPosition=function(f){var g=f;e&&(f=0.5>f?2*f:1-2*(f-0.5));var h=f*f;f=a.y+f*(3*-a.y+f*(3*a.y-a.y*f))+f*(3*b.y+f*(-6*b.y+3*b.y*f))+h*(3*c.y-3*c.y*f)+d.y*f*h;return this.interpolated.set(g,f)};return this},createElasticOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));if(0===d)return{x:0,y:0};if(1===d)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/ +a);return this.interpolated.set(d,a*Math.pow(2,-10*d)*Math.sin(2*(d-e)*Math.PI/b)+1)};return this},createElasticInInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));if(0===d)return{x:0,y:0};if(1===d)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/a);return this.interpolated.set(d,-(a*Math.pow(2,10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b)))};return this},createElasticInOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));var e=b/(2* +Math.PI)*Math.asin(1/a);d*=2;return 1>=d?this.interpolated.set(d,-0.5*a*Math.pow(2,10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b)):this.interpolated.set(d,1+0.5*a*Math.pow(2,-10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b))};return this},bounce:function(a){return(a/=1)<1/2.75?{x:a,y:7.5625*a*a}:a<2/2.75?{x:a,y:7.5625*(a-=1.5/2.75)*a+0.75}:a<2.5/2.75?{x:a,y:7.5625*(a-=2.25/2.75)*a+0.9375}:{x:a,y:7.5625*(a-=2.625/2.75)*a+0.984375}},createBounceOutInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b: +1-2*(b-0.5));return this.bounce(b)};return this},createBounceInInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b:1-2*(b-0.5));b=this.bounce(1-b);b.y=1-b.y;return b};return this},createBounceInOutInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b:1-2*(b-0.5));if(0.5>b)return b=this.bounce(1-2*b),b.y=0.5*(1-b.y),b;b=this.bounce(2*b-1,a);b.y=0.5*b.y+0.5;return b};return this},paint:function(a){a.save();a.beginPath();a.moveTo(0,this.getPosition(0).y*this.paintScale); for(var b=0;b<=this.paintScale;b++)a.lineTo(b,this.getPosition(b/this.paintScale).y*this.paintScale);a.strokeStyle="black";a.stroke();a.restore()},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.Behavior.BaseBehavior",constants:{Status:{NOT_STARTED:0,STARTED:1,EXPIRED:2},parse:function(a){function b(a){for(var a=a.split("."),b=window,c=0;c=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;ethis.behaviorStartTime)return!1;this.cycleBehavior&&a>=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),!1;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>=0;var d="@-"+ +a+"-keyframes "+b+" {";for(a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;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}}}}); +c=c.getKeyFrameDataValues(d);for(var f in c)e[f]=c[f]}return e},calculateKeyFrameData:function(a,b){function c(a){f[a]?h+=f[a]:prevValues&&(k=prevValues[a])&&(h+=k,f[a]=k)}var d,e,f={},g;for(d=0;d=g&&(g=(g-e.behaviorStartTime)/e.behaviorDuration,g=e.calculateKeyFrameData(g), +e=e.getPropertyName(b),"undefined"===typeof f[e]&&(f[e]=""),f[e]+=g+" "));var h="",k;c("translate");c("rotate");c("scale");d="";h&&(d="-"+b+"-transform: "+h+";");h="";c("opacity");h&&(d+=" opacity: "+h+";");return{rules:d+" -webkit-transform-origin: 0% 0%",ret:f}},calculateKeyFramesData:function(a,b,c,d,e){if(this.duration===Number.MAX_VALUE)return"";"undefined"===typeof d&&(d=0.5);"undefined"===typeof e&&(e=0.5);"undefined"===typeof c&&(c=100);var f="@-"+a+"-keyframes "+b+" {",g,h={};for(b=0;b<= +c;b++){g=this.interpolator.getPosition(b/c).y;g=this.getKeyFrameDataValues(g);var k=""+b/c*100+"%{",m=g,n=void 0;for(n in h)m[n]||(m[n]=h[n]);h="-"+a+"-transform:";if(m.x||m.y)h+="translate("+(m.x||0)+"px,"+(m.y||0)+"px)";m.angle&&(h+=" rotate("+m.angle+"rad)");if(1!==m.scaleX||1!==m.scaleY)h+=" scale("+m.scaleX+","+m.scaleY+")";h+=";";m.alpha&&(h+=" opacity: "+m.alpha+";");if(0.5!==d||0.5!==e)h+=" -"+a+"-transform-origin:"+100*d+"% "+100*e+"%;";f+=k+h+"}\n";h=g}return f+"}\n"}}}}); 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= +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);if(a.SVG){var b=(new CAAT.PathUtil.SVGPath).parsePath(a.SVG);this.setValues(b)}a.autoRotate&&(this.autoRotate= +a.autoRotate)},path:null,autoRotate:!1,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,isOpenContour:!1,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=!0;return this},setAutoRotate:function(a,b){this.autoRotate=a;void 0!==b&&(this.autoRotateOp=b);return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(a,b){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){a=this.interpolator.getPosition(a).y;var b=this.path.getPosition(a),c={x:b.x,y:b.y};this.autoRotate&&(a=0===a?b:this.path.getPosition(a-0.001),b=Math.atan2(b.y-a.y,b.x-a.x),c.angle=b);return c},calculateKeyFramesData:function(a,b,c){"undefined"===typeof c&&(c=100);c>>=0;var d, +e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;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.001);this.isRelative&&(c.x+=this.relativeX,c.y+=this.relativeY);if(this.autoRotate){-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(0===d&&0===e)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.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="undefined"!==typeof a.anchorX?parseInt(a.anchorX): +0.5;this.anchorY="undefined"!==typeof a.anchorY?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=!0;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;"undefined"!==typeof c&&"undefined"!==typeof d&&(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){"undefined"===typeof c&&(c=100);c>>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); +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:!0,parse:function(a){CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,a);this.startScale= +a.start||0;this.endScale=a.end||0;this.anchorX="undefined"!==typeof a.anchorX?parseInt(a.anchorX):0.5;this.anchorY="undefined"!==typeof a.anchorY?parseInt(a.anchorY):0.5;this.applyOnX=a.axis?"x"===a.axis.toLowerCase():!0},applyOnAxis:function(a){this.applyOnX=a===CAAT.Behavior.Scale1Behavior.AXIS.X?!1:!0},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;"undefined"!==typeof d&&"undefined"!==typeof e&&(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){a=this.interpolator.getPosition(a).y;var b={};b[this.applyOnX?"scaleX":"scaleY"]=this.startScale+a*(this.endScale-this.startScale);return b},calculateKeyFramesData:function(a,b,c){"undefined"===typeof c&&(c=100);c>>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); 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;b>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+ +"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); +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
', +CAAT.Module({defines:"CAAT.Module.Audio.AudioManager",extendsWith:function(){return{__init:function(){this.isFirefox=null!==navigator.userAgent.match(/Firefox/g);return this},isFirefox:!1,musicChannel:null,musicEnabled:!0,fxEnabled:!0,audioCache:null,channels:null,workingChannels:null,loopingChannels:[],audioFormatExtensions:["ogg","wav","x-wav","mp3"],currentAudioFormatExtension:"ogg",audioTypes:{ogg:"audio/ogg",mp3:"audio/mpeg;",wav:"audio/wav","x-wav":"audio/x-wav",mp4:'audio/mp4"'},initialize:function(a){this.setAudioFormatExtensions(this.audioFormatExtensions); +this.audioCache=[];this.channels=[];this.workingChannels=[];for(var b=0;b<=a;b++){var c=document.createElement("audio");if(null!==c){c.finished=-1;this.channels.push(c);var d=this;c.addEventListener("ended",function(a){a=a.target;var b;for(b=0;bb&&(console.log("Audio w/o extension: "+a),b=a.length()-1);return a.substring(0,b+1)+this.currentAudioFormatExtension},addAudioFromURL:function(a,b,c){var d=document.createElement("audio");return null!==d?(d.src=this.__getAudioUrl(b),console.log("Loading audio: "+d.src),d.preload="auto",d.load(),c&&(d.caat_callback=c,d.caat_id=a),this.audioCache.push({id:a,audio:d}),!0):!1},addAudioFromDomNode:function(a,b,c){var d=b.src.substr(b.src.lastIndexOf(".")+1);return b.canPlayType(this.audioTypes[d])? +(c&&(b.caat_callback=c,b.caat_id=a),this.audioCache.push({id:a,audio:b}),!0):!1},addAudioElement:function(a,b,c){if("string"===typeof b)return this.addAudioFromURL(a,b,c);try{if(b instanceof HTMLAudioElement)return this.addAudioFromDomNode(a,b,c)}catch(d){}return!1},addAudio:function(a,b,c){if(b instanceof Array)for(var d=0;d=h)return{r:a,g:b,b:c};if(h>=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;255a&&(a=0);255b&&(b=0);255c&&(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,k,m,n,p,r,q,s,t,u,x,w;for(f=0;f>24&255,q=(p&16711680)>>16,s=(p&65280)>>8,p&=255,g=a[f+1],t=g>>24&255,u=(g&16711680)>>16,x=(g&65280)>>8,g&=255,t=(t-r)/b,u=(u-q)/b,x=(x-s)/b,w=(g-p)/b,g=0;g>0;k=q+u*g>>0;m=s+x*g>>0;n=p+w*g>>0;var v=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case v.RAMP_RGBA:d.push("argb("+h+","+k+","+m+","+n+")");break;case v.RAMP_RGB:d.push("rgb("+k+","+m+","+n+")");break;case v.RAMP_CHANNEL_RGB:d.push(4278190080| +k<<16|m<<8|n);break;case v.RAMP_CHANNEL_RGBA:d.push(h<<24|k<<16|m<<8|n);break;case v.RAMP_CHANNEL_RGBA_ARRAY:d.push([k,m,n,h]);break;case v.RAMP_CHANNEL_RGB_ARRAY:d.push([k,m,n])}}return d},random:function(){for(var a="#",b=0;3>b;b++)a+="0123456789abcdef"[16*Math.random()>>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:!1,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= +document.getElementById("caat-debug-canvas");if(null===this.canvas)this.canDebug=!1;else return this.canvas.width=a,this.canvas.height=b,this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#000",this.ctx.fillRect(0,0,this.width,this.height),this.textFPS=document.getElementById("textFPS"),this.textDrawTime=document.getElementById("textDrawTime"),this.textRAFTime=document.getElementById("textRAFTime"),this.textEntitiesTotal=document.getElementById("textEntitiesTotal"),this.textEntitiesActive= +document.getElementById("textEntitiesActive"),this.textDraws=document.getElementById("textDraws"),this.textDirtyRects=document.getElementById("textDirtyRects"),this.textDiscardDR=document.getElementById("textDiscardDR"),this.canDebug=!0,this},debugInfo:function(a){this.statistics=a;a=CAAT;this.frameTimeAcc+=a.FRAME_TIME;this.frameRAFAcc+=a.REQUEST_ANIMATION_FRAME_TIME;this.framerate.frames++;a=(new Date).getTime();if(a>this.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps= +1E3*this.framerate.frames/(a-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=0>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= +"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);-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.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){a=/(\d+)p[x|t]\s*/i.exec(a);var b;b=a?a[1]|0:32;a=b-1;b=b+0.2*b|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=9===d.nodeType?d.defaultView||d.parentWindow:!1;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;128>c;c++)b+=String.fromCharCode(c);return this.create(b,a)}, +create:function(a,b){this.padding=b|=0;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(k);e+=k}g=CAAT.Font.getFontMetrics(d.font);d=g.height;this.ascent=g.ascent;this.descent=g.descent;this.height=g.height;k=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;gthis.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= +CAAT.Module({defines:"CAAT.Module.CircleManager.PackedCircleManager",depends:["CAAT.Math.Point","CAAT.Math.Rectangle"],extendsWith:{__init:function(){this.bounds=new CAAT.Math.Rectangle},allCircles:[],numberOfCollisionPasses:1,numberOfTargetingPasses:0,bounds:null,addCircle:function(a){a.id=this.allCircles.length;this.allCircles.push(a);return this},removeCircle:function(a){var b=0,c=!1,d=this.allCircles.length;if(0===d)throw"Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!"; +for(;d--;)if(this.allCircles[d]===a){c=!0;b=d;break}if(!c)throw"Could not locate circle in allCircles array!";this.allCircles[b].dealloc();this.allCircles[b]=null;return this},forceCirclesToMatchDelegatePositions:function(){for(var a=this.allCircles.length,b=0;bthis.bounds.right?a.position.x=this.bounds.left+e:b&1&&c+fthis.bounds.bottom?a.position.y=this.bounds.top-e:b&4&&d+f=this.bounds.right?a.position.x=a.position.x=this.bounds.right-e:b&8&&c-ethis.bounds.bottom?a.position.y=this.bounds.bottom-e:b&16&&d-ed?e=-1:c>=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;var d=!0,e=!0,f=!0,g=!0;"undefined"!==typeof c&& +("undefined"!==typeof c.top&&(d=c.top),"undefined"!==typeof c.bottom&&(e=c.bottom),"undefined"!==typeof c.left&&(f=c.left),"undefined"!==typeof c.right&&(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 k=h.getImageData(0,0,a.width,a.height).data,m;a=0;var n=c.height-1,p=0,r=c.width-1,q=!1;if(d){for(d=0;db){q=!0;break}if(q)break}a=d}if(e){q=!1;for(d=c.height-1;d>=a;d--){for(m=0;mb){q=!0;break}if(q)break}n=d}if(f){q=!1;for(m=0;mb){q=!0;break}if(q)break}p=m}if(g){q=!1;for(m=c.width-1;m>=p;m--){for(d=a;d<=n;d++)if(k[d*c.width*4+3+4*m]>b){q=!0;break}if(q)break}r=m}if(0===p&&0===a&&c.width-1===r&&c.height-1===n)return c;b=r-p+1;e=n-a+1;f=h.getImageData(p,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){b=b||24;c=c||24;var 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){"undefined"===typeof f&&(f=32);"undefined"===typeof g&&(g=1);var h=(a+c)/2,k=(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,k,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,k,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,k,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,k,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;cb;b++){if(this.quadData[b].intersects(a))for(f=this.quadData[b].getOverlappingActors(a),c=0,d=f.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];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;bc&&(c=100);100>d&&(d=100);this.width=c;this.height=d;this.createFromImages(this.images)},createFromImages:function(a){var b;this.scan=new CAAT.Module.TexturePacker.TextureScanMap(this.width,this.height);this.images=[];if(this.allowImagesInvertion)for(b=0;bb.width?-1:0:"height"===c.criteria?a.heightb.height?-1:0: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(); +CAAT.Module({defines:"CAAT.Module.Initialization.Template",depends:["CAAT.Foundation.Director","CAAT.Module.Preloader.ImagePreloader"],constants:{init:function(a,b,c,d,e){c=document.getElementById(c);var f;if(CAAT.__CSS__)c&&!1===c instanceof HTMLDivElement&&(c=null),null===c&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var g=document.createElement("canvas");c.appendChild(g);c=g}else!1==c instanceof HTMLCanvasElement&&(g=document.createElement("canvas"), +document.body.appendChild(g),c=g);else c=document.createElement("canvas"),document.body.appendChild(c);f=(new CAAT.Foundation.Director).initialize(a||800,b||600,c);(new CAAT.Module.Preloader.ImagePreloader).loadImages(d,function(a,b){a===b.length&&(f.emptyScenes(),f.setImagesCache(b),e(f),f.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,!1,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5,0.4)),CAAT.loop(60))})}}}); +CAAT.Module({defines:"CAAT.Module.Initialization.TemplateWithSplash",depends:["CAAT.Foundation.Director","CAAT.Module.Preloader.ImagePreloader"],constants:{init:function(a,b,c,d,e,f,g,h){function k(a,b,c){var d=a.getImage("spinner"),e=a.getImage("splash"),g=a.createScene(),f=(new Date).getTime();e&&g.addChild((new CAAT.Foundation.Actor).setBackgroundImage(e,!1).setBounds(0,0,a.width,a.height).setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE));d&&g.addChild((new CAAT.Foundation.Actor).setBackgroundImage(d).centerAt(g.width/ +2,g.height/2).addBehavior((new CAAT.Behavior.RotateBehavior).setValues(0,2*Math.PI).setFrameTime(0,1E3).setCycle(!0)));g.loadedImage=function(d,e){if(!e||d===e.length){var g=(new Date).getTime()-f;gb&&(g=b),setTimeout(function(){m(a,e,c)},g)):m(a,e,c)}};return g}function m(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(!0);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,!1,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, +0.4))}c=document.getElementById(c);var n;if(CAAT.__CSS__)c&&!1===c instanceof HTMLDivElement&&(c=null),null===c&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var p=document.createElement("canvas");c.appendChild(p);c=p}else!1==c instanceof HTMLCanvasElement&&(p=document.createElement("canvas"),document.body.appendChild(p),c=p);else c=document.createElement("canvas"),document.body.appendChild(c);n=(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});n.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){n.setImagesCache(b);var c=k(n,d||5E3,f);CAAT.loop(60);e&&0a)a%=1;0>a&&(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, +b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.Math.Bezier;g.setQuadric(a,b,c,d,e,f);this.curve=g;this.updatePath();return this},setCubic:function(a,b,c,d,e,f,g,h){var k=new CAAT.Math.Bezier;k.setCubic(a,b,c,d,e,f,g,h);this.curve=k;this.updatePath();return this},updatePath:function(a){this.curve.update();this.length=this.curve.getLength();this.curve.getBoundingBox(this.bbox);return this},getPosition:function(a){if(1a)a%=1;0>a&&(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}}}}); +b){0===b?this.points[0]=a:1===b&&(this.points[1]=a)},updatePath:function(a){a=this.points[1].x-this.points[0].x;var 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(1a)a%=1;0>a&&(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();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]; +if(1===a)return this.points[1]},getContour:function(a){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(;fa)a%=1; +0>a&&(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(;fa;a++)this.bbox.union(this.points[a].x,this.points[a].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(a){return this.getPosition(a/(2*this.bbox.width+2*this.bbox.height))}}}}); +CAAT.Module({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".split(" "),extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:{__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},pathSegments:null,pathSegmentDurationTime:null,pathSegmentStartTime:null,newPosition:null,pathLength:-1,beginPathX:-1,beginPathY:-1,trackPathX:-1,trackPathY:-1,ax:-1,ay:-1,point:[],interactive:!0,behaviorList:null,rb_angle:0,rb_rotateAnchorX:0.5,rb_rotateAnchorY:0.5,sb_scaleX:1,sb_scaleY:1,sb_scaleAnchorX:0.5,sb_scaleAnchorY:0.5,tAnchorX:0,tAnchorY:0,tb_x:0,tb_y:0,matrix:null,tmpMatrix:null,pathPoints:null,width:0,height:0,clipOffsetX:0,clipOffsetY:0,closed:!1,applyAsPath:function(a){var b= a.ctx;a.modelViewMatrix.transformRenderingContext(b);b.globalCompositeOperation="source-out";b.moveTo(this.getFirstPathSegment().startCurvePosition().x,this.getFirstPathSegment().startCurvePosition().y);for(var c=0;c=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=a)){var c,d,e;1<=a?(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.001),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(1a)a%=1;0>a&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,k;e!==f;){g=(f+e)/2|0;k=c[g];if(k<=a&&a<=k+d[g])return a=d[g]?(a-k)/d[g]:0,1a&&(a=0),a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;aa&&(a+=this.getLength());for(var b=0,c=0;c=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(cd&&(d=0);console.log("parse error near ..."+a.substr(d,20))}return{__init:function(){},c:0,bezierInfo:null,__skipBlank:function(a,c){for(var d=a.charAt(c);c=a},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(ca;a++)b[a]=a;this.linesBufferArray=new Uint16Array(b);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.linesBufferArray,this.gl.DYNAMIC_DRAW);this.shaderProgram.vertexPositionAttribute=this.gl.getAttribLocation(this.shaderProgram,"aVertexPosition");this.gl.enableVertexAttribArray(this.shaderProgram.vertexPositionAttribute); this.shaderProgram.textureCoordAttribute=this.gl.getAttribLocation(this.shaderProgram,"aTextureCoord");this.gl.enableVertexAttribArray(this.shaderProgram.textureCoordAttribute);this.shaderProgram.pMatrixUniform=this.gl.getUniformLocation(this.shaderProgram,"uPMatrix");this.shaderProgram.samplerUniform=this.gl.getUniformLocation(this.shaderProgram,"uSampler");this.shaderProgram.alphaUniform=this.gl.getUniformLocation(this.shaderProgram,"alpha");this.shaderProgram.useColor=this.gl.getUniformLocation(this.shaderProgram, -"uUseColor");this.shaderProgram.color=this.gl.getUniformLocation(this.shaderProgram,"uColor");this.setAlpha(1);this.setUseColor(false);this.vertexPositionBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexPositionBuffer);this.vertexPositionArray=new Float32Array(49152);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexPositionArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute,3,this.gl.FLOAT,false,0,0);this.vertexUVBuffer= -this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexUVBuffer);this.vertexUVArray=new Float32Array(32768);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexUVArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.textureCoordAttribute,2,this.gl.FLOAT,false,0,0);this.vertexIndexBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);b=[];for(a=0;a<4096;a++)b.push(0+a*4),b.push(1+a*4),b.push(2+a*4),b.push(0+a*4), -b.push(2+a*4),b.push(3+a*4);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(b),this.gl.DYNAMIC_DRAW);return CAAT.TextureProgram.superclass.initialize.call(this)},setUseColor:function(a,b,c,d,e){this.gl.uniform1i(this.shaderProgram.useColor,a?1:0);if(a&&(this.prevA!==e||this.prevR!==b||this.prevG!==c||this.prevB!==d))this.gl.uniform4f(this.shaderProgram.color,b,c,d,e),this.prevA=e,this.prevR=b,this.prevG=c,this.prevB=d},setTexture:function(a){if(this.prevTexture!==a){var b=this.gl; -b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,a);b.uniform1i(this.shaderProgram.samplerUniform,0);this.prevTexture=a}return this},updateVertexBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexPositionBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},updateUVBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexUVBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},setAlpha:function(a){if(this.prevAlpha!==a)this.gl.uniform1f(this.shaderProgram.alphaUniform, -a),this.prevAlpha=a;return this},drawLines:function(a,b,c,d,e,f,g){var h=this.gl;this.setAlpha(f);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.updateVertexBuffer(a);this.setUseColor(true,c,d,e,1);h.drawElements(h.LINES,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(false);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)},drawPolylines:function(a,b,c,d,e,f,g){var h=this.gl;h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.setAlpha(f); -this.updateVertexBuffer(a);this.setUseColor(true,c,d,e,1);h.drawElements(h.LINE_STRIP,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(false);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)}}});CAAT.Module({defines:"CAAT.Event.TouchInfo",aliases:["CAAT.TouchInfo"],extendsWith:{__init:function(a,b,c,d){this.identifier=a;this.pageX=this.clientX=b;this.pageY=this.clientY=c;this.target=d;this.time=(new Date).getTime();return this}}}); -CAAT.Module({defines:"CAAT.Event.TouchEvent",aliases:["CAAT.TouchEvent"],depends:["CAAT.Event.TouchInfo"],extendsWith:{__init:function(){this.touches=[];this.changedTouches=[];return this},time:0,source:null,sourceEvent:null,shift:false,control:false,alt:false,meta:false,touches:null,changedTouches:null,init:function(a,b,c){this.source=b;this.alt=a.altKey;this.control=a.ctrlKey;this.shift=a.shiftKey;this.meta=a.metaKey;this.sourceEvent=a;this.time=c;return this},addTouch:function(a){-1===this.touches.indexOf(a)&& +"uUseColor");this.shaderProgram.color=this.gl.getUniformLocation(this.shaderProgram,"uColor");this.setAlpha(1);this.setUseColor(!1);this.vertexPositionBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexPositionBuffer);this.vertexPositionArray=new Float32Array(49152);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexPositionArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute,3,this.gl.FLOAT,!1,0,0);this.vertexUVBuffer=this.gl.createBuffer(); +this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexUVBuffer);this.vertexUVArray=new Float32Array(32768);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexUVArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.textureCoordAttribute,2,this.gl.FLOAT,!1,0,0);this.vertexIndexBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);b=[];for(a=0;4096>a;a++)b.push(0+4*a),b.push(1+4*a),b.push(2+4*a),b.push(0+4*a),b.push(2+4*a),b.push(3+4* +a);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(b),this.gl.DYNAMIC_DRAW);return CAAT.TextureProgram.superclass.initialize.call(this)},setUseColor:function(a,b,c,d,e){this.gl.uniform1i(this.shaderProgram.useColor,a?1:0);!a||this.prevA===e&&this.prevR===b&&this.prevG===c&&this.prevB===d||(this.gl.uniform4f(this.shaderProgram.color,b,c,d,e),this.prevA=e,this.prevR=b,this.prevG=c,this.prevB=d)},setTexture:function(a){if(this.prevTexture!==a){var b=this.gl;b.activeTexture(b.TEXTURE0); +b.bindTexture(b.TEXTURE_2D,a);b.uniform1i(this.shaderProgram.samplerUniform,0);this.prevTexture=a}return this},updateVertexBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexPositionBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},updateUVBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexUVBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},setAlpha:function(a){this.prevAlpha!==a&&(this.gl.uniform1f(this.shaderProgram.alphaUniform,a),this.prevAlpha= +a);return this},drawLines:function(a,b,c,d,e,f,g){var h=this.gl;this.setAlpha(f);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.updateVertexBuffer(a);this.setUseColor(!0,c,d,e,1);h.drawElements(h.LINES,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(!1);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)},drawPolylines:function(a,b,c,d,e,f,g){var h=this.gl;h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.setAlpha(f);this.updateVertexBuffer(a); +this.setUseColor(!0,c,d,e,1);h.drawElements(h.LINE_STRIP,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(!1);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)}}});CAAT.Module({defines:"CAAT.Event.TouchInfo",aliases:["CAAT.TouchInfo"],extendsWith:{__init:function(a,b,c,d){this.identifier=a;this.pageX=this.clientX=b;this.pageY=this.clientY=c;this.target=d;this.time=(new Date).getTime();return this}}}); +CAAT.Module({defines:"CAAT.Event.TouchEvent",aliases:["CAAT.TouchEvent"],depends:["CAAT.Event.TouchInfo"],extendsWith:{__init:function(){this.touches=[];this.changedTouches=[];return this},time:0,source:null,sourceEvent:null,shift:!1,control:!1,alt:!1,meta:!1,touches:null,changedTouches:null,init:function(a,b,c){this.source=b;this.alt=a.altKey;this.control=a.ctrlKey;this.shift=a.shiftKey;this.meta=a.metaKey;this.sourceEvent=a;this.time=c;return this},addTouch:function(a){-1===this.touches.indexOf(a)&& this.touches.push(a);return this},addChangedTouch:function(a){-1===this.changedTouches.indexOf(a)&&this.changedTouches.push(a);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({defines:"CAAT.Event.MouseEvent",aliases:["CAAT.MouseEvent"],depends:["CAAT.Math.Point"],extendsWith:{__init:function(){this.point=new CAAT.Math.Point(0,0,0);this.screenPoint=new CAAT.Math.Point(0,0,0);this.touches=[];return this},screenPoint:null,point:null,time:0,source:null,shift:false,control:false,alt:false,meta:false,sourceEvent:null,touches:null,init:function(a,b,c,d,e,f){this.point.set(a,b);this.source=d;this.screenPoint=e;this.alt=c.altKey;this.control=c.ctrlKey;this.shift=c.shiftKey; -this.meta=c.metaKey;this.sourceEvent=c;this.x=a;this.y=b;this.time=f;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({defines:"CAAT.Event.MouseEvent",aliases:["CAAT.MouseEvent"],depends:["CAAT.Math.Point"],extendsWith:{__init:function(){this.point=new CAAT.Math.Point(0,0,0);this.screenPoint=new CAAT.Math.Point(0,0,0);this.touches=[];return this},screenPoint:null,point:null,time:0,source:null,shift:!1,control:!1,alt:!1,meta:!1,wheelDelta:0,sourceEvent:null,touches:null,init:function(a,b,c,d,e,f){this.point.set(a,b);this.source=d;this.screenPoint=e;this.alt=c.altKey;this.control=c.ctrlKey;this.shift=c.shiftKey; +this.meta=c.metaKey;this.wheelDelta=c.wheelDelta;this.sourceEvent=c;this.x=a;this.y=b;this.time=f;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({defines:"CAAT.Event.KeyEvent",aliases:"CAAT.KeyEvent",extendsWith:{__init:function(a,b,c,d){this.keyCode=a;this.action=b;this.modifiers=c;this.sourceEvent=d;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(){CAAT.KEYS={ENTER:13,BACKSPACE:8,TAB:9,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPSLOCK:20,ESCAPE:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,SELECT:93, NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBTRACT:109,DECIMALPOINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SCROLLLOCK:145,SEMICOLON:186,EQUALSIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARDSLASH:191,GRAVEACCENT:192,OPENBRACKET:219,BACKSLASH:220,CLOSEBRAKET:221,SINGLEQUOTE:222};CAAT.Keys=CAAT.KEYS;CAAT.SHIFT_KEY=16;CAAT.CONTROL_KEY= -17;CAAT.ALT_KEY=18;CAAT.ENTER_KEY=13;CAAT.KEY_MODIFIERS={alt:false,control:false,shift:false}}}); -CAAT.Module({defines:"CAAT.Event.Input",depends:["CAAT.Event.KeyEvent","CAAT.Event.MouseEvent","CAAT.Event.TouchEvent"],onCreate:function(){CAAT.setCursor=function(a){if(navigator.browser!=="iOS")document.body.style.cursor=a};CAAT.TOUCH_AS_MOUSE=1;CAAT.TOUCH_AS_MULTITOUCH=2;CAAT.TOUCH_BEHAVIOR=CAAT.TOUCH_AS_MOUSE;CAAT.windowResizeListeners=[];CAAT.registerResizeListener=function(a){CAAT.windowResizeListeners.push(a)};CAAT.unregisterResizeListener=function(a){for(var b=0;b=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;a=this.duration?(this.remove=!0,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=!1;this.startTime=a;this.owner.ensureTimerTask(this);return this},cancel:function(){this.remove=!0;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;0<=c;)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;0<=c;){if(b[c]===a)return!0;c--}return!1}, +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, +this.singleWidth/a.__texturePage.width;a.__dv=this.singleHeight/a.__texturePage.height;e=this.singleWidth;f=this.singleHeight;var h=this.columns;a.inverted&&(d=e,e=f,f=d,h=this.rows);a=this.image.__tx;for(var k=this.image.__ty,m=this.image.__texturePage,d=0;d>0)*e;var n=k+(d/h>>0)*f,p=g+e,r=n+f;g=(new CAAT.Foundation.SpriteImageHelper(g,n,p-g,r-n,m.width,m.height)).setGL(g/m.width,n/m.height,p/m.width,r/m.height);this.mapInfo[d]=g}}else for(d=0;d>0)+1,f=((c.height-g)/f>>0)+1,h,k=a.ctx;for(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, +this.parentOffsetY,parseFloat(b.width),parseFloat(b.height),this.image.width,this.image.height);c.xoffset="undefined"===typeof b.xoffset?0:parseFloat(b.xoffset);c.yoffset="undefined"===typeof b.yoffset?0:parseFloat(b.yoffset);c.xadvance="undefined"===typeof b.xadvance?b.width:parseFloat(b.xadvance);this.mapInfo[a]=c;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.Foundation.SpriteImageHelper(parseFloat(f.x)+this.parentOffsetX, +parseFloat(f.y)+this.parentOffsetX,parseFloat(f.width),parseFloat(f.height),a.width,a.height);d.xoffset="undefined"===typeof f.xoffset?0:f.xoffset;d.yoffset="undefined"===typeof f.yoffset?0:f.yoffset;d.xadvance="undefined"===typeof f.xadvance?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>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;e>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, +[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(!0);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,behaviorList:null,x:0,y:0,width:0,height:0,preferredSize:null,minimumSize:null,start_time:0,duration:Number.MAX_VALUE, +clip:!1,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:!1,frameAlpha:1,expired:!1,discardable:!1,domParent:null,domElement:null,visible:!0,mouseEnabled:!0,time:0,inFrame:!1,backgroundImage:null,size_active:1,size_total:1,id:null,__d_ax:-1,__d_ay:-1,gestureEnabled:!1,AABB:null,viewVertices:null,isAA:!0,preventLayout:!1,setPreventLayout:function(a){this.preventLayout=a;return this},invalidate:function(){this.invalid= +!0;return this},invalidateLayout:function(){this.parent&&!this.parent.layoutInvalidated&&this.parent.invalidateLayout();return this},__validateLayout:function(){},setPreferredSize:function(a,b){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){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(a){},touchMove:function(a){},touchEnd:function(a){},gestureStart:function(a,b,c){},gestureChange:function(a,b,c){this.gestureEnabled&&(this.setRotation(a),this.setScale(b,c));return this},gestureEnd:function(a,b,c){},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];c.xe&&(e=c.x);c.yg&&(g=c.y);c=b[1];c.x< +d&&(d=c.x);c.x>e&&(e=c.x);c.yg&&(g=c.y);c=b[2];c.xe&&(e=c.x);c.yg&&(g=c.y);c=b[3];c.xe&&(e=c.x);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=!0;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)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;("undefined"===typeof b||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(100*this.rotationAngle)/100;a="translate("+this.x+"px,"+this.y+"px) rotate("+this.rotationAngle+"rad) scale("+this.scaleX+","+this.scaleY+")"+a;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=""+100*this.rotationX+"% "+100*this.rotationY+"% ";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(a){this.alpha!==this.styleCache.opacity&& +(this.domElement.style.filter="alpha(opacity="+(100*this.alpha>>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),!1):this.start_time<=a&&ac.x?0:c.x,0>c.y?0:c.y,c.width,c.height),a.unionRectangle(this.runion);this.setSize(a.x1,a.y1);return this},addChildDelayed:function(a){this.pendingChildrenList.push(a); +return this},addChildAt:function(a,b){if(0>=b)return a.parent=this,a.dirty=!0,this.childrenList.splice(0,0,a),this.invalidateLayout(),this;b>=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=!0;return this},findActorById:function(a){for(var b=this.childrenList,c=0,d=b.length;c=d.length?(d.splice(c,1),d.push(a)):(c=d.splice(c,1),0>b?b=0:b>d.length&&(b=d.length),d.splice(b,0,c[0]));for(var c=0,e=d.length;cc?c=1:4Math.random()?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*(0.5>Math.random()?1:-1);break;default:alert("rot anchor ?? "+c)}if(!1===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(a){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a;this.style("display",a?"none":"block")},paint:function(a,b){},getIn:function(a){}, +goOut:function(a){}}}}); +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:!0,CLEAR_NONE:!1,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=!1;this.lastSelectedActor=null;this.dragging=!1;this.cDirtyRects=[];this.sDirtyRects=[];this.dirtyRects=[];for(var a=0;64>a;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:!1,renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:!1,lastSelectedActor:null, +dragging:!1,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:!1,glTextureManager:null,glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:!1,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:!1,nDirtyRects:0,drDiscarded:0,stopped:!1,needsRepaint:!1,touches:null,timerManager:null,SCREEN_RATIO:1,__map:null,clean:function(){this.audioManager=this.imagesCache=this.currentScene=this.scenes=null;this.isMouseDown=!1;this.lastSelectedActor=null;this.dragging=!1;this.__gestureRotation=this.__gestureScale=0;this.dirty=!0;this.cDirtyRects= +this.dirtyRects=null;this.dirtyRectsIndex=0;this.dirtyRectsEnabled=!1;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=!0},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;a=this.dirtyRects.length)for(b=0;32>b;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=!0;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)},findScene:function(a){var b=this.scenes,c,d=b.length;for(c=0;ce?(e=CAAT.Foundation.Scene.EASE_ROTATION,g=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):0.66>e?(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;0.33>f?(f=CAAT.Foundation.Scene.EASE_ROTATION,h=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):0.66>f?(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,8.99*Math.random()>>0,b, +f,8.99*Math.random()>>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=!1;a.setExpired(!1)},setScene:function(a){a="number"==typeof a?a:this.findScene(a);a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(!1); +a.mouseEnabled=!0;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);1>=this.getNumScenes()||0===d||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);1>=this.getNumScenes()||d===this.getNumScenes()- +1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(a){},mouseExit:function(a){},mouseMove:function(a){},mouseDown:function(a){},mouseUp:function(a){},mouseDrag:function(a){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(!0);a.mouseEnabled=!0;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;bb.x||0>b.y||b.x>=this.width||b.y>=this.height|| +(this.touching=!0,this.__mouseDownHandler(a))}},__touchEndHandler:function(a){this.touching&&(a.preventDefault(),a.returnValue=!1,a=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=!1,this.__mouseUpHandler(a))},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),a.returnValue=!1,!this.gesturing))for(var b=0;bf.x||0>f.y||f.x>=this.width||f.y>=this.height)){var g=this.findActorAtPosition(f);null!==g&&(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;be.x||0>e.y||e.x>=b.width||e.y>=b.height||(b.touching=!0,b.__mouseDownHandler(c))}},!1);window.addEventListener("mouseover",function(c){if(c.target===a&&!b.dragging){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||b.__mouseOverHandler(c)}},!1); +window.addEventListener("mouseout",function(c){c.target!==a||b.dragging||(c.preventDefault(),c.cancelBubble=!0,c.stopPropagation&&c.stopPropagation(),b.getCanvasCoord(b.mousePoint,c),b.__mouseOutHandler(c))},!1);window.addEventListener("mousemove",function(a){a.preventDefault();a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation();var c=b.mousePoint;b.getCanvasCoord(c,a);!b.dragging&&(0>c.x||0>c.y||c.x>=b.width||c.y>=b.height)||b.__mouseMoveHandler(a)},!1);window.addEventListener("dblclick",function(c){if(c.target=== +a){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||b.__mouseDBLClickHandler(c)}},!1);var c=function(c){if(c.target===a){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||(c.wheelDelta=Math.max(-1,Math.min(1,c.wheelDelta||-c.detail)),b.__mouseWheelHandler(c))}};window.addEventListener("mousewheel", +c,!1);window.addEventListener("DOMMouseScroll",c,!1);CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MOUSE?(a.addEventListener("touchstart",this.__touchStartHandler.bind(this),!1),a.addEventListener("touchmove",this.__touchMoveHandler.bind(this),!1),a.addEventListener("touchend",this.__touchEndHandler.bind(this),!1),a.addEventListener("gesturestart",function(c){c.target===a&&(c.preventDefault(),c.returnValue=!1,b.__gestureStart(c.scale,c.rotation))},!1),a.addEventListener("gestureend",function(c){c.target=== +a&&(c.preventDefault(),c.returnValue=!1,b.__gestureEnd(c.scale,c.rotation))},!1),a.addEventListener("gesturechange",function(c){c.target===a&&(c.preventDefault(),c.returnValue=!1,b.__gestureChange(c.scale,c.rotation))},!1)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),!1),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this),!1),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),!1),a.addEventListener("touchcancel", +this.__touchCancelHandleMT.bind(this),!1),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),!1),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this),!1),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),!1))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=!1;this.createEventHandler(a)},createEventHandler:function(a){this.in_=!1;this.addHandlers(a)}}},onCreate:function(){"undefined"!==typeof CAAT.__CSS__&& +(CAAT.Foundation.Director.prototype.clip=!0,CAAT.Foundation.Director.prototype.glEnabled=!1,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: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()}}}); +shadowColor:null,shadowOffsetX:null,shadowOffsetY:null,sfont:null,chain:null,setDefault:function(a){this.defaultFS=24;this.font="Arial";this.fontSize=this.defaultFS;this.fill="#000";this.stroke="#f00";this.filled=!0;this.stroked=!1;this.strokeSize=1;this.bold=this.italic=!1;this.alignment="left";this.tabSize=75;this.shadow=!1;this.shadowBlur=0;this.shadowColor="#000";this.shadowOffsetY=this.shadowOffsetX=0;for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);this.__setFont();return this},setStyle:function(a){if("undefined"!== +typeof a)for(var b in a)this[b]=a[b];return this},applyStyle:function(){this.__setFont();return this},clone:function(){var b=new a(this.ctx),c;for(c in this)this.hasOwnProperty(c)&&(b[c]=this[c]);for(var d=this;d.chain;)for(c in d=d.chain,d)null===b[c]&&d.hasOwnProperty(c)&&(b[c]=d[c]);b.__setFont();return b},__getProperty:function(a){var b=this,c;do{c=b[a];if(null!==c)return c;b=b.chain}while(b);return null},image:function(a){this.__setShadow(a)},text:function(a,b,c,d){this.__setShadow(a);a.font= +this.__getProperty("sfont");this.filled&&this.__fillText(a,b,c,d);this.stroked&&this.__strokeText(a,b,c,d)},__setShadow:function(a){this.__getProperty("shadow")&&(a.shadowBlur=this.__getProperty("shadowBlur"),a.shadowColor=this.__getProperty("shadowColor"),a.shadowOffsetX=this.__getProperty("shadowOffsetX"),a.shadowOffsetY=this.__getProperty("shadowOffsetY"))},__fillText:function(a,b,c,d){a.fillStyle=this.__getProperty("fill");a.fillText(b,c,d)},__strokeText:function(a,b,c,d){a.strokeStyle=this.__getProperty("stroke"); +a.lineWidth=this.__getProperty("strokeSize");a.beginPath();a.strokeText(b,c,d)},__setFont:function(){var a=this.__getProperty("italic"),b=this.__getProperty("bold"),c=this.__getProperty("fontSize"),d=this.__getProperty("font");this.sfont=(a?"italic ":"")+(b?"bold ":"")+c+"px "+d;this.ctx.font=this.__getProperty("sfont")},setBold:function(a){a!=this.bold&&(this.bold=a,this.__setFont())},setItalic:function(a){a!=this.italic&&(this.italic=a,this.__setFont())},setStroked:function(a){this.stroked=a},setFilled:function(a){this.filled= +a},getTabPos:function(a){var b=this.__getProperty("tabSize");return((a/b>>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){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="undefined"!==typeof b&&"undefined"!==typeof c?a.getWidth():a instanceof CAAT.Foundation.SpriteImage?a.getWidth():a.getWrappedImageWidth();this.width&&e+this.x>this.width&&0this.width&&0this.width&&this.__nextLine()):this.text+=a},end:function(){0>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(){1=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;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+(null!=a?a.descent:this.defaultFontMetrics.descent);for(c=0;c",d+1),-1!==r&&(q=f.substr(d+1,r-d-1),-1!==q.indexOf("<")?(this.rc.fchar(s),d+=1):(this.rc.setTag(q),d=r+1))):(this.rc.fchar(s),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension("undefined"===typeof b?0:b);this.setLinesAlignment();t.restore();this.setPreferredSize(this.documentWidth,this.documentHeight); +this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);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){"undefined"!==typeof a&&this.setHorizontalAlignment(a);"undefined"!==typeof b&&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(a){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:!1,outlineColor:"black",onUpdateCallback:null,interactive:!1,getPath:function(){return this.path},setPath:function(a){this.path=a;null!=a&&(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);this.bOutline&&(c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height))}},showBoundingBox:function(a,b){(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(a){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()}}}}); +a;return this},paint:function(a,b){},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;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,!1),c.fill());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,!1),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;this.lineCap&&(c.lineCap=this.lineCap);this.lineJoin&&(c.lineJoin=this.lineJoin);this.miterLimit&&(c.miterLimit=this.miterLimit);c.globalCompositeOperation=this.compositeOp;null!==this.fillStyle&&(c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width,this.height), +c.fill());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>0,e.y>>0):c.translate(e.x,e.y);c.rotate(f);this.fill&&c.fillText(h,0,0);this.outline&&(c.beginPath(),c.lineWidth=this.lineWidth,c.strokeText(h, +0,0));c.restore();d+=k}},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 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. @@ -22060,10 +22119,11 @@ CAAT.Module({ /** * Changes (or sets) the current Director scene to the index * parameter. There will be no transition on scene change. - * @param sceneIndex {number} an integer indicating the index of the target Scene + * @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 (sceneIndex) { + setScene:function (scene) { + var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene); var sin = this.scenes[ sceneIndex ]; this.childrenList = []; this.addChild(sin); @@ -22441,10 +22501,11 @@ CAAT.Module({ style = style ? style.getPropertyValue('position') : null; } -// if (!/^(relative|absolute|fixed)$/.test(style)) { + // Accumulate offsets... + x += node[left]; + y += node[top]; + if (!/^(fixed)$/.test(style)) { - x += node[left]; - y += node[top]; node = node[parent]; } else { break; @@ -22507,11 +22568,11 @@ CAAT.Module({ pt.x = posx; pt.y = posy; if (!this.modelViewMatrixI) { - this.modelViewMatrixI = this.modelViewMatrix.getInverse(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); } this.modelViewMatrixI.transformCoord(pt); posx = pt.x; - posy = pt.y + posy = pt.y; point.set(posx, posy); this.screenMousePoint.set(posx, posy); @@ -22564,7 +22625,7 @@ CAAT.Module({ 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.actionPerformed(e); } lactor.mouseUp( @@ -22814,7 +22875,6 @@ CAAT.Module({ __mouseDBLClickHandler:function (e) { - this.getCanvasCoord(this.mousePoint, e); if (null !== this.lastSelectedActor) { /* var pos = this.lastSelectedActor.viewToModel( @@ -22822,8 +22882,22 @@ CAAT.Module({ */ this.lastSelectedActor.mouseDblClick( new CAAT.Event.MouseEvent().init( - this.mousePoint.x, - this.mousePoint.y, + this.prevMousePoint.x, + this.prevMousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + __mouseWheelHandler:function (e) { + + if (null !== this.lastSelectedActor) { + this.lastSelectedActor.mouseWheel( + new CAAT.Event.MouseEvent().init( + this.prevMousePoint.x, + this.prevMousePoint.y, e, this.lastSelectedActor, this.screenMousePoint, @@ -23298,6 +23372,27 @@ CAAT.Module({ } }, false); + var mouseWheelHandler = 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; + } + + //Cross browser wheel delta + e.wheelDelta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); + me.__mouseWheelHandler(e); + } + }; + //IE9, Chrome, Safari, Opera + window.addEventListener('mousewheel', mouseWheelHandler, false); + //Firefox + window.addEventListener('DOMMouseScroll', mouseWheelHandler, 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); @@ -24041,44 +24136,50 @@ CAAT.Module( { renderContextStyle.prototype= { - ctx : null, - - defaultFS : null, - font : null, - fontSize : null, - fill : null, - stroke : null, - filled : null, - stroked : null, - strokeSize : null, - italic : null, - bold : null, - alignment : null, - tabSize : null, - shadow : null, - shadowBlur : null, - shadowColor : null, + ctx : null, + + defaultFS : null, + font : null, + fontSize : null, + fill : null, + stroke : null, + filled : null, + stroked : null, + strokeSize : null, + italic : null, + bold : null, + alignment : null, + tabSize : null, + shadow : null, + shadowBlur : null, + shadowColor : null, + shadowOffsetX: null, + shadowOffsetY: null, - sfont : null, - chain : null, + sfont : null, + + chain : null, setDefault : function( defaultStyles ) { - this.defaultFS = 24; - this.font = "Arial"; - this.fontSize = this.defaultFS; - this.fill = '#000'; - this.stroke = '#f00'; - this.filled = true; - this.stroked = false; - this.strokeSize = 1; - this.italic = false; - this.bold = false; - this.alignment = "left"; - this.tabSize = 75; - this.shadow = false; - this.shadowBlur = 0; - this.shadowColor= "#000"; + this.defaultFS = 24; + this.font = "Arial"; + this.fontSize = this.defaultFS; + this.fill = '#000'; + this.stroke = '#f00'; + this.filled = true; + this.stroked = false; + this.strokeSize = 1; + this.italic = false; + this.bold = false; + this.alignment = "left"; + this.tabSize = 75; + this.shadow = false; + this.shadowBlur = 0; + this.shadowColor = "#000"; + this.shadowOffsetX= 0; + this.shadowOffsetY= 0; + for( var style in defaultStyles ) { if ( defaultStyles.hasOwnProperty(style) ) { @@ -24178,8 +24279,10 @@ CAAT.Module( { __setShadow : function( ctx ) { if ( this.__getProperty("shadow" ) ) { - ctx.shadowBlur= this.__getProperty("shadowBlur"); - ctx.shadowColor= this.__getProperty("shadowColor"); + ctx.shadowBlur = this.__getProperty("shadowBlur"); + ctx.shadowColor = this.__getProperty("shadowColor"); + ctx.shadowOffsetX= this.__getProperty("shadowOffsetX"); + ctx.shadowOffsetY= this.__getProperty("shadowOffsetY"); } }, diff --git a/build/caat-min.js b/build/caat-min.js index 98c85f05..818b74e2 100644 --- a/build/caat-min.js +++ b/build/caat-min.js @@ -22,575 +22,575 @@ 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 +Version: 0.6 build: 67 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-12-11 +TIME: 17:13:07 */ -(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 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:!1,module:null,setProcessed:function(){this.processed=!0},isProcessed:function(){return this.processed}};var k=function(){this.nodes=[];this.loadedFiles=[];this.path={};this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};k.baseURL=""; +k.modulePath={};k.sortedModulePath=[];k.symbol={};k.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.")}a.depends|| +(a.depends=[]);(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}}}}); +1,0,0,0,1];"undefined"!==typeof Float32Array&&(this.matrix=new Float32Array(this.matrix));return this},transformCoord:function(a){var b=a.x,c=a.y,d=this.matrix;a.x=b*d[0]+c*d[1]+d[2];a.y=b*d[3]+c*d[4]+d[5];return a},setRotation:function(a){this.identity();var b=this.matrix,c=Math.cos(a);a=Math.sin(a);b[0]=c;b[1]=-a;b[3]=a;b[4]=c;return this},setScale:function(a,b){this.identity();this.matrix[0]=a;this.matrix[4]=b;return this},setTranslate:function(a,b){this.identity();this.matrix[2]=a;this.matrix[5]= +b;return this},copy:function(a){a=a.matrix;var b=this.matrix;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];return this},identity:function(){var a=this.matrix;a[0]=1;a[1]=0;a[2]=0;a[3]=0;a[4]=1;a[5]=0;a[6]=0;a[7]=0;a[8]=1;return this},multiply:function(a){var b=this.matrix,c=a.matrix;a=b[0];var d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],k=b[6],m=b[7],n=b[8],p=c[0],r=c[1],q=c[2],s=c[3],t=c[4],u=c[5],x=c[6],w=c[7],c=c[8];b[0]=a*p+d*s+e*x;b[1]=a*r+d*t+e*w;b[2]=a*q+ +d*u+e*c;b[3]=f*p+g*s+h*x;b[4]=f*r+g*t+h*w;b[5]=f*q+g*u+h*c;b[6]=k*p+m*s+n*x;b[7]=k*r+m*t+n*w;b[8]=k*q+m*u+n*c;return this},premultiply:function(a){var b=a.matrix[0]*this.matrix[1]+a.matrix[1]*this.matrix[4]+a.matrix[2]*this.matrix[7],c=a.matrix[0]*this.matrix[2]+a.matrix[1]*this.matrix[5]+a.matrix[2]*this.matrix[8],d=a.matrix[3]*this.matrix[0]+a.matrix[4]*this.matrix[3]+a.matrix[5]*this.matrix[6],e=a.matrix[3]*this.matrix[1]+a.matrix[4]*this.matrix[4]+a.matrix[5]*this.matrix[7],f=a.matrix[3]*this.matrix[2]+ +a.matrix[4]*this.matrix[5]+a.matrix[5]*this.matrix[8],g=a.matrix[6]*this.matrix[0]+a.matrix[7]*this.matrix[3]+a.matrix[8]*this.matrix[6],h=a.matrix[6]*this.matrix[1]+a.matrix[7]*this.matrix[4]+a.matrix[8]*this.matrix[7],k=a.matrix[6]*this.matrix[2]+a.matrix[7]*this.matrix[5]+a.matrix[8]*this.matrix[8];this.matrix[0]=a.matrix[0]*this.matrix[0]+a.matrix[1]*this.matrix[3]+a.matrix[2]*this.matrix[6];this.matrix[1]=b;this.matrix[2]=c;this.matrix[3]=d;this.matrix[4]=e;this.matrix[5]=f;this.matrix[6]=g; +this.matrix[7]=h;this.matrix[8]=k;return this},getInverse:function(a){var b=this.matrix,c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],k=b[6],m=b[7],b=b[8];a=a||new CAAT.Math.Matrix;var n=c*(g*b-m*h)-f*(d*b-m*e)+k*(d*h-g*e);if(0===n)return null;var p=a.matrix;p[0]=g*b-h*m;p[1]=e*m-d*b;p[2]=d*h-e*g;p[3]=h*k-f*b;p[4]=c*b-e*k;p[5]=e*f-c*h;p[6]=f*m-g*k;p[7]=d*k-c*m;p[8]=c*g-d*f;a.multiplyScalar(1/n);return a},multiplyScalar:function(a){var b;for(b=0;9>b;b++)this.matrix[b]*=a;return this},transformRenderingContextSet_NoClamp:function(a){var b= +this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2],b[5]);return this},transformRenderingContext_NoClamp:function(a){var b=this.matrix;a.transform(b[0],b[3],b[1],b[4],b[2],b[5]);return this},transformRenderingContextSet_Clamp:function(a){var b=this.matrix;a.setTransform(b[0],b[3],b[1],b[4],b[2]>>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,k,m,n;n= +this.matrix;d=1;m=g=0;k=1;c=Math.cos(e);e=Math.sin(e);f=d;h=m;d=(f*c+g*e)*this.scaleX;g=(-f*e+g*c)*this.scaleY;m=(h*c+k*e)*this.scaleX;k=(-h*e+k*c)*this.scaleY;n[0]=d;n[1]=g;n[2]=a;n[3]=m;n[4]=k;n[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}}}}); +d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,k){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]=k;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;4>a;a++)for(var b=0;4>b;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){a=this.rotate(a,b,c);this.copy(a);return this},rotate:function(a, +b,c){var d=new CAAT.Math.Matrix3,e,f;0!==a&&(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));0!==b&&(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));0!==c&&(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],k=b[1][2],m=b[1][3],n=b[2][0],p=b[2][1],r=b[2][2],b=b[2][3],q=a.matrix;a=q[0][0];var s=q[0][1],t=q[0][2],u=q[0][3],x=q[1][0],w=q[1][1],v=q[1][2],z=q[1][3],y=q[2][0],A=q[2][1],B=q[2][2],C=q[2][3],D=q[3][0],E=q[3][1],F=q[3][2],q=q[3][3];this.matrix[0][0]=c*a+d*x+e*y+f*D;this.matrix[0][1]=c*s+d*w+e*A+f*E;this.matrix[0][2]=c*t+d*v+e*B+f*F;this.matrix[0][3]= +c*u+d*z+e*C+f*q;this.matrix[1][0]=g*a+h*x+k*y+m*D;this.matrix[1][1]=g*s+h*w+k*A+m*E;this.matrix[1][2]=g*t+h*v+k*B+m*F;this.matrix[1][3]=g*u+h*z+k*C+m*q;this.matrix[2][0]=n*a+p*x+r*y+b*D;this.matrix[2][1]=n*s+p*w+r*A+b*E;this.matrix[2][2]=n*t+p*v+r*B+b*F;this.matrix[2][3]=n*u+p*z+r*C+b*q;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],k=b[1][2],m=b[1][3],n=b[2][0],p=b[2][1],r=b[2][2],b=b[2][3],q=a.matrix;a=q[0][0];var s= +q[0][1],t=q[0][2],u=q[0][3],x=q[1][0],w=q[1][1],v=q[1][2],z=q[1][3],y=q[2][0],A=q[2][1],B=q[2][2],q=q[2][3];this.matrix[0][0]=c*a+d*x+e*y;this.matrix[0][1]=c*s+d*w+e*A;this.matrix[0][2]=c*t+d*v+e*B;this.matrix[0][3]=c*u+d*z+e*q+f;this.matrix[1][0]=g*a+h*x+k*y;this.matrix[1][1]=g*s+h*w+k*A;this.matrix[1][2]=g*t+h*v+k*B;this.matrix[1][3]=g*u+h*z+k*q+m;this.matrix[2][0]=n*a+p*x+r*y;this.matrix[2][1]=n*s+p*w+r*A;this.matrix[2][2]=n*t+p*v+r*B;this.matrix[2][3]=n*u+p*z+r*q+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;4>b;b++)for(var c=0;4>c;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],k=a[1][3],m=a[2][0],n=a[2][1],p=a[2][2],r=a[2][3],q=a[3][0],s=a[3][1],t=a[3][2],a=a[3][3];return e*g*p*q+c*k*p*q+e*h*m*s+d*k*m*s+d*f*r*s+b*h*r*s+e*f*n*t+b*k*n*t+d*g*m*a+c*h*m*a+c*f*p*a+b*g*p*a+e*h*n*q-d*k*n*q-d*g*r*q-c*h*r*q-e*f*p*s-b*k*p*s-e*g*m*t-c*k*m*t-c*f*r*t-b*g*r*t-d*f*n*a-b*h*n*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],k=a[1][3],m=a[2][0],n=a[2][1],p= +a[2][2],r=a[2][3],q=a[3][0],s=a[3][1],t=a[3][2],a=a[3][3],u=new CAAT.Math.Matrix3;u.matrix[0][0]=h*r*s+k*n*t+g*p*a-k*p*s-g*r*t-h*n*a;u.matrix[0][1]=e*p*s+c*r*t+d*n*a-c*p*a-d*r*s-e*n*t;u.matrix[0][2]=d*k*s+c*h*a+e*g*t-c*k*t-d*g*a-e*h*s;u.matrix[0][3]=e*h*n+c*k*p+d*g*r-d*k*n-e*g*p-c*h*r;u.matrix[1][0]=k*p*q+f*r*t+h*m*a-h*r*q-k*m*t-f*p*a;u.matrix[1][1]=d*r*q+e*m*t+b*p*a-e*p*q-b*r*t-d*m*a;u.matrix[1][2]=e*h*q+b*k*t+d*f*a-d*k*q-e*f*t-b*h*a;u.matrix[1][3]=d*k*m+e*f*p+b*h*r-e*h*m-b*k*p-d*f*r;u.matrix[2][0]= +g*r*q+k*m*s+f*n*a-k*n*q-f*r*s-g*m*a;u.matrix[2][1]=e*n*q+b*r*s+c*m*a-b*n*a-c*r*q-e*m*s;u.matrix[2][2]=d*k*q+e*f*s+b*g*a-e*g*q-b*k*s-c*f*a;u.matrix[2][3]=e*g*m+b*k*n+c*f*r-b*g*r-c*k*m-e*f*n;u.matrix[3][0]=h*n*q+f*p*s+g*m*t-g*p*q-h*m*s-f*n*t;u.matrix[3][1]=c*p*q+d*m*s+b*n*t-d*n*q-b*p*s-c*m*t;u.matrix[3][2]=d*g*q+b*h*s+c*f*t-b*g*t-c*h*q-d*f*s;u.matrix[3][3]=c*h*m+d*f*n+b*g*p-d*g*m-b*h*n-c*f*p;return u.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;4>b;b++)for(c= +0;4>c;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-1a*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 0.005>a&&-0.005a&&-0.005=this.x&&a=this.y&&bthis.y1&&(this.y1=b), +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()||a.x1<=this.x||a.x>=this.x1||a.y1<=this.y?!1:a.ythis.x1||b+d-1c?2*c:1-2*(c-0.5));null!==b&&b&&(c=1-c);return this.interpolated.set(d,c)};return this},createBackOutInterpolator:function(a){this.getPosition=function(b){var c=b;a&&(b=0.5>b?2*b:1-2*(b-0.5));b-=1;return this.interpolated.set(c,b*b*(2.70158*b+1.70158)+1)};return this},createExponentialInInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return this.interpolated.set(d,Math.pow(c,a))};return this},createExponentialOutInterpolator:function(a,b){this.getPosition= +function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return this.interpolated.set(d,1-Math.pow(1-c,a))};return this},createExponentialInOutInterpolator:function(a,b){this.getPosition=function(c){var d=c;b&&(c=0.5>c?2*c:1-2*(c-0.5));return 1>2*c?this.interpolated.set(d,Math.pow(2*c,a)/2):this.interpolated.set(d,1-Math.abs(Math.pow(2*c-2,a))/2)};return this},createQuadricBezierInterpolator:function(a,b,c,d){this.getPosition=function(e){var f=e;d&&(e=0.5>e?2*e:1-2*(e-0.5));e=(1-e)*(1-e)*a.y+2*(1-e)*e*b.y+ +e*e*c.y;return this.interpolated.set(f,e)};return this},createCubicBezierInterpolator:function(a,b,c,d,e){this.getPosition=function(f){var g=f;e&&(f=0.5>f?2*f:1-2*(f-0.5));var h=f*f;f=a.y+f*(3*-a.y+f*(3*a.y-a.y*f))+f*(3*b.y+f*(-6*b.y+3*b.y*f))+h*(3*c.y-3*c.y*f)+d.y*f*h;return this.interpolated.set(g,f)};return this},createElasticOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));if(0===d)return{x:0,y:0};if(1===d)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/ +a);return this.interpolated.set(d,a*Math.pow(2,-10*d)*Math.sin(2*(d-e)*Math.PI/b)+1)};return this},createElasticInInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));if(0===d)return{x:0,y:0};if(1===d)return{x:1,y:1};var e=b/(2*Math.PI)*Math.asin(1/a);return this.interpolated.set(d,-(a*Math.pow(2,10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b)))};return this},createElasticInOutInterpolator:function(a,b,c){this.getPosition=function(d){c&&(d=0.5>d?2*d:1-2*(d-0.5));var e=b/(2* +Math.PI)*Math.asin(1/a);d*=2;return 1>=d?this.interpolated.set(d,-0.5*a*Math.pow(2,10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b)):this.interpolated.set(d,1+0.5*a*Math.pow(2,-10*(d-=1))*Math.sin(2*(d-e)*Math.PI/b))};return this},bounce:function(a){return(a/=1)<1/2.75?{x:a,y:7.5625*a*a}:a<2/2.75?{x:a,y:7.5625*(a-=1.5/2.75)*a+0.75}:a<2.5/2.75?{x:a,y:7.5625*(a-=2.25/2.75)*a+0.9375}:{x:a,y:7.5625*(a-=2.625/2.75)*a+0.984375}},createBounceOutInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b: +1-2*(b-0.5));return this.bounce(b)};return this},createBounceInInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b:1-2*(b-0.5));b=this.bounce(1-b);b.y=1-b.y;return b};return this},createBounceInOutInterpolator:function(a){this.getPosition=function(b){a&&(b=0.5>b?2*b:1-2*(b-0.5));if(0.5>b)return b=this.bounce(1-2*b),b.y=0.5*(1-b.y),b;b=this.bounce(2*b-1,a);b.y=0.5*b.y+0.5;return b};return this},paint:function(a){a.save();a.beginPath();a.moveTo(0,this.getPosition(0).y*this.paintScale); for(var b=0;b<=this.paintScale;b++)a.lineTo(b,this.getPosition(b/this.paintScale).y*this.paintScale);a.strokeStyle="black";a.stroke();a.restore()},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.Behavior.BaseBehavior",constants:{Status:{NOT_STARTED:0,STARTED:1,EXPIRED:2},parse:function(a){function b(a){for(var a=a.split("."),b=window,c=0;c=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;ethis.behaviorStartTime)return!1;this.cycleBehavior&&a>=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),!1;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>=0;var d="@-"+ +a+"-keyframes "+b+" {";for(a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;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}}}}); +c=c.getKeyFrameDataValues(d);for(var f in c)e[f]=c[f]}return e},calculateKeyFrameData:function(a,b){function c(a){f[a]?h+=f[a]:prevValues&&(k=prevValues[a])&&(h+=k,f[a]=k)}var d,e,f={},g;for(d=0;d=g&&(g=(g-e.behaviorStartTime)/e.behaviorDuration,g=e.calculateKeyFrameData(g), +e=e.getPropertyName(b),"undefined"===typeof f[e]&&(f[e]=""),f[e]+=g+" "));var h="",k;c("translate");c("rotate");c("scale");d="";h&&(d="-"+b+"-transform: "+h+";");h="";c("opacity");h&&(d+=" opacity: "+h+";");return{rules:d+" -webkit-transform-origin: 0% 0%",ret:f}},calculateKeyFramesData:function(a,b,c,d,e){if(this.duration===Number.MAX_VALUE)return"";"undefined"===typeof d&&(d=0.5);"undefined"===typeof e&&(e=0.5);"undefined"===typeof c&&(c=100);var f="@-"+a+"-keyframes "+b+" {",g,h={};for(b=0;b<= +c;b++){g=this.interpolator.getPosition(b/c).y;g=this.getKeyFrameDataValues(g);var k=""+b/c*100+"%{",m=g,n=void 0;for(n in h)m[n]||(m[n]=h[n]);h="-"+a+"-transform:";if(m.x||m.y)h+="translate("+(m.x||0)+"px,"+(m.y||0)+"px)";m.angle&&(h+=" rotate("+m.angle+"rad)");if(1!==m.scaleX||1!==m.scaleY)h+=" scale("+m.scaleX+","+m.scaleY+")";h+=";";m.alpha&&(h+=" opacity: "+m.alpha+";");if(0.5!==d||0.5!==e)h+=" -"+a+"-transform-origin:"+100*d+"% "+100*e+"%;";f+=k+h+"}\n";h=g}return f+"}\n"}}}}); 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= +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);if(a.SVG){var b=(new CAAT.PathUtil.SVGPath).parsePath(a.SVG);this.setValues(b)}a.autoRotate&&(this.autoRotate= +a.autoRotate)},path:null,autoRotate:!1,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,isOpenContour:!1,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=!0;return this},setAutoRotate:function(a,b){this.autoRotate=a;void 0!==b&&(this.autoRotateOp=b);return this},setPath:function(a){this.path=a;return this},setValues:function(a){return this.setPath(a)}, +setTranslation:function(a,b){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){a=this.interpolator.getPosition(a).y;var b=this.path.getPosition(a),c={x:b.x,y:b.y};this.autoRotate&&(a=0===a?b:this.path.getPosition(a-0.001),b=Math.atan2(b.y-a.y,b.x-a.x),c.angle=b);return c},calculateKeyFramesData:function(a,b,c){"undefined"===typeof c&&(c=100);c>>=0;var d, +e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"}",e+=d;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.001);this.isRelative&&(c.x+=this.relativeX,c.y+=this.relativeY);if(this.autoRotate){-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(0===d&&0===e)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.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="undefined"!==typeof a.anchorX?parseInt(a.anchorX): +0.5;this.anchorY="undefined"!==typeof a.anchorY?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=!0;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;"undefined"!==typeof c&&"undefined"!==typeof d&&(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){"undefined"===typeof c&&(c=100);c>>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); +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:!0,parse:function(a){CAAT.Behavior.Scale1Behavior.superclass.parse.call(this,a);this.startScale= +a.start||0;this.endScale=a.end||0;this.anchorX="undefined"!==typeof a.anchorX?parseInt(a.anchorX):0.5;this.anchorY="undefined"!==typeof a.anchorY?parseInt(a.anchorY):0.5;this.applyOnX=a.axis?"x"===a.axis.toLowerCase():!0},applyOnAxis:function(a){this.applyOnX=a===CAAT.Behavior.Scale1Behavior.AXIS.X?!1:!0},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;"undefined"!==typeof d&&"undefined"!==typeof e&&(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){a=this.interpolator.getPosition(a).y;var b={};b[this.applyOnX?"scaleX":"scaleY"]=this.startScale+a*(this.endScale-this.startScale);return b},calculateKeyFramesData:function(a,b,c){"undefined"===typeof c&&(c=100);c>>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); 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;b>=0;var d,e="@-"+a+"-keyframes "+b+" {";for(b=0;b<=c;b++)d=""+b/c*100+"%{-"+a+"-transform:"+this.calculateKeyFrameData(b/c)+"; -"+a+"-transform-origin:"+100*this.anchorX+ +"% "+100*this.anchorY+"% }\n",e+=d;return e+"}\n"}}}}); +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
', +CAAT.Module({defines:"CAAT.Module.Audio.AudioManager",extendsWith:function(){return{__init:function(){this.isFirefox=null!==navigator.userAgent.match(/Firefox/g);return this},isFirefox:!1,musicChannel:null,musicEnabled:!0,fxEnabled:!0,audioCache:null,channels:null,workingChannels:null,loopingChannels:[],audioFormatExtensions:["ogg","wav","x-wav","mp3"],currentAudioFormatExtension:"ogg",audioTypes:{ogg:"audio/ogg",mp3:"audio/mpeg;",wav:"audio/wav","x-wav":"audio/x-wav",mp4:'audio/mp4"'},initialize:function(a){this.setAudioFormatExtensions(this.audioFormatExtensions); +this.audioCache=[];this.channels=[];this.workingChannels=[];for(var b=0;b<=a;b++){var c=document.createElement("audio");if(null!==c){c.finished=-1;this.channels.push(c);var d=this;c.addEventListener("ended",function(a){a=a.target;var b;for(b=0;bb&&(console.log("Audio w/o extension: "+a),b=a.length()-1);return a.substring(0,b+1)+this.currentAudioFormatExtension},addAudioFromURL:function(a,b,c){var d=document.createElement("audio");return null!==d?(d.src=this.__getAudioUrl(b),console.log("Loading audio: "+d.src),d.preload="auto",d.load(),c&&(d.caat_callback=c,d.caat_id=a),this.audioCache.push({id:a,audio:d}),!0):!1},addAudioFromDomNode:function(a,b,c){var d=b.src.substr(b.src.lastIndexOf(".")+1);return b.canPlayType(this.audioTypes[d])? +(c&&(b.caat_callback=c,b.caat_id=a),this.audioCache.push({id:a,audio:b}),!0):!1},addAudioElement:function(a,b,c){if("string"===typeof b)return this.addAudioFromURL(a,b,c);try{if(b instanceof HTMLAudioElement)return this.addAudioFromDomNode(a,b,c)}catch(d){}return!1},addAudio:function(a,b,c){if(b instanceof Array)for(var d=0;d=h)return{r:a,g:b,b:c};if(h>=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;255a&&(a=0);255b&&(b=0);255c&&(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,k,m,n,p,r,q,s,t,u,x,w;for(f=0;f>24&255,q=(p&16711680)>>16,s=(p&65280)>>8,p&=255,g=a[f+1],t=g>>24&255,u=(g&16711680)>>16,x=(g&65280)>>8,g&=255,t=(t-r)/b,u=(u-q)/b,x=(x-s)/b,w=(g-p)/b,g=0;g>0;k=q+u*g>>0;m=s+x*g>>0;n=p+w*g>>0;var v=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case v.RAMP_RGBA:d.push("argb("+h+","+k+","+m+","+n+")");break;case v.RAMP_RGB:d.push("rgb("+k+","+m+","+n+")");break;case v.RAMP_CHANNEL_RGB:d.push(4278190080| +k<<16|m<<8|n);break;case v.RAMP_CHANNEL_RGBA:d.push(h<<24|k<<16|m<<8|n);break;case v.RAMP_CHANNEL_RGBA_ARRAY:d.push([k,m,n,h]);break;case v.RAMP_CHANNEL_RGB_ARRAY:d.push([k,m,n])}}return d},random:function(){for(var a="#",b=0;3>b;b++)a+="0123456789abcdef"[16*Math.random()>>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:!1,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= +document.getElementById("caat-debug-canvas");if(null===this.canvas)this.canDebug=!1;else return this.canvas.width=a,this.canvas.height=b,this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#000",this.ctx.fillRect(0,0,this.width,this.height),this.textFPS=document.getElementById("textFPS"),this.textDrawTime=document.getElementById("textDrawTime"),this.textRAFTime=document.getElementById("textRAFTime"),this.textEntitiesTotal=document.getElementById("textEntitiesTotal"),this.textEntitiesActive= +document.getElementById("textEntitiesActive"),this.textDraws=document.getElementById("textDraws"),this.textDirtyRects=document.getElementById("textDirtyRects"),this.textDiscardDR=document.getElementById("textDiscardDR"),this.canDebug=!0,this},debugInfo:function(a){this.statistics=a;a=CAAT;this.frameTimeAcc+=a.FRAME_TIME;this.frameRAFAcc+=a.REQUEST_ANIMATION_FRAME_TIME;this.framerate.frames++;a=(new Date).getTime();if(a>this.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps= +1E3*this.framerate.frames/(a-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=0>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= +"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);-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.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){a=/(\d+)p[x|t]\s*/i.exec(a);var b;b=a?a[1]|0:32;a=b-1;b=b+0.2*b|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=9===d.nodeType?d.defaultView||d.parentWindow:!1;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;128>c;c++)b+=String.fromCharCode(c);return this.create(b,a)}, +create:function(a,b){this.padding=b|=0;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(k);e+=k}g=CAAT.Font.getFontMetrics(d.font);d=g.height;this.ascent=g.ascent;this.descent=g.descent;this.height=g.height;k=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;gthis.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= +CAAT.Module({defines:"CAAT.Module.CircleManager.PackedCircleManager",depends:["CAAT.Math.Point","CAAT.Math.Rectangle"],extendsWith:{__init:function(){this.bounds=new CAAT.Math.Rectangle},allCircles:[],numberOfCollisionPasses:1,numberOfTargetingPasses:0,bounds:null,addCircle:function(a){a.id=this.allCircles.length;this.allCircles.push(a);return this},removeCircle:function(a){var b=0,c=!1,d=this.allCircles.length;if(0===d)throw"Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!"; +for(;d--;)if(this.allCircles[d]===a){c=!0;b=d;break}if(!c)throw"Could not locate circle in allCircles array!";this.allCircles[b].dealloc();this.allCircles[b]=null;return this},forceCirclesToMatchDelegatePositions:function(){for(var a=this.allCircles.length,b=0;bthis.bounds.right?a.position.x=this.bounds.left+e:b&1&&c+fthis.bounds.bottom?a.position.y=this.bounds.top-e:b&4&&d+f=this.bounds.right?a.position.x=a.position.x=this.bounds.right-e:b&8&&c-ethis.bounds.bottom?a.position.y=this.bounds.bottom-e:b&16&&d-ed?e=-1:c>=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;var d=!0,e=!0,f=!0,g=!0;"undefined"!==typeof c&& +("undefined"!==typeof c.top&&(d=c.top),"undefined"!==typeof c.bottom&&(e=c.bottom),"undefined"!==typeof c.left&&(f=c.left),"undefined"!==typeof c.right&&(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 k=h.getImageData(0,0,a.width,a.height).data,m;a=0;var n=c.height-1,p=0,r=c.width-1,q=!1;if(d){for(d=0;db){q=!0;break}if(q)break}a=d}if(e){q=!1;for(d=c.height-1;d>=a;d--){for(m=0;mb){q=!0;break}if(q)break}n=d}if(f){q=!1;for(m=0;mb){q=!0;break}if(q)break}p=m}if(g){q=!1;for(m=c.width-1;m>=p;m--){for(d=a;d<=n;d++)if(k[d*c.width*4+3+4*m]>b){q=!0;break}if(q)break}r=m}if(0===p&&0===a&&c.width-1===r&&c.height-1===n)return c;b=r-p+1;e=n-a+1;f=h.getImageData(p,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){b=b||24;c=c||24;var 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){"undefined"===typeof f&&(f=32);"undefined"===typeof g&&(g=1);var h=(a+c)/2,k=(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,k,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,k,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,k,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,k,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;cb;b++){if(this.quadData[b].intersects(a))for(f=this.quadData[b].getOverlappingActors(a),c=0,d=f.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];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;bc&&(c=100);100>d&&(d=100);this.width=c;this.height=d;this.createFromImages(this.images)},createFromImages:function(a){var b;this.scan=new CAAT.Module.TexturePacker.TextureScanMap(this.width,this.height);this.images=[];if(this.allowImagesInvertion)for(b=0;bb.width?-1:0:"height"===c.criteria?a.heightb.height?-1:0: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.Module.Initialization.Template",depends:["CAAT.Foundation.Director","CAAT.Module.Preloader.ImagePreloader"],constants:{init:function(a,b,c,d,e){c=document.getElementById(c);var f;if(CAAT.__CSS__)c&&!1===c instanceof HTMLDivElement&&(c=null),null===c&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var g=document.createElement("canvas");c.appendChild(g);c=g}else!1==c instanceof HTMLCanvasElement&&(g=document.createElement("canvas"), +document.body.appendChild(g),c=g);else c=document.createElement("canvas"),document.body.appendChild(c);f=(new CAAT.Foundation.Director).initialize(a||800,b||600,c);(new CAAT.Module.Preloader.ImagePreloader).loadImages(d,function(a,b){a===b.length&&(f.emptyScenes(),f.setImagesCache(b),e(f),f.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,!1,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5,0.4)),CAAT.loop(60))})}}}); +CAAT.Module({defines:"CAAT.Module.Initialization.TemplateWithSplash",depends:["CAAT.Foundation.Director","CAAT.Module.Preloader.ImagePreloader"],constants:{init:function(a,b,c,d,e,f,g,h){function k(a,b,c){var d=a.getImage("spinner"),e=a.getImage("splash"),g=a.createScene(),f=(new Date).getTime();e&&g.addChild((new CAAT.Foundation.Actor).setBackgroundImage(e,!1).setBounds(0,0,a.width,a.height).setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE));d&&g.addChild((new CAAT.Foundation.Actor).setBackgroundImage(d).centerAt(g.width/ +2,g.height/2).addBehavior((new CAAT.Behavior.RotateBehavior).setValues(0,2*Math.PI).setFrameTime(0,1E3).setCycle(!0)));g.loadedImage=function(d,e){if(!e||d===e.length){var g=(new Date).getTime()-f;gb&&(g=b),setTimeout(function(){m(a,e,c)},g)):m(a,e,c)}};return g}function m(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(!0);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,!1,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, +0.4))}c=document.getElementById(c);var n;if(CAAT.__CSS__)c&&!1===c instanceof HTMLDivElement&&(c=null),null===c&&(c=document.createElement("div"),document.body.appendChild(c));else if(c)if(c instanceof HTMLDivElement){var p=document.createElement("canvas");c.appendChild(p);c=p}else!1==c instanceof HTMLCanvasElement&&(p=document.createElement("canvas"),document.body.appendChild(p),c=p);else c=document.createElement("canvas"),document.body.appendChild(c);n=(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});n.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){n.setImagesCache(b);var c=k(n,d||5E3,f);CAAT.loop(60);e&&0=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(); +function(a){var b=a.name,c=a.behavior,d=a.size,e=a.overwrite;if("undefined"===typeof b||"undefined"===typeof c)throw"Keyframes must be defined by a name and a CAAT.Behavior instance.";"undefined"===typeof d&&(d=100);"undefined"===typeof e&&(e=!1);var f=CAAT.CSS.getCSSKeyframesIndex(b);if(null===f||e)return a=c.calculateKeyFramesData(CAAT.CSS.PREFIX,b,d,a.anchorX,a.anchorY),document.styleSheets&&(document.styleSheets.length||(b=document.createElement("style"),b.type="text/css",document.getElementsByTagName("head")[0].appendChild(b)), +null!==f&&document.styleSheets[f.sheetIndex].deleteRule(f.index),document.styleSheets[f?f.sheetIndex:0].insertRule(a,0)),a};CAAT.CSS.getCSSKeyframesIndex=function(a){for(var b=document.styleSheets,c=b.length-1;0<=c;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;0<=f;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;0<=c;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;0<=f;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){a&&(this.color=a);return this},endCurvePosition:function(){},startCurvePosition:function(){},setPoints:function(a){},setPoint:function(a,b){},getPosition:function(a){}, +getLength:function(){return this.length},getBoundingBox:function(){return this.bbox},numControlPoints:function(){},getControlPoint:function(a){},endPath:function(){},getContour:function(a){},updatePath:function(a){},applyAsPath:function(a){},transform:function(a){},drawHandle:function(a,b,c){a.beginPath();a.arc(b,c,CAAT.Math.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,!1);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:!0,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:!1,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){0<=b&& +ba)a%=1;0>a&&(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, +b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.Math.Bezier;g.setQuadric(a,b,c,d,e,f);this.curve=g;this.updatePath();return this},setCubic:function(a,b,c,d,e,f,g,h){var k=new CAAT.Math.Bezier;k.setCubic(a,b,c,d,e,f,g,h);this.curve=k;this.updatePath();return this},updatePath:function(a){this.curve.update();this.length=this.curve.getLength();this.curve.getBoundingBox(this.bbox);return this},getPosition:function(a){if(1a)a%=1;0>a&&(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}}}}); +b){0===b?this.points[0]=a:1===b&&(this.points[1]=a)},updatePath:function(a){a=this.points[1].x-this.points[0].x;var 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(1a)a%=1;0>a&&(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();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]; +if(1===a)return this.points[1]},getContour:function(a){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(;fa)a%=1; +0>a&&(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(;fa;a++)this.bbox.union(this.points[a].x,this.points[a].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(a){return this.getPosition(a/(2*this.bbox.width+2*this.bbox.height))}}}}); +CAAT.Module({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".split(" "),extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:{__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},pathSegments:null,pathSegmentDurationTime:null,pathSegmentStartTime:null,newPosition:null,pathLength:-1,beginPathX:-1,beginPathY:-1,trackPathX:-1,trackPathY:-1,ax:-1,ay:-1,point:[],interactive:!0,behaviorList:null,rb_angle:0,rb_rotateAnchorX:0.5,rb_rotateAnchorY:0.5,sb_scaleX:1,sb_scaleY:1,sb_scaleAnchorX:0.5,sb_scaleAnchorY:0.5,tAnchorX:0,tAnchorY:0,tb_x:0,tb_y:0,matrix:null,tmpMatrix:null,pathPoints:null,width:0,height:0,clipOffsetX:0,clipOffsetY:0,closed:!1,applyAsPath:function(a){var b= a.ctx;a.modelViewMatrix.transformRenderingContext(b);b.globalCompositeOperation="source-out";b.moveTo(this.getFirstPathSegment().startCurvePosition().x,this.getFirstPathSegment().startCurvePosition().y);for(var c=0;c=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=a)){var c,d,e;1<=a?(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.001),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(1a)a%=1;0>a&&(a=1+a);for(var b=this.pathSegments,c=this.pathSegmentStartTime,d=this.pathSegmentDurationTime,e=0,f=b.length,g,h=this.newPosition,k;e!==f;){g=(f+e)/2|0;k=c[g];if(k<=a&&a<=k+d[g])return a=d[g]?(a-k)/d[g]:0,1a&&(a=0),a=b[g].getPosition(a),h.x=a.x,h.y=a.y,h;aa&&(a+=this.getLength());for(var b=0,c=0;c=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(cd&&(d=0);console.log("parse error near ..."+a.substr(d,20))}return{__init:function(){},c:0,bezierInfo:null,__skipBlank:function(a,c){for(var d=a.charAt(c);c=a},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(ca;a++)b[a]=a;this.linesBufferArray=new Uint16Array(b);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,this.linesBufferArray,this.gl.DYNAMIC_DRAW);this.shaderProgram.vertexPositionAttribute=this.gl.getAttribLocation(this.shaderProgram,"aVertexPosition");this.gl.enableVertexAttribArray(this.shaderProgram.vertexPositionAttribute); this.shaderProgram.textureCoordAttribute=this.gl.getAttribLocation(this.shaderProgram,"aTextureCoord");this.gl.enableVertexAttribArray(this.shaderProgram.textureCoordAttribute);this.shaderProgram.pMatrixUniform=this.gl.getUniformLocation(this.shaderProgram,"uPMatrix");this.shaderProgram.samplerUniform=this.gl.getUniformLocation(this.shaderProgram,"uSampler");this.shaderProgram.alphaUniform=this.gl.getUniformLocation(this.shaderProgram,"alpha");this.shaderProgram.useColor=this.gl.getUniformLocation(this.shaderProgram, -"uUseColor");this.shaderProgram.color=this.gl.getUniformLocation(this.shaderProgram,"uColor");this.setAlpha(1);this.setUseColor(false);this.vertexPositionBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexPositionBuffer);this.vertexPositionArray=new Float32Array(49152);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexPositionArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute,3,this.gl.FLOAT,false,0,0);this.vertexUVBuffer= -this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexUVBuffer);this.vertexUVArray=new Float32Array(32768);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexUVArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.textureCoordAttribute,2,this.gl.FLOAT,false,0,0);this.vertexIndexBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);b=[];for(a=0;a<4096;a++)b.push(0+a*4),b.push(1+a*4),b.push(2+a*4),b.push(0+a*4), -b.push(2+a*4),b.push(3+a*4);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(b),this.gl.DYNAMIC_DRAW);return CAAT.TextureProgram.superclass.initialize.call(this)},setUseColor:function(a,b,c,d,e){this.gl.uniform1i(this.shaderProgram.useColor,a?1:0);if(a&&(this.prevA!==e||this.prevR!==b||this.prevG!==c||this.prevB!==d))this.gl.uniform4f(this.shaderProgram.color,b,c,d,e),this.prevA=e,this.prevR=b,this.prevG=c,this.prevB=d},setTexture:function(a){if(this.prevTexture!==a){var b=this.gl; -b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,a);b.uniform1i(this.shaderProgram.samplerUniform,0);this.prevTexture=a}return this},updateVertexBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexPositionBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},updateUVBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexUVBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},setAlpha:function(a){if(this.prevAlpha!==a)this.gl.uniform1f(this.shaderProgram.alphaUniform, -a),this.prevAlpha=a;return this},drawLines:function(a,b,c,d,e,f,g){var h=this.gl;this.setAlpha(f);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.updateVertexBuffer(a);this.setUseColor(true,c,d,e,1);h.drawElements(h.LINES,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(false);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)},drawPolylines:function(a,b,c,d,e,f,g){var h=this.gl;h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.setAlpha(f); -this.updateVertexBuffer(a);this.setUseColor(true,c,d,e,1);h.drawElements(h.LINE_STRIP,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(false);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)}}});CAAT.Module({defines:"CAAT.Event.TouchInfo",aliases:["CAAT.TouchInfo"],extendsWith:{__init:function(a,b,c,d){this.identifier=a;this.pageX=this.clientX=b;this.pageY=this.clientY=c;this.target=d;this.time=(new Date).getTime();return this}}}); -CAAT.Module({defines:"CAAT.Event.TouchEvent",aliases:["CAAT.TouchEvent"],depends:["CAAT.Event.TouchInfo"],extendsWith:{__init:function(){this.touches=[];this.changedTouches=[];return this},time:0,source:null,sourceEvent:null,shift:false,control:false,alt:false,meta:false,touches:null,changedTouches:null,init:function(a,b,c){this.source=b;this.alt=a.altKey;this.control=a.ctrlKey;this.shift=a.shiftKey;this.meta=a.metaKey;this.sourceEvent=a;this.time=c;return this},addTouch:function(a){-1===this.touches.indexOf(a)&& +"uUseColor");this.shaderProgram.color=this.gl.getUniformLocation(this.shaderProgram,"uColor");this.setAlpha(1);this.setUseColor(!1);this.vertexPositionBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexPositionBuffer);this.vertexPositionArray=new Float32Array(49152);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexPositionArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.vertexPositionAttribute,3,this.gl.FLOAT,!1,0,0);this.vertexUVBuffer=this.gl.createBuffer(); +this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.vertexUVBuffer);this.vertexUVArray=new Float32Array(32768);this.gl.bufferData(this.gl.ARRAY_BUFFER,this.vertexUVArray,this.gl.DYNAMIC_DRAW);this.gl.vertexAttribPointer(this.shaderProgram.textureCoordAttribute,2,this.gl.FLOAT,!1,0,0);this.vertexIndexBuffer=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer);b=[];for(a=0;4096>a;a++)b.push(0+4*a),b.push(1+4*a),b.push(2+4*a),b.push(0+4*a),b.push(2+4*a),b.push(3+4* +a);this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(b),this.gl.DYNAMIC_DRAW);return CAAT.TextureProgram.superclass.initialize.call(this)},setUseColor:function(a,b,c,d,e){this.gl.uniform1i(this.shaderProgram.useColor,a?1:0);!a||this.prevA===e&&this.prevR===b&&this.prevG===c&&this.prevB===d||(this.gl.uniform4f(this.shaderProgram.color,b,c,d,e),this.prevA=e,this.prevR=b,this.prevG=c,this.prevB=d)},setTexture:function(a){if(this.prevTexture!==a){var b=this.gl;b.activeTexture(b.TEXTURE0); +b.bindTexture(b.TEXTURE_2D,a);b.uniform1i(this.shaderProgram.samplerUniform,0);this.prevTexture=a}return this},updateVertexBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexPositionBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},updateUVBuffer:function(a){var b=this.gl;b.bindBuffer(b.ARRAY_BUFFER,this.vertexUVBuffer);b.bufferSubData(b.ARRAY_BUFFER,0,a);return this},setAlpha:function(a){this.prevAlpha!==a&&(this.gl.uniform1f(this.shaderProgram.alphaUniform,a),this.prevAlpha= +a);return this},drawLines:function(a,b,c,d,e,f,g){var h=this.gl;this.setAlpha(f);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.updateVertexBuffer(a);this.setUseColor(!0,c,d,e,1);h.drawElements(h.LINES,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(!1);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)},drawPolylines:function(a,b,c,d,e,f,g){var h=this.gl;h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.linesBuffer);h.lineWidth(g);this.setAlpha(f);this.updateVertexBuffer(a); +this.setUseColor(!0,c,d,e,1);h.drawElements(h.LINE_STRIP,b,h.UNSIGNED_SHORT,0);this.setAlpha(1);this.setUseColor(!1);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,this.vertexIndexBuffer)}}});CAAT.Module({defines:"CAAT.Event.TouchInfo",aliases:["CAAT.TouchInfo"],extendsWith:{__init:function(a,b,c,d){this.identifier=a;this.pageX=this.clientX=b;this.pageY=this.clientY=c;this.target=d;this.time=(new Date).getTime();return this}}}); +CAAT.Module({defines:"CAAT.Event.TouchEvent",aliases:["CAAT.TouchEvent"],depends:["CAAT.Event.TouchInfo"],extendsWith:{__init:function(){this.touches=[];this.changedTouches=[];return this},time:0,source:null,sourceEvent:null,shift:!1,control:!1,alt:!1,meta:!1,touches:null,changedTouches:null,init:function(a,b,c){this.source=b;this.alt=a.altKey;this.control=a.ctrlKey;this.shift=a.shiftKey;this.meta=a.metaKey;this.sourceEvent=a;this.time=c;return this},addTouch:function(a){-1===this.touches.indexOf(a)&& this.touches.push(a);return this},addChangedTouch:function(a){-1===this.changedTouches.indexOf(a)&&this.changedTouches.push(a);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({defines:"CAAT.Event.MouseEvent",aliases:["CAAT.MouseEvent"],depends:["CAAT.Math.Point"],extendsWith:{__init:function(){this.point=new CAAT.Math.Point(0,0,0);this.screenPoint=new CAAT.Math.Point(0,0,0);this.touches=[];return this},screenPoint:null,point:null,time:0,source:null,shift:false,control:false,alt:false,meta:false,sourceEvent:null,touches:null,init:function(a,b,c,d,e,f){this.point.set(a,b);this.source=d;this.screenPoint=e;this.alt=c.altKey;this.control=c.ctrlKey;this.shift=c.shiftKey; -this.meta=c.metaKey;this.sourceEvent=c;this.x=a;this.y=b;this.time=f;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({defines:"CAAT.Event.MouseEvent",aliases:["CAAT.MouseEvent"],depends:["CAAT.Math.Point"],extendsWith:{__init:function(){this.point=new CAAT.Math.Point(0,0,0);this.screenPoint=new CAAT.Math.Point(0,0,0);this.touches=[];return this},screenPoint:null,point:null,time:0,source:null,shift:!1,control:!1,alt:!1,meta:!1,wheelDelta:0,sourceEvent:null,touches:null,init:function(a,b,c,d,e,f){this.point.set(a,b);this.source=d;this.screenPoint=e;this.alt=c.altKey;this.control=c.ctrlKey;this.shift=c.shiftKey; +this.meta=c.metaKey;this.wheelDelta=c.wheelDelta;this.sourceEvent=c;this.x=a;this.y=b;this.time=f;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({defines:"CAAT.Event.KeyEvent",aliases:"CAAT.KeyEvent",extendsWith:{__init:function(a,b,c,d){this.keyCode=a;this.action=b;this.modifiers=c;this.sourceEvent=d;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(){CAAT.KEYS={ENTER:13,BACKSPACE:8,TAB:9,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPSLOCK:20,ESCAPE:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,a:65,b:66,c:67,d:68,e:69,f:70,g:71,h:72,i:73,j:74,k:75,l:76,m:77,n:78,o:79,p:80,q:81,r:82,s:83,t:84,u:85,v:86,w:87,x:88,y:89,z:90,SELECT:93, NUMPAD0:96,NUMPAD1:97,NUMPAD2:98,NUMPAD3:99,NUMPAD4:100,NUMPAD5:101,NUMPAD6:102,NUMPAD7:103,NUMPAD8:104,NUMPAD9:105,MULTIPLY:106,ADD:107,SUBTRACT:109,DECIMALPOINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SCROLLLOCK:145,SEMICOLON:186,EQUALSIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARDSLASH:191,GRAVEACCENT:192,OPENBRACKET:219,BACKSLASH:220,CLOSEBRAKET:221,SINGLEQUOTE:222};CAAT.Keys=CAAT.KEYS;CAAT.SHIFT_KEY=16;CAAT.CONTROL_KEY= -17;CAAT.ALT_KEY=18;CAAT.ENTER_KEY=13;CAAT.KEY_MODIFIERS={alt:false,control:false,shift:false}}}); -CAAT.Module({defines:"CAAT.Event.Input",depends:["CAAT.Event.KeyEvent","CAAT.Event.MouseEvent","CAAT.Event.TouchEvent"],onCreate:function(){CAAT.setCursor=function(a){if(navigator.browser!=="iOS")document.body.style.cursor=a};CAAT.TOUCH_AS_MOUSE=1;CAAT.TOUCH_AS_MULTITOUCH=2;CAAT.TOUCH_BEHAVIOR=CAAT.TOUCH_AS_MOUSE;CAAT.windowResizeListeners=[];CAAT.registerResizeListener=function(a){CAAT.windowResizeListeners.push(a)};CAAT.unregisterResizeListener=function(a){for(var b=0;b=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;a=this.duration?(this.remove=!0,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=!1;this.startTime=a;this.owner.ensureTimerTask(this);return this},cancel:function(){this.remove=!0;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;0<=c;)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;0<=c;){if(b[c]===a)return!0;c--}return!1}, +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, +this.singleWidth/a.__texturePage.width;a.__dv=this.singleHeight/a.__texturePage.height;e=this.singleWidth;f=this.singleHeight;var h=this.columns;a.inverted&&(d=e,e=f,f=d,h=this.rows);a=this.image.__tx;for(var k=this.image.__ty,m=this.image.__texturePage,d=0;d>0)*e;var n=k+(d/h>>0)*f,p=g+e,r=n+f;g=(new CAAT.Foundation.SpriteImageHelper(g,n,p-g,r-n,m.width,m.height)).setGL(g/m.width,n/m.height,p/m.width,r/m.height);this.mapInfo[d]=g}}else for(d=0;d>0)+1,f=((c.height-g)/f>>0)+1,h,k=a.ctx;for(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}}}}); +this.parentOffsetY,parseFloat(b.width),parseFloat(b.height),this.image.width,this.image.height);c.xoffset="undefined"===typeof b.xoffset?0:parseFloat(b.xoffset);c.yoffset="undefined"===typeof b.yoffset?0:parseFloat(b.yoffset);c.xadvance="undefined"===typeof b.xadvance?b.width:parseFloat(b.xadvance);this.mapInfo[a]=c;return this},initializeAsGlyphDesigner:function(a,b){this.initialize(a,1,1);var c,d,e=0;for(c in b){var f=b[c];d=new CAAT.Foundation.SpriteImageHelper(parseFloat(f.x)+this.parentOffsetX, +parseFloat(f.y)+this.parentOffsetX,parseFloat(f.width),parseFloat(f.height),a.width,a.height);d.xoffset="undefined"===typeof f.xoffset?0:f.xoffset;d.yoffset="undefined"===typeof f.yoffset?0:f.yoffset;d.xadvance="undefined"===typeof f.xadvance?f.width:f.xadvance;this.mapInfo[c]=d;e||this.setAnimationImageIndex([c]);e++}return this},initializeAsFontMap:function(a,b){this.initialize(a,1,1);for(var c,d=0,e=0;e>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;e>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.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=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:!1,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:!1,frameAlpha:1,expired:!1,discardable:!1, +pointed:!1,mouseEnabled:!0,visible:!0,fillStyle:null,strokeStyle:null,time:0,AABB:null,viewVertices:null,inFrame:!1,dirty:!0,wdirty:!0,oldX:-1,oldY:-1,modelViewMatrix:null,worldModelViewMatrix:null,modelViewMatrixI:null,worldModelViewMatrixI:null,glEnabled:!1,backgroundImage:null,id:null,size_active:1,size_total:1,__d_ax:-1,__d_ay:-1,gestureEnabled:!1,invalid:!0,cached:0,preventLayout:!1,isAA:!0,isCachedActor:!1,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){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){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);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 k= +this.getBehavior("__scaleTo");k||(k=(new CAAT.Behavior.ScaleBehavior).setId("__scaleTo").setValues(1,1,1,1,0.5,0.5),this.addBehavior(k));k.setValues(this.scaleX,a,this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&k.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 k=this.getBehavior("__scaleXTo");k||(k=(new CAAT.Behavior.Scale1Behavior).setId("__scaleXTo").setValues(1,1,a===CAAT.Behavior.Scale1Behavior.AXIS_X,0.5,0.5),this.addBehavior(k));k.setValues(a?this.scaleX:this.scaleY,c,f,g).setDelayTime(e?e:0,d);h&&k.setInterpolator(h);return this}},touchStart:function(a){},touchMove:function(a){},touchEnd:function(a){},gestureStart:function(a,c,d){},gestureChange:function(a,c,d){this.gestureEnabled&& +(this.setRotation(a),this.setScale(c,d));return this},gestureEnd:function(a,c,d){},isVisible:function(){return this.visible},invalidate:function(){this.invalid=!0;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("undefined"===typeof c||c)this.width=a.getWidth(),this.height=a.getHeight();this.glEnabled=!0;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);a&&!this.visible&&(this.dirty=!0);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),!1):this.start_time<=a&&af&&(f=d.x);d.yh&&(h=d.y);d=c[1];d.xf&&(f=d.x);d.yh&&(h=d.y);d=c[2];d.xf&&(f=d.x);d.yh&&(h=d.y);d=c[3];d.xf&&(f=d.x);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!0;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!0},__paintActor:function(a,c){if(!this.visible)return!0;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!0},paintActorGL:function(a,c){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&&this.visible)if(this.glNeedsFlush(a))a.glFlush(),this.glSetShader(a),this.__uv||(this.__uv=new Float32Array(8)),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 d=a.coordsIndex;this.setGLCoords(a.coords,d);a.coordsIndex=d+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||this.frameAlpha!==a.currentOpacity?!0:!1},glSetShader:function(a){var c=this.getTextureGLPage();c!==a.currentTexturePage&&a.setGLTexturePage(c); +this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)},endAnimate:function(a,c){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(){this.cached&&(this.backgroundImage=null,this.cached=CAAT.Foundation.Actor.CACHE_NONE)},cacheAsBitmap:function(a,c){if(0>=this.width||0>=this.height)return this;a=a||0;var 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:!1,inDirtyRect:function(){return!0},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; +"undefined"===typeof c&&(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,!0);this.iNormal=c||0;this.iOver=d||this.iNormal;this.iPress=e||this.iNormal;this.iDisabled=f||this.iNormal;this.fnOnClick=g;this.enabled=!0;this.setSpriteIndex(c);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this}; +this.actionPerformed=function(a){this.enabled&&this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(a){this.enabled&&(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(a){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(a){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(a){this.enabled&&(this.setSpriteIndex(this.iNormal),this.dragging= +!1)};this.mouseClick=function(a){};this.mouseDrag=function(a){this.enabled&&(this.dragging=!0)};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? +this.childrenList=[];this.activeChildren=[];this.pendingChildrenList=[];"undefined"!==typeof a&&(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:!0,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=!1},__validateTree:function(){if(this.layoutManager&&this.layoutManager.isInvalidated()){CAAT.currentDirector.inValidation=!0;this.layoutManager.doLayout(this);for(var a=0;ac.x?0:c.x,0>c.y?0:c.y,c.width,c.height),a.unionRectangle(this.runion);this.setSize(a.x1,a.y1);return this},addChildDelayed:function(a,b){this.pendingChildrenList.push({child:a,constraint:b});return this},addChildAt:function(a,b){if(0>=b)return a.parent=this,a.dirty=!0,this.childrenList.splice(0,0,a),this.invalidateLayout(),this;b>= +this.childrenList.length&&(b=this.childrenList.length);a.parent=this;a.dirty=!0;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=d.length? +(d.splice(c,1),d.push(a)):(c=d.splice(c,1),0>b?b=0: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=!0;return this},easeContainerBehaviour:null,easeContainerBehaviourListener:null,easeIn:!1,paused:!1,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,!0,d)},easeTranslationOut:function(a,b,c,d){this.easeTranslation(a,b,c,!1,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);1>c?c=1:4Math.random()?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*(0.5>Math.random()?1:-1);break;default:alert("rot anchor ?? "+c)}if(!1=== 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;eb?b=0:b>=this.inputList.length&&(b=this.inputList.length-1);b=this.inputList[b];"undefined"===typeof c||c>=b.length?b.push(a):0>=c?b.unshift(a):b.splice(c,0,a);return this},emptyInputList:function(a){0>a?a=0:a>=this.inputList.length&& +(a=this.inputList.length-1);this.inputList[a]=[];return this},removeActorFromInputList:function(a,b){if("undefined"===typeof b){var c,d;for(c=0;cb?b=0:b>=this.inputList.length&&(b=this.inputList.length-1);e=this.inputList[b];for(d=0;da;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:!1,renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null, +isMouseDown:!1,lastSelectedActor:null,dragging:!1,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:!1,glTextureManager:null,glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:!1,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:!1,nDirtyRects:0,drDiscarded:0,stopped:!1,needsRepaint:!1,touches:null,timerManager:null,SCREEN_RATIO:1,__map:null,clean:function(){this.audioManager=this.imagesCache=this.currentScene=this.scenes=null;this.isMouseDown=!1;this.lastSelectedActor=null;this.dragging=!1;this.__gestureRotation=this.__gestureScale= +0;this.dirty=!0;this.cDirtyRects=this.dirtyRects=null;this.dirtyRectsIndex=0;this.dirtyRectsEnabled=!1;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=!0},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;c0&&!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;a=this.dirtyRects.length)for(b=0;32>b;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=!0;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)},findScene:function(a){var b=this.scenes,c,d=b.length;for(c=0;ce?(e=CAAT.Foundation.Scene.EASE_ROTATION,g=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):0.66>e?(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;0.33>f?(f=CAAT.Foundation.Scene.EASE_ROTATION,h=(new CAAT.Behavior.Interpolator).createExponentialInOutInterpolator(4)):0.66>f?(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,8.99*Math.random()>>0,b, +f,8.99*Math.random()>>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=!1;a.setExpired(!1)},setScene:function(a){a="number"==typeof a?a:this.findScene(a);a=this.scenes[a];this.childrenList=[];this.addChild(a);this.currentScene=a;a.setExpired(!1); +a.mouseEnabled=!0;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);1>=this.getNumScenes()||0===d||(c?this.easeInOutRandom(d-1,d,a,b):this.setScene(d-1))},switchToNextScene:function(a,b,c){var d=this.getSceneIndex(this.currentScene);1>=this.getNumScenes()||d===this.getNumScenes()- +1||(c?this.easeInOutRandom(d+1,d,a,b):this.setScene(d+1))},mouseEnter:function(a){},mouseExit:function(a){},mouseMove:function(a){},mouseDown:function(a){},mouseUp:function(a){},mouseDrag:function(a){},easeEnd:function(a,b){b?(this.currentScene=a,this.currentScene.activated()):a.setExpired(!0);a.mouseEnabled=!0;a.emptyBehaviorList()},getSceneIndex:function(a){for(var b=0;bb.x||0>b.y||b.x>=this.width||b.y>=this.height|| +(this.touching=!0,this.__mouseDownHandler(a))}},__touchEndHandler:function(a){this.touching&&(a.preventDefault(),a.returnValue=!1,a=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=!1,this.__mouseUpHandler(a))},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),a.returnValue=!1,!this.gesturing))for(var b=0;bf.x||0>f.y||f.x>=this.width||f.y>=this.height)){var g=this.findActorAtPosition(f);null!==g&&(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;be.x||0>e.y||e.x>=b.width||e.y>=b.height||(b.touching=!0,b.__mouseDownHandler(c))}},!1);window.addEventListener("mouseover",function(c){if(c.target===a&&!b.dragging){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||b.__mouseOverHandler(c)}},!1); +window.addEventListener("mouseout",function(c){c.target!==a||b.dragging||(c.preventDefault(),c.cancelBubble=!0,c.stopPropagation&&c.stopPropagation(),b.getCanvasCoord(b.mousePoint,c),b.__mouseOutHandler(c))},!1);window.addEventListener("mousemove",function(a){a.preventDefault();a.cancelBubble=!0;a.stopPropagation&&a.stopPropagation();var c=b.mousePoint;b.getCanvasCoord(c,a);!b.dragging&&(0>c.x||0>c.y||c.x>=b.width||c.y>=b.height)||b.__mouseMoveHandler(a)},!1);window.addEventListener("dblclick",function(c){if(c.target=== +a){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||b.__mouseDBLClickHandler(c)}},!1);var c=function(c){if(c.target===a){c.preventDefault();c.cancelBubble=!0;c.stopPropagation&&c.stopPropagation();var e=b.mousePoint;b.getCanvasCoord(e,c);0>e.x||0>e.y||e.x>=b.width||e.y>=b.height||(c.wheelDelta=Math.max(-1,Math.min(1,c.wheelDelta||-c.detail)),b.__mouseWheelHandler(c))}};window.addEventListener("mousewheel", +c,!1);window.addEventListener("DOMMouseScroll",c,!1);CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MOUSE?(a.addEventListener("touchstart",this.__touchStartHandler.bind(this),!1),a.addEventListener("touchmove",this.__touchMoveHandler.bind(this),!1),a.addEventListener("touchend",this.__touchEndHandler.bind(this),!1),a.addEventListener("gesturestart",function(c){c.target===a&&(c.preventDefault(),c.returnValue=!1,b.__gestureStart(c.scale,c.rotation))},!1),a.addEventListener("gestureend",function(c){c.target=== +a&&(c.preventDefault(),c.returnValue=!1,b.__gestureEnd(c.scale,c.rotation))},!1),a.addEventListener("gesturechange",function(c){c.target===a&&(c.preventDefault(),c.returnValue=!1,b.__gestureChange(c.scale,c.rotation))},!1)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),!1),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this),!1),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),!1),a.addEventListener("touchcancel", +this.__touchCancelHandleMT.bind(this),!1),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),!1),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this),!1),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),!1))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=!1;this.createEventHandler(a)},createEventHandler:function(a){this.in_=!1;this.addHandlers(a)}}},onCreate:function(){"undefined"!==typeof CAAT.__CSS__&& +(CAAT.Foundation.Director.prototype.clip=!0,CAAT.Foundation.Director.prototype.glEnabled=!1,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: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()}}}); +shadowColor:null,shadowOffsetX:null,shadowOffsetY:null,sfont:null,chain:null,setDefault:function(a){this.defaultFS=24;this.font="Arial";this.fontSize=this.defaultFS;this.fill="#000";this.stroke="#f00";this.filled=!0;this.stroked=!1;this.strokeSize=1;this.bold=this.italic=!1;this.alignment="left";this.tabSize=75;this.shadow=!1;this.shadowBlur=0;this.shadowColor="#000";this.shadowOffsetY=this.shadowOffsetX=0;for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);this.__setFont();return this},setStyle:function(a){if("undefined"!== +typeof a)for(var b in a)this[b]=a[b];return this},applyStyle:function(){this.__setFont();return this},clone:function(){var b=new a(this.ctx),c;for(c in this)this.hasOwnProperty(c)&&(b[c]=this[c]);for(var d=this;d.chain;)for(c in d=d.chain,d)null===b[c]&&d.hasOwnProperty(c)&&(b[c]=d[c]);b.__setFont();return b},__getProperty:function(a){var b=this,c;do{c=b[a];if(null!==c)return c;b=b.chain}while(b);return null},image:function(a){this.__setShadow(a)},text:function(a,b,c,d){this.__setShadow(a);a.font= +this.__getProperty("sfont");this.filled&&this.__fillText(a,b,c,d);this.stroked&&this.__strokeText(a,b,c,d)},__setShadow:function(a){this.__getProperty("shadow")&&(a.shadowBlur=this.__getProperty("shadowBlur"),a.shadowColor=this.__getProperty("shadowColor"),a.shadowOffsetX=this.__getProperty("shadowOffsetX"),a.shadowOffsetY=this.__getProperty("shadowOffsetY"))},__fillText:function(a,b,c,d){a.fillStyle=this.__getProperty("fill");a.fillText(b,c,d)},__strokeText:function(a,b,c,d){a.strokeStyle=this.__getProperty("stroke"); +a.lineWidth=this.__getProperty("strokeSize");a.beginPath();a.strokeText(b,c,d)},__setFont:function(){var a=this.__getProperty("italic"),b=this.__getProperty("bold"),c=this.__getProperty("fontSize"),d=this.__getProperty("font");this.sfont=(a?"italic ":"")+(b?"bold ":"")+c+"px "+d;this.ctx.font=this.__getProperty("sfont")},setBold:function(a){a!=this.bold&&(this.bold=a,this.__setFont())},setItalic:function(a){a!=this.italic&&(this.italic=a,this.__setFont())},setStroked:function(a){this.stroked=a},setFilled:function(a){this.filled= +a},getTabPos:function(a){var b=this.__getProperty("tabSize");return((a/b>>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){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="undefined"!==typeof b&&"undefined"!==typeof c?a.getWidth():a instanceof CAAT.Foundation.SpriteImage?a.getWidth():a.getWrappedImageWidth();this.width&&e+this.x>this.width&&0this.width&&0this.width&&this.__nextLine()):this.text+=a},end:function(){0>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(){1=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;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+(null!=a?a.descent:this.defaultFontMetrics.descent);for(c=0;c",d+1),-1!==r&&(q=f.substr(d+1,r-d-1),-1!==q.indexOf("<")?(this.rc.fchar(s),d+=1):(this.rc.setTag(q),d=r+1))):(this.rc.fchar(s),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension("undefined"===typeof b?0:b);this.setLinesAlignment();t.restore();this.setPreferredSize(this.documentWidth,this.documentHeight); +this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);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){"undefined"!==typeof a&&this.setHorizontalAlignment(a);"undefined"!==typeof b&&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(a){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:!1,outlineColor:"black",onUpdateCallback:null,interactive:!1,getPath:function(){return this.path},setPath:function(a){this.path=a;null!=a&&(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);this.bOutline&&(c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height))}},showBoundingBox:function(a,b){(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(a){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()}}}}); +a;return this},paint:function(a,b){},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;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,!1),c.fill());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,!1),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;this.lineCap&&(c.lineCap=this.lineCap);this.lineJoin&&(c.lineJoin=this.lineJoin);this.miterLimit&&(c.miterLimit=this.miterLimit);c.globalCompositeOperation=this.compositeOp;null!==this.fillStyle&&(c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width,this.height), +c.fill());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>0,e.y>>0):c.translate(e.x,e.y);c.rotate(f);this.fill&&c.fillText(h,0,0);this.outline&&(c.beginPath(),c.lineWidth=this.lineWidth,c.strokeText(h, +0,0));c.restore();d+=k}},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 * WARNING: every call to this method calculates * actor's world model view matrix. @@ -19178,7 +19191,7 @@ CAAT.Module({ if (this.dirty) { this.setModelViewMatrix(); } - this.worldModelViewMatrixI = this.worldModelViewMatrix.getInverse(); + this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI); this.worldModelViewMatrixI.transformCoord(point); return point; }, @@ -19198,7 +19211,7 @@ CAAT.Module({ return null; } - this.modelViewMatrixI = this.modelViewMatrix.getInverse(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); this.modelViewMatrixI.transformCoord(point); return this.contains(point.x, point.y) ? this : null; }, @@ -19345,6 +19358,13 @@ CAAT.Module({ */ mouseDblClick:function (mouseEvent) { }, + /** + * Default mouse wheel handler + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseWheel:function (mouseEvent) { + }, /** * Default mouse enter on Actor handler. * @param mouseEvent {CAAT.Event.MouseEvent} @@ -20719,6 +20739,18 @@ CAAT.Module({ } return -1; }, + /** + * Removed all Actors from this ActorContainer. + * + * @return array of former children + */ + removeAllChildren: function() { + var cl = this.childrenList.slice(); // Make a shalow copy + for (var pos = cl.length-1;pos>=0;pos--) { + this.removeChildAt(pos); + } + return cl; + }, removeChildAt:function (pos) { var cl = this.childrenList; var rm; @@ -20736,7 +20768,7 @@ CAAT.Module({ return null; }, /** - * Removed an Actor form this ActorContainer. + * Removed an Actor from this ActorContainer. * If the Actor is not contained into this Container, nothing happends. * * @param child a CAAT.Foundation.Actor object instance. @@ -21935,7 +21967,6 @@ CAAT.Module({ getValueForKey : function( key ) { return this.__map[key]; - return this; }, createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { @@ -22616,7 +22647,7 @@ CAAT.Module({ this.timerManager.checkTimers(time); this.setModelViewMatrix(this); - this.modelViewMatrixI = this.modelViewMatrix.getInverse(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); this.setScreenBounds(); this.dirty = false; @@ -22819,6 +22850,46 @@ CAAT.Module({ 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. @@ -23037,10 +23108,11 @@ CAAT.Module({ /** * Changes (or sets) the current Director scene to the index * parameter. There will be no transition on scene change. - * @param sceneIndex {number} an integer indicating the index of the target Scene + * @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 (sceneIndex) { + setScene:function (scene) { + var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene); var sin = this.scenes[ sceneIndex ]; this.childrenList = []; this.addChild(sin); @@ -23418,10 +23490,11 @@ CAAT.Module({ style = style ? style.getPropertyValue('position') : null; } -// if (!/^(relative|absolute|fixed)$/.test(style)) { + // Accumulate offsets... + x += node[left]; + y += node[top]; + if (!/^(fixed)$/.test(style)) { - x += node[left]; - y += node[top]; node = node[parent]; } else { break; @@ -23484,11 +23557,11 @@ CAAT.Module({ pt.x = posx; pt.y = posy; if (!this.modelViewMatrixI) { - this.modelViewMatrixI = this.modelViewMatrix.getInverse(); + this.modelViewMatrix.getInverse(this.modelViewMatrixI); } this.modelViewMatrixI.transformCoord(pt); posx = pt.x; - posy = pt.y + posy = pt.y; point.set(posx, posy); this.screenMousePoint.set(posx, posy); @@ -23541,7 +23614,7 @@ CAAT.Module({ 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.actionPerformed(e); } lactor.mouseUp( @@ -23791,7 +23864,6 @@ CAAT.Module({ __mouseDBLClickHandler:function (e) { - this.getCanvasCoord(this.mousePoint, e); if (null !== this.lastSelectedActor) { /* var pos = this.lastSelectedActor.viewToModel( @@ -23799,8 +23871,22 @@ CAAT.Module({ */ this.lastSelectedActor.mouseDblClick( new CAAT.Event.MouseEvent().init( - this.mousePoint.x, - this.mousePoint.y, + this.prevMousePoint.x, + this.prevMousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + __mouseWheelHandler:function (e) { + + if (null !== this.lastSelectedActor) { + this.lastSelectedActor.mouseWheel( + new CAAT.Event.MouseEvent().init( + this.prevMousePoint.x, + this.prevMousePoint.y, e, this.lastSelectedActor, this.screenMousePoint, @@ -24275,6 +24361,27 @@ CAAT.Module({ } }, false); + var mouseWheelHandler = 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; + } + + //Cross browser wheel delta + e.wheelDelta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); + me.__mouseWheelHandler(e); + } + }; + //IE9, Chrome, Safari, Opera + window.addEventListener('mousewheel', mouseWheelHandler, false); + //Firefox + window.addEventListener('DOMMouseScroll', mouseWheelHandler, 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); @@ -25018,44 +25125,50 @@ CAAT.Module( { renderContextStyle.prototype= { - ctx : null, - - defaultFS : null, - font : null, - fontSize : null, - fill : null, - stroke : null, - filled : null, - stroked : null, - strokeSize : null, - italic : null, - bold : null, - alignment : null, - tabSize : null, - shadow : null, - shadowBlur : null, - shadowColor : null, + ctx : null, + + defaultFS : null, + font : null, + fontSize : null, + fill : null, + stroke : null, + filled : null, + stroked : null, + strokeSize : null, + italic : null, + bold : null, + alignment : null, + tabSize : null, + shadow : null, + shadowBlur : null, + shadowColor : null, + shadowOffsetX: null, + shadowOffsetY: null, - sfont : null, - chain : null, + sfont : null, + + chain : null, setDefault : function( defaultStyles ) { - this.defaultFS = 24; - this.font = "Arial"; - this.fontSize = this.defaultFS; - this.fill = '#000'; - this.stroke = '#f00'; - this.filled = true; - this.stroked = false; - this.strokeSize = 1; - this.italic = false; - this.bold = false; - this.alignment = "left"; - this.tabSize = 75; - this.shadow = false; - this.shadowBlur = 0; - this.shadowColor= "#000"; + this.defaultFS = 24; + this.font = "Arial"; + this.fontSize = this.defaultFS; + this.fill = '#000'; + this.stroke = '#f00'; + this.filled = true; + this.stroked = false; + this.strokeSize = 1; + this.italic = false; + this.bold = false; + this.alignment = "left"; + this.tabSize = 75; + this.shadow = false; + this.shadowBlur = 0; + this.shadowColor = "#000"; + this.shadowOffsetX= 0; + this.shadowOffsetY= 0; + for( var style in defaultStyles ) { if ( defaultStyles.hasOwnProperty(style) ) { @@ -25155,8 +25268,10 @@ CAAT.Module( { __setShadow : function( ctx ) { if ( this.__getProperty("shadow" ) ) { - ctx.shadowBlur= this.__getProperty("shadowBlur"); - ctx.shadowColor= this.__getProperty("shadowColor"); + ctx.shadowBlur = this.__getProperty("shadowBlur"); + ctx.shadowColor = this.__getProperty("shadowColor"); + ctx.shadowOffsetX= this.__getProperty("shadowOffsetX"); + ctx.shadowOffsetY= this.__getProperty("shadowOffsetY"); } }, diff --git a/documentation/CAAT b/documentation/CAAT new file mode 120000 index 00000000..140b6e74 --- /dev/null +++ b/documentation/CAAT @@ -0,0 +1 @@ +/applis/renarderi/workspace/CAAT \ No newline at end of file diff --git a/documentation/demos/demo37/mouseWheel.html b/documentation/demos/demo37/mouseWheel.html new file mode 100644 index 00000000..a2abcf2e --- /dev/null +++ b/documentation/demos/demo37/mouseWheel.html @@ -0,0 +1,101 @@ + + + + + + CAAT example: Mouse wheel support + + + + + + +
+ + +
+ +
+
+

Pan Zoom with the mouse wheel

+
+
+ +
+
+
+

+ This demo features the following elements: +

+
    +
  • Mouse wheel support
  • +
+

+ You obviously need a mouse wheel for this one. Use your mouse wheel on the green square. +

+
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/documentation/demos/index.html b/documentation/demos/index.html index 9eec55c1..7495d96a 100644 --- a/documentation/demos/index.html +++ b/documentation/demos/index.html @@ -46,6 +46,7 @@

Demos

UI.TextActor vs drawString SVG Parser CSS3 @KeyFrames + Mouse wheel support diff --git a/documentation/demos/menu/menu.html b/documentation/demos/menu/menu.html index 8fd87743..0c83d6d4 100644 --- a/documentation/demos/menu/menu.html +++ b/documentation/demos/menu/menu.html @@ -48,10 +48,11 @@

Demos

  • Text Actor
  • SVG Path parser
  • @key-frames
  • +
  • mouseWheel
  • Tutorial

    \ No newline at end of file diff --git a/documentation/demos/thumbs/demo37.png b/documentation/demos/thumbs/demo37.png new file mode 100644 index 00000000..5e35421d Binary files /dev/null and b/documentation/demos/thumbs/demo37.png differ diff --git a/documentation/jsdoc/files.html b/documentation/jsdoc/files.html index bb93f836..6761909e 100644 --- a/documentation/jsdoc/files.html +++ b/documentation/jsdoc/files.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -437,7 +437,7 @@

    File Index

    -

    /Users/ibon/js/CAAT/src/Behavior/AlphaBehavior.js

    +

    ./src/Behavior/AlphaBehavior.js

    @@ -449,7 +449,7 @@

    -

    /Users/ibon/js/CAAT/src/Behavior/BaseBehavior.js

    +

    ./src/Behavior/BaseBehavior.js

    @@ -461,7 +461,7 @@


    -

    /Users/ibon/js/CAAT/src/Behavior/ContainerBehavior.js

    +

    ./src/Behavior/ContainerBehavior.js

    @@ -473,7 +473,7 @@

    /Users/ibon/js/CAAT/src/Behavior/GenericBehavior.js

    +

    ./src/Behavior/GenericBehavior.js

    @@ -485,7 +485,7 @@

    /Users/ibon/js/CAAT/src/Behavior/Interpolator.js

    +

    ./src/Behavior/Interpolator.js

    @@ -497,7 +497,7 @@


    -

    /Users/ibon/js/CAAT/src/Behavior/PathBehavior.js

    +

    ./src/Behavior/PathBehavior.js

    @@ -509,7 +509,7 @@


    -

    /Users/ibon/js/CAAT/src/Behavior/RotateBehavior.js

    +

    ./src/Behavior/RotateBehavior.js

    @@ -521,7 +521,7 @@

    /Users/ibon/js/CAAT/src/Behavior/Scale1Behavior.js

    +

    ./src/Behavior/Scale1Behavior.js

    @@ -533,7 +533,7 @@

    /Users/ibon/js/CAAT/src/Behavior/ScaleBehavior.js

    +

    ./src/Behavior/ScaleBehavior.js

    @@ -545,7 +545,7 @@

    -

    /Users/ibon/js/CAAT/src/CAAT.js

    +

    ./src/CAAT.js

    @@ -557,7 +557,7 @@

    /Users/ibon/js/CA
    -

    /Users/ibon/js/CAAT/src/Core/Class.js

    +

    ./src/Core/Class.js

    @@ -569,7 +569,7 @@

    /Users/ibon
    -

    /Users/ibon/js/CAAT/src/Core/Constants.js

    +

    ./src/Core/Constants.js

    @@ -581,7 +581,7 @@

    /Users/
    -

    /Users/ibon/js/CAAT/src/Core/ModuleManager.js

    +

    ./src/Core/ModuleManager.js

    @@ -593,7 +593,7 @@

    /Us
    -

    /Users/ibon/js/CAAT/src/Event/AnimationLoop.js

    +

    ./src/Event/AnimationLoop.js

    @@ -605,7 +605,7 @@

    /U
    -

    /Users/ibon/js/CAAT/src/Event/Input.js

    +

    ./src/Event/Input.js

    @@ -617,7 +617,7 @@

    /Users/ibo
    -

    /Users/ibon/js/CAAT/src/Event/KeyEvent.js

    +

    ./src/Event/KeyEvent.js

    @@ -629,7 +629,7 @@

    /Users/
    -

    /Users/ibon/js/CAAT/src/Event/MouseEvent.js

    +

    ./src/Event/MouseEvent.js

    @@ -641,7 +641,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/Event/TouchEvent.js

    +

    ./src/Event/TouchEvent.js

    @@ -653,7 +653,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/Event/TouchInfo.js

    +

    ./src/Event/TouchInfo.js

    @@ -665,7 +665,7 @@

    /Users
    -

    /Users/ibon/js/CAAT/src/Foundation/Actor.js

    +

    ./src/Foundation/Actor.js

    @@ -677,7 +677,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/Foundation/ActorContainer.js

    +

    ./src/Foundation/ActorContainer.js

    @@ -689,7 +689,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Box2D/B2DBodyActor.js

    +

    ./src/Foundation/Box2D/B2DBodyActor.js

    @@ -701,7 +701,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Box2D/B2DCircularBody.js

    +

    ./src/Foundation/Box2D/B2DCircularBody.js

    @@ -713,7 +713,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Box2D/B2DPolygonBody.js

    +

    ./src/Foundation/Box2D/B2DPolygonBody.js

    @@ -725,7 +725,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Director.js

    +

    ./src/Foundation/Director.js

    @@ -737,7 +737,7 @@

    /U
    -

    /Users/ibon/js/CAAT/src/Foundation/Scene.js

    +

    ./src/Foundation/Scene.js

    @@ -749,7 +749,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/Foundation/SpriteImage.js

    +

    ./src/Foundation/SpriteImage.js

    @@ -761,7 +761,7 @@

    -

    /Users/ibon/js/CAAT/src/Foundation/SpriteImageAnimationHelper.js

    +

    ./src/Foundation/SpriteImageAnimationHelper.js

    @@ -773,7 +773,7 @@

    /Users/ibon/js/CAAT/src/Foundation/SpriteImageHelper.js

    +

    ./src/Foundation/SpriteImageHelper.js

    @@ -785,7 +785,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Timer/TimerManager.js

    +

    ./src/Foundation/Timer/TimerManager.js

    @@ -797,7 +797,7 @@

    /Users/ibon/js/CAAT/src/Foundation/Timer/TimerTask.js

    +

    ./src/Foundation/Timer/TimerTask.js

    @@ -809,7 +809,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/Dock.js

    +

    ./src/Foundation/UI/Dock.js

    @@ -821,7 +821,7 @@

    /Us
    -

    /Users/ibon/js/CAAT/src/Foundation/UI/IMActor.js

    +

    ./src/Foundation/UI/IMActor.js

    @@ -833,7 +833,7 @@


    -

    /Users/ibon/js/CAAT/src/Foundation/UI/InterpolatorActor.js

    +

    ./src/Foundation/UI/InterpolatorActor.js

    @@ -845,7 +845,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/Label.js

    +

    ./src/Foundation/UI/Label.js

    @@ -857,7 +857,7 @@

    /U
    -

    /Users/ibon/js/CAAT/src/Foundation/UI/Layout/BorderLayout.js

    +

    ./src/Foundation/UI/Layout/BorderLayout.js

    @@ -869,7 +869,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/Layout/BoxLayout.js

    +

    ./src/Foundation/UI/Layout/BoxLayout.js

    @@ -881,7 +881,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/Layout/GridLayout.js

    +

    ./src/Foundation/UI/Layout/GridLayout.js

    @@ -893,7 +893,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/Layout/LayoutManager.js

    +

    ./src/Foundation/UI/Layout/LayoutManager.js

    @@ -905,7 +905,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/PathActor.js

    +

    ./src/Foundation/UI/PathActor.js

    @@ -917,7 +917,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/ShapeActor.js

    +

    ./src/Foundation/UI/ShapeActor.js

    @@ -929,7 +929,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/StarActor.js

    +

    ./src/Foundation/UI/StarActor.js

    @@ -941,7 +941,7 @@

    /Users/ibon/js/CAAT/src/Foundation/UI/TextActor.js

    +

    ./src/Foundation/UI/TextActor.js

    @@ -953,7 +953,7 @@

    /Users/ibon/js/CAAT/src/Math/Bezier.js

    +

    ./src/Math/Bezier.js

    @@ -965,7 +965,7 @@

    /Users/ibo
    -

    /Users/ibon/js/CAAT/src/Math/CatmullRom.js

    +

    ./src/Math/CatmullRom.js

    @@ -977,7 +977,7 @@

    /Users
    -

    /Users/ibon/js/CAAT/src/Math/Curve.js

    +

    ./src/Math/Curve.js

    @@ -989,7 +989,7 @@

    /Users/ibon
    -

    /Users/ibon/js/CAAT/src/Math/Dimension.js

    +

    ./src/Math/Dimension.js

    @@ -1001,7 +1001,7 @@

    /Users/
    -

    /Users/ibon/js/CAAT/src/Math/Matrix.js

    +

    ./src/Math/Matrix.js

    @@ -1013,7 +1013,7 @@

    /Users/ibo
    -

    /Users/ibon/js/CAAT/src/Math/Matrix3.js

    +

    ./src/Math/Matrix3.js

    @@ -1025,7 +1025,7 @@

    /Users/ib
    -

    /Users/ibon/js/CAAT/src/Math/Point.js

    +

    ./src/Math/Point.js

    @@ -1037,7 +1037,7 @@

    /Users/ibon
    -

    /Users/ibon/js/CAAT/src/Math/Rectangle.js

    +

    ./src/Math/Rectangle.js

    @@ -1049,7 +1049,7 @@

    /Users/
    -

    /Users/ibon/js/CAAT/src/Modules/Audio/AudioManager.js

    +

    ./src/Modules/Audio/AudioManager.js

    @@ -1061,7 +1061,7 @@

    /Users/ibon/js/CAAT/src/Modules/CircleManager/PackedCircle.js

    +

    ./src/Modules/CircleManager/PackedCircle.js

    @@ -1073,7 +1073,7 @@

    /Users/ibon/js/CAAT/src/Modules/CircleManager/PackedCircleManager.js

    +

    ./src/Modules/CircleManager/PackedCircleManager.js

    @@ -1085,7 +1085,7 @@

    /Users/ibon/js/CAAT/src/Modules/Collision/Quadtree.js

    +

    ./src/Modules/Collision/Quadtree.js

    @@ -1097,7 +1097,7 @@

    /Users/ibon/js/CAAT/src/Modules/Collision/SpatialHash.js

    +

    ./src/Modules/Collision/SpatialHash.js

    @@ -1109,7 +1109,7 @@

    /Users/ibon/js/CAAT/src/Modules/ColorUtil/Color.js

    +

    ./src/Modules/ColorUtil/Color.js

    @@ -1121,7 +1121,7 @@

    /Users/ibon/js/CAAT/src/Modules/CSS/csskeyframehelper.js

    +

    ./src/Modules/CSS/csskeyframehelper.js

    @@ -1133,7 +1133,7 @@

    /Users/ibon/js/CAAT/src/Modules/Debug/Debug.js

    +

    ./src/Modules/Debug/Debug.js

    @@ -1145,7 +1145,7 @@

    /U
    -

    /Users/ibon/js/CAAT/src/Modules/Font/Font.js

    +

    ./src/Modules/Font/Font.js

    @@ -1157,7 +1157,7 @@

    /Use
    -

    /Users/ibon/js/CAAT/src/Modules/Image/ImageProcess/ImageProcessor.js

    +

    ./src/Modules/Image/ImageProcess/ImageProcessor.js

    @@ -1169,7 +1169,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/ImageProcess/IMBumpMapping.js

    +

    ./src/Modules/Image/ImageProcess/IMBumpMapping.js

    @@ -1181,7 +1181,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/ImageProcess/IMPlasma.js

    +

    ./src/Modules/Image/ImageProcess/IMPlasma.js

    @@ -1193,7 +1193,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/ImageProcess/IMRotoZoom.js

    +

    ./src/Modules/Image/ImageProcess/IMRotoZoom.js

    @@ -1205,7 +1205,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/Preloader/ImagePreloader.js

    +

    ./src/Modules/Image/Preloader/ImagePreloader.js

    @@ -1217,7 +1217,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/Preloader/Preloader.js

    +

    ./src/Modules/Image/Preloader/Preloader.js

    @@ -1229,7 +1229,7 @@

    /Users/ibon/js/CAAT/src/Modules/Image/Util/ImageUtil.js

    +

    ./src/Modules/Image/Util/ImageUtil.js

    @@ -1241,7 +1241,7 @@

    /Users/ibon/js/CAAT/src/Modules/Initialization/Template.js

    +

    ./src/Modules/Initialization/Template.js

    @@ -1253,7 +1253,7 @@

    /Users/ibon/js/CAAT/src/Modules/Initialization/TemplateWithSplash.js

    +

    ./src/Modules/Initialization/TemplateWithSplash.js

    @@ -1265,7 +1265,7 @@

    /Users/ibon/js/CAAT/src/Modules/LayoutUtils/RowLayout.js

    +

    ./src/Modules/LayoutUtils/RowLayout.js

    @@ -1277,7 +1277,7 @@

    /Users/ibon/js/CAAT/src/Modules/Locale/ResourceBundle.js

    +

    ./src/Modules/Locale/ResourceBundle.js

    @@ -1289,7 +1289,7 @@

    /Users/ibon/js/CAAT/src/Modules/Runtime/BrowserInfo.js

    +

    ./src/Modules/Runtime/BrowserInfo.js

    @@ -1301,7 +1301,7 @@

    /Users/ibon/js/CAAT/src/Modules/Skeleton/Bone.js

    +

    ./src/Modules/Skeleton/Bone.js

    @@ -1313,7 +1313,7 @@


    -

    /Users/ibon/js/CAAT/src/Modules/Skeleton/BoneActor.js

    +

    ./src/Modules/Skeleton/BoneActor.js

    @@ -1325,7 +1325,7 @@

    /Users/ibon/js/CAAT/src/Modules/Skeleton/Skeleton.js

    +

    ./src/Modules/Skeleton/Skeleton.js

    @@ -1337,7 +1337,7 @@

    /Users/ibon/js/CAAT/src/Modules/Skeleton/SkeletonActor.js

    +

    ./src/Modules/Skeleton/SkeletonActor.js

    @@ -1349,7 +1349,7 @@

    /Users/ibon/js/CAAT/src/Modules/Storage/LocalStorage.js

    +

    ./src/Modules/Storage/LocalStorage.js

    @@ -1361,7 +1361,7 @@

    /Users/ibon/js/CAAT/src/Modules/TexturePacker/TextureElement.js

    +

    ./src/Modules/TexturePacker/TextureElement.js

    @@ -1373,7 +1373,7 @@

    /Users/ibon/js/CAAT/src/Modules/TexturePacker/TexturePage.js

    +

    ./src/Modules/TexturePacker/TexturePage.js

    @@ -1385,7 +1385,7 @@

    /Users/ibon/js/CAAT/src/Modules/TexturePacker/TexturePageManager.js

    +

    ./src/Modules/TexturePacker/TexturePageManager.js

    @@ -1397,7 +1397,7 @@

    /Users/ibon/js/CAAT/src/Modules/TexturePacker/TextureScan.js

    +

    ./src/Modules/TexturePacker/TextureScan.js

    @@ -1409,7 +1409,7 @@

    /Users/ibon/js/CAAT/src/Modules/TexturePacker/TextureScanMap.js

    +

    ./src/Modules/TexturePacker/TextureScanMap.js

    @@ -1421,7 +1421,7 @@

    /Users/ibon/js/CAAT/src/PathUtil/ArcPath.js

    +

    ./src/PathUtil/ArcPath.js

    @@ -1433,7 +1433,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/PathUtil/CurvePath.js

    +

    ./src/PathUtil/CurvePath.js

    @@ -1445,7 +1445,7 @@

    /Us
    -

    /Users/ibon/js/CAAT/src/PathUtil/LinearPath.js

    +

    ./src/PathUtil/LinearPath.js

    @@ -1457,7 +1457,7 @@

    /U
    -

    /Users/ibon/js/CAAT/src/PathUtil/Path.js

    +

    ./src/PathUtil/Path.js

    @@ -1469,7 +1469,7 @@

    /Users/i
    -

    /Users/ibon/js/CAAT/src/PathUtil/PathSegment.js

    +

    ./src/PathUtil/PathSegment.js

    @@ -1481,7 +1481,7 @@

    /
    -

    /Users/ibon/js/CAAT/src/PathUtil/RectPath.js

    +

    ./src/PathUtil/RectPath.js

    @@ -1493,7 +1493,7 @@

    /Use
    -

    /Users/ibon/js/CAAT/src/PathUtil/SVGPath.js

    +

    ./src/PathUtil/SVGPath.js

    @@ -1505,7 +1505,7 @@

    /User
    -

    /Users/ibon/js/CAAT/src/WebGL/ColorProgram.js

    +

    ./src/WebGL/ColorProgram.js

    @@ -1517,7 +1517,7 @@

    /Us
    -

    /Users/ibon/js/CAAT/src/WebGL/GLU.js

    +

    ./src/WebGL/GLU.js

    @@ -1529,7 +1529,7 @@

    /Users/ibon/
    -

    /Users/ibon/js/CAAT/src/WebGL/Program.js

    +

    ./src/WebGL/Program.js

    @@ -1541,7 +1541,7 @@

    /Users/i
    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:42 GMT+0100 (CET)
    \ No newline at end of file diff --git a/documentation/jsdoc/index.html b/documentation/jsdoc/index.html index 3fec5a25..0c432f58 100644 --- a/documentation/jsdoc/index.html +++ b/documentation/jsdoc/index.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -1172,7 +1172,7 @@

    String

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:20 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:42 GMT+0100 (CET)
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html b/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html index 9129fdbb..5f2d5d48 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.AlphaBehavior.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -455,7 +455,7 @@

    -
    Defined in: AlphaBehavior.js. +
    Defined in: AlphaBehavior.js.

    @@ -991,7 +991,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html b/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html index 69e3d577..31793dd0 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.Status.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -453,7 +453,7 @@

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

    @@ -654,7 +654,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html b/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html index 52d9d0e7..af7b33aa 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.BaseBehavior.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -453,7 +453,7 @@

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

    @@ -2655,7 +2655,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html b/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html index c1c30037..2e00fb82 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.ContainerBehavior.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -455,7 +455,7 @@

    -
    Defined in: ContainerBehavior.js. +
    Defined in: ContainerBehavior.js.

    @@ -1463,7 +1463,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html b/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html index 3d854425..652e08b8 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.GenericBehavior.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -455,7 +455,7 @@

    -
    Defined in: GenericBehavior.js. +
    Defined in: GenericBehavior.js.

    @@ -871,7 +871,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html b/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html index b76a40d8..5a87bca0 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.Interpolator.html @@ -12,7 +12,7 @@ body { font: 12px "Lucida Grande", Tahoma, Arial, Helvetica, sans-serif; - width: 940px; + width: 800px; } .header @@ -48,7 +48,7 @@ { margin-top: 24px; float: left; - width: 300px; + width: 160px; position: absolute; left: 8px; background-color: #F3F3F3; @@ -57,7 +57,7 @@ #content { - margin-left: 340px; + margin-left: 190px; width: 600px; } @@ -453,7 +453,7 @@

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

    @@ -1551,7 +1551,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Mon Jul 01 2013 04:59:15 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.4.0 on Wed Dec 11 2013 17:13:40 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.AUTOROTATE.html b/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.AUTOROTATE.html new file mode 100644 index 00000000..b7153332 --- /dev/null +++ b/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 Wed Dec 11 2013 17:13:40 GMT+0100 (CET) +
    + + diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html b/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html index 0cd3ba4c..89697474 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.PathBehavior.autorotate.html @@ -5,14 +5,14 @@ - JsDoc Reference - CAAT.Behavior.PathBehavior.AUTOROTATE + JsDoc Reference - CAAT.Behavior.PathBehavior.autorotate + + + + + + + + + +
    + + +
    +

    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 Wed Dec 11 2013 17:13:40 GMT+0100 (CET) +
    + + diff --git a/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html b/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html index fda029fd..c2a1cbf8 100644 --- a/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html +++ b/documentation/jsdoc/symbols/CAAT.Behavior.Scale1Behavior.Axis.html @@ -5,14 +5,14 @@ - JsDoc Reference - CAAT.Behavior.Scale1Behavior.AXIS + JsDoc Reference - CAAT.Behavior.Scale1Behavior.Axis + + + + + + + + + +
    + + +
    +

    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 Wed Dec 11 2013 17:13:41 GMT+0100 (CET) +
    + + diff --git a/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html b/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html index 38ecc5ea..a041c4b7 100644 --- a/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html +++ b/documentation/jsdoc/symbols/CAAT.Foundation.ActorContainer.AddHint.html @@ -5,14 +5,14 @@ - JsDoc Reference - CAAT.Foundation.ActorContainer.ADDHINT + JsDoc Reference - CAAT.Foundation.ActorContainer.AddHint
      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/documentation/jsdoc/symbols/src/src_Behavior_BaseBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_BaseBehavior.js.html new file mode 100644 index 00000000..e8aadd21 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_ContainerBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_ContainerBehavior.js.html new file mode 100644 index 00000000..c04f6a46 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_GenericBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_GenericBehavior.js.html new file mode 100644 index 00000000..2b46f494 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_Interpolator.js.html b/documentation/jsdoc/symbols/src/src_Behavior_Interpolator.js.html new file mode 100644 index 00000000..f39c05c2 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_PathBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_PathBehavior.js.html new file mode 100644 index 00000000..8439fe23 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_RotateBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_RotateBehavior.js.html new file mode 100644 index 00000000..ebce7154 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_Scale1Behavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_Scale1Behavior.js.html new file mode 100644 index 00000000..5b511a71 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Behavior_ScaleBehavior.js.html b/documentation/jsdoc/symbols/src/src_Behavior_ScaleBehavior.js.html new file mode 100644 index 00000000..e5ea8b22 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_CAAT.js.html b/documentation/jsdoc/symbols/src/src_CAAT.js.html new file mode 100644 index 00000000..b3187fa9 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Core_Class.js.html b/documentation/jsdoc/symbols/src/src_Core_Class.js.html new file mode 100644 index 00000000..9ec7d6e8 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Core_Constants.js.html b/documentation/jsdoc/symbols/src/src_Core_Constants.js.html new file mode 100644 index 00000000..160df33d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Core_ModuleManager.js.html b/documentation/jsdoc/symbols/src/src_Core_ModuleManager.js.html new file mode 100644 index 00000000..4e87cbe7 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Event_AnimationLoop.js.html b/documentation/jsdoc/symbols/src/src_Event_AnimationLoop.js.html new file mode 100644 index 00000000..04b3cc8f --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Event_Input.js.html b/documentation/jsdoc/symbols/src/src_Event_Input.js.html new file mode 100644 index 00000000..ea36b441 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Event_KeyEvent.js.html b/documentation/jsdoc/symbols/src/src_Event_KeyEvent.js.html new file mode 100644 index 00000000..c4751384 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Event_MouseEvent.js.html b/documentation/jsdoc/symbols/src/src_Event_MouseEvent.js.html new file mode 100644 index 00000000..088cb2a6 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Event_MouseEvent.js.html @@ -0,0 +1,122 @@ +
      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 		 * Wheel delta, negative value for scrolling up, positive for scrolling down
    + 73 		 */
    + 74 		wheelDelta:     0,
    + 75 
    + 76         /**
    + 77          * Original mouse/touch event
    + 78          */
    + 79         sourceEvent:    null,
    + 80 
    + 81         touches     :   null,
    + 82 
    + 83 		init : function( x,y,sourceEvent,source,screenPoint,time ) {
    + 84 			this.point.set(x,y);
    + 85 			this.source =       source;
    + 86 			this.screenPoint =  screenPoint;
    + 87             this.alt =          sourceEvent.altKey;
    + 88             this.control =      sourceEvent.ctrlKey;
    + 89             this.shift =        sourceEvent.shiftKey;
    + 90             this.meta =         sourceEvent.metaKey;
    + 91             this.wheelDelta =   sourceEvent.wheelDelta;
    + 92             this.sourceEvent =  sourceEvent;
    + 93             this.x =            x;
    + 94             this.y =            y;
    + 95             this.time =         time;
    + 96 			return this;
    + 97 		},
    + 98 		isAltDown : function() {
    + 99 			return this.alt;
    +100 		},
    +101 		isControlDown : function() {
    +102 			return this.control;
    +103 		},
    +104 		isShiftDown : function() {
    +105 			return this.shift;
    +106 		},
    +107         isMetaDown: function() {
    +108             return this.meta;
    +109         },
    +110         getSourceEvent : function() {
    +111             return this.sourceEvent;
    +112         }
    +113 	}
    +114 });
    +115 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Event_TouchEvent.js.html b/documentation/jsdoc/symbols/src/src_Event_TouchEvent.js.html new file mode 100644 index 00000000..1e0ab931 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Event_TouchInfo.js.html b/documentation/jsdoc/symbols/src/src_Event_TouchInfo.js.html new file mode 100644 index 00000000..29524ee7 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Actor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Actor.js.html new file mode 100644 index 00000000..6494cff9 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Foundation_Actor.js.html @@ -0,0 +1,2606 @@ +
      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.modelViewMatrixI = new CAAT.Math.Matrix();
    +110                 this.worldModelViewMatrix = new CAAT.Math.Matrix();
    +111                 this.worldModelViewMatrixI = new CAAT.Math.Matrix();
    +112 
    +113                 this.resetTransform();
    +114                 this.setScale(1, 1);
    +115                 this.setRotation(0);
    +116 
    +117                 this.id = __index++;
    +118 
    +119                 return this;
    +120             },
    +121 
    +122             /**
    +123              * @type {object}
    +124              */
    +125             __super : null,
    +126 
    +127             /**
    +128              * A collection of this Actors lifecycle observers.
    +129              * @type { Array.<{actorLifeCycleEvent : function( CAAT.Foundation.Actor, string, number ) }> }
    +130              */
    +131             lifecycleListenerList:null,
    +132 
    +133             /**
    +134              * A collection of behaviors to modify this actor´s properties.
    +135              * @type { Array.<CAAT.Behavior.Behavior> }
    +136              */
    +137             behaviorList:null,
    +138 
    +139             /**
    +140              * This actor's parent container.
    +141              * @type { CAAT.Foundation.ActorContainer }
    +142              */
    +143             parent:null, // Parent of this Actor. May be Scene.
    +144 
    +145             /**
    +146              * x position on parent. In parent's local coord. system.
    +147              * @type {number}
    +148              */
    +149             x:0,
    +150             /**
    +151              * y position on parent. In parent's local coord. system.
    +152              * @type {number}
    +153              */
    +154             y:0,
    +155 
    +156             /**
    +157              * Actor's width. In parent's local coord. system.
    +158              * @type {number}
    +159              */
    +160             width:0,
    +161 
    +162             /**
    +163              * Actor's height. In parent's local coord. system.
    +164              * @type {number}
    +165              */
    +166             height:0,
    +167 
    +168             /**
    +169              * actor´s layout preferred size.
    +170              * @type {CAAT.Math.Dimension}
    +171              */
    +172             preferredSize:null,
    +173 
    +174             /**
    +175              * actor's layout minimum size.
    +176              * @type {CAAT.Math.Dimension}
    +177              */
    +178             minimumSize:null,
    +179 
    +180             /**
    +181              * Marks since when this actor, relative to scene time, is going to be animated/drawn.
    +182              * @type {number}
    +183              */
    +184             start_time:0,
    +185 
    +186             /**
    +187              * Marks from the time this actor is going to be animated, during how much time.
    +188              * Forever by default.
    +189              * @type {number}
    +190              */
    +191             duration:Number.MAX_VALUE,
    +192 
    +193             /**
    +194              * Will this actor be clipped before being drawn on screen ?
    +195              * @type {boolean}
    +196              */
    +197             clip:false,
    +198 
    +199             /**
    +200              * If this.clip and this.clipPath===null, a rectangle will be used as clip area. Otherwise,
    +201              * clipPath contains a reference to a CAAT.PathUtil.Path object.
    +202              * @type {CAAT.PathUtil.Path}
    +203              */
    +204             clipPath:null,
    +205 
    +206             /**
    +207              * Translation x anchor. 0..1
    +208              * @type {number}
    +209              */
    +210             tAnchorX:0,
    +211 
    +212             /**
    +213              * Translation y anchor. 0..1
    +214              * @type {number}
    +215              */
    +216             tAnchorY:0,
    +217 
    +218             /**
    +219              * ScaleX value.
    +220              * @type {number}
    +221              */
    +222             scaleX:1, // transformation. width scale parameter
    +223 
    +224             /**
    +225              * ScaleY value.
    +226              * @type {number}
    +227              */
    +228             scaleY:1, // transformation. height scale parameter
    +229 
    +230             /**
    +231              * Scale Anchor X. Value 0-1
    +232              * @type {number}
    +233              */
    +234             scaleTX:.50, // transformation. scale anchor x position
    +235 
    +236             /**
    +237              * Scale Anchor Y. Value 0-1
    +238              * @type {number}
    +239              */
    +240             scaleTY:.50, // transformation. scale anchor y position
    +241 
    +242             /**
    +243              * A value that corresponds to any CAAT.Foundation.Actor.ANCHOR_* value.
    +244              * @type {CAAT.Foundation.Actor.ANCHOR_*}
    +245              */
    +246             scaleAnchor:0, // transformation. scale anchor
    +247 
    +248             /**
    +249              * This actor´s rotation angle in radians.
    +250              * @type {number}
    +251              */
    +252             rotationAngle:0, // transformation. rotation angle in radians
    +253 
    +254             /**
    +255              * Rotation Anchor X. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
    +256              * @type {number}
    +257              */
    +258             rotationY:.50, // transformation. rotation center y
    +259 
    +260             /**
    +261              * Rotation Anchor Y. CAAT uses different Anchors for position, rotation and scale. Value 0-1.
    +262              * @type {number}
    +263              */
    +264             rotationX:.50, // transformation. rotation center x
    +265 
    +266             /**
    +267              * Transparency value. 0 is totally transparent, 1 is totally opaque.
    +268              * @type {number}
    +269              */
    +270             alpha:1, // alpha transparency value
    +271 
    +272             /**
    +273              * true to make all children transparent, false, only this actor/container will be transparent.
    +274              * @type {boolean}
    +275              */
    +276             isGlobalAlpha:false, // is this a global alpha
    +277 
    +278             /**
    +279              * @type {number}
    +280              * @private
    +281              */
    +282             frameAlpha:1, // hierarchically calculated alpha for this Actor.
    +283 
    +284             /**
    +285              * Mark this actor as expired, or out of the scene time.
    +286              * @type {boolean}
    +287              */
    +288             expired:false,
    +289 
    +290             /**
    +291              * Mark this actor as discardable. If an actor is expired and mark as discardable, if will be
    +292              * removed from its parent.
    +293              * @type {boolean}
    +294              */
    +295             discardable:false, // set when you want this actor to be removed if expired
    +296 
    +297             /**
    +298              * @type {boolean}
    +299              */
    +300             pointed:false, // is the mouse pointer inside this actor
    +301 
    +302             /**
    +303              * Enable or disable input on this actor. By default, all actors receive input.
    +304              * See also priority lists.
    +305              * see demo4 for an example of input and priority lists.
    +306              * @type {boolean}
    +307              */
    +308             mouseEnabled:true, // events enabled ?
    +309 
    +310             /**
    +311              * Make this actor visible or not.
    +312              * An invisible actor avoids making any calculation, applying any behavior on it.
    +313              * @type {boolean}
    +314              */
    +315             visible:true,
    +316 
    +317             /**
    +318              * any canvas rendering valid fill style.
    +319              * @type {string}
    +320              */
    +321             fillStyle:null,
    +322 
    +323             /**
    +324              * any canvas rendering valid stroke style.
    +325              * @type {string}
    +326              */
    +327             strokeStyle:null,
    +328 
    +329             /**
    +330              * This actor´s scene time.
    +331              * @type {number}
    +332              */
    +333             time:0, // Cache Scene time.
    +334 
    +335             /**
    +336              * This rectangle keeps the axis aligned bounding box in screen coords of this actor.
    +337              * In can be used, among other uses, to realize whether two given actors collide regardless
    +338              * the affine transformation is being applied on them.
    +339              * @type {CAAT.Math.Rectangle}
    +340              */
    +341             AABB:null,
    +342 
    +343             /**
    +344              * These 4 CAAT.Math.Point objects are the vertices of this actor´s non axis aligned bounding
    +345              * box. If the actor is not rotated, viewVertices and AABB define the same bounding box.
    +346              * @type {Array.<CAAT.Math.Point>}
    +347              */
    +348             viewVertices:null, // model to view transformed vertices.
    +349 
    +350             /**
    +351              * Is this actor processed in the last frame ?
    +352              * @type {boolean}
    +353              */
    +354             inFrame:false, // boolean indicating whether this Actor was present on last frame.
    +355 
    +356             /**
    +357              * Local matrix dirtyness flag.
    +358              * @type {boolean}
    +359              * @private
    +360              */
    +361             dirty:true, // model view is dirty ?
    +362 
    +363             /**
    +364              * Global matrix dirtyness flag.
    +365              * @type {boolean}
    +366              * @private
    +367              */
    +368             wdirty:true, // world model view is dirty ?
    +369 
    +370             /**
    +371              * @type {number}
    +372              * @private
    +373              */
    +374             oldX:-1,
    +375 
    +376             /**
    +377              * @type {number}
    +378              * @private
    +379              */
    +380             oldY:-1,
    +381 
    +382             /**
    +383              * This actor´s affine transformation matrix.
    +384              * @type {CAAT.Math.Matrix}
    +385              */
    +386             modelViewMatrix:null, // model view matrix.
    +387 
    +388             /**
    +389              * This actor´s world affine transformation matrix.
    +390              * @type {CAAT.Math.Matrix}
    +391              */
    +392             worldModelViewMatrix:null, // world model view matrix.
    +393 
    +394             /**
    +395              * @type {CAAT.Math.Matrix}
    +396              */
    +397             modelViewMatrixI:null, // model view matrix.
    +398 
    +399             /**
    +400              * @type {CAAT.Math.Matrix}
    +401              */
    +402             worldModelViewMatrixI:null, // world model view matrix.
    +403 
    +404             /**
    +405              * Is this actor enabled on WebGL ?
    +406              * @type {boolean}
    +407              */
    +408             glEnabled:false,
    +409 
    +410             /**
    +411              * Define this actor´s background image.
    +412              * See SpriteImage object.
    +413              * @type {CAAT.Foundation.SpriteImage}
    +414              */
    +415             backgroundImage:null,
    +416 
    +417             /**
    +418              * Set this actor´ id so that it can be later identified easily.
    +419              * @type {object}
    +420              */
    +421             id:null,
    +422 
    +423             /**
    +424              * debug info.
    +425              * @type {number}
    +426              */
    +427             size_active:1, // number of animated children
    +428 
    +429             /**
    +430              * debug info.
    +431              * @type {number}
    +432              */
    +433             size_total:1,
    +434 
    +435             __d_ax:-1, // for drag-enabled actors.
    +436             __d_ay:-1,
    +437 
    +438             /**
    +439              * Is gesture recognition enabled on this actor ??
    +440              * @type {boolean}
    +441              */
    +442             gestureEnabled:false,
    +443 
    +444             /**
    +445              * If dirty rects are enabled, this flag indicates the rendering engine to invalidate this
    +446              * actor´s screen area.
    +447              * @type {boolean}
    +448              */
    +449             invalid:true,
    +450 
    +451             /**
    +452              * Caching as bitmap strategy. Suitable to cache very complex actors.
    +453              *
    +454              * 0 : no cache.
    +455              * CACHE_SIMPLE : if a container, only cache the container.
    +456              * CACHE_DEEP : if a container, cache the container and recursively all of its children.
    +457              *
    +458              * @type {number}
    +459              */
    +460             cached:0, // 0 no, CACHE_SIMPLE | CACHE_DEEP
    +461 
    +462             /**
    +463              * Exclude this actor from automatic layout on its parent.
    +464              * @type {boolean}
    +465              */
    +466             preventLayout : false,
    +467 
    +468             /**
    +469              * is this actor/container Axis aligned ? if so, much faster inverse matrices can be calculated.
    +470              * @type {boolean}
    +471              * @private
    +472              */
    +473             isAA:true,
    +474 
    +475             /**
    +476              * if this actor is cached, when destroy is called, it does not call 'clean' method, which clears some
    +477              * internal properties.
    +478              */
    +479             isCachedActor : false,
    +480 
    +481             setCachedActor : function(cached) {
    +482                 this.isCachedActor= cached;
    +483                 return this;
    +484             },
    +485 
    +486             /**
    +487              * Make this actor not be laid out.
    +488              */
    +489             setPreventLayout : function(b) {
    +490                 this.preventLayout= b;
    +491                 return this;
    +492             },
    +493 
    +494             invalidateLayout:function () {
    +495                 if (this.parent && !this.parent.layoutInvalidated) {
    +496                     this.parent.invalidateLayout();
    +497                 }
    +498 
    +499                 return this;
    +500             },
    +501 
    +502             __validateLayout:function () {
    +503 
    +504             },
    +505 
    +506             /**
    +507              * Set this actors preferred layout size.
    +508              *
    +509              * @param pw {number}
    +510              * @param ph {number}
    +511              * @return {*}
    +512              */
    +513             setPreferredSize:function (pw, ph) {
    +514                 if (!this.preferredSize) {
    +515                     this.preferredSize = new CAAT.Math.Dimension();
    +516                 }
    +517                 this.preferredSize.width = pw;
    +518                 this.preferredSize.height = ph;
    +519                 return this;
    +520             },
    +521 
    +522             getPreferredSize:function () {
    +523                 return this.preferredSize ? this.preferredSize :
    +524                     this.getMinimumSize();
    +525             },
    +526 
    +527             /**
    +528              * Set this actors minimum layout size.
    +529              *
    +530              * @param pw {number}
    +531              * @param ph {number}
    +532              * @return {*}
    +533              */
    +534             setMinimumSize:function (pw, ph) {
    +535                 if (!this.minimumSize) {
    +536                     this.minimumSize = new CAAT.Math.Dimension();
    +537                 }
    +538 
    +539                 this.minimumSize.width = pw;
    +540                 this.minimumSize.height = ph;
    +541                 return this;
    +542             },
    +543 
    +544             getMinimumSize:function () {
    +545                 return this.minimumSize ? this.minimumSize :
    +546                     new CAAT.Math.Dimension(this.width, this.height);
    +547             },
    +548 
    +549             /**
    +550              * @deprecated
    +551              * @return {*}
    +552              */
    +553             create:function () {
    +554                 return this;
    +555             },
    +556             /**
    +557              * Move this actor to a position.
    +558              * It creates and adds a new PathBehavior.
    +559              * @param x {number} new x position
    +560              * @param y {number} new y position
    +561              * @param duration {number} time to take to get to new position
    +562              * @param delay {=number} time to wait before start moving
    +563              * @param interpolator {=CAAT.Behavior.Interpolator} a CAAT.Behavior.Interpolator instance
    +564              */
    +565             moveTo:function (x, y, duration, delay, interpolator, callback) {
    +566 
    +567                 if (x === this.x && y === this.y) {
    +568                     return;
    +569                 }
    +570 
    +571                 var id = '__moveTo';
    +572                 var b = this.getBehavior(id);
    +573                 if (!b) {
    +574                     b = new CAAT.Behavior.PathBehavior().
    +575                         setId(id).
    +576                         setValues(new CAAT.PathUtil.LinearPath());
    +577                     this.addBehavior(b);
    +578                 }
    +579 
    +580                 b.path.setInitialPosition(this.x, this.y).setFinalPosition(x, y);
    +581                 b.setDelayTime(delay ? delay : 0, duration);
    +582                 if (interpolator) {
    +583                     b.setInterpolator(interpolator);
    +584                 }
    +585 
    +586                 if (callback) {
    +587                     b.lifecycleListenerList = [];
    +588                     b.addListener({
    +589                         behaviorExpired:function (behavior, time, actor) {
    +590                             callback(behavior, time, actor);
    +591                         }
    +592                     });
    +593                 }
    +594 
    +595                 return this;
    +596             },
    +597 
    +598             /**
    +599              *
    +600              * @param angle {number} new rotation angle
    +601              * @param duration {number} time to rotate
    +602              * @param delay {number=} millis to start rotation
    +603              * @param anchorX {number=} rotation anchor x
    +604              * @param anchorY {number=} rotation anchor y
    +605              * @param interpolator {CAAT.Behavior.Interpolator=}
    +606              * @return {*}
    +607              */
    +608             rotateTo:function (angle, duration, delay, anchorX, anchorY, interpolator) {
    +609 
    +610                 if (angle === this.rotationAngle) {
    +611                     return;
    +612                 }
    +613 
    +614                 var id = '__rotateTo';
    +615                 var b = this.getBehavior(id);
    +616                 if (!b) {
    +617                     b = new CAAT.Behavior.RotateBehavior().
    +618                         setId(id).
    +619                         setValues(0, 0, .5, .5);
    +620                     this.addBehavior(b);
    +621                 }
    +622 
    +623                 b.setValues(this.rotationAngle, angle, anchorX, anchorY).
    +624                     setDelayTime(delay ? delay : 0, duration);
    +625 
    +626                 if (interpolator) {
    +627                     b.setInterpolator(interpolator);
    +628                 }
    +629 
    +630                 return this;
    +631             },
    +632 
    +633             /**
    +634              *
    +635              * @param scaleX {number} new X scale
    +636              * @param scaleY {number} new Y scale
    +637              * @param duration {number} time to rotate
    +638              * @param delay {=number} millis to start rotation
    +639              * @param anchorX {=number} rotation anchor x
    +640              * @param anchorY {=number} rotation anchor y
    +641              * @param interpolator {=CAAT.Behavior.Interpolator}
    +642              * @return {*}
    +643              */
    +644             scaleTo:function (scaleX, scaleY, duration, delay, anchorX, anchorY, interpolator) {
    +645 
    +646                 if (this.scaleX === scaleX && this.scaleY === scaleY) {
    +647                     return;
    +648                 }
    +649 
    +650                 var id = '__scaleTo';
    +651                 var b = this.getBehavior(id);
    +652                 if (!b) {
    +653                     b = new CAAT.Behavior.ScaleBehavior().
    +654                         setId(id).
    +655                         setValues(1, 1, 1, 1, .5, .5);
    +656                     this.addBehavior(b);
    +657                 }
    +658 
    +659                 b.setValues(this.scaleX, scaleX, this.scaleY, scaleY, anchorX, anchorY).
    +660                     setDelayTime(delay ? delay : 0, duration);
    +661 
    +662                 if (interpolator) {
    +663                     b.setInterpolator(interpolator);
    +664                 }
    +665 
    +666                 return this;
    +667             },
    +668 
    +669             /**
    +670              *
    +671              * @param scaleX {number} new X scale
    +672              * @param duration {number} time to rotate
    +673              * @param delay {=number} millis to start rotation
    +674              * @param anchorX {=number} rotation anchor x
    +675              * @param anchorY {=number} rotation anchor y
    +676              * @param interpolator {=CAAT.Behavior.Interpolator}
    +677              * @return {*}
    +678              */
    +679             scaleXTo:function (scaleX, duration, delay, anchorX, anchorY, interpolator) {
    +680                 return this.__scale1To(
    +681                     CAAT.Behavior.Scale1Behavior.AXIS_X,
    +682                     scaleX,
    +683                     duration,
    +684                     delay,
    +685                     anchorX,
    +686                     anchorY,
    +687                     interpolator
    +688                 );
    +689             },
    +690 
    +691             /**
    +692              *
    +693              * @param scaleY {number} new Y scale
    +694              * @param duration {number} time to rotate
    +695              * @param delay {=number} millis to start rotation
    +696              * @param anchorX {=number} rotation anchor x
    +697              * @param anchorY {=number} rotation anchor y
    +698              * @param interpolator {=CAAT.Behavior.Interpolator}
    +699              * @return {*}
    +700              */
    +701             scaleYTo:function (scaleY, duration, delay, anchorX, anchorY, interpolator) {
    +702                 return this.__scale1To(
    +703                     CAAT.Behavior.Scale1Behavior.AXIS_Y,
    +704                     scaleY,
    +705                     duration,
    +706                     delay,
    +707                     anchorX,
    +708                     anchorY,
    +709                     interpolator
    +710                 );
    +711             },
    +712 
    +713             /**
    +714              * @param axis {CAAT.Scale1Behavior.AXIS_X|CAAT.Scale1Behavior.AXIS_Y} scale application axis
    +715              * @param scale {number} new Y scale
    +716              * @param duration {number} time to rotate
    +717              * @param delay {=number} millis to start rotation
    +718              * @param anchorX {=number} rotation anchor x
    +719              * @param anchorY {=number} rotation anchor y
    +720              * @param interpolator {=CAAT.Bahavior.Interpolator}
    +721              * @return {*}
    +722              */
    +723             __scale1To:function (axis, scale, duration, delay, anchorX, anchorY, interpolator) {
    +724 
    +725                 if (( axis === CAAT.Behavior.Scale1Behavior.AXIS_X && scale === this.scaleX) ||
    +726                     ( axis === CAAT.Behavior.Scale1Behavior.AXIS_Y && scale === this.scaleY)) {
    +727 
    +728                     return;
    +729                 }
    +730 
    +731                 var id = '__scaleXTo';
    +732                 var b = this.getBehavior(id);
    +733                 if (!b) {
    +734                     b = new CAAT.Behavior.Scale1Behavior().
    +735                         setId(id).
    +736                         setValues(1, 1, axis === CAAT.Behavior.Scale1Behavior.AXIS_X, .5, .5);
    +737                     this.addBehavior(b);
    +738                 }
    +739 
    +740                 b.setValues(
    +741                     axis ? this.scaleX : this.scaleY,
    +742                     scale,
    +743                     anchorX,
    +744                     anchorY).
    +745                     setDelayTime(delay ? delay : 0, duration);
    +746 
    +747                 if (interpolator) {
    +748                     b.setInterpolator(interpolator);
    +749                 }
    +750 
    +751                 return this;
    +752             },
    +753 
    +754             /**
    +755              * Touch Start only received when CAAT.TOUCH_BEHAVIOR= CAAT.TOUCH_AS_MULTITOUCH
    +756              * @param e <CAAT.TouchEvent>
    +757              */
    +758             touchStart:function (e) {
    +759             },
    +760             touchMove:function (e) {
    +761             },
    +762             touchEnd:function (e) {
    +763             },
    +764             gestureStart:function (rotation, scaleX, scaleY) {
    +765             },
    +766             gestureChange:function (rotation, scaleX, scaleY) {
    +767                 if (this.gestureEnabled) {
    +768                     this.setRotation(rotation);
    +769                     this.setScale(scaleX, scaleY);
    +770                 }
    +771                 return this;
    +772             },
    +773             gestureEnd:function (rotation, scaleX, scaleY) {
    +774             },
    +775 
    +776             isVisible:function () {
    +777                 return this.visible;
    +778             },
    +779 
    +780             invalidate:function () {
    +781                 this.invalid = true;
    +782                 return this;
    +783             },
    +784             setGestureEnabled:function (enable) {
    +785                 this.gestureEnabled = !!enable;
    +786                 return this;
    +787             },
    +788             isGestureEnabled:function () {
    +789                 return this.gestureEnabled;
    +790             },
    +791             getId:function () {
    +792                 return this.id;
    +793             },
    +794             setId:function (id) {
    +795                 this.id = id;
    +796                 return this;
    +797             },
    +798             /**
    +799              * Set this actor's parent.
    +800              * @param parent {CAAT.Foundation.ActorContainer}
    +801              * @return this
    +802              */
    +803             setParent:function (parent) {
    +804                 this.parent = parent;
    +805                 return this;
    +806             },
    +807             /**
    +808              * Set this actor's background image.
    +809              * The need of a background image is to kept compatibility with the new CSSDirector class.
    +810              * The image parameter can be either an Image/Canvas or a CAAT.Foundation.SpriteImage instance. If an image
    +811              * is supplied, it will be wrapped into a CAAT.Foundation.SriteImage instance of 1 row by 1 column.
    +812              * If the actor has set an image in the background, the paint method will draw the image, otherwise
    +813              * and if set, will fill its background with a solid color.
    +814              * If adjust_size_to_image is true, the host actor will be redimensioned to the size of one
    +815              * single image from the SpriteImage (either supplied or generated because of passing an Image or
    +816              * Canvas to the function). That means the size will be set to [width:SpriteImage.singleWidth,
    +817              * height:singleHeight].
    +818              *
    +819              * WARN: if using a CSS renderer, the image supplied MUST be a HTMLImageElement instance.
    +820              *
    +821              * @see CAAT.Foundation.SpriteImage
    +822              *
    +823              * @param image {Image|HTMLCanvasElement|CAAT.Foundation.SpriteImage}
    +824              * @param adjust_size_to_image {boolean} whether to set this actor's size based on image parameter.
    +825              *
    +826              * @return this
    +827              */
    +828             setBackgroundImage:function (image, adjust_size_to_image) {
    +829                 if (image) {
    +830                     if (!(image instanceof CAAT.Foundation.SpriteImage)) {
    +831                         if ( isString(image) ) {
    +832                             image = new CAAT.Foundation.SpriteImage().initialize(CAAT.currentDirector.getImage(image), 1, 1);
    +833                         } else {
    +834                             image = new CAAT.Foundation.SpriteImage().initialize(image, 1, 1);
    +835                         }
    +836                     } else {
    +837                         image= image.getRef();
    +838                     }
    +839 
    +840                     image.setOwner(this);
    +841                     this.backgroundImage = image;
    +842                     if (typeof adjust_size_to_image === 'undefined' || adjust_size_to_image) {
    +843                         this.width = image.getWidth();
    +844                         this.height = image.getHeight();
    +845                     }
    +846 
    +847                     this.glEnabled = true;
    +848 
    +849                     this.invalidate();
    +850 
    +851                 } else {
    +852                     this.backgroundImage = null;
    +853                 }
    +854 
    +855                 return this;
    +856             },
    +857             /**
    +858              * Set the actor's SpriteImage index from animation sheet.
    +859              * @see CAAT.Foundation.SpriteImage
    +860              * @param index {number}
    +861              *
    +862              * @return this
    +863              */
    +864             setSpriteIndex:function (index) {
    +865                 if (this.backgroundImage) {
    +866                     this.backgroundImage.setSpriteIndex(index);
    +867                     this.invalidate();
    +868                 }
    +869 
    +870                 return this;
    +871 
    +872             },
    +873             /**
    +874              * Set this actor's background SpriteImage offset displacement.
    +875              * The values can be either positive or negative meaning the texture space of this background
    +876              * image does not start at (0,0) but at the desired position.
    +877              * @see CAAT.Foundation.SpriteImage
    +878              * @param ox {number} horizontal offset
    +879              * @param oy {number} vertical offset
    +880              *
    +881              * @return this
    +882              */
    +883             setBackgroundImageOffset:function (ox, oy) {
    +884                 if (this.backgroundImage) {
    +885                     this.backgroundImage.setOffset(ox, oy);
    +886                 }
    +887 
    +888                 return this;
    +889             },
    +890             /**
    +891              * Set this actor's background SpriteImage its animation sequence.
    +892              * In its simplet's form a SpriteImage treats a given image as an array of rows by columns
    +893              * subimages. If you define d Sprite Image of 2x2, you'll be able to draw any of the 4 subimages.
    +894              * This method defines the animation sequence so that it could be set [0,2,1,3,2,1] as the
    +895              * animation sequence
    +896              * @param ii {Array<number>} an array of integers.
    +897              */
    +898             setAnimationImageIndex:function (ii) {
    +899                 if (this.backgroundImage) {
    +900                     this.backgroundImage.resetAnimationTime();
    +901                     this.backgroundImage.setAnimationImageIndex(ii);
    +902                     this.invalidate();
    +903                 }
    +904                 return this;
    +905             },
    +906 
    +907             addAnimation : function( name, array, time, callback ) {
    +908                 if (this.backgroundImage) {
    +909                     this.backgroundImage.addAnimation(name, array, time, callback);
    +910                 }
    +911                 return this;
    +912             },
    +913 
    +914             playAnimation : function(name) {
    +915                 if (this.backgroundImage) {
    +916                     this.backgroundImage.playAnimation(name);
    +917                 }
    +918                 return this;
    +919             },
    +920 
    +921             setAnimationEndCallback : function(f) {
    +922                 if (this.backgroundImage) {
    +923                     this.backgroundImage.setAnimationEndCallback(f);
    +924                 }
    +925                 return this;
    +926             },
    +927 
    +928             resetAnimationTime:function () {
    +929                 if (this.backgroundImage) {
    +930                     this.backgroundImage.resetAnimationTime();
    +931                     this.invalidate();
    +932                 }
    +933                 return this;
    +934             },
    +935 
    +936             setChangeFPS:function (time) {
    +937                 if (this.backgroundImage) {
    +938                     this.backgroundImage.setChangeFPS(time);
    +939                 }
    +940                 return this;
    +941 
    +942             },
    +943             /**
    +944              * Set this background image transformation.
    +945              * If GL is enabled, this parameter has no effect.
    +946              * @param it any value from CAAT.Foundation.SpriteImage.TR_*
    +947              * @return this
    +948              */
    +949             setImageTransformation:function (it) {
    +950                 if (this.backgroundImage) {
    +951                     this.backgroundImage.setSpriteTransformation(it);
    +952                 }
    +953                 return this;
    +954             },
    +955             /**
    +956              * Center this actor at position (x,y).
    +957              * @param x {number} x position
    +958              * @param y {number} y position
    +959              *
    +960              * @return this
    +961              * @deprecated
    +962              */
    +963             centerOn:function (x, y) {
    +964                 this.setPosition(x - this.width / 2, y - this.height / 2);
    +965                 return this;
    +966             },
    +967             /**
    +968              * Center this actor at position (x,y).
    +969              * @param x {number} x position
    +970              * @param y {number} y position
    +971              *
    +972              * @return this
    +973              */
    +974             centerAt:function (x, y) {
    +975                 this.setPosition(
    +976                     x - this.width * (.5 - this.tAnchorX ),
    +977                     y - this.height * (.5 - this.tAnchorY ) );
    +978                 return this;
    +979             },
    +980             /**
    +981              * If GL is enables, get this background image's texture page, otherwise it will fail.
    +982              * @return {CAAT.GLTexturePage}
    +983              */
    +984             getTextureGLPage:function () {
    +985                 return this.backgroundImage.image.__texturePage;
    +986             },
    +987             /**
    +988              * Set this actor invisible.
    +989              * The actor is animated but not visible.
    +990              * A container won't show any of its children if set visible to false.
    +991              *
    +992              * @param visible {boolean} set this actor visible or not.
    +993              * @return this
    +994              */
    +995             setVisible:function (visible) {
    +996                 this.invalidate();
    +997                 // si estoy visible y quiero hacerme no visible
    +998                 if (CAAT.currentDirector && CAAT.currentDirector.dirtyRectsEnabled && !visible && this.visible) {
    +999                     // if dirty rects, add this actor
    +1000                     CAAT.currentDirector.scheduleDirtyRect(this.AABB);
    +1001                 }
    +1002 
    +1003                 if ( visible && !this.visible) {
    +1004                     this.dirty= true;
    +1005                 }
    +1006 
    +1007                 this.visible = visible;
    +1008                 return this;
    +1009             },
    +1010             /**
    +1011              * Puts an Actor out of time line, that is, won't be transformed nor rendered.
    +1012              * @return this
    +1013              */
    +1014             setOutOfFrameTime:function () {
    +1015                 this.setFrameTime(-1, 0);
    +1016                 return this;
    +1017             },
    +1018             /**
    +1019              * Adds an Actor's life cycle listener.
    +1020              * The developer must ensure the actorListener is not already a listener, otherwise
    +1021              * it will notified more than once.
    +1022              * @param actorListener {object} an object with at least a method of the form:
    +1023              * <code>actorLyfeCycleEvent( actor, string_event_type, long_time )</code>
    +1024              */
    +1025             addListener:function (actorListener) {
    +1026                 this.lifecycleListenerList.push(actorListener);
    +1027                 return this;
    +1028             },
    +1029             /**
    +1030              * Removes an Actor's life cycle listener.
    +1031              * It will only remove the first occurrence of the given actorListener.
    +1032              * @param actorListener {object} an Actor's life cycle listener.
    +1033              */
    +1034             removeListener:function (actorListener) {
    +1035                 var n = this.lifecycleListenerList.length;
    +1036                 while (n--) {
    +1037                     if (this.lifecycleListenerList[n] === actorListener) {
    +1038                         // remove the nth element.
    +1039                         this.lifecycleListenerList.splice(n, 1);
    +1040                         return;
    +1041                     }
    +1042                 }
    +1043             },
    +1044             /**
    +1045              * Set alpha composition scope. global will mean this alpha value will be its children maximum.
    +1046              * If set to false, only this actor will have this alpha value.
    +1047              * @param global {boolean} whether the alpha value should be propagated to children.
    +1048              */
    +1049             setGlobalAlpha:function (global) {
    +1050                 this.isGlobalAlpha = global;
    +1051                 return this;
    +1052             },
    +1053             /**
    +1054              * Notifies the registered Actor's life cycle listener about some event.
    +1055              * @param sEventType an string indicating the type of event being notified.
    +1056              * @param time an integer indicating the time related to Scene's timeline when the event
    +1057              * is being notified.
    +1058              */
    +1059             fireEvent:function (sEventType, time) {
    +1060                 for (var i = 0; i < this.lifecycleListenerList.length; i++) {
    +1061                     this.lifecycleListenerList[i].actorLifeCycleEvent(this, sEventType, time);
    +1062                 }
    +1063             },
    +1064             /**
    +1065              * Sets this Actor as Expired.
    +1066              * If this is a Container, all the contained Actors won't be nor drawn nor will receive
    +1067              * any event. That is, expiring an Actor means totally taking it out the Scene's timeline.
    +1068              * @param time {number} an integer indicating the time the Actor was expired at.
    +1069              * @return this.
    +1070              */
    +1071             setExpired:function (time) {
    +1072                 this.expired = true;
    +1073                 this.fireEvent('expired', time);
    +1074                 return this;
    +1075             },
    +1076             /**
    +1077              * Enable or disable the event bubbling for this Actor.
    +1078              * @param enable {boolean} a boolean indicating whether the event bubbling is enabled.
    +1079              * @return this
    +1080              */
    +1081             enableEvents:function (enable) {
    +1082                 this.mouseEnabled = enable;
    +1083                 return this;
    +1084             },
    +1085             /**
    +1086              * Removes all behaviors from an Actor.
    +1087              * @return this
    +1088              */
    +1089             emptyBehaviorList:function () {
    +1090                 this.behaviorList = [];
    +1091                 return this;
    +1092             },
    +1093             /**
    +1094              * Caches a fillStyle in the Actor.
    +1095              * @param style a valid Canvas rendering context fillStyle.
    +1096              * @return this
    +1097              */
    +1098             setFillStyle:function (style) {
    +1099                 this.fillStyle = style;
    +1100                 this.invalidate();
    +1101                 return this;
    +1102             },
    +1103             /**
    +1104              * Caches a stroke style in the Actor.
    +1105              * @param style a valid canvas rendering context stroke style.
    +1106              * @return this
    +1107              */
    +1108             setStrokeStyle:function (style) {
    +1109                 this.strokeStyle = style;
    +1110                 this.invalidate();
    +1111                 return this;
    +1112             },
    +1113             /**
    +1114              * @deprecated
    +1115              * @param paint
    +1116              */
    +1117             setPaint:function (paint) {
    +1118                 return this.setFillStyle(paint);
    +1119             },
    +1120             /**
    +1121              * Stablishes the Alpha transparency for the Actor.
    +1122              * If it globalAlpha enabled, this alpha will the maximum alpha for every contained actors.
    +1123              * The alpha must be between 0 and 1.
    +1124              * @param alpha a float indicating the alpha value.
    +1125              * @return this
    +1126              */
    +1127             setAlpha:function (alpha) {
    +1128                 this.alpha = alpha;
    +1129                 this.invalidate();
    +1130                 return this;
    +1131             },
    +1132             /**
    +1133              * Remove all transformation values for the Actor.
    +1134              * @return this
    +1135              */
    +1136             resetTransform:function () {
    +1137                 this.rotationAngle = 0;
    +1138                 this.rotationX = .5;
    +1139                 this.rotationY = .5;
    +1140                 this.scaleX = 1;
    +1141                 this.scaleY = 1;
    +1142                 this.scaleTX = .5;
    +1143                 this.scaleTY = .5;
    +1144                 this.scaleAnchor = 0;
    +1145                 this.oldX = -1;
    +1146                 this.oldY = -1;
    +1147                 this.dirty = true;
    +1148 
    +1149                 return this;
    +1150             },
    +1151             /**
    +1152              * Sets the time life cycle for an Actor.
    +1153              * These values are related to Scene time.
    +1154              * @param startTime an integer indicating the time until which the Actor won't be visible on the Scene.
    +1155              * @param duration an integer indicating how much the Actor will last once visible.
    +1156              * @return this
    +1157              */
    +1158             setFrameTime:function (startTime, duration) {
    +1159                 this.start_time = startTime;
    +1160                 this.duration = duration;
    +1161                 this.expired = false;
    +1162                 this.dirty = true;
    +1163 
    +1164                 return this;
    +1165             },
    +1166             /**
    +1167              * This method should me overriden by every custom Actor.
    +1168              * It will be the drawing routine called by the Director to show every Actor.
    +1169              * @param director {CAAT.Foundation.Director} instance that contains the Scene the Actor is in.
    +1170              * @param time {number} indicating the Scene time in which the drawing is performed.
    +1171              */
    +1172             paint:function (director, time) {
    +1173                 if (this.backgroundImage) {
    +1174                     this.backgroundImage.paint(director, time, 0, 0);
    +1175                 } else if (this.fillStyle) {
    +1176                     var ctx = director.ctx;
    +1177                     ctx.fillStyle = this.fillStyle;
    +1178                     ctx.fillRect(0, 0, this.width, this.height);
    +1179                 }
    +1180 
    +1181             },
    +1182             /**
    +1183              * A helper method to setScaleAnchored with an anchor of ANCHOR_CENTER
    +1184              *
    +1185              * @see setScaleAnchored
    +1186              *
    +1187              * @param sx a float indicating a width size multiplier.
    +1188              * @param sy a float indicating a height size multiplier.
    +1189              * @return this
    +1190              */
    +1191             setScale:function (sx, sy) {
    +1192                 this.scaleX = sx;
    +1193                 this.scaleY = sy;
    +1194                 this.dirty = true;
    +1195                 return this;
    +1196             },
    +1197             getAnchorPercent:function (anchor) {
    +1198 
    +1199                 var anchors = [
    +1200                     .50, .50, .50, 0, .50, 1.00,
    +1201                     0, .50, 1.00, .50, 0, 0,
    +1202                     1.00, 0, 0, 1.00, 1.00, 1.00
    +1203                 ];
    +1204 
    +1205                 return { x:anchors[anchor * 2], y:anchors[anchor * 2 + 1] };
    +1206             },
    +1207             /**
    +1208              * Private.
    +1209              * Gets a given anchor position referred to the Actor.
    +1210              * @param anchor
    +1211              * @return an object of the form { x: float, y: float }
    +1212              */
    +1213             getAnchor:function (anchor) {
    +1214                 var tx = 0, ty = 0;
    +1215 
    +1216                 var A= CAAT.Foundation.Actor;
    +1217 
    +1218                 switch (anchor) {
    +1219                     case A.ANCHOR_CENTER:
    +1220                         tx = .5;
    +1221                         ty = .5;
    +1222                         break;
    +1223                     case A.ANCHOR_TOP:
    +1224                         tx = .5;
    +1225                         ty = 0;
    +1226                         break;
    +1227                     case A.ANCHOR_BOTTOM:
    +1228                         tx = .5;
    +1229                         ty = 1;
    +1230                         break;
    +1231                     case A.ANCHOR_LEFT:
    +1232                         tx = 0;
    +1233                         ty = .5;
    +1234                         break;
    +1235                     case A.ANCHOR_RIGHT:
    +1236                         tx = 1;
    +1237                         ty = .5;
    +1238                         break;
    +1239                     case A.ANCHOR_TOP_RIGHT:
    +1240                         tx = 1;
    +1241                         ty = 0;
    +1242                         break;
    +1243                     case A.ANCHOR_BOTTOM_LEFT:
    +1244                         tx = 0;
    +1245                         ty = 1;
    +1246                         break;
    +1247                     case A.ANCHOR_BOTTOM_RIGHT:
    +1248                         tx = 1;
    +1249                         ty = 1;
    +1250                         break;
    +1251                     case A.ANCHOR_TOP_LEFT:
    +1252                         tx = 0;
    +1253                         ty = 0;
    +1254                         break;
    +1255                 }
    +1256 
    +1257                 return {x:tx, y:ty};
    +1258             },
    +1259 
    +1260             setGlobalAnchor:function (ax, ay) {
    +1261                 this.tAnchorX = ax;
    +1262                 this.rotationX = ax;
    +1263                 this.scaleTX = ax;
    +1264 
    +1265                 this.tAnchorY = ay;
    +1266                 this.rotationY = ay;
    +1267                 this.scaleTY = ay;
    +1268 
    +1269                 this.dirty = true;
    +1270                 return this;
    +1271             },
    +1272 
    +1273             setScaleAnchor:function (sax, say) {
    +1274                 this.scaleTX = sax;
    +1275                 this.scaleTY = say;
    +1276                 this.dirty = true;
    +1277                 return this;
    +1278             },
    +1279             /**
    +1280              * Modify the dimensions on an Actor.
    +1281              * The dimension will not affect the local coordinates system in opposition
    +1282              * to setSize or setBounds.
    +1283              *
    +1284              * @param sx {number} width scale.
    +1285              * @param sy {number} height scale.
    +1286              * @param anchorx {number} x anchor to perform the Scale operation.
    +1287              * @param anchory {number} y anchor to perform the Scale operation.
    +1288              *
    +1289              * @return this;
    +1290              */
    +1291             setScaleAnchored:function (sx, sy, anchorx, anchory) {
    +1292                 this.scaleTX = anchorx;
    +1293                 this.scaleTY = anchory;
    +1294 
    +1295                 this.scaleX = sx;
    +1296                 this.scaleY = sy;
    +1297 
    +1298                 this.dirty = true;
    +1299 
    +1300                 return this;
    +1301             },
    +1302 
    +1303             setRotationAnchor:function (rax, ray) {
    +1304                 this.rotationX = ray;
    +1305                 this.rotationY = rax;
    +1306                 this.dirty = true;
    +1307                 return this;
    +1308             },
    +1309             /**
    +1310              * A helper method for setRotationAnchored. This methods stablishes the center
    +1311              * of rotation to be the center of the Actor.
    +1312              *
    +1313              * @param angle a float indicating the angle in radians to rotate the Actor.
    +1314              * @return this
    +1315              */
    +1316             setRotation:function (angle) {
    +1317                 this.rotationAngle = angle;
    +1318                 this.dirty = true;
    +1319                 return this;
    +1320             },
    +1321             /**
    +1322              * This method sets Actor rotation around a given position.
    +1323              * @param angle {number} indicating the angle in radians to rotate the Actor.
    +1324              * @param rx {number} value in the range 0..1
    +1325              * @param ry {number} value in the range 0..1
    +1326              * @return this;
    +1327              */
    +1328             setRotationAnchored:function (angle, rx, ry) {
    +1329                 this.rotationAngle = angle;
    +1330                 this.rotationX = rx;
    +1331                 this.rotationY = ry;
    +1332                 this.dirty = true;
    +1333                 return this;
    +1334             },
    +1335             /**
    +1336              * Sets an Actor's dimension
    +1337              * @param w a float indicating Actor's width.
    +1338              * @param h a float indicating Actor's height.
    +1339              * @return this
    +1340              */
    +1341             setSize:function (w, h) {
    +1342 
    +1343                 this.width = w;
    +1344                 this.height = h;
    +1345 
    +1346                 this.dirty = true;
    +1347 
    +1348                 return this;
    +1349             },
    +1350             /**
    +1351              * Set location and dimension of an Actor at once.
    +1352              *
    +1353              * @param x{number} a float indicating Actor's x position.
    +1354              * @param y{number} a float indicating Actor's y position
    +1355              * @param w{number} a float indicating Actor's width
    +1356              * @param h{number} a float indicating Actor's height
    +1357              * @return this
    +1358              */
    +1359             setBounds:function (x, y, w, h) {
    +1360 
    +1361                 this.x = x;
    +1362                 this.y = y;
    +1363                 this.width = w;
    +1364                 this.height = h;
    +1365 
    +1366                 this.dirty = true;
    +1367 
    +1368                 return this;
    +1369             },
    +1370             /**
    +1371              * This method sets the position of an Actor inside its parent.
    +1372              *
    +1373              * @param x{number} a float indicating Actor's x position
    +1374              * @param y{number} a float indicating Actor's y position
    +1375              * @return this
    +1376              *
    +1377              * @deprecated
    +1378              */
    +1379             setLocation:function (x, y) {
    +1380                 this.x = x;
    +1381                 this.y = y;
    +1382                 this.oldX = x;
    +1383                 this.oldY = y;
    +1384 
    +1385                 this.dirty = true;
    +1386 
    +1387                 return this;
    +1388             },
    +1389 
    +1390             setPosition:function (x, y) {
    +1391                 return this.setLocation(x, y);
    +1392             },
    +1393 
    +1394             setPositionAnchor:function (pax, pay) {
    +1395                 this.tAnchorX = pax;
    +1396                 this.tAnchorY = pay;
    +1397                 return this;
    +1398             },
    +1399 
    +1400             setPositionAnchored:function (x, y, pax, pay) {
    +1401                 this.setLocation(x, y);
    +1402                 this.tAnchorX = pax;
    +1403                 this.tAnchorY = pay;
    +1404                 return this;
    +1405             },
    +1406 
    +1407 
    +1408             /**
    +1409              * This method is called by the Director to know whether the actor is on Scene time.
    +1410              * In case it was necessary, this method will notify any life cycle behaviors about
    +1411              * an Actor expiration.
    +1412              * @param time {number} time indicating the Scene time.
    +1413              *
    +1414              * @private
    +1415              *
    +1416              */
    +1417             isInAnimationFrame:function (time) {
    +1418                 if (this.expired) {
    +1419                     return false;
    +1420                 }
    +1421 
    +1422                 if (this.duration === Number.MAX_VALUE) {
    +1423                     return this.start_time <= time;
    +1424                 }
    +1425 
    +1426                 if (time >= this.start_time + this.duration) {
    +1427                     if (!this.expired) {
    +1428                         this.setExpired(time);
    +1429                     }
    +1430 
    +1431                     return false;
    +1432                 }
    +1433 
    +1434                 return this.start_time <= time && time < this.start_time + this.duration;
    +1435             },
    +1436             /**
    +1437              * Checks whether a coordinate is inside the Actor's bounding box.
    +1438              * @param x {number} a float
    +1439              * @param y {number} a float
    +1440              *
    +1441              * @return boolean indicating whether it is inside.
    +1442              */
    +1443             contains:function (x, y) {
    +1444                 return x >= 0 && y >= 0 && x < this.width && y < this.height;
    +1445             },
    +1446 
    +1447             /**
    +1448              * Add a Behavior to the Actor.
    +1449              * An Actor accepts an undefined number of Behaviors.
    +1450              *
    +1451              * @param behavior {CAAT.Behavior.BaseBehavior}
    +1452              * @return this
    +1453              */
    +1454             addBehavior:function (behavior) {
    +1455                 this.behaviorList.push(behavior);
    +1456                 return this;
    +1457             },
    +1458 
    +1459             /**
    +1460              * Remove a Behavior from the Actor.
    +1461              * If the Behavior is not present at the actor behavior collection nothing happends.
    +1462              *
    +1463              * @param behavior {CAAT.Behavior.BaseBehavior}
    +1464              */
    +1465             removeBehaviour:function (behavior) {
    +1466                 var c = this.behaviorList;
    +1467                 var n = c.length - 1;
    +1468                 while (n) {
    +1469                     if (c[n] === behavior) {
    +1470                         c.splice(n, 1);
    +1471                         return this;
    +1472                     }
    +1473                 }
    +1474                 return this;
    +1475             },
    +1476             /**
    +1477              * Remove a Behavior with id param as behavior identifier from this actor.
    +1478              * This function will remove ALL behavior instances with the given id.
    +1479              *
    +1480              * @param id {number} an integer.
    +1481              * return this;
    +1482              */
    +1483             removeBehaviorById:function (id) {
    +1484                 var c = this.behaviorList;
    +1485                 for (var n = 0; n < c.length; n++) {
    +1486                     if (c[n].id === id) {
    +1487                         c.splice(n, 1);
    +1488                     }
    +1489                 }
    +1490 
    +1491                 return this;
    +1492 
    +1493             },
    +1494             getBehavior:function (id) {
    +1495                 var c = this.behaviorList;
    +1496                 for (var n = 0; n < c.length; n++) {
    +1497                     var cc = c[n];
    +1498                     if (cc.id === id) {
    +1499                         return cc;
    +1500                     }
    +1501                 }
    +1502                 return null;
    +1503             },
    +1504             /**
    +1505              * Set discardable property. If an actor is discardable, upon expiration will be removed from
    +1506              * scene graph and hence deleted.
    +1507              * @param discardable {boolean} a boolean indicating whether the Actor is discardable.
    +1508              * @return this
    +1509              */
    +1510             setDiscardable:function (discardable) {
    +1511                 this.discardable = discardable;
    +1512                 return this;
    +1513             },
    +1514             /**
    +1515              * This method will be called internally by CAAT when an Actor is expired, and at the
    +1516              * same time, is flagged as discardable.
    +1517              * It notifies the Actor life cycle listeners about the destruction event.
    +1518              *
    +1519              * @param time an integer indicating the time at wich the Actor has been destroyed.
    +1520              *
    +1521              * @private
    +1522              *
    +1523              */
    +1524             destroy:function (time) {
    +1525                 if (this.parent) {
    +1526                     this.parent.removeChild(this);
    +1527                 }
    +1528 
    +1529                 this.fireEvent('destroyed', time);
    +1530                 if ( !this.isCachedActor ) {
    +1531                     this.clean();
    +1532                 }
    +1533 
    +1534             },
    +1535 
    +1536             clean : function() {
    +1537                 this.backgroundImage= null;
    +1538                 this.emptyBehaviorList();
    +1539                 this.lifecycleListenerList= [];
    +1540             },
    +1541 
    +1542             /**
    +1543              * Transform a point or array of points in model space to view space.
    +1544              *
    +1545              * @param point {CAAT.Math.Point|Array} an object of the form {x : float, y: float}
    +1546              *
    +1547              * @return the source transformed elements.
    +1548              *
    +1549              * @private
    +1550              *
    +1551              */
    +1552             modelToView:function (point) {
    +1553                 var x, y, pt, tm;
    +1554 
    +1555                 if (this.dirty) {
    +1556                     this.setModelViewMatrix();
    +1557                 }
    +1558 
    +1559                 tm = this.worldModelViewMatrix.matrix;
    +1560 
    +1561                 if (point instanceof Array) {
    +1562                     for (var i = 0; i < point.length; i++) {
    +1563                         //this.worldModelViewMatrix.transformCoord(point[i]);
    +1564                         pt = point[i];
    +1565                         x = pt.x;
    +1566                         y = pt.y;
    +1567                         pt.x = x * tm[0] + y * tm[1] + tm[2];
    +1568                         pt.y = x * tm[3] + y * tm[4] + tm[5];
    +1569                     }
    +1570                 }
    +1571                 else {
    +1572 //                this.worldModelViewMatrix.transformCoord(point);
    +1573                     x = point.x;
    +1574                     y = point.y;
    +1575                     point.x = x * tm[0] + y * tm[1] + tm[2];
    +1576                     point.y = x * tm[3] + y * tm[4] + tm[5];
    +1577                 }
    +1578 
    +1579                 return point;
    +1580             },
    +1581             /**
    +1582              * Transform a local coordinate point on this Actor's coordinate system into
    +1583              * another point in otherActor's coordinate system.
    +1584              * @param point {CAAT.Math.Point}
    +1585              * @param otherActor {CAAT.Math.Actor}
    +1586              */
    +1587             modelToModel:function (point, otherActor) {
    +1588                 if (this.dirty) {
    +1589                     this.setModelViewMatrix();
    +1590                 }
    +1591 
    +1592                 return otherActor.viewToModel(this.modelToView(point));
    +1593             },
    +1594             /**
    +1595              * Transform a point from view to model space.
    +1596              * <p>
    +1597              * WARNING: every call to this method calculates
    +1598              * actor's world model view matrix.
    +1599              *
    +1600              * @param point {CAAT.Math.Point} a point in screen space to be transformed to model space.
    +1601              *
    +1602              * @return the source point object
    +1603              *
    +1604              *
    +1605              */
    +1606             viewToModel:function (point) {
    +1607                 if (this.dirty) {
    +1608                     this.setModelViewMatrix();
    +1609                 }
    +1610                 this.worldModelViewMatrix.getInverse(this.worldModelViewMatrixI);
    +1611                 this.worldModelViewMatrixI.transformCoord(point);
    +1612                 return point;
    +1613             },
    +1614             /**
    +1615              * Private
    +1616              * This method does the needed point transformations across an Actor hierarchy to devise
    +1617              * whether the parameter point coordinate lies inside the Actor.
    +1618              * @param point {CAAT.Math.Point}
    +1619              *
    +1620              * @return null if the point is not inside the Actor. The Actor otherwise.
    +1621              */
    +1622             findActorAtPosition:function (point) {
    +1623                 if (this.scaleX===0 || this.scaleY===0) {
    +1624                     return null;
    +1625                 }
    +1626                 if (!this.visible || !this.mouseEnabled || !this.isInAnimationFrame(this.time)) {
    +1627                     return null;
    +1628                 }
    +1629 
    +1630                 this.modelViewMatrix.getInverse(this.modelViewMatrixI);
    +1631                 this.modelViewMatrixI.transformCoord(point);
    +1632                 return this.contains(point.x, point.y) ? this : null;
    +1633             },
    +1634             /**
    +1635              * Enables a default dragging routine for the Actor.
    +1636              * This default dragging routine allows to:
    +1637              *  <li>scale the Actor by pressing shift+drag
    +1638              *  <li>rotate the Actor by pressing control+drag
    +1639              *  <li>scale non uniformly by pressing alt+shift+drag
    +1640              *
    +1641              * @return this
    +1642              */
    +1643             enableDrag:function () {
    +1644 
    +1645                 this.ax = 0;
    +1646                 this.ay = 0;
    +1647                 this.asx = 1;
    +1648                 this.asy = 1;
    +1649                 this.ara = 0;
    +1650                 this.screenx = 0;
    +1651                 this.screeny = 0;
    +1652 
    +1653                 /**
    +1654                  * Mouse enter handler for default drag behavior.
    +1655                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +1656                  *
    +1657                  * @ignore
    +1658                  */
    +1659                 this.mouseEnter = function (mouseEvent) {
    +1660                     this.__d_ax = -1;
    +1661                     this.__d_ay = -1;
    +1662                     this.pointed = true;
    +1663                     CAAT.setCursor('move');
    +1664                 };
    +1665 
    +1666                 /**
    +1667                  * Mouse exit handler for default drag behavior.
    +1668                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +1669                  *
    +1670                  * @ignore
    +1671                  */
    +1672                 this.mouseExit = function (mouseEvent) {
    +1673                     this.__d_ax = -1;
    +1674                     this.__d_ay = -1;
    +1675                     this.pointed = false;
    +1676                     CAAT.setCursor('default');
    +1677                 };
    +1678 
    +1679                 /**
    +1680                  * Mouse move handler for default drag behavior.
    +1681                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +1682                  *
    +1683                  * @ignore
    +1684                  */
    +1685                 this.mouseMove = function (mouseEvent) {
    +1686                 };
    +1687 
    +1688                 /**
    +1689                  * Mouse up handler for default drag behavior.
    +1690                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +1691                  *
    +1692                  * @ignore
    +1693                  */
    +1694                 this.mouseUp = function (mouseEvent) {
    +1695                     this.__d_ax = -1;
    +1696                     this.__d_ay = -1;
    +1697                 };
    +1698 
    +1699                 /**
    +1700                  * Mouse drag handler for default drag behavior.
    +1701                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +1702                  *
    +1703                  * @ignore
    +1704                  */
    +1705                 this.mouseDrag = function (mouseEvent) {
    +1706 
    +1707                     var pt;
    +1708 
    +1709                     pt = this.modelToView(new CAAT.Math.Point(mouseEvent.x, mouseEvent.y));
    +1710                     this.parent.viewToModel(pt);
    +1711 
    +1712                     if (this.__d_ax === -1 || this.__d_ay === -1) {
    +1713                         this.__d_ax = pt.x;
    +1714                         this.__d_ay = pt.y;
    +1715                         this.__d_asx = this.scaleX;
    +1716                         this.__d_asy = this.scaleY;
    +1717                         this.__d_ara = this.rotationAngle;
    +1718                         this.__d_screenx = mouseEvent.screenPoint.x;
    +1719                         this.__d_screeny = mouseEvent.screenPoint.y;
    +1720                     }
    +1721 
    +1722                     if (mouseEvent.isShiftDown()) {
    +1723                         var scx = (mouseEvent.screenPoint.x - this.__d_screenx) / 100;
    +1724                         var scy = (mouseEvent.screenPoint.y - this.__d_screeny) / 100;
    +1725                         if (!mouseEvent.isAltDown()) {
    +1726                             var sc = Math.max(scx, scy);
    +1727                             scx = sc;
    +1728                             scy = sc;
    +1729                         }
    +1730                         this.setScale(scx + this.__d_asx, scy + this.__d_asy);
    +1731 
    +1732                     } else if (mouseEvent.isControlDown()) {
    +1733                         var vx = mouseEvent.screenPoint.x - this.__d_screenx;
    +1734                         var vy = mouseEvent.screenPoint.y - this.__d_screeny;
    +1735                         this.setRotation(-Math.atan2(vx, vy) + this.__d_ara);
    +1736                     } else {
    +1737                         this.x += pt.x - this.__d_ax;
    +1738                         this.y += pt.y - this.__d_ay;
    +1739                     }
    +1740 
    +1741                     this.__d_ax = pt.x;
    +1742                     this.__d_ay = pt.y;
    +1743                 };
    +1744 
    +1745                 return this;
    +1746             },
    +1747             disableDrag:function () {
    +1748 
    +1749                 this.mouseEnter = function (mouseEvent) {
    +1750                 };
    +1751                 this.mouseExit = function (mouseEvent) {
    +1752                 };
    +1753                 this.mouseMove = function (mouseEvent) {
    +1754                 };
    +1755                 this.mouseUp = function (mouseEvent) {
    +1756                 };
    +1757                 this.mouseDrag = function (mouseEvent) {
    +1758                 };
    +1759 
    +1760                 return this;
    +1761             },
    +1762             /**
    +1763              * Default mouseClick handler.
    +1764              * Mouse click events are received after a call to mouseUp method if no dragging was in progress.
    +1765              *
    +1766              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1767              */
    +1768             mouseClick:function (mouseEvent) {
    +1769             },
    +1770             /**
    +1771              * Default double click handler
    +1772              *
    +1773              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1774              */
    +1775             mouseDblClick:function (mouseEvent) {
    +1776             },
    +1777             /**
    +1778              * Default mouse wheel handler
    +1779              *
    +1780              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1781              */
    +1782             mouseWheel:function (mouseEvent) {
    +1783             },
    +1784             /**
    +1785              * Default mouse enter on Actor handler.
    +1786              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1787              */
    +1788             mouseEnter:function (mouseEvent) {
    +1789                 this.pointed = true;
    +1790             },
    +1791             /**
    +1792              * Default mouse exit on Actor handler.
    +1793              *
    +1794              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1795              */
    +1796             mouseExit:function (mouseEvent) {
    +1797                 this.pointed = false;
    +1798             },
    +1799             /**
    +1800              * Default mouse move inside Actor handler.
    +1801              *
    +1802              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1803              */
    +1804             mouseMove:function (mouseEvent) {
    +1805             },
    +1806             /**
    +1807              * default mouse press in Actor handler.
    +1808              *
    +1809              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1810              */
    +1811             mouseDown:function (mouseEvent) {
    +1812             },
    +1813             /**
    +1814              * default mouse release in Actor handler.
    +1815              *
    +1816              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1817              */
    +1818             mouseUp:function (mouseEvent) {
    +1819             },
    +1820             mouseOut:function (mouseEvent) {
    +1821             },
    +1822             mouseOver:function (mouseEvent) {
    +1823             },
    +1824             /**
    +1825              * default Actor mouse drag handler.
    +1826              *
    +1827              * @param mouseEvent {CAAT.Event.MouseEvent}
    +1828              */
    +1829             mouseDrag:function (mouseEvent) {
    +1830             },
    +1831             /**
    +1832              * Draw a bounding box with on-screen coordinates regardless of the transformations
    +1833              * applied to the Actor.
    +1834              *
    +1835              * @param director {CAAT.Foundations.Director} object instance that contains the Scene the Actor is in.
    +1836              * @param time {number} integer indicating the Scene time when the bounding box is to be drawn.
    +1837              */
    +1838             drawScreenBoundingBox:function (director, time) {
    +1839                 if (null !== this.AABB && this.inFrame) {
    +1840                     var s = this.AABB;
    +1841                     var ctx = director.ctx;
    +1842                     ctx.strokeStyle = CAAT.DEBUGAABBCOLOR;
    +1843                     ctx.strokeRect(.5 + (s.x | 0), .5 + (s.y | 0), s.width | 0, s.height | 0);
    +1844                     if (CAAT.DEBUGBB) {
    +1845                         var vv = this.viewVertices;
    +1846                         ctx.beginPath();
    +1847                         ctx.lineTo(vv[0].x, vv[0].y);
    +1848                         ctx.lineTo(vv[1].x, vv[1].y);
    +1849                         ctx.lineTo(vv[2].x, vv[2].y);
    +1850                         ctx.lineTo(vv[3].x, vv[3].y);
    +1851                         ctx.closePath();
    +1852                         ctx.strokeStyle = CAAT.DEBUGBBCOLOR;
    +1853                         ctx.stroke();
    +1854                     }
    +1855                 }
    +1856             },
    +1857             /**
    +1858              * Private
    +1859              * This method is called by the Director instance.
    +1860              * It applies the list of behaviors the Actor has registered.
    +1861              *
    +1862              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    +1863              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
    +1864              */
    +1865             animate:function (director, time) {
    +1866 
    +1867                 if (!this.visible) {
    +1868                     return false;
    +1869                 }
    +1870 
    +1871                 var i;
    +1872 
    +1873                 if (!this.isInAnimationFrame(time)) {
    +1874                     this.inFrame = false;
    +1875                     this.dirty = true;
    +1876                     return false;
    +1877                 }
    +1878 
    +1879                 if (this.x !== this.oldX || this.y !== this.oldY) {
    +1880                     this.dirty = true;
    +1881                     this.oldX = this.x;
    +1882                     this.oldY = this.y;
    +1883                 }
    +1884 
    +1885                 for (i = 0; i < this.behaviorList.length; i++) {
    +1886                     this.behaviorList[i].apply(time, this);
    +1887                 }
    +1888 
    +1889                 if (this.clipPath) {
    +1890                     this.clipPath.applyBehaviors(time);
    +1891                 }
    +1892 
    +1893                 // transformation stuff.
    +1894                 this.setModelViewMatrix();
    +1895 
    +1896                 if (this.dirty || this.wdirty || this.invalid) {
    +1897                     if (director.dirtyRectsEnabled) {
    +1898                         director.addDirtyRect(this.AABB);
    +1899                     }
    +1900                     this.setScreenBounds();
    +1901                     if (director.dirtyRectsEnabled) {
    +1902                         director.addDirtyRect(this.AABB);
    +1903                     }
    +1904                 }
    +1905                 this.dirty = false;
    +1906                 this.invalid = false;
    +1907 
    +1908                 this.inFrame = true;
    +1909 
    +1910                 if ( this.backgroundImage ) {
    +1911                     this.backgroundImage.setSpriteIndexAtTime(time);
    +1912                 }
    +1913 
    +1914                 return this.AABB.intersects(director.AABB);
    +1915                 //return true;
    +1916             },
    +1917             /**
    +1918              * Set this model view matrix if the actor is Dirty.
    +1919              *
    +1920              mm[2]+= this.x;
    +1921              mm[5]+= this.y;
    +1922              if ( this.rotationAngle ) {
    +1923                  this.modelViewMatrix.multiply( m.setTranslate( this.rotationX, this.rotationY) );
    +1924                  this.modelViewMatrix.multiply( m.setRotation( this.rotationAngle ) );
    +1925                  this.modelViewMatrix.multiply( m.setTranslate( -this.rotationX, -this.rotationY) );                    c= Math.cos( this.rotationAngle );
    +1926              }
    +1927              if ( this.scaleX!=1 || this.scaleY!=1 && (this.scaleTX || this.scaleTY )) {
    +1928                  this.modelViewMatrix.multiply( m.setTranslate( this.scaleTX , this.scaleTY ) );
    +1929                  this.modelViewMatrix.multiply( m.setScale( this.scaleX, this.scaleY ) );
    +1930                  this.modelViewMatrix.multiply( m.setTranslate( -this.scaleTX , -this.scaleTY ) );
    +1931              }
    +1932              *
    +1933              * @return this
    +1934              */
    +1935             setModelViewMatrix:function () {
    +1936                 var c, s, _m00, _m01, _m10, _m11;
    +1937                 var mm0, mm1, mm2, mm3, mm4, mm5;
    +1938                 var mm;
    +1939 
    +1940                 this.wdirty = false;
    +1941                 mm = this.modelViewMatrix.matrix;
    +1942 
    +1943                 if (this.dirty) {
    +1944 
    +1945                     mm0 = 1;
    +1946                     mm1 = 0;
    +1947                     //mm2= mm[2];
    +1948                     mm3 = 0;
    +1949                     mm4 = 1;
    +1950                     //mm5= mm[5];
    +1951 
    +1952                     mm2 = this.x - this.tAnchorX * this.width;
    +1953                     mm5 = this.y - this.tAnchorY * this.height;
    +1954 
    +1955                     if (this.rotationAngle) {
    +1956 
    +1957                         var rx = this.rotationX * this.width;
    +1958                         var ry = this.rotationY * this.height;
    +1959 
    +1960                         mm2 += mm0 * rx + mm1 * ry;
    +1961                         mm5 += mm3 * rx + mm4 * ry;
    +1962 
    +1963                         c = Math.cos(this.rotationAngle);
    +1964                         s = Math.sin(this.rotationAngle);
    +1965                         _m00 = mm0;
    +1966                         _m01 = mm1;
    +1967                         _m10 = mm3;
    +1968                         _m11 = mm4;
    +1969                         mm0 = _m00 * c + _m01 * s;
    +1970                         mm1 = -_m00 * s + _m01 * c;
    +1971                         mm3 = _m10 * c + _m11 * s;
    +1972                         mm4 = -_m10 * s + _m11 * c;
    +1973 
    +1974                         mm2 += -mm0 * rx - mm1 * ry;
    +1975                         mm5 += -mm3 * rx - mm4 * ry;
    +1976                     }
    +1977                     if (this.scaleX != 1 || this.scaleY != 1) {
    +1978 
    +1979                         var sx = this.scaleTX * this.width;
    +1980                         var sy = this.scaleTY * this.height;
    +1981 
    +1982                         mm2 += mm0 * sx + mm1 * sy;
    +1983                         mm5 += mm3 * sx + mm4 * sy;
    +1984 
    +1985                         mm0 = mm0 * this.scaleX;
    +1986                         mm1 = mm1 * this.scaleY;
    +1987                         mm3 = mm3 * this.scaleX;
    +1988                         mm4 = mm4 * this.scaleY;
    +1989 
    +1990                         mm2 += -mm0 * sx - mm1 * sy;
    +1991                         mm5 += -mm3 * sx - mm4 * sy;
    +1992                     }
    +1993 
    +1994                     mm[0] = mm0;
    +1995                     mm[1] = mm1;
    +1996                     mm[2] = mm2;
    +1997                     mm[3] = mm3;
    +1998                     mm[4] = mm4;
    +1999                     mm[5] = mm5;
    +2000                 }
    +2001 
    +2002                 if (this.parent) {
    +2003 
    +2004 
    +2005                     this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1 && this.parent.isAA;
    +2006 
    +2007                     if (this.dirty || this.parent.wdirty) {
    +2008                         this.worldModelViewMatrix.copy(this.parent.worldModelViewMatrix);
    +2009                         if (this.isAA) {
    +2010                             var mmm = this.worldModelViewMatrix.matrix;
    +2011                             mmm[2] += mm[2];
    +2012                             mmm[5] += mm[5];
    +2013                         } else {
    +2014                             this.worldModelViewMatrix.multiply(this.modelViewMatrix);
    +2015                         }
    +2016                         this.wdirty = true;
    +2017                     }
    +2018 
    +2019                 } else {
    +2020                     if (this.dirty) {
    +2021                         this.wdirty = true;
    +2022                     }
    +2023 
    +2024                     this.worldModelViewMatrix.identity();
    +2025                     this.isAA = this.rotationAngle === 0 && this.scaleX === 1 && this.scaleY === 1;
    +2026                 }
    +2027 
    +2028 
    +2029 //if ( (CAAT.DEBUGAABB || glEnabled) && (this.dirty || this.wdirty ) ) {
    +2030                 // screen bounding boxes will always be calculated.
    +2031                 /*
    +2032                  if ( this.dirty || this.wdirty || this.invalid ) {
    +2033                  if ( director.dirtyRectsEnabled ) {
    +2034                  director.addDirtyRect( this.AABB );
    +2035                  }
    +2036                  this.setScreenBounds();
    +2037                  if ( director.dirtyRectsEnabled ) {
    +2038                  director.addDirtyRect( this.AABB );
    +2039                  }
    +2040                  }
    +2041                  this.dirty= false;
    +2042                  this.invalid= false;
    +2043                  */
    +2044             },
    +2045             /**
    +2046              * Calculates the 2D bounding box in canvas coordinates of the Actor.
    +2047              * This bounding box takes into account the transformations applied hierarchically for
    +2048              * each Scene Actor.
    +2049              *
    +2050              * @private
    +2051              *
    +2052              */
    +2053             setScreenBounds:function () {
    +2054 
    +2055                 var AABB = this.AABB;
    +2056                 var vv = this.viewVertices;
    +2057                 var vvv, m, x, y, w, h;
    +2058 
    +2059                 if (this.isAA) {
    +2060                     m = this.worldModelViewMatrix.matrix;
    +2061                     x = m[2];
    +2062                     y = m[5];
    +2063                     w = this.width;
    +2064                     h = this.height;
    +2065                     AABB.x = x;
    +2066                     AABB.y = y;
    +2067                     AABB.x1 = x + w;
    +2068                     AABB.y1 = y + h;
    +2069                     AABB.width = w;
    +2070                     AABB.height = h;
    +2071 
    +2072                     if (CAAT.GLRENDER) {
    +2073                         vvv = vv[0];
    +2074                         vvv.x = x;
    +2075                         vvv.y = y;
    +2076                         vvv = vv[1];
    +2077                         vvv.x = x + w;
    +2078                         vvv.y = y;
    +2079                         vvv = vv[2];
    +2080                         vvv.x = x + w;
    +2081                         vvv.y = y + h;
    +2082                         vvv = vv[3];
    +2083                         vvv.x = x;
    +2084                         vvv.y = y + h;
    +2085                     }
    +2086 
    +2087                     return this;
    +2088                 }
    +2089 
    +2090                 vvv = vv[0];
    +2091                 vvv.x = 0;
    +2092                 vvv.y = 0;
    +2093                 vvv = vv[1];
    +2094                 vvv.x = this.width;
    +2095                 vvv.y = 0;
    +2096                 vvv = vv[2];
    +2097                 vvv.x = this.width;
    +2098                 vvv.y = this.height;
    +2099                 vvv = vv[3];
    +2100                 vvv.x = 0;
    +2101                 vvv.y = this.height;
    +2102 
    +2103                 this.modelToView(this.viewVertices);
    +2104 
    +2105                 var xmin = Number.MAX_VALUE, xmax = -Number.MAX_VALUE;
    +2106                 var ymin = Number.MAX_VALUE, ymax = -Number.MAX_VALUE;
    +2107 
    +2108                 vvv = vv[0];
    +2109                 if (vvv.x < xmin) {
    +2110                     xmin = vvv.x;
    +2111                 }
    +2112                 if (vvv.x > xmax) {
    +2113                     xmax = vvv.x;
    +2114                 }
    +2115                 if (vvv.y < ymin) {
    +2116                     ymin = vvv.y;
    +2117                 }
    +2118                 if (vvv.y > ymax) {
    +2119                     ymax = vvv.y;
    +2120                 }
    +2121                 vvv = vv[1];
    +2122                 if (vvv.x < xmin) {
    +2123                     xmin = vvv.x;
    +2124                 }
    +2125                 if (vvv.x > xmax) {
    +2126                     xmax = vvv.x;
    +2127                 }
    +2128                 if (vvv.y < ymin) {
    +2129                     ymin = vvv.y;
    +2130                 }
    +2131                 if (vvv.y > ymax) {
    +2132                     ymax = vvv.y;
    +2133                 }
    +2134                 vvv = vv[2];
    +2135                 if (vvv.x < xmin) {
    +2136                     xmin = vvv.x;
    +2137                 }
    +2138                 if (vvv.x > xmax) {
    +2139                     xmax = vvv.x;
    +2140                 }
    +2141                 if (vvv.y < ymin) {
    +2142                     ymin = vvv.y;
    +2143                 }
    +2144                 if (vvv.y > ymax) {
    +2145                     ymax = vvv.y;
    +2146                 }
    +2147                 vvv = vv[3];
    +2148                 if (vvv.x < xmin) {
    +2149                     xmin = vvv.x;
    +2150                 }
    +2151                 if (vvv.x > xmax) {
    +2152                     xmax = vvv.x;
    +2153                 }
    +2154                 if (vvv.y < ymin) {
    +2155                     ymin = vvv.y;
    +2156                 }
    +2157                 if (vvv.y > ymax) {
    +2158                     ymax = vvv.y;
    +2159                 }
    +2160 
    +2161                 AABB.x = xmin;
    +2162                 AABB.y = ymin;
    +2163                 AABB.x1 = xmax;
    +2164                 AABB.y1 = ymax;
    +2165                 AABB.width = (xmax - xmin);
    +2166                 AABB.height = (ymax - ymin);
    +2167 
    +2168                 return this;
    +2169             },
    +2170             /**
    +2171              * @private.
    +2172              * This method will be called by the Director to set the whole Actor pre-render process.
    +2173              *
    +2174              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    +2175              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
    +2176              *
    +2177              * @return boolean indicating whether the Actor isInFrameTime
    +2178              */
    +2179             paintActor:function (director, time) {
    +2180 
    +2181                 if (!this.visible || !director.inDirtyRect(this)) {
    +2182                     return true;
    +2183                 }
    +2184 
    +2185                 var ctx = director.ctx;
    +2186 
    +2187                 this.frameAlpha = this.parent ? this.parent.frameAlpha * this.alpha : 1;
    +2188                 ctx.globalAlpha = this.frameAlpha;
    +2189 
    +2190                 director.modelViewMatrix.transformRenderingContextSet(ctx);
    +2191                 this.worldModelViewMatrix.transformRenderingContext(ctx);
    +2192 
    +2193                 if (this.clip) {
    +2194                     ctx.beginPath();
    +2195                     if (!this.clipPath) {
    +2196                         ctx.rect(0, 0, this.width, this.height);
    +2197                     } else {
    +2198                         this.clipPath.applyAsPath(director);
    +2199                     }
    +2200                     ctx.clip();
    +2201                 }
    +2202 
    +2203                 this.paint(director, time);
    +2204 
    +2205                 return true;
    +2206             },
    +2207             /**
    +2208              * for js2native
    +2209              * @param director
    +2210              * @param time
    +2211              */
    +2212             __paintActor:function (director, time) {
    +2213                 if (!this.visible) {
    +2214                     return true;
    +2215                 }
    +2216                 var ctx = director.ctx;
    +2217 
    +2218                 // global opt: set alpha as owns alpha, not take globalAlpha procedure.
    +2219                 this.frameAlpha = this.alpha;
    +2220 
    +2221                 var m = this.worldModelViewMatrix.matrix;
    +2222                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5], this.frameAlpha);
    +2223                 this.paint(director, time);
    +2224                 return true;
    +2225             },
    +2226 
    +2227             /**
    +2228              * Set coordinates and uv values for this actor.
    +2229              * This function uses Director's coords and indexCoords values.
    +2230              * @param director
    +2231              * @param time
    +2232              */
    +2233             paintActorGL:function (director, time) {
    +2234 
    +2235                 this.frameAlpha = this.parent.frameAlpha * this.alpha;
    +2236 
    +2237                 if (!this.glEnabled || !this.visible) {
    +2238                     return;
    +2239                 }
    +2240 
    +2241                 if (this.glNeedsFlush(director)) {
    +2242                     director.glFlush();
    +2243                     this.glSetShader(director);
    +2244 
    +2245                     if (!this.__uv) {
    +2246                         this.__uv = new Float32Array(8);
    +2247                     }
    +2248                     if (!this.__vv) {
    +2249                         this.__vv = new Float32Array(12);
    +2250                     }
    +2251 
    +2252                     this.setGLCoords(this.__vv, 0);
    +2253                     this.setUV(this.__uv, 0);
    +2254                     director.glRender(this.__vv, 12, this.__uv);
    +2255 
    +2256                     return;
    +2257                 }
    +2258 
    +2259                 var glCoords = director.coords;
    +2260                 var glCoordsIndex = director.coordsIndex;
    +2261 
    +2262                 ////////////////// XYZ
    +2263                 this.setGLCoords(glCoords, glCoordsIndex);
    +2264                 director.coordsIndex = glCoordsIndex + 12;
    +2265 
    +2266                 ////////////////// UV
    +2267                 this.setUV(director.uv, director.uvIndex);
    +2268                 director.uvIndex += 8;
    +2269             },
    +2270             /**
    +2271              * TODO: set GLcoords for different image transformations.
    +2272              *
    +2273              * @param glCoords
    +2274              * @param glCoordsIndex
    +2275              */
    +2276             setGLCoords:function (glCoords, glCoordsIndex) {
    +2277 
    +2278                 var vv = this.viewVertices;
    +2279                 glCoords[glCoordsIndex++] = vv[0].x;
    +2280                 glCoords[glCoordsIndex++] = vv[0].y;
    +2281                 glCoords[glCoordsIndex++] = 0;
    +2282 
    +2283                 glCoords[glCoordsIndex++] = vv[1].x;
    +2284                 glCoords[glCoordsIndex++] = vv[1].y;
    +2285                 glCoords[glCoordsIndex++] = 0;
    +2286 
    +2287                 glCoords[glCoordsIndex++] = vv[2].x;
    +2288                 glCoords[glCoordsIndex++] = vv[2].y;
    +2289                 glCoords[glCoordsIndex++] = 0;
    +2290 
    +2291                 glCoords[glCoordsIndex++] = vv[3].x;
    +2292                 glCoords[glCoordsIndex++] = vv[3].y;
    +2293                 glCoords[glCoordsIndex  ] = 0;
    +2294 
    +2295             },
    +2296             /**
    +2297              * Set UV for this actor's quad.
    +2298              *
    +2299              * @param uvBuffer {Float32Array}
    +2300              * @param uvIndex {number}
    +2301              */
    +2302             setUV:function (uvBuffer, uvIndex) {
    +2303                 this.backgroundImage.setUV(uvBuffer, uvIndex);
    +2304             },
    +2305             /**
    +2306              * Test for compulsory gl flushing:
    +2307              *  1.- opacity has changed.
    +2308              *  2.- texture page has changed.
    +2309              *
    +2310              */
    +2311             glNeedsFlush:function (director) {
    +2312                 if (this.getTextureGLPage() !== director.currentTexturePage) {
    +2313                     return true;
    +2314                 }
    +2315                 if (this.frameAlpha !== director.currentOpacity) {
    +2316                     return true;
    +2317                 }
    +2318                 return false;
    +2319             },
    +2320             /**
    +2321              * Change texture shader program parameters.
    +2322              * @param director
    +2323              */
    +2324             glSetShader:function (director) {
    +2325 
    +2326                 var tp = this.getTextureGLPage();
    +2327                 if (tp !== director.currentTexturePage) {
    +2328                     director.setGLTexturePage(tp);
    +2329                 }
    +2330 
    +2331                 if (this.frameAlpha !== director.currentOpacity) {
    +2332                     director.setGLCurrentOpacity(this.frameAlpha);
    +2333                 }
    +2334             },
    +2335             /**
    +2336              * @private.
    +2337              * This method is called after the Director has transformed and drawn a whole frame.
    +2338              *
    +2339              * @param director the CAAT.Foundation.Director object instance that contains the Scene the Actor is in.
    +2340              * @param time an integer indicating the Scene time when the bounding box is to be drawn.
    +2341              * @return this
    +2342              *
    +2343              * @deprecated
    +2344              */
    +2345             endAnimate:function (director, time) {
    +2346                 return this;
    +2347             },
    +2348             initialize:function (overrides) {
    +2349                 if (overrides) {
    +2350                     for (var i in overrides) {
    +2351                         this[i] = overrides[i];
    +2352                     }
    +2353                 }
    +2354 
    +2355                 return this;
    +2356             },
    +2357             /**
    +2358              * Set this Actor's clipping area.
    +2359              * @param enable {boolean} enable clip area.
    +2360              * @param clipPath {CAAT.Path.Path=} An optional path to apply clip with. If enabled and clipPath is not set,
    +2361              *  a rectangle will be used.
    +2362              */
    +2363             setClip:function (enable, clipPath) {
    +2364                 this.clip = enable;
    +2365                 this.clipPath = clipPath;
    +2366                 return this;
    +2367             },
    +2368 
    +2369             isCached : function() {
    +2370                 return this.cached;
    +2371             },
    +2372 
    +2373             stopCacheAsBitmap:function () {
    +2374                 if (this.cached) {
    +2375                     this.backgroundImage = null;
    +2376                     this.cached = CAAT.Foundation.Actor.CACHE_NONE;
    +2377                 }
    +2378             },
    +2379 
    +2380             /**
    +2381              *
    +2382              * @param time {Number=}
    +2383              * @param stragegy {CAAT.Foundation.Actor.CACHE_SIMPLE | CAAT.Foundation.Actor.CACHE_DEEP}
    +2384              * @return this
    +2385              */
    +2386             cacheAsBitmap:function (time, strategy) {
    +2387 
    +2388                 if (this.width<=0 || this.height<=0 ) {
    +2389                     return this;
    +2390                 }
    +2391 
    +2392                 time = time || 0;
    +2393                 var canvas = document.createElement('canvas');
    +2394                 canvas.width = this.width;
    +2395                 canvas.height = this.height;
    +2396                 var ctx = canvas.getContext('2d');
    +2397 
    +2398                 CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,time);
    +2399 
    +2400                 var director = {
    +2401                     ctx:ctx,
    +2402                     modelViewMatrix: new CAAT.Math.Matrix(),
    +2403                     worldModelViewMatrix: new CAAT.Math.Matrix(),
    +2404                     dirtyRectsEnabled:false,
    +2405                     inDirtyRect:function () {
    +2406                         return true;
    +2407                     },
    +2408                     AABB : new CAAT.Math.Rectangle(0,0,this.width,this.height)
    +2409                 };
    +2410 
    +2411                 var pmv = this.modelViewMatrix;
    +2412                 var pwmv = this.worldModelViewMatrix;
    +2413 
    +2414                 this.modelViewMatrix = new CAAT.Math.Matrix();
    +2415                 this.worldModelViewMatrix = new CAAT.Math.Matrix();
    +2416 
    +2417                 this.cached = CAAT.Foundation.Actor.CACHE_NONE;
    +2418 
    +2419                 if ( typeof strategy==="undefined" ) {
    +2420                     strategy= CAAT.Foundation.Actor.CACHE_SIMPLE;
    +2421                 }
    +2422                 if ( strategy===CAAT.Foundation.Actor.CACHE_DEEP ) {
    +2423                     this.animate(director, time );
    +2424                     this.paintActor(director, time);
    +2425                 } else {
    +2426                     if ( this instanceof CAAT.Foundation.ActorContainer || this instanceof CAAT.ActorContainer ) {
    +2427                         CAAT.Foundation.ActorContainer.superclass.paintActor.call(this, director, time);
    +2428                     } else {
    +2429                         this.animate(director, time );
    +2430                         this.paintActor(director, time);
    +2431                     }
    +2432                 }
    +2433                 this.setBackgroundImage(canvas);
    +2434 
    +2435                 this.cached = strategy;
    +2436 
    +2437                 this.modelViewMatrix = pmv;
    +2438                 this.worldModelViewMatrix = pwmv;
    +2439 
    +2440                 return this;
    +2441             },
    +2442             resetAsButton : function() {
    +2443                 this.actionPerformed= null;
    +2444                 this.mouseEnter=    function() {};
    +2445                 this.mouseExit=     function() {};
    +2446                 this.mouseDown=     function() {};
    +2447                 this.mouseUp=       function() {};
    +2448                 this.mouseClick=    function() {};
    +2449                 this.mouseDrag=     function() {};
    +2450                 return this;
    +2451             },
    +2452             /**
    +2453              * Set this actor behavior as if it were a Button. The actor size will be set as SpriteImage's
    +2454              * single size.
    +2455              *
    +2456              * @param buttonImage {CAAT.Foundation.SpriteImage} sprite image with button's state images.
    +2457              * @param iNormal {number} button's normal state image index
    +2458              * @param iOver {number} button's mouse over state image index
    +2459              * @param iPress {number} button's pressed state image index
    +2460              * @param iDisabled {number} button's disabled state image index
    +2461              * @param fn {function(button{CAAT.Foundation.Actor})} callback function
    +2462              */
    +2463             setAsButton:function (buttonImage, iNormal, iOver, iPress, iDisabled, fn) {
    +2464 
    +2465                 var me = this;
    +2466 
    +2467                 this.setBackgroundImage(buttonImage, true);
    +2468 
    +2469                 this.iNormal = iNormal || 0;
    +2470                 this.iOver = iOver || this.iNormal;
    +2471                 this.iPress = iPress || this.iNormal;
    +2472                 this.iDisabled = iDisabled || this.iNormal;
    +2473                 this.fnOnClick = fn;
    +2474                 this.enabled = true;
    +2475 
    +2476                 this.setSpriteIndex(iNormal);
    +2477 
    +2478                 /**
    +2479                  * Enable or disable the button.
    +2480                  * @param enabled {boolean}
    +2481                  * @ignore
    +2482                  */
    +2483                 this.setEnabled = function (enabled) {
    +2484                     this.enabled = enabled;
    +2485                     this.setSpriteIndex(this.enabled ? this.iNormal : this.iDisabled);
    +2486                     return this;
    +2487                 };
    +2488 
    +2489                 /**
    +2490                  * This method will be called by CAAT *before* the mouseUp event is fired.
    +2491                  * @param event {CAAT.Event.MouseEvent}
    +2492                  * @ignore
    +2493                  */
    +2494                 this.actionPerformed = function (event) {
    +2495                     if (this.enabled && this.fnOnClick) {
    +2496                         this.fnOnClick(this);
    +2497                     }
    +2498                 };
    +2499 
    +2500                 /**
    +2501                  * Button's mouse enter handler. It makes the button provide visual feedback
    +2502                  * @param mouseEvent {CAAT.Event.MouseEvent}
    +2503                  * @ignore
    +2504                  */
    +2505                 this.mouseEnter = function (mouseEvent) {
    +2506                     if (!this.enabled) {
    +2507                         return;
    +2508                     }
    +2509 
    +2510                     if (this.dragging) {
    +2511                         this.setSpriteIndex(this.iPress);
    +2512                     } else {
    +2513                         this.setSpriteIndex(this.iOver);
    +2514                     }
    +2515                     CAAT.setCursor('pointer');
    +2516                 };
    +2517 
    +2518                 /**
    +2519                  * Button's mouse exit handler. Release visual apperance.
    +2520                  * @param mouseEvent {CAAT.MouseEvent}
    +2521                  * @ignore
    +2522                  */
    +2523                 this.mouseExit = function (mouseEvent) {
    +2524                     if (!this.enabled) {
    +2525                         return;
    +2526                     }
    +2527 
    +2528                     this.setSpriteIndex(this.iNormal);
    +2529                     CAAT.setCursor('default');
    +2530                 };
    +2531 
    +2532                 /**
    +2533                  * Button's mouse down handler.
    +2534                  * @param mouseEvent {CAAT.MouseEvent}
    +2535                  * @ignore
    +2536                  */
    +2537                 this.mouseDown = function (mouseEvent) {
    +2538                     if (!this.enabled) {
    +2539                         return;
    +2540                     }
    +2541 
    +2542                     this.setSpriteIndex(this.iPress);
    +2543                 };
    +2544 
    +2545                 /**
    +2546                  * Button's mouse up handler.
    +2547                  * @param mouseEvent {CAAT.MouseEvent}
    +2548                  * @ignore
    +2549                  */
    +2550                 this.mouseUp = function (mouseEvent) {
    +2551                     if (!this.enabled) {
    +2552                         return;
    +2553                     }
    +2554 
    +2555                     this.setSpriteIndex(this.iNormal);
    +2556                     this.dragging = false;
    +2557                 };
    +2558 
    +2559                 /**
    +2560                  * Button's mouse click handler. Do nothing by default. This event handler will be
    +2561                  * called ONLY if it has not been drag on the button.
    +2562                  * @param mouseEvent {CAAT.MouseEvent}
    +2563                  * @ignore
    +2564                  */
    +2565                 this.mouseClick = function (mouseEvent) {
    +2566                 };
    +2567 
    +2568                 /**
    +2569                  * Button's mouse drag handler.
    +2570                  * @param mouseEvent {CAAT.MouseEvent}
    +2571                  * @ignore
    +2572                  */
    +2573                 this.mouseDrag = function (mouseEvent) {
    +2574                     if (!this.enabled) {
    +2575                         return;
    +2576                     }
    +2577 
    +2578                     this.dragging = true;
    +2579                 };
    +2580 
    +2581                 this.setButtonImageIndex = function (_normal, _over, _press, _disabled) {
    +2582                     this.iNormal = _normal || 0;
    +2583                     this.iOver = _over || this.iNormal;
    +2584                     this.iPress = _press || this.iNormal;
    +2585                     this.iDisabled = _disabled || this.iNormal;
    +2586                     this.setSpriteIndex(this.iNormal);
    +2587                     return this;
    +2588                 };
    +2589 
    +2590                 return this;
    +2591             },
    +2592 
    +2593             findActorById : function(id) {
    +2594                 return this.id===id ? this : null;
    +2595             }
    +2596         }
    +2597     }
    +2598 });
    +2599 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Foundation_ActorContainer.js.html b/documentation/jsdoc/symbols/src/src_Foundation_ActorContainer.js.html new file mode 100644 index 00000000..bf507ea0 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Foundation_ActorContainer.js.html @@ -0,0 +1,734 @@ +
      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             /**
    +561              * Removed all Actors from this ActorContainer.
    +562              *
    +563              * @return array of former children
    +564              */
    +565             removeAllChildren: function() {
    +566                 var cl = this.childrenList.slice(); // Make a shalow copy
    +567                 for (var pos = cl.length-1;pos>=0;pos--) {
    +568                     this.removeChildAt(pos);
    +569                 }
    +570                 return cl;
    +571             },
    +572             removeChildAt:function (pos) {
    +573                 var cl = this.childrenList;
    +574                 var rm;
    +575                 if (-1 !== pos && pos>=0 && pos<this.childrenList.length) {
    +576                     cl[pos].setParent(null);
    +577                     rm = cl.splice(pos, 1);
    +578                     if (rm[0].isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
    +579                         CAAT.currentDirector.scheduleDirtyRect(rm[0].AABB);
    +580                     }
    +581 
    +582                     this.invalidateLayout();
    +583                     return rm[0];
    +584                 }
    +585 
    +586                 return null;
    +587             },
    +588             /**
    +589              * Removed an Actor from this ActorContainer.
    +590              * If the Actor is not contained into this Container, nothing happends.
    +591              *
    +592              * @param child a CAAT.Foundation.Actor object instance.
    +593              *
    +594              * @return this
    +595              */
    +596             removeChild:function (child) {
    +597                 var pos = this.findChild(child);
    +598                 var ret = this.removeChildAt(pos);
    +599 
    +600                 return ret;
    +601             },
    +602             removeFirstChild:function () {
    +603                 var first = this.childrenList.shift();
    +604                 first.parent = null;
    +605                 if (first.isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
    +606                     CAAT.currentDirector.scheduleDirtyRect(first.AABB);
    +607                 }
    +608 
    +609                 this.invalidateLayout();
    +610 
    +611                 return first;
    +612             },
    +613             removeLastChild:function () {
    +614                 if (this.childrenList.length) {
    +615                     var last = this.childrenList.pop();
    +616                     last.parent = null;
    +617                     if (last.isVisible() && CAAT.currentDirector.dirtyRectsEnabled) {
    +618                         CAAT.currentDirector.scheduleDirtyRect(last.AABB);
    +619                     }
    +620 
    +621                     this.invalidateLayout();
    +622 
    +623                     return last;
    +624                 }
    +625 
    +626                 return null;
    +627             },
    +628             /**
    +629              * @private
    +630              *
    +631              * Gets the Actor inside this ActorContainer at a given Screen coordinate.
    +632              *
    +633              * @param point an object of the form { x: float, y: float }
    +634              *
    +635              * @return the Actor contained inside this ActorContainer if found, or the ActorContainer itself.
    +636              */
    +637             findActorAtPosition:function (point) {
    +638 
    +639                 if (null === sc_findActorAtPosition.call(this, point)) {
    +640                     return null;
    +641                 }
    +642 
    +643                 // z-order
    +644                 var cl = this.childrenList;
    +645                 for (var i = cl.length - 1; i >= 0; i--) {
    +646                     var child = this.childrenList[i];
    +647 
    +648                     var np = new CAAT.Math.Point(point.x, point.y, 0);
    +649                     var contained = child.findActorAtPosition(np);
    +650                     if (null !== contained) {
    +651                         return contained;
    +652                     }
    +653                 }
    +654 
    +655                 return this;
    +656             },
    +657             /**
    +658              * Destroys this ActorContainer.
    +659              * The process falls down recursively for each contained Actor into this ActorContainer.
    +660              *
    +661              * @return this
    +662              */
    +663             destroy:function () {
    +664                 var cl = this.childrenList;
    +665                 for (var i = cl.length - 1; i >= 0; i--) {
    +666                     cl[i].destroy();
    +667                 }
    +668                 sc_destroy.call(this);
    +669 
    +670                 return this;
    +671             },
    +672             /**
    +673              * Get number of Actors into this container.
    +674              * @return integer indicating the number of children.
    +675              */
    +676             getNumChildren:function () {
    +677                 return this.childrenList.length;
    +678             },
    +679             getNumActiveChildren:function () {
    +680                 return this.activeChildren.length;
    +681             },
    +682             /**
    +683              * Returns the Actor at the iPosition(th) position.
    +684              * @param iPosition an integer indicating the position array.
    +685              * @return the CAAT.Foundation.Actor object at position.
    +686              */
    +687             getChildAt:function (iPosition) {
    +688                 return this.childrenList[ iPosition ];
    +689             },
    +690             /**
    +691              * Changes an actor's ZOrder.
    +692              * @param actor the actor to change ZOrder for
    +693              * @param index an integer indicating the new ZOrder. a value greater than children list size means to be the
    +694              * last ZOrder Actor.
    +695              */
    +696             setZOrder:function (actor, index) {
    +697                 var actorPos = this.findChild(actor);
    +698                 // the actor is present
    +699                 if (-1 !== actorPos) {
    +700                     var cl = this.childrenList;
    +701                     // trivial reject.
    +702                     if (index === actorPos) {
    +703                         return;
    +704                     }
    +705 
    +706                     if (index >= cl.length) {
    +707                         cl.splice(actorPos, 1);
    +708                         cl.push(actor);
    +709                     } else {
    +710                         var nActor = cl.splice(actorPos, 1);
    +711                         if (index < 0) {
    +712                             index = 0;
    +713                         } else if (index > cl.length) {
    +714                             index = cl.length;
    +715                         }
    +716 
    +717                         cl.splice(index, 0, nActor[0]);
    +718                     }
    +719 
    +720                     this.invalidateLayout();
    +721                 }
    +722             }
    +723         }
    +724 
    +725     }
    +726 });
    +727 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DBodyActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DBodyActor.js.html new file mode 100644 index 00000000..596e9e6b --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DCircularBody.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DCircularBody.js.html new file mode 100644 index 00000000..25b4958c --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DPolygonBody.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Box2D_B2DPolygonBody.js.html new file mode 100644 index 00000000..155f4b29 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Director.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Director.js.html new file mode 100644 index 00000000..e5a1ab10 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Foundation_Director.js.html @@ -0,0 +1,3095 @@ +
      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             },
    +465 
    +466             createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) {
    +467                 return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel, this);
    +468             },
    +469 
    +470             requestRepaint:function () {
    +471                 this.needsRepaint = true;
    +472             },
    +473 
    +474             getCurrentScene:function () {
    +475                 return this.currentScene;
    +476             },
    +477 
    +478             checkDebug:function () {
    +479                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +480                     var dd = new CAAT.Module.Debug.Debug().initialize(this.width, 60);
    +481                     this.debugInfo = dd.debugInfo.bind(dd);
    +482                 }
    +483             },
    +484             getRenderType:function () {
    +485                 return this.glEnabled ? 'WEBGL' : 'CANVAS';
    +486             },
    +487             windowResized:function (w, h) {
    +488                 var c = CAAT.Foundation.Director;
    +489                 switch (this.resize) {
    +490                     case c.RESIZE_WIDTH:
    +491                         this.setBounds(0, 0, w, this.height);
    +492                         break;
    +493                     case c.RESIZE_HEIGHT:
    +494                         this.setBounds(0, 0, this.width, h);
    +495                         break;
    +496                     case c.RESIZE_BOTH:
    +497                         this.setBounds(0, 0, w, h);
    +498                         break;
    +499                     case c.RESIZE_PROPORTIONAL:
    +500                         this.setScaleProportional(w, h);
    +501                         break;
    +502                 }
    +503 
    +504                 if (this.glEnabled) {
    +505                     this.glReset();
    +506                 }
    +507 
    +508                 if (this.onResizeCallback) {
    +509                     this.onResizeCallback(this, w, h);
    +510                 }
    +511 
    +512             },
    +513             setScaleProportional:function (w, h) {
    +514 
    +515                 var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight);
    +516 
    +517                 this.canvas.width = this.referenceWidth * factor;
    +518                 this.canvas.height = this.referenceHeight * factor;
    +519                 this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d');
    +520 
    +521                 this.__setupRetina();
    +522 
    +523                 this.setScaleAnchored(factor * this.scaleX, factor * this.scaleY, 0, 0);
    +524 //                this.setScaleAnchored(factor, factor, 0, 0);
    +525 
    +526                 if (this.glEnabled) {
    +527                     this.glReset();
    +528                 }
    +529             },
    +530             /**
    +531              * Enable window resize events and set redimension policy. A callback functio could be supplied
    +532              * to be notified on a Director redimension event. This is necessary in the case you set a redim
    +533              * policy not equal to RESIZE_PROPORTIONAL. In those redimension modes, director's area and their
    +534              * children scenes are resized to fit the new area. But scenes content is not resized, and have
    +535              * no option of knowing so uless an onResizeCallback function is supplied.
    +536              *
    +537              * @param mode {number}  RESIZE_BOTH, RESIZE_WIDTH, RESIZE_HEIGHT, RESIZE_NONE.
    +538              * @param onResizeCallback {function(director{CAAT.Director}, width{integer}, height{integer})} a callback
    +539              * to notify on canvas resize.
    +540              */
    +541             enableResizeEvents:function (mode, onResizeCallback) {
    +542                 var dd= CAAT.Foundation.Director;
    +543                 if (mode === dd.RESIZE_BOTH || mode === dd.RESIZE_WIDTH || mode === dd.RESIZE_HEIGHT || mode === dd.RESIZE_PROPORTIONAL) {
    +544                     this.referenceWidth = this.width;
    +545                     this.referenceHeight = this.height;
    +546                     this.resize = mode;
    +547                     CAAT.registerResizeListener(this);
    +548                     this.onResizeCallback = onResizeCallback;
    +549                     this.windowResized(window.innerWidth, window.innerHeight);
    +550                 } else {
    +551                     CAAT.unregisterResizeListener(this);
    +552                     this.onResizeCallback = null;
    +553                 }
    +554 
    +555                 return this;
    +556             },
    +557 
    +558             __setupRetina : function() {
    +559 
    +560                 if ( CAAT.RETINA_DISPLAY_ENABLED ) {
    +561 
    +562                     // The world is full of opensource awesomeness.
    +563                     //
    +564                     // Source: http://www.html5rocks.com/en/tutorials/canvas/hidpi/
    +565                     //
    +566                     var devicePixelRatio= CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio;
    +567                     var backingStoreRatio = this.ctx.webkitBackingStorePixelRatio ||
    +568                                             this.ctx.mozBackingStorePixelRatio ||
    +569                                             this.ctx.msBackingStorePixelRatio ||
    +570                                             this.ctx.oBackingStorePixelRatio ||
    +571                                             this.ctx.backingStorePixelRatio ||
    +572                                             1;
    +573 
    +574                     var ratio = devicePixelRatio / backingStoreRatio;
    +575 
    +576                     if (devicePixelRatio !== backingStoreRatio) {
    +577 
    +578                         var oldWidth = this.canvas.width;
    +579                         var oldHeight = this.canvas.height;
    +580 
    +581                         this.canvas.width = oldWidth * ratio;
    +582                         this.canvas.height = oldHeight * ratio;
    +583 
    +584                         this.canvas.style.width = oldWidth + 'px';
    +585                         this.canvas.style.height = oldHeight + 'px';
    +586 
    +587                         this.setScaleAnchored( ratio, ratio, 0, 0 );
    +588                     } else {
    +589                         this.setScaleAnchored( 1, 1, 0, 0 );
    +590                     }
    +591 
    +592                     this.SCREEN_RATIO= ratio;
    +593                 } else {
    +594                     this.setScaleAnchored( 1, 1, 0, 0 );
    +595                 }
    +596 
    +597                 for (var i = 0; i < this.scenes.length; i++) {
    +598                     this.scenes[i].setBounds(0, 0, this.width, this.height);
    +599                 }
    +600             },
    +601 
    +602             /**
    +603              * Set this director's bounds as well as its contained scenes.
    +604              * @param x {number} ignored, will be 0.
    +605              * @param y {number} ignored, will be 0.
    +606              * @param w {number} director width.
    +607              * @param h {number} director height.
    +608              *
    +609              * @return this
    +610              */
    +611             setBounds:function (x, y, w, h) {
    +612 
    +613                 CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h);
    +614 
    +615                 if ( this.canvas.width!==w ) {
    +616                     this.canvas.width = w;
    +617                 }
    +618 
    +619                 if ( this.canvas.height!==h ) {
    +620                     this.canvas.height = h;
    +621                 }
    +622 
    +623                 this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d');
    +624 
    +625                 this.__setupRetina();
    +626 
    +627                 if (this.glEnabled) {
    +628                     this.glReset();
    +629                 }
    +630 
    +631                 return this;
    +632             },
    +633             /**
    +634              * This method performs Director initialization. Must be called once.
    +635              * If the canvas parameter is not set, it will create a Canvas itself,
    +636              * and the developer must explicitly add the canvas to the desired DOM position.
    +637              * This method will also set the Canvas dimension to the specified values
    +638              * by width and height parameters.
    +639              *
    +640              * @param width {number} a canvas width
    +641              * @param height {number} a canvas height
    +642              * @param canvas {HTMLCanvasElement=} An optional Canvas object.
    +643              * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements
    +644              *              and want events delivered to the correct element.
    +645              *
    +646              * @return this
    +647              */
    +648             initialize:function (width, height, canvas, proxy) {
    +649                 if ( typeof canvas!=="undefined" ) {
    +650                     if ( isString(canvas) ) {
    +651                         canvas= document.getElementById(canvas);
    +652                     } else if ( !(canvas instanceof HTMLCanvasElement ) ) {
    +653                         console.log("Canvas is a: "+canvas+" ???");
    +654                     }
    +655                 }
    +656 
    +657                 if (!canvas) {
    +658                     canvas = document.createElement('canvas');
    +659                     document.body.appendChild(canvas);
    +660                 }
    +661 
    +662                 this.canvas = canvas;
    +663 
    +664                 if (typeof proxy === 'undefined') {
    +665                     proxy = canvas;
    +666                 }
    +667 
    +668                 this.setBounds(0, 0, width, height);
    +669                 this.enableEvents(proxy);
    +670 
    +671                 this.timeline = new Date().getTime();
    +672 
    +673                 // transition scene
    +674                 if (CAAT.CACHE_SCENE_ON_CHANGE) {
    +675                     this.transitionScene = new CAAT.Foundation.Scene().setBounds(0, 0, width, height);
    +676                     var transitionCanvas = document.createElement('canvas');
    +677                     transitionCanvas.width = width;
    +678                     transitionCanvas.height = height;
    +679                     var transitionImageActor = new CAAT.Foundation.Actor().setBackgroundImage(transitionCanvas);
    +680                     this.transitionScene.ctx = transitionCanvas.getContext('2d');
    +681                     this.transitionScene.addChildImmediately(transitionImageActor);
    +682                     this.transitionScene.setEaseListener(this);
    +683                 }
    +684 
    +685                 this.checkDebug();
    +686 
    +687                 return this;
    +688             },
    +689             glReset:function () {
    +690                 this.pMatrix = CAAT.WebGL.GLU.makeOrtho(0, this.referenceWidth, this.referenceHeight, 0, -1, 1);
    +691                 this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
    +692                 this.glColorProgram.setMatrixUniform(this.pMatrix);
    +693                 this.glTextureProgram.setMatrixUniform(this.pMatrix);
    +694                 this.gl.viewportWidth = this.canvas.width;
    +695                 this.gl.viewportHeight = this.canvas.height;
    +696             },
    +697             /**
    +698              * Experimental.
    +699              * Initialize a gl enabled director.
    +700              */
    +701             initializeGL:function (width, height, canvas, proxy) {
    +702 
    +703                 if (!canvas) {
    +704                     canvas = document.createElement('canvas');
    +705                     document.body.appendChild(canvas);
    +706                 }
    +707 
    +708                 canvas.width = width;
    +709                 canvas.height = height;
    +710 
    +711                 if (typeof proxy === 'undefined') {
    +712                     proxy = canvas;
    +713                 }
    +714 
    +715                 this.referenceWidth = width;
    +716                 this.referenceHeight = height;
    +717 
    +718                 var i;
    +719 
    +720                 try {
    +721                     this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/);
    +722                     this.gl.viewportWidth = width;
    +723                     this.gl.viewportHeight = height;
    +724                     CAAT.GLRENDER = true;
    +725                 } catch (e) {
    +726                 }
    +727 
    +728                 if (this.gl) {
    +729                     this.canvas = canvas;
    +730                     this.setBounds(0, 0, width, height);
    +731 
    +732                     this.enableEvents(canvas);
    +733                     this.timeline = new Date().getTime();
    +734 
    +735                     this.glColorProgram = new CAAT.WebGL.ColorProgram(this.gl).create().initialize();
    +736                     this.glTextureProgram = new CAAT.WebGL.TextureProgram(this.gl).create().initialize();
    +737                     this.glTextureProgram.useProgram();
    +738                     this.glReset();
    +739 
    +740                     var maxTris = 512;
    +741                     this.coords = new Float32Array(maxTris * 12);
    +742                     this.uv = new Float32Array(maxTris * 8);
    +743 
    +744                     this.gl.clearColor(0.0, 0.0, 0.0, 255);
    +745 
    +746                     if (this.front_to_back) {
    +747                         this.gl.clearDepth(1.0);
    +748                         this.gl.enable(this.gl.DEPTH_TEST);
    +749                         this.gl.depthFunc(this.gl.LESS);
    +750                     } else {
    +751                         this.gl.disable(this.gl.DEPTH_TEST);
    +752                     }
    +753 
    +754                     this.gl.enable(this.gl.BLEND);
    +755 // Fix FF                this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
    +756                     this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA);
    +757                     this.glEnabled = true;
    +758 
    +759                     this.checkDebug();
    +760                 } else {
    +761                     // fallback to non gl enabled canvas.
    +762                     return this.initialize(width, height, canvas);
    +763                 }
    +764 
    +765                 return this;
    +766             },
    +767             /**
    +768              * Creates an initializes a Scene object.
    +769              * @return {CAAT.Scene}
    +770              */
    +771             createScene:function () {
    +772                 var scene = new CAAT.Scene();
    +773                 this.addScene(scene);
    +774                 return scene;
    +775             },
    +776             setImagesCache:function (imagesCache, tpW, tpH) {
    +777 
    +778                 if (!imagesCache || !imagesCache.length ) {
    +779                     return this;
    +780                 }
    +781 
    +782                 var i;
    +783 
    +784                 if (null !== this.glTextureManager) {
    +785                     this.glTextureManager.deletePages();
    +786                     this.glTextureManager = null;
    +787                 }
    +788 
    +789                 // delete previous image identifiers
    +790                 if (this.imagesCache) {
    +791                     var ids = [];
    +792                     for (i = 0; i < this.imagesCache.length; i++) {
    +793                         ids.push(this.imagesCache[i].id);
    +794                     }
    +795 
    +796                     for (i = 0; i < ids.length; i++) {
    +797                         delete this.imagesCache[ ids[i] ];
    +798                     }
    +799                 }
    +800 
    +801                 this.imagesCache = imagesCache;
    +802 
    +803                 if (imagesCache) {
    +804                     for (i = 0; i < imagesCache.length; i++) {
    +805                         this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image;
    +806                     }
    +807                 }
    +808 
    +809                 this.tpW = tpW || 2048;
    +810                 this.tpH = tpH || 2048;
    +811 
    +812                 this.updateGLPages();
    +813 
    +814                 return this;
    +815             },
    +816             updateGLPages:function () {
    +817                 if (this.glEnabled) {
    +818 
    +819                     this.glTextureManager = new CAAT.Module.TexturePacker.TexturePageManager();
    +820                     this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache);
    +821 
    +822                     this.currentTexturePage = this.glTextureManager.pages[0];
    +823                     this.glTextureProgram.setTexture(this.currentTexturePage.texture);
    +824                 }
    +825             },
    +826             setGLTexturePage:function (tp) {
    +827                 this.currentTexturePage = tp;
    +828                 this.glTextureProgram.setTexture(tp.texture);
    +829                 return this;
    +830             },
    +831             /**
    +832              * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this
    +833              * function will try to recreate the whole GL texture pages.
    +834              * If many handcrafted images are to be added to the director, some performance can be achieved by calling
    +835              * <code>director.addImage(id,image,false)</code> many times and a final call with
    +836              * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages.
    +837              *
    +838              * @param id {string|object} an identitifier to retrieve the image with
    +839              * @param image {Image|HTMLCanvasElement} image to add to cache
    +840              * @param noUpdateGL {!boolean} unless otherwise stated, the director will
    +841              *  try to recreate the texture pages.
    +842              */
    +843             addImage:function (id, image, noUpdateGL) {
    +844                 if (this.getImage(id)) {
    +845 //                    for (var i = 0; i < this.imagesCache.length; i++) {
    +846                     for( var i in this.imagesCache ) {
    +847                         if (this.imagesCache[i].id === id) {
    +848                             this.imagesCache[i].image = image;
    +849                             break;
    +850                         }
    +851                     }
    +852                     this.imagesCache[ id ] = image;
    +853                 } else {
    +854                     this.imagesCache.push({ id:id, image:image });
    +855                     this.imagesCache[id] = image;
    +856                 }
    +857 
    +858                 if (!!!noUpdateGL) {
    +859                     this.updateGLPages();
    +860                 }
    +861             },
    +862             deleteImage:function (id, noUpdateGL) {
    +863                 for (var i = 0; i < this.imagesCache.length; i++) {
    +864                     if (this.imagesCache[i].id === id) {
    +865                         delete this.imagesCache[id];
    +866                         this.imagesCache.splice(i, 1);
    +867                         break;
    +868                     }
    +869                 }
    +870                 if (!!!noUpdateGL) {
    +871                     this.updateGLPages();
    +872                 }
    +873             },
    +874             setGLCurrentOpacity:function (opacity) {
    +875                 this.currentOpacity = opacity;
    +876                 this.glTextureProgram.setAlpha(opacity);
    +877             },
    +878             /**
    +879              * Render buffered elements.
    +880              * @param vertex
    +881              * @param coordsIndex
    +882              * @param uv
    +883              */
    +884             glRender:function (vertex, coordsIndex, uv) {
    +885 
    +886                 vertex = vertex || this.coords;
    +887                 uv = uv || this.uv;
    +888                 coordsIndex = coordsIndex || this.coordsIndex;
    +889 
    +890                 var gl = this.gl;
    +891 
    +892                 var numTris = coordsIndex / 12 * 2;
    +893                 var numVertices = coordsIndex / 3;
    +894 
    +895                 this.glTextureProgram.updateVertexBuffer(vertex);
    +896                 this.glTextureProgram.updateUVBuffer(uv);
    +897 
    +898                 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0);
    +899 
    +900             },
    +901             glFlush:function () {
    +902                 if (this.coordsIndex !== 0) {
    +903                     this.glRender(this.coords, this.coordsIndex, this.uv);
    +904                 }
    +905                 this.coordsIndex = 0;
    +906                 this.uvIndex = 0;
    +907 
    +908                 this.statistics.draws++;
    +909             },
    +910 
    +911             findActorAtPosition:function (point) {
    +912 
    +913                 // z-order
    +914                 var cl = this.childrenList;
    +915                 for (var i = cl.length - 1; i >= 0; i--) {
    +916                     var child = this.childrenList[i];
    +917 
    +918                     var np = new CAAT.Math.Point(point.x, point.y, 0);
    +919                     var contained = child.findActorAtPosition(np);
    +920                     if (null !== contained) {
    +921                         return contained;
    +922                     }
    +923                 }
    +924 
    +925                 return this;
    +926             },
    +927 
    +928             /**
    +929              *
    +930              * Reset statistics information.
    +931              *
    +932              * @private
    +933              */
    +934             resetStats:function () {
    +935                 this.statistics.size_total = 0;
    +936                 this.statistics.size_active = 0;
    +937                 this.statistics.draws = 0;
    +938                 this.statistics.size_discarded_by_dirty_rects = 0;
    +939             },
    +940 
    +941             /**
    +942              * This is the entry point for the animation system of the Director.
    +943              * The director is fed with the elapsed time value to maintain a virtual timeline.
    +944              * This virtual timeline will provide each Scene with its own virtual timeline, and will only
    +945              * feed time when the Scene is the current Scene, or is being switched.
    +946              *
    +947              * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be
    +948              * set up as a single clip area.
    +949              *
    +950              * @param time {number} integer indicating the elapsed time between two consecutive frames of the
    +951              * Director.
    +952              */
    +953             render:function (time) {
    +954 
    +955                 if (this.currentScene && this.currentScene.isPaused()) {
    +956                     return;
    +957                 }
    +958 
    +959                 this.time += time;
    +960 
    +961                 for (i = 0, l = this.childrenList.length; i < l; i++) {
    +962                     var c = this.childrenList[i];
    +963                     if (c.isInAnimationFrame(this.time) && !c.isPaused()) {
    +964                         var tt = c.time - c.start_time;
    +965                         c.timerManager.checkTimers(tt);
    +966                         c.timerManager.removeExpiredTimers();
    +967                     }
    +968                 }
    +969 
    +970 
    +971                 this.animate(this, this.time);
    +972 
    +973                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +974                     this.resetStats();
    +975                 }
    +976 
    +977                 /**
    +978                  * draw director active scenes.
    +979                  */
    +980                 var ne = this.childrenList.length;
    +981                 var i, tt, c;
    +982                 var ctx = this.ctx;
    +983 
    +984                 if (this.glEnabled) {
    +985 
    +986                     this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
    +987                     this.coordsIndex = 0;
    +988                     this.uvIndex = 0;
    +989 
    +990                     for (i = 0; i < ne; i++) {
    +991                         c = this.childrenList[i];
    +992                         if (c.isInAnimationFrame(this.time)) {
    +993                             tt = c.time - c.start_time;
    +994                             if (c.onRenderStart) {
    +995                                 c.onRenderStart(tt);
    +996                             }
    +997                             c.paintActorGL(this, tt);
    +998                             if (c.onRenderEnd) {
    +999                                 c.onRenderEnd(tt);
    +1000                             }
    +1001 
    +1002                             if (!c.isPaused()) {
    +1003                                 c.time += time;
    +1004                             }
    +1005 
    +1006                             if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +1007                                 this.statistics.size_total += c.size_total;
    +1008                                 this.statistics.size_active += c.size_active;
    +1009                             }
    +1010 
    +1011                         }
    +1012                     }
    +1013 
    +1014                     this.glFlush();
    +1015 
    +1016                 } else {
    +1017                     ctx.globalAlpha = 1;
    +1018                     ctx.globalCompositeOperation = 'source-over';
    +1019 
    +1020                     ctx.save();
    +1021                     if (this.dirtyRectsEnabled) {
    +1022                         this.modelViewMatrix.transformRenderingContext(ctx);
    +1023 
    +1024                         if (!CAAT.DEBUG_DIRTYRECTS) {
    +1025                             ctx.beginPath();
    +1026                             this.nDirtyRects = 0;
    +1027                             var dr = this.cDirtyRects;
    +1028                             for (i = 0; i < dr.length; i++) {
    +1029                                 var drr = dr[i];
    +1030                                 if (!drr.isEmpty()) {
    +1031                                     ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0));
    +1032                                     this.nDirtyRects++;
    +1033                                 }
    +1034                             }
    +1035                             ctx.clip();
    +1036                         } else {
    +1037                             ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
    +1038                         }
    +1039 
    +1040                     } else if (this.clear === CAAT.Foundation.Director.CLEAR_ALL) {
    +1041                         ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
    +1042                     }
    +1043 
    +1044                     for (i = 0; i < ne; i++) {
    +1045                         c = this.childrenList[i];
    +1046 
    +1047                         if (c.isInAnimationFrame(this.time)) {
    +1048                             tt = c.time - c.start_time;
    +1049                             ctx.save();
    +1050 
    +1051                             if (c.onRenderStart) {
    +1052                                 c.onRenderStart(tt);
    +1053                             }
    +1054 
    +1055                             if (!CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled) {
    +1056                                 if (this.nDirtyRects) {
    +1057                                     c.paintActor(this, tt);
    +1058                                 }
    +1059                             } else {
    +1060                                 c.paintActor(this, tt);
    +1061                             }
    +1062 
    +1063                             if (c.onRenderEnd) {
    +1064                                 c.onRenderEnd(tt);
    +1065                             }
    +1066                             ctx.restore();
    +1067 
    +1068                             if (CAAT.DEBUGAABB) {
    +1069                                 ctx.globalAlpha = 1;
    +1070                                 ctx.globalCompositeOperation = 'source-over';
    +1071                                 this.modelViewMatrix.transformRenderingContextSet(ctx);
    +1072                                 c.drawScreenBoundingBox(this, tt);
    +1073                             }
    +1074 
    +1075                             if (!c.isPaused()) {
    +1076                                 c.time += time;
    +1077                             }
    +1078 
    +1079                             if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +1080                                 this.statistics.size_total += c.size_total;
    +1081                                 this.statistics.size_active += c.size_active;
    +1082                                 this.statistics.size_dirtyRects = this.nDirtyRects;
    +1083                             }
    +1084 
    +1085                         }
    +1086                     }
    +1087 
    +1088                     if (this.nDirtyRects > 0 && (!navigator.isCocoonJS && CAAT.DEBUG) && CAAT.DEBUG_DIRTYRECTS) {
    +1089                         ctx.beginPath();
    +1090                         this.nDirtyRects = 0;
    +1091                         var dr = this.cDirtyRects;
    +1092                         for (i = 0; i < dr.length; i++) {
    +1093                             var drr = dr[i];
    +1094                             if (!drr.isEmpty()) {
    +1095                                 ctx.rect(drr.x | 0, drr.y | 0, 1 + (drr.width | 0), 1 + (drr.height | 0));
    +1096                                 this.nDirtyRects++;
    +1097                             }
    +1098                         }
    +1099 
    +1100                         ctx.clip();
    +1101                         ctx.fillStyle = 'rgba(160,255,150,.4)';
    +1102                         ctx.fillRect(0, 0, this.canvas.width, this.canvas.height);
    +1103                     }
    +1104 
    +1105                     ctx.restore();
    +1106                 }
    +1107 
    +1108                 this.frameCounter++;
    +1109             },
    +1110 
    +1111             inDirtyRect:function (actor) {
    +1112 
    +1113                 if (!this.dirtyRectsEnabled || CAAT.DEBUG_DIRTYRECTS) {
    +1114                     return true;
    +1115                 }
    +1116 
    +1117                 var dr = this.cDirtyRects;
    +1118                 var i;
    +1119                 var aabb = actor.AABB;
    +1120 
    +1121                 for (i = 0; i < dr.length; i++) {
    +1122                     if (dr[i].intersects(aabb)) {
    +1123                         return true;
    +1124                     }
    +1125                 }
    +1126 
    +1127                 this.statistics.size_discarded_by_dirty_rects += actor.size_total;
    +1128                 return false;
    +1129             },
    +1130 
    +1131             /**
    +1132              * A director is a very special kind of actor.
    +1133              * Its animation routine simple sets its modelViewMatrix in case some transformation's been
    +1134              * applied.
    +1135              * No behaviors are allowed for Director instances.
    +1136              * @param director {CAAT.Director} redundant reference to CAAT.Director itself
    +1137              * @param time {number} director time.
    +1138              */
    +1139             animate:function (director, time) {
    +1140 
    +1141                 this.timerManager.checkTimers(time);
    +1142 
    +1143                 this.setModelViewMatrix(this);
    +1144                 this.modelViewMatrix.getInverse(this.modelViewMatrixI);
    +1145                 this.setScreenBounds();
    +1146 
    +1147                 this.dirty = false;
    +1148                 this.invalid = false;
    +1149                 this.dirtyRectsIndex = -1;
    +1150                 this.cDirtyRects= [];
    +1151 
    +1152                 var cl = this.childrenList;
    +1153                 var cli;
    +1154                 var i, l;
    +1155 
    +1156 
    +1157                 if (this.dirtyRectsEnabled) {
    +1158                     var sdr = this.sDirtyRects;
    +1159                     if (sdr.length) {
    +1160                         for (i = 0, l = sdr.length; i < l; i++) {
    +1161                             this.addDirtyRect(sdr[i]);
    +1162                         }
    +1163                         this.sDirtyRects = [];
    +1164                     }
    +1165                 }
    +1166 
    +1167                 for (i = 0; i < cl.length; i++) {
    +1168                     cli = cl[i];
    +1169                     var tt = cli.time - cli.start_time;
    +1170                     cli.animate(this, tt);
    +1171                 }
    +1172 
    +1173                 this.timerManager.removeExpiredTimers();
    +1174 
    +1175                 return this;
    +1176             },
    +1177 
    +1178             /**
    +1179              * This method is used when asynchronous operations must produce some dirty rectangle painting.
    +1180              * This means that every operation out of the regular CAAT loop must add dirty rect operations
    +1181              * by calling this method.
    +1182              * For example setVisible() and remove.
    +1183              * @param rectangle
    +1184              */
    +1185             scheduleDirtyRect:function (rectangle) {
    +1186                 this.sDirtyRects.push(rectangle);
    +1187             },
    +1188             /**
    +1189              * Add a rectangle to the list of dirty screen areas which should be redrawn.
    +1190              * This is the opposite method to clear the whole screen and repaint everything again.
    +1191              * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this
    +1192              * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or
    +1193              * even lowers performance under others, so it is a developer choice to activate them via a call to
    +1194              * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ).
    +1195              *
    +1196              * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping
    +1197              * rectangles will be removed and intersecting ones will be unioned.
    +1198              *
    +1199              * Before calling this method, check if this.dirtyRectsEnabled is true.
    +1200              *
    +1201              * @param rectangle {CAAT.Rectangle}
    +1202              */
    +1203             addDirtyRect:function (rectangle) {
    +1204 
    +1205                 if (rectangle.isEmpty()) {
    +1206                     return;
    +1207                 }
    +1208 
    +1209                 var i, dr, j, drj;
    +1210                 var cdr = this.cDirtyRects;
    +1211 
    +1212                 for (i = 0; i < cdr.length; i++) {
    +1213                     dr = cdr[i];
    +1214                     if (!dr.isEmpty() && dr.intersects(rectangle)) {
    +1215                         var intersected = true;
    +1216                         while (intersected) {
    +1217                             dr.unionRectangle(rectangle);
    +1218 
    +1219                             for (j = 0; j < cdr.length; j++) {
    +1220                                 if (j !== i) {
    +1221                                     drj = cdr[j];
    +1222                                     if (!drj.isEmpty() && drj.intersects(dr)) {
    +1223                                         dr.unionRectangle(drj);
    +1224                                         drj.setEmpty();
    +1225                                         break;
    +1226                                     }
    +1227                                 }
    +1228                             }
    +1229 
    +1230                             if (j == cdr.length) {
    +1231                                 intersected = false;
    +1232                             }
    +1233                         }
    +1234 
    +1235                         for (j = 0; j < cdr.length; j++) {
    +1236                             if (cdr[j].isEmpty()) {
    +1237                                 cdr.splice(j, 1);
    +1238                             }
    +1239                         }
    +1240 
    +1241                         return;
    +1242                     }
    +1243                 }
    +1244 
    +1245                 this.dirtyRectsIndex++;
    +1246 
    +1247                 if (this.dirtyRectsIndex >= this.dirtyRects.length) {
    +1248                     for (i = 0; i < 32; i++) {
    +1249                         this.dirtyRects.push(new CAAT.Math.Rectangle());
    +1250                     }
    +1251                 }
    +1252 
    +1253                 var r = this.dirtyRects[ this.dirtyRectsIndex ];
    +1254 
    +1255                 r.x = rectangle.x;
    +1256                 r.y = rectangle.y;
    +1257                 r.x1 = rectangle.x1;
    +1258                 r.y1 = rectangle.y1;
    +1259                 r.width = rectangle.width;
    +1260                 r.height = rectangle.height;
    +1261 
    +1262                 this.cDirtyRects.push(r);
    +1263 
    +1264             },
    +1265             /**
    +1266              * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of
    +1267              * another Scene (transitionScene). So instead of drawing two scenes while transitioning from
    +1268              * one to another, first of all an scene is drawn to offscreen, and that image is translated.
    +1269              * <p>
    +1270              * Until the creation of this method, both scenes where drawn while transitioning with
    +1271              * its performance penalty since drawing two scenes could be twice as expensive than drawing
    +1272              * only one.
    +1273              * <p>
    +1274              * Though a high performance increase, we should keep an eye on memory consumption.
    +1275              *
    +1276              * @param ctx a <code>canvas.getContext('2d')</code> instnce.
    +1277              * @param scene {CAAT.Foundation.Scene} the scene to draw offscreen.
    +1278              */
    +1279             renderToContext:function (ctx, scene) {
    +1280                 /**
    +1281                  * draw actors on scene.
    +1282                  */
    +1283                 if (scene.isInAnimationFrame(this.time)) {
    +1284                     ctx.setTransform(1, 0, 0, 1, 0, 0);
    +1285 
    +1286                     ctx.globalAlpha = 1;
    +1287                     ctx.globalCompositeOperation = 'source-over';
    +1288                     ctx.clearRect(0, 0, this.width, this.height);
    +1289 
    +1290                     var octx = this.ctx;
    +1291 
    +1292                     this.ctx = ctx;
    +1293                     ctx.save();
    +1294 
    +1295                     /**
    +1296                      * to draw an scene to an offscreen canvas, we have to:
    +1297                      *   1.- save diector's world model view matrix
    +1298                      *   2.- set no transformation on director since we want the offscreen to
    +1299                      *       be drawn 1:1.
    +1300                      *   3.- set world dirty flag, so that the scene will recalculate its matrices
    +1301                      *   4.- animate the scene
    +1302                      *   5.- paint the scene
    +1303                      *   6.- restore world model view matrix.
    +1304                      */
    +1305                     var matmv = this.modelViewMatrix;
    +1306                     var matwmv = this.worldModelViewMatrix;
    +1307                     this.worldModelViewMatrix = new CAAT.Math.Matrix();
    +1308                     this.modelViewMatrix = this.worldModelViewMatrix;
    +1309                     this.wdirty = true;
    +1310                     scene.animate(this, scene.time);
    +1311                     if (scene.onRenderStart) {
    +1312                         scene.onRenderStart(scene.time);
    +1313                     }
    +1314                     scene.paintActor(this, scene.time);
    +1315                     if (scene.onRenderEnd) {
    +1316                         scene.onRenderEnd(scene.time);
    +1317                     }
    +1318                     this.worldModelViewMatrix = matwmv;
    +1319                     this.modelViewMatrix = matmv;
    +1320 
    +1321                     ctx.restore();
    +1322 
    +1323                     this.ctx = octx;
    +1324                 }
    +1325             },
    +1326             /**
    +1327              * Add a new Scene to Director's Scene list. By adding a Scene to the Director
    +1328              * does not mean it will be immediately visible, you should explicitly call either
    +1329              * <ul>
    +1330              *  <li>easeIn
    +1331              *  <li>easeInOut
    +1332              *  <li>easeInOutRandom
    +1333              *  <li>setScene
    +1334              *  <li>or any of the scene switching methods
    +1335              * </ul>
    +1336              *
    +1337              * @param scene {CAAT.Foundation.Scene}
    +1338              */
    +1339             addScene:function (scene) {
    +1340                 scene.setBounds(0, 0, this.width, this.height);
    +1341                 this.scenes.push(scene);
    +1342                 scene.setEaseListener(this);
    +1343                 if (null === this.currentScene) {
    +1344                     this.setScene(0);
    +1345                 }
    +1346             },
    +1347 
    +1348             /**
    +1349              * Private
    +1350              * Gets a contained Scene index on this Director.
    +1351              *
    +1352              * @param scene a CAAT.Foundation.Scene object instance.
    +1353              *
    +1354              * @return {number}
    +1355              */
    +1356             findScene:function (scene) {
    +1357                 var sl = this.scenes;
    +1358                 var i;
    +1359                 var len = sl.length;
    +1360 
    +1361                 for (i = 0; i < len; i++) {
    +1362                     if (sl[i] === scene) {
    +1363                         return i;
    +1364                     }
    +1365                 }
    +1366                 return -1;
    +1367             },
    +1368 
    +1369             /**
    +1370              * Private
    +1371              * Removes a scene from this director.
    +1372              *
    +1373              * @param scene a CAAT.Foundation.Scene object instance or scene index.
    +1374              *
    +1375              * @return {number}
    +1376              */
    +1377             removeScene: function(scene) {
    +1378                 if (typeof scene == 'number') {
    +1379                     this.scenes.splice(scene, 1);
    +1380                 } else {
    +1381                     var idx = this.findScene(scene);
    +1382                     if (idx > 0) {
    +1383                         this.scenes.splice(idx, 1);
    +1384                     }
    +1385                 }
    +1386             },
    +1387             /**
    +1388              * Get the number of scenes contained in the Director.
    +1389              * @return {number} the number of scenes contained in the Director.
    +1390              */
    +1391             getNumScenes:function () {
    +1392                 return this.scenes.length;
    +1393             },
    +1394             /**
    +1395              * This method offers full control over the process of switching between any given two Scenes.
    +1396              * To apply this method, you must specify the type of transition to apply for each Scene and
    +1397              * the anchor to keep the Scene pinned at.
    +1398              * <p>
    +1399              * The type of transition will be one of the following values defined in CAAT.Foundation.Scene.prototype:
    +1400              * <ul>
    +1401              *  <li>EASE_ROTATION
    +1402              *  <li>EASE_SCALE
    +1403              *  <li>EASE_TRANSLATION
    +1404              * </ul>
    +1405              *
    +1406              * <p>
    +1407              * The anchor will be any of these values defined in CAAT.Foundation.Actor:
    +1408              * <ul>
    +1409              *  <li>ANCHOR_CENTER
    +1410              *  <li>ANCHOR_TOP
    +1411              *  <li>ANCHOR_BOTTOM
    +1412              *  <li>ANCHOR_LEFT
    +1413              *  <li>ANCHOR_RIGHT
    +1414              *  <li>ANCHOR_TOP_LEFT
    +1415              *  <li>ANCHOR_TOP_RIGHT
    +1416              *  <li>ANCHOR_BOTTOM_LEFT
    +1417              *  <li>ANCHOR_BOTTOM_RIGHT
    +1418              * </ul>
    +1419              *
    +1420              * <p>
    +1421              * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the
    +1422              * point by which the scene will scaled.
    +1423              *
    +1424              * @param inSceneIndex integer indicating the Scene index to bring in to the Director.
    +1425              * @param typein integer indicating the type of transition to apply to the bringing in Scene.
    +1426              * @param anchorin integer indicating the anchor of the bringing in Scene.
    +1427              * @param outSceneIndex integer indicating the Scene index to take away from the Director.
    +1428              * @param typeout integer indicating the type of transition to apply to the taking away in Scene.
    +1429              * @param anchorout integer indicating the anchor of the taking away Scene.
    +1430              * @param time inteter indicating the time to perform the process of switchihg between Scene object
    +1431              * in milliseconds.
    +1432              * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to
    +1433              * the scenes.
    +1434              * @param interpolatorIn CAAT.Behavior.Interpolator object to apply to entering scene.
    +1435              * @param interpolatorOut CAAT.Behavior.Interpolator object to apply to exiting scene.
    +1436              */
    +1437             easeInOut:function (inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) {
    +1438 
    +1439                 if (inSceneIndex === this.getCurrentSceneIndex()) {
    +1440                     return;
    +1441                 }
    +1442 
    +1443                 var ssin = this.scenes[ inSceneIndex ];
    +1444                 var sout = this.scenes[ outSceneIndex ];
    +1445 
    +1446                 if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) {
    +1447                     this.renderToContext(this.transitionScene.ctx, sout);
    +1448                     sout = this.transitionScene;
    +1449                 }
    +1450 
    +1451                 ssin.setExpired(false);
    +1452                 sout.setExpired(false);
    +1453 
    +1454                 ssin.mouseEnabled = false;
    +1455                 sout.mouseEnabled = false;
    +1456 
    +1457                 ssin.resetTransform();
    +1458                 sout.resetTransform();
    +1459 
    +1460                 ssin.setLocation(0, 0);
    +1461                 sout.setLocation(0, 0);
    +1462 
    +1463                 ssin.alpha = 1;
    +1464                 sout.alpha = 1;
    +1465 
    +1466                 if (typein === CAAT.Foundation.Scene.EASE_ROTATION) {
    +1467                     ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn);
    +1468                 } else if (typein === CAAT.Foundation.Scene.EASE_SCALE) {
    +1469                     ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn);
    +1470                 } else {
    +1471                     ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn);
    +1472                 }
    +1473 
    +1474                 if (typeout === CAAT.Foundation.Scene.EASE_ROTATION) {
    +1475                     sout.easeRotationOut(time, alpha, anchorout, interpolatorOut);
    +1476                 } else if (typeout === CAAT.Foundation.Scene.EASE_SCALE) {
    +1477                     sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut);
    +1478                 } else {
    +1479                     sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut);
    +1480                 }
    +1481 
    +1482                 this.childrenList = [];
    +1483 
    +1484                 sout.goOut(ssin);
    +1485                 ssin.getIn(sout);
    +1486 
    +1487                 this.addChild(sout);
    +1488                 this.addChild(ssin);
    +1489             },
    +1490             /**
    +1491              * This method will switch between two given Scene indexes (ie, take away scene number 2,
    +1492              * and bring in scene number 5).
    +1493              * <p>
    +1494              * It will randomly choose for each Scene the type of transition to apply and the anchor
    +1495              * point of each transition type.
    +1496              * <p>
    +1497              * It will also set for different kind of transitions the following interpolators:
    +1498              * <ul>
    +1499              * <li>EASE_ROTATION    -> ExponentialInOutInterpolator, exponent 4.
    +1500              * <li>EASE_SCALE       -> ElasticOutInterpolator, 1.1 and .4
    +1501              * <li>EASE_TRANSLATION -> BounceOutInterpolator
    +1502              * </ul>
    +1503              *
    +1504              * <p>
    +1505              * These are the default values, and could not be changed by now.
    +1506              * This method in final instance delegates the process to easeInOutMethod.
    +1507              *
    +1508              * @see easeInOutMethod.
    +1509              *
    +1510              * @param inIndex integer indicating the entering scene index.
    +1511              * @param outIndex integer indicating the exiting scene index.
    +1512              * @param time integer indicating the time to take for the process of Scene in/out in milliseconds.
    +1513              * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions.
    +1514              */
    +1515             easeInOutRandom:function (inIndex, outIndex, time, alpha) {
    +1516 
    +1517                 var pin = Math.random();
    +1518                 var pout = Math.random();
    +1519 
    +1520                 var typeIn;
    +1521                 var interpolatorIn;
    +1522 
    +1523                 if (pin < 0.33) {
    +1524                     typeIn = CAAT.Foundation.Scene.EASE_ROTATION;
    +1525                     interpolatorIn = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4);
    +1526                 } else if (pin < 0.66) {
    +1527                     typeIn = CAAT.Foundation.Scene.EASE_SCALE;
    +1528                     interpolatorIn = new CAAT.Behavior.Interpolator().createElasticOutInterpolator(1.1, 0.4);
    +1529                 } else {
    +1530                     typeIn = CAAT.Foundation.Scene.EASE_TRANSLATE;
    +1531                     interpolatorIn = new CAAT.Behavior.Interpolator().createBounceOutInterpolator();
    +1532                 }
    +1533 
    +1534                 var typeOut;
    +1535                 var interpolatorOut;
    +1536 
    +1537                 if (pout < 0.33) {
    +1538                     typeOut = CAAT.Foundation.Scene.EASE_ROTATION;
    +1539                     interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialInOutInterpolator(4);
    +1540                 } else if (pout < 0.66) {
    +1541                     typeOut = CAAT.Foundation.Scene.EASE_SCALE;
    +1542                     interpolatorOut = new CAAT.Behavior.Interpolator().createExponentialOutInterpolator(4);
    +1543                 } else {
    +1544                     typeOut = CAAT.Foundation.Scene.EASE_TRANSLATE;
    +1545                     interpolatorOut = new CAAT.Behavior.Interpolator().createBounceOutInterpolator();
    +1546                 }
    +1547 
    +1548                 this.easeInOut(
    +1549                     inIndex,
    +1550                     typeIn,
    +1551                     (Math.random() * 8.99) >> 0,
    +1552 
    +1553                     outIndex,
    +1554                     typeOut,
    +1555                     (Math.random() * 8.99) >> 0,
    +1556 
    +1557                     time,
    +1558                     alpha,
    +1559 
    +1560                     interpolatorIn,
    +1561                     interpolatorOut);
    +1562 
    +1563             },
    +1564             /**
    +1565              * This method changes Director's current Scene to the scene index indicated by
    +1566              * inSceneIndex parameter. The Scene running in the director won't be eased out.
    +1567              *
    +1568              * @see {CAAT.Interpolator}
    +1569              * @see {CAAT.Actor}
    +1570              * @see {CAAT.Scene}
    +1571              *
    +1572              * @param inSceneIndex integer indicating the new Scene to set as current.
    +1573              * @param type integer indicating the type of transition to apply to bring the new current
    +1574              * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION,
    +1575              * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION.
    +1576              * @param time integer indicating how much time in milliseconds the Scene entrance will take.
    +1577              * @param alpha boolean indicating whether alpha transparency fading will be applied to the
    +1578              * entereing Scene.
    +1579              * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of
    +1580              * CAAT.Actor.prototype.ANCHOR_* values.
    +1581              * @param interpolator an CAAT.Interpolator object indicating the interpolation function to
    +1582              * apply.
    +1583              */
    +1584             easeIn:function (inSceneIndex, type, time, alpha, anchor, interpolator) {
    +1585                 var sin = this.scenes[ inSceneIndex ];
    +1586                 if (type === CAAT.Foundation.Scene.EASE_ROTATION) {
    +1587                     sin.easeRotationIn(time, alpha, anchor, interpolator);
    +1588                 } else if (type === CAAT.Foundation.Scene.EASE_SCALE) {
    +1589                     sin.easeScaleIn(0, time, alpha, anchor, interpolator);
    +1590                 } else {
    +1591                     sin.easeTranslationIn(time, alpha, anchor, interpolator);
    +1592                 }
    +1593                 this.childrenList = [];
    +1594                 this.addChild(sin);
    +1595 
    +1596                 sin.resetTransform();
    +1597                 sin.setLocation(0, 0);
    +1598                 sin.alpha = 1;
    +1599                 sin.mouseEnabled = false;
    +1600                 sin.setExpired(false);
    +1601             },
    +1602             /**
    +1603              * Changes (or sets) the current Director scene to the index
    +1604              * parameter. There will be no transition on scene change.
    +1605              * @param scene {number or scene object} an integer indicating the index of the target Scene or the target Scene itself
    +1606              * to be shown.
    +1607              */
    +1608             setScene:function (scene) {
    +1609                 var sceneIndex = (typeof scene == 'number') ? scene : this.findScene(scene);
    +1610                 var sin = this.scenes[ sceneIndex ];
    +1611                 this.childrenList = [];
    +1612                 this.addChild(sin);
    +1613                 this.currentScene = sin;
    +1614 
    +1615                 sin.setExpired(false);
    +1616                 sin.mouseEnabled = true;
    +1617                 sin.resetTransform();
    +1618                 sin.setLocation(0, 0);
    +1619                 sin.alpha = 1;
    +1620 
    +1621                 sin.getIn();
    +1622                 sin.activated();
    +1623             },
    +1624             /**
    +1625              * This method will change the current Scene by the Scene indicated as parameter.
    +1626              * It will apply random values for anchor and transition type.
    +1627              * @see easeInOutRandom
    +1628              *
    +1629              * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director.
    +1630              * @param time {number} an integer indicating the time the Scene transition will take.
    +1631              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
    +1632              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
    +1633              */
    +1634             switchToScene:function (iNewSceneIndex, time, alpha, transition) {
    +1635                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
    +1636 
    +1637                 if (!transition) {
    +1638                     this.setScene(iNewSceneIndex);
    +1639                 }
    +1640                 else {
    +1641                     this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha);
    +1642                 }
    +1643             },
    +1644             /**
    +1645              * Sets the previous Scene in sequence as the current Scene.
    +1646              * @see switchToScene.
    +1647              *
    +1648              * @param time {number} integer indicating the time the Scene transition will take.
    +1649              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
    +1650              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
    +1651              */
    +1652             switchToPrevScene:function (time, alpha, transition) {
    +1653 
    +1654                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
    +1655 
    +1656                 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) {
    +1657                     return;
    +1658                 }
    +1659 
    +1660                 if (!transition) {
    +1661                     this.setScene(currentSceneIndex - 1);
    +1662                 }
    +1663                 else {
    +1664                     this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha);
    +1665                 }
    +1666             },
    +1667             /**
    +1668              * Sets the previous Scene in sequence as the current Scene.
    +1669              * @see switchToScene.
    +1670              *
    +1671              * @param time {number} integer indicating the time the Scene transition will take.
    +1672              * @param alpha {boolean} a boolean indicating whether Scene transition should be fading.
    +1673              * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated.
    +1674              */
    +1675             switchToNextScene:function (time, alpha, transition) {
    +1676 
    +1677                 var currentSceneIndex = this.getSceneIndex(this.currentScene);
    +1678 
    +1679                 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) {
    +1680                     return;
    +1681                 }
    +1682 
    +1683                 if (!transition) {
    +1684                     this.setScene(currentSceneIndex + 1);
    +1685                 }
    +1686                 else {
    +1687                     this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha);
    +1688                 }
    +1689             },
    +1690             mouseEnter:function (mouseEvent) {
    +1691             },
    +1692             mouseExit:function (mouseEvent) {
    +1693             },
    +1694             mouseMove:function (mouseEvent) {
    +1695             },
    +1696             mouseDown:function (mouseEvent) {
    +1697             },
    +1698             mouseUp:function (mouseEvent) {
    +1699             },
    +1700             mouseDrag:function (mouseEvent) {
    +1701             },
    +1702             /**
    +1703              * Scene easing listener. Notifies scenes when they're about to be activated (set as current
    +1704              * director's scene).
    +1705              *
    +1706              * @param scene {CAAT.Foundation.Scene} the scene that has just been brought in or taken out of the director.
    +1707              * @param b_easeIn {boolean} scene enters or exits ?
    +1708              */
    +1709             easeEnd:function (scene, b_easeIn) {
    +1710                 // scene is going out
    +1711                 if (!b_easeIn) {
    +1712 
    +1713                     scene.setExpired(true);
    +1714                 } else {
    +1715                     this.currentScene = scene;
    +1716                     this.currentScene.activated();
    +1717                 }
    +1718 
    +1719                 scene.mouseEnabled = true;
    +1720                 scene.emptyBehaviorList();
    +1721             },
    +1722             /**
    +1723              * Return the index for a given Scene object contained in the Director.
    +1724              * @param scene {CAAT.Foundation.Scene}
    +1725              */
    +1726             getSceneIndex:function (scene) {
    +1727                 for (var i = 0; i < this.scenes.length; i++) {
    +1728                     if (this.scenes[i] === scene) {
    +1729                         return i;
    +1730                     }
    +1731                 }
    +1732                 return -1;
    +1733             },
    +1734             /**
    +1735              * Get a concrete director's scene.
    +1736              * @param index {number} an integer indicating the scene index.
    +1737              * @return {CAAT.Foundation.Scene} a CAAT.Scene object instance or null if the index is oob.
    +1738              */
    +1739             getScene:function (index) {
    +1740                 return this.scenes[index];
    +1741             },
    +1742             getSceneById : function(id) {
    +1743                 for( var i=0; i<this.scenes.length; i++ ) {
    +1744                     if (this.scenes[i].id===id) {
    +1745                         return this.scenes[i];
    +1746                     }
    +1747                 }
    +1748                 return null;
    +1749             },
    +1750             /**
    +1751              * Return the index of the current scene in the Director's scene list.
    +1752              * @return {number} the current scene's index.
    +1753              */
    +1754             getCurrentSceneIndex:function () {
    +1755                 return this.getSceneIndex(this.currentScene);
    +1756             },
    +1757             /**
    +1758              * Return the running browser name.
    +1759              * @return {string} the browser name.
    +1760              */
    +1761             getBrowserName:function () {
    +1762                 return this.browserInfo.browser;
    +1763             },
    +1764             /**
    +1765              * Return the running browser version.
    +1766              * @return {string} the browser version.
    +1767              */
    +1768             getBrowserVersion:function () {
    +1769                 return this.browserInfo.version;
    +1770             },
    +1771             /**
    +1772              * Return the operating system name.
    +1773              * @return {string} the os name.
    +1774              */
    +1775             getOSName:function () {
    +1776                 return this.browserInfo.OS;
    +1777             },
    +1778             /**
    +1779              * Gets the resource with the specified resource name.
    +1780              * The Director holds a collection called <code>imagesCache</code>
    +1781              * where you can store a JSON of the form
    +1782              *  <code>[ { id: imageId, image: imageObject } ]</code>.
    +1783              * This structure will be used as a resources cache.
    +1784              * There's a CAAT.Module.ImagePreloader class to preload resources and
    +1785              * generate this structure on loading finalization.
    +1786              *
    +1787              * @param sId {object} an String identifying a resource.
    +1788              */
    +1789             getImage:function (sId) {
    +1790                 var ret = this.imagesCache[sId];
    +1791                 if (ret) {
    +1792                     return ret;
    +1793                 }
    +1794 
    +1795                 //for (var i = 0; i < this.imagesCache.length; i++) {
    +1796                 for( var i in this.imagesCache ) {
    +1797                     if (this.imagesCache[i].id === sId) {
    +1798                         return this.imagesCache[i].image;
    +1799                     }
    +1800                 }
    +1801 
    +1802                 return null;
    +1803             },
    +1804             musicPlay: function(id) {
    +1805                 return this.audioManager.playMusic(id);
    +1806             },
    +1807             musicStop : function() {
    +1808                 this.audioManager.stopMusic();
    +1809             },
    +1810             /**
    +1811              * Adds an audio to the cache.
    +1812              *
    +1813              * @see CAAT.Module.Audio.AudioManager.addAudio
    +1814              * @return this
    +1815              */
    +1816             addAudio:function (id, url) {
    +1817                 this.audioManager.addAudio(id, url);
    +1818                 return this;
    +1819             },
    +1820             /**
    +1821              * Plays the audio instance identified by the id.
    +1822              * @param id {object} the object used to store a sound in the audioCache.
    +1823              */
    +1824             audioPlay:function (id) {
    +1825                 return this.audioManager.play(id);
    +1826             },
    +1827             /**
    +1828              * Loops an audio instance identified by the id.
    +1829              * @param id {object} the object used to store a sound in the audioCache.
    +1830              *
    +1831              * @return {HTMLElement|null} the value from audioManager.loop
    +1832              */
    +1833             audioLoop:function (id) {
    +1834                 return this.audioManager.loop(id);
    +1835             },
    +1836             endSound:function () {
    +1837                 return this.audioManager.endSound();
    +1838             },
    +1839             setSoundEffectsEnabled:function (enabled) {
    +1840                 return this.audioManager.setSoundEffectsEnabled(enabled);
    +1841             },
    +1842             setMusicEnabled:function (enabled) {
    +1843                 return this.audioManager.setMusicEnabled(enabled);
    +1844             },
    +1845             isMusicEnabled:function () {
    +1846                 return this.audioManager.isMusicEnabled();
    +1847             },
    +1848             isSoundEffectsEnabled:function () {
    +1849                 return this.audioManager.isSoundEffectsEnabled();
    +1850             },
    +1851             setVolume:function (id, volume) {
    +1852                 return this.audioManager.setVolume(id, volume);
    +1853             },
    +1854             /**
    +1855              * Removes Director's scenes.
    +1856              */
    +1857             emptyScenes:function () {
    +1858                 this.scenes = [];
    +1859             },
    +1860             /**
    +1861              * Adds an scene to this Director.
    +1862              * @param scene {CAAT.Foundation.Scene} a scene object.
    +1863              */
    +1864             addChild:function (scene) {
    +1865                 scene.parent = this;
    +1866                 this.childrenList.push(scene);
    +1867             },
    +1868             /**
    +1869              * @Deprecated use CAAT.loop instead.
    +1870              * @param fps
    +1871              * @param callback
    +1872              * @param callback2
    +1873              */
    +1874             loop:function (fps, callback, callback2) {
    +1875                 if (callback2) {
    +1876                     this.onRenderStart = callback;
    +1877                     this.onRenderEnd = callback2;
    +1878                 } else if (callback) {
    +1879                     this.onRenderEnd = callback;
    +1880                 }
    +1881                 CAAT.loop();
    +1882             },
    +1883             /**
    +1884              * Starts the director animation.If no scene is explicitly selected, the current Scene will
    +1885              * be the first scene added to the Director.
    +1886              * <p>
    +1887              * The fps parameter will set the animation quality. Higher values,
    +1888              * means CAAT will try to render more frames in the same second (at the
    +1889              * expense of cpu power at least until hardware accelerated canvas rendering
    +1890              * context are available). A value of 60 is a high frame rate and should not be exceeded.
    +1891              *
    +1892              */
    +1893             renderFrame:function () {
    +1894 
    +1895                 CAAT.currentDirector = this;
    +1896 
    +1897                 if (this.stopped) {
    +1898                     return;
    +1899                 }
    +1900 
    +1901                 var t = new Date().getTime(),
    +1902                     delta = t - this.timeline;
    +1903 
    +1904                 /*
    +1905                  check for massive frame time. if for example the current browser tab is minified or taken out of
    +1906                  foreground, the system will account for a bit time interval. minify that impact by lowering down
    +1907                  the elapsed time (virtual timelines FTW)
    +1908                  */
    +1909                 if (delta > 500) {
    +1910                     delta = 500;
    +1911                 }
    +1912 
    +1913                 if (this.onRenderStart) {
    +1914                     this.onRenderStart(delta);
    +1915                 }
    +1916 
    +1917                 this.render(delta);
    +1918 
    +1919                 if (this.debugInfo) {
    +1920                     this.debugInfo(this.statistics);
    +1921                 }
    +1922 
    +1923                 this.timeline = t;
    +1924 
    +1925                 if (this.onRenderEnd) {
    +1926                     this.onRenderEnd(delta);
    +1927                 }
    +1928 
    +1929                 this.needsRepaint = false;
    +1930             },
    +1931 
    +1932             /**
    +1933              * If the director has renderingMode: DIRTY, the timeline must be reset to register accurate frame measurement.
    +1934              */
    +1935             resetTimeline:function () {
    +1936                 this.timeline = new Date().getTime();
    +1937             },
    +1938 
    +1939             endLoop:function () {
    +1940             },
    +1941             /**
    +1942              * This method states whether the director must clear background before rendering
    +1943              * each frame.
    +1944              *
    +1945              * The clearing method could be:
    +1946              *  + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it.
    +1947              *  + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled
    +1948              *    will have their areas redrawn.
    +1949              *  + CAAT.Director.CLEAR_NONE. clears nothing.
    +1950              *
    +1951              * @param clear {CAAT.Director.CLEAR_ALL | CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS}
    +1952              * @return this.
    +1953              */
    +1954             setClear:function (clear) {
    +1955                 this.clear = clear;
    +1956                 if (this.clear === CAAT.Foundation.Director.CLEAR_DIRTY_RECTS) {
    +1957                     this.dirtyRectsEnabled = true;
    +1958                 } else {
    +1959                     this.dirtyRectsEnabled= false;
    +1960                 }
    +1961                 return this;
    +1962             },
    +1963             /**
    +1964              * Get this Director's AudioManager instance.
    +1965              * @return {CAAT.AudioManager} the AudioManager instance.
    +1966              */
    +1967             getAudioManager:function () {
    +1968                 return this.audioManager;
    +1969             },
    +1970             /**
    +1971              * Acculumate dom elements position to properly offset on-screen mouse/touch events.
    +1972              * @param node
    +1973              */
    +1974             cumulateOffset:function (node, parent, prop) {
    +1975                 var left = prop + 'Left';
    +1976                 var top = prop + 'Top';
    +1977                 var x = 0, y = 0, style;
    +1978 
    +1979                 while (navigator.browser !== 'iOS' && node && node.style) {
    +1980                     if (node.currentStyle) {
    +1981                         style = node.currentStyle['position'];
    +1982                     } else {
    +1983                         style = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null);
    +1984                         style = style ? style.getPropertyValue('position') : null;
    +1985                     }
    +1986 
    +1987                     // Accumulate offsets...
    +1988                     x += node[left];
    +1989                     y += node[top];
    +1990 
    +1991                     if (!/^(fixed)$/.test(style)) {
    +1992                         node = node[parent];
    +1993                     } else {
    +1994                         break;
    +1995                     }
    +1996                 }
    +1997 
    +1998                 return {
    +1999                     x:x,
    +2000                     y:y,
    +2001                     style:style
    +2002                 };
    +2003             },
    +2004             getOffset:function (node) {
    +2005                 var res = this.cumulateOffset(node, 'offsetParent', 'offset');
    +2006                 if (res.style === 'fixed') {
    +2007                     var res2 = this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll');
    +2008                     return {
    +2009                         x:res.x + res2.x,
    +2010                         y:res.y + res2.y
    +2011                     };
    +2012                 }
    +2013 
    +2014                 return {
    +2015                     x:res.x,
    +2016                     y:res.y
    +2017                 };
    +2018             },
    +2019             /**
    +2020              * Normalize input event coordinates to be related to (0,0) canvas position.
    +2021              * @param point {CAAT.Math.Point} canvas coordinate.
    +2022              * @param e {MouseEvent} a mouse event from an input event.
    +2023              */
    +2024             getCanvasCoord:function (point, e) {
    +2025 
    +2026                 var pt = new CAAT.Math.Point();
    +2027                 var posx = 0;
    +2028                 var posy = 0;
    +2029                 if (!e) e = window.event;
    +2030 
    +2031                 if (e.pageX || e.pageY) {
    +2032                     posx = e.pageX;
    +2033                     posy = e.pageY;
    +2034                 }
    +2035                 else if (e.clientX || e.clientY) {
    +2036                     posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
    +2037                     posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
    +2038                 }
    +2039 
    +2040                 var offset = this.getOffset(this.canvas);
    +2041 
    +2042                 posx -= offset.x;
    +2043                 posy -= offset.y;
    +2044 
    +2045                 posx*= this.SCREEN_RATIO;
    +2046                 posy*= this.SCREEN_RATIO;
    +2047 
    +2048                 //////////////
    +2049                 // transformar coordenada inversamente con affine transform de director.
    +2050 
    +2051                 pt.x = posx;
    +2052                 pt.y = posy;
    +2053                 if (!this.modelViewMatrixI) {
    +2054                     this.modelViewMatrix.getInverse(this.modelViewMatrixI);
    +2055                 }
    +2056                 this.modelViewMatrixI.transformCoord(pt);
    +2057                 posx = pt.x;
    +2058                 posy = pt.y;
    +2059 
    +2060                 point.set(posx, posy);
    +2061                 this.screenMousePoint.set(posx, posy);
    +2062 
    +2063             },
    +2064 
    +2065             __mouseDownHandler:function (e) {
    +2066 
    +2067                 /*
    +2068                  was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no
    +2069                  button was presses. Then, send a mouseUp for the previos actor, and return;
    +2070                  */
    +2071                 if (this.dragging && this.lastSelectedActor) {
    +2072                     this.__mouseUpHandler(e);
    +2073                     return;
    +2074                 }
    +2075 
    +2076                 this.getCanvasCoord(this.mousePoint, e);
    +2077                 this.isMouseDown = true;
    +2078                 var lactor = this.findActorAtPosition(this.mousePoint);
    +2079 
    +2080                 if (null !== lactor) {
    +2081 
    +2082                     var pos = lactor.viewToModel(
    +2083                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2084 
    +2085                     lactor.mouseDown(
    +2086                         new CAAT.Event.MouseEvent().init(
    +2087                             pos.x,
    +2088                             pos.y,
    +2089                             e,
    +2090                             lactor,
    +2091                             new CAAT.Math.Point(
    +2092                                 this.screenMousePoint.x,
    +2093                                 this.screenMousePoint.y)));
    +2094                 }
    +2095 
    +2096                 this.lastSelectedActor = lactor;
    +2097             },
    +2098 
    +2099             __mouseUpHandler:function (e) {
    +2100 
    +2101                 this.isMouseDown = false;
    +2102                 this.getCanvasCoord(this.mousePoint, e);
    +2103 
    +2104                 var pos = null;
    +2105                 var lactor = this.lastSelectedActor;
    +2106 
    +2107                 if (null !== lactor) {
    +2108                     pos = lactor.viewToModel(
    +2109                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2110                     if (lactor.actionPerformed && lactor.contains(pos.x, pos.y)) {
    +2111                         lactor.actionPerformed(e);
    +2112                     }
    +2113 
    +2114                     lactor.mouseUp(
    +2115                         new CAAT.Event.MouseEvent().init(
    +2116                             pos.x,
    +2117                             pos.y,
    +2118                             e,
    +2119                             lactor,
    +2120                             this.screenMousePoint,
    +2121                             this.currentScene.time));
    +2122                 }
    +2123 
    +2124                 if (!this.dragging && null !== lactor) {
    +2125                     if (lactor.contains(pos.x, pos.y)) {
    +2126                         lactor.mouseClick(
    +2127                             new CAAT.Event.MouseEvent().init(
    +2128                                 pos.x,
    +2129                                 pos.y,
    +2130                                 e,
    +2131                                 lactor,
    +2132                                 this.screenMousePoint,
    +2133                                 this.currentScene.time));
    +2134                     }
    +2135                 }
    +2136 
    +2137                 this.dragging = false;
    +2138                 this.in_ = false;
    +2139 //            CAAT.setCursor('default');
    +2140             },
    +2141 
    +2142             __mouseMoveHandler:function (e) {
    +2143                 //this.getCanvasCoord(this.mousePoint, e);
    +2144 
    +2145                 var lactor;
    +2146                 var pos;
    +2147 
    +2148                 var ct = this.currentScene ? this.currentScene.time : 0;
    +2149 
    +2150                 // drag
    +2151 
    +2152                 if (this.isMouseDown && null!==this.lastSelectedActor) {
    +2153 
    +2154                     lactor = this.lastSelectedActor;
    +2155                     pos = lactor.viewToModel(
    +2156                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2157 
    +2158                     // check for mouse move threshold.
    +2159                     if (!this.dragging) {
    +2160                         if (Math.abs(this.prevMousePoint.x - pos.x) < CAAT.DRAG_THRESHOLD_X &&
    +2161                             Math.abs(this.prevMousePoint.y - pos.y) < CAAT.DRAG_THRESHOLD_Y) {
    +2162                             return;
    +2163                         }
    +2164                     }
    +2165 
    +2166                     this.dragging = true;
    +2167 
    +2168                     var px = lactor.x;
    +2169                     var py = lactor.y;
    +2170                     lactor.mouseDrag(
    +2171                         new CAAT.Event.MouseEvent().init(
    +2172                             pos.x,
    +2173                             pos.y,
    +2174                             e,
    +2175                             lactor,
    +2176                             new CAAT.Math.Point(
    +2177                                 this.screenMousePoint.x,
    +2178                                 this.screenMousePoint.y),
    +2179                             ct));
    +2180 
    +2181                     this.prevMousePoint.x = pos.x;
    +2182                     this.prevMousePoint.y = pos.y;
    +2183 
    +2184                     /**
    +2185                      * Element has not moved after drag, so treat it as a button.
    +2186                      */
    +2187                     if (px === lactor.x && py === lactor.y) {
    +2188 
    +2189                         var contains = lactor.contains(pos.x, pos.y);
    +2190 
    +2191                         if (this.in_ && !contains) {
    +2192                             lactor.mouseExit(
    +2193                                 new CAAT.Event.MouseEvent().init(
    +2194                                     pos.x,
    +2195                                     pos.y,
    +2196                                     e,
    +2197                                     lactor,
    +2198                                     this.screenMousePoint,
    +2199                                     ct));
    +2200                             this.in_ = false;
    +2201                         }
    +2202 
    +2203                         if (!this.in_ && contains) {
    +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                             this.in_ = true;
    +2213                         }
    +2214                     }
    +2215 
    +2216                     return;
    +2217                 }
    +2218 
    +2219                 // mouse move.
    +2220                 this.in_ = true;
    +2221 
    +2222                 lactor = this.findActorAtPosition(this.mousePoint);
    +2223 
    +2224                 // cambiamos de actor.
    +2225                 if (lactor !== this.lastSelectedActor) {
    +2226                     if (null !== this.lastSelectedActor) {
    +2227 
    +2228                         pos = this.lastSelectedActor.viewToModel(
    +2229                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2230 
    +2231                         this.lastSelectedActor.mouseExit(
    +2232                             new CAAT.Event.MouseEvent().init(
    +2233                                 pos.x,
    +2234                                 pos.y,
    +2235                                 e,
    +2236                                 this.lastSelectedActor,
    +2237                                 this.screenMousePoint,
    +2238                                 ct));
    +2239                     }
    +2240 
    +2241                     if (null !== lactor) {
    +2242                         pos = lactor.viewToModel(
    +2243                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2244 
    +2245                         lactor.mouseEnter(
    +2246                             new CAAT.Event.MouseEvent().init(
    +2247                                 pos.x,
    +2248                                 pos.y,
    +2249                                 e,
    +2250                                 lactor,
    +2251                                 this.screenMousePoint,
    +2252                                 ct));
    +2253                     }
    +2254                 }
    +2255 
    +2256                 pos = lactor.viewToModel(
    +2257                     new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2258 
    +2259                 if (null !== lactor) {
    +2260 
    +2261                     lactor.mouseMove(
    +2262                         new CAAT.Event.MouseEvent().init(
    +2263                             pos.x,
    +2264                             pos.y,
    +2265                             e,
    +2266                             lactor,
    +2267                             this.screenMousePoint,
    +2268                             ct));
    +2269                 }
    +2270 
    +2271                 this.prevMousePoint.x = pos.x;
    +2272                 this.prevMousePoint.y = pos.y;
    +2273 
    +2274                 this.lastSelectedActor = lactor;
    +2275             },
    +2276 
    +2277             __mouseOutHandler:function (e) {
    +2278 
    +2279                 if (this.dragging) {
    +2280                     return;
    +2281                 }
    +2282 
    +2283                 if (null !== this.lastSelectedActor) {
    +2284 
    +2285                     this.getCanvasCoord(this.mousePoint, e);
    +2286                     var pos = new CAAT.Math.Point(this.mousePoint.x, this.mousePoint.y, 0);
    +2287                     this.lastSelectedActor.viewToModel(pos);
    +2288 
    +2289                     var ev = new CAAT.Event.MouseEvent().init(
    +2290                         pos.x,
    +2291                         pos.y,
    +2292                         e,
    +2293                         this.lastSelectedActor,
    +2294                         this.screenMousePoint,
    +2295                         this.currentScene.time);
    +2296 
    +2297                     this.lastSelectedActor.mouseExit(ev);
    +2298                     this.lastSelectedActor.mouseOut(ev);
    +2299                     if (!this.dragging) {
    +2300                         this.lastSelectedActor = null;
    +2301                     }
    +2302                 } else {
    +2303                     this.isMouseDown = false;
    +2304                     this.in_ = false;
    +2305 
    +2306                 }
    +2307 
    +2308             },
    +2309 
    +2310             __mouseOverHandler:function (e) {
    +2311 
    +2312                 if (this.dragging) {
    +2313                     return;
    +2314                 }
    +2315 
    +2316                 var lactor;
    +2317                 var pos, ev;
    +2318 
    +2319                 if (null == this.lastSelectedActor) {
    +2320                     lactor = this.findActorAtPosition(this.mousePoint);
    +2321 
    +2322                     if (null !== lactor) {
    +2323 
    +2324                         pos = lactor.viewToModel(
    +2325                             new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2326 
    +2327                         ev = new CAAT.Event.MouseEvent().init(
    +2328                             pos.x,
    +2329                             pos.y,
    +2330                             e,
    +2331                             lactor,
    +2332                             this.screenMousePoint,
    +2333                             this.currentScene ? this.currentScene.time : 0);
    +2334 
    +2335                         lactor.mouseOver(ev);
    +2336                         lactor.mouseEnter(ev);
    +2337                     }
    +2338 
    +2339                     this.lastSelectedActor = lactor;
    +2340                 } else {
    +2341                     lactor = this.lastSelectedActor;
    +2342                     pos = lactor.viewToModel(
    +2343                         new CAAT.Math.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2344 
    +2345                     ev = new CAAT.Event.MouseEvent().init(
    +2346                         pos.x,
    +2347                         pos.y,
    +2348                         e,
    +2349                         lactor,
    +2350                         this.screenMousePoint,
    +2351                         this.currentScene.time);
    +2352 
    +2353                     lactor.mouseOver(ev);
    +2354                     lactor.mouseEnter(ev);
    +2355 
    +2356                 }
    +2357             },
    +2358 
    +2359             __mouseDBLClickHandler:function (e) {
    +2360 
    +2361                 if (null !== this.lastSelectedActor) {
    +2362                     /*
    +2363                      var pos = this.lastSelectedActor.viewToModel(
    +2364                      new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0));
    +2365                      */
    +2366                     this.lastSelectedActor.mouseDblClick(
    +2367                         new CAAT.Event.MouseEvent().init(
    +2368                             this.prevMousePoint.x,
    +2369                             this.prevMousePoint.y,
    +2370                             e,
    +2371                             this.lastSelectedActor,
    +2372                             this.screenMousePoint,
    +2373                             this.currentScene.time));
    +2374                 }
    +2375             },
    +2376 
    +2377             __mouseWheelHandler:function (e) {
    +2378 
    +2379                 if (null !== this.lastSelectedActor) {
    +2380                     this.lastSelectedActor.mouseWheel(
    +2381                         new CAAT.Event.MouseEvent().init(
    +2382                             this.prevMousePoint.x,
    +2383                             this.prevMousePoint.y,
    +2384                             e,
    +2385                             this.lastSelectedActor,
    +2386                             this.screenMousePoint,
    +2387                             this.currentScene.time));
    +2388                 }
    +2389             },
    +2390 
    +2391             /**
    +2392              * Same as mouseDown but not preventing event.
    +2393              * Will only take care of first touch.
    +2394              * @param e
    +2395              */
    +2396             __touchStartHandler:function (e) {
    +2397 
    +2398                 if (e.target === this.canvas) {
    +2399                     e.preventDefault();
    +2400                     e.returnValue = false;
    +2401 
    +2402                     e = e.targetTouches[0];
    +2403 
    +2404                     var mp = this.mousePoint;
    +2405                     this.getCanvasCoord(mp, e);
    +2406                     if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) {
    +2407                         return;
    +2408                     }
    +2409 
    +2410                     this.touching = true;
    +2411 
    +2412                     this.__mouseDownHandler(e);
    +2413                 }
    +2414             },
    +2415 
    +2416             __touchEndHandler:function (e) {
    +2417 
    +2418                 if (this.touching) {
    +2419                     e.preventDefault();
    +2420                     e.returnValue = false;
    +2421 
    +2422                     e = e.changedTouches[0];
    +2423                     var mp = this.mousePoint;
    +2424                     this.getCanvasCoord(mp, e);
    +2425 
    +2426                     this.touching = false;
    +2427 
    +2428                     this.__mouseUpHandler(e);
    +2429                 }
    +2430             },
    +2431 
    +2432             __touchMoveHandler:function (e) {
    +2433 
    +2434                 if (this.touching) {
    +2435                     e.preventDefault();
    +2436                     e.returnValue = false;
    +2437 
    +2438                     if (this.gesturing) {
    +2439                         return;
    +2440                     }
    +2441 
    +2442                     for (var i = 0; i < e.targetTouches.length; i++) {
    +2443                         var ee = e.targetTouches[i];
    +2444                         var mp = this.mousePoint;
    +2445                         this.getCanvasCoord(mp, ee);
    +2446                         this.__mouseMoveHandler(ee);
    +2447                     }
    +2448                 }
    +2449             },
    +2450 
    +2451             __gestureStart:function (scale, rotation) {
    +2452                 this.gesturing = true;
    +2453                 this.__gestureRotation = this.lastSelectedActor.rotationAngle;
    +2454                 this.__gestureSX = this.lastSelectedActor.scaleX - 1;
    +2455                 this.__gestureSY = this.lastSelectedActor.scaleY - 1;
    +2456             },
    +2457 
    +2458             __gestureChange:function (scale, rotation) {
    +2459                 if (typeof scale === 'undefined' || typeof rotation === 'undefined') {
    +2460                     return;
    +2461                 }
    +2462 
    +2463                 if (this.lastSelectedActor !== null && this.lastSelectedActor.isGestureEnabled()) {
    +2464                     this.lastSelectedActor.setRotation(rotation * Math.PI / 180 + this.__gestureRotation);
    +2465 
    +2466                     this.lastSelectedActor.setScale(
    +2467                         this.__gestureSX + scale,
    +2468                         this.__gestureSY + scale);
    +2469                 }
    +2470 
    +2471             },
    +2472 
    +2473             __gestureEnd:function (scale, rotation) {
    +2474                 this.gesturing = false;
    +2475                 this.__gestureRotation = 0;
    +2476                 this.__gestureScale = 0;
    +2477             },
    +2478 
    +2479             __touchEndHandlerMT:function (e) {
    +2480 
    +2481                 e.preventDefault();
    +2482                 e.returnValue = false;
    +2483 
    +2484                 var i, j;
    +2485                 var recent = [];
    +2486 
    +2487                 /**
    +2488                  * extrae actores afectados, y coordenadas relativas para ellos.
    +2489                  * crear una coleccion touch-id : { actor, touch-event }
    +2490                  */
    +2491                 for (i = 0; i < e.changedTouches.length; i++) {
    +2492                     var _touch = e.changedTouches[i];
    +2493                     var id = _touch.identifier;
    +2494                     recent.push(id);
    +2495                 }
    +2496 
    +2497 
    +2498                 /**
    +2499                  * para los touch identificados, extraer que actores se han afectado.
    +2500                  * crear eventos con la info de touch para cada uno.
    +2501                  */
    +2502 
    +2503                 var actors = {};
    +2504                 for (i = 0; i < recent.length; i++) {
    +2505                     var touchId = recent[ i ];
    +2506                     if (this.touches[ touchId ]) {
    +2507                         var actor = this.touches[ touchId ].actor;
    +2508 
    +2509                         if (!actors[actor.id]) {
    +2510                             actors[actor.id] = {
    +2511                                 actor:actor,
    +2512                                 touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
    +2513                             };
    +2514                         }
    +2515 
    +2516                         var ev = actors[ actor.id ].touch;
    +2517                         ev.addChangedTouch(this.touches[ touchId ].touch);
    +2518                     }
    +2519                 }
    +2520 
    +2521                 /**
    +2522                  * remove ended touch info.
    +2523                  */
    +2524                 for (i = 0; i < e.changedTouches.length; i++) {
    +2525                     var touch = e.changedTouches[i];
    +2526                     var id = touch.identifier;
    +2527                     delete this.touches[id];
    +2528                 }
    +2529 
    +2530                 /**
    +2531                  * notificar a todos los actores.
    +2532                  */
    +2533                 for (var pr in actors) {
    +2534                     var data = actors[pr];
    +2535                     var actor = data.actor;
    +2536                     var touch = data.touch;
    +2537 
    +2538                     for (var actorId in this.touches) {
    +2539                         var tt = this.touches[actorId]
    +2540                         if (tt.actor.id === actor.id) {
    +2541                             touch.addTouch(tt.touch);
    +2542                         }
    +2543                     }
    +2544 
    +2545                     actor.touchEnd(touch);
    +2546                 }
    +2547             },
    +2548 
    +2549             __touchMoveHandlerMT:function (e) {
    +2550 
    +2551                 e.preventDefault();
    +2552                 e.returnValue = false;
    +2553 
    +2554                 var i;
    +2555                 var recent = [];
    +2556 
    +2557                 /**
    +2558                  * extrae actores afectados, y coordenadas relativas para ellos.
    +2559                  * crear una coleccion touch-id : { actor, touch-event }
    +2560                  */
    +2561                 for (i = 0; i < e.changedTouches.length; i++) {
    +2562                     var touch = e.changedTouches[i];
    +2563                     var id = touch.identifier;
    +2564 
    +2565                     if (this.touches[ id ]) {
    +2566                         var mp = this.mousePoint;
    +2567                         this.getCanvasCoord(mp, touch);
    +2568 
    +2569                         var actor = this.touches[ id ].actor;
    +2570                         mp = actor.viewToModel(mp);
    +2571 
    +2572                         this.touches[ id ] = {
    +2573                             actor:actor,
    +2574                             touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor)
    +2575                         };
    +2576 
    +2577                         recent.push(id);
    +2578                     }
    +2579                 }
    +2580 
    +2581                 /**
    +2582                  * para los touch identificados, extraer que actores se han afectado.
    +2583                  * crear eventos con la info de touch para cada uno.
    +2584                  */
    +2585 
    +2586                 var actors = {};
    +2587                 for (i = 0; i < recent.length; i++) {
    +2588                     var touchId = recent[ i ];
    +2589                     var actor = this.touches[ touchId ].actor;
    +2590 
    +2591                     if (!actors[actor.id]) {
    +2592                         actors[actor.id] = {
    +2593                             actor:actor,
    +2594                             touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
    +2595                         };
    +2596                     }
    +2597 
    +2598                     var ev = actors[ actor.id ].touch;
    +2599                     ev.addTouch(this.touches[ touchId ].touch);
    +2600                     ev.addChangedTouch(this.touches[ touchId ].touch);
    +2601                 }
    +2602 
    +2603                 /**
    +2604                  * notificar a todos los actores.
    +2605                  */
    +2606                 for (var pr in actors) {
    +2607                     var data = actors[pr];
    +2608                     var actor = data.actor;
    +2609                     var touch = data.touch;
    +2610 
    +2611                     for (var actorId in this.touches) {
    +2612                         var tt = this.touches[actorId]
    +2613                         if (tt.actor.id === actor.id) {
    +2614                             touch.addTouch(tt.touch);
    +2615                         }
    +2616                     }
    +2617 
    +2618                     actor.touchMove(touch);
    +2619                 }
    +2620             },
    +2621 
    +2622             __touchCancelHandleMT:function (e) {
    +2623                 this.__touchEndHandlerMT(e);
    +2624             },
    +2625 
    +2626             __touchStartHandlerMT:function (e) {
    +2627                 e.preventDefault();
    +2628                 e.returnValue = false;
    +2629 
    +2630                 var i;
    +2631                 var recent = [];
    +2632                 var allInCanvas = true;
    +2633 
    +2634                 /**
    +2635                  * extrae actores afectados, y coordenadas relativas para ellos.
    +2636                  * crear una coleccion touch-id : { actor, touch-event }
    +2637                  */
    +2638                 for (i = 0; i < e.changedTouches.length; i++) {
    +2639                     var touch = e.changedTouches[i];
    +2640                     var id = touch.identifier;
    +2641                     var mp = this.mousePoint;
    +2642                     this.getCanvasCoord(mp, touch);
    +2643                     if (mp.x < 0 || mp.y < 0 || mp.x >= this.width || mp.y >= this.height) {
    +2644                         allInCanvas = false;
    +2645                         continue;
    +2646                     }
    +2647 
    +2648                     var actor = this.findActorAtPosition(mp);
    +2649                     if (actor !== null) {
    +2650                         mp = actor.viewToModel(mp);
    +2651 
    +2652                         if (!this.touches[ id ]) {
    +2653 
    +2654                             this.touches[ id ] = {
    +2655                                 actor:actor,
    +2656                                 touch:new CAAT.Event.TouchInfo(id, mp.x, mp.y, actor)
    +2657                             };
    +2658 
    +2659                             recent.push(id);
    +2660                         }
    +2661 
    +2662                     }
    +2663                 }
    +2664 
    +2665                 /**
    +2666                  * para los touch identificados, extraer que actores se han afectado.
    +2667                  * crear eventos con la info de touch para cada uno.
    +2668                  */
    +2669 
    +2670                 var actors = {};
    +2671                 for (i = 0; i < recent.length; i++) {
    +2672                     var touchId = recent[ i ];
    +2673                     var actor = this.touches[ touchId ].actor;
    +2674 
    +2675                     if (!actors[actor.id]) {
    +2676                         actors[actor.id] = {
    +2677                             actor:actor,
    +2678                             touch:new CAAT.Event.TouchEvent().init(e, actor, this.currentScene.time)
    +2679                         };
    +2680                     }
    +2681 
    +2682                     var ev = actors[ actor.id ].touch;
    +2683                     ev.addTouch(this.touches[ touchId ].touch);
    +2684                     ev.addChangedTouch(this.touches[ touchId ].touch);
    +2685                 }
    +2686 
    +2687                 /**
    +2688                  * notificar a todos los actores.
    +2689                  */
    +2690                 for (var pr in actors) {
    +2691                     var data = actors[pr];
    +2692                     var actor = data.actor;
    +2693                     var touch = data.touch;
    +2694 
    +2695                     for (var actorId in this.touches) {
    +2696                         var tt = this.touches[actorId]
    +2697                         if (tt.actor.id === actor.id) {
    +2698                             touch.addTouch(tt.touch);
    +2699                         }
    +2700                     }
    +2701 
    +2702                     actor.touchStart(touch);
    +2703                 }
    +2704 
    +2705             },
    +2706 
    +2707             __findTouchFirstActor:function () {
    +2708 
    +2709                 var t = Number.MAX_VALUE;
    +2710                 var actor = null;
    +2711                 for (var pr in this.touches) {
    +2712 
    +2713                     var touch = this.touches[pr];
    +2714 
    +2715                     if (touch.touch.time && touch.touch.time < t && touch.actor.isGestureEnabled()) {
    +2716                         actor = touch.actor;
    +2717                         t = touch.touch.time;
    +2718                     }
    +2719                 }
    +2720                 return actor;
    +2721             },
    +2722 
    +2723             __gesturedActor:null,
    +2724             __touchGestureStartHandleMT:function (e) {
    +2725                 var actor = this.__findTouchFirstActor();
    +2726 
    +2727                 if (actor !== null && actor.isGestureEnabled()) {
    +2728                     this.__gesturedActor = actor;
    +2729                     this.__gestureRotation = actor.rotationAngle;
    +2730                     this.__gestureSX = actor.scaleX - 1;
    +2731                     this.__gestureSY = actor.scaleY - 1;
    +2732 
    +2733 
    +2734                     actor.gestureStart(
    +2735                         e.rotation * Math.PI / 180,
    +2736                         e.scale + this.__gestureSX,
    +2737                         e.scale + this.__gestureSY);
    +2738                 }
    +2739             },
    +2740 
    +2741             __touchGestureEndHandleMT:function (e) {
    +2742 
    +2743                 if (null !== this.__gesturedActor && this.__gesturedActor.isGestureEnabled()) {
    +2744                     this.__gesturedActor.gestureEnd(
    +2745                         e.rotation * Math.PI / 180,
    +2746                         e.scale + this.__gestureSX,
    +2747                         e.scale + this.__gestureSY);
    +2748                 }
    +2749 
    +2750                 this.__gestureRotation = 0;
    +2751                 this.__gestureScale = 0;
    +2752 
    +2753 
    +2754             },
    +2755 
    +2756             __touchGestureChangeHandleMT:function (e) {
    +2757 
    +2758                 if (this.__gesturedActor !== null && this.__gesturedActor.isGestureEnabled()) {
    +2759                     this.__gesturedActor.gestureChange(
    +2760                         e.rotation * Math.PI / 180,
    +2761                         this.__gestureSX + e.scale,
    +2762                         this.__gestureSY + e.scale);
    +2763                 }
    +2764             },
    +2765 
    +2766 
    +2767             addHandlers:function (canvas) {
    +2768 
    +2769                 var me = this;
    +2770 
    +2771                 window.addEventListener('mouseup', function (e) {
    +2772                     if (me.touching) {
    +2773                         e.preventDefault();
    +2774                         e.cancelBubble = true;
    +2775                         if (e.stopPropagation) e.stopPropagation();
    +2776 
    +2777                         var mp = me.mousePoint;
    +2778                         me.getCanvasCoord(mp, e);
    +2779                         me.__mouseUpHandler(e);
    +2780 
    +2781                         me.touching = false;
    +2782                     }
    +2783                 }, false);
    +2784 
    +2785                 window.addEventListener('mousedown', function (e) {
    +2786                     if (e.target === canvas) {
    +2787                         e.preventDefault();
    +2788                         e.cancelBubble = true;
    +2789                         if (e.stopPropagation) e.stopPropagation();
    +2790 
    +2791                         var mp = me.mousePoint;
    +2792                         me.getCanvasCoord(mp, e);
    +2793                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
    +2794                             return;
    +2795                         }
    +2796                         me.touching = true;
    +2797 
    +2798                         me.__mouseDownHandler(e);
    +2799                     }
    +2800                 }, false);
    +2801 
    +2802                 window.addEventListener('mouseover', function (e) {
    +2803                     if (e.target === canvas && !me.dragging) {
    +2804                         e.preventDefault();
    +2805                         e.cancelBubble = true;
    +2806                         if (e.stopPropagation) e.stopPropagation();
    +2807 
    +2808                         var mp = me.mousePoint;
    +2809                         me.getCanvasCoord(mp, e);
    +2810                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
    +2811                             return;
    +2812                         }
    +2813 
    +2814                         me.__mouseOverHandler(e);
    +2815                     }
    +2816                 }, false);
    +2817 
    +2818                 window.addEventListener('mouseout', function (e) {
    +2819                     if (e.target === canvas && !me.dragging) {
    +2820                         e.preventDefault();
    +2821                         e.cancelBubble = true;
    +2822                         if (e.stopPropagation) e.stopPropagation();
    +2823 
    +2824                         var mp = me.mousePoint;
    +2825                         me.getCanvasCoord(mp, e);
    +2826                         me.__mouseOutHandler(e);
    +2827                     }
    +2828                 }, false);
    +2829 
    +2830                 window.addEventListener('mousemove', function (e) {
    +2831                     e.preventDefault();
    +2832                     e.cancelBubble = true;
    +2833                     if (e.stopPropagation) e.stopPropagation();
    +2834 
    +2835                     var mp = me.mousePoint;
    +2836                     me.getCanvasCoord(mp, e);
    +2837                     if (!me.dragging && ( mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height )) {
    +2838                         return;
    +2839                     }
    +2840                     me.__mouseMoveHandler(e);
    +2841                 }, false);
    +2842 
    +2843                 window.addEventListener("dblclick", function (e) {
    +2844                     if (e.target === canvas) {
    +2845                         e.preventDefault();
    +2846                         e.cancelBubble = true;
    +2847                         if (e.stopPropagation) e.stopPropagation();
    +2848                         var mp = me.mousePoint;
    +2849                         me.getCanvasCoord(mp, e);
    +2850                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
    +2851                             return;
    +2852                         }
    +2853 
    +2854                         me.__mouseDBLClickHandler(e);
    +2855                     }
    +2856                 }, false);
    +2857 
    +2858                 var mouseWheelHandler = function (e) {
    +2859                     if (e.target === canvas) {
    +2860                         e.preventDefault();
    +2861                         e.cancelBubble = true;
    +2862                         if (e.stopPropagation) e.stopPropagation();
    +2863                         var mp = me.mousePoint;
    +2864                         me.getCanvasCoord(mp, e);
    +2865                         if (mp.x < 0 || mp.y < 0 || mp.x >= me.width || mp.y >= me.height) {
    +2866                             return;
    +2867                         }
    +2868 
    +2869                         //Cross browser wheel delta
    +2870                         e.wheelDelta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail)));
    +2871                         me.__mouseWheelHandler(e);
    +2872                     }
    +2873                 };
    +2874                 //IE9, Chrome, Safari, Opera
    +2875                 window.addEventListener('mousewheel', mouseWheelHandler, false);
    +2876                 //Firefox
    +2877                 window.addEventListener('DOMMouseScroll', mouseWheelHandler, false);
    +2878 
    +2879                 if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MOUSE) {
    +2880                     canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false);
    +2881                     canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false);
    +2882                     canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false);
    +2883                     canvas.addEventListener("gesturestart", function (e) {
    +2884                         if (e.target === canvas) {
    +2885                             e.preventDefault();
    +2886                             e.returnValue = false;
    +2887                             me.__gestureStart(e.scale, e.rotation);
    +2888                         }
    +2889                     }, false);
    +2890                     canvas.addEventListener("gestureend", function (e) {
    +2891                         if (e.target === canvas) {
    +2892                             e.preventDefault();
    +2893                             e.returnValue = false;
    +2894                             me.__gestureEnd(e.scale, e.rotation);
    +2895                         }
    +2896                     }, false);
    +2897                     canvas.addEventListener("gesturechange", function (e) {
    +2898                         if (e.target === canvas) {
    +2899                             e.preventDefault();
    +2900                             e.returnValue = false;
    +2901                             me.__gestureChange(e.scale, e.rotation);
    +2902                         }
    +2903                     }, false);
    +2904                 } else if (CAAT.TOUCH_BEHAVIOR === CAAT.TOUCH_AS_MULTITOUCH) {
    +2905                     canvas.addEventListener("touchstart", this.__touchStartHandlerMT.bind(this), false);
    +2906                     canvas.addEventListener("touchmove", this.__touchMoveHandlerMT.bind(this), false);
    +2907                     canvas.addEventListener("touchend", this.__touchEndHandlerMT.bind(this), false);
    +2908                     canvas.addEventListener("touchcancel", this.__touchCancelHandleMT.bind(this), false);
    +2909 
    +2910                     canvas.addEventListener("gesturestart", this.__touchGestureStartHandleMT.bind(this), false);
    +2911                     canvas.addEventListener("gestureend", this.__touchGestureEndHandleMT.bind(this), false);
    +2912                     canvas.addEventListener("gesturechange", this.__touchGestureChangeHandleMT.bind(this), false);
    +2913                 }
    +2914 
    +2915             },
    +2916 
    +2917             enableEvents:function (onElement) {
    +2918                 CAAT.RegisterDirector(this);
    +2919                 this.in_ = false;
    +2920                 this.createEventHandler(onElement);
    +2921             },
    +2922 
    +2923             createEventHandler:function (onElement) {
    +2924                 //var canvas= this.canvas;
    +2925                 this.in_ = false;
    +2926                 //this.addHandlers(canvas);
    +2927                 this.addHandlers(onElement);
    +2928             }
    +2929         }
    +2930     },
    +2931 
    +2932     onCreate:function () {
    +2933 
    +2934         if (typeof CAAT.__CSS__!=="undefined") {
    +2935 
    +2936             CAAT.Foundation.Director.prototype.clip = true;
    +2937             CAAT.Foundation.Director.prototype.glEnabled = false;
    +2938 
    +2939             CAAT.Foundation.Director.prototype.getRenderType = function () {
    +2940                 return 'CSS';
    +2941             };
    +2942 
    +2943             CAAT.Foundation.Director.prototype.setScaleProportional = function (w, h) {
    +2944 
    +2945                 var factor = Math.min(w / this.referenceWidth, h / this.referenceHeight);
    +2946                 this.setScaleAnchored(factor, factor, 0, 0);
    +2947 
    +2948                 this.eventHandler.style.width = '' + this.referenceWidth + 'px';
    +2949                 this.eventHandler.style.height = '' + this.referenceHeight + 'px';
    +2950             };
    +2951 
    +2952             CAAT.Foundation.Director.prototype.setBounds = function (x, y, w, h) {
    +2953                 CAAT.Foundation.Director.superclass.setBounds.call(this, x, y, w, h);
    +2954                 for (var i = 0; i < this.scenes.length; i++) {
    +2955                     this.scenes[i].setBounds(0, 0, w, h);
    +2956                 }
    +2957                 this.eventHandler.style.width = w + 'px';
    +2958                 this.eventHandler.style.height = h + 'px';
    +2959 
    +2960                 return this;
    +2961             };
    +2962 
    +2963             /**
    +2964              * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most
    +2965              * div in the document hierarchy (z-index 999999).
    +2966              * @param width
    +2967              * @param height
    +2968              * @param domElement
    +2969              * @param proxy
    +2970              */
    +2971             CAAT.Foundation.Director.prototype.initialize = function (width, height, domElement, proxy) {
    +2972 
    +2973                 this.timeline = new Date().getTime();
    +2974                 this.domElement = domElement;
    +2975                 this.style('position', 'absolute');
    +2976                 this.style('width', '' + width + 'px');
    +2977                 this.style('height', '' + height + 'px');
    +2978                 this.style('overflow', 'hidden');
    +2979 
    +2980                 this.enableEvents(domElement);
    +2981 
    +2982                 this.setBounds(0, 0, width, height);
    +2983 
    +2984                 this.checkDebug();
    +2985                 return this;
    +2986             };
    +2987 
    +2988             CAAT.Foundation.Director.prototype.render = function (time) {
    +2989 
    +2990                 this.time += time;
    +2991                 this.animate(this, time);
    +2992 
    +2993                 /**
    +2994                  * draw director active scenes.
    +2995                  */
    +2996                 var i, l, tt;
    +2997 
    +2998                 if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +2999                     this.resetStats();
    +3000                 }
    +3001 
    +3002                 for (i = 0, l = this.childrenList.length; i < l; i++) {
    +3003                     var c = this.childrenList[i];
    +3004                     if (c.isInAnimationFrame(this.time) && !c.isPaused()) {
    +3005                         tt = c.time - c.start_time;
    +3006                         c.timerManager.checkTimers(tt);
    +3007                         c.timerManager.removeExpiredTimers();
    +3008                     }
    +3009                 }
    +3010 
    +3011                 for (i = 0, l = this.childrenList.length; i < l; i++) {
    +3012                     var c = this.childrenList[i];
    +3013                     if (c.isInAnimationFrame(this.time)) {
    +3014                         tt = c.time - c.start_time;
    +3015                         if (c.onRenderStart) {
    +3016                             c.onRenderStart(tt);
    +3017                         }
    +3018 
    +3019                         c.paintActor(this, tt);
    +3020 
    +3021                         if (c.onRenderEnd) {
    +3022                             c.onRenderEnd(tt);
    +3023                         }
    +3024 
    +3025                         if (!c.isPaused()) {
    +3026                             c.time += time;
    +3027                         }
    +3028 
    +3029                         if (!navigator.isCocoonJS && CAAT.DEBUG) {
    +3030                             this.statistics.size_discarded_by_dirtyRects += this.drDiscarded;
    +3031                             this.statistics.size_total += c.size_total;
    +3032                             this.statistics.size_active += c.size_active;
    +3033                             this.statistics.size_dirtyRects = this.nDirtyRects;
    +3034 
    +3035                         }
    +3036 
    +3037                     }
    +3038                 }
    +3039 
    +3040                 this.frameCounter++;
    +3041             };
    +3042 
    +3043             CAAT.Foundation.Director.prototype.addScene = function (scene) {
    +3044                 scene.setVisible(true);
    +3045                 scene.setBounds(0, 0, this.width, this.height);
    +3046                 this.scenes.push(scene);
    +3047                 scene.setEaseListener(this);
    +3048                 if (null === this.currentScene) {
    +3049                     this.setScene(0);
    +3050                 }
    +3051 
    +3052                 this.domElement.appendChild(scene.domElement);
    +3053             };
    +3054 
    +3055             CAAT.Foundation.Director.prototype.emptyScenes = function () {
    +3056                 this.scenes = [];
    +3057                 this.domElement.innerHTML = '';
    +3058                 this.createEventHandler();
    +3059             };
    +3060 
    +3061             CAAT.Foundation.Director.prototype.setClear = function (clear) {
    +3062                 return this;
    +3063             };
    +3064 
    +3065             CAAT.Foundation.Director.prototype.createEventHandler = function () {
    +3066                 this.eventHandler = document.createElement('div');
    +3067                 this.domElement.appendChild(this.eventHandler);
    +3068 
    +3069                 this.eventHandler.style.position = 'absolute';
    +3070                 this.eventHandler.style.left = '0';
    +3071                 this.eventHandler.style.top = '0';
    +3072                 this.eventHandler.style.zIndex = 999999;
    +3073                 this.eventHandler.style.width = '' + this.width + 'px';
    +3074                 this.eventHandler.style.height = '' + this.height + 'px';
    +3075 
    +3076                 this.canvas = this.eventHandler;
    +3077                 this.in_ = false;
    +3078 
    +3079                 this.addHandlers(this.canvas);
    +3080             };
    +3081 
    +3082             CAAT.Foundation.Director.prototype.inDirtyRect = function () {
    +3083                 return true;
    +3084             }
    +3085         }
    +3086     }
    +3087 });
    +3088 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Foundation_Scene.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Scene.js.html new file mode 100644 index 00000000..8dceaf8c --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_SpriteImage.js.html b/documentation/jsdoc/symbols/src/src_Foundation_SpriteImage.js.html new file mode 100644 index 00000000..4bdd1f11 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_SpriteImageAnimationHelper.js.html b/documentation/jsdoc/symbols/src/src_Foundation_SpriteImageAnimationHelper.js.html new file mode 100644 index 00000000..acb13762 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_SpriteImageHelper.js.html b/documentation/jsdoc/symbols/src/src_Foundation_SpriteImageHelper.js.html new file mode 100644 index 00000000..f63eacc7 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Timer_TimerManager.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Timer_TimerManager.js.html new file mode 100644 index 00000000..e1a58f47 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_Timer_TimerTask.js.html b/documentation/jsdoc/symbols/src/src_Foundation_Timer_TimerTask.js.html new file mode 100644 index 00000000..f49bc1c9 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_Dock.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Dock.js.html new file mode 100644 index 00000000..352a9a29 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_IMActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_IMActor.js.html new file mode 100644 index 00000000..76813a36 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_InterpolatorActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_InterpolatorActor.js.html new file mode 100644 index 00000000..3b8c74f4 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_Label.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Label.js.html new file mode 100644 index 00000000..76c63fec --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Foundation_UI_Label.js.html @@ -0,0 +1,1233 @@ +
      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             shadowOffsetX: null,
    + 53             shadowOffsetY: null,
    + 54 
    + 55 
    + 56             sfont        : null,
    + 57 
    + 58             chain        : null,
    + 59 
    + 60             setDefault : function( defaultStyles ) {
    + 61                 this.defaultFS    =   24;
    + 62                 this.font         =   "Arial";
    + 63                 this.fontSize     =   this.defaultFS;
    + 64                 this.fill         =   '#000';
    + 65                 this.stroke       =   '#f00';
    + 66                 this.filled       =   true;
    + 67                 this.stroked      =   false;
    + 68                 this.strokeSize   =   1;
    + 69                 this.italic       =   false;
    + 70                 this.bold         =   false;
    + 71                 this.alignment    =   "left";
    + 72                 this.tabSize      =   75;
    + 73                 this.shadow       =   false;
    + 74                 this.shadowBlur   =   0;
    + 75                 this.shadowColor  =   "#000";
    + 76                 this.shadowOffsetX=   0;
    + 77                 this.shadowOffsetY=   0;
    + 78 
    + 79 
    + 80                 for( var style in defaultStyles ) {
    + 81                     if ( defaultStyles.hasOwnProperty(style) ) {
    + 82                         this[style]= defaultStyles[style];
    + 83                     }
    + 84                 }
    + 85 
    + 86                 this.__setFont();
    + 87 
    + 88                 return this;
    + 89             },
    + 90 
    + 91             setStyle : function( styles ) {
    + 92                 if ( typeof styles!=="undefined" ) {
    + 93                     for( var style in styles ) {
    + 94                         this[style]= styles[style];
    + 95                     }
    + 96                 }
    + 97                 return this;
    + 98             },
    + 99 
    +100             applyStyle : function() {
    +101                 this.__setFont();
    +102 
    +103                 return this;
    +104             },
    +105 
    +106             clone : function( ) {
    +107                 var c= new renderContextStyle( this.ctx );
    +108                 var pr;
    +109                 for( pr in this ) {
    +110                     if ( this.hasOwnProperty(pr) ) {
    +111                         c[pr]= this[pr];
    +112                     }
    +113                 }
    +114                 /*
    +115                 c.defaultFS  =   this.defaultFS;
    +116                 c.font       =   this.font;
    +117                 c.fontSize   =   this.fontSize;
    +118                 c.fill       =   this.fill;
    +119                 c.stroke     =   this.stroke;
    +120                 c.filled     =   this.filled;
    +121                 c.stroked    =   this.stroked;
    +122                 c.strokeSize =   this.strokeSize;
    +123                 c.italic     =   this.italic;
    +124                 c.bold       =   this.bold;
    +125                 c.alignment  =   this.alignment;
    +126                 c.tabSize    =   this.tabSize;
    +127                 */
    +128 
    +129                 var me= this;
    +130                 while( me.chain ) {
    +131                     me= me.chain;
    +132                     for( pr in me ) {
    +133                         if ( c[pr]===null  && me.hasOwnProperty(pr) ) {
    +134                             c[pr]= me[pr];
    +135                         }
    +136                     }
    +137                 }
    +138 
    +139                 c.__setFont();
    +140 
    +141                 return c;
    +142             },
    +143 
    +144             __getProperty : function( prop ) {
    +145                 var me= this;
    +146                 var res;
    +147                 do {
    +148                     res= me[prop];
    +149                     if ( res!==null ) {
    +150                         return res;
    +151                     }
    +152                     me= me.chain;
    +153                 } while( me );
    +154 
    +155                 return null;
    +156             },
    +157 
    +158             image : function( ctx ) {
    +159                 this.__setShadow( ctx );
    +160             },
    +161 
    +162             text : function( ctx, text, x, y ) {
    +163 
    +164                 this.__setShadow( ctx );
    +165 
    +166                 ctx.font= this.__getProperty("sfont");
    +167 
    +168                 if ( this.filled ) {
    +169                     this.__fillText( ctx,text,x,y );
    +170                 }
    +171                 if ( this.stroked ) {
    +172                     this.__strokeText( ctx,text,x,y );
    +173                 }
    +174             },
    +175 
    +176             __setShadow : function( ctx ) {
    +177                 if ( this.__getProperty("shadow" ) ) {
    +178                     ctx.shadowBlur   = this.__getProperty("shadowBlur");
    +179                     ctx.shadowColor  = this.__getProperty("shadowColor");
    +180                     ctx.shadowOffsetX= this.__getProperty("shadowOffsetX");
    +181                     ctx.shadowOffsetY= this.__getProperty("shadowOffsetY");
    +182                 }
    +183             },
    +184 
    +185             __fillText : function( ctx, text, x, y ) {
    +186                 ctx.fillStyle= this.__getProperty("fill");
    +187                 ctx.fillText( text, x, y );
    +188             },
    +189 
    +190             __strokeText : function( ctx, text, x, y ) {
    +191                 ctx.strokeStyle= this.__getProperty("stroke");
    +192                 ctx.lineWidth= this.__getProperty("strokeSize");
    +193                 ctx.beginPath();
    +194                 ctx.strokeText( text, x, y );
    +195             },
    +196 
    +197             __setFont : function() {
    +198                 var italic= this.__getProperty("italic");
    +199                 var bold= this.__getProperty("bold");
    +200                 var fontSize= this.__getProperty("fontSize");
    +201                 var font= this.__getProperty("font");
    +202 
    +203                 this.sfont= (italic ? "italic " : "") +
    +204                     (bold ? "bold " : "") +
    +205                     fontSize + "px " +
    +206                     font;
    +207 
    +208                 this.ctx.font= this.__getProperty("sfont");
    +209             },
    +210 
    +211             setBold : function( bool ) {
    +212                 if ( bool!=this.bold ) {
    +213                     this.bold= bool;
    +214                     this.__setFont();
    +215                 }
    +216             },
    +217 
    +218             setItalic : function( bool ) {
    +219                 if ( bool!=this.italic ) {
    +220                     this.italic= bool;
    +221                     this.__setFont();
    +222                 }
    +223             },
    +224 
    +225             setStroked : function( bool ) {
    +226                 this.stroked= bool;
    +227             },
    +228 
    +229             setFilled : function( bool ) {
    +230                 this.filled= bool;
    +231             },
    +232 
    +233             getTabPos : function( x ) {
    +234                 var ts= this.__getProperty("tabSize");
    +235                 return (((x/ts)>>0)+1)*ts;
    +236             },
    +237 
    +238             setFillStyle : function( style ) {
    +239                 this.fill= style;
    +240             },
    +241 
    +242             setStrokeStyle : function( style ) {
    +243                 this.stroke= style;
    +244             },
    +245 
    +246             setStrokeSize : function( size ) {
    +247                 this.strokeSize= size;
    +248             },
    +249 
    +250             setAlignment : function( alignment ) {
    +251                 this.alignment= alignment;
    +252             },
    +253 
    +254             setFontSize : function( size ) {
    +255                 if ( size!==this.fontSize ) {
    +256                     this.fontSize= size;
    +257                     this.__setFont();
    +258                 }
    +259             }
    +260         };
    +261 
    +262         /**
    +263          * This class keeps track of styles, images, and the current applied style.
    +264          */
    +265         var renderContext= function() {
    +266             this.text= "";
    +267             return this;
    +268         };
    +269 
    +270         renderContext.prototype= {
    +271 
    +272             x           :   0,
    +273             y           :   0,
    +274             width       :   0,
    +275             text        :   null,
    +276 
    +277             crcs        :   null,   // current rendering context style
    +278             rcs         :   null,   // rendering content styles stack
    +279 
    +280             styles      :   null,
    +281             images      :   null,
    +282 
    +283             lines       :   null,
    +284 
    +285             documentHeight  : 0,
    +286 
    +287             anchorStack     : null,
    +288 
    +289             __nextLine : function() {
    +290                 this.x= 0;
    +291                 this.currentLine= new DocumentLine(
    +292                     CAAT.Module.Font.Font.getFontMetrics( this.crcs.sfont)  );
    +293                 this.lines.push( this.currentLine );
    +294             },
    +295 
    +296             /**
    +297              *
    +298              * @param image {CAAT.SpriteImage}
    +299              * @param r {number=}
    +300              * @param c {number=}
    +301              * @private
    +302              */
    +303             __image : function( image, r, c ) {
    +304 
    +305 
    +306                 var image_width;
    +307 
    +308                 if ( typeof r!=="undefined" && typeof c!=="undefined" ) {
    +309                     image_width= image.getWidth();
    +310                 } else {
    +311                     image_width= ( image instanceof CAAT.Foundation.SpriteImage ) ? image.getWidth() : image.getWrappedImageWidth();
    +312                 }
    +313 
    +314                 // la imagen cabe en este sitio.
    +315                 if ( this.width ) {
    +316                     if ( image_width + this.x > this.width && this.x>0 ) {
    +317                         this.__nextLine();
    +318                     }
    +319                 }
    +320 
    +321                 this.currentLine.addElementImage( new DocumentElementImage(
    +322                     this.x,
    +323                     image,
    +324                     r,
    +325                     c,
    +326                     this.crcs.clone(),
    +327                     this.__getCurrentAnchor() ) );
    +328 
    +329                 this.x+= image_width;
    +330             },
    +331 
    +332             __text : function() {
    +333 
    +334                 if ( this.text.length===0 ) {
    +335                     return;
    +336                 }
    +337 
    +338                 var text_width= this.ctx.measureText(this.text).width;
    +339 
    +340                 // la palabra cabe en este sitio.
    +341                 if ( this.width ) {
    +342                     if ( text_width + this.x > this.width && this.x>0 ) {
    +343                         this.__nextLine();
    +344                     }
    +345                 }
    +346 
    +347                 //this.crcs.text( this.text, this.x, this.y );
    +348                 this.currentLine.addElement( new DocumentElementText(
    +349                     this.text,
    +350                     this.x,
    +351                     text_width,
    +352                     0, //this.crcs.__getProperty("fontSize"), calculated later
    +353                     this.crcs.clone(),
    +354                     this.__getCurrentAnchor() ) ) ;
    +355 
    +356                 this.x+= text_width;
    +357 
    +358                 this.text="";
    +359             },
    +360 
    +361             fchar : function( _char ) {
    +362 
    +363                 if ( _char===' ' ) {
    +364 
    +365                     this.__text();
    +366 
    +367                     this.x+= this.ctx.measureText(_char).width;
    +368                     if ( this.width ) {
    +369                         if ( this.x > this.width ) {
    +370                             this.__nextLine();
    +371                         }
    +372                     }
    +373                 } else {
    +374                     this.text+= _char;
    +375                 }
    +376             },
    +377 
    +378             end : function() {
    +379                 if ( this.text.length>0 ) {
    +380                     this.__text();
    +381                 }
    +382 
    +383                 var y=0;
    +384                 var lastLineEstimatedDescent= 0;
    +385                 for( var i=0; i<this.lines.length; i++ ) {
    +386                     var inc= this.lines[i].getHeight();
    +387 
    +388                     if ( inc===0 ) {
    +389                         // lineas vacias al menos tienen tamaño del estilo por defecto
    +390                         inc= this.styles["default"].fontSize;
    +391                     }
    +392                     y+= inc;
    +393 
    +394                     /**
    +395                      * add the estimated descent of the last text line to document height's.
    +396                      * the descent is estimated to be a 20% of font's height.
    +397                      */
    +398                     if ( i===this.lines.length-1 ) {
    +399                         lastLineEstimatedDescent= (inc*.25)>>0;
    +400                     }
    +401 
    +402                     this.lines[i].setY(y);
    +403                 }
    +404 
    +405                 this.documentHeight= y + lastLineEstimatedDescent;
    +406             },
    +407 
    +408             getDocumentHeight : function() {
    +409                 return this.documentHeight;
    +410             },
    +411 
    +412             __getCurrentAnchor : function() {
    +413                 if ( this.anchorStack.length ) {
    +414                     return this.anchorStack[ this.anchorStack.length-1 ];
    +415                 }
    +416 
    +417                 return null;
    +418             },
    +419 
    +420             __resetAppliedStyles : function() {
    +421                 this.rcs= [];
    +422                 this.__pushDefaultStyles();
    +423             },
    +424 
    +425             __pushDefaultStyles : function() {
    +426                 this.crcs= new renderContextStyle(this.ctx).setDefault( this.styles["default"] );
    +427                 this.rcs.push( this.crcs );
    +428             },
    +429 
    +430             __pushStyle : function( style ) {
    +431                 var pcrcs= this.crcs;
    +432                 this.crcs= new renderContextStyle(this.ctx);
    +433                 this.crcs.chain= pcrcs;
    +434                 this.crcs.setStyle( style );
    +435                 this.crcs.applyStyle( );
    +436 
    +437                 this.rcs.push( this.crcs );
    +438             },
    +439 
    +440             __popStyle : function() {
    +441                 // make sure you don't remove default style.
    +442                 if ( this.rcs.length>1 ) {
    +443                     this.rcs.pop();
    +444                     this.crcs= this.rcs[ this.rcs.length-1 ];
    +445                     this.crcs.applyStyle();
    +446                 }
    +447             },
    +448 
    +449             __popAnchor : function() {
    +450                 if ( this.anchorStack.length> 0 ) {
    +451                     this.anchorStack.pop();
    +452                 }
    +453             },
    +454 
    +455             __pushAnchor : function( anchor ) {
    +456                 this.anchorStack.push( anchor );
    +457             },
    +458 
    +459             start : function( ctx, styles, images, width ) {
    +460                 this.x=0;
    +461                 this.y=0;
    +462                 this.width= typeof width!=="undefined" ? width : 0;
    +463                 this.ctx= ctx;
    +464                 this.lines= [];
    +465                 this.styles= styles;
    +466                 this.images= images;
    +467                 this.anchorStack= [];
    +468 
    +469                 this.__resetAppliedStyles();
    +470                 this.__nextLine();
    +471 
    +472             },
    +473 
    +474             setTag  : function( tag ) {
    +475 
    +476                 var pairs, style;
    +477 
    +478                 this.__text();
    +479 
    +480                 tag= tag.toLowerCase();
    +481                 if ( tag==='b' ) {
    +482                     this.crcs.setBold( true );
    +483                 } else if ( tag==='/b' ) {
    +484                     this.crcs.setBold( false );
    +485                 } else if ( tag==='i' ) {
    +486                     this.crcs.setItalic( true );
    +487                 } else if ( tag==='/i' ) {
    +488                     this.crcs.setItalic( false );
    +489                 } else if ( tag==='stroked' ) {
    +490                     this.crcs.setStroked( true );
    +491                 } else if ( tag==='/stroked' ) {
    +492                     this.crcs.setStroked( false );
    +493                 } else if ( tag==='filled' ) {
    +494                     this.crcs.setFilled( true );
    +495                 } else if ( tag==='/filled' ) {
    +496                     this.crcs.setFilled( false );
    +497                 } else if ( tag==='tab' ) {
    +498                     this.x= this.crcs.getTabPos( this.x );
    +499                 } else if ( tag==='br' ) {
    +500                     this.__nextLine();
    +501                 } else if ( tag==='/a' ) {
    +502                     this.__popAnchor();
    +503                 } else if ( tag==='/style' ) {
    +504                     if ( this.rcs.length>1 ) {
    +505                         this.__popStyle();
    +506                     } else {
    +507                         /**
    +508                          * underflow pop de estilos. eres un cachondo.
    +509                          */
    +510                     }
    +511                 } else {
    +512                     if ( tag.indexOf("fillcolor")===0 ) {
    +513                         pairs= tag.split("=");
    +514                         this.crcs.setFillStyle( pairs[1] );
    +515                     } else if ( tag.indexOf("strokecolor")===0 ) {
    +516                         pairs= tag.split("=");
    +517                         this.crcs.setStrokeStyle( pairs[1] );
    +518                     } else if ( tag.indexOf("strokesize")===0 ) {
    +519                         pairs= tag.split("=");
    +520                         this.crcs.setStrokeSize( pairs[1]|0 );
    +521                     } else if ( tag.indexOf("fontsize")===0 ) {
    +522                         pairs= tag.split("=");
    +523                         this.crcs.setFontSize( pairs[1]|0 );
    +524                     } else if ( tag.indexOf("style")===0 ) {
    +525                         pairs= tag.split("=");
    +526                         style= this.styles[ pairs[1] ];
    +527                         if ( style ) {
    +528                             this.__pushStyle( style );
    +529                         }
    +530                     } else if ( tag.indexOf("image")===0) {
    +531                         pairs= tag.split("=")[1].split(",");
    +532                         var image= pairs[0];
    +533                         if ( this.images[image] ) {
    +534                             var r= 0, c=0;
    +535                             if ( pairs.length>=3 ) {
    +536                                 r= pairs[1]|0;
    +537                                 c= pairs[2]|0;
    +538                             }
    +539                             this.__image( this.images[image], r, c );
    +540                         } else if (CAAT.currentDirector.getImage(image) ) {
    +541                             this.__image( CAAT.currentDirector.getImage(image) );
    +542                         }
    +543                     } else if ( tag.indexOf("a=")===0 ) {
    +544                         pairs= tag.split("=");
    +545                         this.__pushAnchor( pairs[1] );
    +546                     }
    +547                 }
    +548             }
    +549         };
    +550 
    +551         /**
    +552          * Abstract document element.
    +553          * The document contains a collection of DocumentElementText and DocumentElementImage.
    +554          * @param anchor
    +555          * @param style
    +556          */
    +557         var DocumentElement= function( anchor, style ) {
    +558             this.link= anchor;
    +559             this.style= style;
    +560             return this;
    +561         };
    +562 
    +563         DocumentElement.prototype= {
    +564             x       : null,
    +565             y       : null,
    +566             width   : null,
    +567             height  : null,
    +568 
    +569             style   : null,
    +570 
    +571             link    : null,
    +572 
    +573             isLink : function() {
    +574                 return this.link;
    +575             },
    +576 
    +577             setLink : function( link ) {
    +578                 this.link= link;
    +579                 return this;
    +580             },
    +581 
    +582             getLink : function() {
    +583                 return this.link;
    +584             },
    +585 
    +586             contains : function(x,y) {
    +587                 return false;
    +588             }
    +589 
    +590         };
    +591 
    +592         /**
    +593          * This class represents an image in the document.
    +594          * @param x
    +595          * @param image
    +596          * @param r
    +597          * @param c
    +598          * @param style
    +599          * @param anchor
    +600          */
    +601         var DocumentElementImage= function( x, image, r, c, style, anchor ) {
    +602 
    +603             DocumentElementImage.superclass.constructor.call(this, anchor, style);
    +604 
    +605             this.x= x;
    +606             this.image= image;
    +607             this.row= r;
    +608             this.column= c;
    +609             this.width= image.getWidth();
    +610             this.height= image.getHeight();
    +611 
    +612             if ( this.image instanceof CAAT.SpriteImage || this.image instanceof CAAT.Foundation.SpriteImage ) {
    +613 
    +614                 if ( typeof r==="undefined" || typeof c==="undefined" ) {
    +615                     this.spriteIndex= 0;
    +616                 } else {
    +617                     this.spriteIndex= r*image.columns+c;
    +618                 }
    +619                 this.paint= this.paintSI;
    +620             }
    +621 
    +622             return this;
    +623         };
    +624 
    +625         DocumentElementImage.prototype= {
    +626             image   : null,
    +627             row     : null,
    +628             column  : null,
    +629             spriteIndex : null,
    +630 
    +631             paint : function( ctx ) {
    +632                 this.style.image( ctx );
    +633                 ctx.drawImage( this.image, this.x, -this.height+1);
    +634                 if ( DEBUG ) {
    +635                     ctx.strokeRect( this.x, -this.height+1, this.width, this.height );
    +636                 }
    +637             },
    +638 
    +639             paintSI : function( ctx ) {
    +640                 this.style.image( ctx );
    +641                 this.image.setSpriteIndex( this.spriteIndex );
    +642                 this.image.paint( { ctx: ctx }, 0, this.x,  -this.height+1 );
    +643                 if ( DEBUG ) {
    +644                     ctx.strokeRect( this.x, -this.height+1, this.width, this.height );
    +645                 }
    +646             },
    +647 
    +648             getHeight : function() {
    +649                 return this.image instanceof CAAT.Foundation.SpriteImage ? this.image.getHeight() : this.image.height;
    +650             },
    +651 
    +652             getFontMetrics : function() {
    +653                 return null;
    +654             },
    +655 
    +656             contains : function(x,y) {
    +657                 return x>=this.x && x<=this.x+this.width && y>=this.y && y<this.y + this.height;
    +658             },
    +659 
    +660             setYPosition : function( baseline ) {
    +661                 this.y= baseline - this.height + 1;
    +662             }
    +663 
    +664         };
    +665 
    +666         /**
    +667          * This class represents a text in the document. The text will have applied the styles selected
    +668          * when it was defined.
    +669          * @param text
    +670          * @param x
    +671          * @param width
    +672          * @param height
    +673          * @param style
    +674          * @param anchor
    +675          */
    +676         var DocumentElementText= function( text,x,width,height,style, anchor) {
    +677 
    +678             DocumentElementText.superclass.constructor.call(this, anchor, style);
    +679 
    +680             this.x=         x;
    +681             this.y=         0;
    +682             this.width=     width;
    +683             this.text=      text;
    +684             this.style=     style;
    +685             this.fm=        CAAT.Module.Font.Font.getFontMetrics( style.sfont );
    +686             this.height=    this.fm.height;
    +687 
    +688             return this;
    +689         };
    +690 
    +691         DocumentElementText.prototype= {
    +692 
    +693             text    : null,
    +694             style   : null,
    +695             fm      : null,
    +696 
    +697             bl      : null,     // where baseline was set. current 0 in ctx.
    +698 
    +699             paint : function( ctx ) {
    +700                 this.style.text( ctx, this.text, this.x, 0 );
    +701                 if ( DEBUG ) {
    +702                     ctx.strokeRect( this.x, -this.fm.ascent, this.width, this.height);
    +703                 }
    +704             },
    +705 
    +706             getHeight : function() {
    +707                 return this.fm.height;
    +708             },
    +709 
    +710             getFontMetrics : function() {
    +711                 return this.fm; //CAAT.Font.getFontMetrics( this.style.sfont);
    +712             },
    +713 
    +714             contains : function( x, y ) {
    +715                 return x>= this.x && x<=this.x+this.width &&
    +716                     y>= this.y && y<= this.y+this.height;
    +717             },
    +718 
    +719             setYPosition : function( baseline ) {
    +720                 this.bl= baseline;
    +721                 this.y= baseline - this.fm.ascent;
    +722             }
    +723         };
    +724 
    +725         extend( DocumentElementImage, DocumentElement );
    +726         extend( DocumentElementText, DocumentElement );
    +727 
    +728         /**
    +729          * This class represents a document line.
    +730          * It contains a collection of DocumentElement objects.
    +731          */
    +732         var DocumentLine= function( defaultFontMetrics ) {
    +733             this.elements= [];
    +734             this.defaultFontMetrics= defaultFontMetrics;
    +735             return this;
    +736         };
    +737 
    +738         DocumentLine.prototype= {
    +739             elements    : null,
    +740             width       : 0,
    +741             height      : 0,
    +742             defaultHeight : 0,  // default line height in case it is empty.
    +743             y           : 0,
    +744             x           : 0,
    +745             alignment   : null,
    +746 
    +747             baselinePos : 0,
    +748 
    +749             addElement : function( element ) {
    +750                 this.width= Math.max( this.width, element.x + element.width );
    +751                 this.height= Math.max( this.height, element.height );
    +752                 this.elements.push( element );
    +753                 this.alignment= element.style.__getProperty("alignment");
    +754             },
    +755 
    +756             addElementImage : function( element ) {
    +757                 this.width= Math.max( this.width, element.x + element.width );
    +758                 this.height= Math.max( this.height, element.height );
    +759                 this.elements.push( element );
    +760             },
    +761 
    +762             getHeight : function() {
    +763                 return this.height;
    +764             },
    +765 
    +766             setY : function( y ) {
    +767                 this.y= y;
    +768             },
    +769 
    +770             getY : function() {
    +771                 return this.y;
    +772             },
    +773 
    +774             paint : function( ctx ) {
    +775                 ctx.save();
    +776                 ctx.translate(this.x,this.y + this.baselinePos );
    +777 
    +778                 for( var i=0; i<this.elements.length; i++ ) {
    +779                     this.elements[i].paint(ctx);
    +780                 }
    +781 
    +782                 ctx.restore();
    +783 
    +784             },
    +785 
    +786             setAlignment : function( width ) {
    +787                 var j;
    +788 
    +789                 if ( this.alignment==="center" ) {
    +790                     this.x= (width - this.width)/2;
    +791                 } else if ( this.alignment==="right" ) {
    +792                     this.x= width - this.width;
    +793                 } else if ( this.alignment==="justify" ) {
    +794 
    +795                     // justify: only when text overflows further than document's 80% width
    +796                     if ( this.width / width >= JUSTIFY_RATIO && this.elements.length>1 ) {
    +797                         var remaining= width - this.width;
    +798 
    +799                         var forEachElement= (remaining/(this.elements.length-1))|0;
    +800                         for( j=1; j<this.elements.length ; j++ ) {
    +801                             this.elements[j].x+= j*forEachElement;
    +802                         }
    +803 
    +804                         remaining= width - this.width - forEachElement*(this.elements.length-1);
    +805                         for( j=0; j<remaining; j++ ) {
    +806                             this.elements[this.elements.length-1-j].x+= remaining-j;
    +807                         }
    +808                     }
    +809                 }
    +810             },
    +811 
    +812             adjustHeight : function() {
    +813                 var biggestFont=null;
    +814                 var biggestImage=null;
    +815                 var i;
    +816 
    +817                 for( i=0; i<this.elements.length; i+=1 ) {
    +818                     var elem= this.elements[i];
    +819 
    +820                     var fm= elem.getFontMetrics();
    +821                     if ( null!=fm ) {           // gest a fontMetrics, is a DocumentElementText (text)
    +822                         if ( !biggestFont ) {
    +823                             biggestFont= fm;
    +824                         } else {
    +825                             if ( fm.ascent > biggestFont.ascent ) {
    +826                                 biggestFont= fm;
    +827                             }
    +828                         }
    +829                     } else {                    // no FontMetrics, it is an image.
    +830                         if (!biggestImage) {
    +831                             biggestImage= elem;
    +832                         } else {
    +833                             if ( elem.getHeight() > elem.getHeight() ) {
    +834                                 biggestImage= elem;
    +835                             }
    +836                         }
    +837                     }
    +838                 }
    +839 
    +840                 this.baselinePos= Math.max(
    +841                     biggestFont ? biggestFont.ascent : this.defaultFontMetrics.ascent,
    +842                     biggestImage ? biggestImage.getHeight() : this.defaultFontMetrics.ascent );
    +843                 this.height= this.baselinePos + (biggestFont!=null ? biggestFont.descent : this.defaultFontMetrics.descent );
    +844 
    +845                 for( i=0; i<this.elements.length; i++ ) {
    +846                     this.elements[i].setYPosition( this.baselinePos );
    +847                 }
    +848 
    +849                 return this.height;
    +850             },
    +851 
    +852             /**
    +853              * Every element is positioned at line's baseline.
    +854              * @param x
    +855              * @param y
    +856              * @private
    +857              */
    +858             __getElementAt : function( x, y ) {
    +859                 for( var i=0; i<this.elements.length; i++ ) {
    +860                     var elem= this.elements[i];
    +861                     if ( elem.contains(x,y) ) {
    +862                         return elem;
    +863                     }
    +864                 }
    +865 
    +866                 return null;
    +867             }
    +868         };
    +869 
    +870         return {
    +871 
    +872             /**
    +873              * @lends CAAT.Foundation.UI.Label.prototype
    +874              */
    +875 
    +876 
    +877             __init : function() {
    +878                 this.__super();
    +879 
    +880                 this.rc= new renderContext();
    +881                 this.lines= [];
    +882                 this.styles= {};
    +883                 this.images= {};
    +884 
    +885                 return this;
    +886             },
    +887 
    +888             /**
    +889              * This Label document´s horizontal alignment.
    +890              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
    +891              * @private
    +892              */
    +893             halignment  :   CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.LEFT,
    +894 
    +895             /**
    +896              * This Label document´s vertical alignment.
    +897              * @type {CAAT.Foundation.UI.Layout.LayoutManager}
    +898              * @private
    +899              */
    +900             valignment  :   CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.TOP,
    +901 
    +902             /**
    +903              * This label text.
    +904              * @type {string}
    +905              * @private
    +906              */
    +907             text        :   null,
    +908 
    +909             /**
    +910              * This label document´s render context
    +911              * @type {RenderContext}
    +912              * @private
    +913              */
    +914             rc          :   null,
    +915 
    +916             /**
    +917              * Styles object.
    +918              * @private
    +919              */
    +920             styles      :   null,
    +921 
    +922             /**
    +923              * Calculated document width.
    +924              * @private
    +925              */
    +926             documentWidth   : 0,
    +927 
    +928             /**
    +929              * Calculated document Height.
    +930              * @private
    +931              */
    +932             documentHeight  : 0,
    +933 
    +934             /**
    +935              * Document x position.
    +936              * @private
    +937              */
    +938             documentX       : 0,
    +939 
    +940             /**
    +941              * Document y position.
    +942              * @private
    +943              */
    +944             documentY       : 0,
    +945 
    +946             /**
    +947              * Does this label document flow ?
    +948              * @private
    +949              */
    +950             reflow      :   true,
    +951 
    +952             /**
    +953              * Collection of text lines calculated for the label.
    +954              * @private
    +955              */
    +956             lines       :   null,   // calculated elements lines...
    +957 
    +958             /**
    +959              * Collection of image objects in this label´s document.
    +960              * @private
    +961              */
    +962             images      :   null,
    +963 
    +964             /**
    +965              * Registered callback to notify on anchor click event.
    +966              * @private
    +967              */
    +968             clickCallback   : null,
    +969 
    +970             matchTextSize : true,
    +971 
    +972             /**
    +973              * Make the label actor the size the label document has been calculated for.
    +974              * @param match {boolean}
    +975              */
    +976             setMatchTextSize : function( match ) {
    +977                 this.matchTextSize= match;
    +978                 if ( match ) {
    +979                     this.width= this.preferredSize.width;
    +980                     this.height= this.preferredSize.height;
    +981                 }
    +982             },
    +983 
    +984             setStyle : function( name, styleData ) {
    +985                 this.styles[ name ]= styleData;
    +986                 return this;
    +987             },
    +988 
    +989             addImage : function( name, spriteImage ) {
    +990                 this.images[ name ]= spriteImage;
    +991                 return this;
    +992             },
    +993 
    +994             setSize : function(w,h) {
    +995                 CAAT.Foundation.UI.Label.superclass.setSize.call( this, w, h );
    +996                 this.setText( this.text, this.width );
    +997                 return this;
    +998             },
    +999 
    +1000             setBounds : function( x,y,w,h ) {
    +1001                 CAAT.Foundation.UI.Label.superclass.setBounds.call( this,x,y,w,h );
    +1002                 this.setText( this.text, this.width );
    +1003                 return this;
    +1004             },
    +1005 
    +1006             setText : function( _text, width ) {
    +1007 
    +1008                 if ( null===_text ) {
    +1009                    return;
    +1010                 }
    +1011 
    +1012                 var cached= this.cached;
    +1013                 if ( cached ) {
    +1014                     this.stopCacheAsBitmap();
    +1015                 }
    +1016 
    +1017                 this.documentWidth= 0;
    +1018                 this.documentHeight= 0;
    +1019 
    +1020                 this.text= _text;
    +1021 
    +1022                 var i, l, text;
    +1023                 var tag_closes_at_pos, tag;
    +1024                 var _char;
    +1025                 var ctx= CAAT.currentDirector.ctx;
    +1026                 ctx.save();
    +1027 
    +1028                 text= this.text;
    +1029 
    +1030                 i=0;
    +1031                 l=text.length;
    +1032 
    +1033                 this.rc.start( ctx, this.styles, this.images, width );
    +1034 
    +1035                 while( i<l ) {
    +1036                     _char= text.charAt(i);
    +1037 
    +1038                     if ( _char==='\\' ) {
    +1039                         i+=1;
    +1040                         this.rc.fchar( text.charAt(i) );
    +1041                         i+=1;
    +1042 
    +1043                     } else if ( _char==='<' ) {   // try an enhancement.
    +1044 
    +1045                         // try finding another '>' and see whether it matches a tag
    +1046                         tag_closes_at_pos= text.indexOf('>', i+1);
    +1047                         if ( -1!==tag_closes_at_pos ) {
    +1048                             tag= text.substr( i+1, tag_closes_at_pos-i-1 );
    +1049                             if ( tag.indexOf("<")!==-1 ) {
    +1050                                 this.rc.fchar( _char );
    +1051                                 i+=1;
    +1052                             } else {
    +1053                                 this.rc.setTag( tag );
    +1054                                 i= tag_closes_at_pos+1;
    +1055                             }
    +1056                         }
    +1057                     } else {
    +1058                         this.rc.fchar( _char );
    +1059                         i+= 1;
    +1060                     }
    +1061                 }
    +1062 
    +1063                 this.rc.end();
    +1064                 this.lines= this.rc.lines;
    +1065 
    +1066                 this.__calculateDocumentDimension( typeof width==="undefined" ? 0 : width );
    +1067                 this.setLinesAlignment();
    +1068 
    +1069                 ctx.restore();
    +1070 
    +1071                 this.setPreferredSize( this.documentWidth, this.documentHeight );
    +1072                 this.invalidateLayout();
    +1073 
    +1074                 this.setDocumentPosition();
    +1075 
    +1076                 if ( cached ) {
    +1077                     this.cacheAsBitmap(0,cached);
    +1078                 }
    +1079 
    +1080                 if ( this.matchTextSize ) {
    +1081                     this.width= this.preferredSize.width;
    +1082                     this.height= this.preferredSize.height;
    +1083                 }
    +1084 
    +1085                 return this;
    +1086             },
    +1087 
    +1088             setVerticalAlignment : function( align ) {
    +1089                 this.valignment= align;
    +1090                 this.setDocumentPosition();
    +1091                 return this;
    +1092             },
    +1093 
    +1094             setHorizontalAlignment : function( align ) {
    +1095                 this.halignment= align;
    +1096                 this.setDocumentPosition();
    +1097                 return this;
    +1098             },
    +1099 
    +1100             setDocumentPosition : function( halign, valign ) {
    +1101 
    +1102                 if ( typeof halign!=="undefined" ) {
    +1103                     this.setHorizontalAlignment(halign);
    +1104                 }
    +1105                 if ( typeof valign!=="undefined" ) {
    +1106                     this.setVerticalAlignment(valign);
    +1107                 }
    +1108 
    +1109                 var xo=0, yo=0;
    +1110 
    +1111                 if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) {
    +1112                     yo= (this.height - this.documentHeight )/2;
    +1113                 } else if ( this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM ) {
    +1114                     yo= this.height - this.documentHeight;
    +1115                 }
    +1116 
    +1117                 if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER ) {
    +1118                     xo= (this.width - this.documentWidth )/2;
    +1119                 } else if ( this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT ) {
    +1120                     xo= this.width - this.documentWidth;
    +1121                 }
    +1122 
    +1123                 this.documentX= xo;
    +1124                 this.documentY= yo;
    +1125             },
    +1126 
    +1127             __calculateDocumentDimension : function( suggestedWidth ) {
    +1128                 var i;
    +1129                 var y= 0;
    +1130 
    +1131                 this.documentWidth= 0;
    +1132                 this.documentHeight= 0;
    +1133                 for( i=0; i<this.lines.length; i++ ) {
    +1134                     this.lines[i].y =y;
    +1135                     this.documentWidth= Math.max( this.documentWidth, this.lines[i].width );
    +1136                     this.documentHeight+= this.lines[i].adjustHeight();
    +1137                     y+= this.lines[i].getHeight();
    +1138                 }
    +1139 
    +1140                 this.documentWidth= Math.max( this.documentWidth, suggestedWidth );
    +1141 
    +1142                 return this;
    +1143             },
    +1144 
    +1145             setLinesAlignment : function() {
    +1146 
    +1147                 for( var i=0; i<this.lines.length; i++ ) {
    +1148                     this.lines[i].setAlignment( this.documentWidth )
    +1149                 }
    +1150             },
    +1151 
    +1152             paint : function( director, time ) {
    +1153 
    +1154                 if ( this.cached===CAAT.Foundation.Actor.CACHE_NONE ) {
    +1155                     var ctx= director.ctx;
    +1156 
    +1157                     ctx.save();
    +1158 
    +1159                     ctx.textBaseline="alphabetic";
    +1160                     ctx.translate( this.documentX, this.documentY );
    +1161 
    +1162                     for( var i=0; i<this.lines.length; i++ ) {
    +1163                         var line= this.lines[i];
    +1164                         line.paint( director.ctx );
    +1165 
    +1166                         if ( DEBUG ) {
    +1167                             ctx.strokeRect( line.x, line.y, line.width, line.height );
    +1168                         }
    +1169                     }
    +1170 
    +1171                     ctx.restore();
    +1172                 } else {
    +1173                     if ( this.backgroundImage ) {
    +1174                         this.backgroundImage.paint(director,time,0,0);
    +1175                     }
    +1176                 }
    +1177             },
    +1178 
    +1179             __getDocumentElementAt : function( x, y ) {
    +1180 
    +1181                 x-= this.documentX;
    +1182                 y-= this.documentY;
    +1183 
    +1184                 for( var i=0; i<this.lines.length; i++ ) {
    +1185                     var line= this.lines[i];
    +1186 
    +1187                     if ( line.x<=x && line.y<=y && line.x+line.width>=x && line.y+line.height>=y ) {
    +1188                         return line.__getElementAt( x - line.x, y - line.y );
    +1189                     }
    +1190                 }
    +1191 
    +1192                 return null;
    +1193             },
    +1194 
    +1195             mouseExit : function(e) {
    +1196                 CAAT.setCursor( "default");
    +1197             },
    +1198 
    +1199             mouseMove : function(e) {
    +1200                 var elem= this.__getDocumentElementAt(e.x, e.y);
    +1201                 if ( elem && elem.getLink() ) {
    +1202                     CAAT.setCursor( "pointer");
    +1203                 } else {
    +1204                     CAAT.setCursor( "default");
    +1205                 }
    +1206             },
    +1207 
    +1208             mouseClick : function(e) {
    +1209                 if ( this.clickCallback ) {
    +1210                     var elem= this.__getDocumentElementAt(e.x, e.y);
    +1211                     if ( elem.getLink() ) {
    +1212                         this.clickCallback( elem.getLink() );
    +1213                     }
    +1214                 }
    +1215             },
    +1216 
    +1217             setClickCallback : function( callback ) {
    +1218                 this.clickCallback= callback;
    +1219                 return this;
    +1220             }
    +1221         }
    +1222 
    +1223     }
    +1224 
    +1225 });
    +1226 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_BorderLayout.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_BorderLayout.js.html new file mode 100644 index 00000000..612c419e --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_BoxLayout.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_BoxLayout.js.html new file mode 100644 index 00000000..4f49cbfa --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_GridLayout.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_GridLayout.js.html new file mode 100644 index 00000000..fafe6f2d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_LayoutManager.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_Layout_LayoutManager.js.html new file mode 100644 index 00000000..8ccaf7d0 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_PathActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_PathActor.js.html new file mode 100644 index 00000000..c1f9dfdb --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_ShapeActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_ShapeActor.js.html new file mode 100644 index 00000000..4147595d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_StarActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_StarActor.js.html new file mode 100644 index 00000000..4aaa4201 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Foundation_UI_TextActor.js.html b/documentation/jsdoc/symbols/src/src_Foundation_UI_TextActor.js.html new file mode 100644 index 00000000..54f2545d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Bezier.js.html b/documentation/jsdoc/symbols/src/src_Math_Bezier.js.html new file mode 100644 index 00000000..c7618315 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_CatmullRom.js.html b/documentation/jsdoc/symbols/src/src_Math_CatmullRom.js.html new file mode 100644 index 00000000..ff8bb301 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Curve.js.html b/documentation/jsdoc/symbols/src/src_Math_Curve.js.html new file mode 100644 index 00000000..ace184de --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Dimension.js.html b/documentation/jsdoc/symbols/src/src_Math_Dimension.js.html new file mode 100644 index 00000000..4e4c7d65 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Matrix.js.html b/documentation/jsdoc/symbols/src/src_Math_Matrix.js.html new file mode 100644 index 00000000..6aa70175 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Math_Matrix.js.html @@ -0,0 +1,432 @@ +
      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, 
    +105                     0.0, 0.0, 1.0 ];
    +106 
    +107                 if (typeof Float32Array !== "undefined") {
    +108                     this.matrix = new Float32Array(this.matrix);
    +109                 }
    +110 
    +111                 return this;
    +112             },
    +113 
    +114             /**
    +115              * Transform a point by this matrix. The parameter point will be modified with the transformation values.
    +116              * @param point {CAAT.Point}.
    +117              * @return {CAAT.Point} the parameter point.
    +118              */
    +119             transformCoord:function (point) {
    +120                 var x = point.x;
    +121                 var y = point.y;
    +122 
    +123                 var tm = this.matrix;
    +124 
    +125                 point.x = x * tm[0] + y * tm[1] + tm[2];
    +126                 point.y = x * tm[3] + y * tm[4] + tm[5];
    +127 
    +128                 return point;
    +129             },
    +130 
    +131             setRotation:function (angle) {
    +132 
    +133                 this.identity();
    +134 
    +135                 var tm = this.matrix;
    +136                 var c = Math.cos(angle);
    +137                 var s = Math.sin(angle);
    +138                 tm[0] = c;
    +139                 tm[1] = -s;
    +140                 tm[3] = s;
    +141                 tm[4] = c;
    +142 
    +143                 return this;
    +144             },
    +145 
    +146             setScale:function (scalex, scaley) {
    +147                 this.identity();
    +148 
    +149                 this.matrix[0] = scalex;
    +150                 this.matrix[4] = scaley;
    +151 
    +152                 return this;
    +153             },
    +154 
    +155             /**
    +156              * Sets this matrix as a translation matrix.
    +157              * @param x
    +158              * @param y
    +159              */
    +160             setTranslate:function (x, y) {
    +161                 this.identity();
    +162 
    +163                 this.matrix[2] = x;
    +164                 this.matrix[5] = y;
    +165 
    +166                 return this;
    +167             },
    +168             /**
    +169              * Copy into this matrix the given matrix values.
    +170              * @param matrix {CAAT.Matrix}
    +171              * @return this
    +172              */
    +173             copy:function (matrix) {
    +174                 matrix = matrix.matrix;
    +175 
    +176                 var tmatrix = this.matrix;
    +177                 tmatrix[0] = matrix[0];
    +178                 tmatrix[1] = matrix[1];
    +179                 tmatrix[2] = matrix[2];
    +180                 tmatrix[3] = matrix[3];
    +181                 tmatrix[4] = matrix[4];
    +182                 tmatrix[5] = matrix[5];
    +183                 tmatrix[6] = matrix[6];
    +184                 tmatrix[7] = matrix[7];
    +185                 tmatrix[8] = matrix[8];
    +186 
    +187                 return this;
    +188             },
    +189             /**
    +190              * Set this matrix to the identity matrix.
    +191              * @return this
    +192              */
    +193             identity:function () {
    +194 
    +195                 var m = this.matrix;
    +196                 m[0] = 1.0;
    +197                 m[1] = 0.0;
    +198                 m[2] = 0.0;
    +199 
    +200                 m[3] = 0.0;
    +201                 m[4] = 1.0;
    +202                 m[5] = 0.0;
    +203 
    +204                 m[6] = 0.0;
    +205                 m[7] = 0.0;
    +206                 m[8] = 1.0;
    +207 
    +208                 return this;
    +209             },
    +210             /**
    +211              * Multiply this matrix by a given matrix.
    +212              * @param m {CAAT.Matrix}
    +213              * @return this
    +214              */
    +215             multiply:function (m) {
    +216 
    +217                 var tm = this.matrix;
    +218                 var mm = m.matrix;
    +219 
    +220                 var tm0 = tm[0];
    +221                 var tm1 = tm[1];
    +222                 var tm2 = tm[2];
    +223                 var tm3 = tm[3];
    +224                 var tm4 = tm[4];
    +225                 var tm5 = tm[5];
    +226                 var tm6 = tm[6];
    +227                 var tm7 = tm[7];
    +228                 var tm8 = tm[8];
    +229 
    +230                 var mm0 = mm[0];
    +231                 var mm1 = mm[1];
    +232                 var mm2 = mm[2];
    +233                 var mm3 = mm[3];
    +234                 var mm4 = mm[4];
    +235                 var mm5 = mm[5];
    +236                 var mm6 = mm[6];
    +237                 var mm7 = mm[7];
    +238                 var mm8 = mm[8];
    +239 
    +240                 tm[0] = tm0 * mm0 + tm1 * mm3 + tm2 * mm6;
    +241                 tm[1] = tm0 * mm1 + tm1 * mm4 + tm2 * mm7;
    +242                 tm[2] = tm0 * mm2 + tm1 * mm5 + tm2 * mm8;
    +243                 tm[3] = tm3 * mm0 + tm4 * mm3 + tm5 * mm6;
    +244                 tm[4] = tm3 * mm1 + tm4 * mm4 + tm5 * mm7;
    +245                 tm[5] = tm3 * mm2 + tm4 * mm5 + tm5 * mm8;
    +246                 tm[6] = tm6 * mm0 + tm7 * mm3 + tm8 * mm6;
    +247                 tm[7] = tm6 * mm1 + tm7 * mm4 + tm8 * mm7;
    +248                 tm[8] = tm6 * mm2 + tm7 * mm5 + tm8 * mm8;
    +249 
    +250                 return this;
    +251             },
    +252             /**
    +253              * Premultiply this matrix by a given matrix.
    +254              * @param m {CAAT.Matrix}
    +255              * @return this
    +256              */
    +257             premultiply:function (m) {
    +258 
    +259                 var m00 = m.matrix[0] * this.matrix[0] + m.matrix[1] * this.matrix[3] + m.matrix[2] * this.matrix[6];
    +260                 var m01 = m.matrix[0] * this.matrix[1] + m.matrix[1] * this.matrix[4] + m.matrix[2] * this.matrix[7];
    +261                 var m02 = m.matrix[0] * this.matrix[2] + m.matrix[1] * this.matrix[5] + m.matrix[2] * this.matrix[8];
    +262 
    +263                 var m10 = m.matrix[3] * this.matrix[0] + m.matrix[4] * this.matrix[3] + m.matrix[5] * this.matrix[6];
    +264                 var m11 = m.matrix[3] * this.matrix[1] + m.matrix[4] * this.matrix[4] + m.matrix[5] * this.matrix[7];
    +265                 var m12 = m.matrix[3] * this.matrix[2] + m.matrix[4] * this.matrix[5] + m.matrix[5] * this.matrix[8];
    +266 
    +267                 var m20 = m.matrix[6] * this.matrix[0] + m.matrix[7] * this.matrix[3] + m.matrix[8] * this.matrix[6];
    +268                 var m21 = m.matrix[6] * this.matrix[1] + m.matrix[7] * this.matrix[4] + m.matrix[8] * this.matrix[7];
    +269                 var m22 = m.matrix[6] * this.matrix[2] + m.matrix[7] * this.matrix[5] + m.matrix[8] * this.matrix[8];
    +270 
    +271                 this.matrix[0] = m00;
    +272                 this.matrix[1] = m01;
    +273                 this.matrix[2] = m02;
    +274 
    +275                 this.matrix[3] = m10;
    +276                 this.matrix[4] = m11;
    +277                 this.matrix[5] = m12;
    +278 
    +279                 this.matrix[6] = m20;
    +280                 this.matrix[7] = m21;
    +281                 this.matrix[8] = m22;
    +282 
    +283 
    +284                 return this;
    +285             },
    +286             /**
    +287              * Creates a new inverse matrix from this matrix.
    +288              * @return {CAAT.Matrix} an inverse matrix.
    +289              */
    +290             getInverse:function (out) {
    +291                 var tm = this.matrix;
    +292 
    +293                 var m00 = tm[0];
    +294                 var m01 = tm[1];
    +295                 var m02 = tm[2];
    +296                 var m10 = tm[3];
    +297                 var m11 = tm[4];
    +298                 var m12 = tm[5];
    +299                 var m20 = tm[6];
    +300                 var m21 = tm[7];
    +301                 var m22 = tm[8];
    +302 
    +303                 var newMatrix = out || new CAAT.Math.Matrix();
    +304 
    +305                 var determinant = m00 * (m11 * m22 - m21 * m12) - m10 * (m01 * m22 - m21 * m02) + m20 * (m01 * m12 - m11 * m02);
    +306                 if (determinant === 0) {
    +307                     return null;
    +308                 }
    +309 
    +310                 var m = newMatrix.matrix;
    +311 
    +312                 m[0] = m11 * m22 - m12 * m21;
    +313                 m[1] = m02 * m21 - m01 * m22;
    +314                 m[2] = m01 * m12 - m02 * m11;
    +315 
    +316                 m[3] = m12 * m20 - m10 * m22;
    +317                 m[4] = m00 * m22 - m02 * m20;
    +318                 m[5] = m02 * m10 - m00 * m12;
    +319 
    +320                 m[6] = m10 * m21 - m11 * m20;
    +321                 m[7] = m01 * m20 - m00 * m21;
    +322                 m[8] = m00 * m11 - m01 * m10;
    +323 
    +324                 newMatrix.multiplyScalar(1 / determinant);
    +325 
    +326                 return newMatrix;
    +327             },
    +328             /**
    +329              * Multiply this matrix by a scalar.
    +330              * @param scalar {number} scalar value
    +331              *
    +332              * @return this
    +333              */
    +334             multiplyScalar:function (scalar) {
    +335                 var i;
    +336 
    +337                 for (i = 0; i < 9; i++) {
    +338                     this.matrix[i] *= scalar;
    +339                 }
    +340 
    +341                 return this;
    +342             },
    +343 
    +344             /**
    +345              *
    +346              * @param ctx
    +347              */
    +348             transformRenderingContextSet_NoClamp:function (ctx) {
    +349                 var m = this.matrix;
    +350                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2], m[5]);
    +351                 return this;
    +352             },
    +353 
    +354             /**
    +355              *
    +356              * @param ctx
    +357              */
    +358             transformRenderingContext_NoClamp:function (ctx) {
    +359                 var m = this.matrix;
    +360                 ctx.transform(m[0], m[3], m[1], m[4], m[2], m[5]);
    +361                 return this;
    +362             },
    +363 
    +364             /**
    +365              *
    +366              * @param ctx
    +367              */
    +368             transformRenderingContextSet_Clamp:function (ctx) {
    +369                 var m = this.matrix;
    +370                 ctx.setTransform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0);
    +371                 return this;
    +372             },
    +373 
    +374             /**
    +375              *
    +376              * @param ctx
    +377              */
    +378             transformRenderingContext_Clamp:function (ctx) {
    +379                 var m = this.matrix;
    +380                 ctx.transform(m[0], m[3], m[1], m[4], m[2] >> 0, m[5] >> 0);
    +381                 return this;
    +382             },
    +383 
    +384             setModelViewMatrix:function ( x, y, sx, sy, r  ) {
    +385                 var c, s, _m00, _m01, _m10, _m11;
    +386                 var mm0, mm1, mm2, mm3, mm4, mm5;
    +387                 var mm;
    +388 
    +389                 mm = this.matrix;
    +390 
    +391                 mm0 = 1;
    +392                 mm1 = 0;
    +393                 mm3 = 0;
    +394                 mm4 = 1;
    +395 
    +396                 mm2 = x;
    +397                 mm5 = y;
    +398 
    +399                 c = Math.cos(r);
    +400                 s = Math.sin(r);
    +401                 _m00 = mm0;
    +402                 _m01 = mm1;
    +403                 _m10 = mm3;
    +404                 _m11 = mm4;
    +405                 mm0 = _m00 * c + _m01 * s;
    +406                 mm1 = -_m00 * s + _m01 * c;
    +407                 mm3 = _m10 * c + _m11 * s;
    +408                 mm4 = -_m10 * s + _m11 * c;
    +409 
    +410                 mm0 = mm0 * this.scaleX;
    +411                 mm1 = mm1 * this.scaleY;
    +412                 mm3 = mm3 * this.scaleX;
    +413                 mm4 = mm4 * this.scaleY;
    +414 
    +415                 mm[0] = mm0;
    +416                 mm[1] = mm1;
    +417                 mm[2] = mm2;
    +418                 mm[3] = mm3;
    +419                 mm[4] = mm4;
    +420                 mm[5] = mm5;
    +421             }
    +422         }
    +423     }
    +424 });
    +425 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Math_Matrix3.js.html b/documentation/jsdoc/symbols/src/src_Math_Matrix3.js.html new file mode 100644 index 00000000..a066b4ff --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Point.js.html b/documentation/jsdoc/symbols/src/src_Math_Point.js.html new file mode 100644 index 00000000..65077773 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Math_Rectangle.js.html b/documentation/jsdoc/symbols/src/src_Math_Rectangle.js.html new file mode 100644 index 00000000..5056c20a --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Audio_AudioManager.js.html b/documentation/jsdoc/symbols/src/src_Modules_Audio_AudioManager.js.html new file mode 100644 index 00000000..706bd098 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_CSS_csskeyframehelper.js.html b/documentation/jsdoc/symbols/src/src_Modules_CSS_csskeyframehelper.js.html new file mode 100644 index 00000000..b5ae464d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_CircleManager_PackedCircle.js.html b/documentation/jsdoc/symbols/src/src_Modules_CircleManager_PackedCircle.js.html new file mode 100644 index 00000000..3ced438d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_CircleManager_PackedCircleManager.js.html b/documentation/jsdoc/symbols/src/src_Modules_CircleManager_PackedCircleManager.js.html new file mode 100644 index 00000000..c07cf24b --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Collision_Quadtree.js.html b/documentation/jsdoc/symbols/src/src_Modules_Collision_Quadtree.js.html new file mode 100644 index 00000000..caa5c240 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Collision_SpatialHash.js.html b/documentation/jsdoc/symbols/src/src_Modules_Collision_SpatialHash.js.html new file mode 100644 index 00000000..14a0e524 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_ColorUtil_Color.js.html b/documentation/jsdoc/symbols/src/src_Modules_ColorUtil_Color.js.html new file mode 100644 index 00000000..3cb5b8f5 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Debug_Debug.js.html b/documentation/jsdoc/symbols/src/src_Modules_Debug_Debug.js.html new file mode 100644 index 00000000..8ea2dc42 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Font_Font.js.html b/documentation/jsdoc/symbols/src/src_Modules_Font_Font.js.html new file mode 100644 index 00000000..6cda3778 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMBumpMapping.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMBumpMapping.js.html new file mode 100644 index 00000000..feee121f --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMPlasma.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMPlasma.js.html new file mode 100644 index 00000000..b4f6d49d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMRotoZoom.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_IMRotoZoom.js.html new file mode 100644 index 00000000..6484bc5d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_ImageProcessor.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_ImageProcess_ImageProcessor.js.html new file mode 100644 index 00000000..1411bdd1 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Image_Preloader_ImagePreloader.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_Preloader_ImagePreloader.js.html new file mode 100644 index 00000000..ff9f3568 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_Modules_Image_Preloader_ImagePreloader.js.html @@ -0,0 +1,109 @@ +
      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:{string}, url:{string}}, ...]} an array of object with two fields id and url.
    + 59          * @param callback_loaded_one_image {function( counter {number}, images {{ id:{string}, image: {Image}}} )}
    + 60          * @param callback_error {function (error, index)}
    + 61          * function to call on every image load.
    + 62          */
    + 63         loadImages: function( aImages, callback_loaded_one_image, callback_error ) {
    + 64 
    + 65             if (!aImages) {
    + 66                 if (callback_loaded_one_image ) {
    + 67                     callback_loaded_one_image(0,[]);
    + 68                 }
    + 69             }
    + 70 
    + 71             var me= this, i;
    + 72             this.notificationCallback = callback_loaded_one_image;
    + 73             this.images= [];
    + 74             for( i=0; i<aImages.length; i++ ) {
    + 75                 this.images.push( {id:aImages[i].id, image: new Image() } );
    + 76             }
    + 77 
    + 78             for( i=0; i<aImages.length; i++ ) {
    + 79                 this.images[i].image.onload = function imageLoaded() {
    + 80                     me.imageCounter++;
    + 81                     me.notificationCallback(me.imageCounter, me.images);
    + 82                 };
    + 83 
    + 84                 this.images[i].image.onerror= (function(index) {
    + 85                         return function(e) {
    + 86                             if ( callback_error ) {
    + 87                                 callback_error( e, index );
    + 88                             }
    + 89                         };
    + 90                     })(i);
    + 91 
    + 92                 this.images[i].image.src= aImages[i].url;
    + 93             }
    + 94 
    + 95             if ( aImages.length===0 ) {
    + 96                 callback_loaded_one_image(0,[]);
    + 97             }
    + 98         }
    + 99 
    +100     }
    +101 });
    +102 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_Modules_Image_Preloader_Preloader.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_Preloader_Preloader.js.html new file mode 100644 index 00000000..c13954af --- /dev/null +++ b/documentation/jsdoc/symbols/src/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.cerrored= 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/documentation/jsdoc/symbols/src/src_Modules_Image_Util_ImageUtil.js.html b/documentation/jsdoc/symbols/src/src_Modules_Image_Util_ImageUtil.js.html new file mode 100644 index 00000000..e14ccccf --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Initialization_Template.js.html b/documentation/jsdoc/symbols/src/src_Modules_Initialization_Template.js.html new file mode 100644 index 00000000..cc76c5bd --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Initialization_TemplateWithSplash.js.html b/documentation/jsdoc/symbols/src/src_Modules_Initialization_TemplateWithSplash.js.html new file mode 100644 index 00000000..1633a96e --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_LayoutUtils_RowLayout.js.html b/documentation/jsdoc/symbols/src/src_Modules_LayoutUtils_RowLayout.js.html new file mode 100644 index 00000000..0c7e92b9 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Locale_ResourceBundle.js.html b/documentation/jsdoc/symbols/src/src_Modules_Locale_ResourceBundle.js.html new file mode 100644 index 00000000..4bf1d5de --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Runtime_BrowserInfo.js.html b/documentation/jsdoc/symbols/src/src_Modules_Runtime_BrowserInfo.js.html new file mode 100644 index 00000000..4f90f6a3 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Skeleton_Bone.js.html b/documentation/jsdoc/symbols/src/src_Modules_Skeleton_Bone.js.html new file mode 100644 index 00000000..6894ed9e --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Skeleton_BoneActor.js.html b/documentation/jsdoc/symbols/src/src_Modules_Skeleton_BoneActor.js.html new file mode 100644 index 00000000..c67f389d --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Skeleton_Skeleton.js.html b/documentation/jsdoc/symbols/src/src_Modules_Skeleton_Skeleton.js.html new file mode 100644 index 00000000..099388a2 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Skeleton_SkeletonActor.js.html b/documentation/jsdoc/symbols/src/src_Modules_Skeleton_SkeletonActor.js.html new file mode 100644 index 00000000..947f7677 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_Storage_LocalStorage.js.html b/documentation/jsdoc/symbols/src/src_Modules_Storage_LocalStorage.js.html new file mode 100644 index 00000000..26c2f31f --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureElement.js.html b/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureElement.js.html new file mode 100644 index 00000000..3b34d0b2 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TexturePage.js.html b/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TexturePage.js.html new file mode 100644 index 00000000..6b9f482b --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TexturePageManager.js.html b/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TexturePageManager.js.html new file mode 100644 index 00000000..8c77c931 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureScan.js.html b/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureScan.js.html new file mode 100644 index 00000000..63271906 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureScanMap.js.html b/documentation/jsdoc/symbols/src/src_Modules_TexturePacker_TextureScanMap.js.html new file mode 100644 index 00000000..fb1936e1 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_ArcPath.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_ArcPath.js.html new file mode 100644 index 00000000..09594dbd --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_CurvePath.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_CurvePath.js.html new file mode 100644 index 00000000..8a20e013 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_LinearPath.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_LinearPath.js.html new file mode 100644 index 00000000..9ec5ce2a --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_Path.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_Path.js.html new file mode 100644 index 00000000..9e4af811 --- /dev/null +++ b/documentation/jsdoc/symbols/src/src_PathUtil_Path.js.html @@ -0,0 +1,1175 @@ +
      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             points = points.slice(0);
    +335             if ( closed ) {
    +336                 points.unshift(points[points.length-1]);
    +337                 points.push(points[1]);
    +338                 points.push(points[2]);
    +339             } else {
    +340                 points.unshift(points[0]);
    +341                 points.push(points[points.length-1]);
    +342             }
    +343 
    +344             for( var i=1; i<points.length-2; i++ ) {
    +345 
    +346                 var segment= new CAAT.PathUtil.CurvePath().setColor("#000").setParent(this);
    +347                 var cm= new CAAT.Math.CatmullRom().setCurve(
    +348                     points[ i-1 ],
    +349                     points[ i ],
    +350                     points[ i+1 ],
    +351                     points[ i+2 ]
    +352                 );
    +353                 segment.curve= cm;
    +354                 this.pathSegments.push(segment);
    +355             }
    +356             return this;
    +357         },
    +358         /**
    +359          * Add a CAAT.PathSegment instance to this path.
    +360          * @param pathSegment {CAAT.PathSegment}
    +361          * @return this
    +362          *
    +363          */
    +364 		addSegment : function(pathSegment) {
    +365             pathSegment.setParent(this);
    +366 			this.pathSegments.push(pathSegment);
    +367             return this;
    +368 		},
    +369         addArcTo : function( x1,y1, x2,y2, radius, cw, color ) {
    +370             var r= new CAAT.PathUtil.ArcPath();
    +371             r.setArcTo(true);
    +372             r.setRadius( radius );
    +373             r.setInitialPosition( x1,y1).
    +374                 setFinalPosition( x2,y2 );
    +375 
    +376 
    +377             r.setParent( this );
    +378             r.setColor( color );
    +379 
    +380             this.pathSegments.push(r);
    +381 
    +382             return this;
    +383         },
    +384         addRectangleTo : function( x1,y1, cw, color ) {
    +385             var r= new CAAT.PathUtil.RectPath();
    +386             r.setPoints([
    +387                     this.endCurvePosition(),
    +388                     new CAAT.Math.Point().set(x1,y1)
    +389                 ]);
    +390 
    +391             r.setClockWise(cw);
    +392             r.setColor(color);
    +393             r.setParent(this);
    +394 
    +395             this.pathSegments.push(r);
    +396 
    +397             return this;
    +398         },
    +399         /**
    +400          * Add a Quadric Bezier path segment to this path.
    +401          * The segment starts in the current last path coordinate.
    +402          * @param px1 {number}
    +403          * @param py1 {number}
    +404          * @param px2 {number}
    +405          * @param py2 {number}
    +406          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
    +407          *         being drawn by a CAAT.PathActor).
    +408          *
    +409          * @return this
    +410          */
    +411 		addQuadricTo : function( px1,py1, px2,py2, color ) {
    +412 			var bezier= new CAAT.Math.Bezier();
    +413 
    +414             bezier.setPoints(
    +415                 [
    +416                     this.endCurvePosition(),
    +417                     new CAAT.Math.Point().set(px1,py1),
    +418                     new CAAT.Math.Point().set(px2,py2)
    +419                 ]);
    +420 
    +421 			this.trackPathX= px2;
    +422 			this.trackPathY= py2;
    +423 			
    +424 			var segment= new CAAT.PathUtil.CurvePath().setColor(color).setParent(this);
    +425 			segment.curve= bezier;
    +426 
    +427 			this.pathSegments.push(segment);
    +428 
    +429             return this;
    +430 		},
    +431         /**
    +432          * Add a Cubic Bezier segment to this path.
    +433          * The segment starts in the current last path coordinate.
    +434          * @param px1 {number}
    +435          * @param py1 {number}
    +436          * @param px2 {number}
    +437          * @param py2 {number}
    +438          * @param px3 {number}
    +439          * @param py3 {number}
    +440          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
    +441          *         being drawn by a CAAT.PathActor).
    +442          *
    +443          * @return this
    +444          */
    +445 		addCubicTo : function( px1,py1, px2,py2, px3,py3, color ) {
    +446 			var bezier= new CAAT.Math.Bezier();
    +447 
    +448             bezier.setPoints(
    +449                 [
    +450                     this.endCurvePosition(),
    +451                     new CAAT.Math.Point().set(px1,py1),
    +452                     new CAAT.Math.Point().set(px2,py2),
    +453                     new CAAT.Math.Point().set(px3,py3)
    +454                 ]);
    +455 
    +456 			this.trackPathX= px3;
    +457 			this.trackPathY= py3;
    +458 			
    +459 			var segment= new CAAT.PathUtil.CurvePath().setColor(color).setParent(this);
    +460 			segment.curve= bezier;
    +461 
    +462 			this.pathSegments.push(segment);
    +463             return this;
    +464 		},
    +465         /**
    +466          * Add a Catmull-Rom segment to this path.
    +467          * The segment starts in the current last path coordinate.
    +468          * @param px1 {number}
    +469          * @param py1 {number}
    +470          * @param px2 {number}
    +471          * @param py2 {number}
    +472          * @param px3 {number}
    +473          * @param py3 {number}
    +474          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
    +475          *         being drawn by a CAAT.PathActor).
    +476          *
    +477          * @return this
    +478          */
    +479 		addCatmullTo : function( px1,py1, px2,py2, px3,py3, color ) {
    +480 			var curve= new CAAT.Math.CatmullRom().setColor(color);
    +481 			curve.setCurve(this.trackPathX,this.trackPathY, px1,py1, px2,py2, px3,py3);
    +482 			this.trackPathX= px3;
    +483 			this.trackPathY= py3;
    +484 			
    +485 			var segment= new CAAT.PathUtil.CurvePath().setParent(this);
    +486 			segment.curve= curve;
    +487 
    +488 			this.pathSegments.push(segment);
    +489             return this;
    +490 		},
    +491         /**
    +492          * Adds a line segment to this path.
    +493          * The segment starts in the current last path coordinate.
    +494          * @param px1 {number}
    +495          * @param py1 {number}
    +496          * @param color {color=}. optional parameter. determines the color to draw the segment with (if
    +497          *         being drawn by a CAAT.PathActor).
    +498          *
    +499          * @return this
    +500          */
    +501 		addLineTo : function( px1,py1, color ) {
    +502 			var segment= new CAAT.PathUtil.LinearPath().setColor(color);
    +503             segment.setPoints( [
    +504                     this.endCurvePosition(),
    +505                     new CAAT.Math.Point().set(px1,py1)
    +506                 ]);
    +507 
    +508             segment.setParent(this);
    +509 
    +510 			this.trackPathX= px1;
    +511 			this.trackPathY= py1;
    +512 			
    +513 			this.pathSegments.push(segment);
    +514             return this;
    +515 		},
    +516         /**
    +517          * Set the path's starting point. The method startCurvePosition will return this coordinate.
    +518          * <p>
    +519          * If a call to any method of the form <code>add<Segment>To</code> is called before this calling
    +520          * this method, they will assume to start at -1,-1 and probably you'll get the wrong path.
    +521          * @param px0 {number}
    +522          * @param py0 {number}
    +523          *
    +524          * @return this
    +525          */
    +526 		beginPath : function( px0, py0 ) {
    +527 			this.trackPathX= px0;
    +528 			this.trackPathY= py0;
    +529 			this.beginPathX= px0;
    +530 			this.beginPathY= py0;
    +531             return this;
    +532 		},
    +533         /**
    +534          * <del>Close the path by adding a line path segment from the current last path
    +535          * coordinate to startCurvePosition coordinate</del>.
    +536          * <p>
    +537          * This method closes a path by setting its last path segment's last control point
    +538          * to be the first path segment's first control point.
    +539          * <p>
    +540          *     This method also sets the path as finished, and calculates all path's information
    +541          *     such as length and bounding box.
    +542          *
    +543          * @return this
    +544          */
    +545 		closePath : function()	{
    +546 
    +547             this.getLastPathSegment().setPoint(
    +548                 this.getFirstPathSegment().startCurvePosition(),
    +549                 this.getLastPathSegment().numControlPoints()-1 );
    +550 
    +551 
    +552 			this.trackPathX= this.beginPathX;
    +553 			this.trackPathY= this.beginPathY;
    +554 
    +555             this.closed= true;
    +556 
    +557 			this.endPath();
    +558             return this;
    +559 		},
    +560         /**
    +561          * Finishes the process of building the path. It involves calculating each path segments length
    +562          * and proportional length related to a normalized path length of 1.
    +563          * It also sets current paths length.
    +564          * These calculi are needed to traverse the path appropriately.
    +565          * <p>
    +566          * This method must be called explicitly, except when closing a path (that is, calling the
    +567          * method closePath) which calls this method as well.
    +568          *
    +569          * @return this
    +570          */
    +571 		endPath : function() {
    +572 
    +573 			this.pathSegmentStartTime=[];
    +574 			this.pathSegmentDurationTime= [];
    +575 
    +576             this.updatePath();
    +577 
    +578             return this;
    +579 		},
    +580         /**
    +581          * This method, returns a CAAT.Foundation.Point instance indicating a coordinate in the path.
    +582          * The returned coordinate is the corresponding to normalizing the path's length to 1,
    +583          * and then finding what path segment and what coordinate in that path segment corresponds
    +584          * for the input time parameter.
    +585          * <p>
    +586          * The parameter time must be a value ranging 0..1.
    +587          * If not constrained to these values, the parameter will be modulus 1, and then, if less
    +588          * than 0, be normalized to 1+time, so that the value always ranges from 0 to 1.
    +589          * <p>
    +590          * This method is needed when traversing the path throughout a CAAT.Interpolator instance.
    +591          *
    +592          *
    +593          * @param time {number} a value between 0 and 1 both inclusive. 0 will return path's starting coordinate.
    +594          * 1 will return path's end coordinate.
    +595          * @param open_contour {boolean=} treat this path as an open contour. It is intended for
    +596          * open paths, and interpolators which give values above 1. see tutorial 7.1.
    +597          * @link{../../documentation/tutorials/t7-1.html}
    +598          *
    +599          * @return {CAAT.Foundation.Point}
    +600          */
    +601 		getPosition : function(time, open_contour) {
    +602 
    +603             if (open_contour && (time>=1 || time<=0) ) {
    +604 
    +605                 var p0,p1,ratio, angle;
    +606 
    +607                 if ( time>=1 ) {
    +608                     // these values could be cached.
    +609                     p0= this.__getPositionImpl( .999 );
    +610                     p1= this.endCurvePosition();
    +611 
    +612                     angle= Math.atan2( p1.y - p0.y, p1.x - p0.x );
    +613                     ratio= time%1;
    +614 
    +615 
    +616                 } else {
    +617                     // these values could be cached.
    +618                     p0= this.__getPositionImpl( .001 );
    +619                     p1= this.startCurvePosition();
    +620 
    +621                     angle= Math.atan2( p1.y - p0.y, p1.x - p0.x );
    +622                     ratio= -time;
    +623                 }
    +624 
    +625                 var np= this.newPosition;
    +626                 var length= this.getLength();
    +627 
    +628                 np.x = p1.x + (ratio * length)*Math.cos(angle);
    +629                 np.y = p1.y + (ratio * length)*Math.sin(angle);
    +630 
    +631 
    +632                 return np;
    +633             }
    +634 
    +635             return this.__getPositionImpl(time);
    +636         },
    +637 
    +638         __getPositionImpl : function(time) {
    +639 
    +640             if ( time>1 || time<0 ) {
    +641                 time%=1;
    +642             }
    +643             if ( time<0 ) {
    +644                 time= 1+time;
    +645             }
    +646 
    +647             var ps= this.pathSegments;
    +648             var psst= this.pathSegmentStartTime;
    +649             var psdt= this.pathSegmentDurationTime;
    +650             var l=  0;
    +651             var r=  ps.length;
    +652             var m;
    +653             var np= this.newPosition;
    +654             var psstv;
    +655             while( l!==r ) {
    +656 
    +657                 m= ((r+l)/2)|0;
    +658                 psstv= psst[m];
    +659                 if ( psstv<=time && time<=psstv+psdt[m]) {
    +660                     time= psdt[m] ?
    +661                             (time-psstv)/psdt[m] :
    +662                             0;
    +663 
    +664                     // Clamp this segment's time to a maximum since it is relative to the path.
    +665                     // thanks https://github.com/donaldducky for spotting.
    +666                     if (time>1) {
    +667                         time=1;
    +668                     } else if (time<0 ) {
    +669                         time= 0;
    +670                     }
    +671 
    +672                     var pointInPath= ps[m].getPosition(time);
    +673                     np.x= pointInPath.x;
    +674                     np.y= pointInPath.y;
    +675                     return np;
    +676                 } else if ( time<psstv ) {
    +677                     r= m;
    +678                 } else /*if ( time>=psstv )*/ {
    +679                     l= m+1;
    +680                 }
    +681             }
    +682             return this.endCurvePosition();
    +683 
    +684 
    +685 		},
    +686         /**
    +687          * Analogously to the method getPosition, this method returns a CAAT.Point instance with
    +688          * the coordinate on the path that corresponds to the given length. The input length is
    +689          * related to path's length.
    +690          *
    +691          * @param iLength {number} a float with the target length.
    +692          * @return {CAAT.Point}
    +693          */
    +694 		getPositionFromLength : function(iLength) {
    +695 			
    +696 			iLength%=this.getLength();
    +697 			if (iLength<0 ) {
    +698 				iLength+= this.getLength();
    +699 			}
    +700 			
    +701 			var accLength=0;
    +702 			
    +703 			for( var i=0; i<this.pathSegments.length; i++ ) {
    +704 				if (accLength<=iLength && iLength<=this.pathSegments[i].getLength()+accLength) {
    +705 					iLength-= accLength;
    +706 					var pointInPath= this.pathSegments[i].getPositionFromLength(iLength);
    +707 					this.newPosition.x= pointInPath.x;
    +708 					this.newPosition.y= pointInPath.y;
    +709 					break;
    +710 				}
    +711 				accLength+= this.pathSegments[i].getLength();
    +712 			}
    +713 			
    +714 			return this.newPosition;
    +715 		},
    +716         /**
    +717          * Paints the path.
    +718          * This method is called by CAAT.PathActor instances.
    +719          * If the path is set as interactive (by default) path segment will draw curve modification
    +720          * handles as well.
    +721          *
    +722          * @param director {CAAT.Director} a CAAT.Director instance.
    +723          */
    +724 		paint : function( director ) {
    +725 			for( var i=0; i<this.pathSegments.length; i++ ) {
    +726 				this.pathSegments[i].paint(director,this.interactive);
    +727 			}
    +728 		},
    +729         /**
    +730          * Method invoked when a CAAT.PathActor stops dragging a control point.
    +731          */
    +732 		release : function() {
    +733 			this.ax= -1;
    +734 			this.ay= -1;
    +735 		},
    +736         isEmpty : function() {
    +737             return !this.pathSegments.length;
    +738         },
    +739         /**
    +740          * Returns an integer with the number of path segments that conform this path.
    +741          * @return {number}
    +742          */
    +743         getNumSegments : function() {
    +744             return this.pathSegments.length;
    +745         },
    +746         /**
    +747          * Gets a CAAT.PathSegment instance.
    +748          * @param index {number} the index of the desired CAAT.PathSegment.
    +749          * @return CAAT.PathSegment
    +750          */
    +751 		getSegment : function(index) {
    +752 			return this.pathSegments[index];
    +753 		},
    +754 
    +755         numControlPoints : function() {
    +756             return this.points.length;
    +757         },
    +758 
    +759         getControlPoint : function(index) {
    +760             return this.points[index];
    +761         },
    +762 
    +763         /**
    +764          * Indicates that some path control point has changed, and that the path must recalculate
    +765          * its internal data, ie: length and bbox.
    +766          */
    +767 		updatePath : function(point, callback) {
    +768             var i,j;
    +769 
    +770             this.length=0;
    +771             this.bbox.setEmpty();
    +772             this.points= [];
    +773 
    +774             var xmin= Number.MAX_VALUE, ymin= Number.MAX_VALUE;
    +775 			for( i=0; i<this.pathSegments.length; i++ ) {
    +776 				this.pathSegments[i].updatePath(point);
    +777                 this.length+= this.pathSegments[i].getLength();
    +778                 this.bbox.unionRectangle( this.pathSegments[i].bbox );
    +779 
    +780                 for( j=0; j<this.pathSegments[i].numControlPoints(); j++ ) {
    +781                     var pt= this.pathSegments[i].getControlPoint( j );
    +782                     this.points.push( pt );
    +783                     if ( pt.x < xmin ) {
    +784                         xmin= pt.x;
    +785                     }
    +786                     if ( pt.y < ymin ) {
    +787                         ymin= pt.y;
    +788                     }
    +789                 }
    +790 			}
    +791 
    +792             this.clipOffsetX= -xmin;
    +793             this.clipOffsetY= -ymin;
    +794 
    +795             this.width= this.bbox.width;
    +796             this.height= this.bbox.height;
    +797             this.setLocation( this.bbox.x, this.bbox.y );
    +798 
    +799             this.pathSegmentStartTime=      [];
    +800             this.pathSegmentDurationTime=   [];
    +801             
    +802             var i;
    +803             for( i=0; i<this.pathSegments.length; i++) {
    +804                 this.pathSegmentStartTime.push(0);
    +805                 this.pathSegmentDurationTime.push(0);
    +806             }
    +807 
    +808             for( i=0; i<this.pathSegments.length; i++) {
    +809                 this.pathSegmentDurationTime[i]= this.getLength() ? this.pathSegments[i].getLength()/this.getLength() : 0;
    +810                 if ( i>0 ) {
    +811                     this.pathSegmentStartTime[i]= this.pathSegmentStartTime[i-1]+this.pathSegmentDurationTime[i-1];
    +812                 } else {
    +813                     this.pathSegmentStartTime[0]= 0;
    +814                 }
    +815 
    +816                 this.pathSegments[i].endPath();
    +817             }
    +818 
    +819             this.extractPathPoints();
    +820 
    +821             if ( callback ) {
    +822                 callback(this);
    +823             }
    +824 
    +825             return this;
    +826 
    +827 		},
    +828         /**
    +829          * Sent by a CAAT.PathActor instance object to try to drag a path's control point.
    +830          * @param x {number}
    +831          * @param y {number}
    +832          */
    +833 		press: function(x,y) {
    +834             if (!this.interactive) {
    +835                 return;
    +836             }
    +837 
    +838             var HS= CAAT.Math.Curve.prototype.HANDLE_SIZE/2;
    +839 			for( var i=0; i<this.pathSegments.length; i++ ) {
    +840 				for( var j=0; j<this.pathSegments[i].numControlPoints(); j++ ) {
    +841 					var point= this.pathSegments[i].getControlPoint(j);
    +842 					if ( x>=point.x-HS &&
    +843 						 y>=point.y-HS &&
    +844 						 x<point.x+HS &&
    +845 						 y<point.y+HS ) {
    +846 						
    +847 						this.point= point;
    +848 						return;
    +849 					}
    +850 				}
    +851 			}
    +852 			this.point= null;
    +853 		},
    +854         /**
    +855          * Drags a path's control point.
    +856          * If the method press has not set needed internal data to drag a control point, this
    +857          * method will do nothing, regardless the user is dragging on the CAAT.PathActor delegate.
    +858          * @param x {number}
    +859          * @param y {number}
    +860          */
    +861 		drag : function(x,y,callback) {
    +862             if (!this.interactive) {
    +863                 return;
    +864             }
    +865 
    +866 			if ( null===this.point ) {
    +867 				return;
    +868 			}
    +869 			
    +870 			if ( -1===this.ax || -1===this.ay ) {
    +871 				this.ax= x;
    +872 				this.ay= y;
    +873 			}
    +874 			
    +875             this.point.x+= x-this.ax;
    +876             this.point.y+= y-this.ay;
    +877 
    +878 			this.ax= x;
    +879 			this.ay= y;
    +880 
    +881 			this.updatePath(this.point,callback);
    +882 		},
    +883         /**
    +884          * Returns a collection of CAAT.Point objects which conform a path's contour.
    +885          * @param iSize {number}. Number of samples for each path segment.
    +886          * @return {[CAAT.Point]}
    +887          */
    +888         getContour : function(iSize) {
    +889             var contour=[];
    +890             for( var i=0; i<=iSize; i++ ) {
    +891                 contour.push( new CAAT.Math.Point().set( i/iSize, this.getPosition(i/iSize).y, 0 ) );
    +892             }
    +893 
    +894             return contour;
    +895         },
    +896 
    +897         /**
    +898          * Reposition this path points.
    +899          * This operation will only take place if the supplied points array equals in size to
    +900          * this path's already set points.
    +901          * @param points {Array<CAAT.Point>}
    +902          */
    +903         setPoints : function( points ) {
    +904             if ( this.points.length===points.length ) {
    +905                 for( var i=0; i<points.length; i++ ) {
    +906                     this.points[i].x= points[i].x;
    +907                     this.points[i].y= points[i].y;
    +908                 }
    +909             }
    +910             return this;
    +911         },
    +912 
    +913         /**
    +914          * Set a point from this path.
    +915          * @param point {CAAT.Point}
    +916          * @param index {integer} a point index.
    +917          */
    +918         setPoint : function( point, index ) {
    +919             if ( index>=0 && index<this.points.length ) {
    +920                 this.points[index].x= point.x;
    +921                 this.points[index].y= point.y;
    +922             }
    +923             return this;
    +924         },
    +925 
    +926 
    +927         /**
    +928          * Removes all behaviors from an Actor.
    +929          * @return this
    +930          */
    +931 		emptyBehaviorList : function() {
    +932 			this.behaviorList=[];
    +933             return this;
    +934 		},
    +935 
    +936         extractPathPoints : function() {
    +937             if ( !this.pathPoints ) {
    +938                 var i;
    +939                 this.pathPoints= [];
    +940                 for ( i=0; i<this.numControlPoints(); i++ ) {
    +941                     this.pathPoints.push( this.getControlPoint(i).clone() );
    +942                 }
    +943             }
    +944 
    +945             return this;
    +946         },
    +947 
    +948         /**
    +949          * Add a Behavior to the Actor.
    +950          * An Actor accepts an undefined number of Behaviors.
    +951          *
    +952          * @param behavior {CAAT.Behavior} a CAAT.Behavior instance
    +953          * @return this
    +954          */
    +955 		addBehavior : function( behavior )	{
    +956 			this.behaviorList.push(behavior);
    +957 //            this.extractPathPoints();
    +958             return this;
    +959 		},
    +960         /**
    +961          * Remove a Behavior from the Actor.
    +962          * If the Behavior is not present at the actor behavior collection nothing happends.
    +963          *
    +964          * @param behavior {CAAT.Behavior} a CAAT.Behavior instance.
    +965          */
    +966         removeBehaviour : function( behavior ) {
    +967             var n= this.behaviorList.length-1;
    +968             while(n) {
    +969                 if ( this.behaviorList[n]===behavior ) {
    +970                     this.behaviorList.splice(n,1);
    +971                     return this;
    +972                 }
    +973             }
    +974 
    +975             return this;
    +976         },
    +977         /**
    +978          * Remove a Behavior with id param as behavior identifier from this actor.
    +979          * This function will remove ALL behavior instances with the given id.
    +980          *
    +981          * @param id {number} an integer.
    +982          * return this;
    +983          */
    +984         removeBehaviorById : function( id ) {
    +985             for( var n=0; n<this.behaviorList.length; n++ ) {
    +986                 if ( this.behaviorList[n].id===id) {
    +987                     this.behaviorList.splice(n,1);
    +988                 }
    +989             }
    +990 
    +991             return this;
    +992 
    +993         },
    +994 
    +995         applyBehaviors : function(time) {
    +996 //            if (this.behaviorList.length) {
    +997                 for( var i=0; i<this.behaviorList.length; i++ )	{
    +998                     this.behaviorList[i].apply(time,this);
    +999                 }
    +1000 
    +1001                 /** calculate behavior affine transform matrix **/
    +1002                 this.setATMatrix();
    +1003 
    +1004                 for (i = 0; i < this.numControlPoints(); i++) {
    +1005                     this.setPoint(
    +1006                         this.matrix.transformCoord(
    +1007                             this.pathPoints[i].clone().translate( this.clipOffsetX, this.clipOffsetY )), i);
    +1008                 }
    +1009 //            }
    +1010 
    +1011             return this;
    +1012         },
    +1013 
    +1014         setATMatrix : function() {
    +1015             this.matrix.identity();
    +1016 
    +1017             var m= this.tmpMatrix.identity();
    +1018             var mm= this.matrix.matrix;
    +1019             var c,s,_m00,_m01,_m10,_m11;
    +1020             var mm0, mm1, mm2, mm3, mm4, mm5;
    +1021 
    +1022             var bbox= this.bbox;
    +1023             var bbw= bbox.width  ;
    +1024             var bbh= bbox.height ;
    +1025             var bbx= bbox.x;
    +1026             var bby= bbox.y
    +1027 
    +1028             mm0= 1;
    +1029             mm1= 0;
    +1030             mm3= 0;
    +1031             mm4= 1;
    +1032 
    +1033             mm2= this.tb_x - bbx - this.tAnchorX * bbw;
    +1034             mm5= this.tb_y - bby - this.tAnchorY * bbh;
    +1035 
    +1036             if ( this.rb_angle ) {
    +1037 
    +1038                 var rbx= (this.rb_rotateAnchorX*bbw + bbx);
    +1039                 var rby= (this.rb_rotateAnchorY*bbh + bby);
    +1040 
    +1041                 mm2+= mm0*rbx + mm1*rby;
    +1042                 mm5+= mm3*rbx + mm4*rby;
    +1043 
    +1044                 c= Math.cos( this.rb_angle );
    +1045                 s= Math.sin( this.rb_angle);
    +1046                 _m00= mm0;
    +1047                 _m01= mm1;
    +1048                 _m10= mm3;
    +1049                 _m11= mm4;
    +1050                 mm0=  _m00*c + _m01*s;
    +1051                 mm1= -_m00*s + _m01*c;
    +1052                 mm3=  _m10*c + _m11*s;
    +1053                 mm4= -_m10*s + _m11*c;
    +1054 
    +1055                 mm2+= -mm0*rbx - mm1*rby;
    +1056                 mm5+= -mm3*rbx - mm4*rby;
    +1057             }
    +1058 
    +1059             if ( this.sb_scaleX!=1 || this.sb_scaleY!=1 ) {
    +1060 
    +1061                 var sbx= (this.sb_scaleAnchorX*bbw + bbx);
    +1062                 var sby= (this.sb_scaleAnchorY*bbh + bby);
    +1063 
    +1064                 mm2+= mm0*sbx + mm1*sby;
    +1065                 mm5+= mm3*sbx + mm4*sby;
    +1066 
    +1067                 mm0= mm0*this.sb_scaleX;
    +1068                 mm1= mm1*this.sb_scaleY;
    +1069                 mm3= mm3*this.sb_scaleX;
    +1070                 mm4= mm4*this.sb_scaleY;
    +1071 
    +1072                 mm2+= -mm0*sbx - mm1*sby;
    +1073                 mm5+= -mm3*sbx - mm4*sby;
    +1074             }
    +1075 
    +1076             mm[0]= mm0;
    +1077             mm[1]= mm1;
    +1078             mm[2]= mm2;
    +1079             mm[3]= mm3;
    +1080             mm[4]= mm4;
    +1081             mm[5]= mm5;
    +1082 
    +1083             return this;
    +1084 
    +1085         },
    +1086 
    +1087         setRotationAnchored : function( angle, rx, ry ) {
    +1088             this.rb_angle=          angle;
    +1089             this.rb_rotateAnchorX=  rx;
    +1090             this.rb_rotateAnchorY=  ry;
    +1091             return this;
    +1092         },
    +1093 
    +1094         setRotationAnchor : function( ax, ay ) {
    +1095             this.rb_rotateAnchorX= ax;
    +1096             this.rb_rotateAnchorY= ay;
    +1097         },
    +1098 
    +1099         setRotation : function( angle ) {
    +1100             this.rb_angle= angle;
    +1101         },
    +1102 
    +1103         setScaleAnchored : function( scaleX, scaleY, sx, sy ) {
    +1104             this.sb_scaleX= scaleX;
    +1105             this.sb_scaleAnchorX= sx;
    +1106             this.sb_scaleY= scaleY;
    +1107             this.sb_scaleAnchorY= sy;
    +1108             return this;
    +1109         },
    +1110 
    +1111         setScale : function( sx, sy ) {
    +1112             this.sb_scaleX= sx;
    +1113             this.sb_scaleY= sy;
    +1114             return this;
    +1115         },
    +1116 
    +1117         setScaleAnchor : function( ax, ay ) {
    +1118             this.sb_scaleAnchorX= ax;
    +1119             this.sb_scaleAnchorY= ay;
    +1120             return this;
    +1121         },
    +1122 
    +1123         setPositionAnchor : function( ax, ay ) {
    +1124             this.tAnchorX= ax;
    +1125             this.tAnchorY= ay;
    +1126             return this;
    +1127         },
    +1128 
    +1129         setPositionAnchored : function( x,y,ax,ay ) {
    +1130             this.tb_x= x;
    +1131             this.tb_y= y;
    +1132             this.tAnchorX= ax;
    +1133             this.tAnchorY= ay;
    +1134             return this;
    +1135         },
    +1136 
    +1137         setPosition : function( x,y ) {
    +1138             this.tb_x= x;
    +1139             this.tb_y= y;
    +1140             return this;
    +1141         },
    +1142 
    +1143         setLocation : function( x, y ) {
    +1144             this.tb_x= x;
    +1145             this.tb_y= y;
    +1146             return this;
    +1147         },
    +1148 
    +1149         flatten : function( npatches, closed ) {
    +1150             var point= this.getPositionFromLength(0);
    +1151             var path= new CAAT.PathUtil.Path().beginPath( point.x, point.y );
    +1152             for( var i=0; i<npatches; i++ ) {
    +1153                 point= this.getPositionFromLength(i/npatches*this.length);
    +1154                 path.addLineTo( point.x, point.y  );
    +1155             }
    +1156             if ( closed) {
    +1157                 path.closePath();
    +1158             } else {
    +1159                 path.endPath();
    +1160             }
    +1161 
    +1162             return path;
    +1163         }
    +1164 
    +1165     }
    +1166 	
    +1167 });
    +1168 
    \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/src_PathUtil_PathSegment.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_PathSegment.js.html new file mode 100644 index 00000000..631e91d5 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_RectPath.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_RectPath.js.html new file mode 100644 index 00000000..5b08db4f --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_PathUtil_SVGPath.js.html b/documentation/jsdoc/symbols/src/src_PathUtil_SVGPath.js.html new file mode 100644 index 00000000..e3853808 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_WebGL_ColorProgram.js.html b/documentation/jsdoc/symbols/src/src_WebGL_ColorProgram.js.html new file mode 100644 index 00000000..a56daec6 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_WebGL_GLU.js.html b/documentation/jsdoc/symbols/src/src_WebGL_GLU.js.html new file mode 100644 index 00000000..24425635 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_WebGL_Program.js.html b/documentation/jsdoc/symbols/src/src_WebGL_Program.js.html new file mode 100644 index 00000000..b4540612 --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/jsdoc/symbols/src/src_WebGL_TextureProgram.js.html b/documentation/jsdoc/symbols/src/src_WebGL_TextureProgram.js.html new file mode 100644 index 00000000..d1fed22f --- /dev/null +++ b/documentation/jsdoc/symbols/src/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/documentation/tutorials/02_CAAT_Foundation_Actor.html b/documentation/tutorials/02_CAAT_Foundation_Actor.html index 5edf54db..e3d0b0b5 100644 --- a/documentation/tutorials/02_CAAT_Foundation_Actor.html +++ b/documentation/tutorials/02_CAAT_Foundation_Actor.html @@ -95,12 +95,12 @@

    CAAT.Actor

    More info on CAAT.Actor class

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

    diff --git a/src/Event/MouseEvent.js b/src/Event/MouseEvent.js index 38f2e904..b282a76f 100644 --- a/src/Event/MouseEvent.js +++ b/src/Event/MouseEvent.js @@ -68,6 +68,11 @@ CAAT.Module( { */ meta: false, + /** + * Wheel delta, negative value for scrolling up, positive for scrolling down + */ + wheelDelta: 0, + /** * Original mouse/touch event */ @@ -77,16 +82,17 @@ CAAT.Module( { init : function( x,y,sourceEvent,source,screenPoint,time ) { this.point.set(x,y); - this.source= source; - this.screenPoint= screenPoint; + 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; + this.wheelDelta = sourceEvent.wheelDelta; + this.sourceEvent = sourceEvent; + this.x = x; + this.y = y; + this.time = time; return this; }, isAltDown : function() { diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index a60ac270..b02772c2 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -1592,7 +1592,7 @@ CAAT.Module({ return otherActor.viewToModel(this.modelToView(point)); }, /** - * Transform a point from model to view space. + * Transform a point from view to model space. *

    * WARNING: every call to this method calculates * actor's world model view matrix. @@ -1774,6 +1774,13 @@ CAAT.Module({ */ mouseDblClick:function (mouseEvent) { }, + /** + * Default mouse wheel handler + * + * @param mouseEvent {CAAT.Event.MouseEvent} + */ + mouseWheel:function (mouseEvent) { + }, /** * Default mouse enter on Actor handler. * @param mouseEvent {CAAT.Event.MouseEvent} diff --git a/src/Foundation/ActorCSS.js b/src/Foundation/ActorCSS.js index 4ac0cb88..4c3bf533 100644 --- a/src/Foundation/ActorCSS.js +++ b/src/Foundation/ActorCSS.js @@ -1603,6 +1603,13 @@ CAAT.Module({ */ mouseDblClick:function (mouseEvent) { }, + /** + * Default mouse wheel handler + * + * @param mouseEvent a CAAT.MouseEvent object instance. + */ + mouseWheel:function (mouseEvent) { + }, /** * Default mouse enter on Actor handler. * @param mouseEvent a CAAT.MouseEvent object instance. diff --git a/src/Foundation/Director.js b/src/Foundation/Director.js index f98a2074..8c7a7087 100644 --- a/src/Foundation/Director.js +++ b/src/Foundation/Director.js @@ -2055,7 +2055,7 @@ CAAT.Module({ } this.modelViewMatrixI.transformCoord(pt); posx = pt.x; - posy = pt.y + posy = pt.y; point.set(posx, posy); this.screenMousePoint.set(posx, posy); @@ -2108,7 +2108,7 @@ CAAT.Module({ 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.actionPerformed(e); } lactor.mouseUp( @@ -2358,7 +2358,6 @@ CAAT.Module({ __mouseDBLClickHandler:function (e) { - this.getCanvasCoord(this.mousePoint, e); if (null !== this.lastSelectedActor) { /* var pos = this.lastSelectedActor.viewToModel( @@ -2366,8 +2365,22 @@ CAAT.Module({ */ this.lastSelectedActor.mouseDblClick( new CAAT.Event.MouseEvent().init( - this.mousePoint.x, - this.mousePoint.y, + this.prevMousePoint.x, + this.prevMousePoint.y, + e, + this.lastSelectedActor, + this.screenMousePoint, + this.currentScene.time)); + } + }, + + __mouseWheelHandler:function (e) { + + if (null !== this.lastSelectedActor) { + this.lastSelectedActor.mouseWheel( + new CAAT.Event.MouseEvent().init( + this.prevMousePoint.x, + this.prevMousePoint.y, e, this.lastSelectedActor, this.screenMousePoint, @@ -2842,6 +2855,27 @@ CAAT.Module({ } }, false); + var mouseWheelHandler = 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; + } + + //Cross browser wheel delta + e.wheelDelta = Math.max(-1, Math.min(1, (e.wheelDelta || -e.detail))); + me.__mouseWheelHandler(e); + } + }; + //IE9, Chrome, Safari, Opera + window.addEventListener('mousewheel', mouseWheelHandler, false); + //Firefox + window.addEventListener('DOMMouseScroll', mouseWheelHandler, 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); diff --git a/src/Foundation/sceneCSS.js b/src/Foundation/SceneCSS.js similarity index 100% rename from src/Foundation/sceneCSS.js rename to src/Foundation/SceneCSS.js diff --git a/src/Modules/Image/Preloader/ImagePreloader.js b/src/Modules/Image/Preloader/ImagePreloader.js index 1f539a18..989f6b1a 100755 --- a/src/Modules/Image/Preloader/ImagePreloader.js +++ b/src/Modules/Image/Preloader/ImagePreloader.js @@ -55,8 +55,9 @@ CAAT.Module( { * 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}}} )} + * @param aImages {[{ id:{string}, url:{string}}, ...]} an array of object with two fields id and url. + * @param callback_loaded_one_image {function( counter {number}, images {{ id:{string}, image: {Image}}} )} + * @param callback_error {function (error, index)} * function to call on every image load. */ loadImages: function( aImages, callback_loaded_one_image, callback_error ) { @@ -85,7 +86,7 @@ CAAT.Module( { if ( callback_error ) { callback_error( e, index ); } - } + }; })(i); this.images[i].image.src= aImages[i].url; diff --git a/version.compile.pack.sh b/version.compile.pack.sh index 823c4c6e..a3af8a7d 100755 --- a/version.compile.pack.sh +++ b/version.compile.pack.sh @@ -5,7 +5,8 @@ source ./version.compile.variables.sh ./version.sh VERSION=`cat version.nfo` -echo "New generated version: ${VERSION}" + +echo -e "New generated version: ${VERSION}" CAAT_DST="/tmp/caat" @@ -17,13 +18,13 @@ FILE_CAAT="${DST_FILE_NAME}.js" FILE_CAAT_CSS="${DST_FILE_NAME}-css.js" FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d.js" -echo "Packing ${FILE_CAAT}" -echo "/*" > "${FILE_CAAT}" +echo -e "Packing ${FILE_CAAT}" +echo -e "/*" > "${FILE_CAAT}" cat LICENSE >> "${FILE_CAAT}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}" -echo "Created on:" >> "${FILE_CAAT}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}" +echo -e "Created on:" >> "${FILE_CAAT}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}" -echo "*/\n\n" >> "${FILE_CAAT}" +echo -e "*/\n\n" >> "${FILE_CAAT}" more ./src/Core/ModuleManager.js >> "${FILE_CAAT}" more ./src/Core/Constants.js >> "${FILE_CAAT}" @@ -121,12 +122,12 @@ more ./src/Foundation/UI/ShapeActor.js >> "${FILE_CAAT}" more ./src/Foundation/UI/StarActor.js >> "${FILE_CAAT}" more ./src/Foundation/UI/TextActor.js >> "${FILE_CAAT}" -echo "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT}" +echo -e "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT}" # Distribute resulting compiled files # -echo "\nCopying:" -echo "\tCopying results to ${CAAT_BUILD_DIR}" +echo -e "\nCopying:" +echo -e "\tCopying results to ${CAAT_BUILD_DIR}" cp ${FILE_CAAT} ${CAAT_BUILD_DIR} @@ -134,17 +135,17 @@ cp ${FILE_CAAT} ${CAAT_BUILD_DIR} # # CSS # -echo "Packing ${FILE_CAAT_CSS}" -echo "/*" > "${FILE_CAAT_CSS}" +echo -e "Packing ${FILE_CAAT_CSS}" +echo -e "/*" > "${FILE_CAAT_CSS}" cat LICENSE >> "${FILE_CAAT_CSS}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}" -echo "Created on:" >> "${FILE_CAAT_CSS}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}" +echo -e "Created on:" >> "${FILE_CAAT_CSS}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}" -echo "*/\n\n" >> "${FILE_CAAT_CSS}" +echo -e "*/\n\n" >> "${FILE_CAAT_CSS}" more ./src/Core/ModuleManager.js >> "${FILE_CAAT_CSS}" -echo "CAAT.__CSS__=1;" >> "${FILE_CAAT_CSS}" +echo -e "CAAT.__CSS__=1;" >> "${FILE_CAAT_CSS}" more ./src/Core/Constants.js >> "${FILE_CAAT_CSS}" more ./src/Core/Class.js >> "${FILE_CAAT_CSS}" @@ -236,34 +237,34 @@ more ./src/Foundation/UI/ShapeActor.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/UI/StarActor.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/UI/TextActor.js >> "${FILE_CAAT_CSS}" -echo "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT_CSS}" +echo -e "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT_CSS}" # Distribute resulting compiled files # -echo "\nCopying:" -echo "\tCopying results to ${CAAT_BUILD_DIR}" +echo -e "\nCopying:" +echo -e "\tCopying results to ${CAAT_BUILD_DIR}" cp ${FILE_CAAT_CSS} ${CAAT_BUILD_DIR} # box2d -echo "Packing ${FILE_CAAT_BOX2D}" -echo "/*" > "${FILE_CAAT_BOX2D}" +echo -e "Packing ${FILE_CAAT_BOX2D}" +echo -e "/*" > "${FILE_CAAT_BOX2D}" cat LICENSE >> "${FILE_CAAT_BOX2D}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}" -echo "Created on:" >> "${FILE_CAAT_BOX2D}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}" +echo -e "Created on:" >> "${FILE_CAAT_BOX2D}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}" -echo "*/\n\n" >> "${FILE_CAAT_BOX2D}" +echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}" more ./src/Foundation/Box2D/B2DBodyActor.js >> "${FILE_CAAT_BOX2D}" more ./src/Foundation/Box2D/B2DCircularBody.js >> "${FILE_CAAT_BOX2D}" more ./src/Foundation/Box2D/B2DPolygonBody.js >> "${FILE_CAAT_BOX2D}" -echo "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT_BOX2D}" +echo -e "CAAT.ModuleManager.solveAll();" >> "${FILE_CAAT_BOX2D}" # Distribute resulting compiled files # -echo "\nCopying:" -echo "\tCopying results to ${CAAT_BUILD_DIR}" +echo -e "\nCopying:" +echo -e "\tCopying results to ${CAAT_BUILD_DIR}" cp ${FILE_CAAT_BOX2D} ${CAAT_BUILD_DIR} diff --git a/version.compile.sh b/version.compile.sh index ea66242f..4ab7ff53 100755 --- a/version.compile.sh +++ b/version.compile.sh @@ -3,7 +3,7 @@ source ./version.compile.variables.sh CAAT_DST="/tmp/caat" -echo "\n\nCompilation process\n\n" +echo -e "\n\nCompilation process\n\n" # # define CAAT products files. @@ -21,9 +21,9 @@ FILE_CAAT_BOX2D="${DST_FILE_NAME}-box2d-min.js" # + DST_FILE-css.js # + DST_FILE-box2d.js # -echo "" > "${FILE_CAAT}" -echo "" > "${FILE_CAAT_CSS}" -echo "" > "${FILE_CAAT_BOX2D}" +echo -e "" > "${FILE_CAAT}" +echo -e "" > "${FILE_CAAT_CSS}" +echo -e "" > "${FILE_CAAT_BOX2D}" SOURCE_DIR=${CAAT_SOURCE_DIR} @@ -33,20 +33,20 @@ SOURCE_DIR=${CAAT_SOURCE_DIR} COMPILATION_LEVEL=$1 if [ "${COMPILATION_LEVEL}" ]; then if [[ "${COMPILATION_LEVEL}" == "simple" ]]; then - echo "Compilation level set to simple" + echo -e "Compilation level set to simple" COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS" elif [[ "${COMPILATION_LEVEL}" == "advanced" ]]; then - echo "Compilation level set to advanced" + echo -e "Compilation level set to advanced" COMPILATION_LECEL="ADVANCED_OPTIMIZATIONS" elif [[ "${COMPILATION_LEVEL}" == "spaces" ]]; then - echo "Compilation level set to white spaces" + echo -e "Compilation level set to white spaces" COMPILATION_LEVEL="WHITESPACE_ONLY" else - echo "Compilation level unknown: '${COMPILATION_LEVEL}'. Change to SIMPLE_OPTIMIZATIONS" + echo -e "Compilation level unknown: '${COMPILATION_LEVEL}'. Change to SIMPLE_OPTIMIZATIONS" COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS" fi else - echo "Compilation level defaults to simple optimizations." + echo -e "Compilation level defaults to simple optimizations." COMPILATION_LEVEL="SIMPLE_OPTIMIZATIONS" fi @@ -56,39 +56,39 @@ fi # ./version.sh VERSION=`cat version.nfo` -echo "New generated version: ${VERSION}" -echo "Generated at: ${DST_FILE_NAME}" -echo "From files at: ${SOURCE_DIR}" +echo -e "New generated version: ${VERSION}" +echo -e "Generated at: ${DST_FILE_NAME}" +echo -e "From files at: ${SOURCE_DIR}" # # create stub files for all CAAT products. # -echo "/*" >> "${FILE_CAAT}" +echo -e "/*" >> "${FILE_CAAT}" cat LICENSE >> "${FILE_CAAT}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}" -echo "Created on:" >> "${FILE_CAAT}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT}" +echo -e "Created on:" >> "${FILE_CAAT}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT}" -echo "*/\n\n" >> "${FILE_CAAT}" +echo -e "*/\n\n" >> "${FILE_CAAT}" -echo "/*" >> "${FILE_CAAT_CSS}" +echo -e "/*" >> "${FILE_CAAT_CSS}" cat LICENSE >> "${FILE_CAAT_CSS}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}" -echo "Created on:" >> "${FILE_CAAT_CSS}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_CSS}" +echo -e "Created on:" >> "${FILE_CAAT_CSS}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_CSS}" -echo "*/\n\n" >> "${FILE_CAAT_CSS}" +echo -e "*/\n\n" >> "${FILE_CAAT_CSS}" -echo "/*" >> "${FILE_CAAT_BOX2D}" +echo -e "/*" >> "${FILE_CAAT_BOX2D}" cat LICENSE >> "${FILE_CAAT_BOX2D}" -echo "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}" -echo "Created on:" >> "${FILE_CAAT_BOX2D}" +echo -e "\nVersion: ${VERSION}\n" >> "${FILE_CAAT_BOX2D}" +echo -e "Created on:" >> "${FILE_CAAT_BOX2D}" date "+DATE: %Y-%m-%d%nTIME: %H:%M:%S" >> "${FILE_CAAT_BOX2D}" -echo "*/\n\n" >> "${FILE_CAAT_BOX2D}" +echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}" # # Compile canvas/GL # -echo "\nCreating CAAT canvas/webGL" +echo -e "\nCreating CAAT canvas/webGL" /usr/bin/java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \ --js ${CAAT_BUILD_DIR}/caat.js \ >> "${FILE_CAAT}" @@ -96,22 +96,22 @@ echo "\nCreating CAAT canvas/webGL" # # Compile box2d # -echo "Creating CAAT Box2d" +echo -e "Creating CAAT Box2d" /usr/bin/java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" --js ${CAAT_BUILD_DIR}/caat-box2d.js >> "${FILE_CAAT_BOX2D}" # # Compile css # -echo "Creating CAAT CSS" -echo "CAAT.__CSS__=1;" >> /tmp/__css.js +echo -e "Creating CAAT CSS" +echo -e "CAAT.__CSS__=1;" >> /tmp/__css.js java -jar ${CAAT_CLOSURE_PATH}/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \ --js ${CAAT_BUILD_DIR}/caat-css.js >> "${FILE_CAAT_CSS}" # # Distribute resulting compiled files # -echo "\nCopying:" -echo "\tCopying results to ${CAAT_BUILD_DIR}" +echo -e "\nCopying:" +echo -e "\tCopying results to ${CAAT_BUILD_DIR}" cp ${FILE_CAAT} ${CAAT_BUILD_DIR} cp ${FILE_CAAT_CSS} ${CAAT_BUILD_DIR} cp ${FILE_CAAT_BOX2D} ${CAAT_BUILD_DIR} @@ -120,5 +120,5 @@ cp ${FILE_CAAT_BOX2D} ${CAAT_BUILD_DIR} # # Generating JSDoc. # -echo "\nGenerating JSDoc" +echo -e "\nGenerating JSDoc" ./version.compile.doc.sh diff --git a/version.compile.variables.sh b/version.compile.variables.sh index ff4627c0..281b83c6 100755 --- a/version.compile.variables.sh +++ b/version.compile.variables.sh @@ -3,5 +3,5 @@ CAAT_BUILD_DIR=${CAAT_BUILD_DIR:-./build} CAAT_JSDOC_OUTPUT=${CAAT_JSDOC_OUTPUT:-./documentation/jsdoc} CAAT_DST=${CAAT_DST:-/tmp/caat} -CAAT_CLOSURE_PATH=${CAAT_CLOSURE_PATH:-/Users/ibon/applications/closure} -CAAT_JSDOC_TOOLKIT_PATH=${CAAT_JSDOC_TOOLKIT_PATH:-/Users/ibon/applications/jsdoc-toolkit} +CAAT_CLOSURE_PATH=${CAAT_CLOSURE_PATH:-/applis/renarderi/closure} +CAAT_JSDOC_TOOLKIT_PATH=${CAAT_JSDOC_TOOLKIT_PATH:-/applis/renarderi/jsdoc-toolkit} diff --git a/version.incremental b/version.incremental index 1e8b3149..3fdcd7c4 100644 --- a/version.incremental +++ b/version.incremental @@ -1 +1 @@ -6 +67 diff --git a/version.nfo b/version.nfo index 9e2ed689..90579a61 100644 --- a/version.nfo +++ b/version.nfo @@ -1 +1 @@ -0.6 build: 6 +0.6 build: 67