From 1a77f74eaa0e44d6804a29a94ddebbc3e37b7ad9 Mon Sep 17 00:00:00 2001 From: hyperandroid Date: Tue, 21 Feb 2012 00:10:31 +0100 Subject: [PATCH] 02/21/2012 *0.3 Build 180* -------------------------- * Fixed (at last) Catmull Rom splines as CAAT.Path objects. * Added CAAT.Path.flatten method to turn a compound path of patches into a polyline. * Added CAAT.PathActor.setOnUpdateCallback --- build/caat-box2d-min.js | 6 +- build/caat-box2d.js | 6 +- build/caat-css-min.js | 126 +- build/caat-css.js | 276 +- build/caat-min.js | 132 +- build/caat.js | 283 +- changelog | 9 +- documentation/demos/demo1/path_org.html | 76 +- documentation/jsdoc/files.html | 2 +- documentation/jsdoc/index.html | 2 +- documentation/jsdoc/symbols/CAAT.Actor.html | 2 +- .../jsdoc/symbols/CAAT.ActorContainer.html | 36 +- .../jsdoc/symbols/CAAT.AudioManager.html | 2 +- .../jsdoc/symbols/CAAT.B2DBodyActor.html | 2 +- .../jsdoc/symbols/CAAT.B2DCircularBody.html | 2 +- .../jsdoc/symbols/CAAT.B2DPolygonBody.html | 2 +- documentation/jsdoc/symbols/CAAT.Bezier.html | 2 +- .../jsdoc/symbols/CAAT.CatmullRom.html | 49 +- .../jsdoc/symbols/CAAT.Color.RGB.html | 2 +- documentation/jsdoc/symbols/CAAT.Color.html | 2 +- documentation/jsdoc/symbols/CAAT.Curve.html | 2 +- .../jsdoc/symbols/CAAT.CurvePath.html | 4 +- .../jsdoc/symbols/CAAT.Director.html | 4 +- documentation/jsdoc/symbols/CAAT.Font.html | 2 +- documentation/jsdoc/symbols/CAAT.IMActor.html | 4 +- documentation/jsdoc/symbols/CAAT.IMBump.html | 2 +- .../jsdoc/symbols/CAAT.IMPlasma.html | 2 +- .../jsdoc/symbols/CAAT.IMRotoZoom.html | 2 +- .../jsdoc/symbols/CAAT.ImagePreloader.html | 2 +- .../jsdoc/symbols/CAAT.ImageProcessor.html | 2 +- .../jsdoc/symbols/CAAT.Interpolator.html | 2 +- .../jsdoc/symbols/CAAT.InterpolatorActor.html | 4 +- .../jsdoc/symbols/CAAT.KeyEvent.html | 2 +- .../jsdoc/symbols/CAAT.LinearPath.html | 49 +- documentation/jsdoc/symbols/CAAT.Matrix3.html | 2 +- .../jsdoc/symbols/CAAT.MatrixStack.html | 2 +- .../jsdoc/symbols/CAAT.MouseEvent.html | 2 +- documentation/jsdoc/symbols/CAAT.Path.html | 126 +- .../jsdoc/symbols/CAAT.PathActor.html | 49 +- .../jsdoc/symbols/CAAT.PathSegment.html | 59 +- documentation/jsdoc/symbols/CAAT.Point.html | 2 +- .../jsdoc/symbols/CAAT.Rectangle.html | 2 +- documentation/jsdoc/symbols/CAAT.Scene.html | 4 +- .../jsdoc/symbols/CAAT.ShapeActor.html | 4 +- .../jsdoc/symbols/CAAT.SpriteImage.html | 2 +- .../jsdoc/symbols/CAAT.StarActor.html | 4 +- .../jsdoc/symbols/CAAT.TextActor.html | 4 +- .../jsdoc/symbols/CAAT.TimerTask.html | 2 +- documentation/jsdoc/symbols/CAAT.html | 2 +- ...AT.modules.CircleManager.PackedCircle.html | 2 +- ...les.CircleManager.PackedCircleManager.html | 2 +- .../symbols/CAAT.modules.CircleManager.html | 2 +- .../symbols/CAAT.modules.LocalStorage.html | 2 +- documentation/jsdoc/symbols/CAAT.modules.html | 2 +- documentation/jsdoc/symbols/Function.html | 2 +- documentation/jsdoc/symbols/_global_.html | 2 +- ...rs_ibon_js_CAAT_src_model_director.js.html | 3512 +++++++++-------- src/math/bezier.js | 66 +- src/model/actor.js | 7 +- src/model/director.js | 6 +- src/path/path.js | 154 +- src/path/pathactor.js | 36 +- 62 files changed, 2928 insertions(+), 2235 deletions(-) diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index 47595805..5c5beffc 100644 --- a/build/caat-box2d-min.js +++ b/build/caat-box2d-min.js @@ -22,11 +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.3 build: 138 +Version: 0.3 build: 180 Created on: -DATE: 2012-02-15 -TIME: 23:44:52 +DATE: 2012-02-20 +TIME: 23:55:10 */ diff --git a/build/caat-box2d.js b/build/caat-box2d.js index f6058ac2..223d7b2c 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.3 build: 139 +Version: 0.3 build: 181 Created on: -DATE: 2012-02-15 -TIME: 23:45:17 +DATE: 2012-02-20 +TIME: 23:55:34 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index b1affbca..9e0be9de 100644 --- a/build/caat-css-min.js +++ b/build/caat-css-min.js @@ -22,15 +22,15 @@ 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.3 build: 138 +Version: 0.3 build: 180 Created on: -DATE: 2012-02-15 -TIME: 23:44:52 +DATE: 2012-02-20 +TIME: 23:55:10 */ -var CAAT=CAAT||{};Function.prototype.bind=Function.prototype.bind||function(){var a=this,b=Array.prototype.slice.call(arguments),c=b.shift();return function(){return a.apply(c,b.concat(Array.prototype.slice.call(arguments)))}};CAAT.__CSS__=1;CAAT.__CSS__=1;(function(){CAAT.BrowserDetect=function(){this.init();return this};CAAT.BrowserDetect.prototype={browser:"",version:0,OS:"",init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";this.OS=this.searchString(this.dataOS)||"an unknown OS"},searchString:function(a){for(var b=0;b>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],m=((k d);return this},contains:function(a,b){return a>=0&&a=0&&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.x1this.x1?false:a.y1this.y1?false:true},intersectsRect:function(a,b,c,d){return-1===c||-1===d?false:a+c-1this.x1?false:b+d-1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1, a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= -0.5;for(var b=0;b=0&&ba*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.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)}}})();(function(){CAAT.QuadTree=function(){return this};CAAT.QuadTree.prototype={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.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.QuadTree).create(h, @@ -180,36 +180,36 @@ glTtextureProgram:null,glColorProgram:null,pMatrix:null,coords:null,coordsIndex: (new CAAT.Debug).initialize(this.width,60);this.debugInfo=a.debugInfo.bind(a)}},getRenderType:function(){return this.glEnabled?"WEBGL":"CANVAS"},windowResized:function(a,b){switch(this.resize){case this.RESIZE_WIDTH:this.setBounds(0,0,a,this.height);break;case this.RESIZE_HEIGHT:this.setBounds(0,0,this.width,b);break;case this.RESIZE_BOTH:this.setBounds(0,0,a,b);break;case this.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.setScaleAnchored(c,c,0,0);this.canvas.width=this.referenceWidth*c;this.canvas.height=this.referenceHeight*c;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");this.glEnabled&&this.glReset()},enableResizeEvents:function(a,b){a===this.RESIZE_BOTH||a===this.RESIZE_WIDTH||a===this.RESIZE_HEIGHT||a===this.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)},setBounds:function(a,b,c,d){CAAT.Director.superclass.setBounds.call(this,a,b,c,d);this.canvas.width=c;this.canvas.height=d;this.crc=this.ctx=this.canvas.getContext(this.glEnabled?"experimental-webgl":"2d");for(a=0;a=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},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0},render:function(a){this.time+=a;this.animate(this, -a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c= -this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.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.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix= -new CAAT.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;a.restore();this.ctx=c;this.crc=d}},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(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE? -a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];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.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1, -0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.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.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)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled=true;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=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d); -c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.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.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint, -this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x=c.x;this.prevMousePoint.y= -c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, +return this},initialize:function(a,b,c,d){c||(c=document.createElement("canvas"),document.body.appendChild(c));this.canvas=c;typeof d==="undefined"&&(d=c);this.setBounds(0,0,a,b);this.create();this.enableEvents(d);this.timeline=(new Date).getTime();this.transitionScene=(new CAAT.Scene).create().setBounds(0,0,a,b);c=document.createElement("canvas");c.width=a;c.height=b;a=(new CAAT.Actor).create().setBackgroundImage(c);this.transitionScene.ctx=c.getContext("2d");this.transitionScene.addChildImmediately(a); +this.transitionScene.setEaseListener(this);this.checkDebug();return this},glReset:function(){this.pMatrix=makeOrtho(0,this.referenceWidth,this.referenceHeight,0,-1,1);this.gl.viewport(0,0,this.canvas.width,this.canvas.height);this.glColorProgram.setMatrixUniform(this.pMatrix);this.glTextureProgram.setMatrixUniform(this.pMatrix);this.gl.viewportWidth=this.canvas.width;this.gl.viewportHeight=this.canvas.height},initializeGL:function(a,b,c){c||(c=document.createElement("canvas"),document.body.appendChild(c)); +c.width=a;c.height=b;this.referenceWidth=a;this.referenceHeight=b;try{this.gl=c.getContext("experimental-webgl"),this.gl.viewportWidth=a,this.gl.viewportHeight=b,CAAT.GLRENDER=true}catch(d){}if(this.gl)this.canvas=c,this.create(),this.setBounds(0,0,a,b),this.crc=this.ctx,this.enableEvents(c),this.timeline=(new Date).getTime(),this.glColorProgram=(new CAAT.ColorProgram(this.gl)).create().initialize(),this.glTextureProgram=(new CAAT.TextureProgram(this.gl)).create().initialize(),this.glTextureProgram.useProgram(), +this.glReset(),this.coords=new Float32Array(6144),this.uv=new Float32Array(4096),this.gl.clearColor(0,0,0,255),this.front_to_back?(this.gl.clearDepth(1),this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LESS)):this.gl.disable(this.gl.DEPTH_TEST),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.glEnabled=true,this.checkDebug();else return this.initialize(a,b,c);return this},createScene:function(){var a=(new CAAT.Scene).create();this.addScene(a); +return a},setImagesCache:function(a,b,c){var d;if(null!==this.glTextureManager)this.glTextureManager.deletePages(),this.glTextureManager=null;if(this.imagesCache){var e=[];for(d=0;d=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},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0}, +render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.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.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc; +this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.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;a.restore();this.ctx=c;this.crc=d}},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(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),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.Scene.prototype.EASE_ROTATION? +a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];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.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)): +e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.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.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)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled= +true;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=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI= +this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.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.MouseEvent).init(b.x, +b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x= +c.x;this.prevMousePoint.y=c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y, a,b,this.screenMousePoint,this.currentScene.time)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time);this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_= this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y, @@ -280,42 +280,44 @@ return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c|| 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){this.padding=b;var c=document.createElement("canvas");c.width=1;c.height=1;var d=c.getContext("2d");d.textBaseline="top";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(h),e+=h;c.width=e;c.height=this.fontSize*1.5>>0;d=c.getContext("2d"); d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g1||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},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.crc;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(),c.arc(this.points[0].x,this.points[0].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.arc(this.points[1].x,this.points[1].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill();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()); +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}};extend(CAAT.LinearPath,CAAT.PathSegment)})(); (function(){CAAT.CurvePath=function(){CAAT.CurvePath.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.CurvePath.prototype={curve:null,newPosition:null,applyAsPath:function(a){this.curve.applyAsPath(a);return this},setPoint:function(a,b){this.curve&&this.curve.setPoint(a,b)},setPoints:function(a){var b=new CAAT.Bezier;b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.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.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(a>1||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)},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/ +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}};extend(CAAT.CurvePath,CAAT.PathSegment,null)})(); (function(){CAAT.ShapePath=function(){CAAT.ShapePath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point;return this};CAAT.ShapePath.prototype={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&&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(;f1||a<0)a%=1;a<0&&(a=1+a);for(var b=false,c=0;c0?this.pathSegmentStartTime[b]=this.pathSegmentStartTime[b-1]+this.pathSegmentDurationTime[b-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[b].endPath();this.extractPathPoints();return this},press:function(a,b){if(this.interactive){for(var c= -CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b1||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=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();typeof b!=="undefined"&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b - * Incomplete class, do not use. + * This object manages one single catmull rom segment, that is 4 points. + * A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points. * * @constructor * @extends CAAT.Curve @@ -2121,26 +2127,19 @@ var cp1= proxy( /** * Set curve control points. - * @param cp0x {number} - * @param cp0y {number} - * @param cp1x {number} - * @param cp1y {number} - * @param cp2x {number} - * @param cp2y {number} - * @param cp3x {number} - * @param cp3y {number} + * @param points Array */ - setCurve : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) { - + setCurve : function( p0, p1, p2, p3 ) { + this.coordlist= []; - - this.coordlist.push( new CAAT.Point().set(cp0x, cp0y ) ); - this.coordlist.push( new CAAT.Point().set(cp1x, cp1y ) ); - this.coordlist.push( new CAAT.Point().set(cp2x, cp2y ) ); - this.coordlist.push( new CAAT.Point().set(cp3x, cp3y ) ); - - this.cubic= true; + this.coordlist.push( p0 ); + this.coordlist.push( p1 ); + this.coordlist.push( p2 ); + this.coordlist.push( p3 ); + this.update(); + + return this; }, /** * Paint the contour by solving again the entire curve. @@ -2148,9 +2147,12 @@ var cp1= proxy( */ paint: function(director) { - var x1,x2,y1,y2; - x1 = this.coordlist[0].x; - y1 = this.coordlist[0].y; + var x1,y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; var ctx= director.ctx; @@ -2159,7 +2161,7 @@ var cp1= proxy( ctx.moveTo(x1,y1); var point= new CAAT.Point(); - + for(var t=this.k;t<=1+this.k;t+=this.k){ this.solve(point,t); ctx.lineTo(point.x,point.y); @@ -2176,19 +2178,17 @@ var cp1= proxy( * @param t {number} a number in the range 0..1 */ solve: function(point,t) { - var t2= t*t; - var t3= t*t2; - var c= this.coordlist; -// q(t) = 0.5 *( (2 * P1) + -// (-P0 + P2) * t + -// (2*P0 - 5*P1 + 4*P2 - P3) * t2 + -// (-P0 + 3*P1- 3*P2 + P3) * t3) + // Handy from CAKE. Thanks. + var af = ((-t+2)*t-1)*t*0.5 + var bf = (((3*t-5)*t)*t+2)*0.5 + var cf = ((-3*t+4)*t+1)*t*0.5 + var df = ((t-1)*t*t)*0.5 + + point.x= c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y= c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; - point.x= 0.5*( (2*c[1].x) + (-c[0].x+c[2].x)*t + (2*c[0].x - 5*c[1].x + 4*c[2].x - c[3].x)*t2 + (-c[0].x + 3*c[1].x - 3*c[2].x + c[3].x)*t3 ); - point.y= 0.5*( (2*c[1].y) + (-c[0].y+c[2].y)*t + (2*c[0].y - 5*c[1].y + 4*c[2].y - c[3].y)*t2 + (-c[0].y + 3*c[1].y - 3*c[2].y + c[3].y)*t3 ); - return point; } @@ -8425,7 +8425,10 @@ var cp1= proxy( * @return this */ initialize : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } this.canvas = canvas; if ( typeof proxy==='undefined' ) { @@ -8469,7 +8472,11 @@ var cp1= proxy( */ initializeGL : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } + canvas.width = width; canvas.height = height; @@ -10242,7 +10249,8 @@ var cp1= proxy( } extend(CAAT.Director, CAAT.ActorContainer, null); -})();/** +})(); +/** * See LICENSE file. * * MouseEvent is a class to hold necessary information of every mouse event related to concrete @@ -13441,7 +13449,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** }; CAAT.PathSegment.prototype = { - color: 'black', + color: '#000', length: 0, bbox: null, parent: null, @@ -13559,7 +13567,21 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Transform this path with the given affinetransform matrix. * @param matrix */ - transform : function(matrix) {} + transform : function(matrix) {}, + + drawHandle : function( ctx, x, y ) { + var w= CAAT.Curve.prototype.HANDLE_SIZE/2; + ctx.fillRect( x-w, y-w, w*2, w*2 ); + /* + ctx.arc( + this.points[0].x, + this.points[0].y, + CAAT.Curve.prototype.HANDLE_SIZE/2, + 0, + 2*Math.PI, + false) ; + */ + } }; })(); @@ -13668,6 +13690,9 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this.newPosition; }, + getPositionFromLength : function( len ) { + return this.getPosition( len/this.length ); + }, /** * Returns initial path segment point's x coordinate. * @return {number} @@ -13690,20 +13715,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.moveTo( this.points[0].x, this.points[0].y ); - canvas.lineTo( this.points[1].x, this.points[1].y ); - canvas.stroke(); + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.moveTo( this.points[0].x, this.points[0].y ); + ctx.lineTo( this.points[1].x, this.points[1].y ); + ctx.stroke(); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; - canvas.beginPath(); + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; + ctx.beginPath(); + this.drawHandle( ctx, this.points[0].x, this.points[0].y ); + this.drawHandle( ctx, this.points[1].x, this.points[1].y ); + /* canvas.arc( this.points[0].x, this.points[0].y, @@ -13719,9 +13747,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** 2*Math.PI, false) ; canvas.fill(); + */ } - canvas.restore(); + ctx.restore(); }, /** * Get the number of control points. For this type of path segment, start and @@ -13891,7 +13920,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** paint : function( director,bDrawHandles ) { this.curve.drawHandles= bDrawHandles; director.ctx.strokeStyle= this.color; - this.curve.paint(director); + this.curve.paint(director,bDrawHandles); }, /** * @inheritDoc @@ -14124,21 +14153,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.strokeRect( + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.strokeRect( this.bbox.x, this.bbox.y, this.bbox.width, this.bbox.height ); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; for( var i=0; i=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + }, /** * Analogously to the method getPosition, this method returns a CAAT.Point instance with @@ -14787,7 +14871,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Indicates that some path control point has changed, and that the path must recalculate * its internal data, ie: length and bbox. */ - updatePath : function(point) { + updatePath : function(point, callback) { var i,j; this.length=0; @@ -14845,6 +14929,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.extractPathPoints(); + if ( typeof callback!=='undefined' ) { + callback(this); + } + return this; }, @@ -14881,7 +14969,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * @param x {number} * @param y {number} */ - drag : function(x,y) { + drag : function(x,y,callback) { if (!this.interactive) { return; } @@ -14901,7 +14989,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.ax= x; this.ay= y; - this.updatePath(this.point); + this.updatePath(this.point,callback); }, /** * Returns a collection of CAAT.Point objects which conform a path's contour. @@ -15167,6 +15255,22 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.tb_x= x; this.tb_y= y; return this; + }, + + flatten : function( npatches, closed ) { + var point= this.getPositionFromLength(0); + var path= new CAAT.Path().beginPath( point.x, point.y ); + for( var i=0; i>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],l=((k d);return this},contains:function(a,b){return a>=0&&a=0&&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.x1this.x1?false:a.y1this.y1?false:true},intersectsRect:function(a,b,c,d){return-1===c||-1===d?false:a+c-1this.x1?false:b+d-1this.y1?false:true},intersect:function(a,b){typeof b==="undefined"&&(b=new CAAT.Rectangle);b.x=Math.max(this.x,a.x);b.y=Math.max(this.y,a.y);b.x1=Math.min(this.x1,a.x1);b.y1=Math.min(this.y1, a.y1);b.width=b.x1-b.x;b.height=b.y1-b.y;return b}}})();(function(){CAAT.Curve=function(){return this};CAAT.Curve.prototype={coordlist:null,k:0.05,length:-1,interpolator:false,HANDLE_SIZE:20,drawHandles:true,paint:function(a){if(false!==this.drawHandles){a=a.ctx;a.save();a.beginPath();a.strokeStyle="#a0a0a0";a.moveTo(this.coordlist[0].x,this.coordlist[0].y);a.lineTo(this.coordlist[1].x,this.coordlist[1].y);a.stroke();this.cubic&&(a.moveTo(this.coordlist[2].x,this.coordlist[2].y),a.lineTo(this.coordlist[3].x,this.coordlist[3].y),a.stroke());a.globalAlpha= -0.5;for(var b=0;b=0&&ba*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.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)}}})();(function(){CAAT.QuadTree=function(){return this};CAAT.QuadTree.prototype={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.QuadTree).create(a,b,h,i,this.bgActors);this.quadData[1]=(new CAAT.QuadTree).create(h, @@ -165,9 +165,9 @@ b){if(!this.visible)return true;var c=a.ctx;this.frameAlpha=this.parent?this.par this.parent.frameAlpha;for(c=this.activeChildren;c;c=c.__next)c.paintActorGL(a,b)},animate:function(a,b){var c=this.activeChildren=null;if(false===CAAT.ActorContainer.superclass.animate.call(this,a,b))return false;var d,e=this.pendingChildrenList;for(d=0;d=this.childrenList.length)b=this.childrenList.length; -a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);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,b=a.length-1;b>=0;b--)a[b].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])}}}};if(CAAT.NO_PERF)CAAT.ActorContainer.prototype.paintActor=CAAT.ActorContainer.prototype.__paintActor;extend(CAAT.ActorContainer,CAAT.Actor,null)})(); +a.parent=this;a.dirty=true;this.childrenList.splice(b,0,a);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,b=a.length-1;b>=0;b--)a[b].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])}}}};if(CAAT.NO_PERF)CAAT.ActorContainer.prototype.paintActor=CAAT.ActorContainer.prototype.__paintActor;extend(CAAT.ActorContainer,CAAT.Actor,null)})(); (function(){CAAT.TextActor=function(){CAAT.TextActor.superclass.constructor.call(this);this.font="10px sans-serif";this.textAlign="left";this.textBaseline="top";this.outlineColor="black";this.clip=false;return this};CAAT.TextActor.TRAVERSE_PATH_FORWARD=1;CAAT.TextActor.TRAVERSE_PATH_BACKWARD=-1;CAAT.TextActor.prototype={font:null,textAlign:null,textBaseline:null,fill:true,textFillStyle:"#eee",text:null,textWidth:0,textHeight:0,outline:false,outlineColor:null,path:null,pathInterpolator:null,pathDuration:1E4, sign:1,setFill:function(a){this.fill=a;return this},setTextFillStyle:function(a){this.textFillStyle=a;return this},setOutline:function(a){this.outline=a;return this},setPathTraverseDirection:function(a){this.sign=a;return this},setOutlineColor:function(a){this.outlineColor=a;return this},setText:function(a){this.text=a;if(null===this.text||this.text==="")this.width=this.height=0;this.calcTextSize(CAAT.director[0]);return this},setTextAlign:function(a){this.textAlign=a;return this},setAlign:function(a){return this.setTextAlign(a)}, setTextBaseline:function(a){this.textBaseline=a;return this},setBaseline:function(a){return this.setTextBaseline(a)},setFont:function(a){a||(a="10px sans-serif");this.font=a;this.calcTextSize(CAAT.director[0]);return this},calcTextSize:function(a){if(typeof this.text==="undefined"||null===this.text||""===this.text)return this.textHeight=this.textWidth=0,this;if(a.glEnabled)return this;if(this.font instanceof CAAT.SpriteImage)return this.textWidth=this.font.stringWidth(this.text),this.textHeight=this.font.stringHeight(), @@ -175,7 +175,7 @@ this.width=this.textWidth,this.height=this.textHeight,this;a=a.ctx;a.save();a.fo 0||this.textHeight===0)&&this.calcTextSize(a);var c=a.ctx;if(this.font instanceof CAAT.SpriteImage)return this.drawSpriteText(a,b);if(null!==this.font)c.font=this.font;if(null!==this.textAlign)c.textAlign=this.textAlign;if(null!==this.textBaseline)c.textBaseline=this.textBaseline;if(this.fill&&null!==this.textFillStyle)c.fillStyle=this.textFillStyle;if(this.outline&&null!==this.outlineColor)c.strokeStyle=this.outlineColor;if(null===this.path){var d=0;if(this.textAlign==="center")d=this.width/2|0; else if(this.textAlign==="right")d=this.width;if(this.fill)c.fillText(this.text,d,0),this.outline&&(c.beginPath(),c.strokeText(this.text,d,0));else{if(null!==this.outlineColor)c.strokeStyle=this.outlineColor;c.beginPath();c.strokeText(this.text,d,0)}}else this.drawOnPath(a,b)}},drawOnPath: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.Point(0,0,0),f=new CAAT.Point(0,0,0),g=0;g=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},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0},render:function(a){this.time+=a;this.animate(this, -a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c= -this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.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.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc;this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix= -new CAAT.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;a.restore();this.ctx=c;this.crc=d}},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(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE? -a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];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.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1, -0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.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.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)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled=true;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=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI=this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d); -c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.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.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint, -this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x=c.x;this.prevMousePoint.y= -c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, +return this},initialize:function(a,b,c,d){c||(c=document.createElement("canvas"),document.body.appendChild(c));this.canvas=c;typeof d==="undefined"&&(d=c);this.setBounds(0,0,a,b);this.create();this.enableEvents(d);this.timeline=(new Date).getTime();this.transitionScene=(new CAAT.Scene).create().setBounds(0,0,a,b);c=document.createElement("canvas");c.width=a;c.height=b;a=(new CAAT.Actor).create().setBackgroundImage(c);this.transitionScene.ctx=c.getContext("2d");this.transitionScene.addChildImmediately(a); +this.transitionScene.setEaseListener(this);this.checkDebug();return this},glReset:function(){this.pMatrix=makeOrtho(0,this.referenceWidth,this.referenceHeight,0,-1,1);this.gl.viewport(0,0,this.canvas.width,this.canvas.height);this.glColorProgram.setMatrixUniform(this.pMatrix);this.glTextureProgram.setMatrixUniform(this.pMatrix);this.gl.viewportWidth=this.canvas.width;this.gl.viewportHeight=this.canvas.height},initializeGL:function(a,b,c){c||(c=document.createElement("canvas"),document.body.appendChild(c)); +c.width=a;c.height=b;this.referenceWidth=a;this.referenceHeight=b;try{this.gl=c.getContext("experimental-webgl"),this.gl.viewportWidth=a,this.gl.viewportHeight=b,CAAT.GLRENDER=true}catch(d){}if(this.gl)this.canvas=c,this.create(),this.setBounds(0,0,a,b),this.crc=this.ctx,this.enableEvents(c),this.timeline=(new Date).getTime(),this.glColorProgram=(new CAAT.ColorProgram(this.gl)).create().initialize(),this.glTextureProgram=(new CAAT.TextureProgram(this.gl)).create().initialize(),this.glTextureProgram.useProgram(), +this.glReset(),this.coords=new Float32Array(6144),this.uv=new Float32Array(4096),this.gl.clearColor(0,0,0,255),this.front_to_back?(this.gl.clearDepth(1),this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LESS)):this.gl.disable(this.gl.DEPTH_TEST),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.ONE,this.gl.ONE_MINUS_SRC_ALPHA),this.glEnabled=true,this.checkDebug();else return this.initialize(a,b,c);return this},createScene:function(){var a=(new CAAT.Scene).create();this.addScene(a); +return a},setImagesCache:function(a,b,c){var d;if(null!==this.glTextureManager)this.glTextureManager.deletePages(),this.glTextureManager=null;if(this.imagesCache){var e=[];for(d=0;d=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},resetStats:function(){this.statistics.size_total=0;this.statistics.size_active=0;this.statistics.draws=0}, +render:function(a){this.time+=a;this.animate(this,a);CAAT.DEBUG&&this.resetStats();var b=this.childrenList.length,c,d,e,f=this.ctx;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c0&&CAAT.DEBUG&&CAAT.DEBUG_DIRTYRECTS){f.beginPath();this.nDirtyRects=0;d=this.cDirtyRects;for(c=0;c=this.dirtyRects.length)for(b=0;b<32;b++)this.dirtyRects.push(new CAAT.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.globalAlpha=1;a.globalCompositeOperation="source-over";a.clearRect(0,0,this.width,this.height);a.setTransform(1,0,0,0,1,0);var c=this.ctx,d=this.crc; +this.ctx=this.crc=a;a.save();var e=this.worldModelViewMatrix;this.worldModelViewMatrix=new CAAT.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;a.restore();this.ctx=c;this.crc=d}},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(!this.glEnabled&&!navigator.browser==="iOS")this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx),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.Scene.prototype.EASE_ROTATION? +a.easeRotationIn(g,h,c,i):b===CAAT.Scene.prototype.EASE_SCALE?a.easeScaleIn(0,g,h,c,i):a.easeTranslationIn(g,h,c,i);e===CAAT.Scene.prototype.EASE_ROTATION?d.easeRotationOut(g,h,f,j):e===CAAT.Scene.prototype.EASE_SCALE?d.easeScaleOut(0,g,h,f,j):d.easeTranslationOut(g,h,f,j);this.childrenList=[];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.Scene.prototype.EASE_ROTATION,g=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)): +e<0.66?(e=CAAT.Scene.prototype.EASE_SCALE,g=(new CAAT.Interpolator).createElasticOutInterpolator(1.1,0.4)):(e=CAAT.Scene.prototype.EASE_TRANSLATE,g=(new CAAT.Interpolator).createBounceOutInterpolator());var h;f<0.33?(f=CAAT.Scene.prototype.EASE_ROTATION,h=(new CAAT.Interpolator).createExponentialInOutInterpolator(4)):f<0.66?(f=CAAT.Scene.prototype.EASE_SCALE,h=(new CAAT.Interpolator).createExponentialOutInterpolator(4)):(f=CAAT.Scene.prototype.EASE_TRANSLATE,h=(new CAAT.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.Scene.prototype.EASE_ROTATION?a.easeRotationIn(c,d,e,f):b===CAAT.Scene.prototype.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.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)},endLoop:function(){},setClear:function(a){this.clear=a;if(this.clear===CAAT.Director.CLEAR_DIRTY_RECTS)this.dirtyRectsEnabled= +true;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=0,d=0;if(!b)b=window.event;if(b.pageX||b.pageY)c=b.pageX,d=b.pageY;else if(b.clientX||b.clientY)c=b.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,d=b.clientY+document.body.scrollTop+document.documentElement.scrollTop;var e=this.getOffset(b.target);c-=e.x;d-=e.y;d=new CAAT.Point(c,d);this.modelViewMatrixI= +this.modelViewMatrix.getInverse();this.modelViewMatrixI.transformCoord(d);c=d.x;d=d.y;a.set(c,d);this.screenMousePoint.set(c,d)},__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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));b.mouseDown((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.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.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),c.actionPerformed&&c.contains(b.x,b.y)&&c.actionPerformed(a),c.mouseUp((new CAAT.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.MouseEvent).init(b.x, +b.y,a,c,this.screenMousePoint,this.currentScene.time));this.in_=this.dragging=false},__mouseMoveHandler:function(a){this.getCanvasCoord(this.mousePoint,a);var b,c;if(this.isMouseDown&&null!==this.lastSelectedActor){b=this.lastSelectedActor;c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0));this.dragging=true;var d=b.x,e=b.y;b.mouseDrag((new CAAT.MouseEvent).init(c.x,c.y,a,b,new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y),this.currentScene.time));this.prevMousePoint.x= +c.x;this.prevMousePoint.y=c.y;if(d===b.x&&e===b.y){d=b.contains(c.x,c.y);if(this.in_&&!d)b.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)),this.in_=true}}else this.in_=true,b=this.findActorAtPosition(this.mousePoint),b!==this.lastSelectedActor&&(null!==this.lastSelectedActor&&(c=this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y,0)),this.lastSelectedActor.mouseExit((new CAAT.MouseEvent).init(c.x,c.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time)))),c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),null!==b&&b.mouseMove((new CAAT.MouseEvent).init(c.x,c.y, a,b,this.screenMousePoint,this.currentScene.time)),this.lastSelectedActor=b},__mouseOutHandler:function(a){if(null!==this.lastSelectedActor){this.getCanvasCoord(this.mousePoint,a);var b=new CAAT.Point(this.mousePoint.x,this.mousePoint.y,0);this.lastSelectedActor.viewToModel(b);a=(new CAAT.MouseEvent).init(b.x,b.y,a,this.lastSelectedActor,this.screenMousePoint,this.currentScene.time);this.lastSelectedActor.mouseExit(a);this.lastSelectedActor.mouseOut(a);if(!this.dragging)this.lastSelectedActor=null}else this.in_= this.isMouseDown=false},__mouseOverHandler:function(a){var b,c;this.getCanvasCoord(this.mousePoint,a);null==this.lastSelectedActor?(b=this.findActorAtPosition(this.mousePoint),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)),a=(new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint,this.currentScene.time),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y, @@ -303,45 +303,47 @@ return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c|| 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){this.padding=b;var c=document.createElement("canvas");c.width=1;c.height=1;var d=c.getContext("2d");d.textBaseline="top";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(h),e+=h;c.width=e;c.height=this.fontSize*1.5>>0;d=c.getContext("2d"); d.textBaseline="top";d.font=this.fontStyle+" "+this.fontSize+""+this.fontSizeUnit+" "+this.font;d.fillStyle=this.fillStyle;d.strokeStyle=this.strokeStyle;this.charMap={};for(g=e=0;g1||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},initialPositionX:function(){return this.points[0].x},finalPositionX:function(){return this.points[1].x},paint:function(a,b){var c=a.crc;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(),c.arc(this.points[0].x,this.points[0].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.arc(this.points[1].x,this.points[1].y,CAAT.Curve.prototype.HANDLE_SIZE/2,0,2*Math.PI,false),c.fill();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()); +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}};extend(CAAT.LinearPath,CAAT.PathSegment)})(); (function(){CAAT.CurvePath=function(){CAAT.CurvePath.superclass.constructor.call(this);this.newPosition=new CAAT.Point(0,0,0);return this};CAAT.CurvePath.prototype={curve:null,newPosition:null,applyAsPath:function(a){this.curve.applyAsPath(a);return this},setPoint:function(a,b){this.curve&&this.curve.setPoint(a,b)},setPoints:function(a){var b=new CAAT.Bezier;b.setPoints(a);this.curve=b;return this},setQuadric:function(a,b,c,d,e,f){var g=new CAAT.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.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(a>1||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)},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/ +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}};extend(CAAT.CurvePath,CAAT.PathSegment,null)})(); (function(){CAAT.ShapePath=function(){CAAT.ShapePath.superclass.constructor.call(this);this.points=[];this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.points.push(new CAAT.Point);this.newPosition=new CAAT.Point;return this};CAAT.ShapePath.prototype={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&&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(;f1||a<0)a%=1;a<0&&(a=1+a);for(var b=false,c=0;c0?this.pathSegmentStartTime[b]=this.pathSegmentStartTime[b-1]+this.pathSegmentDurationTime[b-1]:this.pathSegmentStartTime[0]=0,this.pathSegments[b].endPath();this.extractPathPoints();return this},press:function(a,b){if(this.interactive){for(var c= -CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b1||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=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();typeof b!=="undefined"&&b(this);return this},press:function(a,b){if(this.interactive){for(var c=CAAT.Curve.prototype.HANDLE_SIZE/2,d=0;d=f.x-c&&b>=f.y-c&&a=0&&b - * Incomplete class, do not use. + * This object manages one single catmull rom segment, that is 4 points. + * A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points. * * @constructor * @extends CAAT.Curve @@ -2120,26 +2126,19 @@ var cp1= proxy( /** * Set curve control points. - * @param cp0x {number} - * @param cp0y {number} - * @param cp1x {number} - * @param cp1y {number} - * @param cp2x {number} - * @param cp2y {number} - * @param cp3x {number} - * @param cp3y {number} + * @param points Array */ - setCurve : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) { - + setCurve : function( p0, p1, p2, p3 ) { + this.coordlist= []; - - this.coordlist.push( new CAAT.Point().set(cp0x, cp0y ) ); - this.coordlist.push( new CAAT.Point().set(cp1x, cp1y ) ); - this.coordlist.push( new CAAT.Point().set(cp2x, cp2y ) ); - this.coordlist.push( new CAAT.Point().set(cp3x, cp3y ) ); - - this.cubic= true; + this.coordlist.push( p0 ); + this.coordlist.push( p1 ); + this.coordlist.push( p2 ); + this.coordlist.push( p3 ); + this.update(); + + return this; }, /** * Paint the contour by solving again the entire curve. @@ -2147,9 +2146,12 @@ var cp1= proxy( */ paint: function(director) { - var x1,x2,y1,y2; - x1 = this.coordlist[0].x; - y1 = this.coordlist[0].y; + var x1,y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; var ctx= director.ctx; @@ -2158,7 +2160,7 @@ var cp1= proxy( ctx.moveTo(x1,y1); var point= new CAAT.Point(); - + for(var t=this.k;t<=1+this.k;t+=this.k){ this.solve(point,t); ctx.lineTo(point.x,point.y); @@ -2175,19 +2177,17 @@ var cp1= proxy( * @param t {number} a number in the range 0..1 */ solve: function(point,t) { - var t2= t*t; - var t3= t*t2; - var c= this.coordlist; -// q(t) = 0.5 *( (2 * P1) + -// (-P0 + P2) * t + -// (2*P0 - 5*P1 + 4*P2 - P3) * t2 + -// (-P0 + 3*P1- 3*P2 + P3) * t3) + // Handy from CAKE. Thanks. + var af = ((-t+2)*t-1)*t*0.5 + var bf = (((3*t-5)*t)*t+2)*0.5 + var cf = ((-3*t+4)*t+1)*t*0.5 + var df = ((t-1)*t*t)*0.5 + + point.x= c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y= c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; - point.x= 0.5*( (2*c[1].x) + (-c[0].x+c[2].x)*t + (2*c[0].x - 5*c[1].x + 4*c[2].x - c[3].x)*t2 + (-c[0].x + 3*c[1].x - 3*c[2].x + c[3].x)*t3 ); - point.y= 0.5*( (2*c[1].y) + (-c[0].y+c[2].y)*t + (2*c[0].y - 5*c[1].y + 4*c[2].y - c[3].y)*t2 + (-c[0].y + 3*c[1].y - 3*c[2].y + c[3].y)*t3 ); - return point; } @@ -7552,6 +7552,11 @@ var cp1= proxy( return this; }, + removeFirstChild : function() { + var first= this.childrenList.shift(); + first.parent= null; + return first; + }, /** * @private * @@ -8019,7 +8024,7 @@ var cp1= proxy( context.save(); - context.translate( (0.5+p0.x)|0, (0.5+p0.y)|0 ); + context.translate( p0.x|0, p0.y|0 ); context.rotate( angle ); var y = this.textBaseline === "bottom" ? 0 - this.font.height : 0; @@ -9433,7 +9438,10 @@ var cp1= proxy( * @return this */ initialize : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } this.canvas = canvas; if ( typeof proxy==='undefined' ) { @@ -9477,7 +9485,11 @@ var cp1= proxy( */ initializeGL : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } + canvas.width = width; canvas.height = height; @@ -11250,7 +11262,8 @@ var cp1= proxy( } extend(CAAT.Director, CAAT.ActorContainer, null); -})();/** +})(); +/** * See LICENSE file. * * MouseEvent is a class to hold necessary information of every mouse event related to concrete @@ -14450,7 +14463,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** }; CAAT.PathSegment.prototype = { - color: 'black', + color: '#000', length: 0, bbox: null, parent: null, @@ -14568,7 +14581,21 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Transform this path with the given affinetransform matrix. * @param matrix */ - transform : function(matrix) {} + transform : function(matrix) {}, + + drawHandle : function( ctx, x, y ) { + var w= CAAT.Curve.prototype.HANDLE_SIZE/2; + ctx.fillRect( x-w, y-w, w*2, w*2 ); + /* + ctx.arc( + this.points[0].x, + this.points[0].y, + CAAT.Curve.prototype.HANDLE_SIZE/2, + 0, + 2*Math.PI, + false) ; + */ + } }; })(); @@ -14677,6 +14704,9 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** return this.newPosition; }, + getPositionFromLength : function( len ) { + return this.getPosition( len/this.length ); + }, /** * Returns initial path segment point's x coordinate. * @return {number} @@ -14699,20 +14729,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.moveTo( this.points[0].x, this.points[0].y ); - canvas.lineTo( this.points[1].x, this.points[1].y ); - canvas.stroke(); + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.moveTo( this.points[0].x, this.points[0].y ); + ctx.lineTo( this.points[1].x, this.points[1].y ); + ctx.stroke(); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; - canvas.beginPath(); + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; + ctx.beginPath(); + this.drawHandle( ctx, this.points[0].x, this.points[0].y ); + this.drawHandle( ctx, this.points[1].x, this.points[1].y ); + /* canvas.arc( this.points[0].x, this.points[0].y, @@ -14728,9 +14761,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** 2*Math.PI, false) ; canvas.fill(); + */ } - canvas.restore(); + ctx.restore(); }, /** * Get the number of control points. For this type of path segment, start and @@ -14900,7 +14934,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** paint : function( director,bDrawHandles ) { this.curve.drawHandles= bDrawHandles; director.ctx.strokeStyle= this.color; - this.curve.paint(director); + this.curve.paint(director,bDrawHandles); }, /** * @inheritDoc @@ -15133,21 +15167,23 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.strokeRect( + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.strokeRect( this.bbox.x, this.bbox.y, this.bbox.width, this.bbox.height ); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; for( var i=0; i=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + }, /** * Analogously to the method getPosition, this method returns a CAAT.Point instance with @@ -15796,7 +15885,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * Indicates that some path control point has changed, and that the path must recalculate * its internal data, ie: length and bbox. */ - updatePath : function(point) { + updatePath : function(point, callback) { var i,j; this.length=0; @@ -15854,6 +15943,10 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.extractPathPoints(); + if ( typeof callback!=='undefined' ) { + callback(this); + } + return this; }, @@ -15890,7 +15983,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** * @param x {number} * @param y {number} */ - drag : function(x,y) { + drag : function(x,y,callback) { if (!this.interactive) { return; } @@ -15910,7 +16003,7 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.ax= x; this.ay= y; - this.updatePath(this.point); + this.updatePath(this.point,callback); }, /** * Returns a collection of CAAT.Point objects which conform a path's contour. @@ -16176,6 +16269,22 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** this.tb_x= x; this.tb_y= y; return this; + }, + + flatten : function( npatches, closed ) { + var point= this.getPositionFromLength(0); + var path= new CAAT.Path().beginPath( point.x, point.y ); + for( var i=0; iPath management * Startup it all up when the document is ready. * Change for your favorite frameworks initialization code. */ + CAAT.DEBUG=1; window.addEventListener( 'load', function() { @@ -114,7 +115,8 @@

Path management

800, 500, 'experiment-holder', [ - {id:'fish', url:'../demo-resources/img/anim2.png'} + {id:'fish', url:'../demo-resources/img/anim2.png'}, + {id:'score', url: "../demo-resources/img/numerospuntos.png"} ], __scene1 ); @@ -208,20 +210,60 @@

Path management

var scene = director.createScene(); + var dw= director.width; + var dh= director.height; + + + var i; + var R= (Math.min( dw,dh ) - 40)/2; + var pp= []; + var angle; + var NP=7; + for( i=0; iPath management function addDescription(director, scene) { var cc1 = new CAAT.ActorContainer(). - setBounds(0, 30, 280, 110). - create(). + setBounds(140, 80, 280, 110). enableEvents(false); + cc1.setPositionAnchor(.5,.5); scene.addChild(cc1); cc1.addBehavior( @@ -285,7 +327,7 @@

Path management

setTextFillStyle(gradient). setOutline(true). cacheAsBitmap(); - cc1.addChild(text.setLocation((cc1.width - text.textWidth) / 2, 0)); + cc1.addChild(text.setLocation((cc1.width - text.textWidth) / 2, 0) ); var text2 = new CAAT.TextActor(). setFont("20px sans-serif"). diff --git a/documentation/jsdoc/files.html b/documentation/jsdoc/files.html index 9b012132..4d9b8635 100644 --- a/documentation/jsdoc/files.html +++ b/documentation/jsdoc/files.html @@ -708,7 +708,7 @@

/User
- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET)
\ No newline at end of file diff --git a/documentation/jsdoc/index.html b/documentation/jsdoc/index.html index cd41429a..d91d1e59 100644 --- a/documentation/jsdoc/index.html +++ b/documentation/jsdoc/index.html @@ -564,7 +564,7 @@

Function

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET)
\ No newline at end of file diff --git a/documentation/jsdoc/symbols/CAAT.Actor.html b/documentation/jsdoc/symbols/CAAT.Actor.html index c5ef451b..f05a8fbf 100644 --- a/documentation/jsdoc/symbols/CAAT.Actor.html +++ b/documentation/jsdoc/symbols/CAAT.Actor.html @@ -4928,7 +4928,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ActorContainer.html b/documentation/jsdoc/symbols/CAAT.ActorContainer.html index 3b03ce15..e151c7f3 100644 --- a/documentation/jsdoc/symbols/CAAT.ActorContainer.html +++ b/documentation/jsdoc/symbols/CAAT.ActorContainer.html @@ -530,6 +530,15 @@

+ +   + + +
+ + +   @@ -1407,6 +1416,31 @@

+
+ + +
+ + + removeFirstChild() + +
+
+ + + +
+ + + + + + + + + + +
@@ -1464,7 +1498,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.AudioManager.html b/documentation/jsdoc/symbols/CAAT.AudioManager.html index 202a5245..3afe6cd1 100644 --- a/documentation/jsdoc/symbols/CAAT.AudioManager.html +++ b/documentation/jsdoc/symbols/CAAT.AudioManager.html @@ -1185,7 +1185,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html index abf73931..488200ff 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html +++ b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html @@ -1227,7 +1227,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html index 53176ea1..9644d8c2 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html @@ -632,7 +632,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html index 28857fe0..aa5180e8 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html @@ -714,7 +714,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Bezier.html b/documentation/jsdoc/symbols/CAAT.Bezier.html index aac3c096..548d9b29 100644 --- a/documentation/jsdoc/symbols/CAAT.Bezier.html +++ b/documentation/jsdoc/symbols/CAAT.Bezier.html @@ -1022,7 +1022,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CatmullRom.html b/documentation/jsdoc/symbols/CAAT.CatmullRom.html index 6598afd0..b1d04fda 100644 --- a/documentation/jsdoc/symbols/CAAT.CatmullRom.html +++ b/documentation/jsdoc/symbols/CAAT.CatmullRom.html @@ -360,7 +360,7 @@

  -
setCurve(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y) +
setCurve(points, p1, p2, p3)
Set curve control points.
@@ -402,7 +402,8 @@

CatmullRom curves solver implementation.

-Incomplete class, do not use. +This object manages one single catmull rom segment, that is 4 points. +A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points.

@@ -469,7 +470,7 @@

- setCurve(cp0x, cp0y, cp1x, cp1y, cp2x, cp2y, cp3x, cp3y) + setCurve(points, p1, p2, p3)
@@ -485,52 +486,28 @@

Parameters:
- cp0x + points
-
{number}
+
Array
- cp0y + p1
-
{number}
+
- cp1x + p2
-
{number}
+
- cp1y + p3
-
{number}
- -
- cp2x - -
-
{number}
- -
- cp2y - -
-
{number}
- -
- cp3x - -
-
{number}
- -
- cp3y - -
-
{number}
+
@@ -597,7 +574,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.RGB.html b/documentation/jsdoc/symbols/CAAT.Color.RGB.html index e3200894..9ecb22b7 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.RGB.html +++ b/documentation/jsdoc/symbols/CAAT.Color.RGB.html @@ -470,7 +470,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Color.html b/documentation/jsdoc/symbols/CAAT.Color.html index 91a7907e..eef6af8b 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.html +++ b/documentation/jsdoc/symbols/CAAT.Color.html @@ -694,7 +694,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Curve.html b/documentation/jsdoc/symbols/CAAT.Curve.html index 5d5de372..9806aac0 100644 --- a/documentation/jsdoc/symbols/CAAT.Curve.html +++ b/documentation/jsdoc/symbols/CAAT.Curve.html @@ -969,7 +969,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:45 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.CurvePath.html b/documentation/jsdoc/symbols/CAAT.CurvePath.html index 79586f5e..d0e64d0d 100644 --- a/documentation/jsdoc/symbols/CAAT.CurvePath.html +++ b/documentation/jsdoc/symbols/CAAT.CurvePath.html @@ -498,7 +498,7 @@

-
Methods borrowed from class CAAT.PathSegment:
endPath, getBoundingBox, getLength, setColor, setParent, transform
+
Methods borrowed from class CAAT.PathSegment:
drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
@@ -1199,7 +1199,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Director.html b/documentation/jsdoc/symbols/CAAT.Director.html index a8ecd3c3..25528fcf 100644 --- a/documentation/jsdoc/symbols/CAAT.Director.html +++ b/documentation/jsdoc/symbols/CAAT.Director.html @@ -1088,7 +1088,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseOut, mouseOver, paint, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseOut, mouseOver, paint, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -4476,7 +4476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Font.html b/documentation/jsdoc/symbols/CAAT.Font.html index 2c9508a0..12de0e19 100644 --- a/documentation/jsdoc/symbols/CAAT.Font.html +++ b/documentation/jsdoc/symbols/CAAT.Font.html @@ -914,7 +914,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:01 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMActor.html b/documentation/jsdoc/symbols/CAAT.IMActor.html index 066ea5d2..2341ecaf 100644 --- a/documentation/jsdoc/symbols/CAAT.IMActor.html +++ b/documentation/jsdoc/symbols/CAAT.IMActor.html @@ -381,7 +381,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -553,7 +553,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMBump.html b/documentation/jsdoc/symbols/CAAT.IMBump.html index efca2b52..ba2e3f33 100644 --- a/documentation/jsdoc/symbols/CAAT.IMBump.html +++ b/documentation/jsdoc/symbols/CAAT.IMBump.html @@ -819,7 +819,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMPlasma.html b/documentation/jsdoc/symbols/CAAT.IMPlasma.html index aa06b71a..426a73e2 100644 --- a/documentation/jsdoc/symbols/CAAT.IMPlasma.html +++ b/documentation/jsdoc/symbols/CAAT.IMPlasma.html @@ -574,7 +574,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html index 4205c249..4b71a33a 100644 --- a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html +++ b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html @@ -620,7 +620,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html index 64296a30..3776cca2 100644 --- a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html +++ b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html @@ -476,7 +476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html index 9c73401e..9e1d69da 100644 --- a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html +++ b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html @@ -960,7 +960,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Interpolator.html b/documentation/jsdoc/symbols/CAAT.Interpolator.html index cf306b56..b1c436a4 100644 --- a/documentation/jsdoc/symbols/CAAT.Interpolator.html +++ b/documentation/jsdoc/symbols/CAAT.Interpolator.html @@ -1355,7 +1355,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:46 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html index 15b404e8..36cf4ed5 100644 --- a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html +++ b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html @@ -390,7 +390,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -615,7 +615,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.KeyEvent.html b/documentation/jsdoc/symbols/CAAT.KeyEvent.html index 57568481..12368d80 100644 --- a/documentation/jsdoc/symbols/CAAT.KeyEvent.html +++ b/documentation/jsdoc/symbols/CAAT.KeyEvent.html @@ -707,7 +707,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.LinearPath.html b/documentation/jsdoc/symbols/CAAT.LinearPath.html index 899ed302..206f41cc 100644 --- a/documentation/jsdoc/symbols/CAAT.LinearPath.html +++ b/documentation/jsdoc/symbols/CAAT.LinearPath.html @@ -402,6 +402,15 @@

+ +   + + +
+ + +   @@ -489,7 +498,7 @@

-
Methods borrowed from class CAAT.PathSegment:
endPath, getBoundingBox, getLength, setColor, setParent, transform
+
Methods borrowed from class CAAT.PathSegment:
drawHandle, endPath, getBoundingBox, getLength, setColor, setParent, transform
@@ -734,6 +743,42 @@

+
+ + +
+ + + getPositionFromLength(len) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ len + +
+
+ +
+ + + + + + + +
@@ -1079,7 +1124,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Matrix3.html b/documentation/jsdoc/symbols/CAAT.Matrix3.html index 13424b3d..e570f6f6 100644 --- a/documentation/jsdoc/symbols/CAAT.Matrix3.html +++ b/documentation/jsdoc/symbols/CAAT.Matrix3.html @@ -1615,7 +1615,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MatrixStack.html b/documentation/jsdoc/symbols/CAAT.MatrixStack.html index 14ea377e..e5fc7bf1 100644 --- a/documentation/jsdoc/symbols/CAAT.MatrixStack.html +++ b/documentation/jsdoc/symbols/CAAT.MatrixStack.html @@ -624,7 +624,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.MouseEvent.html b/documentation/jsdoc/symbols/CAAT.MouseEvent.html index 5a846808..a1c53278 100644 --- a/documentation/jsdoc/symbols/CAAT.MouseEvent.html +++ b/documentation/jsdoc/symbols/CAAT.MouseEvent.html @@ -651,7 +651,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Path.html b/documentation/jsdoc/symbols/CAAT.Path.html index 76448f6c..7e9de627 100644 --- a/documentation/jsdoc/symbols/CAAT.Path.html +++ b/documentation/jsdoc/symbols/CAAT.Path.html @@ -533,7 +533,7 @@

  -
drag(x, y) +
drag(x, y, callback)
Drags a path's control point.
@@ -575,6 +575,15 @@

+ +   + +
flatten(npatches, closed) +
+
+ + +   @@ -720,6 +729,15 @@

+ +   + +
setCatmullRom(points, closed) +
+
+ + +   @@ -885,7 +903,7 @@

  -
updatePath(point) +
updatePath(point, callback)
Indicates that some path control point has changed, and that the path must recalculate its internal data, ie: length and bbox.
@@ -898,7 +916,7 @@

-
Methods borrowed from class CAAT.PathSegment:
getBoundingBox, getLength, setColor, setParent, transform
+
Methods borrowed from class CAAT.PathSegment:
drawHandle, getBoundingBox, getLength, setColor, setParent, transform
@@ -1698,7 +1716,7 @@

- drag(x, y) + drag(x, y, callback)
@@ -1727,6 +1745,12 @@

{number}
+
+ callback + +
+
+ @@ -1863,6 +1887,48 @@

+
+ + +
+ + + flatten(npatches, closed) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ npatches + +
+
+ +
+ closed + +
+
+ +
+ + + + + + + +
@@ -2428,6 +2494,48 @@

+
+ + +
+ + + setCatmullRom(points, closed) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ points + +
+
+ +
+ closed + +
+
+ +
+ + + + + + + +
@@ -3299,7 +3407,7 @@

- updatePath(point) + updatePath(point, callback)
@@ -3321,6 +3429,12 @@

+
+ callback + +
+
+ @@ -3344,7 +3458,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathActor.html b/documentation/jsdoc/symbols/CAAT.PathActor.html index 725ce419..9a267a06 100644 --- a/documentation/jsdoc/symbols/CAAT.PathActor.html +++ b/documentation/jsdoc/symbols/CAAT.PathActor.html @@ -402,6 +402,15 @@

+ +   + + +
+ + +   @@ -426,7 +435,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -689,6 +698,42 @@

+
+ + +
+ + + setOnUpdateCallback(fn) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ fn + +
+
+ +
+ + + + + + + +
@@ -788,7 +833,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.PathSegment.html b/documentation/jsdoc/symbols/CAAT.PathSegment.html index c344d7f4..29cf5b76 100644 --- a/documentation/jsdoc/symbols/CAAT.PathSegment.html +++ b/documentation/jsdoc/symbols/CAAT.PathSegment.html @@ -355,6 +355,15 @@

+ +   + +
drawHandle(ctx, x, y) +
+
+ + +   @@ -580,6 +589,54 @@

+
+ + +
+ + + drawHandle(ctx, x, y) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ ctx + +
+
+ +
+ x + +
+
+ +
+ y + +
+
+ +
+ + + + + + + +
@@ -1147,7 +1204,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Point.html b/documentation/jsdoc/symbols/CAAT.Point.html index af648933..dbe6c945 100644 --- a/documentation/jsdoc/symbols/CAAT.Point.html +++ b/documentation/jsdoc/symbols/CAAT.Point.html @@ -1271,7 +1271,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Rectangle.html b/documentation/jsdoc/symbols/CAAT.Rectangle.html index 926480fa..8fa894fa 100644 --- a/documentation/jsdoc/symbols/CAAT.Rectangle.html +++ b/documentation/jsdoc/symbols/CAAT.Rectangle.html @@ -959,7 +959,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.Scene.html b/documentation/jsdoc/symbols/CAAT.Scene.html index 55e04963..2bffaad2 100644 --- a/documentation/jsdoc/symbols/CAAT.Scene.html +++ b/documentation/jsdoc/symbols/CAAT.Scene.html @@ -572,7 +572,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -1748,7 +1748,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.ShapeActor.html b/documentation/jsdoc/symbols/CAAT.ShapeActor.html index de6d2b3b..4a4d4c0e 100644 --- a/documentation/jsdoc/symbols/CAAT.ShapeActor.html +++ b/documentation/jsdoc/symbols/CAAT.ShapeActor.html @@ -472,7 +472,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -990,7 +990,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.SpriteImage.html b/documentation/jsdoc/symbols/CAAT.SpriteImage.html index 79eefe2b..f6d22692 100644 --- a/documentation/jsdoc/symbols/CAAT.SpriteImage.html +++ b/documentation/jsdoc/symbols/CAAT.SpriteImage.html @@ -2102,7 +2102,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.StarActor.html b/documentation/jsdoc/symbols/CAAT.StarActor.html index 68212e37..0fcb4b93 100644 --- a/documentation/jsdoc/symbols/CAAT.StarActor.html +++ b/documentation/jsdoc/symbols/CAAT.StarActor.html @@ -480,7 +480,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -1032,7 +1032,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:03 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TextActor.html b/documentation/jsdoc/symbols/CAAT.TextActor.html index c1218e65..d094c30f 100644 --- a/documentation/jsdoc/symbols/CAAT.TextActor.html +++ b/documentation/jsdoc/symbols/CAAT.TextActor.html @@ -508,7 +508,7 @@

-
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
+
Methods borrowed from class CAAT.ActorContainer:
__paintActor, addChild, addChildAt, addChildDelayed, addChildImmediately, animate, destroy, drawScreenBoundingBox, emptyChildren, endAnimate, findActorAtPosition, findActorById, findChild, getChildAt, getNumActiveChildren, getNumChildren, paintActor, paintActorGL, recalcSize, removeChild, removeFirstChild, setZOrder
Methods borrowed from class CAAT.Actor:
addBehavior, addListener, cacheAsBitmap, centerAt, centerOn, contains, create, emptyBehaviorList, enableDrag, enableEvents, fireEvent, getAnchor, getAnchorPercent, getBehavior, getId, getTextureGLPage, glNeedsFlush, glSetShader, initialize, invalidate, isGestureEnabled, isInAnimationFrame, modelToModel, modelToView, mouseClick, mouseDblClick, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseOut, mouseOver, mouseUp, removeBehaviorById, removeBehaviour, removeListener, resetTransform, setAlpha, setAnimationImageIndex, setAsButton, setBackgroundImage, setBackgroundImageOffset, setBounds, setButtonImageIndex, setChangeFPS, setClip, setDiscardable, setExpired, setFillStyle, setFrameTime, setGestureEnabled, setGLCoords, setGlobalAlpha, setGlobalAnchor, setId, setImageTransformation, setLocation, setModelViewMatrix, setOutOfFrameTime, setPaint, setParent, setPosition, setPositionAnchor, setPositionAnchored, setRotation, setRotationAnchor, setRotationAnchored, setScale, setScaleAnchor, setScaleAnchored, setScreenBounds, setSize, setSpriteIndex, setStrokeStyle, setupCollission, setUV, setVisible, viewToModel
@@ -1272,7 +1272,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.TimerTask.html b/documentation/jsdoc/symbols/CAAT.TimerTask.html index e35f1dcf..84f15a34 100644 --- a/documentation/jsdoc/symbols/CAAT.TimerTask.html +++ b/documentation/jsdoc/symbols/CAAT.TimerTask.html @@ -646,7 +646,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.html b/documentation/jsdoc/symbols/CAAT.html index 8d208a03..b49f669f 100644 --- a/documentation/jsdoc/symbols/CAAT.html +++ b/documentation/jsdoc/symbols/CAAT.html @@ -1955,7 +1955,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:44 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html index 1d0c7e6b..63b04610 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html @@ -1025,7 +1025,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html index 1b3b27b2..0307f14c 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html @@ -1054,7 +1054,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html index 51c19d07..e7060ef1 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html @@ -383,7 +383,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html index c36fcd44..af8cd4f6 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html +++ b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html @@ -568,7 +568,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/CAAT.modules.html b/documentation/jsdoc/symbols/CAAT.modules.html index 198cf4d6..218f044e 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.html +++ b/documentation/jsdoc/symbols/CAAT.modules.html @@ -476,7 +476,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:47 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:02 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/Function.html b/documentation/jsdoc/symbols/Function.html index 233e0b14..150122aa 100644 --- a/documentation/jsdoc/symbols/Function.html +++ b/documentation/jsdoc/symbols/Function.html @@ -392,7 +392,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:48 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:04 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/_global_.html b/documentation/jsdoc/symbols/_global_.html index d011f724..b450711b 100644 --- a/documentation/jsdoc/symbols/_global_.html +++ b/documentation/jsdoc/symbols/_global_.html @@ -712,7 +712,7 @@

- Documentation generated by JsDoc Toolkit 2.4.0 on Wed Feb 15 2012 23:45:44 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Mon Feb 20 2012 23:56:00 GMT+0100 (CET)
diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html index c62bdf63..f5b9b620 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_director.js.html @@ -257,1821 +257,1829 @@ 250 * @return this 251 */ 252 initialize : function(width, height, canvas, proxy) { -253 canvas = canvas || document.createElement('canvas'); -254 this.canvas = canvas; -255 -256 if ( typeof proxy==='undefined' ) { -257 proxy= canvas; -258 } -259 -260 this.setBounds(0, 0, width, height); -261 this.create(); -262 this.enableEvents(proxy); -263 -264 this.timeline = new Date().getTime(); -265 -266 // transition scene -267 this.transitionScene = new CAAT.Scene().create().setBounds(0, 0, width, height); -268 var transitionCanvas = document.createElement('canvas'); -269 transitionCanvas.width = width; -270 transitionCanvas.height = height; -271 var transitionImageActor = new CAAT.Actor().create().setBackgroundImage(transitionCanvas); -272 this.transitionScene.ctx = transitionCanvas.getContext('2d'); -273 this.transitionScene.addChildImmediately(transitionImageActor); -274 this.transitionScene.setEaseListener(this); -275 -276 this.checkDebug(); -277 -278 return this; -279 }, -280 glReset : function() { -281 this.pMatrix= makeOrtho( 0, this.referenceWidth, this.referenceHeight, 0, -1, 1 ); -282 this.gl.viewport(0,0,this.canvas.width,this.canvas.height); -283 this.glColorProgram.setMatrixUniform(this.pMatrix); -284 this.glTextureProgram.setMatrixUniform(this.pMatrix); -285 this.gl.viewportWidth = this.canvas.width; -286 this.gl.viewportHeight = this.canvas.height; -287 }, -288 /** -289 * Experimental. -290 * Initialize a gl enabled director. -291 * @param width -292 * @param height -293 * @param canvas -294 */ -295 initializeGL : function(width, height, canvas, proxy) { -296 -297 canvas = canvas || document.createElement('canvas'); -298 canvas.width = width; -299 canvas.height = height; -300 -301 if ( typeof proxy==='undefined' ) { -302 proxy= canvas; +253 if ( !canvas ) { +254 canvas= document.createElement('canvas'); +255 document.body.appendChild(canvas); +256 } +257 this.canvas = canvas; +258 +259 if ( typeof proxy==='undefined' ) { +260 proxy= canvas; +261 } +262 +263 this.setBounds(0, 0, width, height); +264 this.create(); +265 this.enableEvents(proxy); +266 +267 this.timeline = new Date().getTime(); +268 +269 // transition scene +270 this.transitionScene = new CAAT.Scene().create().setBounds(0, 0, width, height); +271 var transitionCanvas = document.createElement('canvas'); +272 transitionCanvas.width = width; +273 transitionCanvas.height = height; +274 var transitionImageActor = new CAAT.Actor().create().setBackgroundImage(transitionCanvas); +275 this.transitionScene.ctx = transitionCanvas.getContext('2d'); +276 this.transitionScene.addChildImmediately(transitionImageActor); +277 this.transitionScene.setEaseListener(this); +278 +279 this.checkDebug(); +280 +281 return this; +282 }, +283 glReset : function() { +284 this.pMatrix= makeOrtho( 0, this.referenceWidth, this.referenceHeight, 0, -1, 1 ); +285 this.gl.viewport(0,0,this.canvas.width,this.canvas.height); +286 this.glColorProgram.setMatrixUniform(this.pMatrix); +287 this.glTextureProgram.setMatrixUniform(this.pMatrix); +288 this.gl.viewportWidth = this.canvas.width; +289 this.gl.viewportHeight = this.canvas.height; +290 }, +291 /** +292 * Experimental. +293 * Initialize a gl enabled director. +294 * @param width +295 * @param height +296 * @param canvas +297 */ +298 initializeGL : function(width, height, canvas, proxy) { +299 +300 if ( !canvas ) { +301 canvas= document.createElement('canvas'); +302 document.body.appendChild(canvas); 303 } 304 -305 this.referenceWidth= width; -306 this.referenceHeight=height; +305 canvas.width = width; +306 canvas.height = height; 307 -308 var i; -309 -310 try { -311 this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); -312 this.gl.viewportWidth = width; -313 this.gl.viewportHeight = height; -314 CAAT.GLRENDER= true; -315 } catch(e) { -316 } -317 -318 if (this.gl) { -319 this.canvas = canvas; -320 this.create(); -321 this.setBounds(0, 0, width, height); -322 -323 this.crc = this.ctx; -324 this.enableEvents(canvas); -325 this.timeline = new Date().getTime(); -326 -327 this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); -328 this.glTextureProgram = new CAAT.TextureProgram(this.gl).create().initialize(); -329 this.glTextureProgram.useProgram(); -330 this.glReset(); -331 -332 -333 var maxTris = 512; -334 this.coords = new Float32Array(maxTris * 12); -335 this.uv = new Float32Array(maxTris * 8); -336 -337 this.gl.clearColor(0.0, 0.0, 0.0, 255); +308 if ( typeof proxy==='undefined' ) { +309 proxy= canvas; +310 } +311 +312 this.referenceWidth= width; +313 this.referenceHeight=height; +314 +315 var i; +316 +317 try { +318 this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); +319 this.gl.viewportWidth = width; +320 this.gl.viewportHeight = height; +321 CAAT.GLRENDER= true; +322 } catch(e) { +323 } +324 +325 if (this.gl) { +326 this.canvas = canvas; +327 this.create(); +328 this.setBounds(0, 0, width, height); +329 +330 this.crc = this.ctx; +331 this.enableEvents(canvas); +332 this.timeline = new Date().getTime(); +333 +334 this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); +335 this.glTextureProgram = new CAAT.TextureProgram(this.gl).create().initialize(); +336 this.glTextureProgram.useProgram(); +337 this.glReset(); 338 -339 if (this.front_to_back) { -340 this.gl.clearDepth(1.0); -341 this.gl.enable(this.gl.DEPTH_TEST); -342 this.gl.depthFunc(this.gl.LESS); -343 } else { -344 this.gl.disable(this.gl.DEPTH_TEST); -345 } -346 -347 this.gl.enable(this.gl.BLEND); -348 // Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); -349 this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); -350 this.glEnabled = true; -351 -352 this.checkDebug(); -353 } else { -354 // fallback to non gl enabled canvas. -355 return this.initialize(width, height, canvas); -356 } -357 -358 return this; -359 }, -360 /** -361 * Creates an initializes a Scene object. -362 * @return {CAAT.Scene} -363 */ -364 createScene : function() { -365 var scene = new CAAT.Scene().create(); -366 this.addScene(scene); -367 return scene; -368 }, -369 setImagesCache : function(imagesCache, tpW, tpH) { -370 -371 var i; -372 -373 if (null !== this.glTextureManager) { -374 this.glTextureManager.deletePages(); -375 this.glTextureManager = null; -376 } +339 +340 var maxTris = 512; +341 this.coords = new Float32Array(maxTris * 12); +342 this.uv = new Float32Array(maxTris * 8); +343 +344 this.gl.clearColor(0.0, 0.0, 0.0, 255); +345 +346 if (this.front_to_back) { +347 this.gl.clearDepth(1.0); +348 this.gl.enable(this.gl.DEPTH_TEST); +349 this.gl.depthFunc(this.gl.LESS); +350 } else { +351 this.gl.disable(this.gl.DEPTH_TEST); +352 } +353 +354 this.gl.enable(this.gl.BLEND); +355 // Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); +356 this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); +357 this.glEnabled = true; +358 +359 this.checkDebug(); +360 } else { +361 // fallback to non gl enabled canvas. +362 return this.initialize(width, height, canvas); +363 } +364 +365 return this; +366 }, +367 /** +368 * Creates an initializes a Scene object. +369 * @return {CAAT.Scene} +370 */ +371 createScene : function() { +372 var scene = new CAAT.Scene().create(); +373 this.addScene(scene); +374 return scene; +375 }, +376 setImagesCache : function(imagesCache, tpW, tpH) { 377 -378 // delete previous image identifiers -379 if ( this.imagesCache ) { -380 var ids= []; -381 for ( i = 0; i < this.imagesCache.length; i++) { -382 ids.push( this.imagesCache[i].id ); -383 } +378 var i; +379 +380 if (null !== this.glTextureManager) { +381 this.glTextureManager.deletePages(); +382 this.glTextureManager = null; +383 } 384 -385 for( i=0; i<ids.length; i++ ) { -386 delete this.imagesCache[ ids[i] ]; -387 } -388 } -389 -390 this.imagesCache = imagesCache; +385 // delete previous image identifiers +386 if ( this.imagesCache ) { +387 var ids= []; +388 for ( i = 0; i < this.imagesCache.length; i++) { +389 ids.push( this.imagesCache[i].id ); +390 } 391 -392 if ( imagesCache ) { -393 for ( i = 0; i < imagesCache.length; i++) { -394 this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; -395 } -396 } -397 -398 this.tpW = tpW || 2048; -399 this.tpH = tpH || 2048; -400 -401 this.updateGLPages(); -402 }, -403 updateGLPages : function() { -404 if (this.glEnabled) { -405 -406 this.glTextureManager = new CAAT.GLTexturePageManager(); -407 this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); -408 -409 this.currentTexturePage = this.glTextureManager.pages[0]; -410 this.glTextureProgram.setTexture(this.currentTexturePage.texture); -411 } -412 }, -413 setGLTexturePage : function( tp ) { -414 this.currentTexturePage = tp; -415 this.glTextureProgram.setTexture(tp.texture); -416 return this; -417 }, -418 /** -419 * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this -420 * function will try to recreate the whole GL texture pages. -421 * If many handcrafted images are to be added to the director, some performance can be achieved by calling -422 * <code>director.addImage(id,image,false)</code> many times and a final call with -423 * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages. -424 * -425 * @param id {string|object} an identitifier to retrieve the image with -426 * @param image {Image|HTMLCanvasElement} image to add to cache -427 * @param noUpdateGL {!boolean} unless otherwise stated, the director will -428 * try to recreate the texture pages. -429 */ -430 addImage : function( id, image, noUpdateGL ) { -431 if ( this.getImage(id) ) { -432 for (var i = 0; i < this.imagesCache.length; i++) { -433 if (this.imagesCache[i].id === id) { -434 this.imagesCache[i].image = image; -435 break; -436 } -437 } -438 this.imagesCache[ id ] = image; -439 } else { -440 this.imagesCache.push( { id: id, image: image } ); -441 this.imagesCache[id]= image; -442 } -443 -444 if ( !!!noUpdateGL ) { -445 this.updateGLPages( ); -446 } -447 }, -448 deleteImage : function( id, noUpdateGL ) { -449 for (var i = 0; i < this.imagesCache.length; i++) { -450 if (this.imagesCache[i].id === id) { -451 delete this.imagesCache[id]; -452 this.imagesCache.splice(i,1); -453 break; -454 } -455 } -456 if ( !!!noUpdateGL ) { -457 this.updateGLPages(); -458 } -459 }, -460 setGLCurrentOpacity : function(opacity) { -461 this.currentOpacity = opacity; -462 this.glTextureProgram.setAlpha(opacity); -463 }, -464 /** -465 * Render buffered elements. -466 * @param vertex -467 * @param coordsIndex -468 * @param uv -469 */ -470 glRender : function(vertex, coordsIndex, uv) { -471 -472 vertex = vertex || this.coords; -473 uv = uv || this.uv; -474 coordsIndex = coordsIndex || this.coordsIndex; -475 -476 var gl = this.gl; -477 -478 var numTris = coordsIndex / 12 * 2; -479 var numVertices = coordsIndex / 3; -480 -481 this.glTextureProgram.updateVertexBuffer(vertex); -482 this.glTextureProgram.updateUVBuffer(uv); -483 -484 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); -485 -486 }, -487 glFlush : function() { -488 if (this.coordsIndex !== 0) { -489 this.glRender(this.coords, this.coordsIndex, this.uv); -490 } -491 this.coordsIndex = 0; -492 this.uvIndex = 0; -493 -494 this.statistics.draws++; -495 }, -496 -497 findActorAtPosition : function(point) { -498 -499 // z-order -500 var cl= this.childrenList; -501 for( var i=cl.length-1; i>=0; i-- ) { -502 var child= this.childrenList[i]; +392 for( i=0; i<ids.length; i++ ) { +393 delete this.imagesCache[ ids[i] ]; +394 } +395 } +396 +397 this.imagesCache = imagesCache; +398 +399 if ( imagesCache ) { +400 for ( i = 0; i < imagesCache.length; i++) { +401 this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; +402 } +403 } +404 +405 this.tpW = tpW || 2048; +406 this.tpH = tpH || 2048; +407 +408 this.updateGLPages(); +409 }, +410 updateGLPages : function() { +411 if (this.glEnabled) { +412 +413 this.glTextureManager = new CAAT.GLTexturePageManager(); +414 this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); +415 +416 this.currentTexturePage = this.glTextureManager.pages[0]; +417 this.glTextureProgram.setTexture(this.currentTexturePage.texture); +418 } +419 }, +420 setGLTexturePage : function( tp ) { +421 this.currentTexturePage = tp; +422 this.glTextureProgram.setTexture(tp.texture); +423 return this; +424 }, +425 /** +426 * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this +427 * function will try to recreate the whole GL texture pages. +428 * If many handcrafted images are to be added to the director, some performance can be achieved by calling +429 * <code>director.addImage(id,image,false)</code> many times and a final call with +430 * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages. +431 * +432 * @param id {string|object} an identitifier to retrieve the image with +433 * @param image {Image|HTMLCanvasElement} image to add to cache +434 * @param noUpdateGL {!boolean} unless otherwise stated, the director will +435 * try to recreate the texture pages. +436 */ +437 addImage : function( id, image, noUpdateGL ) { +438 if ( this.getImage(id) ) { +439 for (var i = 0; i < this.imagesCache.length; i++) { +440 if (this.imagesCache[i].id === id) { +441 this.imagesCache[i].image = image; +442 break; +443 } +444 } +445 this.imagesCache[ id ] = image; +446 } else { +447 this.imagesCache.push( { id: id, image: image } ); +448 this.imagesCache[id]= image; +449 } +450 +451 if ( !!!noUpdateGL ) { +452 this.updateGLPages( ); +453 } +454 }, +455 deleteImage : function( id, noUpdateGL ) { +456 for (var i = 0; i < this.imagesCache.length; i++) { +457 if (this.imagesCache[i].id === id) { +458 delete this.imagesCache[id]; +459 this.imagesCache.splice(i,1); +460 break; +461 } +462 } +463 if ( !!!noUpdateGL ) { +464 this.updateGLPages(); +465 } +466 }, +467 setGLCurrentOpacity : function(opacity) { +468 this.currentOpacity = opacity; +469 this.glTextureProgram.setAlpha(opacity); +470 }, +471 /** +472 * Render buffered elements. +473 * @param vertex +474 * @param coordsIndex +475 * @param uv +476 */ +477 glRender : function(vertex, coordsIndex, uv) { +478 +479 vertex = vertex || this.coords; +480 uv = uv || this.uv; +481 coordsIndex = coordsIndex || this.coordsIndex; +482 +483 var gl = this.gl; +484 +485 var numTris = coordsIndex / 12 * 2; +486 var numVertices = coordsIndex / 3; +487 +488 this.glTextureProgram.updateVertexBuffer(vertex); +489 this.glTextureProgram.updateUVBuffer(uv); +490 +491 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); +492 +493 }, +494 glFlush : function() { +495 if (this.coordsIndex !== 0) { +496 this.glRender(this.coords, this.coordsIndex, this.uv); +497 } +498 this.coordsIndex = 0; +499 this.uvIndex = 0; +500 +501 this.statistics.draws++; +502 }, 503 -504 var np= new CAAT.Point( point.x, point.y, 0 ); -505 var contained= child.findActorAtPosition( np ); -506 if ( null!==contained ) { -507 return contained; -508 } -509 } +504 findActorAtPosition : function(point) { +505 +506 // z-order +507 var cl= this.childrenList; +508 for( var i=cl.length-1; i>=0; i-- ) { +509 var child= this.childrenList[i]; 510 -511 return this; -512 }, -513 -514 /** -515 * -516 * Reset statistics information. -517 * -518 * @private -519 */ -520 resetStats : function() { -521 this.statistics.size_total= 0; -522 this.statistics.size_active=0; -523 this.statistics.draws= 0; -524 }, -525 -526 /** -527 * This is the entry point for the animation system of the Director. -528 * The director is fed with the elapsed time value to maintain a virtual timeline. -529 * This virtual timeline will provide each Scene with its own virtual timeline, and will only -530 * feed time when the Scene is the current Scene, or is being switched. -531 * -532 * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be -533 * set up as a single clip area. -534 * -535 * @param time {number} integer indicating the elapsed time between two consecutive frames of the -536 * Director. -537 */ -538 render : function(time) { -539 -540 this.time += time; -541 -542 this.animate(this,time); -543 -544 if ( CAAT.DEBUG ) { -545 this.resetStats(); -546 } -547 -548 /** -549 * draw director active scenes. -550 */ -551 var ne = this.childrenList.length; -552 var i, tt, c; -553 var ctx= this.ctx; +511 var np= new CAAT.Point( point.x, point.y, 0 ); +512 var contained= child.findActorAtPosition( np ); +513 if ( null!==contained ) { +514 return contained; +515 } +516 } +517 +518 return this; +519 }, +520 +521 /** +522 * +523 * Reset statistics information. +524 * +525 * @private +526 */ +527 resetStats : function() { +528 this.statistics.size_total= 0; +529 this.statistics.size_active=0; +530 this.statistics.draws= 0; +531 }, +532 +533 /** +534 * This is the entry point for the animation system of the Director. +535 * The director is fed with the elapsed time value to maintain a virtual timeline. +536 * This virtual timeline will provide each Scene with its own virtual timeline, and will only +537 * feed time when the Scene is the current Scene, or is being switched. +538 * +539 * If dirty rectangles are enabled and canvas is used for rendering, the dirty rectangles will be +540 * set up as a single clip area. +541 * +542 * @param time {number} integer indicating the elapsed time between two consecutive frames of the +543 * Director. +544 */ +545 render : function(time) { +546 +547 this.time += time; +548 +549 this.animate(this,time); +550 +551 if ( CAAT.DEBUG ) { +552 this.resetStats(); +553 } 554 -555 if (this.glEnabled) { -556 -557 this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); -558 this.coordsIndex = 0; -559 this.uvIndex = 0; -560 -561 for (i = 0; i < ne; i++) { -562 c = this.childrenList[i]; -563 if (c.isInAnimationFrame(this.time)) { -564 tt = c.time - c.start_time; -565 if ( c.onRenderStart ) { -566 c.onRenderStart(tt); -567 } -568 c.paintActorGL(this, tt); -569 if ( c.onRenderEnd ) { -570 c.onRenderEnd(tt); -571 } -572 -573 if ( !c.isPaused() ) { -574 c.time += time; -575 } -576 -577 if ( CAAT.DEBUG ) { -578 this.statistics.size_total+= c.size_total; -579 this.statistics.size_active+= c.size_active; -580 } -581 -582 } -583 } -584 -585 this.glFlush(); -586 -587 } else { -588 ctx.globalAlpha = 1; -589 ctx.globalCompositeOperation = 'source-over'; -590 -591 ctx.save(); -592 if ( this.dirtyRectsEnabled ) { -593 this.modelViewMatrix.transformRenderingContext( ctx ); -594 -595 if ( !CAAT.DEBUG_DIRTYRECTS ) { -596 ctx.beginPath(); -597 this.nDirtyRects=0; -598 var dr= this.cDirtyRects; -599 for( i=0; i<dr.length; i++ ) { -600 var drr= dr[i]; -601 if ( !drr.isEmpty() ) { -602 //ctx.rect( (drr.x|0)+.5, (drr.y|0)+.5, 1+(drr.width|0), 1+(drr.height|0) ); -603 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); -604 this.nDirtyRects++; -605 } -606 } -607 ctx.clip(); -608 } else { -609 ctx.clearRect(0, 0, this.width, this.height); -610 } -611 -612 } else if (this.clear===true ) { -613 ctx.clearRect(0, 0, this.width, this.height); -614 } -615 -616 for (i = 0; i < ne; i++) { -617 c= this.childrenList[i]; +555 /** +556 * draw director active scenes. +557 */ +558 var ne = this.childrenList.length; +559 var i, tt, c; +560 var ctx= this.ctx; +561 +562 if (this.glEnabled) { +563 +564 this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); +565 this.coordsIndex = 0; +566 this.uvIndex = 0; +567 +568 for (i = 0; i < ne; i++) { +569 c = this.childrenList[i]; +570 if (c.isInAnimationFrame(this.time)) { +571 tt = c.time - c.start_time; +572 if ( c.onRenderStart ) { +573 c.onRenderStart(tt); +574 } +575 c.paintActorGL(this, tt); +576 if ( c.onRenderEnd ) { +577 c.onRenderEnd(tt); +578 } +579 +580 if ( !c.isPaused() ) { +581 c.time += time; +582 } +583 +584 if ( CAAT.DEBUG ) { +585 this.statistics.size_total+= c.size_total; +586 this.statistics.size_active+= c.size_active; +587 } +588 +589 } +590 } +591 +592 this.glFlush(); +593 +594 } else { +595 ctx.globalAlpha = 1; +596 ctx.globalCompositeOperation = 'source-over'; +597 +598 ctx.save(); +599 if ( this.dirtyRectsEnabled ) { +600 this.modelViewMatrix.transformRenderingContext( ctx ); +601 +602 if ( !CAAT.DEBUG_DIRTYRECTS ) { +603 ctx.beginPath(); +604 this.nDirtyRects=0; +605 var dr= this.cDirtyRects; +606 for( i=0; i<dr.length; i++ ) { +607 var drr= dr[i]; +608 if ( !drr.isEmpty() ) { +609 //ctx.rect( (drr.x|0)+.5, (drr.y|0)+.5, 1+(drr.width|0), 1+(drr.height|0) ); +610 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); +611 this.nDirtyRects++; +612 } +613 } +614 ctx.clip(); +615 } else { +616 ctx.clearRect(0, 0, this.width, this.height); +617 } 618 -619 if (c.isInAnimationFrame(this.time)) { -620 tt = c.time - c.start_time; -621 // ctx.save(); +619 } else if (this.clear===true ) { +620 ctx.clearRect(0, 0, this.width, this.height); +621 } 622 -623 if ( c.onRenderStart ) { -624 c.onRenderStart(tt); -625 } -626 -627 if ( !CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled ) { -628 if ( this.nDirtyRects ) { -629 c.paintActor(this, tt); -630 } -631 } else { -632 c.paintActor(this, tt); -633 } -634 -635 if ( c.onRenderEnd ) { -636 c.onRenderEnd(tt); -637 } -638 // ctx.restore(); -639 -640 if (CAAT.DEBUGAABB) { -641 ctx.globalAlpha= 1; -642 ctx.globalCompositeOperation= 'source-over'; -643 this.modelViewMatrix.transformRenderingContextSet( ctx ); -644 c.drawScreenBoundingBox(this, tt); -645 } +623 for (i = 0; i < ne; i++) { +624 c= this.childrenList[i]; +625 +626 if (c.isInAnimationFrame(this.time)) { +627 tt = c.time - c.start_time; +628 // ctx.save(); +629 +630 if ( c.onRenderStart ) { +631 c.onRenderStart(tt); +632 } +633 +634 if ( !CAAT.DEBUG_DIRTYRECTS && this.dirtyRectsEnabled ) { +635 if ( this.nDirtyRects ) { +636 c.paintActor(this, tt); +637 } +638 } else { +639 c.paintActor(this, tt); +640 } +641 +642 if ( c.onRenderEnd ) { +643 c.onRenderEnd(tt); +644 } +645 // ctx.restore(); 646 -647 if ( !c.isPaused() ) { -648 c.time += time; -649 } -650 -651 if ( CAAT.DEBUG ) { -652 this.statistics.size_total+= c.size_total; -653 this.statistics.size_active+= c.size_active; -654 this.statistics.size_dirtyRects= this.nDirtyRects; -655 } -656 -657 } -658 } -659 -660 if ( this.nDirtyRects>0 && CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { -661 ctx.beginPath(); -662 this.nDirtyRects=0; -663 var dr= this.cDirtyRects; -664 for( i=0; i<dr.length; i++ ) { -665 var drr= dr[i]; -666 if ( !drr.isEmpty() ) { -667 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); -668 this.nDirtyRects++; -669 } -670 } -671 -672 ctx.clip(); -673 ctx.fillStyle='rgba(160,255,150,.4)'; -674 ctx.fillRect(0,0,this.width, this.height); -675 } -676 -677 ctx.restore(); -678 } -679 -680 this.frameCounter++; -681 }, -682 /** -683 * A director is a very special kind of actor. -684 * Its animation routine simple sets its modelViewMatrix in case some transformation's been -685 * applied. -686 * No behaviors are allowed for Director instances. -687 * @param director {CAAT.Director} redundant reference to CAAT.Director itself -688 * @param time {number} director time. -689 */ -690 animate : function(director, time) { -691 this.setModelViewMatrix(this); -692 this.setScreenBounds(); -693 -694 this.dirty= false; -695 this.invalid= false; -696 this.dirtyRectsIndex= -1; -697 this.cDirtyRects= []; -698 -699 var cl= this.childrenList; -700 var cli; -701 for (var i = 0; i < cl.length; i++) { -702 cli= cl[i]; -703 var tt = cli.time - cli.start_time; -704 cli.animate(this, tt); -705 } -706 -707 return this; -708 }, -709 /** -710 * Add a rectangle to the list of dirty screen areas which should be redrawn. -711 * This is the opposite method to clear the whole screen and repaint everything again. -712 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this -713 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or -714 * even lowers performance under others, so it is a developer choice to activate them via a call to -715 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). -716 * -717 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping -718 * rectangles will be removed and intersecting ones will be unioned. -719 * -720 * Before calling this method, check if this.dirtyRectsEnabled is true. -721 * -722 * @param rectangle {CAAT.Rectangle} -723 */ -724 addDirtyRect : function( rectangle ) { -725 -726 if ( rectangle.isEmpty() ) { -727 return; -728 } -729 -730 var i, dr, j, drj; -731 var cdr= this.cDirtyRects; +647 if (CAAT.DEBUGAABB) { +648 ctx.globalAlpha= 1; +649 ctx.globalCompositeOperation= 'source-over'; +650 this.modelViewMatrix.transformRenderingContextSet( ctx ); +651 c.drawScreenBoundingBox(this, tt); +652 } +653 +654 if ( !c.isPaused() ) { +655 c.time += time; +656 } +657 +658 if ( CAAT.DEBUG ) { +659 this.statistics.size_total+= c.size_total; +660 this.statistics.size_active+= c.size_active; +661 this.statistics.size_dirtyRects= this.nDirtyRects; +662 } +663 +664 } +665 } +666 +667 if ( this.nDirtyRects>0 && CAAT.DEBUG && CAAT.DEBUG_DIRTYRECTS ) { +668 ctx.beginPath(); +669 this.nDirtyRects=0; +670 var dr= this.cDirtyRects; +671 for( i=0; i<dr.length; i++ ) { +672 var drr= dr[i]; +673 if ( !drr.isEmpty() ) { +674 ctx.rect( drr.x|0, drr.y|0, 1+(drr.width|0), 1+(drr.height|0) ); +675 this.nDirtyRects++; +676 } +677 } +678 +679 ctx.clip(); +680 ctx.fillStyle='rgba(160,255,150,.4)'; +681 ctx.fillRect(0,0,this.width, this.height); +682 } +683 +684 ctx.restore(); +685 } +686 +687 this.frameCounter++; +688 }, +689 /** +690 * A director is a very special kind of actor. +691 * Its animation routine simple sets its modelViewMatrix in case some transformation's been +692 * applied. +693 * No behaviors are allowed for Director instances. +694 * @param director {CAAT.Director} redundant reference to CAAT.Director itself +695 * @param time {number} director time. +696 */ +697 animate : function(director, time) { +698 this.setModelViewMatrix(this); +699 this.setScreenBounds(); +700 +701 this.dirty= false; +702 this.invalid= false; +703 this.dirtyRectsIndex= -1; +704 this.cDirtyRects= []; +705 +706 var cl= this.childrenList; +707 var cli; +708 for (var i = 0; i < cl.length; i++) { +709 cli= cl[i]; +710 var tt = cli.time - cli.start_time; +711 cli.animate(this, tt); +712 } +713 +714 return this; +715 }, +716 /** +717 * Add a rectangle to the list of dirty screen areas which should be redrawn. +718 * This is the opposite method to clear the whole screen and repaint everything again. +719 * Despite i'm not very fond of dirty rectangles because it needs some extra calculations, this +720 * procedure has shown to be speeding things up under certain situations. Nevertheless it doesn't or +721 * even lowers performance under others, so it is a developer choice to activate them via a call to +722 * setClear( CAAT.Director.CLEAR_DIRTY_RECTS ). +723 * +724 * This function, not only tracks a list of dirty rectangles, but tries to optimize the list. Overlapping +725 * rectangles will be removed and intersecting ones will be unioned. +726 * +727 * Before calling this method, check if this.dirtyRectsEnabled is true. +728 * +729 * @param rectangle {CAAT.Rectangle} +730 */ +731 addDirtyRect : function( rectangle ) { 732 -733 for( i=0; i<cdr.length; i++ ) { -734 dr= cdr[i]; -735 if ( !dr.isEmpty() && dr.intersects( rectangle ) ) { -736 var intersected= true; -737 while( intersected ) { -738 dr.unionRectangle( rectangle ); +733 if ( rectangle.isEmpty() ) { +734 return; +735 } +736 +737 var i, dr, j, drj; +738 var cdr= this.cDirtyRects; 739 -740 for( j=0; j<cdr.length; j++ ) { -741 if ( j!==i ) { -742 drj= cdr[j]; -743 if ( !drj.isEmpty() && drj.intersects( dr ) ) { -744 dr.unionRectangle( drj ); -745 drj.setEmpty(); -746 break; -747 } -748 } -749 } -750 -751 if ( j==cdr.length ) { -752 intersected= false; -753 } -754 } -755 -756 for( j=0; j<cdr.length; j++ ) { -757 if ( cdr[j].isEmpty() ) { -758 cdr.splice( j, 1 ); -759 } -760 } -761 -762 return; -763 } -764 } -765 -766 this.dirtyRectsIndex++; -767 -768 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { -769 for( i=0; i<32; i++ ) { -770 this.dirtyRects.push( new CAAT.Rectangle() ); -771 } -772 } -773 -774 var r= this.dirtyRects[ this.dirtyRectsIndex ]; -775 -776 r.x= rectangle.x; -777 r.y= rectangle.y; -778 r.x1= rectangle.x1; -779 r.y1= rectangle.y1; -780 r.width= rectangle.width; -781 r.height= rectangle.height; +740 for( i=0; i<cdr.length; i++ ) { +741 dr= cdr[i]; +742 if ( !dr.isEmpty() && dr.intersects( rectangle ) ) { +743 var intersected= true; +744 while( intersected ) { +745 dr.unionRectangle( rectangle ); +746 +747 for( j=0; j<cdr.length; j++ ) { +748 if ( j!==i ) { +749 drj= cdr[j]; +750 if ( !drj.isEmpty() && drj.intersects( dr ) ) { +751 dr.unionRectangle( drj ); +752 drj.setEmpty(); +753 break; +754 } +755 } +756 } +757 +758 if ( j==cdr.length ) { +759 intersected= false; +760 } +761 } +762 +763 for( j=0; j<cdr.length; j++ ) { +764 if ( cdr[j].isEmpty() ) { +765 cdr.splice( j, 1 ); +766 } +767 } +768 +769 return; +770 } +771 } +772 +773 this.dirtyRectsIndex++; +774 +775 if ( this.dirtyRectsIndex>=this.dirtyRects.length ) { +776 for( i=0; i<32; i++ ) { +777 this.dirtyRects.push( new CAAT.Rectangle() ); +778 } +779 } +780 +781 var r= this.dirtyRects[ this.dirtyRectsIndex ]; 782 -783 this.cDirtyRects.push( r ); -784 -785 }, -786 /** -787 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of -788 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from -789 * one to another, first of all an scene is drawn to offscreen, and that image is translated. -790 * <p> -791 * Until the creation of this method, both scenes where drawn while transitioning with -792 * its performance penalty since drawing two scenes could be twice as expensive than drawing -793 * only one. -794 * <p> -795 * Though a high performance increase, we should keep an eye on memory consumption. -796 * -797 * @param ctx a <code>canvas.getContext('2d')</code> instnce. -798 * @param scene {CAAT.Scene} the scene to draw offscreen. -799 */ -800 renderToContext : function(ctx, scene) { -801 /** -802 * draw actors on scene. -803 */ -804 if (scene.isInAnimationFrame(this.time)) { -805 ctx.globalAlpha = 1; -806 ctx.globalCompositeOperation = 'source-over'; -807 ctx.clearRect(0, 0, this.width, this.height); -808 ctx.setTransform(1,0,0, 0,1,0); -809 -810 var octx = this.ctx; -811 var ocrc = this.crc; -812 -813 this.ctx = this.crc = ctx; -814 ctx.save(); -815 -816 /** -817 * to draw an scene to an offscreen canvas, we have to: -818 * 1.- save diector's world model view matrix -819 * 2.- set no transformation on director since we want the offscreen to -820 * be drawn 1:1. -821 * 3.- set world dirty flag, so that the scene will recalculate its matrices -822 * 4.- animate the scene -823 * 5.- paint the scene -824 * 6.- restore world model view matrix. -825 */ -826 var matwmv= this.worldModelViewMatrix; -827 this.worldModelViewMatrix= new CAAT.Matrix(); -828 this.wdirty= true; -829 scene.animate(this, scene.time); -830 if ( scene.onRenderStart ) { -831 scene.onRenderStart(scene.time); -832 } -833 scene.paintActor(this, scene.time); -834 if ( scene.onRenderEnd ) { -835 scene.onRenderEnd(scene.time); -836 } -837 this.worldModelViewMatrix = matwmv; -838 -839 ctx.restore(); -840 -841 this.ctx = octx; -842 this.crc = ocrc; -843 } -844 }, -845 /** -846 * Add a new Scene to Director's Scene list. By adding a Scene to the Director -847 * does not mean it will be immediately visible, you should explicitly call either -848 * <ul> -849 * <li>easeIn -850 * <li>easeInOut -851 * <li>easeInOutRandom -852 * <li>setScene -853 * <li>or any of the scene switching methods -854 * </ul> -855 * -856 * @param scene {CAAT.Scene} an CAAT.Scene object. -857 */ -858 addScene : function(scene) { -859 scene.setBounds(0, 0, this.width, this.height); -860 this.scenes.push(scene); -861 scene.setEaseListener(this); -862 if (null === this.currentScene) { -863 this.setScene(0); -864 } -865 }, -866 /** -867 * Get the number of scenes contained in the Director. -868 * @return {number} the number of scenes contained in the Director. -869 */ -870 getNumScenes : function() { -871 return this.scenes.length; +783 r.x= rectangle.x; +784 r.y= rectangle.y; +785 r.x1= rectangle.x1; +786 r.y1= rectangle.y1; +787 r.width= rectangle.width; +788 r.height= rectangle.height; +789 +790 this.cDirtyRects.push( r ); +791 +792 }, +793 /** +794 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of +795 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from +796 * one to another, first of all an scene is drawn to offscreen, and that image is translated. +797 * <p> +798 * Until the creation of this method, both scenes where drawn while transitioning with +799 * its performance penalty since drawing two scenes could be twice as expensive than drawing +800 * only one. +801 * <p> +802 * Though a high performance increase, we should keep an eye on memory consumption. +803 * +804 * @param ctx a <code>canvas.getContext('2d')</code> instnce. +805 * @param scene {CAAT.Scene} the scene to draw offscreen. +806 */ +807 renderToContext : function(ctx, scene) { +808 /** +809 * draw actors on scene. +810 */ +811 if (scene.isInAnimationFrame(this.time)) { +812 ctx.globalAlpha = 1; +813 ctx.globalCompositeOperation = 'source-over'; +814 ctx.clearRect(0, 0, this.width, this.height); +815 ctx.setTransform(1,0,0, 0,1,0); +816 +817 var octx = this.ctx; +818 var ocrc = this.crc; +819 +820 this.ctx = this.crc = ctx; +821 ctx.save(); +822 +823 /** +824 * to draw an scene to an offscreen canvas, we have to: +825 * 1.- save diector's world model view matrix +826 * 2.- set no transformation on director since we want the offscreen to +827 * be drawn 1:1. +828 * 3.- set world dirty flag, so that the scene will recalculate its matrices +829 * 4.- animate the scene +830 * 5.- paint the scene +831 * 6.- restore world model view matrix. +832 */ +833 var matwmv= this.worldModelViewMatrix; +834 this.worldModelViewMatrix= new CAAT.Matrix(); +835 this.wdirty= true; +836 scene.animate(this, scene.time); +837 if ( scene.onRenderStart ) { +838 scene.onRenderStart(scene.time); +839 } +840 scene.paintActor(this, scene.time); +841 if ( scene.onRenderEnd ) { +842 scene.onRenderEnd(scene.time); +843 } +844 this.worldModelViewMatrix = matwmv; +845 +846 ctx.restore(); +847 +848 this.ctx = octx; +849 this.crc = ocrc; +850 } +851 }, +852 /** +853 * Add a new Scene to Director's Scene list. By adding a Scene to the Director +854 * does not mean it will be immediately visible, you should explicitly call either +855 * <ul> +856 * <li>easeIn +857 * <li>easeInOut +858 * <li>easeInOutRandom +859 * <li>setScene +860 * <li>or any of the scene switching methods +861 * </ul> +862 * +863 * @param scene {CAAT.Scene} an CAAT.Scene object. +864 */ +865 addScene : function(scene) { +866 scene.setBounds(0, 0, this.width, this.height); +867 this.scenes.push(scene); +868 scene.setEaseListener(this); +869 if (null === this.currentScene) { +870 this.setScene(0); +871 } 872 }, 873 /** -874 * This method offers full control over the process of switching between any given two Scenes. -875 * To apply this method, you must specify the type of transition to apply for each Scene and -876 * the anchor to keep the Scene pinned at. -877 * <p> -878 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: -879 * <ul> -880 * <li>EASE_ROTATION -881 * <li>EASE_SCALE -882 * <li>EASE_TRANSLATION -883 * </ul> -884 * -885 * <p> -886 * The anchor will be any of these values defined in CAAT.Actor.prototype: -887 * <ul> -888 * <li>ANCHOR_CENTER -889 * <li>ANCHOR_TOP -890 * <li>ANCHOR_BOTTOM -891 * <li>ANCHOR_LEFT -892 * <li>ANCHOR_RIGHT -893 * <li>ANCHOR_TOP_LEFT -894 * <li>ANCHOR_TOP_RIGHT -895 * <li>ANCHOR_BOTTOM_LEFT -896 * <li>ANCHOR_BOTTOM_RIGHT -897 * </ul> -898 * -899 * <p> -900 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the -901 * point by which the scene will scaled. -902 * -903 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. -904 * @param typein integer indicating the type of transition to apply to the bringing in Scene. -905 * @param anchorin integer indicating the anchor of the bringing in Scene. -906 * @param outSceneIndex integer indicating the Scene index to take away from the Director. -907 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. -908 * @param anchorout integer indicating the anchor of the taking away Scene. -909 * @param time inteter indicating the time to perform the process of switchihg between Scene object -910 * in milliseconds. -911 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to -912 * the scenes. -913 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. -914 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. -915 */ -916 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { -917 -918 if (inSceneIndex === this.getCurrentSceneIndex()) { -919 return; -920 } -921 -922 var ssin = this.scenes[ inSceneIndex ]; -923 var sout = this.scenes[ outSceneIndex ]; +874 * Get the number of scenes contained in the Director. +875 * @return {number} the number of scenes contained in the Director. +876 */ +877 getNumScenes : function() { +878 return this.scenes.length; +879 }, +880 /** +881 * This method offers full control over the process of switching between any given two Scenes. +882 * To apply this method, you must specify the type of transition to apply for each Scene and +883 * the anchor to keep the Scene pinned at. +884 * <p> +885 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: +886 * <ul> +887 * <li>EASE_ROTATION +888 * <li>EASE_SCALE +889 * <li>EASE_TRANSLATION +890 * </ul> +891 * +892 * <p> +893 * The anchor will be any of these values defined in CAAT.Actor.prototype: +894 * <ul> +895 * <li>ANCHOR_CENTER +896 * <li>ANCHOR_TOP +897 * <li>ANCHOR_BOTTOM +898 * <li>ANCHOR_LEFT +899 * <li>ANCHOR_RIGHT +900 * <li>ANCHOR_TOP_LEFT +901 * <li>ANCHOR_TOP_RIGHT +902 * <li>ANCHOR_BOTTOM_LEFT +903 * <li>ANCHOR_BOTTOM_RIGHT +904 * </ul> +905 * +906 * <p> +907 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the +908 * point by which the scene will scaled. +909 * +910 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. +911 * @param typein integer indicating the type of transition to apply to the bringing in Scene. +912 * @param anchorin integer indicating the anchor of the bringing in Scene. +913 * @param outSceneIndex integer indicating the Scene index to take away from the Director. +914 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. +915 * @param anchorout integer indicating the anchor of the taking away Scene. +916 * @param time inteter indicating the time to perform the process of switchihg between Scene object +917 * in milliseconds. +918 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to +919 * the scenes. +920 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. +921 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. +922 */ +923 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { 924 -925 if (!this.glEnabled && !navigator.browser==='iOS') { -926 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); -927 this.renderToContext(this.transitionScene.ctx, sout); -928 sout = this.transitionScene; -929 } -930 -931 ssin.setExpired(false); -932 sout.setExpired(false); -933 -934 ssin.mouseEnabled = false; -935 sout.mouseEnabled = false; -936 -937 ssin.resetTransform(); -938 sout.resetTransform(); -939 -940 ssin.setLocation(0, 0); -941 sout.setLocation(0, 0); -942 -943 ssin.alpha = 1; -944 sout.alpha = 1; -945 -946 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { -947 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); -948 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { -949 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); -950 } else { -951 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); -952 } -953 -954 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { -955 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); -956 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { -957 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); -958 } else { -959 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); -960 } -961 -962 this.childrenList = []; -963 -964 this.addChild(sout); -965 this.addChild(ssin); -966 }, -967 /** -968 * This method will switch between two given Scene indexes (ie, take away scene number 2, -969 * and bring in scene number 5). -970 * <p> -971 * It will randomly choose for each Scene the type of transition to apply and the anchor -972 * point of each transition type. -973 * <p> -974 * It will also set for different kind of transitions the following interpolators: -975 * <ul> -976 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. -977 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 -978 * <li>EASE_TRANSLATION -> BounceOutInterpolator -979 * </ul> -980 * -981 * <p> -982 * These are the default values, and could not be changed by now. -983 * This method in final instance delegates the process to easeInOutMethod. -984 * -985 * @see easeInOutMethod. -986 * -987 * @param inIndex integer indicating the entering scene index. -988 * @param outIndex integer indicating the exiting scene index. -989 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. -990 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. -991 */ -992 easeInOutRandom : function(inIndex, outIndex, time, alpha) { -993 -994 var pin = Math.random(); -995 var pout = Math.random(); -996 -997 var typeIn; -998 var interpolatorIn; -999 -1000 if (pin < 0.33) { -1001 typeIn = CAAT.Scene.prototype.EASE_ROTATION; -1002 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -1003 } else if (pin < 0.66) { -1004 typeIn = CAAT.Scene.prototype.EASE_SCALE; -1005 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); -1006 } else { -1007 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; -1008 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); -1009 } -1010 -1011 var typeOut; -1012 var interpolatorOut; -1013 -1014 if (pout < 0.33) { -1015 typeOut = CAAT.Scene.prototype.EASE_ROTATION; -1016 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -1017 } else if (pout < 0.66) { -1018 typeOut = CAAT.Scene.prototype.EASE_SCALE; -1019 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); -1020 } else { -1021 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; -1022 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); -1023 } -1024 -1025 this.easeInOut( -1026 inIndex, -1027 typeIn, -1028 (Math.random() * 8.99) >> 0, -1029 -1030 outIndex, -1031 typeOut, -1032 (Math.random() * 8.99) >> 0, -1033 -1034 time, -1035 alpha, +925 if (inSceneIndex === this.getCurrentSceneIndex()) { +926 return; +927 } +928 +929 var ssin = this.scenes[ inSceneIndex ]; +930 var sout = this.scenes[ outSceneIndex ]; +931 +932 if (!this.glEnabled && !navigator.browser==='iOS') { +933 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); +934 this.renderToContext(this.transitionScene.ctx, sout); +935 sout = this.transitionScene; +936 } +937 +938 ssin.setExpired(false); +939 sout.setExpired(false); +940 +941 ssin.mouseEnabled = false; +942 sout.mouseEnabled = false; +943 +944 ssin.resetTransform(); +945 sout.resetTransform(); +946 +947 ssin.setLocation(0, 0); +948 sout.setLocation(0, 0); +949 +950 ssin.alpha = 1; +951 sout.alpha = 1; +952 +953 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { +954 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); +955 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { +956 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); +957 } else { +958 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); +959 } +960 +961 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { +962 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); +963 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { +964 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); +965 } else { +966 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); +967 } +968 +969 this.childrenList = []; +970 +971 this.addChild(sout); +972 this.addChild(ssin); +973 }, +974 /** +975 * This method will switch between two given Scene indexes (ie, take away scene number 2, +976 * and bring in scene number 5). +977 * <p> +978 * It will randomly choose for each Scene the type of transition to apply and the anchor +979 * point of each transition type. +980 * <p> +981 * It will also set for different kind of transitions the following interpolators: +982 * <ul> +983 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +984 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +985 * <li>EASE_TRANSLATION -> BounceOutInterpolator +986 * </ul> +987 * +988 * <p> +989 * These are the default values, and could not be changed by now. +990 * This method in final instance delegates the process to easeInOutMethod. +991 * +992 * @see easeInOutMethod. +993 * +994 * @param inIndex integer indicating the entering scene index. +995 * @param outIndex integer indicating the exiting scene index. +996 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. +997 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. +998 */ +999 easeInOutRandom : function(inIndex, outIndex, time, alpha) { +1000 +1001 var pin = Math.random(); +1002 var pout = Math.random(); +1003 +1004 var typeIn; +1005 var interpolatorIn; +1006 +1007 if (pin < 0.33) { +1008 typeIn = CAAT.Scene.prototype.EASE_ROTATION; +1009 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +1010 } else if (pin < 0.66) { +1011 typeIn = CAAT.Scene.prototype.EASE_SCALE; +1012 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); +1013 } else { +1014 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; +1015 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); +1016 } +1017 +1018 var typeOut; +1019 var interpolatorOut; +1020 +1021 if (pout < 0.33) { +1022 typeOut = CAAT.Scene.prototype.EASE_ROTATION; +1023 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +1024 } else if (pout < 0.66) { +1025 typeOut = CAAT.Scene.prototype.EASE_SCALE; +1026 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); +1027 } else { +1028 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; +1029 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); +1030 } +1031 +1032 this.easeInOut( +1033 inIndex, +1034 typeIn, +1035 (Math.random() * 8.99) >> 0, 1036 -1037 interpolatorIn, -1038 interpolatorOut); -1039 -1040 }, -1041 /** -1042 * This method changes Director's current Scene to the scene index indicated by -1043 * inSceneIndex parameter. The Scene running in the director won't be eased out. -1044 * -1045 * @see {CAAT.Interpolator} -1046 * @see {CAAT.Actor} -1047 * @see {CAAT.Scene} -1048 * -1049 * @param inSceneIndex integer indicating the new Scene to set as current. -1050 * @param type integer indicating the type of transition to apply to bring the new current -1051 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, -1052 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. -1053 * @param time integer indicating how much time in milliseconds the Scene entrance will take. -1054 * @param alpha boolean indicating whether alpha transparency fading will be applied to the -1055 * entereing Scene. -1056 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of -1057 * CAAT.Actor.prototype.ANCHOR_* values. -1058 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to -1059 * apply. -1060 */ -1061 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { -1062 var sin = this.scenes[ inSceneIndex ]; -1063 if (type === CAAT.Scene.prototype.EASE_ROTATION) { -1064 sin.easeRotationIn(time, alpha, anchor, interpolator); -1065 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { -1066 sin.easeScaleIn(0, time, alpha, anchor, interpolator); -1067 } else { -1068 sin.easeTranslationIn(time, alpha, anchor, interpolator); -1069 } -1070 this.childrenList = []; -1071 this.addChild(sin); -1072 -1073 sin.resetTransform(); -1074 sin.setLocation(0, 0); -1075 sin.alpha = 1; -1076 sin.mouseEnabled = false; -1077 sin.setExpired(false); -1078 }, -1079 /** -1080 * Changes (or sets) the current Director scene to the index -1081 * parameter. There will be no transition on scene change. -1082 * @param sceneIndex {number} an integer indicating the index of the target Scene -1083 * to be shown. -1084 */ -1085 setScene : function(sceneIndex) { -1086 var sin = this.scenes[ sceneIndex ]; -1087 this.childrenList = []; -1088 this.addChild(sin); -1089 this.currentScene = sin; -1090 -1091 sin.setExpired(false); -1092 sin.mouseEnabled = true; -1093 sin.resetTransform(); -1094 sin.setLocation(0, 0); -1095 sin.alpha = 1; -1096 -1097 sin.activated(); -1098 }, -1099 /** -1100 * This method will change the current Scene by the Scene indicated as parameter. -1101 * It will apply random values for anchor and transition type. -1102 * @see easeInOutRandom -1103 * -1104 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. -1105 * @param time {number} an integer indicating the time the Scene transition will take. -1106 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1107 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1108 */ -1109 switchToScene : function(iNewSceneIndex, time, alpha, transition) { -1110 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1111 -1112 if (!transition) { -1113 this.setScene(iNewSceneIndex); -1114 } -1115 else { -1116 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); -1117 } -1118 }, -1119 /** -1120 * Sets the previous Scene in sequence as the current Scene. -1121 * @see switchToScene. -1122 * -1123 * @param time {number} integer indicating the time the Scene transition will take. -1124 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1125 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1126 */ -1127 switchToPrevScene : function(time, alpha, transition) { -1128 -1129 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1130 -1131 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { -1132 return; -1133 } -1134 -1135 if (!transition) { -1136 this.setScene(currentSceneIndex - 1); -1137 } -1138 else { -1139 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); +1037 outIndex, +1038 typeOut, +1039 (Math.random() * 8.99) >> 0, +1040 +1041 time, +1042 alpha, +1043 +1044 interpolatorIn, +1045 interpolatorOut); +1046 +1047 }, +1048 /** +1049 * This method changes Director's current Scene to the scene index indicated by +1050 * inSceneIndex parameter. The Scene running in the director won't be eased out. +1051 * +1052 * @see {CAAT.Interpolator} +1053 * @see {CAAT.Actor} +1054 * @see {CAAT.Scene} +1055 * +1056 * @param inSceneIndex integer indicating the new Scene to set as current. +1057 * @param type integer indicating the type of transition to apply to bring the new current +1058 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, +1059 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. +1060 * @param time integer indicating how much time in milliseconds the Scene entrance will take. +1061 * @param alpha boolean indicating whether alpha transparency fading will be applied to the +1062 * entereing Scene. +1063 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of +1064 * CAAT.Actor.prototype.ANCHOR_* values. +1065 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to +1066 * apply. +1067 */ +1068 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { +1069 var sin = this.scenes[ inSceneIndex ]; +1070 if (type === CAAT.Scene.prototype.EASE_ROTATION) { +1071 sin.easeRotationIn(time, alpha, anchor, interpolator); +1072 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { +1073 sin.easeScaleIn(0, time, alpha, anchor, interpolator); +1074 } else { +1075 sin.easeTranslationIn(time, alpha, anchor, interpolator); +1076 } +1077 this.childrenList = []; +1078 this.addChild(sin); +1079 +1080 sin.resetTransform(); +1081 sin.setLocation(0, 0); +1082 sin.alpha = 1; +1083 sin.mouseEnabled = false; +1084 sin.setExpired(false); +1085 }, +1086 /** +1087 * Changes (or sets) the current Director scene to the index +1088 * parameter. There will be no transition on scene change. +1089 * @param sceneIndex {number} an integer indicating the index of the target Scene +1090 * to be shown. +1091 */ +1092 setScene : function(sceneIndex) { +1093 var sin = this.scenes[ sceneIndex ]; +1094 this.childrenList = []; +1095 this.addChild(sin); +1096 this.currentScene = sin; +1097 +1098 sin.setExpired(false); +1099 sin.mouseEnabled = true; +1100 sin.resetTransform(); +1101 sin.setLocation(0, 0); +1102 sin.alpha = 1; +1103 +1104 sin.activated(); +1105 }, +1106 /** +1107 * This method will change the current Scene by the Scene indicated as parameter. +1108 * It will apply random values for anchor and transition type. +1109 * @see easeInOutRandom +1110 * +1111 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. +1112 * @param time {number} an integer indicating the time the Scene transition will take. +1113 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1114 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1115 */ +1116 switchToScene : function(iNewSceneIndex, time, alpha, transition) { +1117 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1118 +1119 if (!transition) { +1120 this.setScene(iNewSceneIndex); +1121 } +1122 else { +1123 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); +1124 } +1125 }, +1126 /** +1127 * Sets the previous Scene in sequence as the current Scene. +1128 * @see switchToScene. +1129 * +1130 * @param time {number} integer indicating the time the Scene transition will take. +1131 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1132 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1133 */ +1134 switchToPrevScene : function(time, alpha, transition) { +1135 +1136 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1137 +1138 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { +1139 return; 1140 } -1141 }, -1142 /** -1143 * Sets the previous Scene in sequence as the current Scene. -1144 * @see switchToScene. -1145 * -1146 * @param time {number} integer indicating the time the Scene transition will take. -1147 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -1148 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -1149 */ -1150 switchToNextScene: function(time, alpha, transition) { -1151 -1152 var currentSceneIndex = this.getSceneIndex(this.currentScene); -1153 -1154 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { -1155 return; -1156 } -1157 -1158 if (!transition) { -1159 this.setScene(currentSceneIndex + 1); -1160 } -1161 else { -1162 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); +1141 +1142 if (!transition) { +1143 this.setScene(currentSceneIndex - 1); +1144 } +1145 else { +1146 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); +1147 } +1148 }, +1149 /** +1150 * Sets the previous Scene in sequence as the current Scene. +1151 * @see switchToScene. +1152 * +1153 * @param time {number} integer indicating the time the Scene transition will take. +1154 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +1155 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +1156 */ +1157 switchToNextScene: function(time, alpha, transition) { +1158 +1159 var currentSceneIndex = this.getSceneIndex(this.currentScene); +1160 +1161 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { +1162 return; 1163 } -1164 }, -1165 mouseEnter : function(mouseEvent) { -1166 }, -1167 mouseExit : function(mouseEvent) { -1168 }, -1169 mouseMove : function(mouseEvent) { -1170 }, -1171 mouseDown : function(mouseEvent) { -1172 }, -1173 mouseUp : function(mouseEvent) { -1174 }, -1175 mouseDrag : function(mouseEvent) { -1176 }, -1177 /** -1178 * Scene easing listener. Notifies scenes when they're about to be activated (set as current -1179 * director's scene). -1180 * -1181 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. -1182 * @param b_easeIn {boolean} scene enters or exits ? -1183 */ -1184 easeEnd : function(scene, b_easeIn) { -1185 // scene is going out -1186 if (!b_easeIn) { -1187 -1188 scene.setExpired(true); -1189 } else { -1190 this.currentScene = scene; -1191 this.currentScene.activated(); -1192 } -1193 -1194 scene.mouseEnabled = true; -1195 scene.emptyBehaviorList(); -1196 }, -1197 /** -1198 * Return the index for a given Scene object contained in the Director. -1199 * @param scene {CAAT.Scene} -1200 */ -1201 getSceneIndex : function(scene) { -1202 for (var i = 0; i < this.scenes.length; i++) { -1203 if (this.scenes[i] === scene) { -1204 return i; -1205 } -1206 } -1207 return -1; -1208 }, -1209 /** -1210 * Get a concrete director's scene. -1211 * @param index {number} an integer indicating the scene index. -1212 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. -1213 */ -1214 getScene : function(index) { -1215 return this.scenes[index]; -1216 }, -1217 /** -1218 * Return the index of the current scene in the Director's scene list. -1219 * @return {number} the current scene's index. +1164 +1165 if (!transition) { +1166 this.setScene(currentSceneIndex + 1); +1167 } +1168 else { +1169 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); +1170 } +1171 }, +1172 mouseEnter : function(mouseEvent) { +1173 }, +1174 mouseExit : function(mouseEvent) { +1175 }, +1176 mouseMove : function(mouseEvent) { +1177 }, +1178 mouseDown : function(mouseEvent) { +1179 }, +1180 mouseUp : function(mouseEvent) { +1181 }, +1182 mouseDrag : function(mouseEvent) { +1183 }, +1184 /** +1185 * Scene easing listener. Notifies scenes when they're about to be activated (set as current +1186 * director's scene). +1187 * +1188 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. +1189 * @param b_easeIn {boolean} scene enters or exits ? +1190 */ +1191 easeEnd : function(scene, b_easeIn) { +1192 // scene is going out +1193 if (!b_easeIn) { +1194 +1195 scene.setExpired(true); +1196 } else { +1197 this.currentScene = scene; +1198 this.currentScene.activated(); +1199 } +1200 +1201 scene.mouseEnabled = true; +1202 scene.emptyBehaviorList(); +1203 }, +1204 /** +1205 * Return the index for a given Scene object contained in the Director. +1206 * @param scene {CAAT.Scene} +1207 */ +1208 getSceneIndex : function(scene) { +1209 for (var i = 0; i < this.scenes.length; i++) { +1210 if (this.scenes[i] === scene) { +1211 return i; +1212 } +1213 } +1214 return -1; +1215 }, +1216 /** +1217 * Get a concrete director's scene. +1218 * @param index {number} an integer indicating the scene index. +1219 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. 1220 */ -1221 getCurrentSceneIndex : function() { -1222 return this.getSceneIndex(this.currentScene); +1221 getScene : function(index) { +1222 return this.scenes[index]; 1223 }, 1224 /** -1225 * Return the running browser name. -1226 * @return {string} the browser name. +1225 * Return the index of the current scene in the Director's scene list. +1226 * @return {number} the current scene's index. 1227 */ -1228 getBrowserName : function() { -1229 return this.browserInfo.browser; +1228 getCurrentSceneIndex : function() { +1229 return this.getSceneIndex(this.currentScene); 1230 }, 1231 /** -1232 * Return the running browser version. -1233 * @return {string} the browser version. +1232 * Return the running browser name. +1233 * @return {string} the browser name. 1234 */ -1235 getBrowserVersion : function() { -1236 return this.browserInfo.version; +1235 getBrowserName : function() { +1236 return this.browserInfo.browser; 1237 }, 1238 /** -1239 * Return the operating system name. -1240 * @return {string} the os name. +1239 * Return the running browser version. +1240 * @return {string} the browser version. 1241 */ -1242 getOSName : function() { -1243 return this.browserInfo.OS; +1242 getBrowserVersion : function() { +1243 return this.browserInfo.version; 1244 }, 1245 /** -1246 * Gets the resource with the specified resource name. -1247 * The Director holds a collection called <code>imagesCache</code> -1248 * where you can store a JSON of the form -1249 * <code>[ { id: imageId, image: imageObject } ]</code>. -1250 * This structure will be used as a resources cache. -1251 * There's a CAAT.ImagePreloader class to preload resources and -1252 * generate this structure on loading finalization. -1253 * -1254 * @param sId {object} an String identifying a resource. -1255 */ -1256 getImage : function(sId) { -1257 var ret = this.imagesCache[sId]; -1258 if (ret) { -1259 return ret; -1260 } -1261 -1262 for (var i = 0; i < this.imagesCache.length; i++) { -1263 if (this.imagesCache[i].id === sId) { -1264 return this.imagesCache[i].image; -1265 } -1266 } -1267 -1268 return null; -1269 }, -1270 /** -1271 * Adds an audio to the cache. -1272 * -1273 * @see CAAT.AudioManager.addAudio -1274 * @return this -1275 */ -1276 addAudio : function(id, url) { -1277 this.audioManager.addAudio(id, url); -1278 return this; -1279 }, -1280 /** -1281 * Plays the audio instance identified by the id. -1282 * @param id {object} the object used to store a sound in the audioCache. -1283 */ -1284 audioPlay : function(id) { -1285 this.audioManager.play(id); +1246 * Return the operating system name. +1247 * @return {string} the os name. +1248 */ +1249 getOSName : function() { +1250 return this.browserInfo.OS; +1251 }, +1252 /** +1253 * Gets the resource with the specified resource name. +1254 * The Director holds a collection called <code>imagesCache</code> +1255 * where you can store a JSON of the form +1256 * <code>[ { id: imageId, image: imageObject } ]</code>. +1257 * This structure will be used as a resources cache. +1258 * There's a CAAT.ImagePreloader class to preload resources and +1259 * generate this structure on loading finalization. +1260 * +1261 * @param sId {object} an String identifying a resource. +1262 */ +1263 getImage : function(sId) { +1264 var ret = this.imagesCache[sId]; +1265 if (ret) { +1266 return ret; +1267 } +1268 +1269 for (var i = 0; i < this.imagesCache.length; i++) { +1270 if (this.imagesCache[i].id === sId) { +1271 return this.imagesCache[i].image; +1272 } +1273 } +1274 +1275 return null; +1276 }, +1277 /** +1278 * Adds an audio to the cache. +1279 * +1280 * @see CAAT.AudioManager.addAudio +1281 * @return this +1282 */ +1283 addAudio : function(id, url) { +1284 this.audioManager.addAudio(id, url); +1285 return this; 1286 }, 1287 /** -1288 * Loops an audio instance identified by the id. +1288 * Plays the audio instance identified by the id. 1289 * @param id {object} the object used to store a sound in the audioCache. -1290 * -1291 * @return {HTMLElement|null} the value from audioManager.loop -1292 */ -1293 audioLoop : function(id) { -1294 return this.audioManager.loop(id); -1295 }, -1296 endSound : function() { -1297 return this.audioManager.endSound(); -1298 }, -1299 setSoundEffectsEnabled : function(enabled) { -1300 return this.audioManager.setSoundEffectsEnabled(enabled); -1301 }, -1302 setMusicEnabled : function(enabled) { -1303 return this.audioManager.setMusicEnabled(enabled); -1304 }, -1305 isMusicEnabled : function() { -1306 return this.audioManager.isMusicEnabled(); -1307 }, -1308 isSoundEffectsEnabled : function() { -1309 return this.audioManager.isSoundEffectsEnabled(); -1310 }, -1311 setVolume : function( id, volume ) { -1312 return this.audioManager.setVolume( id, volume ); -1313 }, -1314 /** -1315 * Removes Director's scenes. -1316 */ -1317 emptyScenes : function() { -1318 this.scenes = []; -1319 }, -1320 /** -1321 * Adds an scene to this Director. -1322 * @param scene {CAAT.Scene} a scene object. +1290 */ +1291 audioPlay : function(id) { +1292 this.audioManager.play(id); +1293 }, +1294 /** +1295 * Loops an audio instance identified by the id. +1296 * @param id {object} the object used to store a sound in the audioCache. +1297 * +1298 * @return {HTMLElement|null} the value from audioManager.loop +1299 */ +1300 audioLoop : function(id) { +1301 return this.audioManager.loop(id); +1302 }, +1303 endSound : function() { +1304 return this.audioManager.endSound(); +1305 }, +1306 setSoundEffectsEnabled : function(enabled) { +1307 return this.audioManager.setSoundEffectsEnabled(enabled); +1308 }, +1309 setMusicEnabled : function(enabled) { +1310 return this.audioManager.setMusicEnabled(enabled); +1311 }, +1312 isMusicEnabled : function() { +1313 return this.audioManager.isMusicEnabled(); +1314 }, +1315 isSoundEffectsEnabled : function() { +1316 return this.audioManager.isSoundEffectsEnabled(); +1317 }, +1318 setVolume : function( id, volume ) { +1319 return this.audioManager.setVolume( id, volume ); +1320 }, +1321 /** +1322 * Removes Director's scenes. 1323 */ -1324 addChild : function(scene) { -1325 scene.parent = this; -1326 this.childrenList.push(scene); -1327 }, -1328 /** -1329 * @Deprecated use CAAT.loop instead. -1330 * @param fps -1331 * @param callback -1332 * @param callback2 -1333 */ -1334 loop : function(fps,callback,callback2) { -1335 if ( callback2 ) { -1336 this.onRenderStart= callback; -1337 this.onRenderEnd= callback2; -1338 } else if (callback) { -1339 this.onRenderEnd= callback; -1340 } -1341 CAAT.loop(); -1342 }, -1343 /** -1344 * Starts the director animation.If no scene is explicitly selected, the current Scene will -1345 * be the first scene added to the Director. -1346 * <p> -1347 * The fps parameter will set the animation quality. Higher values, -1348 * means CAAT will try to render more frames in the same second (at the -1349 * expense of cpu power at least until hardware accelerated canvas rendering -1350 * context are available). A value of 60 is a high frame rate and should not be exceeded. -1351 * -1352 * @param fps {number} integer value indicating the target frames per second to run -1353 * the animation at. -1354 */ -1355 renderFrame : function(fps, callback) { -1356 var t = new Date().getTime(), -1357 delta = t - this.timeline; -1358 -1359 /* -1360 check for massive frame time. if for example the current browser tab is minified or taken out of -1361 foreground, the system will account for a bit time interval. minify that impact by lowering down -1362 the elapsed time (virtual timelines FTW) -1363 */ -1364 if ( delta > 500 ) { -1365 delta= 500; -1366 } -1367 -1368 if ( this.onRenderStart ) { -1369 this.onRenderStart(delta); -1370 } -1371 -1372 this.render(delta); -1373 -1374 if ( this.debugInfo ) { -1375 this.debugInfo(this.statistics); -1376 } -1377 -1378 this.timeline = t; -1379 -1380 if (this.onRenderEnd) { -1381 this.onRenderEnd(delta); -1382 } -1383 }, -1384 endLoop : function () { -1385 }, -1386 /** -1387 * This method states whether the director must clear background before rendering -1388 * each frame. -1389 * -1390 * The clearing method could be: -1391 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. -1392 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled -1393 * will have their areas redrawn. -1394 * + CAAT.Director.CLEAR_NONE. clears nothing. -1395 * -1396 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} -1397 * @return this. -1398 */ -1399 setClear : function(clear) { -1400 this.clear = clear; -1401 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { -1402 this.dirtyRectsEnabled= true; -1403 } -1404 return this; -1405 }, -1406 /** -1407 * Get this Director's AudioManager instance. -1408 * @return {CAAT.AudioManager} the AudioManager instance. -1409 */ -1410 getAudioManager : function() { -1411 return this.audioManager; +1324 emptyScenes : function() { +1325 this.scenes = []; +1326 }, +1327 /** +1328 * Adds an scene to this Director. +1329 * @param scene {CAAT.Scene} a scene object. +1330 */ +1331 addChild : function(scene) { +1332 scene.parent = this; +1333 this.childrenList.push(scene); +1334 }, +1335 /** +1336 * @Deprecated use CAAT.loop instead. +1337 * @param fps +1338 * @param callback +1339 * @param callback2 +1340 */ +1341 loop : function(fps,callback,callback2) { +1342 if ( callback2 ) { +1343 this.onRenderStart= callback; +1344 this.onRenderEnd= callback2; +1345 } else if (callback) { +1346 this.onRenderEnd= callback; +1347 } +1348 CAAT.loop(); +1349 }, +1350 /** +1351 * Starts the director animation.If no scene is explicitly selected, the current Scene will +1352 * be the first scene added to the Director. +1353 * <p> +1354 * The fps parameter will set the animation quality. Higher values, +1355 * means CAAT will try to render more frames in the same second (at the +1356 * expense of cpu power at least until hardware accelerated canvas rendering +1357 * context are available). A value of 60 is a high frame rate and should not be exceeded. +1358 * +1359 * @param fps {number} integer value indicating the target frames per second to run +1360 * the animation at. +1361 */ +1362 renderFrame : function(fps, callback) { +1363 var t = new Date().getTime(), +1364 delta = t - this.timeline; +1365 +1366 /* +1367 check for massive frame time. if for example the current browser tab is minified or taken out of +1368 foreground, the system will account for a bit time interval. minify that impact by lowering down +1369 the elapsed time (virtual timelines FTW) +1370 */ +1371 if ( delta > 500 ) { +1372 delta= 500; +1373 } +1374 +1375 if ( this.onRenderStart ) { +1376 this.onRenderStart(delta); +1377 } +1378 +1379 this.render(delta); +1380 +1381 if ( this.debugInfo ) { +1382 this.debugInfo(this.statistics); +1383 } +1384 +1385 this.timeline = t; +1386 +1387 if (this.onRenderEnd) { +1388 this.onRenderEnd(delta); +1389 } +1390 }, +1391 endLoop : function () { +1392 }, +1393 /** +1394 * This method states whether the director must clear background before rendering +1395 * each frame. +1396 * +1397 * The clearing method could be: +1398 * + CAAT.Director.CLEAR_ALL. previous to draw anything on screen the canvas will have clearRect called on it. +1399 * + CAAT.Director.CLEAR_DIRTY_RECTS. Actors marked as invalid, or which have been moved, rotated or scaled +1400 * will have their areas redrawn. +1401 * + CAAT.Director.CLEAR_NONE. clears nothing. +1402 * +1403 * @param clear {CAAT.Director.CLEAR_ALL |�CAAT.Director.CLEAR_NONE | CAAT.Director.CLEAR_DIRTY_RECTS} +1404 * @return this. +1405 */ +1406 setClear : function(clear) { +1407 this.clear = clear; +1408 if ( this.clear===CAAT.Director.CLEAR_DIRTY_RECTS ) { +1409 this.dirtyRectsEnabled= true; +1410 } +1411 return this; 1412 }, 1413 /** -1414 * Acculumate dom elements position to properly offset on-screen mouse/touch events. -1415 * @param node +1414 * Get this Director's AudioManager instance. +1415 * @return {CAAT.AudioManager} the AudioManager instance. 1416 */ -1417 cumulateOffset : function(node, parent, prop) { -1418 var left= prop+'Left'; -1419 var top= prop+'Top'; -1420 var x=0, y=0, style; -1421 -1422 while( navigator.browser!=='iOS' && node && node.style ) { -1423 if ( node.currentStyle ) { -1424 style= node.currentStyle['position']; -1425 } else { -1426 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); -1427 style= style ? style.getPropertyValue('position') : null; -1428 } -1429 -1430 // if (!/^(relative|absolute|fixed)$/.test(style)) { -1431 if (!/^(fixed)$/.test(style)) { -1432 x += node[left]; -1433 y+= node[top]; -1434 node = node[parent]; -1435 } else { -1436 break; -1437 } -1438 } -1439 -1440 return { -1441 x: x, -1442 y: y, -1443 style: style -1444 }; -1445 }, -1446 getOffset : function( node ) { -1447 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); -1448 if ( res.style==='fixed' ) { -1449 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); -1450 return { -1451 x: res.x + res2.x, -1452 y: res.y + res2.y -1453 }; -1454 } -1455 -1456 return { -1457 x: res.x, -1458 y: res.y -1459 }; -1460 }, -1461 /** -1462 * Normalize input event coordinates to be related to (0,0) canvas position. -1463 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. -1464 * @param e {MouseEvent} a mouse event from an input event. -1465 */ -1466 getCanvasCoord : function(point, e) { -1467 -1468 var posx = 0; -1469 var posy = 0; -1470 if (!e) e = window.event; -1471 -1472 if (e.pageX || e.pageY) { -1473 posx = e.pageX; -1474 posy = e.pageY; -1475 } -1476 else if (e.clientX || e.clientY) { -1477 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; -1478 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; -1479 } -1480 -1481 var offset= this.getOffset(e.target); -1482 -1483 posx-= offset.x; -1484 posy-= offset.y; -1485 -1486 ////////////// -1487 // transformar coordenada inversamente con affine transform de director. -1488 -1489 var pt= new CAAT.Point( posx, posy ); -1490 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); -1491 this.modelViewMatrixI.transformCoord(pt); -1492 posx= pt.x; -1493 posy= pt.y -1494 -1495 point.set(posx, posy); -1496 this.screenMousePoint.set(posx, posy); -1497 -1498 }, -1499 -1500 __mouseDownHandler : function(e) { +1417 getAudioManager : function() { +1418 return this.audioManager; +1419 }, +1420 /** +1421 * Acculumate dom elements position to properly offset on-screen mouse/touch events. +1422 * @param node +1423 */ +1424 cumulateOffset : function(node, parent, prop) { +1425 var left= prop+'Left'; +1426 var top= prop+'Top'; +1427 var x=0, y=0, style; +1428 +1429 while( navigator.browser!=='iOS' && node && node.style ) { +1430 if ( node.currentStyle ) { +1431 style= node.currentStyle['position']; +1432 } else { +1433 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); +1434 style= style ? style.getPropertyValue('position') : null; +1435 } +1436 +1437 // if (!/^(relative|absolute|fixed)$/.test(style)) { +1438 if (!/^(fixed)$/.test(style)) { +1439 x += node[left]; +1440 y+= node[top]; +1441 node = node[parent]; +1442 } else { +1443 break; +1444 } +1445 } +1446 +1447 return { +1448 x: x, +1449 y: y, +1450 style: style +1451 }; +1452 }, +1453 getOffset : function( node ) { +1454 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); +1455 if ( res.style==='fixed' ) { +1456 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); +1457 return { +1458 x: res.x + res2.x, +1459 y: res.y + res2.y +1460 }; +1461 } +1462 +1463 return { +1464 x: res.x, +1465 y: res.y +1466 }; +1467 }, +1468 /** +1469 * Normalize input event coordinates to be related to (0,0) canvas position. +1470 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. +1471 * @param e {MouseEvent} a mouse event from an input event. +1472 */ +1473 getCanvasCoord : function(point, e) { +1474 +1475 var posx = 0; +1476 var posy = 0; +1477 if (!e) e = window.event; +1478 +1479 if (e.pageX || e.pageY) { +1480 posx = e.pageX; +1481 posy = e.pageY; +1482 } +1483 else if (e.clientX || e.clientY) { +1484 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; +1485 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; +1486 } +1487 +1488 var offset= this.getOffset(e.target); +1489 +1490 posx-= offset.x; +1491 posy-= offset.y; +1492 +1493 ////////////// +1494 // transformar coordenada inversamente con affine transform de director. +1495 +1496 var pt= new CAAT.Point( posx, posy ); +1497 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); +1498 this.modelViewMatrixI.transformCoord(pt); +1499 posx= pt.x; +1500 posy= pt.y 1501 -1502 /* -1503 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no -1504 button was presses. Then, send a mouseUp for the previos actor, and return; -1505 */ -1506 if ( this.dragging && this.lastSelectedActor ) { -1507 this.__mouseUpHandler(e); -1508 return; -1509 } -1510 -1511 this.getCanvasCoord(this.mousePoint, e); -1512 this.isMouseDown = true; -1513 var lactor = this.findActorAtPosition(this.mousePoint); -1514 -1515 if (null !== lactor) { -1516 -1517 var pos = lactor.viewToModel( -1518 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1519 -1520 lactor.mouseDown( -1521 new CAAT.MouseEvent().init( -1522 pos.x, -1523 pos.y, -1524 e, -1525 lactor, -1526 new CAAT.Point( -1527 this.screenMousePoint.x, -1528 this.screenMousePoint.y ))); -1529 } -1530 -1531 this.lastSelectedActor= lactor; -1532 }, -1533 -1534 __mouseUpHandler : function(e) { -1535 -1536 this.isMouseDown = false; -1537 this.getCanvasCoord(this.mousePoint, e); -1538 -1539 var pos= null; -1540 var lactor= this.lastSelectedActor; -1541 -1542 if (null !== lactor) { -1543 pos = lactor.viewToModel( -1544 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1545 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { -1546 lactor.actionPerformed(e) -1547 } +1502 point.set(posx, posy); +1503 this.screenMousePoint.set(posx, posy); +1504 +1505 }, +1506 +1507 __mouseDownHandler : function(e) { +1508 +1509 /* +1510 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no +1511 button was presses. Then, send a mouseUp for the previos actor, and return; +1512 */ +1513 if ( this.dragging && this.lastSelectedActor ) { +1514 this.__mouseUpHandler(e); +1515 return; +1516 } +1517 +1518 this.getCanvasCoord(this.mousePoint, e); +1519 this.isMouseDown = true; +1520 var lactor = this.findActorAtPosition(this.mousePoint); +1521 +1522 if (null !== lactor) { +1523 +1524 var pos = lactor.viewToModel( +1525 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1526 +1527 lactor.mouseDown( +1528 new CAAT.MouseEvent().init( +1529 pos.x, +1530 pos.y, +1531 e, +1532 lactor, +1533 new CAAT.Point( +1534 this.screenMousePoint.x, +1535 this.screenMousePoint.y ))); +1536 } +1537 +1538 this.lastSelectedActor= lactor; +1539 }, +1540 +1541 __mouseUpHandler : function(e) { +1542 +1543 this.isMouseDown = false; +1544 this.getCanvasCoord(this.mousePoint, e); +1545 +1546 var pos= null; +1547 var lactor= this.lastSelectedActor; 1548 -1549 lactor.mouseUp( -1550 new CAAT.MouseEvent().init( -1551 pos.x, -1552 pos.y, -1553 e, -1554 lactor, -1555 this.screenMousePoint, -1556 this.currentScene.time)); -1557 } -1558 -1559 if (!this.dragging && null !== lactor) { -1560 if (lactor.contains(pos.x, pos.y)) { -1561 lactor.mouseClick( -1562 new CAAT.MouseEvent().init( -1563 pos.x, -1564 pos.y, -1565 e, -1566 lactor, -1567 this.screenMousePoint, -1568 this.currentScene.time)); -1569 } -1570 } -1571 -1572 this.dragging = false; -1573 this.in_= false; -1574 // CAAT.setCursor('default'); -1575 }, -1576 -1577 __mouseMoveHandler : function(e) { -1578 this.getCanvasCoord(this.mousePoint, e); -1579 -1580 var lactor; -1581 var pos; -1582 -1583 // drag -1584 -1585 if (this.isMouseDown && null !== this.lastSelectedActor) { -1586 /* -1587 // check for mouse move threshold. -1588 if (!this.dragging) { -1589 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && -1590 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { -1591 return; -1592 } -1593 } -1594 */ -1595 -1596 -1597 lactor = this.lastSelectedActor; -1598 pos = lactor.viewToModel( -1599 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1600 -1601 this.dragging = true; +1549 if (null !== lactor) { +1550 pos = lactor.viewToModel( +1551 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1552 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { +1553 lactor.actionPerformed(e) +1554 } +1555 +1556 lactor.mouseUp( +1557 new CAAT.MouseEvent().init( +1558 pos.x, +1559 pos.y, +1560 e, +1561 lactor, +1562 this.screenMousePoint, +1563 this.currentScene.time)); +1564 } +1565 +1566 if (!this.dragging && null !== lactor) { +1567 if (lactor.contains(pos.x, pos.y)) { +1568 lactor.mouseClick( +1569 new CAAT.MouseEvent().init( +1570 pos.x, +1571 pos.y, +1572 e, +1573 lactor, +1574 this.screenMousePoint, +1575 this.currentScene.time)); +1576 } +1577 } +1578 +1579 this.dragging = false; +1580 this.in_= false; +1581 // CAAT.setCursor('default'); +1582 }, +1583 +1584 __mouseMoveHandler : function(e) { +1585 this.getCanvasCoord(this.mousePoint, e); +1586 +1587 var lactor; +1588 var pos; +1589 +1590 // drag +1591 +1592 if (this.isMouseDown && null !== this.lastSelectedActor) { +1593 /* +1594 // check for mouse move threshold. +1595 if (!this.dragging) { +1596 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && +1597 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { +1598 return; +1599 } +1600 } +1601 */ 1602 -1603 var px= lactor.x; -1604 var py= lactor.y; -1605 lactor.mouseDrag( -1606 new CAAT.MouseEvent().init( -1607 pos.x, -1608 pos.y, -1609 e, -1610 lactor, -1611 new CAAT.Point( -1612 this.screenMousePoint.x, -1613 this.screenMousePoint.y), -1614 this.currentScene.time)); -1615 -1616 this.prevMousePoint.x= pos.x; -1617 this.prevMousePoint.y= pos.y; -1618 -1619 /** -1620 * Element has not moved after drag, so treat it as a button. -1621 */ -1622 if ( px===lactor.x && py===lactor.y ) { -1623 -1624 var contains= lactor.contains(pos.x, pos.y); +1603 +1604 lactor = this.lastSelectedActor; +1605 pos = lactor.viewToModel( +1606 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1607 +1608 this.dragging = true; +1609 +1610 var px= lactor.x; +1611 var py= lactor.y; +1612 lactor.mouseDrag( +1613 new CAAT.MouseEvent().init( +1614 pos.x, +1615 pos.y, +1616 e, +1617 lactor, +1618 new CAAT.Point( +1619 this.screenMousePoint.x, +1620 this.screenMousePoint.y), +1621 this.currentScene.time)); +1622 +1623 this.prevMousePoint.x= pos.x; +1624 this.prevMousePoint.y= pos.y; 1625 -1626 if (this.in_ && !contains) { -1627 lactor.mouseExit( -1628 new CAAT.MouseEvent().init( -1629 pos.x, -1630 pos.y, -1631 e, -1632 lactor, -1633 this.screenMousePoint, -1634 this.currentScene.time)); -1635 this.in_ = false; -1636 } -1637 -1638 if (!this.in_ && contains ) { -1639 lactor.mouseEnter( -1640 new CAAT.MouseEvent().init( -1641 pos.x, -1642 pos.y, -1643 e, -1644 lactor, -1645 this.screenMousePoint, -1646 this.currentScene.time)); -1647 this.in_ = true; -1648 } -1649 } -1650 -1651 return; -1652 } -1653 -1654 // mouse move. -1655 this.in_= true; -1656 -1657 lactor = this.findActorAtPosition(this.mousePoint); -1658 -1659 // cambiamos de actor. -1660 if (lactor !== this.lastSelectedActor) { -1661 if (null !== this.lastSelectedActor) { -1662 -1663 pos = this.lastSelectedActor.viewToModel( -1664 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1626 /** +1627 * Element has not moved after drag, so treat it as a button. +1628 */ +1629 if ( px===lactor.x && py===lactor.y ) { +1630 +1631 var contains= lactor.contains(pos.x, pos.y); +1632 +1633 if (this.in_ && !contains) { +1634 lactor.mouseExit( +1635 new CAAT.MouseEvent().init( +1636 pos.x, +1637 pos.y, +1638 e, +1639 lactor, +1640 this.screenMousePoint, +1641 this.currentScene.time)); +1642 this.in_ = false; +1643 } +1644 +1645 if (!this.in_ && contains ) { +1646 lactor.mouseEnter( +1647 new CAAT.MouseEvent().init( +1648 pos.x, +1649 pos.y, +1650 e, +1651 lactor, +1652 this.screenMousePoint, +1653 this.currentScene.time)); +1654 this.in_ = true; +1655 } +1656 } +1657 +1658 return; +1659 } +1660 +1661 // mouse move. +1662 this.in_= true; +1663 +1664 lactor = this.findActorAtPosition(this.mousePoint); 1665 -1666 this.lastSelectedActor.mouseExit( -1667 new CAAT.MouseEvent().init( -1668 pos.x, -1669 pos.y, -1670 e, -1671 this.lastSelectedActor, -1672 this.screenMousePoint, -1673 this.currentScene.time)); -1674 } -1675 -1676 if (null !== lactor) { -1677 pos = lactor.viewToModel( -1678 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1679 -1680 lactor.mouseEnter( -1681 new CAAT.MouseEvent().init( -1682 pos.x, -1683 pos.y, -1684 e, -1685 lactor, -1686 this.screenMousePoint, -1687 this.currentScene.time)); -1688 } -1689 } -1690 -1691 pos = lactor.viewToModel( -1692 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1693 -1694 if (null !== lactor) { -1695 -1696 lactor.mouseMove( -1697 new CAAT.MouseEvent().init( -1698 pos.x, -1699 pos.y, -1700 e, -1701 lactor, -1702 this.screenMousePoint, -1703 this.currentScene.time)); -1704 } -1705 -1706 this.lastSelectedActor = lactor; -1707 }, -1708 -1709 __mouseOutHandler : function(e) { -1710 -1711 if (null !== this.lastSelectedActor ) { +1666 // cambiamos de actor. +1667 if (lactor !== this.lastSelectedActor) { +1668 if (null !== this.lastSelectedActor) { +1669 +1670 pos = this.lastSelectedActor.viewToModel( +1671 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1672 +1673 this.lastSelectedActor.mouseExit( +1674 new CAAT.MouseEvent().init( +1675 pos.x, +1676 pos.y, +1677 e, +1678 this.lastSelectedActor, +1679 this.screenMousePoint, +1680 this.currentScene.time)); +1681 } +1682 +1683 if (null !== lactor) { +1684 pos = lactor.viewToModel( +1685 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1686 +1687 lactor.mouseEnter( +1688 new CAAT.MouseEvent().init( +1689 pos.x, +1690 pos.y, +1691 e, +1692 lactor, +1693 this.screenMousePoint, +1694 this.currentScene.time)); +1695 } +1696 } +1697 +1698 pos = lactor.viewToModel( +1699 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1700 +1701 if (null !== lactor) { +1702 +1703 lactor.mouseMove( +1704 new CAAT.MouseEvent().init( +1705 pos.x, +1706 pos.y, +1707 e, +1708 lactor, +1709 this.screenMousePoint, +1710 this.currentScene.time)); +1711 } 1712 -1713 this.getCanvasCoord(this.mousePoint, e); -1714 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); -1715 this.lastSelectedActor.viewToModel(pos); -1716 -1717 var ev= new CAAT.MouseEvent().init( -1718 pos.x, -1719 pos.y, -1720 e, -1721 this.lastSelectedActor, -1722 this.screenMousePoint, -1723 this.currentScene.time); -1724 -1725 this.lastSelectedActor.mouseExit(ev); -1726 this.lastSelectedActor.mouseOut(ev); -1727 -1728 if ( !this.dragging ) { -1729 this.lastSelectedActor = null; -1730 } -1731 } else { -1732 this.isMouseDown = false; -1733 this.in_ = false; -1734 } -1735 -1736 }, -1737 -1738 __mouseOverHandler : function(e) { -1739 -1740 var lactor; -1741 var pos, ev; -1742 this.getCanvasCoord(this.mousePoint, e); -1743 -1744 if ( null==this.lastSelectedActor ) { -1745 lactor= this.findActorAtPosition( this.mousePoint ); +1713 this.lastSelectedActor = lactor; +1714 }, +1715 +1716 __mouseOutHandler : function(e) { +1717 +1718 if (null !== this.lastSelectedActor ) { +1719 +1720 this.getCanvasCoord(this.mousePoint, e); +1721 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); +1722 this.lastSelectedActor.viewToModel(pos); +1723 +1724 var ev= new CAAT.MouseEvent().init( +1725 pos.x, +1726 pos.y, +1727 e, +1728 this.lastSelectedActor, +1729 this.screenMousePoint, +1730 this.currentScene.time); +1731 +1732 this.lastSelectedActor.mouseExit(ev); +1733 this.lastSelectedActor.mouseOut(ev); +1734 +1735 if ( !this.dragging ) { +1736 this.lastSelectedActor = null; +1737 } +1738 } else { +1739 this.isMouseDown = false; +1740 this.in_ = false; +1741 } +1742 +1743 }, +1744 +1745 __mouseOverHandler : function(e) { 1746 -1747 if (null !== lactor) { -1748 -1749 pos = lactor.viewToModel( -1750 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1751 -1752 ev= new CAAT.MouseEvent().init( -1753 pos.x, -1754 pos.y, -1755 e, -1756 lactor, -1757 this.screenMousePoint, -1758 this.currentScene.time); -1759 -1760 lactor.mouseOver(ev); -1761 lactor.mouseEnter(ev); -1762 } -1763 -1764 this.lastSelectedActor= lactor; -1765 } else { -1766 lactor= this.lastSelectedActor; -1767 pos = lactor.viewToModel( -1768 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1769 -1770 ev= new CAAT.MouseEvent().init( -1771 pos.x, -1772 pos.y, -1773 e, -1774 lactor, -1775 this.screenMousePoint, -1776 this.currentScene.time); -1777 -1778 lactor.mouseOver(ev); -1779 lactor.mouseEnter(ev); -1780 -1781 } -1782 }, -1783 -1784 __mouseDBLClickHandler : function(e) { -1785 -1786 this.getCanvasCoord(this.mousePoint, e); -1787 if (null !== this.lastSelectedActor) { -1788 /* -1789 var pos = this.lastSelectedActor.viewToModel( -1790 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1791 */ -1792 this.lastSelectedActor.mouseDblClick( -1793 new CAAT.MouseEvent().init( -1794 this.mousePoint.x, -1795 this.mousePoint.y, -1796 e, -1797 this.lastSelectedActor, -1798 this.screenMousePoint, -1799 this.currentScene.time)); -1800 } -1801 }, -1802 -1803 /** -1804 * Same as mouseDown but not preventing event. -1805 * Will only take care of first touch. -1806 * @param e -1807 */ -1808 __touchStartHandler : function(e) { +1747 var lactor; +1748 var pos, ev; +1749 this.getCanvasCoord(this.mousePoint, e); +1750 +1751 if ( null==this.lastSelectedActor ) { +1752 lactor= this.findActorAtPosition( this.mousePoint ); +1753 +1754 if (null !== lactor) { +1755 +1756 pos = lactor.viewToModel( +1757 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1758 +1759 ev= new CAAT.MouseEvent().init( +1760 pos.x, +1761 pos.y, +1762 e, +1763 lactor, +1764 this.screenMousePoint, +1765 this.currentScene.time); +1766 +1767 lactor.mouseOver(ev); +1768 lactor.mouseEnter(ev); +1769 } +1770 +1771 this.lastSelectedActor= lactor; +1772 } else { +1773 lactor= this.lastSelectedActor; +1774 pos = lactor.viewToModel( +1775 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1776 +1777 ev= new CAAT.MouseEvent().init( +1778 pos.x, +1779 pos.y, +1780 e, +1781 lactor, +1782 this.screenMousePoint, +1783 this.currentScene.time); +1784 +1785 lactor.mouseOver(ev); +1786 lactor.mouseEnter(ev); +1787 +1788 } +1789 }, +1790 +1791 __mouseDBLClickHandler : function(e) { +1792 +1793 this.getCanvasCoord(this.mousePoint, e); +1794 if (null !== this.lastSelectedActor) { +1795 /* +1796 var pos = this.lastSelectedActor.viewToModel( +1797 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1798 */ +1799 this.lastSelectedActor.mouseDblClick( +1800 new CAAT.MouseEvent().init( +1801 this.mousePoint.x, +1802 this.mousePoint.y, +1803 e, +1804 this.lastSelectedActor, +1805 this.screenMousePoint, +1806 this.currentScene.time)); +1807 } +1808 }, 1809 -1810 e.preventDefault(); -1811 e= e.targetTouches[0] -1812 this.__mouseDownHandler(e); -1813 }, -1814 -1815 __touchEndHandler : function(e) { +1810 /** +1811 * Same as mouseDown but not preventing event. +1812 * Will only take care of first touch. +1813 * @param e +1814 */ +1815 __touchStartHandler : function(e) { 1816 1817 e.preventDefault(); -1818 e= e.changedTouches[0]; -1819 this.__mouseUpHandler(e); +1818 e= e.targetTouches[0] +1819 this.__mouseDownHandler(e); 1820 }, 1821 -1822 __touchMoveHandler : function(e) { +1822 __touchEndHandler : function(e) { 1823 1824 e.preventDefault(); -1825 -1826 if ( this.gesturing ) { -1827 return; -1828 } -1829 -1830 for( var i=0; i<e.targetTouches.length; i++ ) { -1831 if ( !i ) { -1832 this.__mouseMoveHandler(e.targetTouches[i]); -1833 } -1834 } -1835 }, +1825 e= e.changedTouches[0]; +1826 this.__mouseUpHandler(e); +1827 }, +1828 +1829 __touchMoveHandler : function(e) { +1830 +1831 e.preventDefault(); +1832 +1833 if ( this.gesturing ) { +1834 return; +1835 } 1836 -1837 __gestureStart : function( scale, rotation ) { -1838 this.gesturing= true; -1839 this.__gestureRotation= this.lastSelectedActor.rotationAngle; -1840 this.__gestureSX= this.lastSelectedActor.scaleX - 1; -1841 this.__gestureSY= this.lastSelectedActor.scaleY - 1; +1837 for( var i=0; i<e.targetTouches.length; i++ ) { +1838 if ( !i ) { +1839 this.__mouseMoveHandler(e.targetTouches[i]); +1840 } +1841 } 1842 }, 1843 -1844 __gestureChange : function( scale, rotation ) { -1845 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { -1846 return; -1847 } -1848 -1849 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { -1850 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); -1851 -1852 this.lastSelectedActor.setScale( -1853 this.__gestureSX + scale, -1854 this.__gestureSY + scale ); -1855 } -1856 -1857 }, +1844 __gestureStart : function( scale, rotation ) { +1845 this.gesturing= true; +1846 this.__gestureRotation= this.lastSelectedActor.rotationAngle; +1847 this.__gestureSX= this.lastSelectedActor.scaleX - 1; +1848 this.__gestureSY= this.lastSelectedActor.scaleY - 1; +1849 }, +1850 +1851 __gestureChange : function( scale, rotation ) { +1852 if ( typeof scale==='undefined' || typeof rotation==='undefined' ) { +1853 return; +1854 } +1855 +1856 if ( this.lastSelectedActor!==null && this.lastSelectedActor.isGestureEnabled() ) { +1857 this.lastSelectedActor.setRotation( rotation*Math.PI/180 + this.__gestureRotation ); 1858 -1859 __gestureEnd : function( scale, rotation ) { -1860 this.gesturing= false; -1861 this.__gestureRotation= 0; -1862 this.__gestureScale= 0; -1863 }, -1864 -1865 addHandlers: function(canvas) { -1866 -1867 var me= this; -1868 -1869 canvas.addEventListener('mouseup', function(e) { -1870 e.preventDefault(); -1871 me.__mouseUpHandler(e); -1872 }, false ); +1859 this.lastSelectedActor.setScale( +1860 this.__gestureSX + scale, +1861 this.__gestureSY + scale ); +1862 } +1863 +1864 }, +1865 +1866 __gestureEnd : function( scale, rotation ) { +1867 this.gesturing= false; +1868 this.__gestureRotation= 0; +1869 this.__gestureScale= 0; +1870 }, +1871 +1872 addHandlers: function(canvas) { 1873 -1874 canvas.addEventListener('mousedown', function(e) { -1875 e.preventDefault(); -1876 me.__mouseDownHandler(e); -1877 }, false ); -1878 -1879 canvas.addEventListener('mouseover',function(e) { -1880 e.preventDefault(); -1881 me.__mouseOverHandler(e); -1882 }, false); -1883 -1884 canvas.addEventListener('mouseout',function(e) { -1885 e.preventDefault(); -1886 me.__mouseOutHandler(e); -1887 }, false); -1888 -1889 canvas.addEventListener('mousemove', -1890 function(e) { -1891 e.preventDefault(); -1892 me.__mouseMoveHandler(e); -1893 }, -1894 false); +1874 var me= this; +1875 +1876 canvas.addEventListener('mouseup', function(e) { +1877 e.preventDefault(); +1878 me.__mouseUpHandler(e); +1879 }, false ); +1880 +1881 canvas.addEventListener('mousedown', function(e) { +1882 e.preventDefault(); +1883 me.__mouseDownHandler(e); +1884 }, false ); +1885 +1886 canvas.addEventListener('mouseover',function(e) { +1887 e.preventDefault(); +1888 me.__mouseOverHandler(e); +1889 }, false); +1890 +1891 canvas.addEventListener('mouseout',function(e) { +1892 e.preventDefault(); +1893 me.__mouseOutHandler(e); +1894 }, false); 1895 -1896 canvas.addEventListener("dblclick", function(e) { -1897 e.preventDefault(); -1898 me.__mouseDBLClickHandler(e); -1899 }, false); -1900 -1901 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); -1902 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); -1903 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); -1904 canvas.addEventListener("gesturestart", function(e) { -1905 e.preventDefault(); -1906 me.__gestureStart( e.scale, e.rotation ); -1907 }, false ); -1908 canvas.addEventListener("gestureend", function(e) { -1909 e.preventDefault(); -1910 me.__gestureEnd( e.scale, e.rotation ); -1911 }, false ); -1912 canvas.addEventListener("gesturechange", function(e) { -1913 e.preventDefault(); -1914 me.__gestureChange( e.scale, e.rotation ); -1915 }, false ); -1916 }, -1917 -1918 enableEvents : function( onElement ) { -1919 CAAT.RegisterDirector(this); -1920 this.in_ = false; -1921 this.createEventHandler( onElement ); -1922 }, -1923 -1924 createEventHandler : function( onElement ) { -1925 //var canvas= this.canvas; -1926 this.in_ = false; -1927 //this.addHandlers(canvas); -1928 this.addHandlers( onElement ); -1929 } -1930 }; -1931 -1932 -1933 if (CAAT.__CSS__) { -1934 -1935 CAAT.Director.prototype.clip= true; -1936 CAAT.Director.prototype.glEnabled= false; -1937 -1938 CAAT.Director.prototype.getRenderType= function() { -1939 return 'CSS'; -1940 }; +1896 canvas.addEventListener('mousemove', +1897 function(e) { +1898 e.preventDefault(); +1899 me.__mouseMoveHandler(e); +1900 }, +1901 false); +1902 +1903 canvas.addEventListener("dblclick", function(e) { +1904 e.preventDefault(); +1905 me.__mouseDBLClickHandler(e); +1906 }, false); +1907 +1908 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); +1909 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); +1910 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); +1911 canvas.addEventListener("gesturestart", function(e) { +1912 e.preventDefault(); +1913 me.__gestureStart( e.scale, e.rotation ); +1914 }, false ); +1915 canvas.addEventListener("gestureend", function(e) { +1916 e.preventDefault(); +1917 me.__gestureEnd( e.scale, e.rotation ); +1918 }, false ); +1919 canvas.addEventListener("gesturechange", function(e) { +1920 e.preventDefault(); +1921 me.__gestureChange( e.scale, e.rotation ); +1922 }, false ); +1923 }, +1924 +1925 enableEvents : function( onElement ) { +1926 CAAT.RegisterDirector(this); +1927 this.in_ = false; +1928 this.createEventHandler( onElement ); +1929 }, +1930 +1931 createEventHandler : function( onElement ) { +1932 //var canvas= this.canvas; +1933 this.in_ = false; +1934 //this.addHandlers(canvas); +1935 this.addHandlers( onElement ); +1936 } +1937 }; +1938 +1939 +1940 if (CAAT.__CSS__) { 1941 -1942 CAAT.Director.prototype.setScaleProportional= function(w,h) { -1943 -1944 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); -1945 this.setScaleAnchored( factor, factor, 0, 0 ); -1946 -1947 this.eventHandler.style.width= ''+this.referenceWidth +'px'; -1948 this.eventHandler.style.height= ''+this.referenceHeight+'px'; -1949 }; +1942 CAAT.Director.prototype.clip= true; +1943 CAAT.Director.prototype.glEnabled= false; +1944 +1945 CAAT.Director.prototype.getRenderType= function() { +1946 return 'CSS'; +1947 }; +1948 +1949 CAAT.Director.prototype.setScaleProportional= function(w,h) { 1950 -1951 CAAT.Director.prototype.setBounds= function(x, y, w, h) { -1952 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); -1953 for (var i = 0; i < this.scenes.length; i++) { -1954 this.scenes[i].setBounds(0, 0, w, h); -1955 } -1956 this.eventHandler.style.width= w+'px'; -1957 this.eventHandler.style.height= h+'px'; -1958 -1959 return this; -1960 }; -1961 -1962 /** -1963 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most -1964 * div in the document hierarchy (z-index 999999). -1965 * @param width -1966 * @param height -1967 * @param domElement -1968 * @param proxy -1969 */ -1970 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { -1971 -1972 this.timeline = new Date().getTime(); -1973 this.domElement= domElement; -1974 this.style('position','absolute'); -1975 this.style('width',''+width+'px'); -1976 this.style('height',''+height+'px'); -1977 this.style('overflow', 'hidden' ); +1951 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); +1952 this.setScaleAnchored( factor, factor, 0, 0 ); +1953 +1954 this.eventHandler.style.width= ''+this.referenceWidth +'px'; +1955 this.eventHandler.style.height= ''+this.referenceHeight+'px'; +1956 }; +1957 +1958 CAAT.Director.prototype.setBounds= function(x, y, w, h) { +1959 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); +1960 for (var i = 0; i < this.scenes.length; i++) { +1961 this.scenes[i].setBounds(0, 0, w, h); +1962 } +1963 this.eventHandler.style.width= w+'px'; +1964 this.eventHandler.style.height= h+'px'; +1965 +1966 return this; +1967 }; +1968 +1969 /** +1970 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most +1971 * div in the document hierarchy (z-index 999999). +1972 * @param width +1973 * @param height +1974 * @param domElement +1975 * @param proxy +1976 */ +1977 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { 1978 -1979 this.enableEvents(domElement); -1980 -1981 this.setBounds(0, 0, width, height); -1982 -1983 this.checkDebug(); -1984 return this; -1985 }; -1986 -1987 CAAT.Director.prototype.render= function(time) { -1988 -1989 this.time += time; -1990 this.animate(this,time); -1991 -1992 /** -1993 * draw director active scenes. -1994 */ -1995 var i, l, tt; -1996 -1997 if ( CAAT.DEBUG ) { -1998 this.resetStats(); -1999 } -2000 -2001 for (i = 0, l=this.childrenList.length; i < l; i++) { -2002 var c= this.childrenList[i]; -2003 if (c.isInAnimationFrame(this.time)) { -2004 tt = c.time - c.start_time; -2005 if ( c.onRenderStart ) { -2006 c.onRenderStart(tt); -2007 } -2008 -2009 if ( c.onRenderEnd ) { -2010 c.onRenderEnd(tt); -2011 } -2012 -2013 if (!c.isPaused()) { -2014 c.time += time; -2015 } -2016 -2017 if ( CAAT.DEBUG ) { -2018 this.statistics.size_total+= c.size_total; -2019 this.statistics.size_active+= c.size_active; -2020 this.statistics.size_dirtyRects= this.nDirtyRects; -2021 } -2022 -2023 } -2024 } -2025 -2026 this.frameCounter++; -2027 }; -2028 -2029 CAAT.Director.prototype.addScene= function(scene) { -2030 scene.setVisible(true); -2031 scene.setBounds(0, 0, this.width, this.height); -2032 this.scenes.push(scene); -2033 scene.setEaseListener(this); -2034 if (null === this.currentScene) { -2035 this.setScene(0); -2036 } -2037 -2038 this.domElement.appendChild( scene.domElement ); -2039 }; -2040 -2041 CAAT.Director.prototype.emptyScenes= function() { -2042 this.scenes = []; -2043 this.domElement.innerHTML=''; -2044 this.createEventHandler(); -2045 }; -2046 -2047 CAAT.Director.prototype.setClear= function(clear) { -2048 return this; -2049 }; -2050 -2051 CAAT.Director.prototype.createEventHandler= function() { -2052 this.eventHandler= document.createElement('div'); -2053 this.domElement.appendChild(this.eventHandler); -2054 -2055 this.eventHandler.style.position= 'absolute'; -2056 this.eventHandler.style.left= '0'; -2057 this.eventHandler.style.top= '0'; -2058 this.eventHandler.style.zIndex= 999999; -2059 this.eventHandler.style.width= ''+this.width+'px'; -2060 this.eventHandler.style.height= ''+this.height+'px'; +1979 this.timeline = new Date().getTime(); +1980 this.domElement= domElement; +1981 this.style('position','absolute'); +1982 this.style('width',''+width+'px'); +1983 this.style('height',''+height+'px'); +1984 this.style('overflow', 'hidden' ); +1985 +1986 this.enableEvents(domElement); +1987 +1988 this.setBounds(0, 0, width, height); +1989 +1990 this.checkDebug(); +1991 return this; +1992 }; +1993 +1994 CAAT.Director.prototype.render= function(time) { +1995 +1996 this.time += time; +1997 this.animate(this,time); +1998 +1999 /** +2000 * draw director active scenes. +2001 */ +2002 var i, l, tt; +2003 +2004 if ( CAAT.DEBUG ) { +2005 this.resetStats(); +2006 } +2007 +2008 for (i = 0, l=this.childrenList.length; i < l; i++) { +2009 var c= this.childrenList[i]; +2010 if (c.isInAnimationFrame(this.time)) { +2011 tt = c.time - c.start_time; +2012 if ( c.onRenderStart ) { +2013 c.onRenderStart(tt); +2014 } +2015 +2016 if ( c.onRenderEnd ) { +2017 c.onRenderEnd(tt); +2018 } +2019 +2020 if (!c.isPaused()) { +2021 c.time += time; +2022 } +2023 +2024 if ( CAAT.DEBUG ) { +2025 this.statistics.size_total+= c.size_total; +2026 this.statistics.size_active+= c.size_active; +2027 this.statistics.size_dirtyRects= this.nDirtyRects; +2028 } +2029 +2030 } +2031 } +2032 +2033 this.frameCounter++; +2034 }; +2035 +2036 CAAT.Director.prototype.addScene= function(scene) { +2037 scene.setVisible(true); +2038 scene.setBounds(0, 0, this.width, this.height); +2039 this.scenes.push(scene); +2040 scene.setEaseListener(this); +2041 if (null === this.currentScene) { +2042 this.setScene(0); +2043 } +2044 +2045 this.domElement.appendChild( scene.domElement ); +2046 }; +2047 +2048 CAAT.Director.prototype.emptyScenes= function() { +2049 this.scenes = []; +2050 this.domElement.innerHTML=''; +2051 this.createEventHandler(); +2052 }; +2053 +2054 CAAT.Director.prototype.setClear= function(clear) { +2055 return this; +2056 }; +2057 +2058 CAAT.Director.prototype.createEventHandler= function() { +2059 this.eventHandler= document.createElement('div'); +2060 this.domElement.appendChild(this.eventHandler); 2061 -2062 var canvas= this.eventHandler; -2063 this.in_ = false; -2064 -2065 this.addHandlers(canvas); -2066 }; -2067 } +2062 this.eventHandler.style.position= 'absolute'; +2063 this.eventHandler.style.left= '0'; +2064 this.eventHandler.style.top= '0'; +2065 this.eventHandler.style.zIndex= 999999; +2066 this.eventHandler.style.width= ''+this.width+'px'; +2067 this.eventHandler.style.height= ''+this.height+'px'; 2068 -2069 extend(CAAT.Director, CAAT.ActorContainer, null); -2070 })(); \ No newline at end of file +2069 var canvas= this.eventHandler; +2070 this.in_ = false; +2071 +2072 this.addHandlers(canvas); +2073 }; +2074 } +2075 +2076 extend(CAAT.Director, CAAT.ActorContainer, null); +2077 })(); +2078 \ No newline at end of file diff --git a/src/math/bezier.js b/src/math/bezier.js index d824ae01..1432cf5d 100644 --- a/src/math/bezier.js +++ b/src/math/bezier.js @@ -52,10 +52,14 @@ ctx.lineTo( this.coordlist[3].x, this.coordlist[3].y ); ctx.stroke(); } - + + ctx.globalAlpha=0.5; for( var i=0; i - * Incomplete class, do not use. + * This object manages one single catmull rom segment, that is 4 points. + * A complete spline should be managed with CAAT.Path.setCatmullRom with a complete list of points. * * @constructor * @extends CAAT.Curve @@ -444,26 +450,19 @@ /** * Set curve control points. - * @param cp0x {number} - * @param cp0y {number} - * @param cp1x {number} - * @param cp1y {number} - * @param cp2x {number} - * @param cp2y {number} - * @param cp3x {number} - * @param cp3y {number} + * @param points Array */ - setCurve : function( cp0x,cp0y, cp1x,cp1y, cp2x,cp2y, cp3x,cp3y ) { - + setCurve : function( p0, p1, p2, p3 ) { + this.coordlist= []; - - this.coordlist.push( new CAAT.Point().set(cp0x, cp0y ) ); - this.coordlist.push( new CAAT.Point().set(cp1x, cp1y ) ); - this.coordlist.push( new CAAT.Point().set(cp2x, cp2y ) ); - this.coordlist.push( new CAAT.Point().set(cp3x, cp3y ) ); - - this.cubic= true; + this.coordlist.push( p0 ); + this.coordlist.push( p1 ); + this.coordlist.push( p2 ); + this.coordlist.push( p3 ); + this.update(); + + return this; }, /** * Paint the contour by solving again the entire curve. @@ -471,9 +470,12 @@ */ paint: function(director) { - var x1,x2,y1,y2; - x1 = this.coordlist[0].x; - y1 = this.coordlist[0].y; + var x1,y1; + + // Catmull rom solves from point 1 !!! + + x1 = this.coordlist[1].x; + y1 = this.coordlist[1].y; var ctx= director.ctx; @@ -482,7 +484,7 @@ ctx.moveTo(x1,y1); var point= new CAAT.Point(); - + for(var t=this.k;t<=1+this.k;t+=this.k){ this.solve(point,t); ctx.lineTo(point.x,point.y); @@ -499,19 +501,17 @@ * @param t {number} a number in the range 0..1 */ solve: function(point,t) { - var t2= t*t; - var t3= t*t2; - var c= this.coordlist; -// q(t) = 0.5 *( (2 * P1) + -// (-P0 + P2) * t + -// (2*P0 - 5*P1 + 4*P2 - P3) * t2 + -// (-P0 + 3*P1- 3*P2 + P3) * t3) + // Handy from CAKE. Thanks. + var af = ((-t+2)*t-1)*t*0.5 + var bf = (((3*t-5)*t)*t+2)*0.5 + var cf = ((-3*t+4)*t+1)*t*0.5 + var df = ((t-1)*t*t)*0.5 + + point.x= c[0].x * af + c[1].x * bf + c[2].x * cf + c[3].x * df; + point.y= c[0].y * af + c[1].y * bf + c[2].y * cf + c[3].y * df; - point.x= 0.5*( (2*c[1].x) + (-c[0].x+c[2].x)*t + (2*c[0].x - 5*c[1].x + 4*c[2].x - c[3].x)*t2 + (-c[0].x + 3*c[1].x - 3*c[2].x + c[3].x)*t3 ); - point.y= 0.5*( (2*c[1].y) + (-c[0].y+c[2].y)*t + (2*c[0].y - 5*c[1].y + 4*c[2].y - c[3].y)*t2 + (-c[0].y + 3*c[1].y - 3*c[2].y + c[3].y)*t3 ); - return point; } diff --git a/src/model/actor.js b/src/model/actor.js index 074e2129..5c426654 100644 --- a/src/model/actor.js +++ b/src/model/actor.js @@ -2196,6 +2196,11 @@ return this; }, + removeFirstChild : function() { + var first= this.childrenList.shift(); + first.parent= null; + return first; + }, /** * @private * @@ -2663,7 +2668,7 @@ context.save(); - context.translate( (0.5+p0.x)|0, (0.5+p0.y)|0 ); + context.translate( p0.x|0, p0.y|0 ); context.rotate( angle ); var y = this.textBaseline === "bottom" ? 0 - this.font.height : 0; diff --git a/src/model/director.js b/src/model/director.js index 83b043c4..0e6ea14d 100644 --- a/src/model/director.js +++ b/src/model/director.js @@ -297,7 +297,11 @@ */ initializeGL : function(width, height, canvas, proxy) { - canvas = canvas || document.createElement('canvas'); + if ( !canvas ) { + canvas= document.createElement('canvas'); + document.body.appendChild(canvas); + } + canvas.width = width; canvas.height = height; diff --git a/src/path/path.js b/src/path/path.js index 5b163e0c..b861ce61 100644 --- a/src/path/path.js +++ b/src/path/path.js @@ -31,7 +31,7 @@ }; CAAT.PathSegment.prototype = { - color: 'black', + color: '#000', length: 0, bbox: null, parent: null, @@ -149,7 +149,21 @@ * Transform this path with the given affinetransform matrix. * @param matrix */ - transform : function(matrix) {} + transform : function(matrix) {}, + + drawHandle : function( ctx, x, y ) { + var w= CAAT.Curve.prototype.HANDLE_SIZE/2; + ctx.fillRect( x-w, y-w, w*2, w*2 ); + /* + ctx.arc( + this.points[0].x, + this.points[0].y, + CAAT.Curve.prototype.HANDLE_SIZE/2, + 0, + 2*Math.PI, + false) ; + */ + } }; })(); @@ -258,6 +272,9 @@ return this.newPosition; }, + getPositionFromLength : function( len ) { + return this.getPosition( len/this.length ); + }, /** * Returns initial path segment point's x coordinate. * @return {number} @@ -280,20 +297,23 @@ */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.moveTo( this.points[0].x, this.points[0].y ); - canvas.lineTo( this.points[1].x, this.points[1].y ); - canvas.stroke(); + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.moveTo( this.points[0].x, this.points[0].y ); + ctx.lineTo( this.points[1].x, this.points[1].y ); + ctx.stroke(); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; - canvas.beginPath(); + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; + ctx.beginPath(); + this.drawHandle( ctx, this.points[0].x, this.points[0].y ); + this.drawHandle( ctx, this.points[1].x, this.points[1].y ); + /* canvas.arc( this.points[0].x, this.points[0].y, @@ -309,9 +329,10 @@ 2*Math.PI, false) ; canvas.fill(); + */ } - canvas.restore(); + ctx.restore(); }, /** * Get the number of control points. For this type of path segment, start and @@ -481,7 +502,7 @@ paint : function( director,bDrawHandles ) { this.curve.drawHandles= bDrawHandles; director.ctx.strokeStyle= this.color; - this.curve.paint(director); + this.curve.paint(director,bDrawHandles); }, /** * @inheritDoc @@ -714,21 +735,23 @@ */ paint : function(director, bDrawHandles) { - var canvas= director.crc; + var ctx= director.ctx; - canvas.save(); + ctx.save(); - canvas.strokeStyle= this.color; - canvas.beginPath(); - canvas.strokeRect( + ctx.strokeStyle= this.color; + ctx.beginPath(); + ctx.strokeRect( this.bbox.x, this.bbox.y, this.bbox.width, this.bbox.height ); if ( bDrawHandles ) { - canvas.globalAlpha=0.5; - canvas.fillStyle='#7f7f00'; + ctx.globalAlpha=0.5; + ctx.fillStyle='#7f7f00'; for( var i=0; i=psstv )*/ { + l= m+1; + } + } + return this.endCurvePosition(); + + }, /** * Analogously to the method getPosition, this method returns a CAAT.Point instance with @@ -1377,7 +1453,7 @@ * Indicates that some path control point has changed, and that the path must recalculate * its internal data, ie: length and bbox. */ - updatePath : function(point) { + updatePath : function(point, callback) { var i,j; this.length=0; @@ -1435,6 +1511,10 @@ this.extractPathPoints(); + if ( typeof callback!=='undefined' ) { + callback(this); + } + return this; }, @@ -1471,7 +1551,7 @@ * @param x {number} * @param y {number} */ - drag : function(x,y) { + drag : function(x,y,callback) { if (!this.interactive) { return; } @@ -1491,7 +1571,7 @@ this.ax= x; this.ay= y; - this.updatePath(this.point); + this.updatePath(this.point,callback); }, /** * Returns a collection of CAAT.Point objects which conform a path's contour. @@ -1757,6 +1837,22 @@ this.tb_x= x; this.tb_y= y; return this; + }, + + flatten : function( npatches, closed ) { + var point= this.getPositionFromLength(0); + var path= new CAAT.Path().beginPath( point.x, point.y ); + for( var i=0; i