From 23f0f30548a84f98205aafbc521b84b190ba2b1a Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Tue, 15 Jan 2013 13:37:34 +0100 Subject: [PATCH 01/11] Added setAnimationSpeed() function to replace setFPS() in SpriteImage --- src/Foundation/SpriteImage.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Foundation/SpriteImage.js b/src/Foundation/SpriteImage.js index 2604dcf0..f51ab346 100644 --- a/src/Foundation/SpriteImage.js +++ b/src/Foundation/SpriteImage.js @@ -40,7 +40,7 @@ CAAT.Module({ animationImageIndex:null, // an Array defining the sprite frame sequence prevAnimationTime:-1, - changeFPS:1000, // how much Scene time to take before changing an Sprite frame. + animationTimeDelta:1000, // how much Scene time to take before changing an Sprite frame. transformation:0, // any of the TR_* constants. spriteIndex:0, // the current sprite frame prevIndex:0, // current index of sprite frames array. @@ -117,7 +117,7 @@ CAAT.Module({ this.currentAnimation= name; this.setAnimationImageIndex( animation.animation ); - this.changeFPS= animation.time; + this.animationTimeDelta= animation.time; this.callback= animation.onEndPlayCallback; return this; @@ -617,9 +617,18 @@ CAAT.Module({ * Set the elapsed time needed to change the image index. * @param fps an integer indicating the time in milliseconds to change. * @return this + * @deprecated */ setChangeFPS:function (fps) { - this.changeFPS = fps; + return this.setAnimationSpeed(fps); + }, + /** + * Set the time between two frames of the animation (i.e., time needed to change the image index). + * @param timeDelta an integer indicating the time delta between frames in milliseconds. + * @return this + */ + setAnimationSpeed:function(timeDelta) { + this.animationTimeDelta = timeDelta; return this; }, /** @@ -709,7 +718,7 @@ CAAT.Module({ else { var ttime = time; ttime -= this.prevAnimationTime; - ttime /= this.changeFPS; + ttime /= this.animationTimeDelta; ttime %= this.animationImageIndex.length; var idx = Math.floor(ttime); // if ( this.spriteIndex!==idx ) { From 174b59c09beb4990016818747beb9bfadf012321 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sat, 19 Jan 2013 22:53:37 +0100 Subject: [PATCH 02/11] Added Ibon's fixes of build 55 --- build/caat-box2d-min.js | 19 +- build/caat-box2d.js | 46 +- build/caat-css-min.js | 526 +--------------------- build/caat-css.js | 592 +++---------------------- build/caat-min.js | 535 +--------------------- build/caat.js | 78 +++- src/Behavior/BaseBehavior.js | 11 +- src/Foundation/Actor.js | 4 +- src/Foundation/ActorContainer.js | 2 +- src/Foundation/Box2D/B2DBodyActor.js | 40 +- src/Foundation/Director.js | 3 +- src/Foundation/Scene.js | 2 +- src/Foundation/UI/Layout/GridLayout.js | 33 +- version.compile.sh | 16 +- version.distribution | 2 +- version.incremental | 2 +- version.nfo | 2 +- version.sh | 1 + 18 files changed, 230 insertions(+), 1684 deletions(-) diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index ceb4c0b4..c27e4a2b 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -22,24 +22,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.5 build: 46 +Version: 0.5 build: 55 Created on: -DATE: 2012-12-13 -TIME: 21:30:18 +DATE: 2013-01-19 +TIME: 22:53:06 */ -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:false,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 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+this.width/2)/CAAT.PMR,(a+this.height/2)/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){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=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();this.bodyData.polygonType===CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE?CAAT.Foundation.Actor.prototype.setLocation.call(this,CAAT.PMR*b.x,CAAT.PMR*b.y):CAAT.Foundation.Actor.prototype.setLocation.call(this,CAAT.PMR*b.x-this.width/2,CAAT.PMR*b.y-this.height/2);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){if(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(true);return{worldBody:g,worldBodyFixture:h,fixDef:b,bodyDef:d}}},extendsWith:{radius:1,createBody:function(c,a){var b=a.radius||1;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;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),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,(i-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(true);return{worldBody:e,worldBodyFixture:d,fixDef:b,bodyDef:f,boundingBox:j}}},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 1a1876ab..232eb151 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.5 build: 47 +Version: 0.5 build: 55 Created on: -DATE: 2012-12-13 -TIME: 21:30:47 +DATE: 2013-01-19 +TIME: 22:53:07 */ @@ -39,6 +39,7 @@ CAAT.Module({ extendsWith:function () { CAAT.PMR = 64; + /** * As Eemeli Kelokorpi suggested, * @param set @@ -110,6 +111,25 @@ CAAT.Module({ recycle:false, + __init : function() { + this.__super(); + this.setPositionAnchor(.5,.5); + + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + setPositionAnchored : function(x,y,ax,ay) { + this.x= x; + this.y= y; + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + /** * set this actor to recycle its body, that is, do not destroy it. */ @@ -142,8 +162,8 @@ CAAT.Module({ setLocation:function (x, y) { this.worldBody.SetPosition( new Box2D.Common.Math.b2Vec2( - (x + this.width / 2) / CAAT.PMR, - (y + this.height / 2) / CAAT.PMR)); + x / CAAT.PMR, + y / CAAT.PMR)); return this; }, /** @@ -249,18 +269,10 @@ CAAT.Module({ var pos= this.worldBody.GetPosition(); - if (this.bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x, - CAAT.PMR*pos.y ); - - } else { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x - this.width/2, - CAAT.PMR*pos.y - this.height/2 ); - } + CAAT.Foundation.Actor.prototype.setLocation.call( + this, + CAAT.PMR*pos.x, + CAAT.PMR*pos.y); this.setRotation( this.worldBody.GetAngle() ); diff --git a/build/caat-css-min.js b/build/caat-css-min.js index fbaedeb4..c27e4a2b 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -22,531 +22,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.5 build: 46 +Version: 0.5 build: 55 Created on: -DATE: 2012-12-13 -TIME: 21:30:18 +DATE: 2013-01-19 +TIME: 22:53:06 */ -(function(a){function b(b){for(var b=b.split("."),c=a,d=0;d NOT solved."))},removeDependency:function(a){for(var b=0;b Can't extend non-existant class: "+this.baseClass);return}b.extend(this.extendWith, -this.constants,this.name,this.aliases,{decorated:this.decorated})}else e.extend(this.extendWith,this.constants,this.name,this.aliases,{decorated:this.decorated});console.log("Created module: "+this.name);this.callback&&this.callback()}};var g=function(a,b){this.path=a;this.module=b;return this};g.prototype={path:null,processed:false,module:null,setProcessed:function(){this.processed=true},isProcessed:function(){return this.processed}};var h=function(){this.nodes=[];this.loadedFiles=[];this.path={}; -this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};h.baseURL="";h.modulePath={};h.sortedModulePath=[];h.symbol={};h.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;c1;)h=h[i.shift()];window[g]=h[i];(function(a,g,h,i,n){var q=function(){console.log("Creating object of type proxy["+n+"]");var g=new a[i](Array.prototype.slice.call(arguments));g.____name=n;return proxyObject(g,b,c,d,e,f)};q.prototype=a[i].prototype;for(var p in g[h])g[h].hasOwnProperty(p)&&typeof g[h][p]!=="function"&&p!=="__object"&&p!=="__isProxy"&&function(a,b,c){c.__defineGetter__(b,function(){return a[b]}); -c.__defineSetter__(b,function(c){a[b]=c})}(g[h],p,q);g[h]=q})(window,h,i,g,a)}; -proxyObject=function(a,b,c,d,e,f){if(typeof a!=="object"||isArray(a)||isString(a)||a.__isProxy)return a;a.$proxy__isProxy=true;for(var g in a)if(a.hasOwnProperty(g)&&g!=="constructor")if(typeof a[g]==="function"){var h=a[g];a["$proxy__"+g]=h;a[g]=function(a,e,g){return function(){var f=Array.prototype.slice.call(arguments);b&&b({object:a,objectName:a.____name,method:g,arguments:f});var h=null;try{h=e.apply(a,f),c&&c({object:a,objectName:a.____name,method:g,arguments:f})}catch(n){if(d)h=d({object:a, -objectName:a.____name,method:g,arguments:f,exception:n});else throw n;}return h}}(a,h,g)}else g!=="____name"&&function(a,b,c,d){a["$proxy__"+b]=a[b];a.__defineGetter__(b,function(){c&&c(a.____name,b);return a["$proxy__"+b]});a.__defineSetter__(b,function(c){a["$proxy__"+b]=c;d&&d(a.____name,b,c)})}(a,g,e,f);return a};CAAT.Module({defines:"CAAT.Core.Class",extendsWith:function(){return{}}}); -CAAT.Module({defines:"CAAT.Math.Bezier",depends:["CAAT.Math.Curve"],extendsClass:"CAAT.Math.Curve",aliases:["CAAT.Bezier"],extendsWith:function(){return{cubic:false,applyAsPath:function(a){var b=this.coordlist;this.cubic?a.ctx.bezierCurveTo(b[1].x,b[1].y,b[2].x,b[2].y,b[3].x,b[3].y):a.ctx.quadraticCurveTo(b[1].x,b[1].y,b[2].x,b[2].y);return this},isQuadric:function(){return!this.cubic},isCubic:function(){return this.cubic},setCubic:function(a,b,c,d,e,f,g,h){this.coordlist=[];this.coordlist.push((new CAAT.Math.Point).set(a, -b));this.coordlist.push((new CAAT.Math.Point).set(c,d));this.coordlist.push((new CAAT.Math.Point).set(e,f));this.coordlist.push((new CAAT.Math.Point).set(g,h));this.cubic=true;this.update();return this},setQuadric:function(a,b,c,d,e,f){this.coordlist=[];this.coordlist.push((new CAAT.Math.Point).set(a,b));this.coordlist.push((new CAAT.Math.Point).set(c,d));this.coordlist.push((new CAAT.Math.Point).set(e,f));this.cubic=false;this.update();return this},setPoints:function(a){if(a.length===3)this.coordlist= -a,this.cubic=false,this.update();else if(a.length===4)this.coordlist=a,this.cubic=true,this.update();else throw"points must be an array of 3 or 4 CAAT.Point instances.";return this},paint:function(a){this.cubic?this.paintCubic(a):this.paintCuadric(a);CAAT.Math.Bezier.superclass.paint.call(this,a)},paintCuadric:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Math.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x, -b.y);a.stroke();a.restore()},paintCubic:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Math.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);a.stroke();a.restore()},solve:function(a,b){return this.cubic?this.solveCubic(a,b):this.solveQuadric(a,b)},solveCubic:function(a,b){var c=b*b,d=b*c,e=this.coordlist,f=e[0],g=e[1],h=e[2],e=e[3];a.x=f.x+b*(-f.x*3+b*(3*f.x-f.x*b))+b*(3*g.x+b*(-6*g.x+g.x*3*b))+c*(h.x* -3-h.x*3*b)+e.x*d;a.y=f.y+b*(-f.y*3+b*(3*f.y-f.y*b))+b*(3*g.y+b*(-6*g.y+g.y*3*b))+c*(h.y*3-h.y*3*b)+e.y*d;return a},solveQuadric:function(a,b){var c=this.coordlist,d=c[0],e=c[1],c=c[2],f=1-b;a.x=f*f*d.x+2*f*b*e.x+b*b*c.x;a.y=f*f*d.y+2*f*b*e.y+b*b*c.y;return a}}}}); -CAAT.Module({defines:"CAAT.Math.CatmullRom",depends:["CAAT.Math.Curve"],extendsClass:"CAAT.Math.Curve",aliases:["CAAT.CatmullRom"],extendsWith:function(){return{setCurve:function(a,b,c,d){this.coordlist=[];this.coordlist.push(a);this.coordlist.push(b);this.coordlist.push(c);this.coordlist.push(d);this.update();return this},paint:function(a){var b,c;b=this.coordlist[1].x;c=this.coordlist[1].y;var d=a.ctx;d.save();d.beginPath();d.moveTo(b,c);b=new CAAT.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b, -c),d.lineTo(b.x,b.y);d.stroke();d.restore();CAAT.Math.CatmullRom.superclass.paint.call(this,a)},solve:function(a,b){var c=this.coordlist,d=((-b+2)*b-1)*b*0.5,e=((3*b-5)*b*b+2)*0.5,f=((-3*b+4)*b+1)*b*0.5,g=(b-1)*b*b*0.5;a.x=c[0].x*d+c[1].x*e+c[2].x*f+c[3].x*g;a.y=c[0].y*d+c[1].y*e+c[2].y*f+c[3].y*g;return a},applyAsPath:function(a){for(var a=a.ctx,b=new CAAT.Math.Point,c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);return this},endCurvePosition:function(){return this.coordlist[this.coordlist.length- -2]},startCurvePosition:function(){return this.coordlist[1]}}}}); -CAAT.Module({defines:"CAAT.Math.Curve",depends:["CAAT.Math.Point"],extendsWith:function(){return{coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){var b=this.coordlist,a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(b[0].x,b[0].y);a.lineTo(b[1].x,b[1].y);a.stroke();this.cubic&&(a.moveTo(b[2].x,b[2].y),a.lineTo(b[3].x,b[3].y),a.stroke());a.globalAlpha=0.5;for(var 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}}}}); -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],m=b[2][0],k=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1],p=n[0][2],r=n[0][3],t=n[1][0],s=n[1][1],u=n[1][2],v=n[1][3],w=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*t+e*w+f*A;this.matrix[0][1]=c*q+d*s+e*x+f*B;this.matrix[0][2]=c*p+d*u+e*y+f*C;this.matrix[0][3]= -c*r+d*v+e*z+f*n;this.matrix[1][0]=g*a+h*t+i*w+j*A;this.matrix[1][1]=g*q+h*s+i*x+j*B;this.matrix[1][2]=g*p+h*u+i*y+j*C;this.matrix[1][3]=g*r+h*v+i*z+j*n;this.matrix[2][0]=m*a+k*t+o*w+b*A;this.matrix[2][1]=m*q+k*s+o*x+b*B;this.matrix[2][2]=m*p+k*u+o*y+b*C;this.matrix[2][3]=m*r+k*v+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],m=b[2][0],k=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1], -p=n[0][2],r=n[0][3],t=n[1][0],s=n[1][1],u=n[1][2],v=n[1][3],w=n[2][0],x=n[2][1],y=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*t+e*w;this.matrix[0][1]=c*q+d*s+e*x;this.matrix[0][2]=c*p+d*u+e*y;this.matrix[0][3]=c*r+d*v+e*n+f;this.matrix[1][0]=g*a+h*t+i*w;this.matrix[1][1]=g*q+h*s+i*x;this.matrix[1][2]=g*p+h*u+i*y;this.matrix[1][3]=g*r+h*v+i*n+j;this.matrix[2][0]=m*a+k*t+o*w;this.matrix[2][1]=m*q+k*s+o*x;this.matrix[2][2]=m*p+k*u+o*y;this.matrix[2][3]=m*r+k*v+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],m=a[2][1],k=a[2][2],o=a[2][3],n=a[3][0],q=a[3][1],p=a[3][2],a=a[3][3];return e*g*k*n+c*i*k*n+e*h*j*q+d*i*j*q+d*f*o*q+b*h*o*q+e*f*m*p+b*i*m*p+d*g*j*a+c*h*j*a+c*f*k*a+b*g*k*a+e*h*m*n-d*i*m*n-d*g*o*n-c*h*o*n-e*f*k*q-b*i*k*q-e*g*j*p-c*i*j*p-c*f*o*p-b*g*o*p-d*f*m*a-b*h*m*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],m=a[2][1],k= -a[2][2],o=a[2][3],n=a[3][0],q=a[3][1],p=a[3][2],a=a[3][3],r=new CAAT.Math.Matrix3;r.matrix[0][0]=h*o*q+i*m*p+g*k*a-i*k*q-g*o*p-h*m*a;r.matrix[0][1]=e*k*q+c*o*p+d*m*a-c*k*a-d*o*q-e*m*p;r.matrix[0][2]=d*i*q+c*h*a+e*g*p-c*i*p-d*g*a-e*h*q;r.matrix[0][3]=e*h*m+c*i*k+d*g*o-d*i*m-e*g*k-c*h*o;r.matrix[1][0]=i*k*n+f*o*p+h*j*a-h*o*n-i*j*p-f*k*a;r.matrix[1][1]=d*o*n+e*j*p+b*k*a-e*k*n-b*o*p-d*j*a;r.matrix[1][2]=e*h*n+b*i*p+d*f*a-d*i*n-e*f*p-b*h*a;r.matrix[1][3]=d*i*j+e*f*k+b*h*o-e*h*j-b*i*k-d*f*o;r.matrix[2][0]= -g*o*n+i*j*q+f*m*a-i*m*n-f*o*q-g*j*a;r.matrix[2][1]=e*m*n+b*o*q+c*j*a-b*m*a-c*o*n-e*j*q;r.matrix[2][2]=d*i*n+e*f*q+b*g*a-e*g*n-b*i*q-c*f*a;r.matrix[2][3]=e*g*j+b*i*m+c*f*o-b*g*o-c*i*j-e*f*m;r.matrix[3][0]=h*m*n+f*k*q+g*j*p-g*k*n-h*j*q-f*m*p;r.matrix[3][1]=c*k*n+d*j*q+b*m*p-d*m*n-b*k*q-c*j*p;r.matrix[3][2]=d*g*n+b*h*q+c*f*p-b*g*p-c*h*n-d*f*q;r.matrix[3][3]=c*h*j+d*f*m+b*g*k-d*g*j-b*h*m-c*f*k;return r.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;b<4;b++)for(c= -0;c<4;c++)this.matrix[b][c]*=a;return this}}}}); -CAAT.Module({defines:"CAAT.Math.Point",aliases:["CAAT.Point"],extendsWith:function(){return{x:0,y:0,z:0,__init:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},set:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},clone:function(){return new CAAT.Math.Point(this.x,this.y,this.z)},translate:function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this},translatePoint:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},subtract:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z; -return this},multiply:function(a){this.x*=a;this.y*=a;this.z*=a;return this},rotate:function(a){var b=this.x,c=this.y;this.x=b*Math.cos(a)-Math.sin(a)*c;this.y=b*Math.sin(a)+Math.cos(a)*c;this.z=0;return this},setAngle:function(a){var b=this.getLength();this.x=Math.cos(a)*b;this.y=Math.sin(a)*b;this.z=0;return this},setLength:function(a){var b=this.getLength();b?this.multiply(a/b):this.x=this.y=this.z=a;return this},normalize:function(){var a=this.getLength();this.x/=a;this.y/=a;this.z/=a;return this}, -getAngle:function(){return Math.atan2(this.y,this.x)},limit:function(a){var b=this.getLengthSquared();if(b+0.01>a*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b* -b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Math.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}}}); -CAAT.Module({defines:"CAAT.Math.Rectangle",aliases:["CAAT.Rectangle"],extendsWith:function(){return{__init:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d)},x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+ -this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d);return this},contains:function(a,b){return a>=this.x&&a=this.y&&bthis.y1)this.y1=b;if(a>this.x1)this.x1=a;this.width=this.x1- -this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1,a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1<=this.x?false:a.x>=this.x1?false:a.y1<=this.y?false:a.ythis.x1?false:b+d-1=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e= -0,f=this.lifecycleListenerList.length;e>=0;for(var d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}}}}); -CAAT.Module({defines:"CAAT.Behavior.ContainerBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Behavior.GenericBehavior"],aliases:["CAAT.ContainerBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{behaviors:null,__init:function(){this.__super();this.behaviors=[];return this},conformToDuration:function(a){this.duration=a;a/=this.duration;for(var b,c=0;c=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}}, -calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return"";typeof c==="undefined"&&(c=100);for(var d=null,e="@-"+a+"-keyframes "+b+" {",f,b=0;b<=c;b++)f=this.interpolator.getPosition(b/c).y,d=this.calculateKeyFrameData(f,a,d),f=""+b/c*100+"%{"+d.rules+"}\n",d=d.ret,e+=f;e+="}";return e}}}}); -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}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,getPropertyName:function(){return"translate"},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)"},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);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.Foundation.SpriteImage,h=CAAT.Behavior.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL), -f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x,c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}}}}); -CAAT.Module({defines:"CAAT.Behavior.RotateBehavior",extendsClass:"CAAT.Behavior.BaseBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.RotateBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);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)"}, -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)+"}\n",e+=d;e+="}";return e}}}}); -CAAT.Module({defines:"CAAT.Behavior.Scale1Behavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.Scale1Behavior"],constants:{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,sx:1,sy:1,applyOnX: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+")"},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}}}}); -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,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"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)+"}",e+=d;e+="}";return e}}}}); -CAAT.Module({defines:"CAAT.Module.Runtime.BrowserInfo",constants:function(){function a(a){for(var b=0;b0){var b=this.channels.shift(); -b.src=a.src;b.load();b.volume=a.volume;b.play();this.workingChannels.push(b)}return this},loop:function(a){if(!this.musicEnabled)return this;a=this.getAudio(a);if(null!==a){var b=document.createElement("audio");if(null!==b)return b.src=a.src,b.preload="auto",this.browserInfo.browser==="Firefox"?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,m,k,o,n,q,p,r,t,s;for(f=0;f>24&255;n=(k&16711680)>>16;q=(k&65280)>>8;k&=255;g=a[f+1];p=g>>24&255;r=(g&16711680)>>16;t=(g&65280)>>8;g&=255;p=(p-o)/b;r=(r-n)/b;t=(t-q)/b;s=(g-k)/b;for(g=0;g>0;i=n+r*g>>0;j=q+t*g>>0;m=k+s*g>>0;var u=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case u.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+m+")");break;case u.RAMP_RGB:d.push("rgb("+i+","+j+","+m+")");break;case u.RAMP_CHANNEL_RGB:d.push(4278190080| -i<<16|j<<8|m);break;case u.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|m);break;case u.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,m,h]);break;case u.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,m])}}}return d},random:function(){for(var a="#",b=0;b<3;b++)a+="0123456789abcdef"[Math.random()*16>>0];return a}},extendsWith:{__init:function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this},r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}}); -CAAT.Module({defines:"CAAT.Module.Debug.Debug",depends:["CAAT.Event.AnimationLoop"],extendsWith:{width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,textDiscardDR:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'
CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0 Discard DR: 0
Sound
Music
AA Bounding Boxes
Bounding Boxes
Dirty Rects
', -setScale:function(a){this.scale=a;return this},initialize:function(a,b){this.width=a=window.innerWidth;this.height=b;this.framerate={refreshInterval:CAAT.FPS_REFRESH||500,frames:0,timeLastRefresh:0,fps:0,prevFps:-1,fpsMin:1E3,fpsMax:0};if(!document.getElementById("caat-debug")){var c=document.createElement("div");c.innerHTML=this.debugTpl;document.body.appendChild(c);eval(' var __x= CAAT; function initCheck( name, bool, callback ) { var elem= document.getElementById(name); if ( elem ) { elem.className= (bool) ? "checkbox_enabled" : "checkbox_disabled"; if ( callback ) { elem.addEventListener( "click", (function(elem, callback) { return function(e) { elem.__value= !elem.__value; elem.className= (elem.__value) ? "checkbox_enabled" : "checkbox_disabled"; callback(e,elem.__value); } })(elem, callback), false ); } elem.__value= bool; } } function setupTabs() { var numTabs=0; var elem; var elemContent; do { elem= document.getElementById("caat-debug-tab"+numTabs); if ( elem ) { elemContent= document.getElementById("caat-debug-tab"+numTabs+"-content"); if ( elemContent ) { elemContent.style.display= numTabs===0 ? \'block\' : \'none\'; elem.className= numTabs===0 ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; elem.addEventListener( "click", (function(tabIndex) { return function(e) { for( var i=0; ithis.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps=this.framerate.frames* -1E3/(a.RAF-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this.framerate.fpsMin;this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps);this.textFPS.innerHTML=this.framerate.fps;var b=(this.frameTimeAcc*100/this.framerate.frames|0)/100;this.frameTimeAcc=0;this.textDrawTime.innerHTML=b;b=(this.frameRAFAcc*100/this.framerate.frames|0)/100;this.frameRAFAcc=0;this.textRAFTime.innerHTML=b;this.framerate.timeLastRefresh= -a.RAF;this.framerate.frames=0;this.paint(b)}this.textEntitiesTotal.innerHTML=this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws;this.textDiscardDR.innerHTML=this.statistics.size_discarded_by_dirty_rects},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle="black";b.beginPath(); -b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath(); -b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}}); -CAAT.Module({defines:"CAAT.Module.Font.Font",aliases:"CAAT.Font",depends:["CAAT.Foundation.SpriteImage"],constants:{getFontMetrics:function(a){var b;if(CAAT.CSS_TEXT_METRICS)try{return b=CAAT.Module.Font.Font.getFontMetricsCSS(a)}catch(c){}return CAAT.Module.Font.Font.getFontMetricsNoCSS(a)},getFontMetricsNoCSS:function(a){var a=/(\d+)p[x|t]/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;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){var e=this;this.id=a;this.path=c;this.image=new Image;this.image.onload=function(){d.__onload(e)};this.image.onerror=function(){d.__onerror(e)};this.load=function(){e.image.src=e.path};return this};return{__init:function(){this.elements=[];return this},elements:null,imageCounter:0,cfinished:null,cloaded:null,cerrored:null,loadedCount:0,addElement:function(b,c){this.elements.push(new a(b,c,this));return this}, -__onload:function(a){this.cloaded&&this.cloaded(a.id);this.loadedCount++;this.loadedCount===this.elements.length&&this.cfinished&&this.cfinished(this.elements)},__onerror:function(a){this.cerrored&&this.cerrored(a.id)},load:function(a,c,d){this.cfinished=a;this.cloaded=c;this.cerroed=d;for(a=0;a>=0;var d=true,e=true,f=true,g=true;if(typeof c!== -"undefined"){if(typeof c.top!=="undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,m=c.height-1,k=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}m=d}if(f){n=false;for(j=0;jb){n=true;break}if(n)break}k=j}if(g){n=false;for(j=c.width-1;j>=k;j--){for(d=a;d<=m;d++)if(i[d*c.width*4+3+j*4]>b){n=true;break}if(n)break}o=j}if(0===k&&0===a&&c.width-1===o&&c.height-1===m)return c;b=o-k+1;e=m-a+1;f=h.getImageData(k,a,b,e);c.width=b;c.height= -e;h=c.getContext("2d");h.putImageData(f,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}}); -CAAT.Module({defines:"CAAT.Module.Collision.QuadTree",depends:["CAAT.Math.Rectangle"],extendsClass:"CAAT.Math.Rectangle",extendsWith:function(){return{bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]= -(new CAAT.Module.Collision.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,i,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ -a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; -for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;bb&&(g=b),setTimeout(function(){j(a,e,c)},g)):j(a,e,c)}};return g}function j(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(true);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,false,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, -0.4))}var c=document.getElementById(c),m;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 k=document.createElement("canvas");c.appendChild(k);c=k}else false==c instanceof HTMLCanvasElement&&(k=document.createElement("canvas"),document.body.appendChild(k),c=k);else c=document.createElement("canvas"),document.body.appendChild(c);m=(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});m.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){m.setImagesCache(b);var c=i(m,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,length:-1,cw:true,bbox:null,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:false,setRadius:function(a){this.radius= -a;return this},isArcTo:function(){return this.arcTo},setArcTo:function(a){this.arcTo=a;return this},initialize:function(a,b,c,d){this.setInitialPosition(a,b);this.setFinalPosition(a+c,b);this.angle=d||2*Math.PI;return this},applyAsPath:function(a){a=a.ctx;this.arcTo?a.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):a.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.angle+this.startAngle,this.cw);return this},setPoint:function(a,b){b>=0&& -b1||a<0)a%=1;a<0&&(a=1+a);-1===this.length?this.newPosition.set(this.points[0].x,this.points[0].y):(a=this.angle*a*(this.cw?1:-1)+this.startAngle,this.newPosition.set(this.points[0].x+this.radius*Math.cos(a),this.points[0].y+this.radius*Math.sin(a)));return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save(); -c.strokeStyle=this.color;c.beginPath();this.arcTo?c.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):c.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.startAngle+this.angle,this.cw);c.stroke();if(b){c.globalAlpha=0.5;c.fillStyle="#7f7f00";for(var d=0;d1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition, -a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x},finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]}, -endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/a,y:this.getPosition(c/a).y});return b}}}}); -CAAT.Module({defines:"CAAT.PathUtil.LinearPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point"],aliases:["CAAT.LinearPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point(0,0,0);return this},points:null,newPosition:null,applyAsPath:function(a){a.ctx.lineTo(this.points[1].x,this.points[1].y)},setPoint:function(a, -b){b===0?this.points[0]=a:b===1&&(this.points[1]=a)},updatePath:function(){var a=this.points[1].x-this.points[0].x,b=this.points[1].y-this.points[0].y;this.length=Math.sqrt(a*a+b*b);this.bbox.setEmpty();this.bbox.union(this.points[0].x,this.points[0].y);this.bbox.union(this.points[1].x,this.points[1].y);return this},setPoints:function(a){this.points[0]=a[0];this.points[1]=a[1];this.updatePath();return this},setInitialPosition:function(a,b){this.points[0].x=a;this.points[0].y=b;this.newPosition.set(a, -b);return this},setFinalPosition:function(a,b){this.points[1].x=a;this.points[1].y=b;return this},endCurvePosition:function(){return this.points[1]},startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x}, -finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0]; -else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); -CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; -return this},points:null,length:-1,cw:true,bbox:null,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&&b -1||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(;f1||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 a< -i?f=g:e=g+1;return this.endCurvePosition()},getPositionFromLength:function(a){a%=this.getLength();a<0&&(a+=this.getLength());for(var b=0,c=0;c0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();b&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Math.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b=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},reset:function(a){this.remove=false;this.startTime=a;this.scene.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){a=(new CAAT.Foundation.Timer.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,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?d=Math.floor((b+c-1)/c):c=Math.floor((b+d-1)/d);for(var e=(d-1)*this.hgap,f=a.width- -(this.padding.left+this.padding.right),g=Math.floor((f-e)/d),h=(c-1)*this.vgap,i=a.height-(this.padding.top+this.padding.bottom),j=Math.floor((i-h)/c),h=Math.floor((i-(j*c+h))/2),i=0,e=this.padding.left+Math.floor((f-(g*d+e))/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 m=i+(d/h>>0)*f,k=g+e,o=m+f;g=(new CAAT.Foundation.SpriteImageHelper(g,m,k-g,o-m,j.width,j.height)).setGL(g/j.width,m/j.height,k/j.width,o/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(f-=d);var g=(this.offsetY-this.ownerActor.y)%e;g>0&&(g-=e);for(var d=((c.width-f)/d>>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx, -a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save(); -a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex]; -a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a, -b,c,d,e,f,g){a.drawImage(this.image,d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex]; -return""+-(a.x+this.parentOffsetX-this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height- -this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV; -break;case b.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint=this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this}, -setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1){if(this.prevAnimationTime===-1)this.prevAnimationTime=a,this.spriteIndex=this.animationImageIndex[0],this.prevIndex=0;else{var b=a;b-=this.prevAnimationTime;b/=this.changeFPS;b%=this.animationImageIndex.length;b=Math.floor(b);b>0,f=0;fa&&(a=c)}this.fontHeight=a;return this.fontHeight*this.fontScale},drawText:function(a,b,c,d){var e,f,g;for(e=0;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, --this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,-this.height));break;case CAAT.Foundation.Actor.ANCHOR_BOTTOM:d?f.setPath((new CAAT.Path).setLinear(0,this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,this.height));break;case CAAT.Foundation.Actor.ANCHOR_LEFT:d?f.setPath((new CAAT.Path).setLinear(-this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,-this.width,0));break;case CAAT.Foundation.Actor.ANCHOR_RIGHT:d?f.setPath((new CAAT.Path).setLinear(this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0, -0,this.width,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);a=f.path.startCurvePosition();this.setLocation(a.x,a.y);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn= -false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:case CAAT.Foundation.Actor.ANCHOR_CENTER:j=i=1;break;case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:j= -h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var m;m=g;g=i;i=m;m=h;h=j;j=m}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time,b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this}, -easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var f=0,g=0;if(c==CAAT.Foundation.Actor.ANCHOR_CENTER)c=CAAT.Foundation.Actor.ANCHOR_TOP;switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:f= -Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false===d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,d);b=this.getAnchorPercent(c);f=(new CAAT.Behavior.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f); -this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a},behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a;this.style("display",a?"none":"block")},paint:function(){},getIn:function(){}, -goOut:function(){}}}}); -CAAT.Module({defines:"CAAT.Foundation.Director",aliases:["CAAT.Director"],extendsClass:"CAAT.Foundation.ActorContainer",depends:"CAAT.Core.Class,CAAT.Core.Constants,CAAT.Foundation.ActorContainer,CAAT.Module.Audio.AudioManager,CAAT.Module.Runtime.BrowserInfo,CAAT.Module.Debug.Debug,CAAT.Math.Point,CAAT.Math.Rectangle,CAAT.Math.Matrix,CAAT.Foundation.Timer.TimerManager,CAAT.Foundation.Actor,CAAT.Foundation.Scene,CAAT.Event.AnimationLoop,CAAT.Event.Input,CAAT.Event.KeyEvent,CAAT.Event.MouseEvent,CAAT.Event.TouchEvent,CAAT.WebGL.Program,CAAT.WebGL.ColorProgram,CAAT.WebGL.TextureProgram,CAAT.WebGL.GLU,CAAT.Module.TexturePacker.TexturePageManager".split(","),constants:{RENDER_MODE_CONTINUOUS:1, -RENDER_MODE_DIRTY:2,CLEAR_DIRTY_RECTS:1,CLEAR_ALL:true,CLEAR_NONE:false,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16},extendsWith:function(){return{__init:function(){this.__super();this.browserInfo=CAAT.Module.Runtime.BrowserInfo;this.audioManager=(new CAAT.Module.Audio.AudioManager).initialize(8);this.scenes=[];this.mousePoint=new CAAT.Math.Point(0,0,0);this.prevMousePoint=new CAAT.Math.Point(0,0,0);this.screenMousePoint=new CAAT.Math.Point(0,0,0);this.isMouseDown= -false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.sDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Math.Rectangle);this.dirtyRectsIndex=0;this.touches={};this.timerManager=new CAAT.Foundation.Timer.TimerManager;this.__map={};return this},debug:false,renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false,lastSelectedActor:null, -dragging:false,scenes:null,currentScene:null,canvas:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:CAAT.Foundation.Director.CLEAR_ALL,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null,glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,size_dirtyRects:0,draws:0,size_discarded_by_dirty_rects:0},currentTexturePage:0,currentOpacity:1,intervalId:null, -frameCounter:0,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,sDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,nDirtyRects:0,drDiscarded:0,stopped:false,needsRepaint:false,touches:null,timerManager:null,SCREEN_RATIO:1,__map:null,clean:function(){this.audioManager=this.imagesCache=this.currentScene=this.scenes=null;this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.__gestureRotation=this.__gestureScale=0;this.dirty= -true;this.cDirtyRects=this.dirtyRects=null;this.dirtyRectsIndex=0;this.dirtyRectsEnabled=false;this.nDirtyRects=0;this.onResizeCallback=null;this.__map={};return this},setValueForKey:function(a,b){this.__map[a]=b;return this},getValueForKey:function(a){return this.__map[a]},createTimer:function(a,b,c,d,e){this.timerManager.createTimer(a,b,c,d,e);return this},requestRepaint:function(){this.needsRepaint=true},getCurrentScene:function(){return this.currentScene},checkDebug:function(){if(!navigator.isCocoonJS&& -CAAT.DEBUG){var a=(new CAAT.Module.Debug.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){var c=CAAT.Foundation.Director;switch(this.resize){case c.RESIZE_WIDTH:this.setBounds(0,0,a,this.height);break;case c.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case c.RESIZE_BOTH:this.setBounds(0,0,a,b);break;case c.RESIZE_PROPORTIONAL:this.setScaleProportional(a,b)}this.glEnabled&&this.glReset(); -if(this.onResizeCallback)this.onResizeCallback(this,a,b)},setScaleProportional:function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");this.__setupRetina();this.setScaleAnchored(c*this.scaleX,c*this.scaleY,0,0);this.glEnabled&&this.glReset()},enableResizeEvents:function(a,b){var c=CAAT.Foundation.Director;a===c.RESIZE_BOTH|| -a===c.RESIZE_WIDTH||a===c.RESIZE_HEIGHT||a===c.RESIZE_PROPORTIONAL?(this.referenceWidth=this.width,this.referenceHeight=this.height,this.resize=a,CAAT.registerResizeListener(this),this.onResizeCallback=b,this.windowResized(window.innerWidth,window.innerHeight)):(CAAT.unregisterResizeListener(this),this.onResizeCallback=null);return this},__setupRetina:function(){if(CAAT.RETINA_DISPLAY_ENABLED){var a=CAAT.Module.Runtime.BrowserInfo.DevicePixelRatio,b=this.ctx.webkitBackingStorePixelRatio||this.ctx.mozBackingStorePixelRatio|| -this.ctx.msBackingStorePixelRatio||this.ctx.oBackingStorePixelRatio||this.ctx.backingStorePixelRatio||1,c=a/b;a!==b?(a=this.canvas.width,b=this.canvas.height,this.canvas.width=a*c,this.canvas.height=b*c,this.canvas.style.width=a+"px",this.canvas.style.height=b+"px",this.setScaleAnchored(c,c,0,0)):this.setScaleAnchored(1,1,0,0);this.SCREEN_RATIO=c}else this.setScaleAnchored(1,1,0,0);for(c=0;c=0;b--){var c=this.childrenList[b],d=new CAAT.Math.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0;this.statistics.size_discarded_by_dirty_rects=0},render:function(a){if(!this.currentScene||!this.currentScene.isPaused()){this.time+=a;for(e=0,l=this.childrenList.length;e0&&!navigator.isCocoonJS&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;b=this.cDirtyRects; -for(e=0;e=this.dirtyRects.length)for(b= -0;b<32;b++)this.dirtyRects.push(new CAAT.Math.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.setTransform(1,0,0,1,0,0);a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);var c=this.ctx;this.ctx=a;a.save();var d=this.modelViewMatrix,e=this.worldModelViewMatrix;this.modelViewMatrix=this.worldModelViewMatrix= -new CAAT.Math.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;this.modelViewMatrix=d;a.restore();this.ctx=c}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a= -this.scenes[a];d=this.scenes[d];if(!CAAT.__CSS__&&!this.glEnabled)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=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=false,this.__mouseUpHandler(a)},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),!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){c.target===a&&(c.preventDefault(),b.__gestureStart(c.scale,c.rotation))},false),a.addEventListener("gestureend",function(c){c.target===a&&(c.preventDefault(),b.__gestureEnd(c.scale,c.rotation))},false),a.addEventListener("gesturechange",function(c){c.target===a&&(c.preventDefault(),b.__gestureChange(c.scale,c.rotation))},false)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this), -false),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),false),a.addEventListener("touchcancel",this.__touchCancelHandleMT.bind(this),false),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),false),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this),false),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),false))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=false;this.createEventHandler(a)}, -createEventHandler:function(a){this.in_=false;this.addHandlers(a)}}},onCreate:function(){if(typeof CAAT.__CSS__!=="undefined")CAAT.Foundation.Director.prototype.clip=true,CAAT.Foundation.Director.prototype.glEnabled=false,CAAT.Foundation.Director.prototype.getRenderType=function(){return"CSS"},CAAT.Foundation.Director.prototype.setScaleProportional=function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.eventHandler.style.width=""+this.referenceWidth+ -"px";this.eventHandler.style.height=""+this.referenceHeight+"px"},CAAT.Foundation.Director.prototype.setBounds=function(a,b,c,d){CAAT.Foundation.Director.superclass.setBounds.call(this,a,b,c,d);for(a=0;ad+this.range?this.minSize:a===d?this.maxSize:a>0)+1)*b},setFillStyle:function(a){this.fill=a},setStrokeStyle:function(a){this.stroke=a},setStrokeSize:function(a){this.strokeSize= -a},setAlignment:function(a){this.alignment=a},setFontSize:function(a){if(a!==this.fontSize)this.fontSize=a,this.__setFont()}};var b=function(){this.text="";return this};b.prototype={x:0,y:0,width:0,text:null,crcs:null,rcs:null,styles:null,images:null,lines:null,documentHeight:0,anchorStack:null,__nextLine:function(){this.x=0;this.currentLine=new f;this.lines.push(this.currentLine)},__image:function(a,b,c){var e;e=b&&c?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 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,k){d.superclass.constructor.call(this,k,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=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.singleHeight: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(){this.elements=[];return this};f.prototype={elements:null,width:0,height: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:0,b?b.getHeight():0);this.height=this.baselinePos+(a!=null?a.descent:0);for(c=0;c",d+1),-1!==o&&(n=f.substr(d+1,o-d-1),n.indexOf("<")!==-1?(this.rc.fchar(q),d+=1):(this.rc.setTag(n),d=o+1))):(this.rc.fchar(q),d+=1);this.rc.end(); -this.lines=this.rc.lines;this.__calculateDocumentDimension(typeof b==="undefined"?0:b);this.setLinesAlignment();p.restore();this.setPreferredSize(this.documentWidth,this.documentHeight);this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);return this}},setVerticalAlignment:function(a){this.valignment=a;this.setDocumentPosition();return this},setHorizontalAlignment:function(a){this.halignment=a;this.setDocumentPosition();return this},setDocumentPosition:function(){var a=0, -b=0;this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?b=(this.height-this.documentHeight)/2:this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM&&(b=this.height-this.documentHeight);this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?a=(this.width-this.documentWidth)/2:this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT&&(a=this.width-this.documentWidth);this.documentX=a;this.documentY=b},__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,showBBox:false,getPath:function(){return this.path},setPath:function(a){this.path=a;if(a!=null)this.pathBoundingRectangle=a.getBoundingBox(),this.setInteractive(this.interactive);return this},paint:function(a,b){CAAT.Foundation.UI.PathActor.superclass.paint.call(this, -a,b);if(this.path){var c=a.ctx;c.strokeStyle="#000";this.path.paint(a,this.interactive);if(this.bOutline)c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height)}},showBoundingBox:function(a,b){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= -a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); -CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= -a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= -a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ -2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, -this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); -CAAT.Module({defines:"CAAT.Foundation.UI.StarActor",aliases:["CAAT.StarActor"],depends:["CAAT.Foundation.ActorContainer"],extendsClass:"CAAT.Foundation.ActorContainer",extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";return this},nPeaks:0,maxRadius:0,minRadius:0,initialAngle:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap=a;return this},setLineJoin:function(a){this.lineJoin= -a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setFilled:function(){return this},setOutlined:function(){return this},setCompositeOp:function(a){this.compositeOp=a;return this},setInitialAngle:function(a){this.initialAngle=a;return this},initialize:function(a,b,c){this.setSize(2*b,2*b);this.nPeaks= -a;this.maxRadius=b;this.minRadius=c;return this},paint:function(a){var a=a.ctx,b=this.width/2,c=this.height/2,d=this.maxRadius,e=this.minRadius,f=b+d*Math.cos(this.initialAngle),g=c+d*Math.sin(this.initialAngle);a.lineWidth=this.lineWidth;if(this.lineCap)a.lineCap=this.lineCap;if(this.lineJoin)a.lineJoin=this.lineJoin;if(this.miterLimit)a.miterLimit=this.miterLimit;a.globalCompositeOperation=this.compositeOp;a.beginPath();a.moveTo(f,g);for(f=1;f>0,e.y>>0);c.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 * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. * - * @constructor + * */ __init:function () { this.lifecycleListenerList = []; @@ -3765,6 +3773,7 @@ CAAT.Module({ discardable:false, // is true, this behavior will be removed from the this.actor instance when it expires. + /* @memberOf CAAT.Behavior.BaseBehavior */ setValueApplication:function (apply) { this.doValueApplication = apply; return this; @@ -12872,8 +12881,16 @@ CAAT.Module( { doLayout : function( container ) { - var nactors= container.getNumChildren(); - if (nactors === 0) { + var actors= []; + for( var i=0; i= 0) { - if (!this.timerList[i].remove) { - this.timerList[i].checkTask(time); - } - i--; - } - }, - /** - * Make sure the timertask is contained in the timer task list by adding it to the list in case it - * is not contained. - * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. - * @return this - */ - ensureTimerTask:function (timertask) { - if (!this.hasTimer(timertask)) { - this.timerList.push(timertask); - } - return this; - }, - /** - * Check whether the timertask is in this scene's timer task list. - * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. - * @return {boolean} a boolean indicating whether the timertask is in this scene or not. - */ - hasTimer:function (timertask) { - var i = this.timerList.length - 1; - while (i >= 0) { - if (this.timerList[i] === timertask) { - return true; - } - i--; - } - - return false; - }, - /** - * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene - * is taken out of the Director the timer task is paused, and resumed on Scene restoration. - * - * @param startTime {number} an integer indicating the scene time this task must start executing at. - * @param duration {number} an integer indicating the timerTask duration. - * @param callback_timeout {function} timer on timeout callback function. - * @param callback_tick {function} timer on tick callback function. - * @param callback_cancel {function} timer on cancel callback function. - * - * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. - */ - createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { - - var tt = new CAAT.TimerTask().create( - startTime, - duration, - callback_timeout, - callback_tick, - callback_cancel); - - tt.taskId = this.timerSequence++; - tt.sceneTime = this.time; - tt.scene = this; - - this.timerList.push(tt); - - return tt; - }, - /** - * Removes expired timers. This method must not be called directly. - */ - removeExpiredTimers:function () { - var i; - for (i = 0; i < this.timerList.length; i++) { - if (this.timerList[i].remove) { - this.timerList.splice(i, 1); - } - } - }, - /** - * Scene animation method. - * It extendsClass Container's base behavior by adding timer control. - * @param director {CAAT.Director} a CAAT.Director instance. - * @param time {number} an integer indicating the Scene time the animation is being performed at. - */ -// animate:function (director, time) { -// this.checkTimers(time); -// CAAT.Scene.superclass.animate.call(this, director, time); -// this.removeExpiredTimers(); -// }, - /** - * Helper method to manage alpha transparency fading on Scene switch by the Director. - * @param time {number} integer indicating the time in milliseconds the fading will take. - * @param isIn {boolean} boolean indicating whether this Scene in the switch process is - * being brought in. - * - * @private - */ - createAlphaBehaviour:function (time, isIn) { - var ab = new CAAT.AlphaBehavior(); - ab.setFrameTime(0, time); - ab.startAlpha = isIn ? 0 : 1; - ab.endAlpha = isIn ? 1 : 0; - this.easeContainerBehaviour.addBehavior(ab); - }, - /** - * Called from CAAT.Director to bring in an Scene. - * A helper method for easeTranslation. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslationIn:function (time, alpha, anchor, interpolator) { - this.easeTranslation(time, alpha, anchor, true, interpolator); - }, - /** - * Called from CAAT.Director to bring in an Scene. - * A helper method for easeTranslation. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslationOut:function (time, alpha, anchor, interpolator) { - this.easeTranslation(time, alpha, anchor, false, interpolator); - }, - /** - * This method will setup Scene behaviours to switch an Scene via a translation. - * The anchor value can only be - *
  • CAAT.Actor.ANCHOR_LEFT - *
  • CAAT.Actor.ANCHOR_RIGHT - *
  • CAAT.Actor.ANCHOR_TOP - *
  • CAAT.Actor.ANCHOR_BOTTOM - * if any other value is specified, any of the previous ones will be applied. - * - * @param time integer indicating time in milliseconds for the Scene. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param isIn boolean indicating whether the scene will be brought in. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslation:function (time, alpha, anchor, isIn, interpolator) { - - this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); - this.easeIn = isIn; - - var pb = new CAAT.Behavior.PathBehavior(); - if (interpolator) { - pb.setInterpolator(interpolator); - } - - pb.setFrameTime(0, time); - - // BUGBUG anchors: 1..4 - if (anchor < 1) { - anchor = 1; - } else if (anchor > 4) { - anchor = 4; - } - - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(0, -this.height, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, 0, -this.height)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(0, this.height, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, 0, this.height)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_LEFT: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(-this.width, 0, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, -this.width, 0)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(this.width, 0, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, this.width, 0)); - } - break; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - this.easeContainerBehaviour.addBehavior(pb); - - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - var start = pb.path.startCurvePosition(); - this.setLocation(start.x, start.y); - - this.emptyBehaviorList(); - CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Called from CAAT.Director to bring in a Scene. - * A helper method for easeScale. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - */ - easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { - this.easeScale(starttime, time, alpha, anchor, true, interpolator); - this.easeIn = true; - }, - /** - * Called from CAAT.Director to take away a Scene. - * A helper method for easeScale. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator instance to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - */ - easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { - this.easeScale(starttime, time, alpha, anchor, false, interpolator); - this.easeIn = false; - }, - /** - * Called from CAAT.Director to bring in ot take away an Scene. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - * @param isIn boolean indicating whether the Scene is being brought in. - */ - easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { - this.easeContainerBehaviour = new CAAT.ContainerBehavior(); - - var x = 0; - var y = 0; - var x2 = 0; - var y2 = 0; - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: - case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_CENTER: - x2 = 1; - y2 = 1; - break; - case CAAT.Foundation.Actor.ANCHOR_TOP: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - x = 1; - x2 = 1; - y = 0; - y2 = 1; - break; - case CAAT.Foundation.Actor.ANCHOR_LEFT: - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - y = 1; - y2 = 1; - x = 0; - x2 = 1; - break; - default: - alert('scale anchor ?? ' + anchor); - } - - if (!isIn) { - var tmp; - tmp = x; - x = x2; - x2 = tmp; - - tmp = y; - y = y2; - y2 = tmp; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - var anchorPercent = this.getAnchorPercent(anchor); - var sb = new CAAT.ScaleBehavior(). - setFrameTime(starttime, time). - setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); - - if (interpolator) { - sb.setInterpolator(interpolator); - } - - this.easeContainerBehaviour.addBehavior(sb); - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - this.emptyBehaviorList(); - CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Overriden method to disallow default behavior. - * Do not use directly. - */ - addBehavior:function (behaviour) { - return this; - }, - /** - * Called from CAAT.Director to use Rotations for bringing in. - * This method is a Helper for the method easeRotation. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeRotationIn:function (time, alpha, anchor, interpolator) { - this.easeRotation(time, alpha, anchor, true, interpolator); - this.easeIn = true; - }, - /** - * Called from CAAT.Director to use Rotations for taking Scenes away. - * This method is a Helper for the method easeRotation. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeRotationOut:function (time, alpha, anchor, interpolator) { - this.easeRotation(time, alpha, anchor, false, interpolator); - this.easeIn = false; - }, - /** - * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. - * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param isIn boolean indicating whehter the Scene is brought in. - */ - easeRotation:function (time, alpha, anchor, isIn, interpolator) { - this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); - - var start = 0; - var end = 0; - - if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { - anchor = CAAT.Foundation.Actor.ANCHOR_TOP; - } - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - case CAAT.Foundation.Actor.ANCHOR_LEFT: - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - start = Math.PI * (Math.random() < 0.5 ? 1 : -1); - break; - case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: - case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: - start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); - break; - default: - alert('rot anchor ?? ' + anchor); - } - - if (false === isIn) { - var tmp = start; - start = end; - end = tmp; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - var anchorPercent = this.getAnchorPercent(anchor); - var rb = new CAAT.Behavior.RotateBehavior(). - setFrameTime(0, time). - setValues(start, end, anchorPercent.x, anchorPercent.y); - - if (interpolator) { - rb.setInterpolator(interpolator); - } - this.easeContainerBehaviour.addBehavior(rb); - - - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - this.emptyBehaviorList(); - CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Registers a listener for listen for transitions events. - * Al least, the Director registers himself as Scene easing transition listener. - * When the transition is done, it restores the Scene's capability of receiving events. - * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form - * behaviorExpired( caat_behaviour, time, actor); - */ - setEaseListener:function (listener) { - this.easeContainerBehaviourListener = listener; - }, - /** - * Private. - * listener for the Scene's easeContainerBehaviour. - * @param actor - */ - behaviorExpired:function (actor) { - this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); - }, - /** - * This method should be overriden in case the developer wants to do some special actions when - * the scene has just been brought in. - */ - activated:function () { - }, - /** - * Scenes, do not expire the same way Actors do. - * It simply will be set expired=true, but the frameTime won't be modified. - * WARN: the parameter here is treated as boolean, not number. - */ - setExpired:function (bExpired) { - this.expired = bExpired; - this.style('display', bExpired ? 'none' : 'block'); - }, - /** - * An scene by default does not paint anything because has not fillStyle set. - * @param director - * @param time - */ - paint:function (director, time) { - }, - - getIn : function( out_scene ) { - - }, - - goOut : function( in_scene ) { - - } - } - } -});/** * See LICENSE file. * **/ @@ -17314,8 +16829,7 @@ CAAT.Module({ }, createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { - this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel); - return this; + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel); }, requestRepaint:function () { diff --git a/build/caat-min.js b/build/caat-min.js index 22f92c1d..c27e4a2b 100644 --- a/build/caat-min.js +++ b/build/caat-min.js @@ -22,540 +22,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.5 build: 46 +Version: 0.5 build: 55 Created on: -DATE: 2012-12-13 -TIME: 21:30:18 +DATE: 2013-01-19 +TIME: 22:53:06 */ -(function(a){function b(b){for(var b=b.split("."),c=a,d=0;d NOT solved."))},removeDependency:function(a){for(var b=0;b Can't extend non-existant class: "+this.baseClass);return}b.extend(this.extendWith, -this.constants,this.name,this.aliases,{decorated:this.decorated})}else e.extend(this.extendWith,this.constants,this.name,this.aliases,{decorated:this.decorated});console.log("Created module: "+this.name);this.callback&&this.callback()}};var g=function(a,b){this.path=a;this.module=b;return this};g.prototype={path:null,processed:false,module:null,setProcessed:function(){this.processed=true},isProcessed:function(){return this.processed}};var h=function(){this.nodes=[];this.loadedFiles=[];this.path={}; -this.solveListener=[];this.orderedSolvedModules=[];this.readyListener=[];return this};h.baseURL="";h.modulePath={};h.sortedModulePath=[];h.symbol={};h.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;c1;)h=h[i.shift()];window[g]=h[i];(function(a,g,h,i,m){var q=function(){console.log("Creating object of type proxy["+m+"]");var g=new a[i](Array.prototype.slice.call(arguments));g.____name=m;return proxyObject(g,b,c,d,e,f)};q.prototype=a[i].prototype;for(var p in g[h])g[h].hasOwnProperty(p)&&typeof g[h][p]!=="function"&&p!=="__object"&&p!=="__isProxy"&&function(a,b,c){c.__defineGetter__(b,function(){return a[b]}); -c.__defineSetter__(b,function(c){a[b]=c})}(g[h],p,q);g[h]=q})(window,h,i,g,a)}; -proxyObject=function(a,b,c,d,e,f){if(typeof a!=="object"||isArray(a)||isString(a)||a.__isProxy)return a;a.$proxy__isProxy=true;for(var g in a)if(a.hasOwnProperty(g)&&g!=="constructor")if(typeof a[g]==="function"){var h=a[g];a["$proxy__"+g]=h;a[g]=function(a,e,g){return function(){var f=Array.prototype.slice.call(arguments);b&&b({object:a,objectName:a.____name,method:g,arguments:f});var h=null;try{h=e.apply(a,f),c&&c({object:a,objectName:a.____name,method:g,arguments:f})}catch(m){if(d)h=d({object:a, -objectName:a.____name,method:g,arguments:f,exception:m});else throw m;}return h}}(a,h,g)}else g!=="____name"&&function(a,b,c,d){a["$proxy__"+b]=a[b];a.__defineGetter__(b,function(){c&&c(a.____name,b);return a["$proxy__"+b]});a.__defineSetter__(b,function(c){a["$proxy__"+b]=c;d&&d(a.____name,b,c)})}(a,g,e,f);return a};CAAT.Module({defines:"CAAT.Core.Class",extendsWith:function(){return{}}}); -CAAT.Module({defines:"CAAT.Math.Bezier",depends:["CAAT.Math.Curve"],extendsClass:"CAAT.Math.Curve",aliases:["CAAT.Bezier"],extendsWith:function(){return{cubic:false,applyAsPath:function(a){var b=this.coordlist;this.cubic?a.ctx.bezierCurveTo(b[1].x,b[1].y,b[2].x,b[2].y,b[3].x,b[3].y):a.ctx.quadraticCurveTo(b[1].x,b[1].y,b[2].x,b[2].y);return this},isQuadric:function(){return!this.cubic},isCubic:function(){return this.cubic},setCubic:function(a,b,c,d,e,f,g,h){this.coordlist=[];this.coordlist.push((new CAAT.Math.Point).set(a, -b));this.coordlist.push((new CAAT.Math.Point).set(c,d));this.coordlist.push((new CAAT.Math.Point).set(e,f));this.coordlist.push((new CAAT.Math.Point).set(g,h));this.cubic=true;this.update();return this},setQuadric:function(a,b,c,d,e,f){this.coordlist=[];this.coordlist.push((new CAAT.Math.Point).set(a,b));this.coordlist.push((new CAAT.Math.Point).set(c,d));this.coordlist.push((new CAAT.Math.Point).set(e,f));this.cubic=false;this.update();return this},setPoints:function(a){if(a.length===3)this.coordlist= -a,this.cubic=false,this.update();else if(a.length===4)this.coordlist=a,this.cubic=true,this.update();else throw"points must be an array of 3 or 4 CAAT.Point instances.";return this},paint:function(a){this.cubic?this.paintCubic(a):this.paintCuadric(a);CAAT.Math.Bezier.superclass.paint.call(this,a)},paintCuadric:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Math.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x, -b.y);a.stroke();a.restore()},paintCubic:function(a){var b,c;b=this.coordlist[0].x;c=this.coordlist[0].y;a=a.ctx;a.save();a.beginPath();a.moveTo(b,c);b=new CAAT.Math.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);a.stroke();a.restore()},solve:function(a,b){return this.cubic?this.solveCubic(a,b):this.solveQuadric(a,b)},solveCubic:function(a,b){var c=b*b,d=b*c,e=this.coordlist,f=e[0],g=e[1],h=e[2],e=e[3];a.x=f.x+b*(-f.x*3+b*(3*f.x-f.x*b))+b*(3*g.x+b*(-6*g.x+g.x*3*b))+c*(h.x* -3-h.x*3*b)+e.x*d;a.y=f.y+b*(-f.y*3+b*(3*f.y-f.y*b))+b*(3*g.y+b*(-6*g.y+g.y*3*b))+c*(h.y*3-h.y*3*b)+e.y*d;return a},solveQuadric:function(a,b){var c=this.coordlist,d=c[0],e=c[1],c=c[2],f=1-b;a.x=f*f*d.x+2*f*b*e.x+b*b*c.x;a.y=f*f*d.y+2*f*b*e.y+b*b*c.y;return a}}}}); -CAAT.Module({defines:"CAAT.Math.CatmullRom",depends:["CAAT.Math.Curve"],extendsClass:"CAAT.Math.Curve",aliases:["CAAT.CatmullRom"],extendsWith:function(){return{setCurve:function(a,b,c,d){this.coordlist=[];this.coordlist.push(a);this.coordlist.push(b);this.coordlist.push(c);this.coordlist.push(d);this.update();return this},paint:function(a){var b,c;b=this.coordlist[1].x;c=this.coordlist[1].y;var d=a.ctx;d.save();d.beginPath();d.moveTo(b,c);b=new CAAT.Point;for(c=this.k;c<=1+this.k;c+=this.k)this.solve(b, -c),d.lineTo(b.x,b.y);d.stroke();d.restore();CAAT.Math.CatmullRom.superclass.paint.call(this,a)},solve:function(a,b){var c=this.coordlist,d=((-b+2)*b-1)*b*0.5,e=((3*b-5)*b*b+2)*0.5,f=((-3*b+4)*b+1)*b*0.5,g=(b-1)*b*b*0.5;a.x=c[0].x*d+c[1].x*e+c[2].x*f+c[3].x*g;a.y=c[0].y*d+c[1].y*e+c[2].y*f+c[3].y*g;return a},applyAsPath:function(a){for(var a=a.ctx,b=new CAAT.Math.Point,c=this.k;c<=1+this.k;c+=this.k)this.solve(b,c),a.lineTo(b.x,b.y);return this},endCurvePosition:function(){return this.coordlist[this.coordlist.length- -2]},startCurvePosition:function(){return this.coordlist[1]}}}}); -CAAT.Module({defines:"CAAT.Math.Curve",depends:["CAAT.Math.Point"],extendsWith:function(){return{coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){var b=this.coordlist,a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(b[0].x,b[0].y);a.lineTo(b[1].x,b[1].y);a.stroke();this.cubic&&(a.moveTo(b[2].x,b[2].y),a.lineTo(b[3].x,b[3].y),a.stroke());a.globalAlpha=0.5;for(var 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}}}}); -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],n=b[2][0],k=b[2][1],o=b[2][2],b=b[2][3],m=a.matrix,a=m[0][0],q=m[0][1],p=m[0][2],r=m[0][3],t=m[1][0],s=m[1][1],u=m[1][2],v=m[1][3],w=m[2][0],x=m[2][1],y=m[2][2],z=m[2][3],A=m[3][0],B=m[3][1],C=m[3][2],m=m[3][3];this.matrix[0][0]=c*a+d*t+e*w+f*A;this.matrix[0][1]=c*q+d*s+e*x+f*B;this.matrix[0][2]=c*p+d*u+e*y+f*C;this.matrix[0][3]= -c*r+d*v+e*z+f*m;this.matrix[1][0]=g*a+h*t+i*w+j*A;this.matrix[1][1]=g*q+h*s+i*x+j*B;this.matrix[1][2]=g*p+h*u+i*y+j*C;this.matrix[1][3]=g*r+h*v+i*z+j*m;this.matrix[2][0]=n*a+k*t+o*w+b*A;this.matrix[2][1]=n*q+k*s+o*x+b*B;this.matrix[2][2]=n*p+k*u+o*y+b*C;this.matrix[2][3]=n*r+k*v+o*z+b*m;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],n=b[2][0],k=b[2][1],o=b[2][2],b=b[2][3],m=a.matrix,a=m[0][0],q=m[0][1], -p=m[0][2],r=m[0][3],t=m[1][0],s=m[1][1],u=m[1][2],v=m[1][3],w=m[2][0],x=m[2][1],y=m[2][2],m=m[2][3];this.matrix[0][0]=c*a+d*t+e*w;this.matrix[0][1]=c*q+d*s+e*x;this.matrix[0][2]=c*p+d*u+e*y;this.matrix[0][3]=c*r+d*v+e*m+f;this.matrix[1][0]=g*a+h*t+i*w;this.matrix[1][1]=g*q+h*s+i*x;this.matrix[1][2]=g*p+h*u+i*y;this.matrix[1][3]=g*r+h*v+i*m+j;this.matrix[2][0]=n*a+k*t+o*w;this.matrix[2][1]=n*q+k*s+o*x;this.matrix[2][2]=n*p+k*u+o*y;this.matrix[2][3]=n*r+k*v+o*m+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],n=a[2][1],k=a[2][2],o=a[2][3],m=a[3][0],q=a[3][1],p=a[3][2],a=a[3][3];return e*g*k*m+c*i*k*m+e*h*j*q+d*i*j*q+d*f*o*q+b*h*o*q+e*f*n*p+b*i*n*p+d*g*j*a+c*h*j*a+c*f*k*a+b*g*k*a+e*h*n*m-d*i*n*m-d*g*o*m-c*h*o*m-e*f*k*q-b*i*k*q-e*g*j*p-c*i*j*p-c*f*o*p-b*g*o*p-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],i=a[1][3],j=a[2][0],n=a[2][1],k= -a[2][2],o=a[2][3],m=a[3][0],q=a[3][1],p=a[3][2],a=a[3][3],r=new CAAT.Math.Matrix3;r.matrix[0][0]=h*o*q+i*n*p+g*k*a-i*k*q-g*o*p-h*n*a;r.matrix[0][1]=e*k*q+c*o*p+d*n*a-c*k*a-d*o*q-e*n*p;r.matrix[0][2]=d*i*q+c*h*a+e*g*p-c*i*p-d*g*a-e*h*q;r.matrix[0][3]=e*h*n+c*i*k+d*g*o-d*i*n-e*g*k-c*h*o;r.matrix[1][0]=i*k*m+f*o*p+h*j*a-h*o*m-i*j*p-f*k*a;r.matrix[1][1]=d*o*m+e*j*p+b*k*a-e*k*m-b*o*p-d*j*a;r.matrix[1][2]=e*h*m+b*i*p+d*f*a-d*i*m-e*f*p-b*h*a;r.matrix[1][3]=d*i*j+e*f*k+b*h*o-e*h*j-b*i*k-d*f*o;r.matrix[2][0]= -g*o*m+i*j*q+f*n*a-i*n*m-f*o*q-g*j*a;r.matrix[2][1]=e*n*m+b*o*q+c*j*a-b*n*a-c*o*m-e*j*q;r.matrix[2][2]=d*i*m+e*f*q+b*g*a-e*g*m-b*i*q-c*f*a;r.matrix[2][3]=e*g*j+b*i*n+c*f*o-b*g*o-c*i*j-e*f*n;r.matrix[3][0]=h*n*m+f*k*q+g*j*p-g*k*m-h*j*q-f*n*p;r.matrix[3][1]=c*k*m+d*j*q+b*n*p-d*n*m-b*k*q-c*j*p;r.matrix[3][2]=d*g*m+b*h*q+c*f*p-b*g*p-c*h*m-d*f*q;r.matrix[3][3]=c*h*j+d*f*n+b*g*k-d*g*j-b*h*n-c*f*k;return r.multiplyScalar(1/this.calculateDeterminant())},multiplyScalar:function(a){var b,c;for(b=0;b<4;b++)for(c= -0;c<4;c++)this.matrix[b][c]*=a;return this}}}}); -CAAT.Module({defines:"CAAT.Math.Point",aliases:["CAAT.Point"],extendsWith:function(){return{x:0,y:0,z:0,__init:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},set:function(a,b,c){this.x=a;this.y=b;this.z=c||0;return this},clone:function(){return new CAAT.Math.Point(this.x,this.y,this.z)},translate:function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this},translatePoint:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},subtract:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z; -return this},multiply:function(a){this.x*=a;this.y*=a;this.z*=a;return this},rotate:function(a){var b=this.x,c=this.y;this.x=b*Math.cos(a)-Math.sin(a)*c;this.y=b*Math.sin(a)+Math.cos(a)*c;this.z=0;return this},setAngle:function(a){var b=this.getLength();this.x=Math.cos(a)*b;this.y=Math.sin(a)*b;this.z=0;return this},setLength:function(a){var b=this.getLength();b?this.multiply(a/b):this.x=this.y=this.z=a;return this},normalize:function(){var a=this.getLength();this.x/=a;this.y/=a;this.z/=a;return this}, -getAngle:function(){return Math.atan2(this.y,this.x)},limit:function(a){var b=this.getLengthSquared();if(b+0.01>a*a)b=Math.sqrt(b),this.x=this.x/b*a,this.y=this.y/b*a,this.z=this.z/b*a;return this},getLength:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);return a<0.0050&&a>-0.0050?1.0E-6:a},getLengthSquared:function(){var a=this.x*this.x+this.y*this.y+this.z*this.z;return a<0.0050&&a>-0.0050?0:a},getDistance:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return Math.sqrt(b* -b+c*c+a*a)},getDistanceSquared:function(a){var b=this.x-a.x,c=this.y-a.y,a=this.z-a.z;return b*b+c*c+a*a},toString:function(){return"(CAAT.Math.Point) x:"+String(Math.round(Math.floor(this.x*10))/10)+" y:"+String(Math.round(Math.floor(this.y*10))/10)+" z:"+String(Math.round(Math.floor(this.z*10))/10)}}}}); -CAAT.Module({defines:"CAAT.Math.Rectangle",aliases:["CAAT.Rectangle"],extendsWith:function(){return{__init:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d)},x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.y1=this.x1=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+ -this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c,d);return this},contains:function(a,b){return a>=this.x&&a=this.y&&bthis.y1)this.y1=b;if(a>this.x1)this.x1=a;this.width=this.x1- -this.x;this.height=this.y1-this.y}},unionRectangle:function(a){this.union(a.x,a.y);this.union(a.x1,a.y);this.union(a.x,a.y1);this.union(a.x1,a.y1);return this},intersects:function(a){return a.isEmpty()||this.isEmpty()?false:a.x1<=this.x?false:a.x>=this.x1?false:a.y1<=this.y?false:a.ythis.x1?false:b+d-1=this.behaviorStartTime&&(a=(a-this.behaviorStartTime)%this.behaviorDuration+this.behaviorStartTime);if(a>this.behaviorStartTime+this.behaviorDuration)return this.status!==e.EXPIRED&&this.setExpired(b,a),false;if(this.status===e.NOT_STARTED)this.status=e.STARTED,this.fireBehaviorStartedEvent(b,a);return this.behaviorStartTime<=a},fireBehaviorStartedEvent:function(a,b){for(var e= -0,f=this.lifecycleListenerList.length;e>=0;for(var d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+a/c*100+"%{opacity: "+this.calculateKeyFrameData(a/c)+"}",d+=b;d+="}";return d}}}}); -CAAT.Module({defines:"CAAT.Behavior.ContainerBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Behavior.GenericBehavior"],aliases:["CAAT.ContainerBehavior"],extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{behaviors:null,__init:function(){this.__super();this.behaviors=[];return this},conformToDuration:function(a){this.duration=a;a/=this.duration;for(var b,c=0;c=h&&(h=(h-f.behaviorStartTime)/f.behaviorDuration,h=f.calculateKeyFrameData(h),f=f.getPropertyName(b),typeof g[f]==="undefined"&&(g[f]=""),g[f]+=h+" "));var i="",j;d("translate");d("rotate");d("scale");a="";i&&(a="-"+b+"-transform: "+i+";");i="";d("opacity");i&&(a+=" opacity: "+i+";");return{rules:a,ret:g}}, -calculateKeyFramesData:function(a,b,c){if(this.duration===Number.MAX_VALUE)return"";typeof c==="undefined"&&(c=100);for(var d=null,e="@-"+a+"-keyframes "+b+" {",f,b=0;b<=c;b++)f=this.interpolator.getPosition(b/c).y,d=this.calculateKeyFrameData(f,a,d),f=""+b/c*100+"%{"+d.rules+"}\n",d=d.ret,e+=f;e+="}";return e}}}}); -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}},extendsClass:"CAAT.Behavior.BaseBehavior",extendsWith:function(){return{path:null,autoRotate:false,prevX:-1,prevY:-1,autoRotateOp:CAAT.Behavior.PathBehavior.autorotate.FREE,getPropertyName:function(){return"translate"},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)"},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);if(this.autoRotate){if(-1===this.prevX&&-1===this.prevY)this.prevX=c.x,this.prevY=c.y;var d=c.x-this.prevX,e=c.y-this.prevY;if(d===0&&e===0)return b.setLocation(c.x,c.y),{x:b.x,y:b.y};var f=Math.atan2(e,d),g=CAAT.Foundation.SpriteImage,h=CAAT.Behavior.PathBehavior.autorotate;this.autoRotateOp===h.LEFT_TO_RIGHT?this.prevX<=c.x?b.setImageTransformation(g.TR_NONE):(b.setImageTransformation(g.TR_FLIP_HORIZONTAL), -f+=Math.PI):this.autoRotateOp===h.RIGHT_TO_LEFT&&(this.prevX<=c.x?b.setImageTransformation(g.TR_FLIP_HORIZONTAL):(b.setImageTransformation(g.TR_NONE),f-=Math.PI));b.setRotation(f);this.prevX=c.x;this.prevY=c.y;Math.sqrt(d*d+e*e)}return this.doValueApplication?(b.setLocation(c.x,c.y),{x:b.x,y:b.y}):{x:c.x,y:c.y}},positionOnTime:function(a){return this.isBehaviorInTime(a,null)?(a=this.normalizeTime(a),this.path.getPosition(a)):{x:-1,y:-1}}}}}); -CAAT.Module({defines:"CAAT.Behavior.RotateBehavior",extendsClass:"CAAT.Behavior.BaseBehavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.RotateBehavior"],extendsWith:function(){return{__init:function(){this.__super();this.anchor=CAAT.Foundation.Actor.ANCHOR_CENTER;return this},startAngle:0,endAngle:0,anchorX:0.5,anchorY:0.5,getPropertyName:function(){return"rotate"},setForTime:function(a,b){var c=this.startAngle+a*(this.endAngle-this.startAngle);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)"}, -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)+"}\n",e+=d;e+="}";return e}}}}); -CAAT.Module({defines:"CAAT.Behavior.Scale1Behavior",depends:["CAAT.Behavior.BaseBehavior","CAAT.Foundation.Actor"],aliases:["CAAT.Scale1Behavior"],constants:{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,sx:1,sy:1,applyOnX: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+")"},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}}}}); -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,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"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)+"}",e+=d;e+="}";return e}}}}); -CAAT.Module({defines:"CAAT.Module.Runtime.BrowserInfo",constants:function(){function a(a){for(var b=0;b0){var b=this.channels.shift(); -b.src=a.src;b.load();b.volume=a.volume;b.play();this.workingChannels.push(b)}return this},loop:function(a){if(!this.musicEnabled)return this;a=this.getAudio(a);if(null!==a){var b=document.createElement("audio");if(null!==b)return b.src=a.src,b.preload="auto",this.browserInfo.browser==="Firefox"?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,n,k,o,m,q,p,r,t,s;for(f=0;f>24&255;m=(k&16711680)>>16;q=(k&65280)>>8;k&=255;g=a[f+1];p=g>>24&255;r=(g&16711680)>>16;t=(g&65280)>>8;g&=255;p=(p-o)/b;r=(r-m)/b;t=(t-q)/b;s=(g-k)/b;for(g=0;g>0;i=m+r*g>>0;j=q+t*g>>0;n=k+s*g>>0;var u=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case u.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+n+")");break;case u.RAMP_RGB:d.push("rgb("+i+","+j+","+n+")");break;case u.RAMP_CHANNEL_RGB:d.push(4278190080| -i<<16|j<<8|n);break;case u.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|n);break;case u.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,n,h]);break;case u.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,n])}}}return d},random:function(){for(var a="#",b=0;b<3;b++)a+="0123456789abcdef"[Math.random()*16>>0];return a}},extendsWith:{__init:function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this},r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}}); -CAAT.Module({defines:"CAAT.Module.Debug.Debug",depends:["CAAT.Event.AnimationLoop"],extendsWith:{width:0,height:0,canvas:null,ctx:null,statistics:null,framerate:null,textContainer:null,textFPS:null,textEntitiesTotal:null,textEntitiesActive:null,textDraws:null,textDrawTime:null,textRAFTime:null,textDirtyRects:null,textDiscardDR:null,frameTimeAcc:0,frameRAFAcc:0,canDebug:false,SCALE:60,debugTpl:'
    CAAT Debug panel Performance Controls Draw Time: 5.46 ms. FPS: 48
    RAF Time: 20.76 ms. Entities Total: 41 Entities Active: 37 Draws: 0 DirtyRects: 0 Discard DR: 0
    Sound
    Music
    AA Bounding Boxes
    Bounding Boxes
    Dirty Rects
    ', -setScale:function(a){this.scale=a;return this},initialize:function(a,b){this.width=a=window.innerWidth;this.height=b;this.framerate={refreshInterval:CAAT.FPS_REFRESH||500,frames:0,timeLastRefresh:0,fps:0,prevFps:-1,fpsMin:1E3,fpsMax:0};if(!document.getElementById("caat-debug")){var c=document.createElement("div");c.innerHTML=this.debugTpl;document.body.appendChild(c);eval(' var __x= CAAT; function initCheck( name, bool, callback ) { var elem= document.getElementById(name); if ( elem ) { elem.className= (bool) ? "checkbox_enabled" : "checkbox_disabled"; if ( callback ) { elem.addEventListener( "click", (function(elem, callback) { return function(e) { elem.__value= !elem.__value; elem.className= (elem.__value) ? "checkbox_enabled" : "checkbox_disabled"; callback(e,elem.__value); } })(elem, callback), false ); } elem.__value= bool; } } function setupTabs() { var numTabs=0; var elem; var elemContent; do { elem= document.getElementById("caat-debug-tab"+numTabs); if ( elem ) { elemContent= document.getElementById("caat-debug-tab"+numTabs+"-content"); if ( elemContent ) { elemContent.style.display= numTabs===0 ? \'block\' : \'none\'; elem.className= numTabs===0 ? "debug_tab debug_tab_selected" : "debug_tab debug_tab_not_selected"; elem.addEventListener( "click", (function(tabIndex) { return function(e) { for( var i=0; ithis.framerate.timeLastRefresh+this.framerate.refreshInterval){this.framerate.fps=this.framerate.frames* -1E3/(a.RAF-this.framerate.timeLastRefresh)|0;this.framerate.fpsMin=this.framerate.frames>0?Math.min(this.framerate.fpsMin,this.framerate.fps):this.framerate.fpsMin;this.framerate.fpsMax=Math.max(this.framerate.fpsMax,this.framerate.fps);this.textFPS.innerHTML=this.framerate.fps;var b=(this.frameTimeAcc*100/this.framerate.frames|0)/100;this.frameTimeAcc=0;this.textDrawTime.innerHTML=b;b=(this.frameRAFAcc*100/this.framerate.frames|0)/100;this.frameRAFAcc=0;this.textRAFTime.innerHTML=b;this.framerate.timeLastRefresh= -a.RAF;this.framerate.frames=0;this.paint(b)}this.textEntitiesTotal.innerHTML=this.statistics.size_total;this.textEntitiesActive.innerHTML=this.statistics.size_active;this.textDirtyRects.innerHTML=this.statistics.size_dirtyRects;this.textDraws.innerHTML=this.statistics.draws;this.textDiscardDR.innerHTML=this.statistics.size_discarded_by_dirty_rects},paint:function(a){var b=this.ctx,c=0;b.drawImage(this.canvas,1,0,this.width-1,this.height,0,0,this.width-1,this.height);b.strokeStyle="black";b.beginPath(); -b.moveTo(this.width-0.5,0);b.lineTo(this.width-0.5,this.height);b.stroke();b.strokeStyle="#a22";b.beginPath();c=this.height-(20/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();b.strokeStyle="#aa2";b.beginPath();c=this.height-(30/this.SCALE*this.height>>0)-0.5;b.moveTo(0.5,c);b.lineTo(this.width+0.5,c);b.stroke();c=Math.min(this.height-this.framerate.fps/this.SCALE*this.height,59);if(-1===this.framerate.prevFps)this.framerate.prevFps=c|0;b.strokeStyle="#0ff";b.beginPath(); -b.moveTo(this.width,(c|0)-0.5);b.lineTo(this.width,this.framerate.prevFps-0.5);b.stroke();this.framerate.prevFps=c;a=(this.height-a/this.SCALE*this.height>>0)-0.5;b.strokeStyle="#ff0";b.beginPath();b.moveTo(this.width,a);b.lineTo(this.width,a);b.stroke()}}}); -CAAT.Module({defines:"CAAT.Module.Font.Font",aliases:"CAAT.Font",depends:["CAAT.Foundation.SpriteImage"],constants:{getFontMetrics:function(a){var b;if(CAAT.CSS_TEXT_METRICS)try{return b=CAAT.Module.Font.Font.getFontMetricsCSS(a)}catch(c){}return CAAT.Module.Font.Font.getFontMetricsNoCSS(a)},getFontMetricsNoCSS:function(a){var a=/(\d+)p[x|t]/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;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){var e=this;this.id=a;this.path=c;this.image=new Image;this.image.onload=function(){d.__onload(e)};this.image.onerror=function(){d.__onerror(e)};this.load=function(){e.image.src=e.path};return this};return{__init:function(){this.elements=[];return this},elements:null,imageCounter:0,cfinished:null,cloaded:null,cerrored:null,loadedCount:0,addElement:function(b,c){this.elements.push(new a(b,c,this));return this}, -__onload:function(a){this.cloaded&&this.cloaded(a.id);this.loadedCount++;this.loadedCount===this.elements.length&&this.cfinished&&this.cfinished(this.elements)},__onerror:function(a){this.cerrored&&this.cerrored(a.id)},load:function(a,c,d){this.cfinished=a;this.cloaded=c;this.cerroed=d;for(a=0;a>=0;var d=true,e=true,f=true,g=true;if(typeof c!== -"undefined"){if(typeof c.top!=="undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,n=c.height-1,k=0,o=c.width-1,m=false;if(d){for(d=0;db){m=true;break}if(m)break}a=d}if(e){m=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){m=true;break}if(m)break}n=d}if(f){m=false;for(j=0;jb){m=true;break}if(m)break}k=j}if(g){m=false;for(j=c.width-1;j>=k;j--){for(d=a;d<=n;d++)if(i[d*c.width*4+3+j*4]>b){m=true;break}if(m)break}o=j}if(0===k&&0===a&&c.width-1===o&&c.height-1===n)return c;b=o-k+1;e=n-a+1;f=h.getImageData(k,a,b,e);c.width=b;c.height= -e;h=c.getContext("2d");h.putImageData(f,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}}); -CAAT.Module({defines:"CAAT.Module.Collision.QuadTree",depends:["CAAT.Math.Rectangle"],extendsClass:"CAAT.Math.Rectangle",extendsWith:function(){return{bgActors:null,quadData:null,create:function(a,b,c,d,e,f,g){typeof f==="undefined"&&(f=32);typeof g==="undefined"&&(g=1);var h=(a+c)/2,i=(b+d)/2;this.x=a;this.y=b;this.x1=c;this.y1=d;this.width=c-a;this.height=d-b;this.bgActors=this.__getOverlappingActorList(e);if(this.bgActors.length<=g||this.width<=f)return this;this.quadData=Array(4);this.quadData[0]= -(new CAAT.Module.Collision.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.Module.Collision.QuadTree).create(h,b,c,i,this.bgActors);this.quadData[2]=(new CAAT.Module.Collision.QuadTree).create(a,i,h,d,this.bgActors);this.quadData[3]=(new CAAT.Module.Collision.QuadTree).create(h,i,c,d,this.bgActors);return this},__getOverlappingActorList:function(a){for(var b=[],c=0,d=a.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ -a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; -for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;bb&&(g=b),setTimeout(function(){j(a,e,c)},g)):j(a,e,c)}};return g}function j(a,b,c){a.emptyScenes();a.setImagesCache(b);a.setClear(true);c(a);a.setClear(CAAT.Foundation.Director.CLEAR_ALL);a.easeIn(0,CAAT.Foundation.Scene.EASE_SCALE,2E3,false,CAAT.Foundation.Actor.ANCHOR_CENTER,(new CAAT.Behavior.Interpolator).createElasticOutInterpolator(2.5, -0.4))}var c=document.getElementById(c),n;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 k=document.createElement("canvas");c.appendChild(k);c=k}else false==c instanceof HTMLCanvasElement&&(k=document.createElement("canvas"),document.body.appendChild(k),c=k);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=i(n,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,length:-1,cw:true,bbox:null,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:false,setRadius:function(a){this.radius= -a;return this},isArcTo:function(){return this.arcTo},setArcTo:function(a){this.arcTo=a;return this},initialize:function(a,b,c,d){this.setInitialPosition(a,b);this.setFinalPosition(a+c,b);this.angle=d||2*Math.PI;return this},applyAsPath:function(a){a=a.ctx;this.arcTo?a.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):a.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.angle+this.startAngle,this.cw);return this},setPoint:function(a,b){b>=0&& -b1||a<0)a%=1;a<0&&(a=1+a);-1===this.length?this.newPosition.set(this.points[0].x,this.points[0].y):(a=this.angle*a*(this.cw?1:-1)+this.startAngle,this.newPosition.set(this.points[0].x+this.radius*Math.cos(a),this.points[0].y+this.radius*Math.sin(a)));return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save(); -c.strokeStyle=this.color;c.beginPath();this.arcTo?c.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):c.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.startAngle+this.angle,this.cw);c.stroke();if(b){c.globalAlpha=0.5;c.fillStyle="#7f7f00";for(var d=0;d1||a<0)a%=1;a<0&&(a=1+a);this.curve.solve(this.newPosition, -a);return this.newPosition},getPositionFromLength:function(a){this.curve.solve(this.newPosition,a/this.length);return this.newPosition},initialPositionX:function(){return this.curve.coordlist[0].x},finalPositionX:function(){return this.curve.coordlist[this.curve.coordlist.length-1].x},paint:function(a,b){this.curve.drawHandles=b;a.ctx.strokeStyle=this.color;this.curve.paint(a,b)},numControlPoints:function(){return this.curve.coordlist.length},getControlPoint:function(a){return this.curve.coordlist[a]}, -endCurvePosition:function(){return this.curve.endCurvePosition()},startCurvePosition:function(){return this.curve.startCurvePosition()},getContour:function(a){for(var b=[],c=0;c<=a;c++)b.push({x:c/a,y:this.getPosition(c/a).y});return b}}}}); -CAAT.Module({defines:"CAAT.PathUtil.LinearPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point"],aliases:["CAAT.LinearPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point(0,0,0);return this},points:null,newPosition:null,applyAsPath:function(a){a.ctx.lineTo(this.points[1].x,this.points[1].y)},setPoint:function(a, -b){b===0?this.points[0]=a:b===1&&(this.points[1]=a)},updatePath:function(){var a=this.points[1].x-this.points[0].x,b=this.points[1].y-this.points[0].y;this.length=Math.sqrt(a*a+b*b);this.bbox.setEmpty();this.bbox.union(this.points[0].x,this.points[0].y);this.bbox.union(this.points[1].x,this.points[1].y);return this},setPoints:function(a){this.points[0]=a[0];this.points[1]=a[1];this.updatePath();return this},setInitialPosition:function(a,b){this.points[0].x=a;this.points[0].y=b;this.newPosition.set(a, -b);return this},setFinalPosition:function(a,b){this.points[1].x=a;this.points[1].y=b;return this},endCurvePosition:function(){return this.points[1]},startCurvePosition:function(){return this.points[0]},getPosition:function(a){if(a>1||a<0)a%=1;a<0&&(a=1+a);this.newPosition.set(this.points[0].x+(this.points[1].x-this.points[0].x)*a,this.points[0].y+(this.points[1].y-this.points[0].y)*a);return this.newPosition},getPositionFromLength:function(a){return this.getPosition(a/this.length)},initialPositionX:function(){return this.points[0].x}, -finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save();c.strokeStyle=this.color;c.beginPath();c.moveTo(this.points[0].x,this.points[0].y);c.lineTo(this.points[1].x,this.points[1].y);c.stroke();if(b)c.globalAlpha=0.5,c.fillStyle="#7f7f00",c.beginPath(),this.drawHandle(c,this.points[0].x,this.points[0].y),this.drawHandle(c,this.points[1].x,this.points[1].y);c.restore()},numControlPoints:function(){return 2},getControlPoint:function(a){if(0===a)return this.points[0]; -else if(1===a)return this.points[1]},getContour:function(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); -CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; -return this},points:null,length:-1,cw:true,bbox:null,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&&b -1||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(;f1||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 a< -i?f=g:e=g+1;return this.endCurvePosition()},getPositionFromLength:function(a){a%=this.getLength();a<0&&(a+=this.getLength());for(var b=0,c=0;c0?this.pathSegmentStartTime[c]=this.pathSegmentStartTime[c-1]+this.pathSegmentDurationTime[c-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[c].endPath();this.extractPathPoints();b&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Math.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b=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},reset:function(a){this.remove=false;this.startTime=a;this.scene.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){a=(new CAAT.Foundation.Timer.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,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?d=Math.floor((b+c-1)/c):c=Math.floor((b+d-1)/d);for(var e=(d-1)*this.hgap,f=a.width- -(this.padding.left+this.padding.right),g=Math.floor((f-e)/d),h=(c-1)*this.vgap,i=a.height-(this.padding.top+this.padding.bottom),j=Math.floor((i-h)/c),h=Math.floor((i-(j*c+h))/2),i=0,e=this.padding.left+Math.floor((f-(g*d+e))/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 n=i+(d/h>>0)*f,k=g+e,o=n+f;g=(new CAAT.Foundation.SpriteImageHelper(g,n,k-g,o-n,j.width,j.height)).setGL(g/j.width,n/j.height,k/j.width,o/j.height);this.mapInfo[d]=g}}else for(d=0;d0&&(f-=d);var g=(this.offsetY-this.ownerActor.y)%e;g>0&&(g-=e);for(var d=((c.width-f)/d>>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx, -a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save(); -a.translate(c|0,d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex]; -a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a, -b,c,d,e,f,g){a.drawImage(this.image,d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex]; -return""+-(a.x+this.parentOffsetX-this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height- -this.offsetY)/f.height,f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV; -break;case b.TR_FLIP_ALL:this.paint=this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint=this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this}, -setSpriteIndex:function(a){this.spriteIndex=a;return this},setSpriteIndexAtTime:function(a){if(this.animationImageIndex.length>1){if(this.prevAnimationTime===-1)this.prevAnimationTime=a,this.spriteIndex=this.animationImageIndex[0],this.prevIndex=0;else{var b=a;b-=this.prevAnimationTime;b/=this.changeFPS;b%=this.animationImageIndex.length;b=Math.floor(b);b>0,f=0;fa&&(a=c)}this.fontHeight=a;return this.fontHeight*this.fontScale},drawText:function(a,b,c,d){var e,f,g;for(e=0;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, -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,collides:false,collidesAsRect:true,preventLayout:false,isAA:true,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},setupCollission:function(a,c){this.collides=a;this.collidesAsRect=!c},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/2,c-this.height/2);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);this.visible=a;return this},setOutOfFrameTime:function(){this.setFrameTime(-1,0);return this},addListener:function(a){this.lifecycleListenerList.push(a);return this},removeListener:function(a){for(var c= -this.lifecycleListenerList.length;c--;)if(this.lifecycleListenerList[c]===a){this.lifecycleListenerList.splice(c,1);break}},setGlobalAlpha:function(a){this.isGlobalAlpha=a;return this},fireEvent:function(a,c){for(var d=0;d=this.start_time+this.duration?(this.expired||this.setExpired(a),false):this.start_time<=a&&a=0&&c>=0&&af)f=d.x;if(d.yh)h=d.y;d=c[1];if(d.xf)f=d.x;if(d.yh)h=d.y;d=c[2];if(d.xf)f=d.x;if(d.yh)h=d.y;d=c[3];if(d.xf)f=d.x;if(d.yh)h=d.y;a.x=e;a.y=g;a.x1=f;a.y1=h;a.width=f-e;a.height=h-g;return this},paintActor:function(a,c){if(!this.visible||!a.inDirtyRect(this))return true;var d=a.ctx;this.frameAlpha=this.parent?this.parent.frameAlpha*this.alpha:1;d.globalAlpha=this.frameAlpha;a.modelViewMatrix.transformRenderingContextSet(d); -this.worldModelViewMatrix.transformRenderingContext(d);this.clip&&(d.beginPath(),this.clipPath?this.clipPath.applyAsPath(a):d.rect(0,0,this.width,this.height),d.clip());this.paint(a,c);return true},__paintActor:function(a,c){if(!this.visible)return true;var d=a.ctx;this.frameAlpha=this.alpha;var e=this.worldModelViewMatrix.matrix;d.setTransform(e[0],e[3],e[1],e[4],e[2],e[5],this.frameAlpha);this.paint(a,c);return true},paintActorGL:function(a){this.frameAlpha=this.parent.frameAlpha*this.alpha;if(this.glEnabled&& -this.visible)if(this.glNeedsFlush(a)){a.glFlush();this.glSetShader(a);if(!this.__uv)this.__uv=new Float32Array(8);if(!this.__vv)this.__vv=new Float32Array(12);this.setGLCoords(this.__vv,0);this.setUV(this.__uv,0);a.glRender(this.__vv,12,this.__uv)}else{var c=a.coordsIndex;this.setGLCoords(a.coords,c);a.coordsIndex=c+12;this.setUV(a.uv,a.uvIndex);a.uvIndex+=8}},setGLCoords:function(a,c){var d=this.viewVertices;a[c++]=d[0].x;a[c++]=d[0].y;a[c++]=0;a[c++]=d[1].x;a[c++]=d[1].y;a[c++]=0;a[c++]=d[2].x; -a[c++]=d[2].y;a[c++]=0;a[c++]=d[3].x;a[c++]=d[3].y;a[c]=0},setUV:function(a,c){this.backgroundImage.setUV(a,c)},glNeedsFlush:function(a){return this.getTextureGLPage()!==a.currentTexturePage?true:this.frameAlpha!==a.currentOpacity?true:false},glSetShader:function(a){var c=this.getTextureGLPage();c!==a.currentTexturePage&&a.setGLTexturePage(c);this.frameAlpha!==a.currentOpacity&&a.setGLCurrentOpacity(this.frameAlpha)},endAnimate:function(){return this},initialize:function(a){if(a)for(var c in a)this[c]= -a[c];return this},setClip:function(a,c){this.clip=a;this.clipPath=c;return this},isCached:function(){return this.cached},stopCacheAsBitmap:function(){if(this.cached)this.backgroundImage=null,this.cached=CAAT.Foundation.Actor.CACHE_NONE},cacheAsBitmap:function(a,c){if(this.width<=0||this.height<=0)return this;var a=a||0,d=document.createElement("canvas");d.width=this.width;d.height=this.height;var e=d.getContext("2d");CAAT.Foundation.Actor.prototype.animate.call(this,CAAT.currentDirector,a);var e= -{ctx:e,modelViewMatrix:new CAAT.Math.Matrix,worldModelViewMatrix:new CAAT.Math.Matrix,dirtyRectsEnabled:false,inDirtyRect:function(){return true},AABB:new CAAT.Math.Rectangle(0,0,this.width,this.height)},f=this.modelViewMatrix,g=this.worldModelViewMatrix;this.modelViewMatrix=new CAAT.Math.Matrix;this.worldModelViewMatrix=new CAAT.Math.Matrix;this.cached=CAAT.Foundation.Actor.CACHE_NONE;if(typeof c==="undefined")c=CAAT.Foundation.Actor.CACHE_SIMPLE;c===CAAT.Foundation.Actor.CACHE_DEEP?(this.animate(e, -a),this.paintActor(e,a)):this instanceof CAAT.Foundation.ActorContainer||this instanceof CAAT.ActorContainer?CAAT.Foundation.ActorContainer.superclass.paintActor.call(this,e,a):(this.animate(e,a),this.paintActor(e,a));this.setBackgroundImage(d);this.cached=c;this.modelViewMatrix=f;this.worldModelViewMatrix=g;return this},resetAsButton:function(){this.actionPerformed=null;this.mouseEnter=function(){};this.mouseExit=function(){};this.mouseDown=function(){};this.mouseUp=function(){};this.mouseClick= -function(){};this.mouseDrag=function(){};return this},setAsButton:function(a,c,d,e,f,g){this.setBackgroundImage(a,true);this.iNormal=c||0;this.iOver=d||this.iNormal;this.iPress=e||this.iNormal;this.iDisabled=f||this.iNormal;this.fnOnClick=g;this.enabled=true;this.setSpriteIndex(c);this.setEnabled=function(a){this.enabled=a;this.setSpriteIndex(this.enabled?this.iNormal:this.iDisabled);return this};this.actionPerformed=function(){this.enabled&&this.fnOnClick&&this.fnOnClick(this)};this.mouseEnter=function(){this.enabled&& -(this.dragging?this.setSpriteIndex(this.iPress):this.setSpriteIndex(this.iOver),CAAT.setCursor("pointer"))};this.mouseExit=function(){this.enabled&&(this.setSpriteIndex(this.iNormal),CAAT.setCursor("default"))};this.mouseDown=function(){this.enabled&&this.setSpriteIndex(this.iPress)};this.mouseUp=function(){if(this.enabled)this.setSpriteIndex(this.iNormal),this.dragging=false};this.mouseClick=function(){};this.mouseDrag=function(){if(this.enabled)this.dragging=true};this.setButtonImageIndex=function(a, -b,c,d){this.iNormal=a||0;this.iOver=b||this.iNormal;this.iPress=c||this.iNormal;this.iDisabled=d||this.iNormal;this.setSpriteIndex(this.iNormal);return this};return this},findActorById:function(a){return this.id===a?this:null}}}}); -CAAT.Module({defines:"CAAT.Foundation.ActorContainer",aliases:["CAAT.ActorContainer"],depends:["CAAT.Foundation.Actor","CAAT.Math.Point","CAAT.Math.Rectangle"],constants:{AddHint:{CONFORM:1}},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){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)},createAlphaBehaviour:function(a,b){var c=new CAAT.Behavior.AlphaBehavior;c.setFrameTime(0,a);c.startAlpha=b?0:1;c.endAlpha=b?1:0;this.easeContainerBehaviour.addBehavior(c)}, -easeTranslationIn:function(a,b,c,d){this.easeTranslation(a,b,c,true,d)},easeTranslationOut:function(a,b,c,d){this.easeTranslation(a,b,c,false,d)},easeTranslation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;this.easeIn=d;var f=new CAAT.Behavior.PathBehavior;e&&f.setInterpolator(e);f.setFrameTime(0,a);c<1?c=1:c>4&&(c=4);switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(0,-this.height+1,0,0)),this.setPosition(0,-this.height+ -1)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,0,-this.height+1)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_BOTTOM:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(0,this.height-1,0,0)),this.setPosition(0,this.height-1)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,0,this.height-1)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_LEFT:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(-this.width+1,0,0,0)),this.setPosition(-this.width+1,0)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0, -0,-this.width+1,0)),this.setPosition(0,0));break;case CAAT.Foundation.Actor.ANCHOR_RIGHT:d?(f.setPath((new CAAT.PathUtil.Path).setLinear(this.width-1,0,0,0)),this.setPosition(this.width-1,0)):(f.setPath((new CAAT.PathUtil.Path).setLinear(0,0,this.width-1,0)),this.setPosition(0,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this, -this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn=false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:case CAAT.Foundation.Actor.ANCHOR_CENTER:j= -i=1;break;case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:j=h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var n;n=g;g=i;i=n;n=h;h=j;j=n}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.Behavior.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time, -b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this},easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var f=0,g=0;if(c==CAAT.Foundation.Actor.ANCHOR_CENTER)c= -CAAT.Foundation.Actor.ANCHOR_TOP;switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:f=Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false=== -d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,d);b=this.getAnchorPercent(c);f=(new CAAT.Behavior.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a}, -behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a},paint:function(a){if(this.fillStyle)a=a.ctx,a.fillStyle=this.fillStyle,a.fillRect(0,0,this.width,this.height)},findActorAtPosition:function(a){var b,c,d=new CAAT.Math.Point;if(this.inputList){var e=this.inputList;for(b=0;b=this.inputList.length&&(b=this.inputList.length-1);b=this.inputList[b];typeof c==="undefined"||c>=b.length?b.push(a):c<=0?b.unshift(a):b.splice(c,0,a);return this},emptyInputList:function(a){a<0?a=0:a>=this.inputList.length&&(a=this.inputList.length- -1);this.inputList[a]=[];return this},removeActorFromInputList:function(a,b){if(typeof b==="undefined"){var c,d;for(c=0;c=this.inputList.length&&(b=this.inputList.length-1);e=this.inputList[b];for(d=0;d=0;b--){var c=this.childrenList[b],d=new CAAT.Math.Point(a.x,a.y,0),c=c.findActorAtPosition(d);if(null!==c)return c}return this},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0;this.statistics.size_discarded_by_dirty_rects=0},render:function(a){if(!this.currentScene||!this.currentScene.isPaused()){this.time+=a;for(e=0,l=this.childrenList.length;e0&&!navigator.isCocoonJS&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;b=this.cDirtyRects; -for(e=0;e=this.dirtyRects.length)for(b= -0;b<32;b++)this.dirtyRects.push(new CAAT.Math.Rectangle);b=this.dirtyRects[this.dirtyRectsIndex];b.x=a.x;b.y=a.y;b.x1=a.x1;b.y1=a.y1;b.width=a.width;b.height=a.height;this.cDirtyRects.push(b)}},renderToContext:function(a,b){if(b.isInAnimationFrame(this.time)){a.setTransform(1,0,0,1,0,0);a.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);var c=this.ctx;this.ctx=a;a.save();var d=this.modelViewMatrix,e=this.worldModelViewMatrix;this.modelViewMatrix=this.worldModelViewMatrix= -new CAAT.Math.Matrix;this.wdirty=true;b.animate(this,b.time);if(b.onRenderStart)b.onRenderStart(b.time);b.paintActor(this,b.time);if(b.onRenderEnd)b.onRenderEnd(b.time);this.worldModelViewMatrix=e;this.modelViewMatrix=d;a.restore();this.ctx=c}},addScene:function(a){a.setBounds(0,0,this.width,this.height);this.scenes.push(a);a.setEaseListener(this);null===this.currentScene&&this.setScene(0)},getNumScenes:function(){return this.scenes.length},easeInOut:function(a,b,c,d,e,f,g,h,i,j){if(a!==this.getCurrentSceneIndex()){a= -this.scenes[a];d=this.scenes[d];if(!CAAT.__CSS__&&!this.glEnabled)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=a.changedTouches[0],this.getCanvasCoord(this.mousePoint,a),this.touching=false,this.__mouseUpHandler(a)},__touchMoveHandler:function(a){if(this.touching&&(a.preventDefault(),!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){c.target===a&&(c.preventDefault(),b.__gestureStart(c.scale,c.rotation))},false),a.addEventListener("gestureend",function(c){c.target===a&&(c.preventDefault(),b.__gestureEnd(c.scale,c.rotation))},false),a.addEventListener("gesturechange",function(c){c.target===a&&(c.preventDefault(),b.__gestureChange(c.scale,c.rotation))},false)):CAAT.TOUCH_BEHAVIOR===CAAT.TOUCH_AS_MULTITOUCH&&(a.addEventListener("touchstart",this.__touchStartHandlerMT.bind(this),false),a.addEventListener("touchmove",this.__touchMoveHandlerMT.bind(this), -false),a.addEventListener("touchend",this.__touchEndHandlerMT.bind(this),false),a.addEventListener("touchcancel",this.__touchCancelHandleMT.bind(this),false),a.addEventListener("gesturestart",this.__touchGestureStartHandleMT.bind(this),false),a.addEventListener("gestureend",this.__touchGestureEndHandleMT.bind(this),false),a.addEventListener("gesturechange",this.__touchGestureChangeHandleMT.bind(this),false))},enableEvents:function(a){CAAT.RegisterDirector(this);this.in_=false;this.createEventHandler(a)}, -createEventHandler:function(a){this.in_=false;this.addHandlers(a)}}},onCreate:function(){if(typeof CAAT.__CSS__!=="undefined")CAAT.Foundation.Director.prototype.clip=true,CAAT.Foundation.Director.prototype.glEnabled=false,CAAT.Foundation.Director.prototype.getRenderType=function(){return"CSS"},CAAT.Foundation.Director.prototype.setScaleProportional=function(a,b){var c=Math.min(a/this.referenceWidth,b/this.referenceHeight);this.setScaleAnchored(c,c,0,0);this.eventHandler.style.width=""+this.referenceWidth+ -"px";this.eventHandler.style.height=""+this.referenceHeight+"px"},CAAT.Foundation.Director.prototype.setBounds=function(a,b,c,d){CAAT.Foundation.Director.superclass.setBounds.call(this,a,b,c,d);for(a=0;ad+this.range?this.minSize:a===d?this.maxSize:a>0)+1)*b},setFillStyle:function(a){this.fill=a},setStrokeStyle:function(a){this.stroke=a},setStrokeSize:function(a){this.strokeSize= -a},setAlignment:function(a){this.alignment=a},setFontSize:function(a){if(a!==this.fontSize)this.fontSize=a,this.__setFont()}};var b=function(){this.text="";return this};b.prototype={x:0,y:0,width:0,text:null,crcs:null,rcs:null,styles:null,images:null,lines:null,documentHeight:0,anchorStack:null,__nextLine:function(){this.x=0;this.currentLine=new f;this.lines.push(this.currentLine)},__image:function(a,b,c){var e;e=b&&c?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 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,k){d.superclass.constructor.call(this,k,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=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.singleHeight: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(){this.elements=[];return this};f.prototype={elements:null,width:0,height: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:0,b?b.getHeight():0);this.height=this.baselinePos+(a!=null?a.descent:0);for(c=0;c",d+1),-1!==o&&(m=f.substr(d+1,o-d-1),m.indexOf("<")!==-1?(this.rc.fchar(q),d+=1):(this.rc.setTag(m),d=o+1))):(this.rc.fchar(q),d+=1);this.rc.end(); -this.lines=this.rc.lines;this.__calculateDocumentDimension(typeof b==="undefined"?0:b);this.setLinesAlignment();p.restore();this.setPreferredSize(this.documentWidth,this.documentHeight);this.invalidateLayout();this.setDocumentPosition();c&&this.cacheAsBitmap(0,c);return this}},setVerticalAlignment:function(a){this.valignment=a;this.setDocumentPosition();return this},setHorizontalAlignment:function(a){this.halignment=a;this.setDocumentPosition();return this},setDocumentPosition:function(){var a=0, -b=0;this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?b=(this.height-this.documentHeight)/2:this.valignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.BOTTOM&&(b=this.height-this.documentHeight);this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.CENTER?a=(this.width-this.documentWidth)/2:this.halignment===CAAT.Foundation.UI.Layout.LayoutManager.ALIGNMENT.RIGHT&&(a=this.width-this.documentWidth);this.documentX=a;this.documentY=b},__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,showBBox:false,getPath:function(){return this.path},setPath:function(a){this.path=a;if(a!=null)this.pathBoundingRectangle=a.getBoundingBox(),this.setInteractive(this.interactive);return this},paint:function(a,b){CAAT.Foundation.UI.PathActor.superclass.paint.call(this, -a,b);if(this.path){var c=a.ctx;c.strokeStyle="#000";this.path.paint(a,this.interactive);if(this.bOutline)c.strokeStyle=this.outlineColor,c.strokeRect(this.pathBoundingRectangle.x,this.pathBoundingRectangle.y,this.pathBoundingRectangle.width,this.pathBoundingRectangle.height)}},showBoundingBox:function(a,b){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= -a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); -CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= -a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= -a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ -2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, -this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); -CAAT.Module({defines:"CAAT.Foundation.UI.StarActor",aliases:["CAAT.StarActor"],depends:["CAAT.Foundation.ActorContainer"],extendsClass:"CAAT.Foundation.ActorContainer",extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";return this},nPeaks:0,maxRadius:0,minRadius:0,initialAngle:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap=a;return this},setLineJoin:function(a){this.lineJoin= -a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setFilled:function(){return this},setOutlined:function(){return this},setCompositeOp:function(a){this.compositeOp=a;return this},setInitialAngle:function(a){this.initialAngle=a;return this},initialize:function(a,b,c){this.setSize(2*b,2*b);this.nPeaks= -a;this.maxRadius=b;this.minRadius=c;return this},paint:function(a){var a=a.ctx,b=this.width/2,c=this.height/2,d=this.maxRadius,e=this.minRadius,f=b+d*Math.cos(this.initialAngle),g=c+d*Math.sin(this.initialAngle);a.lineWidth=this.lineWidth;if(this.lineCap)a.lineCap=this.lineCap;if(this.lineJoin)a.lineJoin=this.lineJoin;if(this.miterLimit)a.miterLimit=this.miterLimit;a.globalCompositeOperation=this.compositeOp;a.beginPath();a.moveTo(f,g);for(f=1;f>0,e.y>>0);c.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 * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. * - * @constructor + * */ __init:function () { this.lifecycleListenerList = []; @@ -3764,6 +3772,7 @@ CAAT.Module({ discardable:false, // is true, this behavior will be removed from the this.actor instance when it expires. + /* @memberOf CAAT.Behavior.BaseBehavior */ setValueApplication:function (apply) { this.doValueApplication = apply; return this; @@ -12871,8 +12880,16 @@ CAAT.Module( { doLayout : function( container ) { - var nactors= container.getNumChildren(); - if (nactors === 0) { + var actors= []; + for( var i=0; i * Other Behaviors simply must supply with the method setForTime(time, actor) overriden. * - * @constructor + * */ __init:function () { this.lifecycleListenerList = []; @@ -98,6 +106,7 @@ CAAT.Module({ discardable:false, // is true, this behavior will be removed from the this.actor instance when it expires. + /* @memberOf CAAT.Behavior.BaseBehavior */ setValueApplication:function (apply) { this.doValueApplication = apply; return this; diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index b62e12d8..f122b44b 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -630,7 +630,9 @@ CAAT.Module({ * @return this */ centerAt:function (x, y) { - this.setPosition(x - this.width / 2, y - this.height / 2); + this.setPosition( + x - this.width * (.5 - this.tAnchorX ), + y - this.height * (.5 - this.tAnchorY ) ); return this; }, /** diff --git a/src/Foundation/ActorContainer.js b/src/Foundation/ActorContainer.js index bbda20a3..17a9907a 100644 --- a/src/Foundation/ActorContainer.js +++ b/src/Foundation/ActorContainer.js @@ -109,7 +109,7 @@ CAAT.Module({ return; } - var cl = this.childrenList; + var cl = this.activeChildren; for (var i = 0; i < cl.length; i++) { cl[i].drawScreenBoundingBox(director, time); } diff --git a/src/Foundation/Box2D/B2DBodyActor.js b/src/Foundation/Box2D/B2DBodyActor.js index 120dcadc..eaec1e52 100644 --- a/src/Foundation/Box2D/B2DBodyActor.js +++ b/src/Foundation/Box2D/B2DBodyActor.js @@ -8,6 +8,7 @@ CAAT.Module({ extendsWith:function () { CAAT.PMR = 64; + /** * As Eemeli Kelokorpi suggested, * @param set @@ -79,6 +80,25 @@ CAAT.Module({ recycle:false, + __init : function() { + this.__super(); + this.setPositionAnchor(.5,.5); + + return this; + }, + + setPositionAnchor : function( ax, ay ) { + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + + setPositionAnchored : function(x,y,ax,ay) { + this.x= x; + this.y= y; + this.tAnchorX= .5; + this.tAnchorY= .5; + }, + /** * set this actor to recycle its body, that is, do not destroy it. */ @@ -111,8 +131,8 @@ CAAT.Module({ setLocation:function (x, y) { this.worldBody.SetPosition( new Box2D.Common.Math.b2Vec2( - (x + this.width / 2) / CAAT.PMR, - (y + this.height / 2) / CAAT.PMR)); + x / CAAT.PMR, + y / CAAT.PMR)); return this; }, /** @@ -218,18 +238,10 @@ CAAT.Module({ var pos= this.worldBody.GetPosition(); - if (this.bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x, - CAAT.PMR*pos.y ); - - } else { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x - this.width/2, - CAAT.PMR*pos.y - this.height/2 ); - } + CAAT.Foundation.Actor.prototype.setLocation.call( + this, + CAAT.PMR*pos.x, + CAAT.PMR*pos.y); this.setRotation( this.worldBody.GetAngle() ); diff --git a/src/Foundation/Director.js b/src/Foundation/Director.js index ffe5ebaf..ef0fe050 100644 --- a/src/Foundation/Director.js +++ b/src/Foundation/Director.js @@ -201,8 +201,7 @@ CAAT.Module({ }, createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { - this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel); - return this; + return this.timerManager.createTimer(startTime, duration, callback_timeout, callback_tick, callback_cancel); }, requestRepaint:function () { diff --git a/src/Foundation/Scene.js b/src/Foundation/Scene.js index 06bfdf6b..4862c4b3 100644 --- a/src/Foundation/Scene.js +++ b/src/Foundation/Scene.js @@ -71,7 +71,7 @@ CAAT.Module({ // }, /** * Helper method to manage alpha transparency fading on Scene switch by the Director. - * @param time {number} time in milliseconds the fading will take. + * @param time {number} time in milliseconds then fading will taableIne. * @param isIn {boolean} whether this Scene is being brought in. * * @private diff --git a/src/Foundation/UI/Layout/GridLayout.js b/src/Foundation/UI/Layout/GridLayout.js index 72ca0c48..e2a7fad2 100644 --- a/src/Foundation/UI/Layout/GridLayout.js +++ b/src/Foundation/UI/Layout/GridLayout.js @@ -21,8 +21,16 @@ CAAT.Module( { doLayout : function( container ) { - var nactors= container.getNumChildren(); - if (nactors === 0) { + var actors= []; + for( var i=0; i "${FILE_CAAT}" echo "" > "${FILE_CAAT_CSS}" echo "" > "${FILE_CAAT_BOX2D}" -SOURCE_DIR=/Users/ibon/js/CAAT/src - # # set compilation level # @@ -89,7 +91,7 @@ echo -e "*/\n\n" >> "${FILE_CAAT_BOX2D}" # Compile canvas/GL # echo -e "\nCreating CAAT canvas/webGL" -/usr/bin/java -jar /Users/ibon/applications/closure/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \ +/usr/bin/java -jar ${COMPILER_JAR} --compilation_level "${COMPILATION_LEVEL}" \ --js build/caat.js \ >> "${FILE_CAAT}" @@ -97,14 +99,14 @@ echo -e "\nCreating CAAT canvas/webGL" # Compile box2d # echo "Creating CAAT Box2d" - /usr/bin/java -jar /Users/ibon/applications/closure/compiler.jar --compilation_level "${COMPILATION_LEVEL}" --js build/caat-box2d.js >> "${FILE_CAAT_BOX2D}" + /usr/bin/java -jar ${COMPILER_JAR} --compilation_level "${COMPILATION_LEVEL}" --js build/caat-box2d.js >> "${FILE_CAAT_BOX2D}" # # Compile css # echo "Creating CAAT CSS" echo -e "CAAT.__CSS__=1;" >> /tmp/__css.js -java -jar /Users/ibon/applications/closure/compiler.jar --compilation_level "${COMPILATION_LEVEL}" \ +java -jar ${COMPILER_JAR} --compilation_level "${COMPILATION_LEVEL}" \ --js build/caat-css.js >> "${FILE_CAAT_CSS}" # @@ -123,5 +125,5 @@ done < version.distribution # # Generating JSDoc. # -echo -e "\nGenerating JSDoc" -./version.compile.doc.sh +#echo -e "\nGenerating JSDoc" +#./version.compile.doc.sh diff --git a/version.distribution b/version.distribution index ed2d0c4c..6f65c48b 100644 --- a/version.distribution +++ b/version.distribution @@ -1 +1 @@ -/Users/ibon/js/CAAT/build +./build diff --git a/version.incremental b/version.incremental index abac1ea7..c3f407c0 100644 --- a/version.incremental +++ b/version.incremental @@ -1 +1 @@ -47 +55 diff --git a/version.nfo b/version.nfo index 5efd58e2..b4974f17 100644 --- a/version.nfo +++ b/version.nfo @@ -1 +1 @@ -0.5 build: 47 +0.5 build: 55 diff --git a/version.sh b/version.sh index 483ac19d..8d21b88d 100755 --- a/version.sh +++ b/version.sh @@ -7,6 +7,7 @@ VERSION_MAJOR=`echo $VERSION_INFO | cut -d "." -f 1` VERSION_MINOR=`echo $VERSION_INFO | cut -d "." -f 2 | cut -d " " -f 1` VERSION_INCREMENTAL=`cat "$FILE_INCREMENTAL"` let VERSION_INCREMENTAL++; +VERSION_INCREMENTAL="55" echo $VERSION_INCREMENTAL > $FILE_INCREMENTAL echo "$VERSION_MAJOR.$VERSION_MINOR build: $VERSION_INCREMENTAL" > $FILE From 3f7227f6822efee712fd700eb1fc253488d735f4 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sun, 3 Feb 2013 14:41:40 +0100 Subject: [PATCH 03/11] Fixed setLocation on BodyActor so that it sets x and y properly --- src/Foundation/Box2D/B2DBodyActor.js | 45 ++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/src/Foundation/Box2D/B2DBodyActor.js b/src/Foundation/Box2D/B2DBodyActor.js index eaec1e52..7ff68a37 100644 --- a/src/Foundation/Box2D/B2DBodyActor.js +++ b/src/Foundation/Box2D/B2DBodyActor.js @@ -87,18 +87,6 @@ CAAT.Module({ return this; }, - setPositionAnchor : function( ax, ay ) { - this.tAnchorX= .5; - this.tAnchorY= .5; - }, - - setPositionAnchored : function(x,y,ax,ay) { - this.x= x; - this.y= y; - this.tAnchorX= .5; - this.tAnchorY= .5; - }, - /** * set this actor to recycle its body, that is, do not destroy it. */ @@ -128,13 +116,46 @@ CAAT.Module({ this.worldBody.SetSleepingAllowed(bool); return this; }, + /** + * This method sets the position of an Actor inside its parent. + * + * @param x{number} a float indicating Actor's x position + * @param y{number} a float indicating Actor's y position + * @return this + * + * @deprecated + */ setLocation:function (x, y) { + this.x = x; + this.y = y; + this.oldX = x; + this.oldY = y; + + this.dirty = true; this.worldBody.SetPosition( new Box2D.Common.Math.b2Vec2( x / CAAT.PMR, y / CAAT.PMR)); return this; }, + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + /** * Set this body's * density. From 7b058234c3815d75f140189f7ea509063354deeb Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sun, 3 Feb 2013 16:43:22 +0100 Subject: [PATCH 04/11] Forgot to cleanup --- src/Foundation/Box2D/B2DBodyActor.js | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Foundation/Box2D/B2DBodyActor.js b/src/Foundation/Box2D/B2DBodyActor.js index 054e10c5..f4bfa015 100644 --- a/src/Foundation/Box2D/B2DBodyActor.js +++ b/src/Foundation/Box2D/B2DBodyActor.js @@ -134,10 +134,9 @@ CAAT.Module({ this.dirty = true; this.worldBody.SetPosition( new Box2D.Common.Math.b2Vec2( - (x + this.width / 2) / CAAT.PMR, - (y + this.height / 2) / CAAT.PMR)); -// x / CAAT.PMR, -// y / CAAT.PMR)); + x / CAAT.PMR, + y / CAAT.PMR)); + return this; }, @@ -260,19 +259,7 @@ CAAT.Module({ animate: function(director, time) { var pos= this.worldBody.GetPosition(); -/* - if (this.bodyData.polygonType === CAAT.Foundation.Box2D.B2DPolygonBody.TYPE.EDGE) { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x, - CAAT.PMR*pos.y ); - } else { - CAAT.Foundation.Actor.prototype.setLocation.call( - this, - CAAT.PMR*pos.x - this.width/2, - CAAT.PMR*pos.y - this.height/2 ); - } -*/ + CAAT.Foundation.Actor.prototype.setLocation.call( this, CAAT.PMR*pos.x, From 6644e6239c2dfa40250e260893a8e3d056fc13c1 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Mon, 27 May 2013 00:43:43 +0200 Subject: [PATCH 05/11] Fixed sprite image index copy in getRef() --- src/Foundation/SpriteImage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Foundation/SpriteImage.js b/src/Foundation/SpriteImage.js index 97ab7055..5a0dc528 100644 --- a/src/Foundation/SpriteImage.js +++ b/src/Foundation/SpriteImage.js @@ -283,6 +283,8 @@ CAAT.Module({ ret.scaleFont= this.scaleFont; + ret.spriteIndex= this.spriteIndex; + return ret; }, /** From bb4cfc41d2042dc6c986db26ac0a997e7f0dfa45 Mon Sep 17 00:00:00 2001 From: rehan Date: Mon, 15 Jul 2013 16:13:58 +0530 Subject: [PATCH 06/11] fixed removeBehaviour. added decrement and condition to loop. renamed for consistency --- src/Foundation/Actor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index 70d052c7..5a47ed7d 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -1451,14 +1451,15 @@ CAAT.Module({ * * @param behavior {CAAT.Behavior.BaseBehavior} */ - removeBehaviour:function (behavior) { + removeBehavior:function (behavior) { var c = this.behaviorList; var n = c.length - 1; - while (n) { + while (n >= 0) { if (c[n] === behavior) { c.splice(n, 1); return this; } + n = n - 1; } return this; }, From 0e38b192c47237ef64657a646c7862dd0c869c75 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sat, 24 Aug 2013 17:14:02 +0200 Subject: [PATCH 07/11] removeBehaviour no longer loops forever. also renamed to be consistent (u removed) deprecated old function --- src/Foundation/Actor.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index a60ac270..cda4acce 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -1461,15 +1461,26 @@ CAAT.Module({ * If the Behavior is not present at the actor behavior collection nothing happends. * * @param behavior {CAAT.Behavior.BaseBehavior} + * @deprecated */ removeBehaviour:function (behavior) { + this.removeBehavior(behavior); + }, + /** + * Remove a Behavior from the Actor. + * If the Behavior is not present at the actor behavior collection nothing happends. + * + * @param behavior {CAAT.Behavior.BaseBehavior} + */ + removeBehavior:function (behavior) { var c = this.behaviorList; var n = c.length - 1; - while (n) { + while (n >= 0) { if (c[n] === behavior) { c.splice(n, 1); return this; } + n = n - 1; } return this; }, From 682cc0cefac1f2066b049ffe020f9ebe814853fa Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Sun, 25 Aug 2013 14:06:29 +0200 Subject: [PATCH 08/11] Fixed Ibon's scripts so that we can compile CAAT Compiled CAAT with our patches --- build/caat-box2d-min.js | 25 +- build/caat-box2d.js | 52 +- build/caat-css-min.js | 900 +++++++++++++++++---------------- build/caat-css.js | 702 +++++--------------------- build/caat-min.js | 939 +++++++++++++++++------------------ build/caat.js | 203 +++++--- version.compile.pack.sh | 60 +-- version.compile.sh | 58 +-- version.compile.variables.sh | 2 +- 9 files changed, 1289 insertions(+), 1652 deletions(-) diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index bfa904a8..609922d5 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -25,21 +25,22 @@ THE SOFTWARE. Version: 0.6 build: 6 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-08-25 +TIME: 14:03:51 */ 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; +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},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 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.x=b;this.y=a;this.oldX=b;this.oldY=a;this.dirty=!0;this.worldBody.SetPosition(new Box2D.Common.Math.b2Vec2(b/CAAT.PMR,a/CAAT.PMR));return this},setPosition:function(b,a){return this.setLocation(b,a)},setPositionAnchor:function(b,a){this.tAnchorX=b;this.tAnchorY=a;return this},setPositionAnchored:function(b, +a,c,d){this.setLocation(b,a);this.tAnchorX=c;this.tAnchorY=d;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){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){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(!0);return{worldBody:g,worldBodyFixture:h,fixDef:c,bodyDef:d}}},extendsWith:{radius:1,createBody:function(b,a){var c=a.radius||1,c=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; +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;for(var d=Number.MAX_VALUE,g=-Number.MAX_VALUE,h=Number.MAX_VALUE,j=-Number.MAX_VALUE, +e=[],i=a.bodyDefScale||1,i=i+(a.bodyDefScaleTolerance||0)*Math.random(),f=0;fg&&(g=k);lj&&(j=l);e.push(new Box2D.Common.Math.b2Vec2(k/CAAT.PMR,l/CAAT.PMR))}i=[{x:d,y:h},{x:g,y:j}];f=new Box2D.Dynamics.b2BodyDef;f.type=a.bodyType;f.position.Set(((g-d)/2+(a.x||0))/CAAT.PMR,((j-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,(j-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(!0);return{worldBody:e,worldBodyFixture:d,fixDef:c,bodyDef:f,boundingBox:i}}},extendsClass:"CAAT.Foundation.Box2D.B2DBodyActor",extendsWith:{boundingBox:null,getDistanceJointLocalAnchor:function(){return this.worldBody.GetFixtureList().GetShape().GetLocalCenter()},createBody:function(b,a){CAAT.Foundation.Box2D.B2DPolygonBody.superclass.createBody.call(this,b,a);var c=CAAT.Foundation.Box2D.B2DPolygonBody.createPolygonBody(b,a);a.userData.actor=this;this.worldBody=c.worldBody; this.worldBodyFixture=c.worldBodyFixture;this.fixtureDef=c.fixDef;this.bodyDef=c.bodyDef;this.bodyData=a;this.boundingBox=c.boundingBox;this.setBackgroundImage(a.image).setSize(c.boundingBox[1].x-c.boundingBox[0].x+1,c.boundingBox[1].y-c.boundingBox[0].y+1).setFillStyle(c.worldBodyFixture.IsSensor()?"#0f0":"#f00").setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE);return this}}});CAAT.ModuleManager.solveAll(); diff --git a/build/caat-box2d.js b/build/caat-box2d.js index 420e2272..b4f2b392 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: 6 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-08-25 +TIME: 14:03:51 */ @@ -163,18 +163,6 @@ CAAT.Module({ return this; }, - setPositionAnchor : function( ax, ay ) { - this.tAnchorX= .5; - this.tAnchorY= .5; - }, - - setPositionAnchored : function(x,y,ax,ay) { - this.x= x; - this.y= y; - this.tAnchorX= .5; - this.tAnchorY= .5; - }, - /** * set this actor to recycle its body, that is, do not destroy it. */ @@ -204,13 +192,47 @@ CAAT.Module({ this.worldBody.SetSleepingAllowed(bool); return this; }, + /** + * This method sets the position of an Actor inside its parent. + * + * @param x{number} a float indicating Actor's x position + * @param y{number} a float indicating Actor's y position + * @return this + * + * @deprecated + */ setLocation:function (x, y) { + this.x = x; + this.y = y; + this.oldX = x; + this.oldY = y; + + this.dirty = true; this.worldBody.SetPosition( new Box2D.Common.Math.b2Vec2( x / CAAT.PMR, y / CAAT.PMR)); + return this; }, + + setPosition:function (x, y) { + return this.setLocation(x, y); + }, + + setPositionAnchor:function (pax, pay) { + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + + setPositionAnchored:function (x, y, pax, pay) { + this.setLocation(x, y); + this.tAnchorX = pax; + this.tAnchorY = pay; + return this; + }, + /** * Set this body's * density. diff --git a/build/caat-css-min.js b/build/caat-css-min.js index 44a6dcd0..40e9f655 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -25,559 +25,545 @@ THE SOFTWARE. Version: 0.6 build: 6 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-08-25 +TIME: 14:03:51 */ -(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 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:!1,module:null,setProcessed:function(){this.processed=!0},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.")}a.depends|| +(a.depends=[]);if((b=a.depends)&&!isArray(b))b=[b],a.depends=b;for(c=0;c=0&&bb;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,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}}}}); +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)*this.scaleX;g=(-f*e+g*c)*this.scaleY;j=(h*c+i*e)*this.scaleX;i=(-h*e+i*c)*this.scaleY;k[0]=d;k[1]=g;k[2]=a;k[3]=j;k[4]=i;k[5]=b}}}}); CAAT.Module({defines:"CAAT.Math.Matrix3",aliases:["CAAT.Matrix3"],extendsWith:function(){return{matrix:null,fmatrix:null,__init:function(){this.matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];this.fmatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return this},transformCoord:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.matrix[0][0]+c*this.matrix[0][1]+d*this.matrix[0][2]+this.matrix[0][3];a.y=b*this.matrix[1][0]+c*this.matrix[1][1]+d*this.matrix[1][2]+this.matrix[1][3];a.z=b*this.matrix[2][0]+c*this.matrix[2][1]+ d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,i){this.identity();this.matrix[0][0]=a;this.matrix[0][1]=b;this.matrix[0][2]=c;this.matrix[1][0]=d;this.matrix[1][1]=e;this.matrix[1][2]=f;this.matrix[2][0]=g;this.matrix[2][1]=h;this.matrix[2][2]=i;return this},initWithMatrix:function(a){this.matrix=a;return this},flatten:function(){var a=this.fmatrix,b=this.matrix;a[0]=b[0][0];a[1]=b[1][0];a[2]=b[2][0];a[3]=b[3][0];a[4]=b[0][1];a[5]=b[1][1];a[6]=b[2][1];a[7]=b[2][1]; -a[8]=b[0][2];a[9]=b[1][2];a[10]=b[2][2];a[11]=b[3][2];a[12]=b[0][3];a[13]=b[1][3];a[14]=b[2][3];a[15]=b[3][3];return this.fmatrix},identity:function(){for(var a=0;a<4;a++)for(var b=0;b<4;b++)this.matrix[a][b]=a===b?1:0;return this},getMatrix:function(){return this.matrix},rotateXY:function(a){return this.rotate(a,0,0)},rotateXZ:function(a){return this.rotate(0,a,0)},rotateYZ:function(a){return this.rotate(0,0,a)},setRotate:function(a,b,c){this.copy(this.rotate(a,b,c));return this},rotate:function(a, -b,c){var d=new CAAT.Math.Matrix3,e,f;a!==0&&(f=new CAAT.Math.Math.Matrix3,e=Math.sin(a),a=Math.cos(a),f.matrix[1][1]=a,f.matrix[1][2]=-e,f.matrix[2][1]=e,f.matrix[2][2]=a,d.multiply(f));b!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(b),a=Math.cos(b),f.matrix[0][0]=a,f.matrix[0][2]=-e,f.matrix[2][0]=e,f.matrix[2][2]=a,d.multiply(f));c!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(c),a=Math.cos(c),f.matrix[0][0]=a,f.matrix[0][1]=-e,f.matrix[1][0]=e,f.matrix[1][1]=a,d.multiply(f));return d},getClone:function(){var a= -new CAAT.Math.Matrix3;a.copy(this);return a},multiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1],q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],z=n[2][3],A=n[3][0],B=n[3][1],C=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*v+f*A;this.matrix[0][1]=c*p+d*t+e*x+f*B;this.matrix[0][2]=c*q+d*s+e*y+f*C;this.matrix[0][3]= -c*r+d*w+e*z+f*n;this.matrix[1][0]=g*a+h*u+i*v+j*A;this.matrix[1][1]=g*p+h*t+i*x+j*B;this.matrix[1][2]=g*q+h*s+i*y+j*C;this.matrix[1][3]=g*r+h*w+i*z+j*n;this.matrix[2][0]=k*a+m*u+o*v+b*A;this.matrix[2][1]=k*p+m*t+o*x+b*B;this.matrix[2][2]=k*q+m*s+o*y+b*C;this.matrix[2][3]=k*r+m*w+o*z+b*n;return this},premultiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1], -q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*v;this.matrix[0][1]=c*p+d*t+e*x;this.matrix[0][2]=c*q+d*s+e*y;this.matrix[0][3]=c*r+d*w+e*n+f;this.matrix[1][0]=g*a+h*u+i*v;this.matrix[1][1]=g*p+h*t+i*x;this.matrix[1][2]=g*q+h*s+i*y;this.matrix[1][3]=g*r+h*w+i*n+j;this.matrix[2][0]=k*a+m*u+o*v;this.matrix[2][1]=k*p+m*t+o*x;this.matrix[2][2]=k*q+m*s+o*y;this.matrix[2][3]=k*r+m*w+o*n+b;return this},setTranslate:function(a, +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],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],p=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1],r=n[0][2],s=n[0][3],u=n[1][0],v=n[1][1],t=n[1][2],x=n[1][3],w=n[2][0],y=n[2][1],z=n[2][2],A=n[2][3],B=n[3][0],C=n[3][1],D=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*w+f*B;this.matrix[0][1]=c*q+d*v+e*y+f*C;this.matrix[0][2]=c*r+d*t+e*z+f*D;this.matrix[0][3]= +c*s+d*x+e*A+f*n;this.matrix[1][0]=g*a+h*u+i*w+j*B;this.matrix[1][1]=g*q+h*v+i*y+j*C;this.matrix[1][2]=g*r+h*t+i*z+j*D;this.matrix[1][3]=g*s+h*x+i*A+j*n;this.matrix[2][0]=k*a+m*u+p*w+b*B;this.matrix[2][1]=k*q+m*v+p*y+b*C;this.matrix[2][2]=k*r+m*t+p*z+b*D;this.matrix[2][3]=k*s+m*x+p*A+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],p=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1], +r=n[0][2],s=n[0][3],u=n[1][0],v=n[1][1],t=n[1][2],x=n[1][3],w=n[2][0],y=n[2][1],z=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*w;this.matrix[0][1]=c*q+d*v+e*y;this.matrix[0][2]=c*r+d*t+e*z;this.matrix[0][3]=c*s+d*x+e*n+f;this.matrix[1][0]=g*a+h*u+i*w;this.matrix[1][1]=g*q+h*v+i*y;this.matrix[1][2]=g*r+h*t+i*z;this.matrix[1][3]=g*s+h*x+i*n+j;this.matrix[2][0]=k*a+m*u+p*w;this.matrix[2][1]=k*q+m*v+p*y;this.matrix[2][2]=k*r+m*t+p*z;this.matrix[2][3]=k*s+m*x+p*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}}}}); +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],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],p=a[2][3],n=a[3][0],q=a[3][1],r=a[3][2],a=a[3][3];return e*g*m*n+c*i*m*n+e*h*j*q+d*i*j*q+d*f*p*q+b*h*p*q+e*f*k*r+b*i*k*r+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*p*n-c*h*p*n-e*f*m*q-b*i*m*q-e*g*j*r-c*i*j*r-c*f*p*r-b*g*p*r-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],p=a[2][3],n=a[3][0],q=a[3][1],r=a[3][2],a=a[3][3],s=new CAAT.Math.Matrix3;s.matrix[0][0]=h*p*q+i*k*r+g*m*a-i*m*q-g*p*r-h*k*a;s.matrix[0][1]=e*m*q+c*p*r+d*k*a-c*m*a-d*p*q-e*k*r;s.matrix[0][2]=d*i*q+c*h*a+e*g*r-c*i*r-d*g*a-e*h*q;s.matrix[0][3]=e*h*k+c*i*m+d*g*p-d*i*k-e*g*m-c*h*p;s.matrix[1][0]=i*m*n+f*p*r+h*j*a-h*p*n-i*j*r-f*m*a;s.matrix[1][1]=d*p*n+e*j*r+b*m*a-e*m*n-b*p*r-d*j*a;s.matrix[1][2]=e*h*n+b*i*r+d*f*a-d*i*n-e*f*r-b*h*a;s.matrix[1][3]=d*i*j+e*f*m+b*h*p-e*h*j-b*i*m-d*f*p;s.matrix[2][0]= +g*p*n+i*j*q+f*k*a-i*k*n-f*p*q-g*j*a;s.matrix[2][1]=e*k*n+b*p*q+c*j*a-b*k*a-c*p*n-e*j*q;s.matrix[2][2]=d*i*n+e*f*q+b*g*a-e*g*n-b*i*q-c*f*a;s.matrix[2][3]=e*g*j+b*i*k+c*f*p-b*g*p-c*i*j-e*f*k;s.matrix[3][0]=h*k*n+f*m*q+g*j*r-g*m*n-h*j*q-f*k*r;s.matrix[3][1]=c*m*n+d*j*q+b*k*r-d*k*n-b*m*q-c*j*r;s.matrix[3][2]=d*g*n+b*h*q+c*f*r-b*g*r-c*h*n-d*f*q;s.matrix[3][3]=c*h*j+d*f*k+b*g*m-d*g*j-b*h*k-c*f*m;return s.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.0050>a&&-0.0050a&&-0.0050=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((d-e)*2*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((d-e)*2*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*d;return 1>=d?this.interpolated.set(d,-0.5*a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*2*Math.PI/b)):this.interpolated.set(d,1+0.5*a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*2*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,d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+100*(a/c)+"%{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}}}}); +e=e.getPropertyName(b),"undefined"===typeof f[e]&&(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+";");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);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=""+100*(b/c)+"%{",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(1!==j.scaleX||1!==j.scaleY)h+=" scale("+j.scaleX+","+j.scaleY+")";h+=";";j.alpha&&(h+=" opacity: "+j.alpha+";");if(0.5!==d||0.5!==e)h+=" -"+a+"-transform-origin:"+100*d+"% "+100*e+"%;";f+=i+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(){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};this.autoRotate&&(a=0===a?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){"undefined"===typeof c&&(c=100);for(var c=c>> +0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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.0010);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);for(var c=c>>0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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){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){"undefined"===typeof c&&(c=100);for(var c=c>>0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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){var a=a.target,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=b/e,f,g,h,i,j,k,m,p,n,q,r,s,u,v;for(f=0;f>24&255;n=(m&16711680)>>16;q=(m&65280)>>8;m&=255;g=a[f+1];r=g>>24&255;s=(g&16711680)>>16;u=(g&65280)>>8;g&=255;r=(r-p)/b;s=(s-n)/b;u=(u-q)/b;v=(g-m)/b;for(g=0;g>0;i=n+s*g>>0;j=q+u*g>>0;k=m+v*g>>0;var t=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case t.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+k+")");break;case t.RAMP_RGB:d.push("rgb("+i+","+j+","+k+")");break;case t.RAMP_CHANNEL_RGB:d.push(4278190080| +i<<16|j<<8|k);break;case t.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|k);break;case t.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,k,h]);break;case t.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,k])}}}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){var a=/(\d+)p[x|t]\s*/i.exec(a),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(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;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.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]= +c.width=a.height;c.height=a.width;var d=c.getContext("2d");d.globalAlpha=1;d.fillStyle="rgba(0,0,0,0)";d.clearRect(0,0,c.width,c.height);var e=new CAAT.Math.Matrix;e.multiply((new CAAT.Math.Matrix).setTranslate(c.width/2,c.width/2));e.multiply((new CAAT.Math.Matrix).setRotation(b*Math.PI/180));e.multiply((new CAAT.Math.Matrix).setTranslate(-c.width/2,-c.width/2));e.transformRenderingContext(d);d.drawImage(a,0,0);return c},optimize:function(a,b,c){var b=b>>0,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 i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,p=c.width-1,n=!1;if(d){for(d=0;db){n=!0;break}if(n)break}a=d}if(e){n=!1;for(d=c.height-1;d>=a;d--){for(j=0;jb){n=!0;break}if(n)break}k=d}if(f){n=!1;for(j=0;jb){n=!0;break}if(n)break}m=j}if(g){n=!1;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[4*d*c.width+3+4*j]>b){n=!0;break}if(n)break}p=j}if(0===m&&0===a&&c.width-1===p&&c.height-1===k)return c;b=p-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){"undefined"===typeof f&&(f=32);"undefined"===typeof g&&(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;cb;b++){if(this.quadData[b].intersects(a)){f=this.quadData[b].getOverlappingActors(a);c=0;for(d=f.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ -a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; -for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;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){var c=document.getElementById(c),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 i(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))}var c=document.getElementById(c),j; +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 k=document.createElement("canvas");c.appendChild(k);c=k}else!1==c instanceof HTMLCanvasElement&&(k=document.createElement("canvas"),document.body.appendChild(k),c=k);else c=document.createElement("canvas"),document.body.appendChild(c);j=(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});j.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){j.setImagesCache(b);var c=d||5E3,g=j.getImage("spinner"),h=j.getImage("splash"),k=j.createScene(),u=(new Date).getTime();h&&k.addChild((new CAAT.Foundation.Actor).setBackgroundImage(h,!1).setBounds(0,0,j.width,j.height).setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE));g&&k.addChild((new CAAT.Foundation.Actor).setBackgroundImage(g).centerAt(k.width/ +2,k.height/2).addBehavior((new CAAT.Behavior.RotateBehavior).setValues(0,2*Math.PI).setFrameTime(0,1E3).setCycle(!0)));k.loadedImage=function(a,b){if(!b||a===b.length){var d=(new Date).getTime()-u;dc&&(d=c),setTimeout(function(){i(j,b,f)},d)):i(j,b,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 i=new CAAT.Math.Bezier;i.setCubic(a,b,c,d,e,f,g,h);this.curve=i;this.updatePath();return this},updatePath:function(){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(){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(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(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; -return this},points:null,cw:true,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x, -this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1; -a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c,b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;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=0&&b="0"&&a<="9"},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(c=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.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(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,i;e!==f;){g=(f+e)/2|0;i=c[g];if(i<=a&&a<=i+d[g])return a=d[g]?(a-i)/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&&ad&&(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);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){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,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.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, +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, -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, +getWidth:function(){var a=this.mapInfo[this.spriteIndex];if(null===a||"undefined"===typeof a)console.log(this.mapInfo),console.log(this.spriteIndex);return a.width},getHeight:function(){return this.mapInfo[this.spriteIndex].height},getWrappedImageWidth:function(){return this.image.width},getWrappedImageHeight:function(){return this.image.height},getRef:function(){var a=new CAAT.Foundation.SpriteImage;a.image=this.image;a.rows=this.rows;a.columns=this.columns;a.width=this.width;a.height=this.height; +a.singleWidth=this.singleWidth;a.singleHeight=this.singleHeight;a.mapInfo=this.mapInfo;a.offsetX=this.offsetX;a.offsetY=this.offsetY;a.scaleX=this.scaleX;a.scaleY=this.scaleY;a.animationsMap=this.animationsMap;a.parentOffsetX=this.parentOffsetX;a.parentOffsetY=this.parentOffsetY;a.scaleFont=this.scaleFont;a.spriteIndex=this.spriteIndex;return a},setOffsetX:function(a){this.offsetX=a;return this},setOffsetY:function(a){this.offsetY=a;return this},setOffset:function(a,b){this.offsetX=a;this.offsetY= +b;return this},initialize:function(a,b,c){a||console.log("Null image for SpriteImage.");isString(a)&&(a=CAAT.currentDirector.getImage(a));this.parentOffsetY=this.parentOffsetX=0;this.rows=b;this.columns=c;if(a instanceof CAAT.Foundation.SpriteImage||a instanceof CAAT.SpriteImage){this.image=a.image;var d=a.mapInfo[0];this.width=d.width;this.height=d.height;this.parentOffsetX=d.x;this.parentOffsetY=d.y;this.width=a.mapInfo[0].width;this.height=a.mapInfo[0].height}else this.image=a,this.width=a.width, +this.height=a.height,this.mapInfo={};this.singleWidth=Math.floor(this.width/c);this.singleHeight=Math.floor(this.height/b);var e,f,g;if(a.__texturePage){a.__du=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);for(var a=this.image.__tx,i=this.image.__ty,j=this.image.__texturePage,d=0;d>0)*e;var k=i+(d/h>>0)*f,m=g+e,p=k+f;g=(new CAAT.Foundation.SpriteImageHelper(g, +k,m-g,p-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,p/j.height);this.mapInfo[d]=g}}else for(d=0;d>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx,a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0, +d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image, +b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a,b,c,d,e,f,g){a.drawImage(this.image, +d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return""+-(a.x+this.parentOffsetX- +this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height, +f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case b.TR_FLIP_ALL:this.paint= +this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint=this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this},setSpriteIndex:function(a){this.spriteIndex= +a;return this},setSpriteIndexAtTime:function(a){if(1>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, --this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,-this.height));break;case CAAT.Foundation.Actor.ANCHOR_BOTTOM:d?f.setPath((new CAAT.Path).setLinear(0,this.height,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,0,this.height));break;case CAAT.Foundation.Actor.ANCHOR_LEFT:d?f.setPath((new CAAT.Path).setLinear(-this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0,0,-this.width,0));break;case CAAT.Foundation.Actor.ANCHOR_RIGHT:d?f.setPath((new CAAT.Path).setLinear(this.width,0,0,0)):f.setPath((new CAAT.Path).setLinear(0, -0,this.width,0))}b&&this.createAlphaBehaviour(a,d);this.easeContainerBehaviour.addBehavior(f);this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);a=f.path.startCurvePosition();this.setLocation(a.x,a.y);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},easeScaleIn:function(a,b,c,d,e){this.easeScale(a,b,c,d,true,e);this.easeIn=true},easeScaleOut:function(a,b,c,d,e){this.easeScale(a,b,c,d,false,e);this.easeIn= -false},easeScale:function(a,b,c,d,e,f){this.easeContainerBehaviour=new CAAT.ContainerBehavior;var g=0,h=0,i=0,j=0;switch(d){case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:case CAAT.Foundation.Actor.ANCHOR_CENTER:j=i=1;break;case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:i=g=1;h=0;j=1;break;case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:j= -h=1;g=0;i=1;break;default:alert("scale anchor ?? "+d)}if(!e){var k;k=g;g=i;i=k;k=h;h=j;j=k}c&&this.createAlphaBehaviour(b,e);c=this.getAnchorPercent(d);a=(new CAAT.ScaleBehavior).setFrameTime(a,b).setValues(g,i,h,j,c.x,c.y);f&&a.setInterpolator(f);this.easeContainerBehaviour.addBehavior(a);this.easeContainerBehaviour.setFrameTime(this.time,b);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},addBehavior:function(){return this}, -easeRotationIn:function(a,b,c,d){this.easeRotation(a,b,c,true,d);this.easeIn=true},easeRotationOut:function(a,b,c,d){this.easeRotation(a,b,c,false,d);this.easeIn=false},easeRotation:function(a,b,c,d,e){this.easeContainerBehaviour=new CAAT.Behavior.ContainerBehavior;var f=0,g=0;if(c==CAAT.Foundation.Actor.ANCHOR_CENTER)c=CAAT.Foundation.Actor.ANCHOR_TOP;switch(c){case CAAT.Foundation.Actor.ANCHOR_TOP:case CAAT.Foundation.Actor.ANCHOR_BOTTOM:case CAAT.Foundation.Actor.ANCHOR_LEFT:case CAAT.Foundation.Actor.ANCHOR_RIGHT:f= -Math.PI*(Math.random()<0.5?1:-1);break;case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT:case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT:case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT:f=Math.PI/2*(Math.random()<0.5?1:-1);break;default:alert("rot anchor ?? "+c)}if(false===d)var h=f,f=g,g=h;b&&this.createAlphaBehaviour(a,d);b=this.getAnchorPercent(c);f=(new CAAT.Behavior.RotateBehavior).setFrameTime(0,a).setValues(f,g,b.x,b.y);e&&f.setInterpolator(e);this.easeContainerBehaviour.addBehavior(f); -this.easeContainerBehaviour.setFrameTime(this.time,a);this.easeContainerBehaviour.addListener(this);this.emptyBehaviorList();CAAT.Foundation.Scene.superclass.addBehavior.call(this,this.easeContainerBehaviour)},setEaseListener:function(a){this.easeContainerBehaviourListener=a},behaviorExpired:function(){this.easeContainerBehaviourListener.easeEnd(this,this.easeIn)},activated:function(){},setExpired:function(a){this.expired=a;this.style("display",a?"none":"block")},paint:function(){},getIn:function(){}, -goOut:function(){}}}}); -CAAT.Module({defines:"CAAT.Foundation.Director",aliases:["CAAT.Director"],extendsClass:"CAAT.Foundation.ActorContainer",depends:"CAAT.Core.Class,CAAT.Core.Constants,CAAT.Foundation.ActorContainer,CAAT.Module.Audio.AudioManager,CAAT.Module.Runtime.BrowserInfo,CAAT.Module.Debug.Debug,CAAT.Math.Point,CAAT.Math.Rectangle,CAAT.Math.Matrix,CAAT.Foundation.Timer.TimerManager,CAAT.Foundation.Actor,CAAT.Foundation.Scene,CAAT.Event.AnimationLoop,CAAT.Event.Input,CAAT.Event.KeyEvent,CAAT.Event.MouseEvent,CAAT.Event.TouchEvent,CAAT.WebGL.Program,CAAT.WebGL.ColorProgram,CAAT.WebGL.TextureProgram,CAAT.WebGL.GLU,CAAT.Module.TexturePacker.TexturePageManager".split(","),constants:{RENDER_MODE_CONTINUOUS:1, -RENDER_MODE_DIRTY:2,CLEAR_DIRTY_RECTS:1,CLEAR_ALL:true,CLEAR_NONE:false,RESIZE_NONE:1,RESIZE_WIDTH:2,RESIZE_HEIGHT:4,RESIZE_BOTH:8,RESIZE_PROPORTIONAL:16},extendsWith:function(){return{__init:function(){this.__super();this.browserInfo=CAAT.Module.Runtime.BrowserInfo;this.audioManager=(new CAAT.Module.Audio.AudioManager).initialize(8);this.scenes=[];this.imagesCache=[];this.mousePoint=new CAAT.Math.Point(0,0,0);this.prevMousePoint=new CAAT.Math.Point(0,0,0);this.screenMousePoint=new CAAT.Math.Point(0, -0,0);this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.cDirtyRects=[];this.sDirtyRects=[];this.dirtyRects=[];for(var a=0;a<64;a++)this.dirtyRects.push(new CAAT.Math.Rectangle);this.dirtyRectsIndex=0;this.touches={};this.timerManager=new CAAT.Foundation.Timer.TimerManager;this.__map={};return this},debug:false,renderMode:CAAT.Foundation.Director.RENDER_MODE_CONTINUOUS,onRenderStart:null,onRenderEnd:null,mousePoint:null,prevMousePoint:null,screenMousePoint:null,isMouseDown:false, -lastSelectedActor:null,dragging:false,scenes:null,currentScene:null,canvas:null,ctx:null,time:0,timeline:0,imagesCache:null,audioManager:null,clear:CAAT.Foundation.Director.CLEAR_ALL,transitionScene:null,browserInfo:null,gl:null,glEnabled:false,glTextureManager:null,glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex:0,uv:null,uvIndex:0,front_to_back:false,statistics:{size_total:0,size_active:0,size_dirtyRects:0,draws:0,size_discarded_by_dirty_rects:0},currentTexturePage:0, -currentOpacity:1,intervalId:null,frameCounter:0,resize:1,onResizeCallback:null,__gestureScale:0,__gestureRotation:0,dirtyRects:null,cDirtyRects:null,sDirtyRects:null,dirtyRectsIndex:0,dirtyRectsEnabled:false,nDirtyRects:0,drDiscarded:0,stopped:false,needsRepaint:false,touches:null,timerManager:null,SCREEN_RATIO:1,__map:null,clean:function(){this.audioManager=this.imagesCache=this.currentScene=this.scenes=null;this.isMouseDown=false;this.lastSelectedActor=null;this.dragging=false;this.__gestureRotation= -this.__gestureScale=0;this.dirty=true;this.cDirtyRects=this.dirtyRects=null;this.dirtyRectsIndex=0;this.dirtyRectsEnabled=false;this.nDirtyRects=0;this.onResizeCallback=null;this.__map={};return this},cancelPlay:function(a){return this.audioManager.cancelPlay(a)},cancelPlayByChannel:function(a){return this.audioManager.cancelPlayByChannel(a)},setAudioFormatExtensions:function(a){this.audioManager.setAudioFormatExtensions(a);return this},setValueForKey:function(a,b){this.__map[a]=b;return this},getValueForKey:function(a){return this.__map[a]}, -createTimer:function(a,b,c,d,e){return this.timerManager.createTimer(a,b,c,d,e,this)},requestRepaint:function(){this.needsRepaint=true},getCurrentScene:function(){return this.currentScene},checkDebug:function(){if(!navigator.isCocoonJS&&CAAT.DEBUG){var a=(new CAAT.Module.Debug.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){var c=CAAT.Foundation.Director;switch(this.resize){case c.RESIZE_WIDTH:this.setBounds(0, +[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(){},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];c.xe&&(e=c.x);c.yg&&(g=c.y);c=b[1];c.xe&&(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(){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;ca;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(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},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;bd.x||(0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,c);0>d.x||(0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,a);(b.dragging||!(0>d.x||0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,c);0>d.x||(0>d.y||d.x>=b.width||d.y>=b.height)||b.__mouseDBLClickHandler(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: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= +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!==p&&(n=f.substr(d+1,p-d-1),-1!==n.indexOf("<")?(this.rc.fchar(q),d+=1):(this.rc.setTag(n),d=p+1))):(this.rc.fchar(q),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension("undefined"===typeof b?0:b);this.setLinesAlignment();r.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(){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){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= -a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ -2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, -this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); +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;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+=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) { - if (!this.timerList[i].remove) { - this.timerList[i].checkTask(time); - } - i--; - } - }, - /** - * Make sure the timertask is contained in the timer task list by adding it to the list in case it - * is not contained. - * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. - * @return this - */ - ensureTimerTask:function (timertask) { - if (!this.hasTimer(timertask)) { - this.timerList.push(timertask); - } - return this; - }, - /** - * Check whether the timertask is in this scene's timer task list. - * @param timertask {CAAT.TimerTask} a CAAT.TimerTask object. - * @return {boolean} a boolean indicating whether the timertask is in this scene or not. - */ - hasTimer:function (timertask) { - var i = this.timerList.length - 1; - while (i >= 0) { - if (this.timerList[i] === timertask) { - return true; - } - i--; - } - - return false; - }, - /** - * Creates a timer task. Timertask object live and are related to scene's time, so when an Scene - * is taken out of the Director the timer task is paused, and resumed on Scene restoration. - * - * @param startTime {number} an integer indicating the scene time this task must start executing at. - * @param duration {number} an integer indicating the timerTask duration. - * @param callback_timeout {function} timer on timeout callback function. - * @param callback_tick {function} timer on tick callback function. - * @param callback_cancel {function} timer on cancel callback function. - * - * @return {CAAT.TimerTask} a CAAT.TimerTask class instance. - */ - createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { - - var tt = new CAAT.TimerTask().create( - startTime, - duration, - callback_timeout, - callback_tick, - callback_cancel); - - tt.taskId = this.timerSequence++; - tt.sceneTime = this.time; - tt.scene = this; - - this.timerList.push(tt); - - return tt; - }, - /** - * Removes expired timers. This method must not be called directly. - */ - removeExpiredTimers:function () { - var i; - for (i = 0; i < this.timerList.length; i++) { - if (this.timerList[i].remove) { - this.timerList.splice(i, 1); - } - } - }, - /** - * Scene animation method. - * It extendsClass Container's base behavior by adding timer control. - * @param director {CAAT.Director} a CAAT.Director instance. - * @param time {number} an integer indicating the Scene time the animation is being performed at. - */ -// animate:function (director, time) { -// this.checkTimers(time); -// CAAT.Scene.superclass.animate.call(this, director, time); -// this.removeExpiredTimers(); -// }, - /** - * Helper method to manage alpha transparency fading on Scene switch by the Director. - * @param time {number} integer indicating the time in milliseconds the fading will take. - * @param isIn {boolean} boolean indicating whether this Scene in the switch process is - * being brought in. - * - * @private - */ - createAlphaBehaviour:function (time, isIn) { - var ab = new CAAT.AlphaBehavior(); - ab.setFrameTime(0, time); - ab.startAlpha = isIn ? 0 : 1; - ab.endAlpha = isIn ? 1 : 0; - this.easeContainerBehaviour.addBehavior(ab); - }, - /** - * Called from CAAT.Director to bring in an Scene. - * A helper method for easeTranslation. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslationIn:function (time, alpha, anchor, interpolator) { - this.easeTranslation(time, alpha, anchor, true, interpolator); - }, - /** - * Called from CAAT.Director to bring in an Scene. - * A helper method for easeTranslation. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslationOut:function (time, alpha, anchor, interpolator) { - this.easeTranslation(time, alpha, anchor, false, interpolator); - }, - /** - * This method will setup Scene behaviours to switch an Scene via a translation. - * The anchor value can only be - *
  • CAAT.Actor.ANCHOR_LEFT - *
  • CAAT.Actor.ANCHOR_RIGHT - *
  • CAAT.Actor.ANCHOR_TOP - *
  • CAAT.Actor.ANCHOR_BOTTOM - * if any other value is specified, any of the previous ones will be applied. - * - * @param time integer indicating time in milliseconds for the Scene. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param isIn boolean indicating whether the scene will be brought in. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeTranslation:function (time, alpha, anchor, isIn, interpolator) { - - this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); - this.easeIn = isIn; - - var pb = new CAAT.Behavior.PathBehavior(); - if (interpolator) { - pb.setInterpolator(interpolator); - } - - pb.setFrameTime(0, time); - - // BUGBUG anchors: 1..4 - if (anchor < 1) { - anchor = 1; - } else if (anchor > 4) { - anchor = 4; - } - - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(0, -this.height, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, 0, -this.height)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(0, this.height, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, 0, this.height)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_LEFT: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(-this.width, 0, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, -this.width, 0)); - } - break; - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - if (isIn) { - pb.setPath(new CAAT.Path().setLinear(this.width, 0, 0, 0)); - } else { - pb.setPath(new CAAT.Path().setLinear(0, 0, this.width, 0)); - } - break; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - this.easeContainerBehaviour.addBehavior(pb); - - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - var start = pb.path.startCurvePosition(); - this.setLocation(start.x, start.y); - - this.emptyBehaviorList(); - CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Called from CAAT.Director to bring in a Scene. - * A helper method for easeScale. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - */ - easeScaleIn:function (starttime, time, alpha, anchor, interpolator) { - this.easeScale(starttime, time, alpha, anchor, true, interpolator); - this.easeIn = true; - }, - /** - * Called from CAAT.Director to take away a Scene. - * A helper method for easeScale. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator instance to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - */ - easeScaleOut:function (starttime, time, alpha, anchor, interpolator) { - this.easeScale(starttime, time, alpha, anchor, false, interpolator); - this.easeIn = false; - }, - /** - * Called from CAAT.Director to bring in ot take away an Scene. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param starttime integer indicating in milliseconds from which scene time the behavior will be applied. - * @param isIn boolean indicating whether the Scene is being brought in. - */ - easeScale:function (starttime, time, alpha, anchor, isIn, interpolator) { - this.easeContainerBehaviour = new CAAT.ContainerBehavior(); - - var x = 0; - var y = 0; - var x2 = 0; - var y2 = 0; - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: - case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_CENTER: - x2 = 1; - y2 = 1; - break; - case CAAT.Foundation.Actor.ANCHOR_TOP: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - x = 1; - x2 = 1; - y = 0; - y2 = 1; - break; - case CAAT.Foundation.Actor.ANCHOR_LEFT: - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - y = 1; - y2 = 1; - x = 0; - x2 = 1; - break; - default: - alert('scale anchor ?? ' + anchor); - } - - if (!isIn) { - var tmp; - tmp = x; - x = x2; - x2 = tmp; - - tmp = y; - y = y2; - y2 = tmp; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - var anchorPercent = this.getAnchorPercent(anchor); - var sb = new CAAT.ScaleBehavior(). - setFrameTime(starttime, time). - setValues(x, x2, y, y2, anchorPercent.x, anchorPercent.y); - - if (interpolator) { - sb.setInterpolator(interpolator); - } - - this.easeContainerBehaviour.addBehavior(sb); - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - this.emptyBehaviorList(); - CAAT.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Overriden method to disallow default behavior. - * Do not use directly. - */ - addBehavior:function (behaviour) { - return this; - }, - /** - * Called from CAAT.Director to use Rotations for bringing in. - * This method is a Helper for the method easeRotation. - * @param time integer indicating time in milliseconds for the Scene to be brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeRotationIn:function (time, alpha, anchor, interpolator) { - this.easeRotation(time, alpha, anchor, true, interpolator); - this.easeIn = true; - }, - /** - * Called from CAAT.Director to use Rotations for taking Scenes away. - * This method is a Helper for the method easeRotation. - * @param time integer indicating time in milliseconds for the Scene to be taken away. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - */ - easeRotationOut:function (time, alpha, anchor, interpolator) { - this.easeRotation(time, alpha, anchor, false, interpolator); - this.easeIn = false; - }, - /** - * Called from CAAT.Director to use Rotations for taking away or bringing Scenes in. - * @param time integer indicating time in milliseconds for the Scene to be taken away or brought in. - * @param alpha boolean indicating whether fading will be applied to the Scene. - * @param anchor integer indicating the Scene switch anchor. - * @param interpolator {CAAT.Interpolator} a CAAT.Interpolator to apply to the Scene transition. - * @param isIn boolean indicating whehter the Scene is brought in. - */ - easeRotation:function (time, alpha, anchor, isIn, interpolator) { - this.easeContainerBehaviour = new CAAT.Behavior.ContainerBehavior(); - - var start = 0; - var end = 0; - - if (anchor == CAAT.Foundation.Actor.ANCHOR_CENTER) { - anchor = CAAT.Foundation.Actor.ANCHOR_TOP; - } - - switch (anchor) { - case CAAT.Foundation.Actor.ANCHOR_TOP: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM: - case CAAT.Foundation.Actor.ANCHOR_LEFT: - case CAAT.Foundation.Actor.ANCHOR_RIGHT: - start = Math.PI * (Math.random() < 0.5 ? 1 : -1); - break; - case CAAT.Foundation.Actor.ANCHOR_TOP_LEFT: - case CAAT.Foundation.Actor.ANCHOR_TOP_RIGHT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_LEFT: - case CAAT.Foundation.Actor.ANCHOR_BOTTOM_RIGHT: - start = Math.PI / 2 * (Math.random() < 0.5 ? 1 : -1); - break; - default: - alert('rot anchor ?? ' + anchor); - } - - if (false === isIn) { - var tmp = start; - start = end; - end = tmp; - } - - if (alpha) { - this.createAlphaBehaviour(time, isIn); - } - - var anchorPercent = this.getAnchorPercent(anchor); - var rb = new CAAT.Behavior.RotateBehavior(). - setFrameTime(0, time). - setValues(start, end, anchorPercent.x, anchorPercent.y); - - if (interpolator) { - rb.setInterpolator(interpolator); - } - this.easeContainerBehaviour.addBehavior(rb); - - - this.easeContainerBehaviour.setFrameTime(this.time, time); - this.easeContainerBehaviour.addListener(this); - - this.emptyBehaviorList(); - CAAT.Foundation.Scene.superclass.addBehavior.call(this, this.easeContainerBehaviour); - }, - /** - * Registers a listener for listen for transitions events. - * Al least, the Director registers himself as Scene easing transition listener. - * When the transition is done, it restores the Scene's capability of receiving events. - * @param listener {function(caat_behavior,time,actor)} an object which contains a method of the form - * behaviorExpired( caat_behaviour, time, actor); - */ - setEaseListener:function (listener) { - this.easeContainerBehaviourListener = listener; - }, - /** - * Private. - * listener for the Scene's easeContainerBehaviour. - * @param actor - */ - behaviorExpired:function (actor) { - this.easeContainerBehaviourListener.easeEnd(this, this.easeIn); - }, - /** - * This method should be overriden in case the developer wants to do some special actions when - * the scene has just been brought in. - */ - activated:function () { - }, - /** - * Scenes, do not expire the same way Actors do. - * It simply will be set expired=true, but the frameTime won't be modified. - * WARN: the parameter here is treated as boolean, not number. - */ - setExpired:function (bExpired) { - this.expired = bExpired; - this.style('display', bExpired ? 'none' : 'block'); - }, - /** - * An scene by default does not paint anything because has not fillStyle set. - * @param director - * @param time - */ - paint:function (director, time) { - }, - - getIn : function( out_scene ) { - - }, - - goOut : function( in_scene ) { - - } - } - } -});/** * See LICENSE file. * **/ @@ -20958,7 +20449,6 @@ CAAT.Module({ getValueForKey : function( key ) { return this.__map[key]; - return this; }, createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { @@ -21639,7 +21129,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; @@ -21842,6 +21332,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. @@ -22060,10 +21590,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 +21972,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,7 +22039,7 @@ 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; @@ -24041,44 +23573,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, - sfont : 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, - 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 +23716,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..f1e3bb3d 100644 --- a/build/caat-min.js +++ b/build/caat-min.js @@ -25,572 +25,571 @@ THE SOFTWARE. Version: 0.6 build: 6 Created on: -DATE: 2013-07-01 -TIME: 04:58:33 +DATE: 2013-08-25 +TIME: 14:03:51 */ -(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 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:!1,module:null,setProcessed:function(){this.processed=!0},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.")}a.depends|| +(a.depends=[]);if((b=a.depends)&&!isArray(b))b=[b],a.depends=b;for(c=0;c=0&&bb;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,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}}}}); +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)*this.scaleX;g=(-f*e+g*c)*this.scaleY;j=(h*c+i*e)*this.scaleX;i=(-h*e+i*c)*this.scaleY;k[0]=d;k[1]=g;k[2]=a;k[3]=j;k[4]=i;k[5]=b}}}}); CAAT.Module({defines:"CAAT.Math.Matrix3",aliases:["CAAT.Matrix3"],extendsWith:function(){return{matrix:null,fmatrix:null,__init:function(){this.matrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];this.fmatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];return this},transformCoord:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.matrix[0][0]+c*this.matrix[0][1]+d*this.matrix[0][2]+this.matrix[0][3];a.y=b*this.matrix[1][0]+c*this.matrix[1][1]+d*this.matrix[1][2]+this.matrix[1][3];a.z=b*this.matrix[2][0]+c*this.matrix[2][1]+ d*this.matrix[2][2]+this.matrix[2][3];return a},initialize:function(a,b,c,d,e,f,g,h,i){this.identity();this.matrix[0][0]=a;this.matrix[0][1]=b;this.matrix[0][2]=c;this.matrix[1][0]=d;this.matrix[1][1]=e;this.matrix[1][2]=f;this.matrix[2][0]=g;this.matrix[2][1]=h;this.matrix[2][2]=i;return this},initWithMatrix:function(a){this.matrix=a;return this},flatten:function(){var a=this.fmatrix,b=this.matrix;a[0]=b[0][0];a[1]=b[1][0];a[2]=b[2][0];a[3]=b[3][0];a[4]=b[0][1];a[5]=b[1][1];a[6]=b[2][1];a[7]=b[2][1]; -a[8]=b[0][2];a[9]=b[1][2];a[10]=b[2][2];a[11]=b[3][2];a[12]=b[0][3];a[13]=b[1][3];a[14]=b[2][3];a[15]=b[3][3];return this.fmatrix},identity:function(){for(var a=0;a<4;a++)for(var b=0;b<4;b++)this.matrix[a][b]=a===b?1:0;return this},getMatrix:function(){return this.matrix},rotateXY:function(a){return this.rotate(a,0,0)},rotateXZ:function(a){return this.rotate(0,a,0)},rotateYZ:function(a){return this.rotate(0,0,a)},setRotate:function(a,b,c){this.copy(this.rotate(a,b,c));return this},rotate:function(a, -b,c){var d=new CAAT.Math.Matrix3,e,f;a!==0&&(f=new CAAT.Math.Math.Matrix3,e=Math.sin(a),a=Math.cos(a),f.matrix[1][1]=a,f.matrix[1][2]=-e,f.matrix[2][1]=e,f.matrix[2][2]=a,d.multiply(f));b!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(b),a=Math.cos(b),f.matrix[0][0]=a,f.matrix[0][2]=-e,f.matrix[2][0]=e,f.matrix[2][2]=a,d.multiply(f));c!==0&&(f=new CAAT.Math.Matrix3,e=Math.sin(c),a=Math.cos(c),f.matrix[0][0]=a,f.matrix[0][1]=-e,f.matrix[1][0]=e,f.matrix[1][1]=a,d.multiply(f));return d},getClone:function(){var a= -new CAAT.Math.Matrix3;a.copy(this);return a},multiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1],q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],z=n[2][3],A=n[3][0],B=n[3][1],C=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*v+f*A;this.matrix[0][1]=c*p+d*t+e*x+f*B;this.matrix[0][2]=c*q+d*s+e*y+f*C;this.matrix[0][3]= -c*r+d*w+e*z+f*n;this.matrix[1][0]=g*a+h*u+i*v+j*A;this.matrix[1][1]=g*p+h*t+i*x+j*B;this.matrix[1][2]=g*q+h*s+i*y+j*C;this.matrix[1][3]=g*r+h*w+i*z+j*n;this.matrix[2][0]=k*a+m*u+o*v+b*A;this.matrix[2][1]=k*p+m*t+o*x+b*B;this.matrix[2][2]=k*q+m*s+o*y+b*C;this.matrix[2][3]=k*r+m*w+o*z+b*n;return this},premultiply:function(a){var b=this.getClone().matrix,c=b[0][0],d=b[0][1],e=b[0][2],f=b[0][3],g=b[1][0],h=b[1][1],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],o=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],p=n[0][1], -q=n[0][2],r=n[0][3],u=n[1][0],t=n[1][1],s=n[1][2],w=n[1][3],v=n[2][0],x=n[2][1],y=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*v;this.matrix[0][1]=c*p+d*t+e*x;this.matrix[0][2]=c*q+d*s+e*y;this.matrix[0][3]=c*r+d*w+e*n+f;this.matrix[1][0]=g*a+h*u+i*v;this.matrix[1][1]=g*p+h*t+i*x;this.matrix[1][2]=g*q+h*s+i*y;this.matrix[1][3]=g*r+h*w+i*n+j;this.matrix[2][0]=k*a+m*u+o*v;this.matrix[2][1]=k*p+m*t+o*x;this.matrix[2][2]=k*q+m*s+o*y;this.matrix[2][3]=k*r+m*w+o*n+b;return this},setTranslate:function(a, +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],i=b[1][2],j=b[1][3],k=b[2][0],m=b[2][1],p=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1],r=n[0][2],s=n[0][3],u=n[1][0],v=n[1][1],t=n[1][2],x=n[1][3],w=n[2][0],y=n[2][1],z=n[2][2],A=n[2][3],B=n[3][0],C=n[3][1],D=n[3][2],n=n[3][3];this.matrix[0][0]=c*a+d*u+e*w+f*B;this.matrix[0][1]=c*q+d*v+e*y+f*C;this.matrix[0][2]=c*r+d*t+e*z+f*D;this.matrix[0][3]= +c*s+d*x+e*A+f*n;this.matrix[1][0]=g*a+h*u+i*w+j*B;this.matrix[1][1]=g*q+h*v+i*y+j*C;this.matrix[1][2]=g*r+h*t+i*z+j*D;this.matrix[1][3]=g*s+h*x+i*A+j*n;this.matrix[2][0]=k*a+m*u+p*w+b*B;this.matrix[2][1]=k*q+m*v+p*y+b*C;this.matrix[2][2]=k*r+m*t+p*z+b*D;this.matrix[2][3]=k*s+m*x+p*A+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],p=b[2][2],b=b[2][3],n=a.matrix,a=n[0][0],q=n[0][1], +r=n[0][2],s=n[0][3],u=n[1][0],v=n[1][1],t=n[1][2],x=n[1][3],w=n[2][0],y=n[2][1],z=n[2][2],n=n[2][3];this.matrix[0][0]=c*a+d*u+e*w;this.matrix[0][1]=c*q+d*v+e*y;this.matrix[0][2]=c*r+d*t+e*z;this.matrix[0][3]=c*s+d*x+e*n+f;this.matrix[1][0]=g*a+h*u+i*w;this.matrix[1][1]=g*q+h*v+i*y;this.matrix[1][2]=g*r+h*t+i*z;this.matrix[1][3]=g*s+h*x+i*n+j;this.matrix[2][0]=k*a+m*u+p*w;this.matrix[2][1]=k*q+m*v+p*y;this.matrix[2][2]=k*r+m*t+p*z;this.matrix[2][3]=k*s+m*x+p*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}}}}); +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],i=a[1][3],j=a[2][0],k=a[2][1],m=a[2][2],p=a[2][3],n=a[3][0],q=a[3][1],r=a[3][2],a=a[3][3];return e*g*m*n+c*i*m*n+e*h*j*q+d*i*j*q+d*f*p*q+b*h*p*q+e*f*k*r+b*i*k*r+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*p*n-c*h*p*n-e*f*m*q-b*i*m*q-e*g*j*r-c*i*j*r-c*f*p*r-b*g*p*r-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],p=a[2][3],n=a[3][0],q=a[3][1],r=a[3][2],a=a[3][3],s=new CAAT.Math.Matrix3;s.matrix[0][0]=h*p*q+i*k*r+g*m*a-i*m*q-g*p*r-h*k*a;s.matrix[0][1]=e*m*q+c*p*r+d*k*a-c*m*a-d*p*q-e*k*r;s.matrix[0][2]=d*i*q+c*h*a+e*g*r-c*i*r-d*g*a-e*h*q;s.matrix[0][3]=e*h*k+c*i*m+d*g*p-d*i*k-e*g*m-c*h*p;s.matrix[1][0]=i*m*n+f*p*r+h*j*a-h*p*n-i*j*r-f*m*a;s.matrix[1][1]=d*p*n+e*j*r+b*m*a-e*m*n-b*p*r-d*j*a;s.matrix[1][2]=e*h*n+b*i*r+d*f*a-d*i*n-e*f*r-b*h*a;s.matrix[1][3]=d*i*j+e*f*m+b*h*p-e*h*j-b*i*m-d*f*p;s.matrix[2][0]= +g*p*n+i*j*q+f*k*a-i*k*n-f*p*q-g*j*a;s.matrix[2][1]=e*k*n+b*p*q+c*j*a-b*k*a-c*p*n-e*j*q;s.matrix[2][2]=d*i*n+e*f*q+b*g*a-e*g*n-b*i*q-c*f*a;s.matrix[2][3]=e*g*j+b*i*k+c*f*p-b*g*p-c*i*j-e*f*k;s.matrix[3][0]=h*k*n+f*m*q+g*j*r-g*m*n-h*j*q-f*k*r;s.matrix[3][1]=c*m*n+d*j*q+b*k*r-d*k*n-b*m*q-c*j*r;s.matrix[3][2]=d*g*n+b*h*q+c*f*r-b*g*r-c*h*n-d*f*q;s.matrix[3][3]=c*h*j+d*f*k+b*g*m-d*g*j-b*h*k-c*f*m;return s.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.0050>a&&-0.0050a&&-0.0050=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((d-e)*2*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((d-e)*2*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*d;return 1>=d?this.interpolated.set(d,-0.5*a*Math.pow(2,10*(d-=1))*Math.sin((d-e)*2*Math.PI/b)):this.interpolated.set(d,1+0.5*a*Math.pow(2,-10*(d-=1))*Math.sin((d-e)*2*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,d="@-"+a+"-keyframes "+b+" {",a=0;a<=c;a++)b=""+100*(a/c)+"%{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}}}}); +e=e.getPropertyName(b),"undefined"===typeof f[e]&&(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+";");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);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=""+100*(b/c)+"%{",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(1!==j.scaleX||1!==j.scaleY)h+=" scale("+j.scaleX+","+j.scaleY+")";h+=";";j.alpha&&(h+=" opacity: "+j.alpha+";");if(0.5!==d||0.5!==e)h+=" -"+a+"-transform-origin:"+100*d+"% "+100*e+"%;";f+=i+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(){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};this.autoRotate&&(a=0===a?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){"undefined"===typeof c&&(c=100);for(var c=c>> +0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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.0010);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);for(var c=c>>0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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){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){"undefined"===typeof c&&(c=100);for(var c=c>>0,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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,d,e="@-"+a+"-keyframes "+b+" {",b=0;b<=c;b++)d=""+100*(b/c)+"%{-"+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){var a=a.target,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=b/e,f,g,h,i,j,k,m,p,n,q,r,s,u,v;for(f=0;f>24&255;n=(m&16711680)>>16;q=(m&65280)>>8;m&=255;g=a[f+1];r=g>>24&255;s=(g&16711680)>>16;u=(g&65280)>>8;g&=255;r=(r-p)/b;s=(s-n)/b;u=(u-q)/b;v=(g-m)/b;for(g=0;g>0;i=n+s*g>>0;j=q+u*g>>0;k=m+v*g>>0;var t=CAAT.Module.ColorUtil.Color.RampEnumeration;switch(c){case t.RAMP_RGBA:d.push("argb("+h+","+i+","+j+","+k+")");break;case t.RAMP_RGB:d.push("rgb("+i+","+j+","+k+")");break;case t.RAMP_CHANNEL_RGB:d.push(4278190080| +i<<16|j<<8|k);break;case t.RAMP_CHANNEL_RGBA:d.push(h<<24|i<<16|j<<8|k);break;case t.RAMP_CHANNEL_RGBA_ARRAY:d.push([i,j,k,h]);break;case t.RAMP_CHANNEL_RGB_ARRAY:d.push([i,j,k])}}}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){var a=/(\d+)p[x|t]\s*/i.exec(a),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(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;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.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]= +c.width=a.height;c.height=a.width;var d=c.getContext("2d");d.globalAlpha=1;d.fillStyle="rgba(0,0,0,0)";d.clearRect(0,0,c.width,c.height);var e=new CAAT.Math.Matrix;e.multiply((new CAAT.Math.Matrix).setTranslate(c.width/2,c.width/2));e.multiply((new CAAT.Math.Matrix).setRotation(b*Math.PI/180));e.multiply((new CAAT.Math.Matrix).setTranslate(-c.width/2,-c.width/2));e.transformRenderingContext(d);d.drawImage(a,0,0);return c},optimize:function(a,b,c){var b=b>>0,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 i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,p=c.width-1,n=!1;if(d){for(d=0;db){n=!0;break}if(n)break}a=d}if(e){n=!1;for(d=c.height-1;d>=a;d--){for(j=0;jb){n=!0;break}if(n)break}k=d}if(f){n=!1;for(j=0;jb){n=!0;break}if(n)break}m=j}if(g){n=!1;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[4*d*c.width+3+4*j]>b){n=!0;break}if(n)break}p=j}if(0===m&&0===a&&c.width-1===p&&c.height-1===k)return c;b=p-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){"undefined"===typeof f&&(f=32);"undefined"===typeof g&&(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;cb;b++){if(this.quadData[b].intersects(a)){f=this.quadData[b].getOverlappingActors(a);c=0;for(d=f.length;c>0);this.ycache=[];for(e=0;e>0);this.xycache=[];for(e=0;e1&&this._solveCollisionCell(c,a)}},_solveCollisionCell:function(a,b){var c,d;for(c=0;c0&&this.freeChunks.splice(c++,0,{position:e,size:f});h>0&&this.freeChunks.splice(c,0,{position:g,size:h});return true}}return false},log:function(a){if(0===this.freeChunks.length)CAAT.log("index "+ -a+" empty");else{for(var a="index "+a,b=0;bthis.width||b>this.height)return null;for(var c,d,e=0;e<=this.scanMapHeight-b;){var f=null; -for(c=false;e<=this.scanMapHeight-b;e++)if(f=this.scanMap[e].findWhereFits(a),null!==f&&f.length>0){c=true;break}if(c){for(d=0;db.width?-1:0;else if(c.criteria==="height")return a.heightb.height?-1:0;return fg?-1:0});for(b=0;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)}})}}}); -(function(){CAAT.CSS={};CAAT.CSS.PREFIX=function(){for(var a="",b=["WebKit","Moz","O"],c=0;c=0;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;f>=0;f--)if((e[f].type===window.CSSRule.WEBKIT_KEYFRAMES_RULE||e[f].type===window.CSSRule.MOZ_KEYFRAMES_RULE)&&e[f].name===a)return{sheetIndex:c,index:f}}catch(g){}return null};CAAT.CSS.getCSSKeyframes= -function(a){for(var b=document.styleSheets,c=b.length-1;c>=0;c--)try{for(var d=b[c],e=d.cssRules?d.cssRules:d.rules?d.rules:[],f=e.length-1;f>=0;f--)if((e[f].type===window.CSSRule.WEBKIT_KEYFRAMES_RULE||e[f].type===window.CSSRule.MOZ_KEYFRAMES_RULE)&&e[f].name===a)return e[f]}catch(g){}return null}})(); -CAAT.Module({defines:"CAAT.PathUtil.PathSegment",depends:["CAAT.Math.Rectangle","CAAT.Math.Point","CAAT.Math.Matrix","CAAT.Math.Curve"],extendsWith:function(){return{__init:function(){this.bbox=new CAAT.Math.Rectangle;return this},color:"#000",length:0,bbox:null,parent:null,setParent:function(a){this.parent=a;return this},setColor:function(a){if(a)this.color=a;return this},endCurvePosition:function(){},startCurvePosition:function(){},setPoints:function(){},setPoint:function(){},getPosition:function(){}, -getLength:function(){return this.length},getBoundingBox:function(){return this.bbox},numControlPoints:function(){},getControlPoint:function(){},endPath:function(){},getContour:function(){},updatePath:function(){},applyAsPath:function(){},transform:function(){},drawHandle:function(a,b,c){a.beginPath();a.arc(b,c,CAAT.Math.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false);a.fill()}}}}); -CAAT.Module({defines:"CAAT.PathUtil.ArcPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.ArcPath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point;return this},points:null,cw:true,newPosition:null,radius:0,startAngle:0,angle:2*Math.PI,arcTo:false,setRadius:function(a){this.radius= -a;return this},isArcTo:function(){return this.arcTo},setArcTo:function(a){this.arcTo=a;return this},initialize:function(a,b,c,d){this.setInitialPosition(a,b);this.setFinalPosition(a+c,b);this.angle=d||2*Math.PI;return this},applyAsPath:function(a){a=a.ctx;this.arcTo?a.arcTo(this.points[0].x,this.points[0].y,this.points[1].x,this.points[1].y,this.radius):a.arc(this.points[0].x,this.points[0].y,this.radius,this.startAngle,this.angle+this.startAngle,this.cw);return this},setPoint:function(a,b){b>=0&& -b1||a<0)a%=1;a<0&&(a=1+a);-1===this.length?this.newPosition.set(this.points[0].x,this.points[0].y):(a=this.angle*a*(this.cw?1:-1)+this.startAngle,this.newPosition.set(this.points[0].x+this.radius*Math.cos(a),this.points[0].y+this.radius*Math.sin(a)));return this.newPosition},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.ctx;c.save(); +CAAT.Module({defines:"CAAT.Module.Initialization.Template",depends:["CAAT.Foundation.Director","CAAT.Module.Preloader.ImagePreloader"],constants:{init:function(a,b,c,d,e){var c=document.getElementById(c),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 i(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))}var c=document.getElementById(c),j; +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 k=document.createElement("canvas");c.appendChild(k);c=k}else!1==c instanceof HTMLCanvasElement&&(k=document.createElement("canvas"),document.body.appendChild(k),c=k);else c=document.createElement("canvas"),document.body.appendChild(c);j=(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});j.setClear(CAAT.Foundation.Director.CLEAR_DIRTY_RECTS);(new CAAT.Module.Preloader.ImagePreloader).loadImages(a,function(a,b){if(a===b.length){j.setImagesCache(b);var c=d||5E3,g=j.getImage("spinner"),h=j.getImage("splash"),k=j.createScene(),u=(new Date).getTime();h&&k.addChild((new CAAT.Foundation.Actor).setBackgroundImage(h,!1).setBounds(0,0,j.width,j.height).setImageTransformation(CAAT.Foundation.SpriteImage.TR_FIXED_TO_SIZE));g&&k.addChild((new CAAT.Foundation.Actor).setBackgroundImage(g).centerAt(k.width/ +2,k.height/2).addBehavior((new CAAT.Behavior.RotateBehavior).setValues(0,2*Math.PI).setFrameTime(0,1E3).setCycle(!0)));k.loadedImage=function(a,b){if(!b||a===b.length){var d=(new Date).getTime()-u;dc&&(d=c),setTimeout(function(){i(j,b,f)},d)):i(j,b,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 i=new CAAT.Math.Bezier;i.setCubic(a,b,c,d,e,f,g,h);this.curve=i;this.updatePath();return this},updatePath:function(){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(){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(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(){var a=[];a.push(this.getPosition(0).clone());a.push(this.getPosition(1).clone());return a}}}}); CAAT.Module({defines:"CAAT.PathUtil.RectPath",depends:["CAAT.PathUtil.PathSegment","CAAT.Math.Point","CAAT.Math.Rectangle"],aliases:["CAAT.RectPath","CAAT.ShapePath"],extendsClass:"CAAT.PathUtil.PathSegment",extendsWith:function(){return{__init:function(){this.__super();this.points=[];this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.points.push(new CAAT.Math.Point);this.newPosition=new CAAT.Math.Point; -return this},points:null,cw:true,newPosition:null,applyAsPath:function(a){a=a.ctx;this.cw?(a.lineTo(this.points[0].x,this.points[0].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[4].x,this.points[4].y)):(a.lineTo(this.points[4].x,this.points[4].y),a.lineTo(this.points[3].x,this.points[3].y),a.lineTo(this.points[2].x,this.points[2].y),a.lineTo(this.points[1].x,this.points[1].y),a.lineTo(this.points[0].x, -this.points[0].y));return this},setPoint:function(a,b){b>=0&&b1||a<0)a%=1; -a<0&&(a=1+a);if(-1===this.length)this.newPosition.set(0,0);else{var b=this.bbox.width/this.length,c=this.bbox.height/this.length,d=0,e,f=0;this.cw?(e=[0,1,2,3,4],b=[b,c,b,c]):(e=[4,3,2,1,0],b=[c,b,c,b]);for(;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=0&&b="0"&&a<="9"},__getNumber:function(a,c,d,e){c=this.__skipBlank(a,c);if(c=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.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(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,i;e!==f;){g=(f+e)/2|0;i=c[g];if(i<=a&&a<=i+d[g])return a=d[g]?(a-i)/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&&ad&&(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);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){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,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.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, +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, -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}}}}); +getWidth:function(){var a=this.mapInfo[this.spriteIndex];if(null===a||"undefined"===typeof a)console.log(this.mapInfo),console.log(this.spriteIndex);return a.width},getHeight:function(){return this.mapInfo[this.spriteIndex].height},getWrappedImageWidth:function(){return this.image.width},getWrappedImageHeight:function(){return this.image.height},getRef:function(){var a=new CAAT.Foundation.SpriteImage;a.image=this.image;a.rows=this.rows;a.columns=this.columns;a.width=this.width;a.height=this.height; +a.singleWidth=this.singleWidth;a.singleHeight=this.singleHeight;a.mapInfo=this.mapInfo;a.offsetX=this.offsetX;a.offsetY=this.offsetY;a.scaleX=this.scaleX;a.scaleY=this.scaleY;a.animationsMap=this.animationsMap;a.parentOffsetX=this.parentOffsetX;a.parentOffsetY=this.parentOffsetY;a.scaleFont=this.scaleFont;a.spriteIndex=this.spriteIndex;return a},setOffsetX:function(a){this.offsetX=a;return this},setOffsetY:function(a){this.offsetY=a;return this},setOffset:function(a,b){this.offsetX=a;this.offsetY= +b;return this},initialize:function(a,b,c){a||console.log("Null image for SpriteImage.");isString(a)&&(a=CAAT.currentDirector.getImage(a));this.parentOffsetY=this.parentOffsetX=0;this.rows=b;this.columns=c;if(a instanceof CAAT.Foundation.SpriteImage||a instanceof CAAT.SpriteImage){this.image=a.image;var d=a.mapInfo[0];this.width=d.width;this.height=d.height;this.parentOffsetX=d.x;this.parentOffsetY=d.y;this.width=a.mapInfo[0].width;this.height=a.mapInfo[0].height}else this.image=a,this.width=a.width, +this.height=a.height,this.mapInfo={};this.singleWidth=Math.floor(this.width/c);this.singleHeight=Math.floor(this.height/b);var e,f,g;if(a.__texturePage){a.__du=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);for(var a=this.image.__tx,i=this.image.__ty,j=this.image.__texturePage,d=0;d>0)*e;var k=i+(d/h>>0)*f,m=g+e,p=k+f;g=(new CAAT.Foundation.SpriteImageHelper(g, +k,m-g,p-k,j.width,j.height)).setGL(g/j.width,k/j.height,m/j.width,p/j.height);this.mapInfo[d]=g}}else for(d=0;d>0)+1,e=((c.height-g)/e>>0)+1,h,i=a.ctx,a=0;a>0,c.y-this.ownerActor.y+g+a*b.height>>0,b.width,b.height)},paintInvertedH:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((c|0)+b.width,d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0, +d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c|0,d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image, +b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintAtRect:function(a,b,c,d,e,f){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,e,f);return this},paintScaledWidth:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,b.height);return this},paintChunk:function(a,b,c,d,e,f,g){a.drawImage(this.image, +d,e,f,g,b,c,f,g)},paintTile:function(a,b,c,d){b=this.mapInfo[b];a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,b.width,b.height);return this},paintScaled:function(a,b,c,d){b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX+c>>0,this.offsetY+d>>0,this.ownerActor.width,this.ownerActor.height);return this},getCurrentSpriteImageCSSPosition:function(){var a=this.mapInfo[this.spriteIndex];return""+-(a.x+this.parentOffsetX- +this.offsetX)+"px "+-(a.y+this.parentOffsetY-this.offsetY)+"px "+(this.ownerActor.transformation===CAAT.Foundation.SpriteImage.TR_TILE?"repeat":"no-repeat")},getNumImages:function(){return this.rows*this.columns},setUV:function(a,b){var c=this.image;if(c.__texturePage){var d=b,e=this.mapInfo[this.spriteIndex],f=e.u,g=e.v,h=e.u1,e=e.v1;if(this.offsetX||this.offsetY)f=c.__texturePage,g=-this.offsetY/f.height,h=(this.ownerActor.width-this.offsetX)/f.width,e=(this.ownerActor.height-this.offsetY)/f.height, +f=-this.offsetX/f.width+c.__u,g+=c.__v,h+=c.__u,e+=c.__v;c.inverted?(a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e,a[d++]=f,a[d++]=g):(a[d++]=f,a[d++]=g,a[d++]=h,a[d++]=g,a[d++]=h,a[d++]=e,a[d++]=f,a[d++]=e)}},setChangeFPS:function(a){this.changeFPS=a;return this},setSpriteTransformation:function(a){this.transformation=a;var b=CAAT.Foundation.SpriteImage;switch(a){case b.TR_FLIP_HORIZONTAL:this.paint=this.paintInvertedH;break;case b.TR_FLIP_VERTICAL:this.paint=this.paintInvertedV;break;case b.TR_FLIP_ALL:this.paint= +this.paintInvertedHV;break;case b.TR_FIXED_TO_SIZE:this.paint=this.paintScaled;break;case b.TR_FIXED_WIDTH_TO_SIZE:this.paint=this.paintScaledWidth;break;case b.TR_TILE:this.paint=this.paintTiled;break;default:this.paint=this.paintN}this.ownerActor.invalidate();return this},resetAnimationTime:function(){this.prevAnimationTime=-1;return this},setAnimationImageIndex:function(a){this.animationImageIndex=a;this.spriteIndex=a[0];this.prevAnimationTime=-1;return this},setSpriteIndex:function(a){this.spriteIndex= +a;return this},setSpriteIndexAtTime:function(a){if(1>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 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=!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){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 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||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(){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;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:!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(){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(){this.enabled&& +(this.setSpriteIndex(this.iNormal),this.dragging=!1)};this.mouseClick=function(){};this.mouseDrag=function(){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(){},mouseExit:function(){},mouseMove:function(){},mouseDown:function(){},mouseUp:function(){},mouseDrag:function(){},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;bd.x||(0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,c);0>d.x||(0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,a);(b.dragging||!(0>d.x||0>d.y||d.x>=b.width||d.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 d=b.mousePoint;b.getCanvasCoord(d,c);0>d.x||(0>d.y||d.x>=b.width||d.y>=b.height)||b.__mouseDBLClickHandler(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: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= +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!==p&&(n=f.substr(d+1,p-d-1),-1!==n.indexOf("<")?(this.rc.fchar(q),d+=1):(this.rc.setTag(n),d=p+1))):(this.rc.fchar(q),d+=1);this.rc.end();this.lines=this.rc.lines;this.__calculateDocumentDimension("undefined"===typeof b?0:b);this.setLinesAlignment();r.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(){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){if((this.bOutline=a)&&b)this.outlineColor=b;return this},setInteractive:function(a){this.interactive=a;this.path&&this.path.setInteractive(a);return this},setOnUpdateCallback:function(a){this.onUpdateCallback= a;return this},mouseDrag:function(a){this.path.drag(a.point.x,a.point.y,this.onUpdateCallback)},mouseDown:function(a){this.path.press(a.point.x,a.point.y)},mouseUp:function(){this.path.release()}}}); CAAT.Module({defines:"CAAT.Foundation.UI.ShapeActor",aliases:["CAAT.ShapeActor"],extendsClass:"CAAT.Foundation.ActorContainer",depends:["CAAT.Foundation.ActorContainer"],constants:{SHAPE_CIRCLE:0,SHAPE_RECTANGLE:1},extendsWith:{__init:function(){this.__super();this.compositeOp="source-over";this.setShape(CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE);return this},shape:0,compositeOp:null,lineWidth:1,lineCap:null,lineJoin:null,miterLimit:null,setLineWidth:function(a){this.lineWidth=a;return this},setLineCap:function(a){this.lineCap= a;return this},setLineJoin:function(a){this.lineJoin=a;return this},setMiterLimit:function(a){this.miterLimit=a;return this},getLineCap:function(){return this.lineCap},getLineJoin:function(){return this.lineJoin},getMiterLimit:function(){return this.miterLimit},getLineWidth:function(){return this.lineWidth},setShape:function(a){this.shape=a;this.paint=this.shape===CAAT.Foundation.UI.ShapeActor.SHAPE_CIRCLE?this.paintCircle:this.paintRectangle;return this},setCompositeOp:function(a){this.compositeOp= -a;return this},paint:function(){},paintCircle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.arc(this.width/2,this.height/2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.arc(this.width/2,this.height/ -2,Math.min(this.width,this.height)/2-this.lineWidth/2,0,2*Math.PI,false),c.stroke()}},paintRectangle:function(a,b){if(this.cached)CAAT.Foundation.ActorContainer.prototype.paint.call(this,a,b);else{var c=a.ctx;c.lineWidth=this.lineWidth;if(this.lineCap)c.lineCap=this.lineCap;if(this.lineJoin)c.lineJoin=this.lineJoin;if(this.miterLimit)c.miterLimit=this.miterLimit;c.globalCompositeOperation=this.compositeOp;if(null!==this.fillStyle)c.fillStyle=this.fillStyle,c.beginPath(),c.fillRect(0,0,this.width, -this.height),c.fill();if(null!==this.strokeStyle)c.strokeStyle=this.strokeStyle,c.beginPath(),c.strokeRect(0,0,this.width,this.height),c.stroke()}}}}); +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;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+=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) { if (c[n] === behavior) { c.splice(n, 1); return this; } + n = n - 1; } return this; }, @@ -19178,7 +19202,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 +19222,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; }, @@ -20719,6 +20743,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 +20772,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 +21971,6 @@ CAAT.Module({ getValueForKey : function( key ) { return this.__map[key]; - return this; }, createTimer:function (startTime, duration, callback_timeout, callback_tick, callback_cancel) { @@ -22616,7 +22651,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 +22854,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 +23112,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 +23494,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,7 +23561,7 @@ 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; @@ -25018,44 +25095,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, - sfont : 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, - 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 +25238,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/version.compile.pack.sh b/version.compile.pack.sh index 823c4c6e..8cbc618c 100755 --- a/version.compile.pack.sh +++ b/version.compile.pack.sh @@ -3,27 +3,27 @@ # version.nfo contains new version value. #i source ./version.compile.variables.sh -./version.sh +#./version.sh VERSION=`cat version.nfo` -echo "New generated version: ${VERSION}" +echo "Version: ${VERSION}" CAAT_DST="/tmp/caat" DST_FILE_NAME="${CAAT_DST}"; -VERSION=`cat version.nfo` +#VERSION=`cat version.nfo` 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 +121,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 +134,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}" @@ -225,7 +225,7 @@ more ./src/Foundation/SpriteImageAnimationHelper.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/SpriteImage.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/ActorCSS.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/ActorContainerCSS.js >> "${FILE_CAAT_CSS}" -more ./src/Foundation/SceneCSS.js >> "${FILE_CAAT_CSS}" +#more ./src/Foundation/SceneCSS.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/Director.js >> "${FILE_CAAT_CSS}" more ./src/Foundation/UI/Dock.js >> "${FILE_CAAT_CSS}" @@ -236,34 +236,36 @@ 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} + +rm -rf ${CAAT_DST} diff --git a/version.compile.sh b/version.compile.sh index ea66242f..0a40392d 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} @@ -54,41 +54,41 @@ fi # execute version procedure. # version.nfo contains new version value. # -./version.sh +#./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 "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,7 @@ cp ${FILE_CAAT_BOX2D} ${CAAT_BUILD_DIR} # # Generating JSDoc. # -echo "\nGenerating JSDoc" -./version.compile.doc.sh +#echo -e "\nGenerating JSDoc" +#./version.compile.doc.sh + +rm -f /tmp/caat* diff --git a/version.compile.variables.sh b/version.compile.variables.sh index ff4627c0..da42510c 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_CLOSURE_PATH=${CAAT_CLOSURE_PATH:-../../tools/closure-compiler} CAAT_JSDOC_TOOLKIT_PATH=${CAAT_JSDOC_TOOLKIT_PATH:-/Users/ibon/applications/jsdoc-toolkit} From 795700ed7852ecc7ebf0d35c4bf4ff6aa3fed976 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Fri, 22 Nov 2013 18:54:28 +0100 Subject: [PATCH 09/11] Fixing WebGL. Initialize proper context in case of webgl throughout caat. Fixes the following errors: WebGL: INVALID_VALUE: vertexAttribPointer: bad size, stride or offset WebGL: INVALID_OPERATION: uniformMatrix4fv: location is not from current program --- src/Foundation/Actor.js | 2 +- src/Foundation/Director.js | 19 +++++++++++++++---- src/Foundation/SpriteImage.js | 2 +- src/Modules/TexturePacker/TexturePage.js | 4 ++-- src/WebGL/ColorProgram.js | 2 +- src/WebGL/Program.js | 1 + 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Foundation/Actor.js b/src/Foundation/Actor.js index cda4acce..ee63a640 100644 --- a/src/Foundation/Actor.js +++ b/src/Foundation/Actor.js @@ -2328,7 +2328,7 @@ CAAT.Module({ glSetShader:function (director) { var tp = this.getTextureGLPage(); - if (tp !== director.currentTexturePage) { + if (tp && tp !== director.currentTexturePage) { director.setGLTexturePage(tp); } diff --git a/src/Foundation/Director.js b/src/Foundation/Director.js index f98a2074..de8445cf 100644 --- a/src/Foundation/Director.js +++ b/src/Foundation/Director.js @@ -516,7 +516,12 @@ CAAT.Module({ this.canvas.width = this.referenceWidth * factor; this.canvas.height = this.referenceHeight * factor; - this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + if (this.glEnabled) { + this.ctx = this.canvas.getContext('webgl') || this.canvas.getContext('experimental-webgl'); + } + else { + this.ctx = this.canvas.getContext('2d'); + } this.__setupRetina(); @@ -620,7 +625,12 @@ CAAT.Module({ this.canvas.height = h; } - this.ctx = this.canvas.getContext(this.glEnabled ? 'experimental-webgl' : '2d'); + if (this.gl) { + this.ctx = this.canvas.getContext('webgl') || this.canvas.getContext('experimental-webgl'); + } + else { + this.ctx = this.canvas.getContext('2d'); + } this.__setupRetina(); @@ -718,7 +728,7 @@ CAAT.Module({ var i; try { - this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); + this.gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); this.gl.viewportWidth = width; this.gl.viewportHeight = height; CAAT.GLRENDER = true; @@ -759,6 +769,7 @@ CAAT.Module({ this.checkDebug(); } else { // fallback to non gl enabled canvas. + CAAT.log("WebGL not supported, falling back to 2D canvas.") return this.initialize(width, height, canvas); } @@ -1443,7 +1454,7 @@ CAAT.Module({ var ssin = this.scenes[ inSceneIndex ]; var sout = this.scenes[ outSceneIndex ]; - if (!CAAT.__CSS__ && CAAT.CACHE_SCENE_ON_CHANGE) { + if (!CAAT.__CSS__ && !this.glEnabled && CAAT.CACHE_SCENE_ON_CHANGE) { this.renderToContext(this.transitionScene.ctx, sout); sout = this.transitionScene; } diff --git a/src/Foundation/SpriteImage.js b/src/Foundation/SpriteImage.js index 3f773d33..27e4fd5d 100644 --- a/src/Foundation/SpriteImage.js +++ b/src/Foundation/SpriteImage.js @@ -325,7 +325,7 @@ CAAT.Module({ initialize:function (image, rows, columns) { if (!image) { - console.log("Null image for SpriteImage."); + CAAT.log("Error: got null instead of image object."); } if ( isString(image) ) { diff --git a/src/Modules/TexturePacker/TexturePage.js b/src/Modules/TexturePacker/TexturePage.js index 82f32b1e..aeaaad5a 100644 --- a/src/Modules/TexturePacker/TexturePage.js +++ b/src/Modules/TexturePacker/TexturePage.js @@ -284,8 +284,8 @@ CAAT.Module( { img.__h= newHeight; this.scan.substract(where.x,where.y,w,h); - } else { - CAAT.log('Imagen ',img.src,' de tamano ',img.width,img.height,' no cabe.'); +// } else { +// CAAT.log('Image ',img.src,' of size ',img.width,img.height,' does not fit into texture page.'); } }, changeHeuristic : function(criteria) { diff --git a/src/WebGL/ColorProgram.js b/src/WebGL/ColorProgram.js index 665a6b8c..4635ebf6 100644 --- a/src/WebGL/ColorProgram.js +++ b/src/WebGL/ColorProgram.js @@ -102,7 +102,7 @@ CAAT.Module( { this.gl.vertexAttribPointer( this.shaderProgram.vertexColorAttribute, - this.colorBuffer, + 4, this.gl.FLOAT, false, 0, diff --git a/src/WebGL/Program.js b/src/WebGL/Program.js index 73a0b8b3..a932ae3e 100644 --- a/src/WebGL/Program.js +++ b/src/WebGL/Program.js @@ -122,6 +122,7 @@ CAAT.Module( { return this; }, setMatrixUniform : function( caatMatrix4 ) { + this.gl.useProgram(this.shaderProgram); this.gl.uniformMatrix4fv( this.shaderProgram.pMatrixUniform, false, From 99bbab3f5654e2f9d465f3be51ebe10cd4c81378 Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Fri, 22 Nov 2013 18:59:18 +0100 Subject: [PATCH 10/11] Enable demo menu also for local access --- documentation/demos/menu/menu.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/documentation/demos/menu/menu.js b/documentation/demos/menu/menu.js index d4a50972..166bc5de 100644 --- a/documentation/demos/menu/menu.js +++ b/documentation/demos/menu/menu.js @@ -29,7 +29,8 @@ function processReqChange() { if (req.readyState == 4) { - if (req.status == 200) { + // status is 0 for local resources accessed via file:// + if (!req.status && req.response || req.status >= 200 && req.status < 300 || req.status === 304 ? req : null) { var menu= document.getElementById('menu'); menu.innerHTML= req.responseText; } else { @@ -40,4 +41,4 @@ window.addEventListener('load',loadXMLDoc,false); -})(); \ No newline at end of file +})(); From 2d251452a53379941cfe30a855ad4a9d5657b81b Mon Sep 17 00:00:00 2001 From: Arne Brutschy Date: Fri, 22 Nov 2013 19:39:40 +0100 Subject: [PATCH 11/11] Added renderer selection to demo27, demo35 and demo4 --- documentation/demos/demo27/font.html | 90 ++++++++++++++----- documentation/demos/demo35/label.html | 70 +++++++++++---- .../demos/demo4/coordinates_org.html | 67 +++++++++++--- 3 files changed, 177 insertions(+), 50 deletions(-) diff --git a/documentation/demos/demo27/font.html b/documentation/demos/demo27/font.html index d3deaaaf..1faa611c 100644 --- a/documentation/demos/demo27/font.html +++ b/documentation/demos/demo27/font.html @@ -19,8 +19,8 @@
    -
    @@ -90,6 +89,47 @@

    CAAT.Font

    */ (function() { + + function getRequestParameter(name) { + if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) + return decodeURIComponent(name[1]); + } + var renderer = getRequestParameter('renderer'); + var modulesToLoad; + if (renderer === "css") { + modulesToLoad = [ + "CAAT.PathUtil.Path", + "CAAT.Foundation.Director", + "CAAT.Foundation.ActorCSS", + "CAAT.Foundation.ActorContainerCSS", + "CAAT.Foundation.SpriteImage", + "CAAT.Foundation.UI.TextActor", + "CAAT.Math.Point", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.Interpolator", + "CAAT.Module.Font.Font", + "CAAT.Module.ColorUtil.Color" + ]; + CAAT.__CSS__=1; + } + else { + modulesToLoad = [ + "CAAT.PathUtil.Path", + "CAAT.Foundation.Director", + "CAAT.Foundation.Actor", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.SpriteImage", + "CAAT.Foundation.UI.TextActor", + "CAAT.Math.Point", + "CAAT.Behavior.PathBehavior", + "CAAT.Behavior.RotateBehavior", + "CAAT.Behavior.Interpolator", + "CAAT.Module.Font.Font", + "CAAT.Module.ColorUtil.Color" + ]; + } + /** * Startup it all up when the document is ready. * Change for your favorite frameworks initialization code. @@ -110,20 +150,7 @@

    CAAT.Font

    setModulePath("CAAT.WebGL", "WebGL"). // get modules, and solve their dependencies. - bring([ - "CAAT.PathUtil.Path", - "CAAT.Foundation.Director", - "CAAT.Foundation.Actor", - "CAAT.Foundation.ActorContainer", - "CAAT.Foundation.SpriteImage", - "CAAT.Foundation.UI.TextActor", - "CAAT.Math.Point", - "CAAT.Behavior.PathBehavior", - "CAAT.Behavior.RotateBehavior", - "CAAT.Behavior.Interpolator", - "CAAT.Module.Font.Font", - "CAAT.Module.ColorUtil.Color" - ]). + bring(modulesToLoad). // this function will be fired every time all dependencies have been solved. // if you call again bring, this function could be fired again. @@ -132,14 +159,35 @@

    CAAT.Font

    function textOnPath(director) { - var director= new CAAT.Foundation.Director().initialize(800,500,'experiment-canvas'); + var container = document.getElementById("experiment-holder"); + var director; + var container; + if (renderer === 'css') { + console.log("Using css renderer"); + canvas = document.createElement("div"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } + else if (renderer === 'webgl') { + console.log("Using WebGL renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initializeGL(800,500,canvas); + } + else { + console.log("Using canvas renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } var scene = director.createScene(); - var gradient = director.ctx.createLinearGradient(0, -30, 0, 100); +/* var gradient = director.ctx.createLinearGradient(0, -30, 0, 100); gradient.addColorStop(0, '#ff0'); gradient.addColorStop(0.5, '#f00'); gradient.addColorStop(1, 'blue'); - +*/ + gradient = 'blue'; var font_baumans= new CAAT.Module.Font.Font(). setFont('"Baumans"'). setFontSize(100,"px"). @@ -191,4 +239,4 @@

    CAAT.Font

    })(); - \ No newline at end of file + diff --git a/documentation/demos/demo35/label.html b/documentation/demos/demo35/label.html index efb1cfcf..cfeaaf6f 100644 --- a/documentation/demos/demo35/label.html +++ b/documentation/demos/demo35/label.html @@ -12,8 +12,8 @@
    -
    @@ -86,6 +85,36 @@

    Label - Reload for new layouts

    */ (function() { + function getRequestParameter(name) { + if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) + return decodeURIComponent(name[1]); + } + var renderer = getRequestParameter('renderer'); + var modulesToLoad; + if (renderer === "css") { + modulesToLoad = [ + "CAAT.Foundation.Director", + "CAAT.Foundation.ActorCSS", + "CAAT.Foundation.ActorContainerCSS", + "CAAT.Foundation.SpriteImage", + "CAAT.Foundation.UI.Label", + "CAAT.Module.ColorUtil.Color", + "CAAT.Module.Preloader.Preloader" + ]; + CAAT.__CSS__=1; + } + else { + modulesToLoad = [ + "CAAT.Foundation.Director", + "CAAT.Foundation.Actor", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.SpriteImage", + "CAAT.Foundation.UI.Label", + "CAAT.Module.ColorUtil.Color", + "CAAT.Module.Preloader.Preloader" + ]; + } + /** * Startup it all up when the document is ready. * Change for your favorite frameworks initialization code. @@ -107,16 +136,7 @@

    Label - Reload for new layouts

    setModulePath("CAAT.WebGL", "WebGL"). // get modules, and solve their dependencies. - bring( - [ - "CAAT.Foundation.Director", - "CAAT.Foundation.Actor", - "CAAT.Foundation.ActorContainer", - "CAAT.Foundation.SpriteImage", - "CAAT.Foundation.UI.Label", - "CAAT.Module.ColorUtil.Color", - "CAAT.Module.Preloader.Preloader" - ]). + bring(modulesToLoad). // this function will be firer every time all dependencies have been solved. // if you call again bring, this function could be fired again. @@ -185,7 +205,27 @@

    Label - Reload for new layouts

    CAAT.DEBUG=1; - var director= new CAAT.Foundation.Director().initialize( 800,500,'experiment-canvas' ); + var container = document.getElementById("experiment-holder"); + var director; + var container; + if (renderer === 'css') { + console.log("Using css renderer"); + canvas = document.createElement("div"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } + else if (renderer === 'webgl') { + console.log("Using WebGL renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initializeGL(800,500,canvas); + } + else { + console.log("Using canvas renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } director.setImagesCache( images ); var scene = director.createScene(); @@ -205,4 +245,4 @@

    Label - Reload for new layouts

    })(); - \ No newline at end of file + diff --git a/documentation/demos/demo4/coordinates_org.html b/documentation/demos/demo4/coordinates_org.html index cd99a599..1eb940a1 100644 --- a/documentation/demos/demo4/coordinates_org.html +++ b/documentation/demos/demo4/coordinates_org.html @@ -12,8 +12,8 @@
    -
    @@ -98,6 +97,34 @@

    Homogeneous coordinates

    (function() { + function getRequestParameter(name) { + if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) + return decodeURIComponent(name[1]); + } + var renderer = getRequestParameter('renderer'); + var modulesToLoad; + if (renderer === "css") { + modulesToLoad = [ + "CAAT.Foundation.Director", + "CAAT.Foundation.ActorCSS", + "CAAT.Foundation.ActorContainerCSS", + "CAAT.Foundation.UI.TextActor", + "CAAT.Behavior.Interpolator", + "CAAT.Behavior.RotateBehavior" + ]; + CAAT.__CSS__=1; + } + else { + modulesToLoad = [ + "CAAT.Foundation.Director", + "CAAT.Foundation.Actor", + "CAAT.Foundation.ActorContainer", + "CAAT.Foundation.UI.TextActor", + "CAAT.Behavior.Interpolator", + "CAAT.Behavior.RotateBehavior" + ]; + } + window.addEventListener('load',load,false); function load() { @@ -114,15 +141,7 @@

    Homogeneous coordinates

    setModulePath("CAAT.WebGL", "WebGL"). // get modules, and solve their dependencies. - bring( - [ - "CAAT.Foundation.Director", - "CAAT.Foundation.Actor", - "CAAT.Foundation.ActorContainer", - "CAAT.Foundation.UI.TextActor", - "CAAT.Behavior.Interpolator", - "CAAT.Behavior.RotateBehavior" - ]). + bring(modulesToLoad). // this function will be firer every time all dependencies have been solved. // if you call again bring, this function could be fired again. @@ -131,7 +150,27 @@

    Homogeneous coordinates

    function __coordinates() { - var director= new CAAT.Foundation.Director().initialize( 800,500,'experiment-canvas' ); + var container = document.getElementById("experiment-holder"); + var director; + var container; + if (renderer === 'css') { + console.log("Using css renderer"); + canvas = document.createElement("div"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } + else if (renderer === 'webgl') { + console.log("Using WebGL renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initializeGL(800,500,canvas); + } + else { + console.log("Using canvas renderer"); + canvas = document.createElement("canvas"); + container.appendChild(canvas); + director= new CAAT.Foundation.Director().initialize(800,500,canvas); + } var scene= director.createScene(); @@ -391,4 +430,4 @@

    Homogeneous coordinates

    })(); - \ No newline at end of file +