diff --git a/build/caat-box2d-min.js b/build/caat-box2d-min.js index f0e2fae4..558674cf 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.1 build: 373 +Version: 0.1 build: 406 Created on: -DATE: 2011-12-16 -TIME: 17:28:40 +DATE: 2011-12-18 +TIME: 16:41:15 */ diff --git a/build/caat-box2d.js b/build/caat-box2d.js index f4ffffb5..ebd190f0 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.1 build: 374 +Version: 0.1 build: 407 Created on: -DATE: 2011-12-16 -TIME: 17:29:01 +DATE: 2011-12-18 +TIME: 16:41:42 */ diff --git a/build/caat-css-min.js b/build/caat-css-min.js index 8bda430a..ba70ce99 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.1 build: 373 +Version: 0.1 build: 406 Created on: -DATE: 2011-12-16 -TIME: 17:28:40 +DATE: 2011-12-18 +TIME: 16:41:15 */ -var CAAT=CAAT||{};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;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=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;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c>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;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.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint));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.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.in_=false;if(!this.in_&& -d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint)),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))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +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;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c>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;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.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint));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.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.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint)),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))),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)))),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.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.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),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,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),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&(this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)), this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor,this.screenMousePoint)))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();for(var b=0;bthis.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-ethis.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-ed?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil=function(){return this};CAAT.modules.ImageUtil.prototype={createAlphaSpriteSheet:function(a,b,c,d,e){if(a>=0;var c=document.createElement("canvas");c.width=a.width;c.height=a.height;var d= -c.getContext("2d");d.fillStyle="rgba(0,0,0,0)";d.fillRect(0,0,a.width,a.height);d.drawImage(a,0,0);var e=d.getImageData(0,0,a.width,a.height).data,f,g,h=c.height,i=0,j=c.width;f=0;var k=false;for(f=0;fb){k=true;break}if(k)break}h=f;k=false;for(f=c.height-1;f>=h;f--){for(g=3;gb){k=true;break}if(k)break}i=f;k=false;for(g=0;gb){k=true;break}if(k)break}j= -g;k=false;for(g=c.width-1;g>=j;g--){for(f=0;fb){k=true;break}if(k)break}f=g;if(0===j&&0===h&&c.width-1===f&&c.height-1===i)return c;e=f-j+1;i=i-h+1;h=d.getImageData(j,h,e,i);c.width=e;c.height=i;d=c.getContext("2d");d.putImageData(h,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b- -d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}})();(function(){CAAT.InterpolatorActor=function(){CAAT.InterpolatorActor.superclass.constructor.call(this);return this};CAAT.InterpolatorActor.prototype={interpolator:null,contour:null,S:50,gap:5,setGap:function(a){this.gap=a;return this},setInterpolator:function(a,b){this.interpolator=a;this.contour=a.getContour(b||this.S);return this},paint:function(a,b){CAAT.InterpolatorActor.superclass.paint.call(this,a,b);if(this.backgroundImage)return this;if(this.interpolator){var c=a.crc,d=this.width-2*this.gap, +d=b.getDistanceSquaredFromPosition(a.targetPosition),e=0;c>d?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil={};CAAT.modules.ImageUtil.createAlphaSpriteSheet=function(a,b,c,d,e){if(a>=0;var d=true,e=true,f=true,g=true;if(typeof c!=="undefined"){if(typeof c.top!== +"undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,n=c.width-1,l=false;if(d){for(d=0;db){l=true;break}if(l)break}a= +d}if(e){l=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){l=true;break}if(l)break}k=d}if(f){l=false;for(j=0;jb){l=true;break}if(l)break}m=j}if(g){l=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}n=j}if(0===m&&0===a&&c.width-1===n&&c.height-1===k)return c;b=n-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height=e;h=c.getContext("2d");h.putImageData(f,0,0); +return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}})();(function(){CAAT.Font=function(){return this};CAAT.Font.prototype={fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,padding:0,image:null,charMap:null,height:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle= +a;return this},create:function(a,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)+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;g, bottom, left }Ê} */ - optimize : function(image, threshold) { - threshold>>=0; + CAAT.modules.ImageUtil.optimize= function(image, threshold, areas ) { + threshold>>=0; - var canvas= document.createElement('canvas'); - canvas.width= image.width; - canvas.height=image.height; - var ctx= canvas.getContext('2d'); + var atop= true; + var abottom= true; + var aleft= true; + var aright= true; + if ( typeof areas!=='undefined' ) { + if ( typeof areas.top!=='undefined' ) { + atop= areas.top; + } + if ( typeof areas.bottom!=='undefined' ) { + abottom= areas.bottom; + } + if ( typeof areas.left!=='undefined' ) { + aleft= areas.left; + } + if ( typeof areas.right!=='undefined' ) { + aright= areas.right; + } + } - ctx.fillStyle='rgba(0,0,0,0)'; - ctx.fillRect(0,0,image.width,image.height); - ctx.drawImage( image, 0, 0 ); - var imageData= ctx.getImageData(0,0,image.width,image.height); - var data= imageData.data; + var canvas= document.createElement('canvas'); + canvas.width= image.width; + canvas.height=image.height; + var ctx= canvas.getContext('2d'); - var i,j; - var miny= canvas.height, maxy=0; - var minx= canvas.width, maxx=0; + ctx.fillStyle='rgba(0,0,0,0)'; + ctx.fillRect(0,0,image.width,image.height); + ctx.drawImage( image, 0, 0 ); + + var imageData= ctx.getImageData(0,0,image.width,image.height); + var data= imageData.data; + + var i,j; + var miny= 0, maxy=canvas.height-1; + var minx= 0, maxx=canvas.width-1; - var alpha= false; + var alpha= false; + + if ( atop ) { for( i=0; ithreshold ) { @@ -11391,10 +11433,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } // i contiene el indice del ultimo scan que no es transparente total. miny= i; + } + if ( abottom ) { alpha= false; for( i=canvas.height-1; i>=miny; i-- ) { - for( j=3; jthreshold ) { alpha= true; break; @@ -11406,11 +11450,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } maxy= i; + } - + if ( aleft ) { alpha= false; for( j=0; jthreshold ) { alpha= true; break; @@ -11421,10 +11466,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } minx= j; + } + if ( aright ) { alpha= false; for( j=canvas.width-1; j>=minx; j-- ) { - for( i=0; ithreshold ) { alpha= true; break; @@ -11435,42 +11482,43 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } maxx= j; + } - if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { - return canvas; - } + if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { + return canvas; + } - var width= maxx-minx+1; - var height=maxy-miny+1; - var id2= ctx.getImageData( minx, miny, width, height ); + var width= maxx-minx+1; + var height=maxy-miny+1; + var id2= ctx.getImageData( minx, miny, width, height ); - canvas.width= width; - canvas.height= height; - ctx= canvas.getContext('2d'); - ctx.putImageData( id2, 0, 0 ); + canvas.width= width; + canvas.height= height; + ctx= canvas.getContext('2d'); + ctx.putImageData( id2, 0, 0 ); - return canvas; - }, - createThumb : function(image, w, h, best_fit) { - w= w||24; - h= h||24; - var canvas= document.createElement('canvas'); - canvas.width= w; - canvas.height= h; - var ctx= canvas.getContext('2d'); - - if ( best_fit ) { - var max= Math.max( image.width, image.height ); - var ww= image.width/max*w; - var hh= image.height/max*h; - ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); - } else { - ctx.drawImage( image, 0, 0, w, h ); - } + return canvas; + }; - return canvas; + CAAT.modules.ImageUtil.createThumb= function(image, w, h, best_fit) { + w= w||24; + h= h||24; + var canvas= document.createElement('canvas'); + canvas.width= w; + canvas.height= h; + var ctx= canvas.getContext('2d'); + + if ( best_fit ) { + var max= Math.max( image.width, image.height ); + var ww= image.width/max*w; + var hh= image.height/max*h; + ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); + } else { + ctx.drawImage( image, 0, 0, w, h ); } - }; + + return canvas; + } })();/** * See LICENSE file. @@ -11535,7 +11583,166 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } }; -})();/** +})(); +(function() { + + /** + * @constructor + */ + CAAT.Font= function( ) { + return this; + }; + + var UNKNOWN_CHAR_WIDTH= 10; + + CAAT.Font.prototype= { + + fontSize : 10, + fontSizeUnit: "px", + font : 'Sans-Serif', + fontStyle : '', + fillStyle : '#fff', + strokeStyle : null, + padding : 0, + image : null, + charMap : null, + + height : 0, + + setPadding : function( padding ) { + this.padding= padding; + return this; + }, + + setFontStyle : function( style ) { + this.fontStyle= style; + return this; + }, + + setFontSize : function( fontSize ) { + this.fontSize= fontSize; + this.fontSizeUnit= 'px'; + return this; + }, + + setFont : function( font ) { + this.font= font; + return this; + }, + + setFillStyle : function( style ) { + this.fillStyle= style; + return this; + }, + + setStrokeStyle : function( style ) { + this.strokeStyle= style; + return this; + }, + + create : function( chars, padding ) { + var canvas= document.createElement('canvas'); + canvas.width= 1; + canvas.height= 1; + var ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + + var textWidth= 0; + var charWidth= []; + var i; + var x; + var cchar; + + for( i=0; i>0 ) + 2 * padding; + charWidth.push(cw); + textWidth+= cw; + } + + canvas.width= textWidth; + canvas.height= (this.fontSize*1.5)>>0; + ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + ctx.fillStyle= this.fillStyle; + ctx.strokeStyle= this.strokeStyle; + + this.charMap= {}; + + x=0; + for( i=0; i=g)return{r:d,g:e,b:f};a=a+(d-a)/g*h>>0;b=b+(e-b)/g*h>>0;c=c+(f-c)/g*h>>0;a>255?a=255:a<0&&(a=0);b>255?b=255:b<0&&(b=0);c>255?c=255:c<0&&(c=0);return{r:a,g:b,b:c}},makeRGBColorRamp:function(a,b,c){var d=[],e=a.length-1;b/=e;for(var f=0;f>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],l=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,m=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o>0,q=i+n*o>>0,r=j+m*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<< +a[f],h=g>>24&255,i=(g&16711680)>>16,j=(g&65280)>>8;g&=255;for(var k=a[f+1],m=((k>>24&255)-h)/b,n=(((k&16711680)>>16)-i)/b,l=(((k&65280)>>8)-j)/b,k=((k&255)-g)/b,o=0;o>0,q=i+n*o>>0,r=j+l*o>>0,s=g+k*o>>0;switch(c){case this.RampEnumeration.RAMP_RGBA:d.push("argb("+p+","+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_RGB:d.push("rgb("+q+","+r+","+s+")");break;case this.RampEnumeration.RAMP_CHANNEL_RGB:d.push(4278190080|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA:d.push(p<< 24|q<<16|r<<8|s);break;case this.RampEnumeration.RAMP_CHANNEL_RGBA_ARRAY:d.push([q,r,s,p]);break;case this.RampEnumeration.RAMP_CHANNEL_RGB_ARRAY:d.push([q,r,s])}}}return d}}})();(function(){CAAT.Color.RGB=function(a,b,c){this.r=a||255;this.g=b||255;this.b=c||255;return this};CAAT.Color.RGB.prototype={r:255,g:255,b:255,toHex:function(){return("000000"+((this.r<<16)+(this.g<<8)+this.b).toString(16)).slice(-6)}}})();(function(){CAAT.Rectangle=function(){return this};CAAT.Rectangle.prototype={x:0,y:0,x1:0,y1:0,width:-1,height:-1,setEmpty:function(){this.height=this.width=-1;this.height=this.width=this.y=this.x=0;return this},setLocation:function(a,b){this.x=a;this.y=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setDimension:function(a,b){this.width=a;this.height=b;this.x1=this.x+this.width;this.y1=this.y+this.height;return this},setBounds:function(a,b,c,d){this.setLocation(a,b);this.setDimension(c, d);return this},contains:function(a,b){return a>=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}}})();(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= @@ -135,8 +135,8 @@ return a},findActorAtPosition:function(a){if(!this.mouseEnabled||!this.isInAnima -1;this.pointed=false;CAAT.setCursor("default")};this.mouseMove=function(){};this.mouseUp=function(){this.__d_ay=this.__d_ax=-1};this.mouseDrag=function(a){var b;b=this.modelToView(new CAAT.Point(a.x,a.y));this.parent.viewToModel(b);if(this.__d_ax===-1||this.__d_ay===-1)this.__d_ax=b.x,this.__d_ay=b.y,this.__d_asx=this.scaleX,this.__d_asy=this.scaleY,this.__d_ara=this.rotationAngle,this.__d_screenx=a.screenPoint.x,this.__d_screeny=a.screenPoint.y;if(a.isShiftDown()){var c=(a.screenPoint.x-this.__d_screenx)/ 100,d=(a.screenPoint.y-this.__d_screeny)/100;a.isAltDown()||(d=c=a=Math.max(c,d));this.setScale(c+this.__d_asx,d+this.__d_asy)}else a.isControlDown()?this.setRotation(-Math.atan2(a.screenPoint.x-this.__d_screenx,a.screenPoint.y-this.__d_screeny)+this.__d_ara):(this.x+=b.x-this.__d_ax,this.y+=b.y-this.__d_ay);this.__d_ax=b.x;this.__d_ay=b.y};return this},mouseClick:function(){},mouseDblClick:function(){},mouseEnter:function(){this.pointed=true},mouseExit:function(){this.pointed=false},mouseMove:function(){}, mouseDown:function(){},mouseUp:function(){},mouseOut:function(){},mouseOver:function(){},mouseDrag:function(){},drawScreenBoundingBox:function(a){if(null!==this.AABB&&this.inFrame){var b=this.AABB;a.ctx.strokeRect(b.x,b.y,b.width,b.height)}},animate:function(a,b){var c;if(!this.isInAnimationFrame(b))return this.inFrame=false,this.dirty=true,false;if(this.x!==this.oldX||this.y!==this.oldY)this.dirty=true,this.oldX=this.x,this.oldY=this.y;for(c=0;c>0}catch(c){this.textHeight=20}if(this.height===0)this.height=this.textHeight;a.crc.restore();return this},paint:function(a, b){if(this.backgroundImage)CAAT.TextActor.superclass.paint.call(this,a,b);else if(null!==this.text){(this.textWidth===0||this.textHeight===0)&&this.calcTextSize(a);var c=a.crc;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(null!==this.fillStyle)c.fillStyle=this.fillStyle;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){if(c.fillText(this.text, -d,0),this.outline){if(null!==this.outlineColor)c.strokeStyle=this.outlineColor;c.beginPath();c.strokeText(this.text,d,0)}}else{if(null!==this.outlineColor)c.strokeStyle=this.outlineColor;c.strokeText(this.text,d,0)}}else this.drawOnPath(a,b)}},drawOnPath:function(a,b){for(var c=a.crc,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;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c>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;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.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint));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.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.in_=false;if(!this.in_&& -d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint)),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))),null!==b&&(c=b.viewToModel(new CAAT.Point(this.screenMousePoint.x, +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;if(this.glEnabled){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);for(c=this.uvIndex=this.coordsIndex=0;c>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;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.dragging&&null!==c&&c.contains(b.x,b.y)&&c.mouseClick((new CAAT.MouseEvent).init(b.x,b.y,a,c,this.screenMousePoint));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.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.in_=false;if(!this.in_&&d)b.mouseEnter((new CAAT.MouseEvent).init(c.x,c.y,a,b,this.screenMousePoint)),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))),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)))),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.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.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),b.mouseOver(a),b.mouseEnter(a)),this.lastSelectedActor=b):(b=this.lastSelectedActor,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),b.mouseOver(a),b.mouseEnter(a))},__mouseDBLClickHandler:function(a){this.getCanvasCoord(this.mousePoint,a);null!==this.lastSelectedActor&&(this.lastSelectedActor.viewToModel(new CAAT.Point(this.screenMousePoint.x,this.screenMousePoint.y,0)), this.lastSelectedActor.mouseDblClick((new CAAT.MouseEvent).init(this.mousePoint.x,this.mousePoint.y,a,this.lastSelectedActor,this.screenMousePoint)))},__touchStartHandler:function(a){a.preventDefault();a=a.targetTouches[0];this.__mouseDownHandler(a)},__touchEndHandler:function(a){a.preventDefault();a=a.changedTouches[0];this.__mouseUpHandler(a)},__touchMoveHandler:function(a){a.preventDefault();for(var b=0;b>0)*d;var k=i+(a/g>>0)*e,l=f+d,n=k+e;f=(new CAAT.SpriteImageHelper).setGL(f/j.width,k/j.height,l/j.width,n/j.height);this.mapInfo[a]=f}}else for(a=0;a>0)*d;var k=i+(a/g>>0)*e,m=f+d,n=k+e;f=(new CAAT.SpriteImageHelper).setGL(f/j.width,k/j.height,m/j.width,n/j.height);this.mapInfo[a]=f}}else for(a=0;a0&&(g-=e);var h=this.offsetY%f;h>0&&(h-=f);var e=((this.ownerActor.width-g)/e>>0)+1,f=((this.ownerActor.height-h)/f>>0)+1,i,j;for(i=0;i>0,d+h+i*b.height>>0,b.width,b.height)},paintInvertedH:function(a, b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate((0.5+c|0)+b.width,0.5+d|0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintInvertedV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c+0.5|0,0.5+d+b.height|0);a.scale(1,-1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>> 0,b.width,b.height);a.restore();return this},paintInvertedHV:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a=a.ctx;a.save();a.translate(c+0.5|0,0.5+d+b.height|0);a.scale(1,-1);a.translate(b.width,0);a.scale(-1,1);a.drawImage(this.image,b.x,b.y,b.width,b.height,this.offsetX>>0,this.offsetY>>0,b.width,b.height);a.restore();return this},paintN:function(a,b,c,d){this.setSpriteIndexAtTime(b);b=this.mapInfo[this.spriteIndex];a.ctx.drawImage(this.image,b.x,b.y,b.width,b.height, @@ -261,14 +261,17 @@ a;return this},setTargetPosition:function(a){this.targetPosition=a;return this}, this.delegate=this.offset=this.position=null}}})();(function(){CAAT.modules.CircleManager.PackedCircleManager=function(){return this};CAAT.modules.CircleManager.PackedCircleManager.prototype={allCircles:[],numberOfCollisionPasses:1,numberOfTargetingPasses:0,bounds:new CAAT.Rectangle,addCircle:function(a){a.id=this.allCircles.length;this.allCircles.push(a);return this},removeCircle:function(a){var b=0,c=false,d=this.allCircles.length;if(d===0)throw"Error: (PackedCircleManager) attempting to remove circle, and allCircles.length === 0!!";for(;d--;)if(this.allCircles[d]=== a){c=true;b=d;break}if(!c)throw"Could not locate circle in allCircles array!";this.allCircles[b].dealloc();this.allCircles[b]=null;return this},forceCirclesToMatchDelegatePositions:function(){for(var a=this.allCircles.length,b=0;bthis.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.right)a.position.x=this.bounds.left+e;else if(b&1&&c+fthis.bounds.bottom)a.position.y=this.bounds.top-e;else if(b&4&&d+f=this.bounds.right)a.position.x=a.position.x=this.bounds.right-e;else if(b&8&&c-ethis.bounds.bottom)a.position.y=this.bounds.bottom-e;else if(b&16&&d-ed?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil=function(){return this};CAAT.modules.ImageUtil.prototype={createAlphaSpriteSheet:function(a,b,c,d,e){if(a>=0;var c=document.createElement("canvas");c.width=a.width;c.height=a.height;var d= -c.getContext("2d");d.fillStyle="rgba(0,0,0,0)";d.fillRect(0,0,a.width,a.height);d.drawImage(a,0,0);var e=d.getImageData(0,0,a.width,a.height).data,f,g,h=c.height,i=0,j=c.width;f=0;var k=false;for(f=0;fb){k=true;break}if(k)break}h=f;k=false;for(f=c.height-1;f>=h;f--){for(g=3;gb){k=true;break}if(k)break}i=f;k=false;for(g=0;gb){k=true;break}if(k)break}j= -g;k=false;for(g=c.width-1;g>=j;g--){for(f=0;fb){k=true;break}if(k)break}f=g;if(0===j&&0===h&&c.width-1===f&&c.height-1===i)return c;e=f-j+1;i=i-h+1;h=d.getImageData(j,h,e,i);c.width=e;c.height=i;d=c.getContext("2d");d.putImageData(h,0,0);return c},createThumb:function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b- -d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}}})();(function(){CAAT.InterpolatorActor=function(){CAAT.InterpolatorActor.superclass.constructor.call(this);return this};CAAT.InterpolatorActor.prototype={interpolator:null,contour:null,S:50,gap:5,setGap:function(a){this.gap=a;return this},setInterpolator:function(a,b){this.interpolator=a;this.contour=a.getContour(b||this.S);return this},paint:function(a,b){CAAT.InterpolatorActor.superclass.paint.call(this,a,b);if(this.backgroundImage)return this;if(this.interpolator){var c=a.crc,d=this.width-2*this.gap, +d=b.getDistanceSquaredFromPosition(a.targetPosition),e=0;c>d?e=-1:c=0;a--)this.allCircles[a]===null&&this.allCircles.splice(a,1)},initialize:function(a){if(a)for(var b in a)this[b]=a[b];return this}}})();(function(){CAAT.modules.LocalStorage=function(){return this};CAAT.modules.LocalStorage.prototype={save:function(a,b){try{localStorage.setItem(a,JSON.stringify(b))}catch(c){}return this},load:function(a){try{return JSON.parse(localStorage.getItem(a))}catch(b){return null}},remove:function(a){try{localStorage.removeItem(a)}catch(b){}return this}}})();(function(){CAAT.modules.ImageUtil={};CAAT.modules.ImageUtil.createAlphaSpriteSheet=function(a,b,c,d,e){if(a>=0;var d=true,e=true,f=true,g=true;if(typeof c!=="undefined"){if(typeof c.top!== +"undefined")d=c.top;if(typeof c.bottom!=="undefined")e=c.bottom;if(typeof c.left!=="undefined")f=c.left;if(typeof c.right!=="undefined")g=c.right}c=document.createElement("canvas");c.width=a.width;c.height=a.height;var h=c.getContext("2d");h.fillStyle="rgba(0,0,0,0)";h.fillRect(0,0,a.width,a.height);h.drawImage(a,0,0);var i=h.getImageData(0,0,a.width,a.height).data,j,a=0,k=c.height-1,m=0,n=c.width-1,l=false;if(d){for(d=0;db){l=true;break}if(l)break}a= +d}if(e){l=false;for(d=c.height-1;d>=a;d--){for(j=0;jb){l=true;break}if(l)break}k=d}if(f){l=false;for(j=0;jb){l=true;break}if(l)break}m=j}if(g){l=false;for(j=c.width-1;j>=m;j--){for(d=a;d<=k;d++)if(i[d*c.width*4+3+j*4]>b){l=true;break}if(l)break}n=j}if(0===m&&0===a&&c.width-1===n&&c.height-1===k)return c;b=n-m+1;e=k-a+1;f=h.getImageData(m,a,b,e);c.width=b;c.height=e;h=c.getContext("2d");h.putImageData(f,0,0); +return c};CAAT.modules.ImageUtil.createThumb=function(a,b,c,d){var b=b||24,c=c||24,e=document.createElement("canvas");e.width=b;e.height=c;var f=e.getContext("2d");if(d){var g=Math.max(a.width,a.height),d=a.width/g*b,g=a.height/g*c;f.drawImage(a,(b-d)/2,(c-g)/2,d,g)}else f.drawImage(a,0,0,b,c);return e}})();(function(){CAAT.Font=function(){return this};CAAT.Font.prototype={fontSize:10,fontSizeUnit:"px",font:"Sans-Serif",fontStyle:"",fillStyle:"#fff",strokeStyle:null,padding:0,image:null,charMap:null,height:0,setPadding:function(a){this.padding=a;return this},setFontStyle:function(a){this.fontStyle=a;return this},setFontSize:function(a){this.fontSize=a;this.fontSizeUnit="px";return this},setFont:function(a){this.font=a;return this},setFillStyle:function(a){this.fillStyle=a;return this},setStrokeStyle:function(a){this.strokeStyle= +a;return this},create:function(a,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)+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;g=0&&b0.5;this.b2=Math.random()>0.5;this.b3=Math.random()>0.5;this.b4= Math.random()>0.5;this.spd1=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd2=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd3=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.spd4=Math.floor((Math.random()*3+1)*(Math.random()<0.5?1:-1));this.i1=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i2=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i3=Math.floor((Math.random()*2.4+1)*(Math.random()<0.5?1:-1));this.i4=Math.floor((Math.random()* -2.4+1)*(Math.random()<0.5?1:-1))},apply:function(a,b){var c=0;this.tpos1=this.pos1;this.tpos2=this.pos2;for(var d=this.bufferImage,e=this.m_colorMap,f=this.wavetable,g,h=0;h> -1;break;case 2:f=this.height-1}switch(this.m_alignv){case 0:g=0;break;case 1:g=this.width>>1;break;case 2:g=this.width-1}for(var c=(this.width>>1<<8)-e*g+b*f&65535,f=(this.height>>1<<8)-b*g-e*f&65535,g=this.sourceImageData.width,h=this.sourceImageData.data,i=this.bufferImage,j,k,l;d>this.shift&this.mask)*g+(k>>this.shift&this.mask),j<<=2,i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],k+=e,l+=b;a+=this.distortion;c-=b;f+= +1;break;case 2:f=this.height-1}switch(this.m_alignv){case 0:g=0;break;case 1:g=this.width>>1;break;case 2:g=this.width-1}for(var c=(this.width>>1<<8)-e*g+b*f&65535,f=(this.height>>1<<8)-b*g-e*f&65535,g=this.sourceImageData.width,h=this.sourceImageData.data,i=this.bufferImage,j,k,m;d>this.shift&this.mask)*g+(k>>this.shift&this.mask),j<<=2,i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],i[d++]=h[j++],k+=e,m+=b;a+=this.distortion;c-=b;f+= e-a}},apply:function(a,b){null!==this.sourceImageData&&this.rotoZoom(a,b);return CAAT.IMRotoZoom.superclass.apply.call(this,a,b)},setCenter:function(){var a=Math.random();this.m_alignv=a<0.33?0:a<0.66?1:2;a=Math.random();this.m_alignh=a<0.33?0:a<0.66?1:2}};extend(CAAT.IMRotoZoom,CAAT.ImageProcessor,null)})();(function(){CAAT.Program=function(a){this.gl=a;return this};CAAT.Program.prototype={shaderProgram:null,gl:null,setAlpha:function(){},getShader:function(a,b,c){if(b==="x-shader/x-fragment")b=a.createShader(a.FRAGMENT_SHADER);else if(b==="x-shader/x-vertex")b=a.createShader(a.VERTEX_SHADER);else return null;a.shaderSource(b,c);a.compileShader(b);return!a.getShaderParameter(b,a.COMPILE_STATUS)?(alert(a.getShaderInfoLog(b)),null):b},getDomShader:function(a,b){var c=document.getElementById(b);if(!c)return null; for(var d="",e=c.firstChild;e;)e.nodeType===3&&(d+=e.textContent),e=e.nextSibling;if(c.type==="x-shader/x-fragment")c=a.createShader(a.FRAGMENT_SHADER);else if(c.type==="x-shader/x-vertex")c=a.createShader(a.VERTEX_SHADER);else return null;a.shaderSource(c,d);a.compileShader(c);return!a.getShaderParameter(c,a.COMPILE_STATUS)?(alert(a.getShaderInfoLog(c)),null):c},initialize:function(){return this},getFragmentShader:function(){return null},getVertexShader:function(){return null},create:function(){var a= this.gl;this.shaderProgram=a.createProgram();a.attachShader(this.shaderProgram,this.getVertexShader());a.attachShader(this.shaderProgram,this.getFragmentShader());a.linkProgram(this.shaderProgram);a.useProgram(this.shaderProgram);return this},setMatrixUniform:function(a){this.gl.uniformMatrix4fv(this.shaderProgram.pMatrixUniform,false,new Float32Array(a.flatten()))},useProgram:function(){this.gl.useProgram(this.shaderProgram);return this}}})(); diff --git a/build/caat.js b/build/caat.js index 0cf9cb7a..05d9eed1 100644 --- a/build/caat.js +++ b/build/caat.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.1 build: 374 +Version: 0.1 build: 407 Created on: -DATE: 2011-12-16 -TIME: 17:29:01 +DATE: 2011-12-18 +TIME: 16:41:42 */ @@ -6866,6 +6866,7 @@ var cp1= proxy( return this; }, + /** * Calculates the text dimension in pixels and stores the values in textWidth and textHeight * attributes. @@ -6879,6 +6880,8 @@ var cp1= proxy( return this; } + var ctx= director.ctx; + director.ctx.save(); director.ctx.font= this.font; @@ -6969,6 +6972,7 @@ var cp1= proxy( if ( null!==this.outlineColor ) { canvas.strokeStyle= this.outlineColor; } + canvas.beginPath(); canvas.strokeText( this.text, tx, 0 ); } } @@ -8378,16 +8382,22 @@ var cp1= proxy( * @param width {number} a canvas width * @param height {number} a canvas height * @param canvas {HTMLCanvasElement=} An optional Canvas object. + * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + * and want events delivered to the correct element. * * @return this */ - initialize : function(width, height, canvas) { + initialize : function(width, height, canvas, proxy) { canvas = canvas || document.createElement('canvas'); this.canvas = canvas; + if ( typeof proxy==='undefined' ) { + proxy= canvas; + } + this.setBounds(0, 0, width, height); this.create(); - this.enableEvents(); + this.enableEvents(proxy); this.timeline = new Date().getTime(); @@ -8420,12 +8430,16 @@ var cp1= proxy( * @param height * @param canvas */ - initializeGL : function(width, height, canvas) { + initializeGL : function(width, height, canvas, proxy) { canvas = canvas || document.createElement('canvas'); canvas.width = width; canvas.height = height; + if ( typeof proxy==='undefined' ) { + proxy= canvas; + } + this.referenceWidth= width; this.referenceHeight=height; @@ -8444,7 +8458,7 @@ var cp1= proxy( this.setBounds(0, 0, width, height); this.crc = this.ctx; - this.enableEvents(); + this.enableEvents(canvas); this.timeline = new Date().getTime(); this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); @@ -9830,16 +9844,17 @@ var cp1= proxy( }, false ); }, - enableEvents : function() { + enableEvents : function( onElement ) { CAAT.RegisterDirector(this); this.in_ = false; - this.createEventHandler(); + this.createEventHandler( onElement ); }, - createEventHandler : function() { - var canvas= this.canvas; + createEventHandler : function( onElement ) { + //var canvas= this.canvas; this.in_ = false; - this.addHandlers(canvas); + //this.addHandlers(canvas); + this.addHandlers( onElement ); } }; @@ -9873,7 +9888,15 @@ var cp1= proxy( return this; }; - CAAT.Director.prototype.initialize= function(width, height, domElement) { + /** + * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most + * div in the document hierarchy (z-index 999999). + * @param width + * @param height + * @param domElement + * @param proxy + */ + CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { this.timeline = new Date().getTime(); this.domElement= domElement; @@ -9881,7 +9904,8 @@ var cp1= proxy( this.style('width',''+width+'px'); this.style('height',''+height+'px'); this.style('overflow', 'hidden' ); - this.enableEvents(); + + this.enableEvents(domElement); this.setBounds(0, 0, width, height); @@ -12264,88 +12288,110 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** (function() { - CAAT.modules.ImageUtil= function() { - return this; - }; + CAAT.modules.ImageUtil= {}; - CAAT.modules.ImageUtil.prototype= { - createAlphaSpriteSheet: function(maxAlpha, minAlpha, sheetSize, image, bg_fill_style ) { + CAAT.modules.ImageUtil.createAlphaSpriteSheet= function(maxAlpha, minAlpha, sheetSize, image, bg_fill_style ) { - if ( maxAlpha, bottom, left }Ê} */ - optimize : function(image, threshold) { - threshold>>=0; + CAAT.modules.ImageUtil.optimize= function(image, threshold, areas ) { + threshold>>=0; - var canvas= document.createElement('canvas'); - canvas.width= image.width; - canvas.height=image.height; - var ctx= canvas.getContext('2d'); + var atop= true; + var abottom= true; + var aleft= true; + var aright= true; + if ( typeof areas!=='undefined' ) { + if ( typeof areas.top!=='undefined' ) { + atop= areas.top; + } + if ( typeof areas.bottom!=='undefined' ) { + abottom= areas.bottom; + } + if ( typeof areas.left!=='undefined' ) { + aleft= areas.left; + } + if ( typeof areas.right!=='undefined' ) { + aright= areas.right; + } + } - ctx.fillStyle='rgba(0,0,0,0)'; - ctx.fillRect(0,0,image.width,image.height); - ctx.drawImage( image, 0, 0 ); - var imageData= ctx.getImageData(0,0,image.width,image.height); - var data= imageData.data; + var canvas= document.createElement('canvas'); + canvas.width= image.width; + canvas.height=image.height; + var ctx= canvas.getContext('2d'); - var i,j; - var miny= canvas.height, maxy=0; - var minx= canvas.width, maxx=0; + ctx.fillStyle='rgba(0,0,0,0)'; + ctx.fillRect(0,0,image.width,image.height); + ctx.drawImage( image, 0, 0 ); - var alpha= false; + var imageData= ctx.getImageData(0,0,image.width,image.height); + var data= imageData.data; + + var i,j; + var miny= 0, maxy=canvas.height-1; + var minx= 0, maxx=canvas.width-1; + + var alpha= false; + + if ( atop ) { for( i=0; ithreshold ) { @@ -12360,10 +12406,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } // i contiene el indice del ultimo scan que no es transparente total. miny= i; + } + if ( abottom ) { alpha= false; for( i=canvas.height-1; i>=miny; i-- ) { - for( j=3; jthreshold ) { alpha= true; break; @@ -12375,11 +12423,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } maxy= i; + } - + if ( aleft ) { alpha= false; for( j=0; jthreshold ) { alpha= true; break; @@ -12390,10 +12439,12 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } minx= j; + } + if ( aright ) { alpha= false; for( j=canvas.width-1; j>=minx; j-- ) { - for( i=0; ithreshold ) { alpha= true; break; @@ -12404,42 +12455,43 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } } maxx= j; + } - if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { - return canvas; - } - - var width= maxx-minx+1; - var height=maxy-miny+1; - var id2= ctx.getImageData( minx, miny, width, height ); + if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { + return canvas; + } - canvas.width= width; - canvas.height= height; - ctx= canvas.getContext('2d'); - ctx.putImageData( id2, 0, 0 ); + var width= maxx-minx+1; + var height=maxy-miny+1; + var id2= ctx.getImageData( minx, miny, width, height ); - return canvas; - }, - createThumb : function(image, w, h, best_fit) { - w= w||24; - h= h||24; - var canvas= document.createElement('canvas'); - canvas.width= w; - canvas.height= h; - var ctx= canvas.getContext('2d'); + canvas.width= width; + canvas.height= height; + ctx= canvas.getContext('2d'); + ctx.putImageData( id2, 0, 0 ); - if ( best_fit ) { - var max= Math.max( image.width, image.height ); - var ww= image.width/max*w; - var hh= image.height/max*h; - ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); - } else { - ctx.drawImage( image, 0, 0, w, h ); - } + return canvas; + }; - return canvas; + CAAT.modules.ImageUtil.createThumb= function(image, w, h, best_fit) { + w= w||24; + h= h||24; + var canvas= document.createElement('canvas'); + canvas.width= w; + canvas.height= h; + var ctx= canvas.getContext('2d'); + + if ( best_fit ) { + var max= Math.max( image.width, image.height ); + var ww= image.width/max*w; + var hh= image.height/max*h; + ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); + } else { + ctx.drawImage( image, 0, 0, w, h ); } - }; + + return canvas; + } })();/** * See LICENSE file. @@ -12504,7 +12556,166 @@ CAAT.modules.CircleManager = CAAT.modules.CircleManager || {};/** } }; -})();/** +})(); +(function() { + + /** + * @constructor + */ + CAAT.Font= function( ) { + return this; + }; + + var UNKNOWN_CHAR_WIDTH= 10; + + CAAT.Font.prototype= { + + fontSize : 10, + fontSizeUnit: "px", + font : 'Sans-Serif', + fontStyle : '', + fillStyle : '#fff', + strokeStyle : null, + padding : 0, + image : null, + charMap : null, + + height : 0, + + setPadding : function( padding ) { + this.padding= padding; + return this; + }, + + setFontStyle : function( style ) { + this.fontStyle= style; + return this; + }, + + setFontSize : function( fontSize ) { + this.fontSize= fontSize; + this.fontSizeUnit= 'px'; + return this; + }, + + setFont : function( font ) { + this.font= font; + return this; + }, + + setFillStyle : function( style ) { + this.fillStyle= style; + return this; + }, + + setStrokeStyle : function( style ) { + this.strokeStyle= style; + return this; + }, + + create : function( chars, padding ) { + var canvas= document.createElement('canvas'); + canvas.width= 1; + canvas.height= 1; + var ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + + var textWidth= 0; + var charWidth= []; + var i; + var x; + var cchar; + + for( i=0; i>0 ) + 2 * padding; + charWidth.push(cw); + textWidth+= cw; + } + + canvas.width= textWidth; + canvas.height= (this.fontSize*1.5)>>0; + ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + ctx.fillStyle= this.fillStyle; + ctx.strokeStyle= this.strokeStyle; + + this.charMap= {}; + + x=0; + for( i=0; iClasses
  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -528,6 +530,18 @@

    /Users/ibon/js/CAAT/src/modules/Font/font.js

    + +
    + + + +

    @@ -680,7 +694,7 @@

    /User
    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    \ No newline at end of file diff --git a/documentation/jsdoc/index.html b/documentation/jsdoc/index.html index 466f8f18..83b5f1c0 100644 --- a/documentation/jsdoc/index.html +++ b/documentation/jsdoc/index.html @@ -214,6 +214,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -370,6 +372,12 @@

    CAAT.Director


    +
    +

    CAAT.Font

    + +
    +
    +

    CAAT.IMActor

    @@ -548,7 +556,7 @@

    Function

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 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 de3b256e..e25a1a46 100644 --- a/documentation/jsdoc/symbols/CAAT.Actor.html +++ b/documentation/jsdoc/symbols/CAAT.Actor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -4440,7 +4442,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.ActorContainer.html b/documentation/jsdoc/symbols/CAAT.ActorContainer.html index b9d82504..ad82b24b 100644 --- a/documentation/jsdoc/symbols/CAAT.ActorContainer.html +++ b/documentation/jsdoc/symbols/CAAT.ActorContainer.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1414,7 +1416,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.AudioManager.html b/documentation/jsdoc/symbols/CAAT.AudioManager.html index e0214b21..7d82661f 100644 --- a/documentation/jsdoc/symbols/CAAT.AudioManager.html +++ b/documentation/jsdoc/symbols/CAAT.AudioManager.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1123,7 +1125,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html index 22ff1ac3..423d3b2f 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html +++ b/documentation/jsdoc/symbols/CAAT.B2DBodyActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1223,7 +1225,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html index 84dbad9b..f3e6a07d 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DCircularBody.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -628,7 +630,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html index aab4d847..d965afcd 100644 --- a/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html +++ b/documentation/jsdoc/symbols/CAAT.B2DPolygonBody.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -710,7 +712,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Bezier.html b/documentation/jsdoc/symbols/CAAT.Bezier.html index b666d66e..8bbfc75e 100644 --- a/documentation/jsdoc/symbols/CAAT.Bezier.html +++ b/documentation/jsdoc/symbols/CAAT.Bezier.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1018,7 +1020,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.CatmullRom.html b/documentation/jsdoc/symbols/CAAT.CatmullRom.html index 8e320ded..e64fef94 100644 --- a/documentation/jsdoc/symbols/CAAT.CatmullRom.html +++ b/documentation/jsdoc/symbols/CAAT.CatmullRom.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -593,7 +595,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Color.RGB.html b/documentation/jsdoc/symbols/CAAT.Color.RGB.html index f1955353..38200b88 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.RGB.html +++ b/documentation/jsdoc/symbols/CAAT.Color.RGB.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -466,7 +468,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Color.html b/documentation/jsdoc/symbols/CAAT.Color.html index 95e76f63..43ee9808 100644 --- a/documentation/jsdoc/symbols/CAAT.Color.html +++ b/documentation/jsdoc/symbols/CAAT.Color.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -690,7 +692,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:25 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Curve.html b/documentation/jsdoc/symbols/CAAT.Curve.html index ae3d1c91..14103de4 100644 --- a/documentation/jsdoc/symbols/CAAT.Curve.html +++ b/documentation/jsdoc/symbols/CAAT.Curve.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -965,7 +967,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:13 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.CurvePath.html b/documentation/jsdoc/symbols/CAAT.CurvePath.html index 165bedce..173dc065 100644 --- a/documentation/jsdoc/symbols/CAAT.CurvePath.html +++ b/documentation/jsdoc/symbols/CAAT.CurvePath.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1195,7 +1197,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:14 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Director.html b/documentation/jsdoc/symbols/CAAT.Director.html index 3684864f..0b7597f0 100644 --- a/documentation/jsdoc/symbols/CAAT.Director.html +++ b/documentation/jsdoc/symbols/CAAT.Director.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -592,7 +594,7 @@

      -
    enableEvents() +
    enableEvents(onElement)
    @@ -772,7 +774,7 @@

      -
    initialize(width, height, canvas) +
    initialize(width, height, canvas, proxy)
    This method performs Director initialization.
    @@ -781,7 +783,7 @@

      -
    initializeGL(width, height, canvas) +
    initializeGL(width, height, canvas, proxy)
    Experimental.
    @@ -2298,7 +2300,7 @@

    - enableEvents() + enableEvents(onElement)
    @@ -2310,6 +2312,17 @@

    +
    +
    Parameters:
    + +
    + onElement + +
    +
    + +
    + @@ -2970,7 +2983,7 @@

    - initialize(width, height, canvas) + initialize(width, height, canvas, proxy)
    @@ -3007,6 +3020,13 @@

    {HTMLCanvasElement=} An optional Canvas object.
    +
    + proxy + +
    +
    {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + and want events delivered to the correct element.
    + @@ -3029,7 +3049,7 @@

    - initializeGL(width, height, canvas) + initializeGL(width, height, canvas, proxy)
    @@ -3063,6 +3083,12 @@

    +
    + proxy + +
    +
    + @@ -4180,7 +4206,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:14 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.IMActor.html b/documentation/jsdoc/symbols/CAAT.IMActor.html index 90469932..970f852a 100644 --- a/documentation/jsdoc/symbols/CAAT.IMActor.html +++ b/documentation/jsdoc/symbols/CAAT.IMActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -549,7 +551,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:14 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.IMBump.html b/documentation/jsdoc/symbols/CAAT.IMBump.html index f83c4e63..6452ae6d 100644 --- a/documentation/jsdoc/symbols/CAAT.IMBump.html +++ b/documentation/jsdoc/symbols/CAAT.IMBump.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -815,7 +817,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.IMPlasma.html b/documentation/jsdoc/symbols/CAAT.IMPlasma.html index 1067d07a..89fd5a36 100644 --- a/documentation/jsdoc/symbols/CAAT.IMPlasma.html +++ b/documentation/jsdoc/symbols/CAAT.IMPlasma.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -570,7 +572,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html index 696c47e0..fc9b18ee 100644 --- a/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html +++ b/documentation/jsdoc/symbols/CAAT.IMRotoZoom.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -616,7 +618,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html index 405f1251..00006e39 100644 --- a/documentation/jsdoc/symbols/CAAT.ImagePreloader.html +++ b/documentation/jsdoc/symbols/CAAT.ImagePreloader.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -472,7 +474,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:14 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html index 8c8186ae..6cbb1fb9 100644 --- a/documentation/jsdoc/symbols/CAAT.ImageProcessor.html +++ b/documentation/jsdoc/symbols/CAAT.ImageProcessor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -956,7 +958,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:26 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Interpolator.html b/documentation/jsdoc/symbols/CAAT.Interpolator.html index 95120f55..bb2b011a 100644 --- a/documentation/jsdoc/symbols/CAAT.Interpolator.html +++ b/documentation/jsdoc/symbols/CAAT.Interpolator.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1351,7 +1353,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html index 87141e00..78faa83e 100644 --- a/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html +++ b/documentation/jsdoc/symbols/CAAT.InterpolatorActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -611,7 +613,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.LinearPath.html b/documentation/jsdoc/symbols/CAAT.LinearPath.html index d53084d4..09b01bd7 100644 --- a/documentation/jsdoc/symbols/CAAT.LinearPath.html +++ b/documentation/jsdoc/symbols/CAAT.LinearPath.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1075,7 +1077,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Matrix3.html b/documentation/jsdoc/symbols/CAAT.Matrix3.html index 35c07548..44c18764 100644 --- a/documentation/jsdoc/symbols/CAAT.Matrix3.html +++ b/documentation/jsdoc/symbols/CAAT.Matrix3.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1611,7 +1613,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.MatrixStack.html b/documentation/jsdoc/symbols/CAAT.MatrixStack.html index b61a1373..077618d8 100644 --- a/documentation/jsdoc/symbols/CAAT.MatrixStack.html +++ b/documentation/jsdoc/symbols/CAAT.MatrixStack.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -620,7 +622,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.MouseEvent.html b/documentation/jsdoc/symbols/CAAT.MouseEvent.html index d794c9b1..05dfc566 100644 --- a/documentation/jsdoc/symbols/CAAT.MouseEvent.html +++ b/documentation/jsdoc/symbols/CAAT.MouseEvent.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -641,7 +643,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Path.html b/documentation/jsdoc/symbols/CAAT.Path.html index 0e2e5a23..f56a2fe2 100644 --- a/documentation/jsdoc/symbols/CAAT.Path.html +++ b/documentation/jsdoc/symbols/CAAT.Path.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -2977,7 +2979,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.PathActor.html b/documentation/jsdoc/symbols/CAAT.PathActor.html index 33495919..ec2bb428 100644 --- a/documentation/jsdoc/symbols/CAAT.PathActor.html +++ b/documentation/jsdoc/symbols/CAAT.PathActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -784,7 +786,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.PathSegment.html b/documentation/jsdoc/symbols/CAAT.PathSegment.html index d22a2ae5..eb413695 100644 --- a/documentation/jsdoc/symbols/CAAT.PathSegment.html +++ b/documentation/jsdoc/symbols/CAAT.PathSegment.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1143,7 +1145,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Point.html b/documentation/jsdoc/symbols/CAAT.Point.html index a5ddccba..18bfcdcc 100644 --- a/documentation/jsdoc/symbols/CAAT.Point.html +++ b/documentation/jsdoc/symbols/CAAT.Point.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1267,7 +1269,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Rectangle.html b/documentation/jsdoc/symbols/CAAT.Rectangle.html index d698c7f9..e16fc7c1 100644 --- a/documentation/jsdoc/symbols/CAAT.Rectangle.html +++ b/documentation/jsdoc/symbols/CAAT.Rectangle.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -796,7 +798,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.Scene.html b/documentation/jsdoc/symbols/CAAT.Scene.html index f0e1197f..6bd6686b 100644 --- a/documentation/jsdoc/symbols/CAAT.Scene.html +++ b/documentation/jsdoc/symbols/CAAT.Scene.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1744,7 +1746,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.ShapeActor.html b/documentation/jsdoc/symbols/CAAT.ShapeActor.html index d1406e73..f116ae3b 100644 --- a/documentation/jsdoc/symbols/CAAT.ShapeActor.html +++ b/documentation/jsdoc/symbols/CAAT.ShapeActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -986,7 +988,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:28 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:16 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.SpriteImage.html b/documentation/jsdoc/symbols/CAAT.SpriteImage.html index 1edb2c8f..cb566d0c 100644 --- a/documentation/jsdoc/symbols/CAAT.SpriteImage.html +++ b/documentation/jsdoc/symbols/CAAT.SpriteImage.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1736,7 +1738,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.StarActor.html b/documentation/jsdoc/symbols/CAAT.StarActor.html index ab7977c2..9c5a8110 100644 --- a/documentation/jsdoc/symbols/CAAT.StarActor.html +++ b/documentation/jsdoc/symbols/CAAT.StarActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1028,7 +1030,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.TextActor.html b/documentation/jsdoc/symbols/CAAT.TextActor.html index a42d8841..4c541288 100644 --- a/documentation/jsdoc/symbols/CAAT.TextActor.html +++ b/documentation/jsdoc/symbols/CAAT.TextActor.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1119,7 +1121,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.TimerTask.html b/documentation/jsdoc/symbols/CAAT.TimerTask.html index 0567f5f4..539d6afa 100644 --- a/documentation/jsdoc/symbols/CAAT.TimerTask.html +++ b/documentation/jsdoc/symbols/CAAT.TimerTask.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -642,7 +644,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.html b/documentation/jsdoc/symbols/CAAT.html index 5bcf3e6e..c3817a5b 100644 --- a/documentation/jsdoc/symbols/CAAT.html +++ b/documentation/jsdoc/symbols/CAAT.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1811,7 +1813,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:24 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:12 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html index fd127046..70f2ca72 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircle.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1021,7 +1023,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html index 6a3ecb5e..3f7fdc5e 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.PackedCircleManager.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -1050,7 +1052,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html index b81f95d4..9f3741cf 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html +++ b/documentation/jsdoc/symbols/CAAT.modules.CircleManager.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -379,7 +381,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html index 284cc5c2..9bf0c255 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html +++ b/documentation/jsdoc/symbols/CAAT.modules.LocalStorage.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -564,7 +566,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/CAAT.modules.html b/documentation/jsdoc/symbols/CAAT.modules.html index 923176ff..1c81d507 100644 --- a/documentation/jsdoc/symbols/CAAT.modules.html +++ b/documentation/jsdoc/symbols/CAAT.modules.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -343,37 +345,17 @@

    <static>  
    - CAAT.modules.LayoutUtils + CAAT.modules.ImageUtil
    See LICENSE file.
    - - - - - - - - - - - - - - - - - - - - - @@ -385,6 +367,9 @@

    + + + @@ -424,18 +409,18 @@

    Field Detail - +
    <static> - CAAT.modules.LayoutUtils + CAAT.modules.ImageUtil
    See LICENSE file.
    - Defined in: layout.js. + Defined in: ImageUtil.js.
    @@ -447,37 +432,26 @@

    - +
    - - - - -
    - Method Detail -
    - - +
    <static> - CAAT.modules.ImageUtil() + CAAT.modules.LayoutUtils
    See LICENSE file.
    - Defined in: ImageUtil.js. + Defined in: layout.js.
    - - - - + @@ -486,6 +460,9 @@

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

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:27 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:15 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/Function.html b/documentation/jsdoc/symbols/Function.html index 7e905237..d83d7131 100644 --- a/documentation/jsdoc/symbols/Function.html +++ b/documentation/jsdoc/symbols/Function.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -390,7 +392,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:29 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:17 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/_global_.html b/documentation/jsdoc/symbols/_global_.html index e7b36165..cb2b6b37 100644 --- a/documentation/jsdoc/symbols/_global_.html +++ b/documentation/jsdoc/symbols/_global_.html @@ -219,6 +219,8 @@

    Classes

  • CAAT.Director
  • +
  • CAAT.Font
  • +
  • CAAT.IMActor
  • CAAT.ImagePreloader
  • @@ -766,7 +768,7 @@

    - Documentation generated by JsDoc Toolkit 2.4.0 on Fri Dec 16 2011 17:29:24 GMT+0100 (CET) + Documentation generated by JsDoc Toolkit 2.4.0 on Sun Dec 18 2011 16:42:12 GMT+0100 (CET)
    diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html index 0dc02c7d..6798e1a5 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_model_actor.js.html @@ -2208,598 +2208,602 @@ 2201 2202 return this; 2203 }, -2204 /** -2205 * Calculates the text dimension in pixels and stores the values in textWidth and textHeight -2206 * attributes. -2207 * If Actor's width and height were not set, the Actor's dimension will be set to these values. -2208 * @param director a CAAT.Director instance. -2209 * @return this -2210 */ -2211 calcTextSize : function(director) { -2212 -2213 if ( director.glEnabled ) { -2214 return this; -2215 } -2216 -2217 director.ctx.save(); -2218 director.ctx.font= this.font; +2204 +2205 /** +2206 * Calculates the text dimension in pixels and stores the values in textWidth and textHeight +2207 * attributes. +2208 * If Actor's width and height were not set, the Actor's dimension will be set to these values. +2209 * @param director a CAAT.Director instance. +2210 * @return this +2211 */ +2212 calcTextSize : function(director) { +2213 +2214 if ( director.glEnabled ) { +2215 return this; +2216 } +2217 +2218 var ctx= director.ctx; 2219 -2220 this.textWidth= director.crc.measureText( this.text ).width; -2221 if (this.width===0) { -2222 this.width= this.textWidth; -2223 } -2224 -2225 try { -2226 var pos= this.font.indexOf("px"); -2227 var s = this.font.substring(0, pos ); -2228 this.textHeight= parseInt(s,10); -2229 -2230 // needed to calculate the descent. -2231 // no context.getDescent(font) WTF !!! -2232 this.textHeight+= (this.textHeight/4)>>0; -2233 } catch(e) { -2234 this.textHeight=20; // default height; -2235 } -2236 -2237 if ( this.height===0 ) { -2238 this.height= this.textHeight; -2239 } -2240 -2241 director.crc.restore(); -2242 -2243 return this; -2244 }, -2245 /** -2246 * Custom paint method for TextActor instances. -2247 * If the path attribute is set, the text will be drawn traversing the path. -2248 * -2249 * @param director a valid CAAT.Director instance. -2250 * @param time an integer with the Scene time the Actor is being drawn. -2251 */ -2252 paint : function(director, time) { -2253 -2254 if ( this.backgroundImage ) { // cached -2255 CAAT.TextActor.superclass.paint.call(this, director, time ); -2256 return ; -2257 } -2258 -2259 if ( null===this.text) { -2260 return; -2261 } -2262 -2263 if ( this.textWidth===0 || this.textHeight===0 ) { -2264 this.calcTextSize(director); -2265 } -2266 -2267 var canvas= director.crc; -2268 -2269 if( null!==this.font ) { -2270 canvas.font= this.font; -2271 } -2272 if ( null!==this.textAlign ) { -2273 canvas.textAlign= this.textAlign; +2220 director.ctx.save(); +2221 director.ctx.font= this.font; +2222 +2223 this.textWidth= director.crc.measureText( this.text ).width; +2224 if (this.width===0) { +2225 this.width= this.textWidth; +2226 } +2227 +2228 try { +2229 var pos= this.font.indexOf("px"); +2230 var s = this.font.substring(0, pos ); +2231 this.textHeight= parseInt(s,10); +2232 +2233 // needed to calculate the descent. +2234 // no context.getDescent(font) WTF !!! +2235 this.textHeight+= (this.textHeight/4)>>0; +2236 } catch(e) { +2237 this.textHeight=20; // default height; +2238 } +2239 +2240 if ( this.height===0 ) { +2241 this.height= this.textHeight; +2242 } +2243 +2244 director.crc.restore(); +2245 +2246 return this; +2247 }, +2248 /** +2249 * Custom paint method for TextActor instances. +2250 * If the path attribute is set, the text will be drawn traversing the path. +2251 * +2252 * @param director a valid CAAT.Director instance. +2253 * @param time an integer with the Scene time the Actor is being drawn. +2254 */ +2255 paint : function(director, time) { +2256 +2257 if ( this.backgroundImage ) { // cached +2258 CAAT.TextActor.superclass.paint.call(this, director, time ); +2259 return ; +2260 } +2261 +2262 if ( null===this.text) { +2263 return; +2264 } +2265 +2266 if ( this.textWidth===0 || this.textHeight===0 ) { +2267 this.calcTextSize(director); +2268 } +2269 +2270 var canvas= director.crc; +2271 +2272 if( null!==this.font ) { +2273 canvas.font= this.font; 2274 } -2275 if ( null!==this.textBaseline ) { -2276 canvas.textBaseline= this.textBaseline; +2275 if ( null!==this.textAlign ) { +2276 canvas.textAlign= this.textAlign; 2277 } -2278 if ( null!==this.fillStyle ) { -2279 canvas.fillStyle= this.fillStyle; +2278 if ( null!==this.textBaseline ) { +2279 canvas.textBaseline= this.textBaseline; 2280 } -2281 -2282 if (null===this.path) { -2283 -2284 var tx=0; -2285 if ( this.textAlign==='center') { -2286 tx= (this.width/2)|0; -2287 } else if ( this.textAlign==='right' ) { -2288 tx= this.width; -2289 } -2290 -2291 if ( this.fill ) { -2292 canvas.fillText( this.text, tx, 0 ); -2293 if ( this.outline ) { -2294 -2295 // firefox necesita beginPath, si no, dibujara ademas el cuadrado del -2296 // contenedor de los textos. -2297 if ( null!==this.outlineColor ) { -2298 canvas.strokeStyle= this.outlineColor; -2299 } -2300 canvas.beginPath(); -2301 canvas.strokeText( this.text, tx, 0 ); -2302 } -2303 } else { -2304 if ( null!==this.outlineColor ) { -2305 canvas.strokeStyle= this.outlineColor; -2306 } -2307 canvas.strokeText( this.text, tx, 0 ); -2308 } -2309 } -2310 else { -2311 this.drawOnPath(director,time); -2312 } -2313 }, -2314 /** -2315 * Private. -2316 * Draw the text traversing a path. -2317 * @param director a valid CAAT.Director instance. -2318 * @param time an integer with the Scene time the Actor is being drawn. -2319 */ -2320 drawOnPath : function(director, time) { -2321 -2322 var canvas= director.crc; -2323 -2324 var textWidth=this.sign * this.pathInterpolator.getPosition( -2325 (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; -2326 var p0= new CAAT.Point(0,0,0); -2327 var p1= new CAAT.Point(0,0,0); -2328 -2329 for( var i=0; i<this.text.length; i++ ) { -2330 var caracter= this.text[i].toString(); -2331 var charWidth= canvas.measureText( caracter ).width; +2281 if ( null!==this.fillStyle ) { +2282 canvas.fillStyle= this.fillStyle; +2283 } +2284 +2285 if (null===this.path) { +2286 +2287 var tx=0; +2288 if ( this.textAlign==='center') { +2289 tx= (this.width/2)|0; +2290 } else if ( this.textAlign==='right' ) { +2291 tx= this.width; +2292 } +2293 +2294 if ( this.fill ) { +2295 canvas.fillText( this.text, tx, 0 ); +2296 if ( this.outline ) { +2297 +2298 // firefox necesita beginPath, si no, dibujara ademas el cuadrado del +2299 // contenedor de los textos. +2300 if ( null!==this.outlineColor ) { +2301 canvas.strokeStyle= this.outlineColor; +2302 } +2303 canvas.beginPath(); +2304 canvas.strokeText( this.text, tx, 0 ); +2305 } +2306 } else { +2307 if ( null!==this.outlineColor ) { +2308 canvas.strokeStyle= this.outlineColor; +2309 } +2310 canvas.beginPath(); +2311 canvas.strokeText( this.text, tx, 0 ); +2312 } +2313 } +2314 else { +2315 this.drawOnPath(director,time); +2316 } +2317 }, +2318 /** +2319 * Private. +2320 * Draw the text traversing a path. +2321 * @param director a valid CAAT.Director instance. +2322 * @param time an integer with the Scene time the Actor is being drawn. +2323 */ +2324 drawOnPath : function(director, time) { +2325 +2326 var canvas= director.crc; +2327 +2328 var textWidth=this.sign * this.pathInterpolator.getPosition( +2329 (time%this.pathDuration)/this.pathDuration ).y * this.path.getLength() ; +2330 var p0= new CAAT.Point(0,0,0); +2331 var p1= new CAAT.Point(0,0,0); 2332 -2333 var pathLength= this.path.getLength(); -2334 -2335 var currentCurveLength= charWidth/2 + textWidth; +2333 for( var i=0; i<this.text.length; i++ ) { +2334 var caracter= this.text[i].toString(); +2335 var charWidth= canvas.measureText( caracter ).width; 2336 -2337 p0= this.path.getPositionFromLength(currentCurveLength).clone(); -2338 p1= this.path.getPositionFromLength(currentCurveLength-0.1).clone(); -2339 -2340 var angle= Math.atan2( p0.y-p1.y, p0.x-p1.x ); -2341 -2342 canvas.save(); +2337 var pathLength= this.path.getLength(); +2338 +2339 var currentCurveLength= charWidth/2 + textWidth; +2340 +2341 p0= this.path.getPositionFromLength(currentCurveLength).clone(); +2342 p1= this.path.getPositionFromLength(currentCurveLength-0.1).clone(); 2343 -2344 canvas.translate( (0.5+p0.x)|0, (0.5+p0.y)|0 ); -2345 canvas.rotate( angle ); -2346 if ( this.fill ) { -2347 canvas.fillText(caracter,0,0); -2348 } -2349 if ( this.outline ) { -2350 canvas.strokeStyle= this.outlineColor; -2351 canvas.strokeText(caracter,0,0); +2344 var angle= Math.atan2( p0.y-p1.y, p0.x-p1.x ); +2345 +2346 canvas.save(); +2347 +2348 canvas.translate( (0.5+p0.x)|0, (0.5+p0.y)|0 ); +2349 canvas.rotate( angle ); +2350 if ( this.fill ) { +2351 canvas.fillText(caracter,0,0); 2352 } -2353 -2354 canvas.restore(); -2355 -2356 textWidth+= charWidth; -2357 } -2358 }, -2359 /** -2360 * Set the path, interpolator and duration to draw the text on. -2361 * @param path a valid CAAT.Path instance. -2362 * @param interpolator a CAAT.Interpolator object. If not set, a Linear Interpolator will be used. -2363 * @param duration an integer indicating the time to take to traverse the path. Optional. 10000 ms -2364 * by default. -2365 */ -2366 setPath : function( path, interpolator, duration ) { -2367 this.path= path; -2368 this.pathInterpolator= interpolator || new CAAT.Interpolator().createLinearInterpolator(); -2369 this.pathDuration= duration || 10000; -2370 -2371 /* -2372 parent could not be set by the time this method is called. -2373 so the actors bounds set is removed. -2374 the developer must ensure to call setbounds properly on actor. -2375 */ -2376 this.mouseEnabled= false; -2377 -2378 return this; -2379 } -2380 }; +2353 if ( this.outline ) { +2354 canvas.strokeStyle= this.outlineColor; +2355 canvas.strokeText(caracter,0,0); +2356 } +2357 +2358 canvas.restore(); +2359 +2360 textWidth+= charWidth; +2361 } +2362 }, +2363 /** +2364 * Set the path, interpolator and duration to draw the text on. +2365 * @param path a valid CAAT.Path instance. +2366 * @param interpolator a CAAT.Interpolator object. If not set, a Linear Interpolator will be used. +2367 * @param duration an integer indicating the time to take to traverse the path. Optional. 10000 ms +2368 * by default. +2369 */ +2370 setPath : function( path, interpolator, duration ) { +2371 this.path= path; +2372 this.pathInterpolator= interpolator || new CAAT.Interpolator().createLinearInterpolator(); +2373 this.pathDuration= duration || 10000; +2374 +2375 /* +2376 parent could not be set by the time this method is called. +2377 so the actors bounds set is removed. +2378 the developer must ensure to call setbounds properly on actor. +2379 */ +2380 this.mouseEnabled= false; 2381 -2382 extend( CAAT.TextActor, CAAT.ActorContainer, null); -2383 })(); -2384 -2385 (function() { -2386 -2387 /** -2388 * This Actor draws common shapes, concretely Circles and rectangles. -2389 * -2390 * @constructor -2391 * @extends CAAT.ActorContainer -2392 */ -2393 CAAT.ShapeActor = function() { -2394 CAAT.ShapeActor.superclass.constructor.call(this); -2395 this.compositeOp= 'source-over'; -2396 -2397 /** -2398 * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default, -2399 * so if no explicit call to setShape was made, nothing would be drawn. -2400 */ -2401 this.setShape( this.SHAPE_CIRCLE ); -2402 return this; -2403 }; -2404 -2405 CAAT.ShapeActor.prototype= { -2406 -2407 shape: 0, // shape type. One of the constant SHAPE_* values -2408 compositeOp: null, // a valid canvas rendering context string describing compositeOps. -2409 lineWidth: 1, -2410 lineCap: null, -2411 lineJoin: null, -2412 miterLimit: null, -2413 -2414 SHAPE_CIRCLE: 0, // Constants to describe different shapes. -2415 SHAPE_RECTANGLE:1, -2416 -2417 /** -2418 * -2419 * @param l {number>0} -2420 */ -2421 setLineWidth : function(l) { -2422 this.lineWidth= l; -2423 return this; -2424 }, -2425 /** -2426 * -2427 * @param lc {string{butt|round|square}} -2428 */ -2429 setLineCap : function(lc) { -2430 this.lineCap= lc; -2431 return this; -2432 }, -2433 /** -2434 * -2435 * @param lj {string{bevel|round|miter}} -2436 */ -2437 setLineJoin : function(lj) { -2438 this.lineJoin= lj; -2439 return this; -2440 }, -2441 /** -2442 * -2443 * @param ml {integer>0} -2444 */ -2445 setMiterLimit : function(ml) { -2446 this.miterLimit= ml; -2447 return this; -2448 }, -2449 getLineCap : function() { -2450 return this.lineCap; -2451 }, -2452 getLineJoin : function() { -2453 return this.lineJoin; -2454 }, -2455 getMiterLimit : function() { -2456 return this.miterLimit; -2457 }, -2458 getLineWidth : function() { -2459 return this.lineWidth; -2460 }, -2461 /** -2462 * Sets shape type. -2463 * No check for parameter validity is performed. -2464 * Set paint method according to the shape. -2465 * @param iShape an integer with any of the SHAPE_* constants. -2466 * @return this -2467 */ -2468 setShape : function(iShape) { -2469 this.shape= iShape; -2470 this.paint= this.shape===this.SHAPE_CIRCLE ? -2471 this.paintCircle : -2472 this.paintRectangle; -2473 return this; -2474 }, -2475 /** -2476 * Sets the composite operation to apply on shape drawing. -2477 * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. -2478 * @return this -2479 */ -2480 setCompositeOp : function(compositeOp){ -2481 this.compositeOp= compositeOp; -2482 return this; -2483 }, -2484 /** -2485 * Draws the shape. -2486 * Applies the values of fillStype, strokeStyle, compositeOp, etc. -2487 * -2488 * @param director a valid CAAT.Director instance. -2489 * @param time an integer with the Scene time the Actor is being drawn. -2490 */ -2491 paint : function(director,time) { -2492 }, -2493 /** -2494 * @private -2495 * Draws a circle. -2496 * @param director a valid CAAT.Director instance. -2497 * @param time an integer with the Scene time the Actor is being drawn. -2498 */ -2499 paintCircle : function(director,time) { -2500 var ctx= director.crc; -2501 -2502 ctx.lineWidth= this.lineWidth; -2503 -2504 ctx.globalCompositeOperation= this.compositeOp; -2505 if ( null!==this.fillStyle ) { -2506 ctx.fillStyle= this.fillStyle; -2507 ctx.beginPath(); -2508 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2, 0, 2*Math.PI, false ); -2509 ctx.fill(); -2510 } -2511 -2512 if ( null!==this.strokeStyle ) { -2513 ctx.strokeStyle= this.strokeStyle; -2514 ctx.beginPath(); -2515 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2, 0, 2*Math.PI, false ); -2516 ctx.stroke(); -2517 } -2518 }, -2519 /** -2520 * -2521 * Private -2522 * Draws a Rectangle. -2523 * -2524 * @param director a valid CAAT.Director instance. -2525 * @param time an integer with the Scene time the Actor is being drawn. -2526 */ -2527 paintRectangle : function(director,time) { -2528 var ctx= director.crc; -2529 -2530 ctx.lineWidth= this.lineWidth; -2531 -2532 if ( this.lineCap ) { -2533 ctx.lineCap= this.lineCap; -2534 } -2535 if ( this.lineJoin ) { -2536 ctx.lineJoin= this.lineJoin; -2537 } -2538 if ( this.miterLimit ) { -2539 ctx.miterLimit= this.miterLimit; -2540 } -2541 -2542 ctx.globalCompositeOperation= this.compositeOp; -2543 if ( null!==this.fillStyle ) { -2544 ctx.fillStyle= this.fillStyle; -2545 ctx.beginPath(); -2546 ctx.fillRect(0,0,this.width,this.height); -2547 ctx.fill(); -2548 } -2549 -2550 if ( null!==this.strokeStyle ) { -2551 ctx.strokeStyle= this.strokeStyle; -2552 ctx.beginPath(); -2553 ctx.strokeRect(0,0,this.width,this.height); -2554 ctx.stroke(); -2555 } -2556 } -2557 }; -2558 -2559 extend( CAAT.ShapeActor, CAAT.ActorContainer, null); -2560 })(); -2561 -2562 (function() { -2563 -2564 /** -2565 * This actor draws stars. -2566 * -2567 * @constructor -2568 * @extends CAAT.ActorContainer -2569 */ -2570 CAAT.StarActor= function() { -2571 CAAT.StarActor.superclass.constructor.call(this); -2572 this.compositeOp= 'source-over'; -2573 return this; -2574 }; -2575 -2576 CAAT.StarActor.prototype= { -2577 nPeaks: 0, -2578 maxRadius: 0, -2579 minRadius: 0, -2580 initialAngle: 0, -2581 compositeOp: null, -2582 lineWidth: 1, -2583 lineCap: null, -2584 lineJoin: null, -2585 miterLimit: null, -2586 -2587 /** -2588 * -2589 * @param l {number>0} -2590 */ -2591 setLineWidth : function(l) { -2592 this.lineWidth= l; -2593 return this; -2594 }, -2595 /** -2596 * -2597 * @param lc {string{butt|round|square}} -2598 */ -2599 setLineCap : function(lc) { -2600 this.lineCap= lc; -2601 return this; -2602 }, -2603 /** -2604 * -2605 * @param lj {string{bevel|round|miter}} -2606 */ -2607 setLineJoin : function(lj) { -2608 this.lineJoin= lj; -2609 return this; -2610 }, -2611 /** -2612 * -2613 * @param ml {integer>0} -2614 */ -2615 setMiterLimit : function(ml) { -2616 this.miterLimit= ml; -2617 return this; -2618 }, -2619 getLineCap : function() { -2620 return this.lineCap; -2621 }, -2622 getLineJoin : function() { -2623 return this.lineJoin; -2624 }, -2625 getMiterLimit : function() { -2626 return this.miterLimit; -2627 }, -2628 getLineWidth : function() { -2629 return this.lineWidth; -2630 }, -2631 /** -2632 * Sets whether the star will be color filled. -2633 * @param filled {boolean} -2634 * @deprecated -2635 */ -2636 setFilled : function( filled ) { -2637 return this; -2638 }, -2639 /** -2640 * Sets whether the star will be outlined. -2641 * @param outlined {boolean} -2642 * @deprecated -2643 */ -2644 setOutlined : function( outlined ) { -2645 return this; -2646 }, -2647 /** -2648 * Sets the composite operation to apply on shape drawing. -2649 * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. -2650 * @return this -2651 */ -2652 setCompositeOp : function(compositeOp){ -2653 this.compositeOp= compositeOp; -2654 return this; -2655 }, -2656 /** -2657 * -2658 * @param angle {number} number in radians. -2659 */ -2660 setInitialAngle : function(angle) { -2661 this.initialAngle= angle; -2662 return this; -2663 }, -2664 /** -2665 * Initialize the star values. -2666 * <p> -2667 * The star actor will be of size 2*maxRadius. -2668 * -2669 * @param nPeaks {number} number of star points. -2670 * @param maxRadius {number} maximum star radius -2671 * @param minRadius {number} minimum star radius +2382 return this; +2383 } +2384 }; +2385 +2386 extend( CAAT.TextActor, CAAT.ActorContainer, null); +2387 })(); +2388 +2389 (function() { +2390 +2391 /** +2392 * This Actor draws common shapes, concretely Circles and rectangles. +2393 * +2394 * @constructor +2395 * @extends CAAT.ActorContainer +2396 */ +2397 CAAT.ShapeActor = function() { +2398 CAAT.ShapeActor.superclass.constructor.call(this); +2399 this.compositeOp= 'source-over'; +2400 +2401 /** +2402 * Thanks Svend Dutz and Thomas Karolski for noticing this call was not performed by default, +2403 * so if no explicit call to setShape was made, nothing would be drawn. +2404 */ +2405 this.setShape( this.SHAPE_CIRCLE ); +2406 return this; +2407 }; +2408 +2409 CAAT.ShapeActor.prototype= { +2410 +2411 shape: 0, // shape type. One of the constant SHAPE_* values +2412 compositeOp: null, // a valid canvas rendering context string describing compositeOps. +2413 lineWidth: 1, +2414 lineCap: null, +2415 lineJoin: null, +2416 miterLimit: null, +2417 +2418 SHAPE_CIRCLE: 0, // Constants to describe different shapes. +2419 SHAPE_RECTANGLE:1, +2420 +2421 /** +2422 * +2423 * @param l {number>0} +2424 */ +2425 setLineWidth : function(l) { +2426 this.lineWidth= l; +2427 return this; +2428 }, +2429 /** +2430 * +2431 * @param lc {string{butt|round|square}} +2432 */ +2433 setLineCap : function(lc) { +2434 this.lineCap= lc; +2435 return this; +2436 }, +2437 /** +2438 * +2439 * @param lj {string{bevel|round|miter}} +2440 */ +2441 setLineJoin : function(lj) { +2442 this.lineJoin= lj; +2443 return this; +2444 }, +2445 /** +2446 * +2447 * @param ml {integer>0} +2448 */ +2449 setMiterLimit : function(ml) { +2450 this.miterLimit= ml; +2451 return this; +2452 }, +2453 getLineCap : function() { +2454 return this.lineCap; +2455 }, +2456 getLineJoin : function() { +2457 return this.lineJoin; +2458 }, +2459 getMiterLimit : function() { +2460 return this.miterLimit; +2461 }, +2462 getLineWidth : function() { +2463 return this.lineWidth; +2464 }, +2465 /** +2466 * Sets shape type. +2467 * No check for parameter validity is performed. +2468 * Set paint method according to the shape. +2469 * @param iShape an integer with any of the SHAPE_* constants. +2470 * @return this +2471 */ +2472 setShape : function(iShape) { +2473 this.shape= iShape; +2474 this.paint= this.shape===this.SHAPE_CIRCLE ? +2475 this.paintCircle : +2476 this.paintRectangle; +2477 return this; +2478 }, +2479 /** +2480 * Sets the composite operation to apply on shape drawing. +2481 * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. +2482 * @return this +2483 */ +2484 setCompositeOp : function(compositeOp){ +2485 this.compositeOp= compositeOp; +2486 return this; +2487 }, +2488 /** +2489 * Draws the shape. +2490 * Applies the values of fillStype, strokeStyle, compositeOp, etc. +2491 * +2492 * @param director a valid CAAT.Director instance. +2493 * @param time an integer with the Scene time the Actor is being drawn. +2494 */ +2495 paint : function(director,time) { +2496 }, +2497 /** +2498 * @private +2499 * Draws a circle. +2500 * @param director a valid CAAT.Director instance. +2501 * @param time an integer with the Scene time the Actor is being drawn. +2502 */ +2503 paintCircle : function(director,time) { +2504 var ctx= director.crc; +2505 +2506 ctx.lineWidth= this.lineWidth; +2507 +2508 ctx.globalCompositeOperation= this.compositeOp; +2509 if ( null!==this.fillStyle ) { +2510 ctx.fillStyle= this.fillStyle; +2511 ctx.beginPath(); +2512 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2, 0, 2*Math.PI, false ); +2513 ctx.fill(); +2514 } +2515 +2516 if ( null!==this.strokeStyle ) { +2517 ctx.strokeStyle= this.strokeStyle; +2518 ctx.beginPath(); +2519 ctx.arc( this.width/2, this.height/2, Math.min(this.width,this.height)/2, 0, 2*Math.PI, false ); +2520 ctx.stroke(); +2521 } +2522 }, +2523 /** +2524 * +2525 * Private +2526 * Draws a Rectangle. +2527 * +2528 * @param director a valid CAAT.Director instance. +2529 * @param time an integer with the Scene time the Actor is being drawn. +2530 */ +2531 paintRectangle : function(director,time) { +2532 var ctx= director.crc; +2533 +2534 ctx.lineWidth= this.lineWidth; +2535 +2536 if ( this.lineCap ) { +2537 ctx.lineCap= this.lineCap; +2538 } +2539 if ( this.lineJoin ) { +2540 ctx.lineJoin= this.lineJoin; +2541 } +2542 if ( this.miterLimit ) { +2543 ctx.miterLimit= this.miterLimit; +2544 } +2545 +2546 ctx.globalCompositeOperation= this.compositeOp; +2547 if ( null!==this.fillStyle ) { +2548 ctx.fillStyle= this.fillStyle; +2549 ctx.beginPath(); +2550 ctx.fillRect(0,0,this.width,this.height); +2551 ctx.fill(); +2552 } +2553 +2554 if ( null!==this.strokeStyle ) { +2555 ctx.strokeStyle= this.strokeStyle; +2556 ctx.beginPath(); +2557 ctx.strokeRect(0,0,this.width,this.height); +2558 ctx.stroke(); +2559 } +2560 } +2561 }; +2562 +2563 extend( CAAT.ShapeActor, CAAT.ActorContainer, null); +2564 })(); +2565 +2566 (function() { +2567 +2568 /** +2569 * This actor draws stars. +2570 * +2571 * @constructor +2572 * @extends CAAT.ActorContainer +2573 */ +2574 CAAT.StarActor= function() { +2575 CAAT.StarActor.superclass.constructor.call(this); +2576 this.compositeOp= 'source-over'; +2577 return this; +2578 }; +2579 +2580 CAAT.StarActor.prototype= { +2581 nPeaks: 0, +2582 maxRadius: 0, +2583 minRadius: 0, +2584 initialAngle: 0, +2585 compositeOp: null, +2586 lineWidth: 1, +2587 lineCap: null, +2588 lineJoin: null, +2589 miterLimit: null, +2590 +2591 /** +2592 * +2593 * @param l {number>0} +2594 */ +2595 setLineWidth : function(l) { +2596 this.lineWidth= l; +2597 return this; +2598 }, +2599 /** +2600 * +2601 * @param lc {string{butt|round|square}} +2602 */ +2603 setLineCap : function(lc) { +2604 this.lineCap= lc; +2605 return this; +2606 }, +2607 /** +2608 * +2609 * @param lj {string{bevel|round|miter}} +2610 */ +2611 setLineJoin : function(lj) { +2612 this.lineJoin= lj; +2613 return this; +2614 }, +2615 /** +2616 * +2617 * @param ml {integer>0} +2618 */ +2619 setMiterLimit : function(ml) { +2620 this.miterLimit= ml; +2621 return this; +2622 }, +2623 getLineCap : function() { +2624 return this.lineCap; +2625 }, +2626 getLineJoin : function() { +2627 return this.lineJoin; +2628 }, +2629 getMiterLimit : function() { +2630 return this.miterLimit; +2631 }, +2632 getLineWidth : function() { +2633 return this.lineWidth; +2634 }, +2635 /** +2636 * Sets whether the star will be color filled. +2637 * @param filled {boolean} +2638 * @deprecated +2639 */ +2640 setFilled : function( filled ) { +2641 return this; +2642 }, +2643 /** +2644 * Sets whether the star will be outlined. +2645 * @param outlined {boolean} +2646 * @deprecated +2647 */ +2648 setOutlined : function( outlined ) { +2649 return this; +2650 }, +2651 /** +2652 * Sets the composite operation to apply on shape drawing. +2653 * @param compositeOp an string with a valid canvas rendering context string describing compositeOps. +2654 * @return this +2655 */ +2656 setCompositeOp : function(compositeOp){ +2657 this.compositeOp= compositeOp; +2658 return this; +2659 }, +2660 /** +2661 * +2662 * @param angle {number} number in radians. +2663 */ +2664 setInitialAngle : function(angle) { +2665 this.initialAngle= angle; +2666 return this; +2667 }, +2668 /** +2669 * Initialize the star values. +2670 * <p> +2671 * The star actor will be of size 2*maxRadius. 2672 * -2673 * @return this -2674 */ -2675 initialize : function(nPeaks, maxRadius, minRadius) { -2676 this.setSize( 2*maxRadius, 2*maxRadius ); -2677 -2678 this.nPeaks= nPeaks; -2679 this.maxRadius= maxRadius; -2680 this.minRadius= minRadius; +2673 * @param nPeaks {number} number of star points. +2674 * @param maxRadius {number} maximum star radius +2675 * @param minRadius {number} minimum star radius +2676 * +2677 * @return this +2678 */ +2679 initialize : function(nPeaks, maxRadius, minRadius) { +2680 this.setSize( 2*maxRadius, 2*maxRadius ); 2681 -2682 return this; -2683 }, -2684 /** -2685 * Paint the star. -2686 * -2687 * @param director {CAAT.Director} -2688 * @param timer {number} -2689 */ -2690 paint : function(director, timer) { -2691 -2692 var ctx= director.ctx; -2693 var centerX= this.width/2; -2694 var centerY= this.height/2; -2695 var r1= this.maxRadius; -2696 var r2= this.minRadius; -2697 var ix= centerX + r1*Math.cos(this.initialAngle); -2698 var iy= centerY + r1*Math.sin(this.initialAngle); -2699 -2700 ctx.lineWidth= this.lineWidth; -2701 if ( this.lineCap ) { -2702 ctx.lineCap= this.lineCap; -2703 } -2704 if ( this.lineJoin ) { -2705 ctx.lineJoin= this.lineJoin; -2706 } -2707 if ( this.miterLimit ) { -2708 ctx.miterLimit= this.miterLimit; -2709 } -2710 -2711 ctx.globalCompositeOperation= this.compositeOp; -2712 -2713 ctx.beginPath(); -2714 ctx.moveTo(ix,iy); -2715 -2716 for( var i=1; i<this.nPeaks*2; i++ ) { -2717 var angleStar= Math.PI/this.nPeaks * i + this.initialAngle; -2718 var rr= (i%2===0) ? r1 : r2; -2719 var x= centerX + rr*Math.cos(angleStar); -2720 var y= centerY + rr*Math.sin(angleStar); -2721 ctx.lineTo(x,y); -2722 } -2723 -2724 ctx.lineTo( -2725 centerX + r1*Math.cos(this.initialAngle), -2726 centerY + r1*Math.sin(this.initialAngle) ); +2682 this.nPeaks= nPeaks; +2683 this.maxRadius= maxRadius; +2684 this.minRadius= minRadius; +2685 +2686 return this; +2687 }, +2688 /** +2689 * Paint the star. +2690 * +2691 * @param director {CAAT.Director} +2692 * @param timer {number} +2693 */ +2694 paint : function(director, timer) { +2695 +2696 var ctx= director.ctx; +2697 var centerX= this.width/2; +2698 var centerY= this.height/2; +2699 var r1= this.maxRadius; +2700 var r2= this.minRadius; +2701 var ix= centerX + r1*Math.cos(this.initialAngle); +2702 var iy= centerY + r1*Math.sin(this.initialAngle); +2703 +2704 ctx.lineWidth= this.lineWidth; +2705 if ( this.lineCap ) { +2706 ctx.lineCap= this.lineCap; +2707 } +2708 if ( this.lineJoin ) { +2709 ctx.lineJoin= this.lineJoin; +2710 } +2711 if ( this.miterLimit ) { +2712 ctx.miterLimit= this.miterLimit; +2713 } +2714 +2715 ctx.globalCompositeOperation= this.compositeOp; +2716 +2717 ctx.beginPath(); +2718 ctx.moveTo(ix,iy); +2719 +2720 for( var i=1; i<this.nPeaks*2; i++ ) { +2721 var angleStar= Math.PI/this.nPeaks * i + this.initialAngle; +2722 var rr= (i%2===0) ? r1 : r2; +2723 var x= centerX + rr*Math.cos(angleStar); +2724 var y= centerY + rr*Math.sin(angleStar); +2725 ctx.lineTo(x,y); +2726 } 2727 -2728 ctx.closePath(); -2729 -2730 if ( this.fillStyle ) { -2731 ctx.fillStyle= this.fillStyle; -2732 ctx.fill(); -2733 } -2734 -2735 if ( this.strokeStyle ) { -2736 ctx.strokeStyle= this.strokeStyle; -2737 ctx.stroke(); -2738 } -2739 -2740 } -2741 }; -2742 -2743 extend(CAAT.StarActor, CAAT.ActorContainer, null); -2744 -2745 })(); +2728 ctx.lineTo( +2729 centerX + r1*Math.cos(this.initialAngle), +2730 centerY + r1*Math.sin(this.initialAngle) ); +2731 +2732 ctx.closePath(); +2733 +2734 if ( this.fillStyle ) { +2735 ctx.fillStyle= this.fillStyle; +2736 ctx.fill(); +2737 } +2738 +2739 if ( this.strokeStyle ) { +2740 ctx.strokeStyle= this.strokeStyle; +2741 ctx.stroke(); +2742 } +2743 +2744 } +2745 }; 2746 -2747 /** -2748 * An actor suitable to draw an ImageProcessor instance. -2749 */ -2750 (function() { -2751 -2752 /** -2753 * This Actor will show the result of an image processing operation. -2754 * -2755 * @constructor -2756 * @extends CAAT.ActorContainer -2757 */ -2758 CAAT.IMActor= function() { -2759 CAAT.IMActor.superclass.constructor.call(this); -2760 return this; -2761 }; -2762 -2763 CAAT.IMActor.prototype= { -2764 -2765 imageProcessor: null, -2766 changeTime: 100, -2767 lastApplicationTime: -1, +2747 extend(CAAT.StarActor, CAAT.ActorContainer, null); +2748 +2749 })(); +2750 +2751 /** +2752 * An actor suitable to draw an ImageProcessor instance. +2753 */ +2754 (function() { +2755 +2756 /** +2757 * This Actor will show the result of an image processing operation. +2758 * +2759 * @constructor +2760 * @extends CAAT.ActorContainer +2761 */ +2762 CAAT.IMActor= function() { +2763 CAAT.IMActor.superclass.constructor.call(this); +2764 return this; +2765 }; +2766 +2767 CAAT.IMActor.prototype= { 2768 -2769 /** -2770 * Set the image processor. -2771 * -2772 * @param im {CAAT.ImageProcessor} a CAAT.ImageProcessor instance. -2773 */ -2774 setImageProcessor : function(im) { -2775 this.imageProcessor= im; -2776 return this; -2777 }, -2778 /** -2779 * Call image processor to update image every time milliseconds. -2780 * @param time an integer indicating milliseconds to elapse before updating the frame. -2781 */ -2782 setImageProcessingTime : function( time ) { -2783 this.changeTime= time; -2784 return this; -2785 }, -2786 paint : function( director, time ) { -2787 if ( time-this.lastApplicationTime>this.changeTime ) { -2788 this.imageProcessor.apply( director, time ); -2789 this.lastApplicationTime= time; -2790 } -2791 -2792 var ctx= director.ctx; -2793 this.imageProcessor.paint( director, time ); -2794 } -2795 }; -2796 -2797 extend( CAAT.IMActor, CAAT.ActorContainer, null); -2798 })(); \ No newline at end of file +2769 imageProcessor: null, +2770 changeTime: 100, +2771 lastApplicationTime: -1, +2772 +2773 /** +2774 * Set the image processor. +2775 * +2776 * @param im {CAAT.ImageProcessor} a CAAT.ImageProcessor instance. +2777 */ +2778 setImageProcessor : function(im) { +2779 this.imageProcessor= im; +2780 return this; +2781 }, +2782 /** +2783 * Call image processor to update image every time milliseconds. +2784 * @param time an integer indicating milliseconds to elapse before updating the frame. +2785 */ +2786 setImageProcessingTime : function( time ) { +2787 this.changeTime= time; +2788 return this; +2789 }, +2790 paint : function( director, time ) { +2791 if ( time-this.lastApplicationTime>this.changeTime ) { +2792 this.imageProcessor.apply( director, time ); +2793 this.lastApplicationTime= time; +2794 } +2795 +2796 var ctx= director.ctx; +2797 this.imageProcessor.paint( director, time ); +2798 } +2799 }; +2800 +2801 extend( CAAT.IMActor, CAAT.ActorContainer, null); +2802 })(); \ No newline at end of file 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 e5942dba..342f22a4 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 @@ -231,1597 +231,1617 @@ 224 * @param width {number} a canvas width 225 * @param height {number} a canvas height 226 * @param canvas {HTMLCanvasElement=} An optional Canvas object. -227 * -228 * @return this -229 */ -230 initialize : function(width, height, canvas) { -231 canvas = canvas || document.createElement('canvas'); -232 this.canvas = canvas; -233 -234 this.setBounds(0, 0, width, height); -235 this.create(); -236 this.enableEvents(); -237 -238 this.timeline = new Date().getTime(); +227 * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements +228 * and want events delivered to the correct element. +229 * +230 * @return this +231 */ +232 initialize : function(width, height, canvas, proxy) { +233 canvas = canvas || document.createElement('canvas'); +234 this.canvas = canvas; +235 +236 if ( typeof proxy==='undefined' ) { +237 proxy= canvas; +238 } 239 -240 // transition scene -241 this.transitionScene = new CAAT.Scene().create().setBounds(0, 0, width, height); -242 var transitionCanvas = document.createElement('canvas'); -243 transitionCanvas.width = width; -244 transitionCanvas.height = height; -245 var transitionImageActor = new CAAT.Actor().create().setBackgroundImage(transitionCanvas); -246 this.transitionScene.ctx = transitionCanvas.getContext('2d'); -247 this.transitionScene.addChildImmediately(transitionImageActor); -248 this.transitionScene.setEaseListener(this); -249 -250 this.checkDebug(); -251 -252 return this; -253 }, -254 glReset : function() { -255 this.pMatrix= makeOrtho( 0, this.referenceWidth, this.referenceHeight, 0, -1, 1 ); -256 this.gl.viewport(0,0,this.canvas.width,this.canvas.height); -257 this.glColorProgram.setMatrixUniform(this.pMatrix); -258 this.glTextureProgram.setMatrixUniform(this.pMatrix); -259 this.gl.viewportWidth = this.canvas.width; -260 this.gl.viewportHeight = this.canvas.height; -261 }, -262 /** -263 * Experimental. -264 * Initialize a gl enabled director. -265 * @param width -266 * @param height -267 * @param canvas -268 */ -269 initializeGL : function(width, height, canvas) { -270 -271 canvas = canvas || document.createElement('canvas'); -272 canvas.width = width; -273 canvas.height = height; -274 -275 this.referenceWidth= width; -276 this.referenceHeight=height; -277 -278 var i; -279 -280 try { -281 this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); -282 this.gl.viewportWidth = width; -283 this.gl.viewportHeight = height; -284 } catch(e) { -285 } -286 -287 if (this.gl) { -288 this.canvas = canvas; -289 this.create(); -290 this.setBounds(0, 0, width, height); -291 -292 this.crc = this.ctx; -293 this.enableEvents(); -294 this.timeline = new Date().getTime(); -295 -296 this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); -297 this.glTextureProgram = new CAAT.TextureProgram(this.gl).create().initialize(); -298 this.glTextureProgram.useProgram(); -299 this.glReset(); -300 +240 this.setBounds(0, 0, width, height); +241 this.create(); +242 this.enableEvents(proxy); +243 +244 this.timeline = new Date().getTime(); +245 +246 // transition scene +247 this.transitionScene = new CAAT.Scene().create().setBounds(0, 0, width, height); +248 var transitionCanvas = document.createElement('canvas'); +249 transitionCanvas.width = width; +250 transitionCanvas.height = height; +251 var transitionImageActor = new CAAT.Actor().create().setBackgroundImage(transitionCanvas); +252 this.transitionScene.ctx = transitionCanvas.getContext('2d'); +253 this.transitionScene.addChildImmediately(transitionImageActor); +254 this.transitionScene.setEaseListener(this); +255 +256 this.checkDebug(); +257 +258 return this; +259 }, +260 glReset : function() { +261 this.pMatrix= makeOrtho( 0, this.referenceWidth, this.referenceHeight, 0, -1, 1 ); +262 this.gl.viewport(0,0,this.canvas.width,this.canvas.height); +263 this.glColorProgram.setMatrixUniform(this.pMatrix); +264 this.glTextureProgram.setMatrixUniform(this.pMatrix); +265 this.gl.viewportWidth = this.canvas.width; +266 this.gl.viewportHeight = this.canvas.height; +267 }, +268 /** +269 * Experimental. +270 * Initialize a gl enabled director. +271 * @param width +272 * @param height +273 * @param canvas +274 */ +275 initializeGL : function(width, height, canvas, proxy) { +276 +277 canvas = canvas || document.createElement('canvas'); +278 canvas.width = width; +279 canvas.height = height; +280 +281 if ( typeof proxy==='undefined' ) { +282 proxy= canvas; +283 } +284 +285 this.referenceWidth= width; +286 this.referenceHeight=height; +287 +288 var i; +289 +290 try { +291 this.gl = canvas.getContext("experimental-webgl"/*, {antialias: false}*/); +292 this.gl.viewportWidth = width; +293 this.gl.viewportHeight = height; +294 } catch(e) { +295 } +296 +297 if (this.gl) { +298 this.canvas = canvas; +299 this.create(); +300 this.setBounds(0, 0, width, height); 301 -302 var maxTris = 512; -303 this.coords = new Float32Array(maxTris * 12); -304 this.uv = new Float32Array(maxTris * 8); +302 this.crc = this.ctx; +303 this.enableEvents(canvas); +304 this.timeline = new Date().getTime(); 305 -306 this.gl.clearColor(0.0, 0.0, 0.0, 255); -307 -308 if (this.front_to_back) { -309 this.gl.clearDepth(1.0); -310 this.gl.enable(this.gl.DEPTH_TEST); -311 this.gl.depthFunc(this.gl.LESS); -312 } else { -313 this.gl.disable(this.gl.DEPTH_TEST); -314 } +306 this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); +307 this.glTextureProgram = new CAAT.TextureProgram(this.gl).create().initialize(); +308 this.glTextureProgram.useProgram(); +309 this.glReset(); +310 +311 +312 var maxTris = 512; +313 this.coords = new Float32Array(maxTris * 12); +314 this.uv = new Float32Array(maxTris * 8); 315 -316 this.gl.enable(this.gl.BLEND); -317 // Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); -318 this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); -319 this.glEnabled = true; -320 -321 this.checkDebug(); -322 } else { -323 // fallback to non gl enabled canvas. -324 return this.initialize(width, height, canvas); -325 } -326 -327 return this; -328 }, -329 /** -330 * Creates an initializes a Scene object. -331 * @return {CAAT.Scene} -332 */ -333 createScene : function() { -334 var scene = new CAAT.Scene().create(); -335 this.addScene(scene); -336 return scene; -337 }, -338 setImagesCache : function(imagesCache, tpW, tpH) { -339 -340 var i; -341 -342 if (null !== this.glTextureManager) { -343 this.glTextureManager.deletePages(); -344 this.glTextureManager = null; -345 } -346 -347 // delete previous image identifiers -348 if ( this.imagesCache ) { -349 var ids= []; -350 for ( i = 0; i < this.imagesCache.length; i++) { -351 ids.push( this.imagesCache[i].id ); -352 } -353 -354 for( i=0; i<ids.length; i++ ) { -355 delete this.imagesCache[ ids[i] ]; -356 } -357 } -358 -359 this.imagesCache = imagesCache; -360 -361 if ( imagesCache ) { -362 for ( i = 0; i < imagesCache.length; i++) { -363 this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; -364 } -365 } -366 -367 this.tpW = tpW || 2048; -368 this.tpH = tpH || 2048; -369 -370 this.updateGLPages(); -371 }, -372 updateGLPages : function() { -373 if (this.glEnabled) { -374 -375 this.glTextureManager = new CAAT.GLTexturePageManager(); -376 this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); -377 -378 this.currentTexturePage = this.glTextureManager.pages[0]; -379 this.glTextureProgram.setTexture(this.currentTexturePage.texture); -380 } +316 this.gl.clearColor(0.0, 0.0, 0.0, 255); +317 +318 if (this.front_to_back) { +319 this.gl.clearDepth(1.0); +320 this.gl.enable(this.gl.DEPTH_TEST); +321 this.gl.depthFunc(this.gl.LESS); +322 } else { +323 this.gl.disable(this.gl.DEPTH_TEST); +324 } +325 +326 this.gl.enable(this.gl.BLEND); +327 // Fix FF this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA); +328 this.gl.blendFunc(this.gl.ONE, this.gl.ONE_MINUS_SRC_ALPHA); +329 this.glEnabled = true; +330 +331 this.checkDebug(); +332 } else { +333 // fallback to non gl enabled canvas. +334 return this.initialize(width, height, canvas); +335 } +336 +337 return this; +338 }, +339 /** +340 * Creates an initializes a Scene object. +341 * @return {CAAT.Scene} +342 */ +343 createScene : function() { +344 var scene = new CAAT.Scene().create(); +345 this.addScene(scene); +346 return scene; +347 }, +348 setImagesCache : function(imagesCache, tpW, tpH) { +349 +350 var i; +351 +352 if (null !== this.glTextureManager) { +353 this.glTextureManager.deletePages(); +354 this.glTextureManager = null; +355 } +356 +357 // delete previous image identifiers +358 if ( this.imagesCache ) { +359 var ids= []; +360 for ( i = 0; i < this.imagesCache.length; i++) { +361 ids.push( this.imagesCache[i].id ); +362 } +363 +364 for( i=0; i<ids.length; i++ ) { +365 delete this.imagesCache[ ids[i] ]; +366 } +367 } +368 +369 this.imagesCache = imagesCache; +370 +371 if ( imagesCache ) { +372 for ( i = 0; i < imagesCache.length; i++) { +373 this.imagesCache[ imagesCache[i].id ] = imagesCache[i].image; +374 } +375 } +376 +377 this.tpW = tpW || 2048; +378 this.tpH = tpH || 2048; +379 +380 this.updateGLPages(); 381 }, -382 setGLTexturePage : function( tp ) { -383 this.currentTexturePage = tp; -384 this.glTextureProgram.setTexture(tp.texture); -385 return this; -386 }, -387 /** -388 * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this -389 * function will try to recreate the whole GL texture pages. -390 * If many handcrafted images are to be added to the director, some performance can be achieved by calling -391 * <code>director.addImage(id,image,false)</code> many times and a final call with -392 * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages. -393 * -394 * @param id {string|object} an identitifier to retrieve the image with -395 * @param image {Image|Canvas} image to add to cache -396 * @param noUpdateGL {*boolean} unless otherwise stated, the director will -397 * try to recreate the texture pages. -398 */ -399 addImage : function( id, image, noUpdateGL ) { -400 if ( this.getImage(id) ) { -401 for (var i = 0; i < this.imagesCache.length; i++) { -402 if (this.imagesCache[i].id === id) { -403 this.imagesCache[i].image = image; -404 break; -405 } -406 } -407 this.imagesCache[ id ] = image; -408 } else { -409 this.imagesCache.push( { id: id, image: image } ); -410 this.imagesCache[id]= image; -411 } -412 -413 if ( !!!noUpdateGL ) { -414 this.updateGLPages( ); -415 } -416 }, -417 deleteImage : function( id, noUpdateGL ) { -418 for (var i = 0; i < this.imagesCache.length; i++) { -419 if (this.imagesCache[i].id === id) { -420 delete this.imagesCache[id]; -421 this.imagesCache.splice(i,1); -422 break; -423 } -424 } -425 if ( !!!noUpdateGL ) { -426 this.updateGLPages(); -427 } -428 }, -429 setGLCurrentOpacity : function(opacity) { -430 this.currentOpacity = opacity; -431 this.glTextureProgram.setAlpha(opacity); -432 }, -433 /** -434 * Render buffered elements. -435 * @param vertex -436 * @param coordsIndex -437 * @param uv -438 */ -439 glRender : function(vertex, coordsIndex, uv) { -440 -441 vertex = vertex || this.coords; -442 uv = uv || this.uv; -443 coordsIndex = coordsIndex || this.coordsIndex; -444 -445 var gl = this.gl; -446 -447 var numTris = coordsIndex / 12 * 2; -448 var numVertices = coordsIndex / 3; -449 -450 this.glTextureProgram.updateVertexBuffer(vertex); -451 this.glTextureProgram.updateUVBuffer(uv); -452 -453 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); +382 updateGLPages : function() { +383 if (this.glEnabled) { +384 +385 this.glTextureManager = new CAAT.GLTexturePageManager(); +386 this.glTextureManager.createPages(this.gl, this.tpW, this.tpH, this.imagesCache); +387 +388 this.currentTexturePage = this.glTextureManager.pages[0]; +389 this.glTextureProgram.setTexture(this.currentTexturePage.texture); +390 } +391 }, +392 setGLTexturePage : function( tp ) { +393 this.currentTexturePage = tp; +394 this.glTextureProgram.setTexture(tp.texture); +395 return this; +396 }, +397 /** +398 * Add a new image to director's image cache. If gl is enabled and the 'noUpdateGL' is not set to true this +399 * function will try to recreate the whole GL texture pages. +400 * If many handcrafted images are to be added to the director, some performance can be achieved by calling +401 * <code>director.addImage(id,image,false)</code> many times and a final call with +402 * <code>director.addImage(id,image,true)</code> to finally command the director to create texture pages. +403 * +404 * @param id {string|object} an identitifier to retrieve the image with +405 * @param image {Image|Canvas} image to add to cache +406 * @param noUpdateGL {*boolean} unless otherwise stated, the director will +407 * try to recreate the texture pages. +408 */ +409 addImage : function( id, image, noUpdateGL ) { +410 if ( this.getImage(id) ) { +411 for (var i = 0; i < this.imagesCache.length; i++) { +412 if (this.imagesCache[i].id === id) { +413 this.imagesCache[i].image = image; +414 break; +415 } +416 } +417 this.imagesCache[ id ] = image; +418 } else { +419 this.imagesCache.push( { id: id, image: image } ); +420 this.imagesCache[id]= image; +421 } +422 +423 if ( !!!noUpdateGL ) { +424 this.updateGLPages( ); +425 } +426 }, +427 deleteImage : function( id, noUpdateGL ) { +428 for (var i = 0; i < this.imagesCache.length; i++) { +429 if (this.imagesCache[i].id === id) { +430 delete this.imagesCache[id]; +431 this.imagesCache.splice(i,1); +432 break; +433 } +434 } +435 if ( !!!noUpdateGL ) { +436 this.updateGLPages(); +437 } +438 }, +439 setGLCurrentOpacity : function(opacity) { +440 this.currentOpacity = opacity; +441 this.glTextureProgram.setAlpha(opacity); +442 }, +443 /** +444 * Render buffered elements. +445 * @param vertex +446 * @param coordsIndex +447 * @param uv +448 */ +449 glRender : function(vertex, coordsIndex, uv) { +450 +451 vertex = vertex || this.coords; +452 uv = uv || this.uv; +453 coordsIndex = coordsIndex || this.coordsIndex; 454 -455 }, -456 glFlush : function() { -457 if (this.coordsIndex !== 0) { -458 this.glRender(this.coords, this.coordsIndex, this.uv); -459 } -460 this.coordsIndex = 0; -461 this.uvIndex = 0; +455 var gl = this.gl; +456 +457 var numTris = coordsIndex / 12 * 2; +458 var numVertices = coordsIndex / 3; +459 +460 this.glTextureProgram.updateVertexBuffer(vertex); +461 this.glTextureProgram.updateUVBuffer(uv); 462 -463 this.statistics.draws++; -464 }, -465 -466 findActorAtPosition : function(point) { -467 -468 // z-order -469 var cl= this.childrenList; -470 for( var i=cl.length-1; i>=0; i-- ) { -471 var child= this.childrenList[i]; +463 gl.drawElements(gl.TRIANGLES, 3 * numTris, gl.UNSIGNED_SHORT, 0); +464 +465 }, +466 glFlush : function() { +467 if (this.coordsIndex !== 0) { +468 this.glRender(this.coords, this.coordsIndex, this.uv); +469 } +470 this.coordsIndex = 0; +471 this.uvIndex = 0; 472 -473 var np= new CAAT.Point( point.x, point.y, 0 ); -474 var contained= child.findActorAtPosition( np ); -475 if ( null!==contained ) { -476 return contained; -477 } -478 } -479 -480 return this; -481 }, +473 this.statistics.draws++; +474 }, +475 +476 findActorAtPosition : function(point) { +477 +478 // z-order +479 var cl= this.childrenList; +480 for( var i=cl.length-1; i>=0; i-- ) { +481 var child= this.childrenList[i]; 482 -483 -484 resetStats : function() { -485 this.statistics.size_total= 0; -486 this.statistics.size_active=0; -487 this.statistics.draws= 0; -488 }, +483 var np= new CAAT.Point( point.x, point.y, 0 ); +484 var contained= child.findActorAtPosition( np ); +485 if ( null!==contained ) { +486 return contained; +487 } +488 } 489 -490 /** -491 * This is the entry point for the animation system of the Director. -492 * The director is fed with the elapsed time value to maintain a virtual timeline. -493 * This virtual timeline will provide each Scene with its own virtual timeline, and will only -494 * feed time when the Scene is the current Scene, or is being switched. -495 * -496 * @param time {number} integer indicating the elapsed time between two consecutive frames of the -497 * Director. -498 */ -499 render : function(time) { -500 -501 this.time += time; -502 -503 this.animate(this,time); -504 -505 if ( CAAT.DEBUG ) { -506 this.resetStats(); -507 } -508 -509 /** -510 * draw director active scenes. -511 */ -512 var ne = this.childrenList.length; -513 var i, tt; -514 if (this.glEnabled) { -515 -516 this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); -517 this.coordsIndex = 0; -518 this.uvIndex = 0; -519 -520 for (i = 0; i < ne; i++) { -521 var c = this.childrenList[i]; -522 if (c.isInAnimationFrame(this.time)) { -523 tt = c.time - c.start_time; -524 if ( c.onRenderStart ) { -525 c.onRenderStart(tt); -526 } -527 c.paintActorGL(this, tt); -528 if ( c.onRenderEnd ) { -529 c.onRenderEnd(tt); -530 } -531 -532 if ( !c.isPaused() ) { -533 c.time += time; -534 } -535 -536 if ( CAAT.DEBUG ) { -537 this.statistics.size_total+= c.size_total; -538 this.statistics.size_active+= c.size_active; -539 } -540 -541 } -542 } -543 -544 this.glFlush(); +490 return this; +491 }, +492 +493 +494 resetStats : function() { +495 this.statistics.size_total= 0; +496 this.statistics.size_active=0; +497 this.statistics.draws= 0; +498 }, +499 +500 /** +501 * This is the entry point for the animation system of the Director. +502 * The director is fed with the elapsed time value to maintain a virtual timeline. +503 * This virtual timeline will provide each Scene with its own virtual timeline, and will only +504 * feed time when the Scene is the current Scene, or is being switched. +505 * +506 * @param time {number} integer indicating the elapsed time between two consecutive frames of the +507 * Director. +508 */ +509 render : function(time) { +510 +511 this.time += time; +512 +513 this.animate(this,time); +514 +515 if ( CAAT.DEBUG ) { +516 this.resetStats(); +517 } +518 +519 /** +520 * draw director active scenes. +521 */ +522 var ne = this.childrenList.length; +523 var i, tt; +524 if (this.glEnabled) { +525 +526 this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT); +527 this.coordsIndex = 0; +528 this.uvIndex = 0; +529 +530 for (i = 0; i < ne; i++) { +531 var c = this.childrenList[i]; +532 if (c.isInAnimationFrame(this.time)) { +533 tt = c.time - c.start_time; +534 if ( c.onRenderStart ) { +535 c.onRenderStart(tt); +536 } +537 c.paintActorGL(this, tt); +538 if ( c.onRenderEnd ) { +539 c.onRenderEnd(tt); +540 } +541 +542 if ( !c.isPaused() ) { +543 c.time += time; +544 } 545 -546 } else { -547 this.ctx.globalAlpha = 1; -548 this.ctx.globalCompositeOperation = 'source-over'; -549 -550 if (this.clear) { -551 this.ctx.clearRect(0, 0, this.width, this.height); +546 if ( CAAT.DEBUG ) { +547 this.statistics.size_total+= c.size_total; +548 this.statistics.size_active+= c.size_active; +549 } +550 +551 } 552 } 553 -554 for (i = 0; i < ne; i++) { -555 var c= this.childrenList[i]; -556 -557 if (c.isInAnimationFrame(this.time)) { -558 tt = c.time - c.start_time; -559 this.ctx.save(); -560 -561 if ( c.onRenderStart ) { -562 c.onRenderStart(tt); -563 } -564 c.paintActor(this, tt); -565 if ( c.onRenderEnd ) { -566 c.onRenderEnd(tt); -567 } -568 this.ctx.restore(); -569 if (CAAT.DEBUGBB) { -570 this.ctx.strokeStyle = CAAT.DEBUGBBCOLOR; -571 c.drawScreenBoundingBox(this, tt); -572 } -573 -574 if ( !c.isPaused() ) { -575 c.time += time; -576 } -577 -578 if ( CAAT.DEBUG ) { -579 this.statistics.size_total+= c.size_total; -580 this.statistics.size_active+= c.size_active; -581 } -582 -583 } -584 } -585 } -586 -587 this.frameCounter++; -588 }, -589 /** -590 * A director is a very special kind of actor. -591 * Its animation routine simple sets its modelViewMatrix in case some transformation's been -592 * applied. -593 * No behaviors are allowed for Director instances. -594 * @param director {CAAT.Director} redundant reference to CAAT.Director itself -595 * @param time {number} director time. -596 */ -597 animate : function(director, time) { -598 this.setModelViewMatrix(this.glEnabled); -599 -600 var cl= this.childrenList; -601 var cli; -602 for (var i = 0; i < cl.length; i++) { -603 cli= cl[i]; -604 var tt = cli.time - cli.start_time; -605 cli.animate(this, tt); -606 } -607 -608 return this; -609 }, -610 /** -611 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of -612 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from -613 * one to another, first of all an scene is drawn to offscreen, and that image is translated. -614 * <p> -615 * Until the creation of this method, both scenes where drawn while transitioning with -616 * its performance penalty since drawing two scenes could be twice as expensive than drawing -617 * only one. -618 * <p> -619 * Though a high performance increase, we should keep an eye on memory consumption. -620 * -621 * @param ctx a <code>canvas.getContext('2d')</code> instnce. -622 * @param scene {CAAT.Scene} the scene to draw offscreen. -623 */ -624 renderToContext : function(ctx, scene) { -625 /** -626 * draw actors on scene. -627 */ -628 if (scene.isInAnimationFrame(this.time)) { -629 ctx.globalAlpha = 1; -630 ctx.globalCompositeOperation = 'source-over'; -631 ctx.clearRect(0, 0, this.width, this.height); -632 ctx.setTransform(1,0,0, 0,1,0); -633 -634 var octx = this.ctx; -635 var ocrc = this.crc; -636 -637 this.ctx = this.crc = ctx; -638 ctx.save(); -639 -640 /** -641 * to draw an scene to an offscreen canvas, we have to: -642 * 1.- save diector's world model view matrix -643 * 2.- set no transformation on director since we want the offscreen to -644 * be drawn 1:1. -645 * 3.- set world dirty flag, so that the scene will recalculate its matrices -646 * 4.- animate the scene -647 * 5.- paint the scene -648 * 6.- restore world model view matrix. -649 */ -650 var matwmv= this.worldModelViewMatrix; -651 this.worldModelViewMatrix= new CAAT.Matrix(); -652 this.wdirty= true; -653 scene.animate(this, scene.time); -654 if ( scene.onRenderStart ) { -655 scene.onRenderStart(scene.time); -656 } -657 scene.paintActor(this, scene.time); -658 if ( scene.onRenderEnd ) { -659 scene.onRenderEnd(scene.time); -660 } -661 this.worldModelViewMatrix = matwmv; -662 -663 ctx.restore(); -664 -665 this.ctx = octx; -666 this.crc = ocrc; -667 } -668 }, -669 /** -670 * Add a new Scene to Director's Scene list. By adding a Scene to the Director -671 * does not mean it will be immediately visible, you should explicitly call either -672 * <ul> -673 * <li>easeIn -674 * <li>easeInOut -675 * <li>easeInOutRandom -676 * <li>setScene -677 * <li>or any of the scene switching methods -678 * </ul> -679 * -680 * @param scene {CAAT.Scene} an CAAT.Scene object. -681 */ -682 addScene : function(scene) { -683 scene.setBounds(0, 0, this.width, this.height); -684 this.scenes.push(scene); -685 scene.setEaseListener(this); -686 if (null === this.currentScene) { -687 this.setScene(0); -688 } -689 }, -690 /** -691 * Get the number of scenes contained in the Director. -692 * @return {number} the number of scenes contained in the Director. -693 */ -694 getNumScenes : function() { -695 return this.scenes.length; -696 }, -697 /** -698 * This method offers full control over the process of switching between any given two Scenes. -699 * To apply this method, you must specify the type of transition to apply for each Scene and -700 * the anchor to keep the Scene pinned at. -701 * <p> -702 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: -703 * <ul> -704 * <li>EASE_ROTATION -705 * <li>EASE_SCALE -706 * <li>EASE_TRANSLATION -707 * </ul> -708 * -709 * <p> -710 * The anchor will be any of these values defined in CAAT.Actor.prototype: -711 * <ul> -712 * <li>ANCHOR_CENTER -713 * <li>ANCHOR_TOP -714 * <li>ANCHOR_BOTTOM -715 * <li>ANCHOR_LEFT -716 * <li>ANCHOR_RIGHT -717 * <li>ANCHOR_TOP_LEFT -718 * <li>ANCHOR_TOP_RIGHT -719 * <li>ANCHOR_BOTTOM_LEFT -720 * <li>ANCHOR_BOTTOM_RIGHT -721 * </ul> -722 * -723 * <p> -724 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the -725 * point by which the scene will scaled. -726 * -727 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. -728 * @param typein integer indicating the type of transition to apply to the bringing in Scene. -729 * @param anchorin integer indicating the anchor of the bringing in Scene. -730 * @param outSceneIndex integer indicating the Scene index to take away from the Director. -731 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. -732 * @param anchorout integer indicating the anchor of the taking away Scene. -733 * @param time inteter indicating the time to perform the process of switchihg between Scene object -734 * in milliseconds. -735 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to -736 * the scenes. -737 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. -738 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. -739 */ -740 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { -741 -742 if (inSceneIndex === this.getCurrentSceneIndex()) { -743 return; -744 } -745 -746 var ssin = this.scenes[ inSceneIndex ]; -747 var sout = this.scenes[ outSceneIndex ]; -748 -749 if (!this.glEnabled && !navigator.browser==='iOS') { -750 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); -751 this.renderToContext(this.transitionScene.ctx, sout); -752 sout = this.transitionScene; -753 } -754 -755 ssin.setExpired(false); -756 sout.setExpired(false); -757 -758 ssin.mouseEnabled = false; -759 sout.mouseEnabled = false; -760 -761 ssin.resetTransform(); -762 sout.resetTransform(); -763 -764 ssin.setLocation(0, 0); -765 sout.setLocation(0, 0); -766 -767 ssin.alpha = 1; -768 sout.alpha = 1; -769 -770 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { -771 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); -772 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { -773 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); -774 } else { -775 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); -776 } -777 -778 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { -779 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); -780 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { -781 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); -782 } else { -783 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); -784 } -785 -786 this.childrenList = []; +554 this.glFlush(); +555 +556 } else { +557 this.ctx.globalAlpha = 1; +558 this.ctx.globalCompositeOperation = 'source-over'; +559 +560 if (this.clear) { +561 this.ctx.clearRect(0, 0, this.width, this.height); +562 } +563 +564 for (i = 0; i < ne; i++) { +565 var c= this.childrenList[i]; +566 +567 if (c.isInAnimationFrame(this.time)) { +568 tt = c.time - c.start_time; +569 this.ctx.save(); +570 +571 if ( c.onRenderStart ) { +572 c.onRenderStart(tt); +573 } +574 c.paintActor(this, tt); +575 if ( c.onRenderEnd ) { +576 c.onRenderEnd(tt); +577 } +578 this.ctx.restore(); +579 if (CAAT.DEBUGBB) { +580 this.ctx.strokeStyle = CAAT.DEBUGBBCOLOR; +581 c.drawScreenBoundingBox(this, tt); +582 } +583 +584 if ( !c.isPaused() ) { +585 c.time += time; +586 } +587 +588 if ( CAAT.DEBUG ) { +589 this.statistics.size_total+= c.size_total; +590 this.statistics.size_active+= c.size_active; +591 } +592 +593 } +594 } +595 } +596 +597 this.frameCounter++; +598 }, +599 /** +600 * A director is a very special kind of actor. +601 * Its animation routine simple sets its modelViewMatrix in case some transformation's been +602 * applied. +603 * No behaviors are allowed for Director instances. +604 * @param director {CAAT.Director} redundant reference to CAAT.Director itself +605 * @param time {number} director time. +606 */ +607 animate : function(director, time) { +608 this.setModelViewMatrix(this.glEnabled); +609 +610 var cl= this.childrenList; +611 var cli; +612 for (var i = 0; i < cl.length; i++) { +613 cli= cl[i]; +614 var tt = cli.time - cli.start_time; +615 cli.animate(this, tt); +616 } +617 +618 return this; +619 }, +620 /** +621 * This method draws an Scene to an offscreen canvas. This offscreen canvas is also a child of +622 * another Scene (transitionScene). So instead of drawing two scenes while transitioning from +623 * one to another, first of all an scene is drawn to offscreen, and that image is translated. +624 * <p> +625 * Until the creation of this method, both scenes where drawn while transitioning with +626 * its performance penalty since drawing two scenes could be twice as expensive than drawing +627 * only one. +628 * <p> +629 * Though a high performance increase, we should keep an eye on memory consumption. +630 * +631 * @param ctx a <code>canvas.getContext('2d')</code> instnce. +632 * @param scene {CAAT.Scene} the scene to draw offscreen. +633 */ +634 renderToContext : function(ctx, scene) { +635 /** +636 * draw actors on scene. +637 */ +638 if (scene.isInAnimationFrame(this.time)) { +639 ctx.globalAlpha = 1; +640 ctx.globalCompositeOperation = 'source-over'; +641 ctx.clearRect(0, 0, this.width, this.height); +642 ctx.setTransform(1,0,0, 0,1,0); +643 +644 var octx = this.ctx; +645 var ocrc = this.crc; +646 +647 this.ctx = this.crc = ctx; +648 ctx.save(); +649 +650 /** +651 * to draw an scene to an offscreen canvas, we have to: +652 * 1.- save diector's world model view matrix +653 * 2.- set no transformation on director since we want the offscreen to +654 * be drawn 1:1. +655 * 3.- set world dirty flag, so that the scene will recalculate its matrices +656 * 4.- animate the scene +657 * 5.- paint the scene +658 * 6.- restore world model view matrix. +659 */ +660 var matwmv= this.worldModelViewMatrix; +661 this.worldModelViewMatrix= new CAAT.Matrix(); +662 this.wdirty= true; +663 scene.animate(this, scene.time); +664 if ( scene.onRenderStart ) { +665 scene.onRenderStart(scene.time); +666 } +667 scene.paintActor(this, scene.time); +668 if ( scene.onRenderEnd ) { +669 scene.onRenderEnd(scene.time); +670 } +671 this.worldModelViewMatrix = matwmv; +672 +673 ctx.restore(); +674 +675 this.ctx = octx; +676 this.crc = ocrc; +677 } +678 }, +679 /** +680 * Add a new Scene to Director's Scene list. By adding a Scene to the Director +681 * does not mean it will be immediately visible, you should explicitly call either +682 * <ul> +683 * <li>easeIn +684 * <li>easeInOut +685 * <li>easeInOutRandom +686 * <li>setScene +687 * <li>or any of the scene switching methods +688 * </ul> +689 * +690 * @param scene {CAAT.Scene} an CAAT.Scene object. +691 */ +692 addScene : function(scene) { +693 scene.setBounds(0, 0, this.width, this.height); +694 this.scenes.push(scene); +695 scene.setEaseListener(this); +696 if (null === this.currentScene) { +697 this.setScene(0); +698 } +699 }, +700 /** +701 * Get the number of scenes contained in the Director. +702 * @return {number} the number of scenes contained in the Director. +703 */ +704 getNumScenes : function() { +705 return this.scenes.length; +706 }, +707 /** +708 * This method offers full control over the process of switching between any given two Scenes. +709 * To apply this method, you must specify the type of transition to apply for each Scene and +710 * the anchor to keep the Scene pinned at. +711 * <p> +712 * The type of transition will be one of the following values defined in CAAT.Scene.prototype: +713 * <ul> +714 * <li>EASE_ROTATION +715 * <li>EASE_SCALE +716 * <li>EASE_TRANSLATION +717 * </ul> +718 * +719 * <p> +720 * The anchor will be any of these values defined in CAAT.Actor.prototype: +721 * <ul> +722 * <li>ANCHOR_CENTER +723 * <li>ANCHOR_TOP +724 * <li>ANCHOR_BOTTOM +725 * <li>ANCHOR_LEFT +726 * <li>ANCHOR_RIGHT +727 * <li>ANCHOR_TOP_LEFT +728 * <li>ANCHOR_TOP_RIGHT +729 * <li>ANCHOR_BOTTOM_LEFT +730 * <li>ANCHOR_BOTTOM_RIGHT +731 * </ul> +732 * +733 * <p> +734 * In example, for an entering scene performing a EASE_SCALE transition, the anchor is the +735 * point by which the scene will scaled. +736 * +737 * @param inSceneIndex integer indicating the Scene index to bring in to the Director. +738 * @param typein integer indicating the type of transition to apply to the bringing in Scene. +739 * @param anchorin integer indicating the anchor of the bringing in Scene. +740 * @param outSceneIndex integer indicating the Scene index to take away from the Director. +741 * @param typeout integer indicating the type of transition to apply to the taking away in Scene. +742 * @param anchorout integer indicating the anchor of the taking away Scene. +743 * @param time inteter indicating the time to perform the process of switchihg between Scene object +744 * in milliseconds. +745 * @param alpha boolean boolean indicating whether alpha transparency fading will be applied to +746 * the scenes. +747 * @param interpolatorIn CAAT.Interpolator object to apply to entering scene. +748 * @param interpolatorOut CAAT.Interpolator object to apply to exiting scene. +749 */ +750 easeInOut : function(inSceneIndex, typein, anchorin, outSceneIndex, typeout, anchorout, time, alpha, interpolatorIn, interpolatorOut) { +751 +752 if (inSceneIndex === this.getCurrentSceneIndex()) { +753 return; +754 } +755 +756 var ssin = this.scenes[ inSceneIndex ]; +757 var sout = this.scenes[ outSceneIndex ]; +758 +759 if (!this.glEnabled && !navigator.browser==='iOS') { +760 this.worldModelViewMatrix.transformRenderingContext(this.transitionScene.ctx); +761 this.renderToContext(this.transitionScene.ctx, sout); +762 sout = this.transitionScene; +763 } +764 +765 ssin.setExpired(false); +766 sout.setExpired(false); +767 +768 ssin.mouseEnabled = false; +769 sout.mouseEnabled = false; +770 +771 ssin.resetTransform(); +772 sout.resetTransform(); +773 +774 ssin.setLocation(0, 0); +775 sout.setLocation(0, 0); +776 +777 ssin.alpha = 1; +778 sout.alpha = 1; +779 +780 if (typein === CAAT.Scene.prototype.EASE_ROTATION) { +781 ssin.easeRotationIn(time, alpha, anchorin, interpolatorIn); +782 } else if (typein === CAAT.Scene.prototype.EASE_SCALE) { +783 ssin.easeScaleIn(0, time, alpha, anchorin, interpolatorIn); +784 } else { +785 ssin.easeTranslationIn(time, alpha, anchorin, interpolatorIn); +786 } 787 -788 this.addChild(sout); -789 this.addChild(ssin); -790 }, -791 /** -792 * This method will switch between two given Scene indexes (ie, take away scene number 2, -793 * and bring in scene number 5). -794 * <p> -795 * It will randomly choose for each Scene the type of transition to apply and the anchor -796 * point of each transition type. -797 * <p> -798 * It will also set for different kind of transitions the following interpolators: -799 * <ul> -800 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. -801 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 -802 * <li>EASE_TRANSLATION -> BounceOutInterpolator -803 * </ul> -804 * -805 * <p> -806 * These are the default values, and could not be changed by now. -807 * This method in final instance delegates the process to easeInOutMethod. -808 * -809 * @see easeInOutMethod. -810 * -811 * @param inIndex integer indicating the entering scene index. -812 * @param outIndex integer indicating the exiting scene index. -813 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. -814 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. -815 */ -816 easeInOutRandom : function(inIndex, outIndex, time, alpha) { -817 -818 var pin = Math.random(); -819 var pout = Math.random(); -820 -821 var typeIn; -822 var interpolatorIn; -823 -824 if (pin < 0.33) { -825 typeIn = CAAT.Scene.prototype.EASE_ROTATION; -826 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -827 } else if (pin < 0.66) { -828 typeIn = CAAT.Scene.prototype.EASE_SCALE; -829 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); -830 } else { -831 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; -832 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); -833 } -834 -835 var typeOut; -836 var interpolatorOut; -837 -838 if (pout < 0.33) { -839 typeOut = CAAT.Scene.prototype.EASE_ROTATION; -840 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); -841 } else if (pout < 0.66) { -842 typeOut = CAAT.Scene.prototype.EASE_SCALE; -843 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); -844 } else { -845 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; -846 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); -847 } -848 -849 this.easeInOut( -850 inIndex, -851 typeIn, -852 (Math.random() * 8.99) >> 0, -853 -854 outIndex, -855 typeOut, -856 (Math.random() * 8.99) >> 0, -857 -858 time, -859 alpha, -860 -861 interpolatorIn, -862 interpolatorOut); +788 if (typeout === CAAT.Scene.prototype.EASE_ROTATION) { +789 sout.easeRotationOut(time, alpha, anchorout, interpolatorOut); +790 } else if (typeout === CAAT.Scene.prototype.EASE_SCALE) { +791 sout.easeScaleOut(0, time, alpha, anchorout, interpolatorOut); +792 } else { +793 sout.easeTranslationOut(time, alpha, anchorout, interpolatorOut); +794 } +795 +796 this.childrenList = []; +797 +798 this.addChild(sout); +799 this.addChild(ssin); +800 }, +801 /** +802 * This method will switch between two given Scene indexes (ie, take away scene number 2, +803 * and bring in scene number 5). +804 * <p> +805 * It will randomly choose for each Scene the type of transition to apply and the anchor +806 * point of each transition type. +807 * <p> +808 * It will also set for different kind of transitions the following interpolators: +809 * <ul> +810 * <li>EASE_ROTATION -> ExponentialInOutInterpolator, exponent 4. +811 * <li>EASE_SCALE -> ElasticOutInterpolator, 1.1 and .4 +812 * <li>EASE_TRANSLATION -> BounceOutInterpolator +813 * </ul> +814 * +815 * <p> +816 * These are the default values, and could not be changed by now. +817 * This method in final instance delegates the process to easeInOutMethod. +818 * +819 * @see easeInOutMethod. +820 * +821 * @param inIndex integer indicating the entering scene index. +822 * @param outIndex integer indicating the exiting scene index. +823 * @param time integer indicating the time to take for the process of Scene in/out in milliseconds. +824 * @param alpha boolean indicating whether alpha transparency fading should be applied to transitions. +825 */ +826 easeInOutRandom : function(inIndex, outIndex, time, alpha) { +827 +828 var pin = Math.random(); +829 var pout = Math.random(); +830 +831 var typeIn; +832 var interpolatorIn; +833 +834 if (pin < 0.33) { +835 typeIn = CAAT.Scene.prototype.EASE_ROTATION; +836 interpolatorIn = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +837 } else if (pin < 0.66) { +838 typeIn = CAAT.Scene.prototype.EASE_SCALE; +839 interpolatorIn = new CAAT.Interpolator().createElasticOutInterpolator(1.1, 0.4); +840 } else { +841 typeIn = CAAT.Scene.prototype.EASE_TRANSLATE; +842 interpolatorIn = new CAAT.Interpolator().createBounceOutInterpolator(); +843 } +844 +845 var typeOut; +846 var interpolatorOut; +847 +848 if (pout < 0.33) { +849 typeOut = CAAT.Scene.prototype.EASE_ROTATION; +850 interpolatorOut = new CAAT.Interpolator().createExponentialInOutInterpolator(4); +851 } else if (pout < 0.66) { +852 typeOut = CAAT.Scene.prototype.EASE_SCALE; +853 interpolatorOut = new CAAT.Interpolator().createExponentialOutInterpolator(4); +854 } else { +855 typeOut = CAAT.Scene.prototype.EASE_TRANSLATE; +856 interpolatorOut = new CAAT.Interpolator().createBounceOutInterpolator(); +857 } +858 +859 this.easeInOut( +860 inIndex, +861 typeIn, +862 (Math.random() * 8.99) >> 0, 863 -864 }, -865 /** -866 * This method changes Director's current Scene to the scene index indicated by -867 * inSceneIndex parameter. The Scene running in the director won't be eased out. -868 * -869 * @see {CAAT.Interpolator} -870 * @see {CAAT.Actor} -871 * @see {CAAT.Scene} -872 * -873 * @param inSceneIndex integer indicating the new Scene to set as current. -874 * @param type integer indicating the type of transition to apply to bring the new current -875 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, -876 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. -877 * @param time integer indicating how much time in milliseconds the Scene entrance will take. -878 * @param alpha boolean indicating whether alpha transparency fading will be applied to the -879 * entereing Scene. -880 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of -881 * CAAT.Actor.prototype.ANCHOR_* values. -882 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to -883 * apply. -884 */ -885 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { -886 var sin = this.scenes[ inSceneIndex ]; -887 if (type === CAAT.Scene.prototype.EASE_ROTATION) { -888 sin.easeRotationIn(time, alpha, anchor, interpolator); -889 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { -890 sin.easeScaleIn(0, time, alpha, anchor, interpolator); -891 } else { -892 sin.easeTranslationIn(time, alpha, anchor, interpolator); -893 } -894 this.childrenList = []; -895 this.addChild(sin); -896 -897 sin.resetTransform(); -898 sin.setLocation(0, 0); -899 sin.alpha = 1; -900 sin.mouseEnabled = false; -901 sin.setExpired(false); -902 }, -903 /** -904 * Changes (or sets) the current Director scene to the index -905 * parameter. There will be no transition on scene change. -906 * @param sceneIndex {number} an integer indicating the index of the target Scene -907 * to be shown. -908 */ -909 setScene : function(sceneIndex) { -910 var sin = this.scenes[ sceneIndex ]; -911 this.childrenList = []; -912 this.addChild(sin); -913 this.currentScene = sin; -914 -915 sin.setExpired(false); -916 sin.mouseEnabled = true; -917 sin.resetTransform(); -918 sin.setLocation(0, 0); -919 sin.alpha = 1; -920 -921 sin.activated(); -922 }, -923 /** -924 * This method will change the current Scene by the Scene indicated as parameter. -925 * It will apply random values for anchor and transition type. -926 * @see easeInOutRandom -927 * -928 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. -929 * @param time {number} an integer indicating the time the Scene transition will take. -930 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -931 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -932 */ -933 switchToScene : function(iNewSceneIndex, time, alpha, transition) { -934 var currentSceneIndex = this.getSceneIndex(this.currentScene); -935 -936 if (!transition) { -937 this.setScene(iNewSceneIndex); -938 } -939 else { -940 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); -941 } -942 }, -943 /** -944 * Sets the previous Scene in sequence as the current Scene. -945 * @see switchToScene. -946 * -947 * @param time {number} integer indicating the time the Scene transition will take. -948 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -949 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -950 */ -951 switchToPrevScene : function(time, alpha, transition) { -952 -953 var currentSceneIndex = this.getSceneIndex(this.currentScene); -954 -955 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { -956 return; -957 } -958 -959 if (!transition) { -960 this.setScene(currentSceneIndex - 1); -961 } -962 else { -963 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); -964 } -965 }, -966 /** -967 * Sets the previous Scene in sequence as the current Scene. -968 * @see switchToScene. -969 * -970 * @param time {number} integer indicating the time the Scene transition will take. -971 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. -972 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. -973 */ -974 switchToNextScene: function(time, alpha, transition) { -975 -976 var currentSceneIndex = this.getSceneIndex(this.currentScene); -977 -978 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { -979 return; -980 } -981 -982 if (!transition) { -983 this.setScene(currentSceneIndex + 1); -984 } -985 else { -986 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); -987 } -988 }, -989 mouseEnter : function(mouseEvent) { -990 }, -991 mouseExit : function(mouseEvent) { -992 }, -993 mouseMove : function(mouseEvent) { -994 }, -995 mouseDown : function(mouseEvent) { -996 }, -997 mouseUp : function(mouseEvent) { +864 outIndex, +865 typeOut, +866 (Math.random() * 8.99) >> 0, +867 +868 time, +869 alpha, +870 +871 interpolatorIn, +872 interpolatorOut); +873 +874 }, +875 /** +876 * This method changes Director's current Scene to the scene index indicated by +877 * inSceneIndex parameter. The Scene running in the director won't be eased out. +878 * +879 * @see {CAAT.Interpolator} +880 * @see {CAAT.Actor} +881 * @see {CAAT.Scene} +882 * +883 * @param inSceneIndex integer indicating the new Scene to set as current. +884 * @param type integer indicating the type of transition to apply to bring the new current +885 * Scene to the Director. The values will be one of: CAAT.Scene.prototype.EASE_ROTATION, +886 * CAAT.Scene.prototype.EASE_SCALE, CAAT.Scene.prototype.EASE_TRANSLATION. +887 * @param time integer indicating how much time in milliseconds the Scene entrance will take. +888 * @param alpha boolean indicating whether alpha transparency fading will be applied to the +889 * entereing Scene. +890 * @param anchor integer indicating the anchor to fix for Scene transition. It will be any of +891 * CAAT.Actor.prototype.ANCHOR_* values. +892 * @param interpolator an CAAT.Interpolator object indicating the interpolation function to +893 * apply. +894 */ +895 easeIn : function(inSceneIndex, type, time, alpha, anchor, interpolator) { +896 var sin = this.scenes[ inSceneIndex ]; +897 if (type === CAAT.Scene.prototype.EASE_ROTATION) { +898 sin.easeRotationIn(time, alpha, anchor, interpolator); +899 } else if (type === CAAT.Scene.prototype.EASE_SCALE) { +900 sin.easeScaleIn(0, time, alpha, anchor, interpolator); +901 } else { +902 sin.easeTranslationIn(time, alpha, anchor, interpolator); +903 } +904 this.childrenList = []; +905 this.addChild(sin); +906 +907 sin.resetTransform(); +908 sin.setLocation(0, 0); +909 sin.alpha = 1; +910 sin.mouseEnabled = false; +911 sin.setExpired(false); +912 }, +913 /** +914 * Changes (or sets) the current Director scene to the index +915 * parameter. There will be no transition on scene change. +916 * @param sceneIndex {number} an integer indicating the index of the target Scene +917 * to be shown. +918 */ +919 setScene : function(sceneIndex) { +920 var sin = this.scenes[ sceneIndex ]; +921 this.childrenList = []; +922 this.addChild(sin); +923 this.currentScene = sin; +924 +925 sin.setExpired(false); +926 sin.mouseEnabled = true; +927 sin.resetTransform(); +928 sin.setLocation(0, 0); +929 sin.alpha = 1; +930 +931 sin.activated(); +932 }, +933 /** +934 * This method will change the current Scene by the Scene indicated as parameter. +935 * It will apply random values for anchor and transition type. +936 * @see easeInOutRandom +937 * +938 * @param iNewSceneIndex {number} an integer indicating the index of the new scene to run on the Director. +939 * @param time {number} an integer indicating the time the Scene transition will take. +940 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +941 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +942 */ +943 switchToScene : function(iNewSceneIndex, time, alpha, transition) { +944 var currentSceneIndex = this.getSceneIndex(this.currentScene); +945 +946 if (!transition) { +947 this.setScene(iNewSceneIndex); +948 } +949 else { +950 this.easeInOutRandom(iNewSceneIndex, currentSceneIndex, time, alpha); +951 } +952 }, +953 /** +954 * Sets the previous Scene in sequence as the current Scene. +955 * @see switchToScene. +956 * +957 * @param time {number} integer indicating the time the Scene transition will take. +958 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +959 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +960 */ +961 switchToPrevScene : function(time, alpha, transition) { +962 +963 var currentSceneIndex = this.getSceneIndex(this.currentScene); +964 +965 if (this.getNumScenes() <= 1 || currentSceneIndex === 0) { +966 return; +967 } +968 +969 if (!transition) { +970 this.setScene(currentSceneIndex - 1); +971 } +972 else { +973 this.easeInOutRandom(currentSceneIndex - 1, currentSceneIndex, time, alpha); +974 } +975 }, +976 /** +977 * Sets the previous Scene in sequence as the current Scene. +978 * @see switchToScene. +979 * +980 * @param time {number} integer indicating the time the Scene transition will take. +981 * @param alpha {boolean} a boolean indicating whether Scene transition should be fading. +982 * @param transition {boolean} a boolean indicating whether the scene change must smoothly animated. +983 */ +984 switchToNextScene: function(time, alpha, transition) { +985 +986 var currentSceneIndex = this.getSceneIndex(this.currentScene); +987 +988 if (this.getNumScenes() <= 1 || currentSceneIndex === this.getNumScenes() - 1) { +989 return; +990 } +991 +992 if (!transition) { +993 this.setScene(currentSceneIndex + 1); +994 } +995 else { +996 this.easeInOutRandom(currentSceneIndex + 1, currentSceneIndex, time, alpha); +997 } 998 }, -999 mouseDrag : function(mouseEvent) { +999 mouseEnter : function(mouseEvent) { 1000 }, -1001 /** -1002 * Scene easing listener. Notifies scenes when they're about to be activated (set as current -1003 * director's scene). -1004 * -1005 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. -1006 * @param b_easeIn {boolean} scene enters or exits ? -1007 */ -1008 easeEnd : function(scene, b_easeIn) { -1009 // scene is going out -1010 if (!b_easeIn) { -1011 -1012 scene.setExpired(true); -1013 } else { -1014 this.currentScene = scene; -1015 this.currentScene.activated(); -1016 } -1017 -1018 scene.mouseEnabled = true; -1019 scene.emptyBehaviorList(); -1020 }, -1021 /** -1022 * Return the index for a given Scene object contained in the Director. -1023 * @param scene {CAAT.Scene} -1024 */ -1025 getSceneIndex : function(scene) { -1026 for (var i = 0; i < this.scenes.length; i++) { -1027 if (this.scenes[i] === scene) { -1028 return i; -1029 } -1030 } -1031 return -1; -1032 }, -1033 /** -1034 * Get a concrete director's scene. -1035 * @param index {number} an integer indicating the scene index. -1036 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. -1037 */ -1038 getScene : function(index) { -1039 return this.scenes[index]; -1040 }, -1041 /** -1042 * Return the index of the current scene in the Director's scene list. -1043 * @return {number} the current scene's index. -1044 */ -1045 getCurrentSceneIndex : function() { -1046 return this.getSceneIndex(this.currentScene); -1047 }, -1048 /** -1049 * Return the running browser name. -1050 * @return {string} the browser name. -1051 */ -1052 getBrowserName : function() { -1053 return this.browserInfo.browser; -1054 }, -1055 /** -1056 * Return the running browser version. -1057 * @return {string} the browser version. -1058 */ -1059 getBrowserVersion : function() { -1060 return this.browserInfo.version; -1061 }, -1062 /** -1063 * Return the operating system name. -1064 * @return {string} the os name. -1065 */ -1066 getOSName : function() { -1067 return this.browserInfo.OS; -1068 }, -1069 /** -1070 * Gets the resource with the specified resource name. -1071 * The Director holds a collection called <code>imagesCache</code> -1072 * where you can store a JSON of the form -1073 * <code>[ { id: imageId, image: imageObject } ]</code>. -1074 * This structure will be used as a resources cache. -1075 * There's a CAAT.ImagePreloader class to preload resources and -1076 * generate this structure on loading finalization. -1077 * -1078 * @param sId {object} an String identifying a resource. -1079 */ -1080 getImage : function(sId) { -1081 var ret = this.imagesCache[sId]; -1082 if (ret) { -1083 return ret; -1084 } -1085 -1086 for (var i = 0; i < this.imagesCache.length; i++) { -1087 if (this.imagesCache[i].id === sId) { -1088 return this.imagesCache[i].image; -1089 } -1090 } -1091 -1092 return null; -1093 }, -1094 /** -1095 * Adds an audio to the cache. -1096 * -1097 * @see CAAT.AudioManager.addAudio -1098 * @return this -1099 */ -1100 addAudio : function(id, url) { -1101 this.audioManager.addAudio(id, url); -1102 return this; +1001 mouseExit : function(mouseEvent) { +1002 }, +1003 mouseMove : function(mouseEvent) { +1004 }, +1005 mouseDown : function(mouseEvent) { +1006 }, +1007 mouseUp : function(mouseEvent) { +1008 }, +1009 mouseDrag : function(mouseEvent) { +1010 }, +1011 /** +1012 * Scene easing listener. Notifies scenes when they're about to be activated (set as current +1013 * director's scene). +1014 * +1015 * @param scene {CAAT.Scene} the scene that has just been brought in or taken out of the director. +1016 * @param b_easeIn {boolean} scene enters or exits ? +1017 */ +1018 easeEnd : function(scene, b_easeIn) { +1019 // scene is going out +1020 if (!b_easeIn) { +1021 +1022 scene.setExpired(true); +1023 } else { +1024 this.currentScene = scene; +1025 this.currentScene.activated(); +1026 } +1027 +1028 scene.mouseEnabled = true; +1029 scene.emptyBehaviorList(); +1030 }, +1031 /** +1032 * Return the index for a given Scene object contained in the Director. +1033 * @param scene {CAAT.Scene} +1034 */ +1035 getSceneIndex : function(scene) { +1036 for (var i = 0; i < this.scenes.length; i++) { +1037 if (this.scenes[i] === scene) { +1038 return i; +1039 } +1040 } +1041 return -1; +1042 }, +1043 /** +1044 * Get a concrete director's scene. +1045 * @param index {number} an integer indicating the scene index. +1046 * @return {CAAT.Scene} a CAAT.Scene object instance or null if the index is oob. +1047 */ +1048 getScene : function(index) { +1049 return this.scenes[index]; +1050 }, +1051 /** +1052 * Return the index of the current scene in the Director's scene list. +1053 * @return {number} the current scene's index. +1054 */ +1055 getCurrentSceneIndex : function() { +1056 return this.getSceneIndex(this.currentScene); +1057 }, +1058 /** +1059 * Return the running browser name. +1060 * @return {string} the browser name. +1061 */ +1062 getBrowserName : function() { +1063 return this.browserInfo.browser; +1064 }, +1065 /** +1066 * Return the running browser version. +1067 * @return {string} the browser version. +1068 */ +1069 getBrowserVersion : function() { +1070 return this.browserInfo.version; +1071 }, +1072 /** +1073 * Return the operating system name. +1074 * @return {string} the os name. +1075 */ +1076 getOSName : function() { +1077 return this.browserInfo.OS; +1078 }, +1079 /** +1080 * Gets the resource with the specified resource name. +1081 * The Director holds a collection called <code>imagesCache</code> +1082 * where you can store a JSON of the form +1083 * <code>[ { id: imageId, image: imageObject } ]</code>. +1084 * This structure will be used as a resources cache. +1085 * There's a CAAT.ImagePreloader class to preload resources and +1086 * generate this structure on loading finalization. +1087 * +1088 * @param sId {object} an String identifying a resource. +1089 */ +1090 getImage : function(sId) { +1091 var ret = this.imagesCache[sId]; +1092 if (ret) { +1093 return ret; +1094 } +1095 +1096 for (var i = 0; i < this.imagesCache.length; i++) { +1097 if (this.imagesCache[i].id === sId) { +1098 return this.imagesCache[i].image; +1099 } +1100 } +1101 +1102 return null; 1103 }, 1104 /** -1105 * Plays the audio instance identified by the id. -1106 * @param id {object} the object used to store a sound in the audioCache. -1107 */ -1108 audioPlay : function(id) { -1109 this.audioManager.play(id); -1110 }, -1111 /** -1112 * Loops an audio instance identified by the id. -1113 * @param id {object} the object used to store a sound in the audioCache. -1114 * -1115 * @return {HTMLElement|null} the value from audioManager.loop -1116 */ -1117 audioLoop : function(id) { -1118 return this.audioManager.loop(id); -1119 }, -1120 endSound : function() { -1121 return this.audioManager.endSound(); -1122 }, -1123 setSoundEffectsEnabled : function(enabled) { -1124 return this.audioManager.setSoundEffectsEnabled(enabled); -1125 }, -1126 setMusicEnabled : function(enabled) { -1127 return this.audioManager.setMusicEnabled(enabled); -1128 }, -1129 isMusicEnabled : function() { -1130 return this.audioManager.isMusicEnabled(); -1131 }, -1132 isSoundEffectsEnabled : function() { -1133 return this.audioManager.isSoundEffectsEnabled(); -1134 }, -1135 /** -1136 * Removes Director's scenes. -1137 */ -1138 emptyScenes : function() { -1139 this.scenes = []; -1140 }, -1141 /** -1142 * Adds an scene to this Director. -1143 * @param scene {CAAT.Scene} a scene object. -1144 */ -1145 addChild : function(scene) { -1146 scene.parent = this; -1147 this.childrenList.push(scene); -1148 }, -1149 /** -1150 * @Deprecated use CAAT.loop instead. -1151 * @param fps -1152 * @param callback -1153 * @param callback2 +1105 * Adds an audio to the cache. +1106 * +1107 * @see CAAT.AudioManager.addAudio +1108 * @return this +1109 */ +1110 addAudio : function(id, url) { +1111 this.audioManager.addAudio(id, url); +1112 return this; +1113 }, +1114 /** +1115 * Plays the audio instance identified by the id. +1116 * @param id {object} the object used to store a sound in the audioCache. +1117 */ +1118 audioPlay : function(id) { +1119 this.audioManager.play(id); +1120 }, +1121 /** +1122 * Loops an audio instance identified by the id. +1123 * @param id {object} the object used to store a sound in the audioCache. +1124 * +1125 * @return {HTMLElement|null} the value from audioManager.loop +1126 */ +1127 audioLoop : function(id) { +1128 return this.audioManager.loop(id); +1129 }, +1130 endSound : function() { +1131 return this.audioManager.endSound(); +1132 }, +1133 setSoundEffectsEnabled : function(enabled) { +1134 return this.audioManager.setSoundEffectsEnabled(enabled); +1135 }, +1136 setMusicEnabled : function(enabled) { +1137 return this.audioManager.setMusicEnabled(enabled); +1138 }, +1139 isMusicEnabled : function() { +1140 return this.audioManager.isMusicEnabled(); +1141 }, +1142 isSoundEffectsEnabled : function() { +1143 return this.audioManager.isSoundEffectsEnabled(); +1144 }, +1145 /** +1146 * Removes Director's scenes. +1147 */ +1148 emptyScenes : function() { +1149 this.scenes = []; +1150 }, +1151 /** +1152 * Adds an scene to this Director. +1153 * @param scene {CAAT.Scene} a scene object. 1154 */ -1155 loop : function(fps,callback,callback2) { -1156 if ( callback2 ) { -1157 this.onRenderStart= callback; -1158 this.onRenderEnd= callback2; -1159 } else if (callback) { -1160 this.onRenderEnd= callback; -1161 } -1162 CAAT.loop(); -1163 }, -1164 /** -1165 * Starts the director animation.If no scene is explicitly selected, the current Scene will -1166 * be the first scene added to the Director. -1167 * <p> -1168 * The fps parameter will set the animation quality. Higher values, -1169 * means CAAT will try to render more frames in the same second (at the -1170 * expense of cpu power at least until hardware accelerated canvas rendering -1171 * context are available). A value of 60 is a high frame rate and should not be exceeded. -1172 * -1173 * @param fps {number} integer value indicating the target frames per second to run -1174 * the animation at. -1175 */ -1176 renderFrame : function(fps, callback) { -1177 var t = new Date().getTime(), -1178 delta = t - this.timeline; -1179 -1180 /* -1181 check for massive frame time. if for example the current browser tab is minified or taken out of -1182 foreground, the system will account for a bit time interval. minify that impact by lowering down -1183 the elapsed time (virtual timelines FTW) -1184 */ -1185 if ( delta > 500 ) { -1186 delta= 500; -1187 } -1188 -1189 if ( this.onRenderStart ) { -1190 this.onRenderStart(delta); -1191 } -1192 -1193 this.render(delta); -1194 -1195 if ( this.debugInfo ) { -1196 this.debugInfo(this.statistics); +1155 addChild : function(scene) { +1156 scene.parent = this; +1157 this.childrenList.push(scene); +1158 }, +1159 /** +1160 * @Deprecated use CAAT.loop instead. +1161 * @param fps +1162 * @param callback +1163 * @param callback2 +1164 */ +1165 loop : function(fps,callback,callback2) { +1166 if ( callback2 ) { +1167 this.onRenderStart= callback; +1168 this.onRenderEnd= callback2; +1169 } else if (callback) { +1170 this.onRenderEnd= callback; +1171 } +1172 CAAT.loop(); +1173 }, +1174 /** +1175 * Starts the director animation.If no scene is explicitly selected, the current Scene will +1176 * be the first scene added to the Director. +1177 * <p> +1178 * The fps parameter will set the animation quality. Higher values, +1179 * means CAAT will try to render more frames in the same second (at the +1180 * expense of cpu power at least until hardware accelerated canvas rendering +1181 * context are available). A value of 60 is a high frame rate and should not be exceeded. +1182 * +1183 * @param fps {number} integer value indicating the target frames per second to run +1184 * the animation at. +1185 */ +1186 renderFrame : function(fps, callback) { +1187 var t = new Date().getTime(), +1188 delta = t - this.timeline; +1189 +1190 /* +1191 check for massive frame time. if for example the current browser tab is minified or taken out of +1192 foreground, the system will account for a bit time interval. minify that impact by lowering down +1193 the elapsed time (virtual timelines FTW) +1194 */ +1195 if ( delta > 500 ) { +1196 delta= 500; 1197 } -1198 -1199 this.timeline = t; -1200 -1201 if (this.onRenderEnd) { -1202 this.onRenderEnd(delta); -1203 } -1204 }, -1205 endLoop : function () { -1206 }, -1207 /** -1208 * This method states whether the director must clear background before rendering -1209 * each frame. -1210 * @param clear {boolean} a boolean indicating whether to clear the screen before scene draw. -1211 * @return this. -1212 */ -1213 setClear : function(clear) { -1214 this.clear = clear; -1215 return this; +1198 +1199 if ( this.onRenderStart ) { +1200 this.onRenderStart(delta); +1201 } +1202 +1203 this.render(delta); +1204 +1205 if ( this.debugInfo ) { +1206 this.debugInfo(this.statistics); +1207 } +1208 +1209 this.timeline = t; +1210 +1211 if (this.onRenderEnd) { +1212 this.onRenderEnd(delta); +1213 } +1214 }, +1215 endLoop : function () { 1216 }, 1217 /** -1218 * Get this Director's AudioManager instance. -1219 * @return {CAAT.AudioManager} the AudioManager instance. -1220 */ -1221 getAudioManager : function() { -1222 return this.audioManager; -1223 }, -1224 /** -1225 * Acculumate dom elements position to properly offset on-screen mouse/touch events. -1226 * @param node -1227 */ -1228 cumulateOffset : function(node, parent, prop) { -1229 var left= prop+'Left'; -1230 var top= prop+'Top'; -1231 var x=0, y=0, style; -1232 -1233 while( navigator.browser!=='iOS' && node && node.style ) { -1234 if ( node.currentStyle ) { -1235 style= node.currentStyle['position']; -1236 } else { -1237 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); -1238 style= style ? style.getPropertyValue('position') : null; -1239 } -1240 -1241 // if (!/^(relative|absolute|fixed)$/.test(style)) { -1242 if (!/^(fixed)$/.test(style)) { -1243 x += node[left]; -1244 y+= node[top]; -1245 node = node[parent]; +1218 * This method states whether the director must clear background before rendering +1219 * each frame. +1220 * @param clear {boolean} a boolean indicating whether to clear the screen before scene draw. +1221 * @return this. +1222 */ +1223 setClear : function(clear) { +1224 this.clear = clear; +1225 return this; +1226 }, +1227 /** +1228 * Get this Director's AudioManager instance. +1229 * @return {CAAT.AudioManager} the AudioManager instance. +1230 */ +1231 getAudioManager : function() { +1232 return this.audioManager; +1233 }, +1234 /** +1235 * Acculumate dom elements position to properly offset on-screen mouse/touch events. +1236 * @param node +1237 */ +1238 cumulateOffset : function(node, parent, prop) { +1239 var left= prop+'Left'; +1240 var top= prop+'Top'; +1241 var x=0, y=0, style; +1242 +1243 while( navigator.browser!=='iOS' && node && node.style ) { +1244 if ( node.currentStyle ) { +1245 style= node.currentStyle['position']; 1246 } else { -1247 break; -1248 } -1249 } +1247 style= (node.ownerDocument.defaultView || node.ownerDocument.parentWindow).getComputedStyle(node, null); +1248 style= style ? style.getPropertyValue('position') : null; +1249 } 1250 -1251 return { -1252 x: x, -1253 y: y, -1254 style: style -1255 }; -1256 }, -1257 getOffset : function( node ) { -1258 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); -1259 if ( res.style==='fixed' ) { -1260 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); -1261 return { -1262 x: res.x + res2.x, -1263 y: res.y + res2.y -1264 }; -1265 } -1266 -1267 return { -1268 x: res.x, -1269 y: res.y -1270 }; -1271 }, -1272 /** -1273 * Normalize input event coordinates to be related to (0,0) canvas position. -1274 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. -1275 * @param e {MouseEvent} a mouse event from an input event. -1276 */ -1277 getCanvasCoord : function(point, e) { -1278 -1279 var posx = 0; -1280 var posy = 0; -1281 if (!e) e = window.event; -1282 -1283 if (e.pageX || e.pageY) { -1284 posx = e.pageX; -1285 posy = e.pageY; -1286 } -1287 else if (e.clientX || e.clientY) { -1288 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; -1289 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; -1290 } -1291 -1292 var offset= this.getOffset(e.target); -1293 -1294 posx-= offset.x; -1295 posy-= offset.y; -1296 -1297 ////////////// -1298 // transformar coordenada inversamente con affine transform de director. -1299 -1300 var pt= new CAAT.Point( posx, posy ); -1301 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); -1302 this.modelViewMatrixI.transformCoord(pt); -1303 posx= pt.x; -1304 posy= pt.y -1305 -1306 point.set(posx, posy); -1307 this.screenMousePoint.set(posx, posy); -1308 -1309 }, -1310 -1311 __mouseDownHandler : function(e) { -1312 -1313 /* -1314 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no -1315 button was presses. Then, send a mouseUp for the previos actor, and return; -1316 */ -1317 if ( this.dragging && this.lastSelectedActor ) { -1318 this.__mouseUpHandler(e); -1319 return; -1320 } -1321 -1322 this.getCanvasCoord(this.mousePoint, e); -1323 this.isMouseDown = true; -1324 var lactor = this.findActorAtPosition(this.mousePoint); -1325 -1326 if (null !== lactor) { -1327 -1328 var pos = lactor.viewToModel( -1329 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1330 -1331 lactor.mouseDown( -1332 new CAAT.MouseEvent().init( -1333 pos.x, -1334 pos.y, -1335 e, -1336 lactor, -1337 new CAAT.Point( -1338 this.screenMousePoint.x, -1339 this.screenMousePoint.y ))); -1340 } -1341 -1342 this.lastSelectedActor= lactor; -1343 }, -1344 -1345 __mouseUpHandler : function(e) { -1346 -1347 this.isMouseDown = false; -1348 this.getCanvasCoord(this.mousePoint, e); -1349 -1350 var pos= null; -1351 var lactor= this.lastSelectedActor; -1352 -1353 if (null !== lactor) { -1354 pos = lactor.viewToModel( -1355 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1356 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { -1357 lactor.actionPerformed(e) -1358 } +1251 // if (!/^(relative|absolute|fixed)$/.test(style)) { +1252 if (!/^(fixed)$/.test(style)) { +1253 x += node[left]; +1254 y+= node[top]; +1255 node = node[parent]; +1256 } else { +1257 break; +1258 } +1259 } +1260 +1261 return { +1262 x: x, +1263 y: y, +1264 style: style +1265 }; +1266 }, +1267 getOffset : function( node ) { +1268 var res= this.cumulateOffset(node, 'offsetParent', 'offset'); +1269 if ( res.style==='fixed' ) { +1270 var res2= this.cumulateOffset(node, node.parentNode ? 'parentNode' : 'parentElement', 'scroll'); +1271 return { +1272 x: res.x + res2.x, +1273 y: res.y + res2.y +1274 }; +1275 } +1276 +1277 return { +1278 x: res.x, +1279 y: res.y +1280 }; +1281 }, +1282 /** +1283 * Normalize input event coordinates to be related to (0,0) canvas position. +1284 * @param point {CAAT.Point} a CAAT.Point instance to hold the canvas coordinate. +1285 * @param e {MouseEvent} a mouse event from an input event. +1286 */ +1287 getCanvasCoord : function(point, e) { +1288 +1289 var posx = 0; +1290 var posy = 0; +1291 if (!e) e = window.event; +1292 +1293 if (e.pageX || e.pageY) { +1294 posx = e.pageX; +1295 posy = e.pageY; +1296 } +1297 else if (e.clientX || e.clientY) { +1298 posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; +1299 posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; +1300 } +1301 +1302 var offset= this.getOffset(e.target); +1303 +1304 posx-= offset.x; +1305 posy-= offset.y; +1306 +1307 ////////////// +1308 // transformar coordenada inversamente con affine transform de director. +1309 +1310 var pt= new CAAT.Point( posx, posy ); +1311 this.modelViewMatrixI= this.modelViewMatrix.getInverse(); +1312 this.modelViewMatrixI.transformCoord(pt); +1313 posx= pt.x; +1314 posy= pt.y +1315 +1316 point.set(posx, posy); +1317 this.screenMousePoint.set(posx, posy); +1318 +1319 }, +1320 +1321 __mouseDownHandler : function(e) { +1322 +1323 /* +1324 was dragging and mousedown detected, can only mean a mouseOut's been performed and on mouseOver, no +1325 button was presses. Then, send a mouseUp for the previos actor, and return; +1326 */ +1327 if ( this.dragging && this.lastSelectedActor ) { +1328 this.__mouseUpHandler(e); +1329 return; +1330 } +1331 +1332 this.getCanvasCoord(this.mousePoint, e); +1333 this.isMouseDown = true; +1334 var lactor = this.findActorAtPosition(this.mousePoint); +1335 +1336 if (null !== lactor) { +1337 +1338 var pos = lactor.viewToModel( +1339 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1340 +1341 lactor.mouseDown( +1342 new CAAT.MouseEvent().init( +1343 pos.x, +1344 pos.y, +1345 e, +1346 lactor, +1347 new CAAT.Point( +1348 this.screenMousePoint.x, +1349 this.screenMousePoint.y ))); +1350 } +1351 +1352 this.lastSelectedActor= lactor; +1353 }, +1354 +1355 __mouseUpHandler : function(e) { +1356 +1357 this.isMouseDown = false; +1358 this.getCanvasCoord(this.mousePoint, e); 1359 -1360 lactor.mouseUp( -1361 new CAAT.MouseEvent().init( -1362 pos.x, -1363 pos.y, -1364 e, -1365 lactor, -1366 this.screenMousePoint)); -1367 } -1368 -1369 if (!this.dragging && null !== lactor) { -1370 if (lactor.contains(pos.x, pos.y)) { -1371 lactor.mouseClick( -1372 new CAAT.MouseEvent().init( -1373 pos.x, -1374 pos.y, -1375 e, -1376 lactor, -1377 this.screenMousePoint)); -1378 } -1379 } -1380 -1381 this.dragging = false; -1382 this.in_= false; -1383 // CAAT.setCursor('default'); -1384 }, -1385 -1386 __mouseMoveHandler : function(e) { -1387 this.getCanvasCoord(this.mousePoint, e); -1388 -1389 var lactor; -1390 var pos; -1391 -1392 // drag -1393 -1394 if (this.isMouseDown && null !== this.lastSelectedActor) { -1395 /* -1396 // check for mouse move threshold. -1397 if (!this.dragging) { -1398 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && -1399 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { -1400 return; -1401 } -1402 } -1403 */ -1404 -1405 -1406 lactor = this.lastSelectedActor; -1407 pos = lactor.viewToModel( -1408 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1409 -1410 this.dragging = true; -1411 -1412 var px= lactor.x; -1413 var py= lactor.y; -1414 lactor.mouseDrag( -1415 new CAAT.MouseEvent().init( -1416 pos.x, -1417 pos.y, -1418 e, -1419 lactor, -1420 new CAAT.Point( -1421 this.screenMousePoint.x, -1422 this.screenMousePoint.y))); -1423 -1424 this.prevMousePoint.x= pos.x; -1425 this.prevMousePoint.y= pos.y; -1426 -1427 /** -1428 * Element has not moved after drag, so treat it as a button. -1429 */ -1430 if ( px===lactor.x && py===lactor.y ) { -1431 -1432 var contains= lactor.contains(pos.x, pos.y); +1360 var pos= null; +1361 var lactor= this.lastSelectedActor; +1362 +1363 if (null !== lactor) { +1364 pos = lactor.viewToModel( +1365 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1366 if ( lactor.actionPerformed && lactor.contains(pos.x, pos.y) ) { +1367 lactor.actionPerformed(e) +1368 } +1369 +1370 lactor.mouseUp( +1371 new CAAT.MouseEvent().init( +1372 pos.x, +1373 pos.y, +1374 e, +1375 lactor, +1376 this.screenMousePoint)); +1377 } +1378 +1379 if (!this.dragging && null !== lactor) { +1380 if (lactor.contains(pos.x, pos.y)) { +1381 lactor.mouseClick( +1382 new CAAT.MouseEvent().init( +1383 pos.x, +1384 pos.y, +1385 e, +1386 lactor, +1387 this.screenMousePoint)); +1388 } +1389 } +1390 +1391 this.dragging = false; +1392 this.in_= false; +1393 // CAAT.setCursor('default'); +1394 }, +1395 +1396 __mouseMoveHandler : function(e) { +1397 this.getCanvasCoord(this.mousePoint, e); +1398 +1399 var lactor; +1400 var pos; +1401 +1402 // drag +1403 +1404 if (this.isMouseDown && null !== this.lastSelectedActor) { +1405 /* +1406 // check for mouse move threshold. +1407 if (!this.dragging) { +1408 if (Math.abs(this.prevMousePoint.x - this.mousePoint.x) < CAAT.DRAG_THRESHOLD_X && +1409 Math.abs(this.prevMousePoint.y - this.mousePoint.y) < CAAT.DRAG_THRESHOLD_Y) { +1410 return; +1411 } +1412 } +1413 */ +1414 +1415 +1416 lactor = this.lastSelectedActor; +1417 pos = lactor.viewToModel( +1418 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1419 +1420 this.dragging = true; +1421 +1422 var px= lactor.x; +1423 var py= lactor.y; +1424 lactor.mouseDrag( +1425 new CAAT.MouseEvent().init( +1426 pos.x, +1427 pos.y, +1428 e, +1429 lactor, +1430 new CAAT.Point( +1431 this.screenMousePoint.x, +1432 this.screenMousePoint.y))); 1433 -1434 if (this.in_ && !contains) { -1435 lactor.mouseExit( -1436 new CAAT.MouseEvent().init( -1437 pos.x, -1438 pos.y, -1439 e, -1440 lactor, -1441 this.screenMousePoint)); -1442 this.in_ = false; -1443 } -1444 -1445 if (!this.in_ && contains ) { -1446 lactor.mouseEnter( -1447 new CAAT.MouseEvent().init( -1448 pos.x, -1449 pos.y, -1450 e, -1451 lactor, -1452 this.screenMousePoint)); -1453 this.in_ = true; -1454 } -1455 } -1456 -1457 return; -1458 } -1459 -1460 // mouse move. -1461 this.in_= true; -1462 -1463 lactor = this.findActorAtPosition(this.mousePoint); -1464 -1465 // cambiamos de actor. -1466 if (lactor !== this.lastSelectedActor) { -1467 if (null !== this.lastSelectedActor) { -1468 -1469 pos = this.lastSelectedActor.viewToModel( -1470 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1471 -1472 this.lastSelectedActor.mouseExit( -1473 new CAAT.MouseEvent().init( -1474 pos.x, -1475 pos.y, -1476 e, -1477 this.lastSelectedActor, -1478 this.screenMousePoint)); -1479 } -1480 -1481 if (null !== lactor) { -1482 pos = lactor.viewToModel( -1483 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1484 -1485 lactor.mouseEnter( -1486 new CAAT.MouseEvent().init( -1487 pos.x, -1488 pos.y, -1489 e, -1490 lactor, -1491 this.screenMousePoint)); -1492 } -1493 } +1434 this.prevMousePoint.x= pos.x; +1435 this.prevMousePoint.y= pos.y; +1436 +1437 /** +1438 * Element has not moved after drag, so treat it as a button. +1439 */ +1440 if ( px===lactor.x && py===lactor.y ) { +1441 +1442 var contains= lactor.contains(pos.x, pos.y); +1443 +1444 if (this.in_ && !contains) { +1445 lactor.mouseExit( +1446 new CAAT.MouseEvent().init( +1447 pos.x, +1448 pos.y, +1449 e, +1450 lactor, +1451 this.screenMousePoint)); +1452 this.in_ = false; +1453 } +1454 +1455 if (!this.in_ && contains ) { +1456 lactor.mouseEnter( +1457 new CAAT.MouseEvent().init( +1458 pos.x, +1459 pos.y, +1460 e, +1461 lactor, +1462 this.screenMousePoint)); +1463 this.in_ = true; +1464 } +1465 } +1466 +1467 return; +1468 } +1469 +1470 // mouse move. +1471 this.in_= true; +1472 +1473 lactor = this.findActorAtPosition(this.mousePoint); +1474 +1475 // cambiamos de actor. +1476 if (lactor !== this.lastSelectedActor) { +1477 if (null !== this.lastSelectedActor) { +1478 +1479 pos = this.lastSelectedActor.viewToModel( +1480 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1481 +1482 this.lastSelectedActor.mouseExit( +1483 new CAAT.MouseEvent().init( +1484 pos.x, +1485 pos.y, +1486 e, +1487 this.lastSelectedActor, +1488 this.screenMousePoint)); +1489 } +1490 +1491 if (null !== lactor) { +1492 pos = lactor.viewToModel( +1493 new CAAT.Point( this.screenMousePoint.x, this.screenMousePoint.y, 0)); 1494 -1495 pos = lactor.viewToModel( -1496 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1497 -1498 if (null !== lactor) { -1499 -1500 lactor.mouseMove( -1501 new CAAT.MouseEvent().init( -1502 pos.x, -1503 pos.y, -1504 e, -1505 lactor, -1506 this.screenMousePoint)); -1507 } -1508 -1509 this.lastSelectedActor = lactor; -1510 }, -1511 -1512 __mouseOutHandler : function(e) { -1513 -1514 if (null !== this.lastSelectedActor ) { -1515 -1516 this.getCanvasCoord(this.mousePoint, e); -1517 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); -1518 this.lastSelectedActor.viewToModel(pos); -1519 -1520 var ev= new CAAT.MouseEvent().init( -1521 pos.x, -1522 pos.y, -1523 e, -1524 this.lastSelectedActor, -1525 this.screenMousePoint); -1526 -1527 this.lastSelectedActor.mouseExit(ev); -1528 this.lastSelectedActor.mouseOut(ev); +1495 lactor.mouseEnter( +1496 new CAAT.MouseEvent().init( +1497 pos.x, +1498 pos.y, +1499 e, +1500 lactor, +1501 this.screenMousePoint)); +1502 } +1503 } +1504 +1505 pos = lactor.viewToModel( +1506 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1507 +1508 if (null !== lactor) { +1509 +1510 lactor.mouseMove( +1511 new CAAT.MouseEvent().init( +1512 pos.x, +1513 pos.y, +1514 e, +1515 lactor, +1516 this.screenMousePoint)); +1517 } +1518 +1519 this.lastSelectedActor = lactor; +1520 }, +1521 +1522 __mouseOutHandler : function(e) { +1523 +1524 if (null !== this.lastSelectedActor ) { +1525 +1526 this.getCanvasCoord(this.mousePoint, e); +1527 var pos = new CAAT.Point(this.mousePoint.x, this.mousePoint.y, 0); +1528 this.lastSelectedActor.viewToModel(pos); 1529 -1530 if ( !this.dragging ) { -1531 this.lastSelectedActor = null; -1532 } -1533 } else { -1534 this.isMouseDown = false; -1535 this.in_ = false; -1536 } -1537 -1538 }, +1530 var ev= new CAAT.MouseEvent().init( +1531 pos.x, +1532 pos.y, +1533 e, +1534 this.lastSelectedActor, +1535 this.screenMousePoint); +1536 +1537 this.lastSelectedActor.mouseExit(ev); +1538 this.lastSelectedActor.mouseOut(ev); 1539 -1540 __mouseOverHandler : function(e) { -1541 -1542 var lactor; -1543 var pos; -1544 this.getCanvasCoord(this.mousePoint, e); -1545 -1546 if ( null==this.lastSelectedActor ) { -1547 lactor= this.findActorAtPosition( this.mousePoint ); -1548 -1549 if (null !== lactor) { -1550 -1551 pos = lactor.viewToModel( -1552 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1553 -1554 var ev= new CAAT.MouseEvent().init( -1555 pos.x, -1556 pos.y, -1557 e, -1558 lactor, -1559 this.screenMousePoint); +1540 if ( !this.dragging ) { +1541 this.lastSelectedActor = null; +1542 } +1543 } else { +1544 this.isMouseDown = false; +1545 this.in_ = false; +1546 } +1547 +1548 }, +1549 +1550 __mouseOverHandler : function(e) { +1551 +1552 var lactor; +1553 var pos; +1554 this.getCanvasCoord(this.mousePoint, e); +1555 +1556 if ( null==this.lastSelectedActor ) { +1557 lactor= this.findActorAtPosition( this.mousePoint ); +1558 +1559 if (null !== lactor) { 1560 -1561 lactor.mouseOver(ev); -1562 lactor.mouseEnter(ev); -1563 } -1564 -1565 this.lastSelectedActor= lactor; -1566 } else { -1567 var lactor= this.lastSelectedActor; -1568 pos = lactor.viewToModel( -1569 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1561 pos = lactor.viewToModel( +1562 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1563 +1564 var ev= new CAAT.MouseEvent().init( +1565 pos.x, +1566 pos.y, +1567 e, +1568 lactor, +1569 this.screenMousePoint); 1570 -1571 var ev= new CAAT.MouseEvent().init( -1572 pos.x, -1573 pos.y, -1574 e, -1575 lactor, -1576 this.screenMousePoint); -1577 -1578 lactor.mouseOver(ev); -1579 lactor.mouseEnter(ev); -1580 -1581 } -1582 }, -1583 -1584 __mouseDBLClickHandler : function(e) { -1585 -1586 this.getCanvasCoord(this.mousePoint, e); -1587 if (null !== this.lastSelectedActor) { -1588 -1589 var pos = this.lastSelectedActor.viewToModel( -1590 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); -1591 -1592 this.lastSelectedActor.mouseDblClick( -1593 new CAAT.MouseEvent().init( -1594 this.mousePoint.x, -1595 this.mousePoint.y, -1596 e, -1597 this.lastSelectedActor, -1598 this.screenMousePoint)); -1599 } -1600 }, +1571 lactor.mouseOver(ev); +1572 lactor.mouseEnter(ev); +1573 } +1574 +1575 this.lastSelectedActor= lactor; +1576 } else { +1577 var lactor= this.lastSelectedActor; +1578 pos = lactor.viewToModel( +1579 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); +1580 +1581 var ev= new CAAT.MouseEvent().init( +1582 pos.x, +1583 pos.y, +1584 e, +1585 lactor, +1586 this.screenMousePoint); +1587 +1588 lactor.mouseOver(ev); +1589 lactor.mouseEnter(ev); +1590 +1591 } +1592 }, +1593 +1594 __mouseDBLClickHandler : function(e) { +1595 +1596 this.getCanvasCoord(this.mousePoint, e); +1597 if (null !== this.lastSelectedActor) { +1598 +1599 var pos = this.lastSelectedActor.viewToModel( +1600 new CAAT.Point(this.screenMousePoint.x, this.screenMousePoint.y, 0)); 1601 -1602 /** -1603 * Same as mouseDown but not preventing event. -1604 * Will only take care of first touch. -1605 * @param e -1606 */ -1607 __touchStartHandler : function(e) { -1608 -1609 e.preventDefault(); -1610 e= e.targetTouches[0] -1611 this.__mouseDownHandler(e); -1612 }, -1613 -1614 __touchEndHandler : function(e) { -1615 -1616 e.preventDefault(); -1617 e= e.changedTouches[0]; -1618 this.__mouseUpHandler(e); -1619 }, -1620 -1621 __touchMoveHandler : function(e) { -1622 -1623 e.preventDefault(); -1624 -1625 for( var i=0; i<e.targetTouches.length; i++ ) { -1626 if ( !i ) { -1627 this.__mouseMoveHandler(e.targetTouches[i]); -1628 } -1629 } -1630 }, -1631 -1632 addHandlers: function(canvas) { -1633 -1634 var me= this; -1635 -1636 canvas.addEventListener('mouseup', function(e) { -1637 e.preventDefault(); -1638 me.__mouseUpHandler(e); -1639 }, false ); -1640 -1641 canvas.addEventListener('mousedown', function(e) { -1642 e.preventDefault(); -1643 me.__mouseDownHandler(e); -1644 }, false ); +1602 this.lastSelectedActor.mouseDblClick( +1603 new CAAT.MouseEvent().init( +1604 this.mousePoint.x, +1605 this.mousePoint.y, +1606 e, +1607 this.lastSelectedActor, +1608 this.screenMousePoint)); +1609 } +1610 }, +1611 +1612 /** +1613 * Same as mouseDown but not preventing event. +1614 * Will only take care of first touch. +1615 * @param e +1616 */ +1617 __touchStartHandler : function(e) { +1618 +1619 e.preventDefault(); +1620 e= e.targetTouches[0] +1621 this.__mouseDownHandler(e); +1622 }, +1623 +1624 __touchEndHandler : function(e) { +1625 +1626 e.preventDefault(); +1627 e= e.changedTouches[0]; +1628 this.__mouseUpHandler(e); +1629 }, +1630 +1631 __touchMoveHandler : function(e) { +1632 +1633 e.preventDefault(); +1634 +1635 for( var i=0; i<e.targetTouches.length; i++ ) { +1636 if ( !i ) { +1637 this.__mouseMoveHandler(e.targetTouches[i]); +1638 } +1639 } +1640 }, +1641 +1642 addHandlers: function(canvas) { +1643 +1644 var me= this; 1645 -1646 canvas.addEventListener('mouseover',function(e) { +1646 canvas.addEventListener('mouseup', function(e) { 1647 e.preventDefault(); -1648 me.__mouseOverHandler(e); -1649 }, false); +1648 me.__mouseUpHandler(e); +1649 }, false ); 1650 -1651 canvas.addEventListener('mouseout',function(e) { +1651 canvas.addEventListener('mousedown', function(e) { 1652 e.preventDefault(); -1653 me.__mouseOutHandler(e); -1654 }, false); +1653 me.__mouseDownHandler(e); +1654 }, false ); 1655 -1656 canvas.addEventListener('mousemove', -1657 function(e) { -1658 e.preventDefault(); -1659 me.__mouseMoveHandler(e); -1660 }, -1661 false); -1662 -1663 canvas.addEventListener("dblclick", function(e) { -1664 e.preventDefault(); -1665 me.__mouseDBLClickHandler(e); -1666 }, false); -1667 -1668 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); -1669 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); -1670 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); -1671 canvas.addEventListener("gesturestart", function(e) { -1672 e.preventDefault(); -1673 }, false ); -1674 canvas.addEventListener("gesturechange", function(e) { -1675 e.preventDefault(); -1676 }, false ); -1677 }, -1678 -1679 enableEvents : function() { -1680 CAAT.RegisterDirector(this); -1681 this.in_ = false; -1682 this.createEventHandler(); -1683 }, -1684 -1685 createEventHandler : function() { -1686 var canvas= this.canvas; -1687 this.in_ = false; -1688 this.addHandlers(canvas); -1689 } -1690 }; -1691 -1692 -1693 if (CAAT.__CSS__) { +1656 canvas.addEventListener('mouseover',function(e) { +1657 e.preventDefault(); +1658 me.__mouseOverHandler(e); +1659 }, false); +1660 +1661 canvas.addEventListener('mouseout',function(e) { +1662 e.preventDefault(); +1663 me.__mouseOutHandler(e); +1664 }, false); +1665 +1666 canvas.addEventListener('mousemove', +1667 function(e) { +1668 e.preventDefault(); +1669 me.__mouseMoveHandler(e); +1670 }, +1671 false); +1672 +1673 canvas.addEventListener("dblclick", function(e) { +1674 e.preventDefault(); +1675 me.__mouseDBLClickHandler(e); +1676 }, false); +1677 +1678 canvas.addEventListener("touchstart", this.__touchStartHandler.bind(this), false); +1679 canvas.addEventListener("touchmove", this.__touchMoveHandler.bind(this), false); +1680 canvas.addEventListener("touchend", this.__touchEndHandler.bind(this), false); +1681 canvas.addEventListener("gesturestart", function(e) { +1682 e.preventDefault(); +1683 }, false ); +1684 canvas.addEventListener("gesturechange", function(e) { +1685 e.preventDefault(); +1686 }, false ); +1687 }, +1688 +1689 enableEvents : function( onElement ) { +1690 CAAT.RegisterDirector(this); +1691 this.in_ = false; +1692 this.createEventHandler( onElement ); +1693 }, 1694 -1695 CAAT.Director.prototype.clip= true; -1696 CAAT.Director.prototype.glEnabled= false; -1697 -1698 CAAT.Director.prototype.getRenderType= function() { -1699 return 'CSS'; -1700 }; -1701 -1702 CAAT.Director.prototype.setScaleProportional= function(w,h) { +1695 createEventHandler : function( onElement ) { +1696 //var canvas= this.canvas; +1697 this.in_ = false; +1698 //this.addHandlers(canvas); +1699 this.addHandlers( onElement ); +1700 } +1701 }; +1702 1703 -1704 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); -1705 this.setScaleAnchored( factor, factor, 0, 0 ); -1706 -1707 this.eventHandler.style.width= ''+this.referenceWidth +'px'; -1708 this.eventHandler.style.height= ''+this.referenceHeight+'px'; -1709 }; -1710 -1711 CAAT.Director.prototype.setBounds= function(x, y, w, h) { -1712 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); -1713 for (var i = 0; i < this.scenes.length; i++) { -1714 this.scenes[i].setBounds(0, 0, w, h); -1715 } -1716 this.eventHandler.style.width= w+'px'; -1717 this.eventHandler.style.height= h+'px'; -1718 -1719 return this; +1704 if (CAAT.__CSS__) { +1705 +1706 CAAT.Director.prototype.clip= true; +1707 CAAT.Director.prototype.glEnabled= false; +1708 +1709 CAAT.Director.prototype.getRenderType= function() { +1710 return 'CSS'; +1711 }; +1712 +1713 CAAT.Director.prototype.setScaleProportional= function(w,h) { +1714 +1715 var factor= Math.min(w/this.referenceWidth, h/this.referenceHeight); +1716 this.setScaleAnchored( factor, factor, 0, 0 ); +1717 +1718 this.eventHandler.style.width= ''+this.referenceWidth +'px'; +1719 this.eventHandler.style.height= ''+this.referenceHeight+'px'; 1720 }; 1721 -1722 CAAT.Director.prototype.initialize= function(width, height, domElement) { -1723 -1724 this.timeline = new Date().getTime(); -1725 this.domElement= domElement; -1726 this.style('position','absolute'); -1727 this.style('width',''+width+'px'); -1728 this.style('height',''+height+'px'); -1729 this.style('overflow', 'hidden' ); -1730 this.enableEvents(); -1731 -1732 this.setBounds(0, 0, width, height); -1733 -1734 this.checkDebug(); -1735 return this; -1736 }; -1737 -1738 CAAT.Director.prototype.render= function(time) { -1739 -1740 this.time += time; -1741 this.animate(this,time); +1722 CAAT.Director.prototype.setBounds= function(x, y, w, h) { +1723 CAAT.Director.superclass.setBounds.call(this, x, y, w, h); +1724 for (var i = 0; i < this.scenes.length; i++) { +1725 this.scenes[i].setBounds(0, 0, w, h); +1726 } +1727 this.eventHandler.style.width= w+'px'; +1728 this.eventHandler.style.height= h+'px'; +1729 +1730 return this; +1731 }; +1732 +1733 /** +1734 * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most +1735 * div in the document hierarchy (z-index 999999). +1736 * @param width +1737 * @param height +1738 * @param domElement +1739 * @param proxy +1740 */ +1741 CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { 1742 -1743 /** -1744 * draw director active scenes. -1745 */ -1746 var i, l, tt; -1747 -1748 if ( CAAT.DEBUG ) { -1749 this.resetStats(); -1750 } +1743 this.timeline = new Date().getTime(); +1744 this.domElement= domElement; +1745 this.style('position','absolute'); +1746 this.style('width',''+width+'px'); +1747 this.style('height',''+height+'px'); +1748 this.style('overflow', 'hidden' ); +1749 +1750 this.enableEvents(domElement); 1751 -1752 for (i = 0, l=this.childrenList.length; i < l; i++) { -1753 var c= this.childrenList[i]; -1754 if (c.isInAnimationFrame(this.time)) { -1755 tt = c.time - c.start_time; -1756 if ( c.onRenderStart ) { -1757 c.onRenderStart(tt); -1758 } +1752 this.setBounds(0, 0, width, height); +1753 +1754 this.checkDebug(); +1755 return this; +1756 }; +1757 +1758 CAAT.Director.prototype.render= function(time) { 1759 -1760 if ( c.onRenderEnd ) { -1761 c.onRenderEnd(tt); -1762 } -1763 -1764 if (!c.isPaused()) { -1765 c.time += time; -1766 } +1760 this.time += time; +1761 this.animate(this,time); +1762 +1763 /** +1764 * draw director active scenes. +1765 */ +1766 var i, l, tt; 1767 -1768 if ( CAAT.DEBUG ) { -1769 this.statistics.size_total+= c.size_total; -1770 this.statistics.size_active+= c.size_active; -1771 } -1772 -1773 } -1774 } -1775 -1776 this.frameCounter++; -1777 }; -1778 -1779 CAAT.Director.prototype.addScene= function(scene) { -1780 scene.setVisible(true); -1781 scene.setBounds(0, 0, this.width, this.height); -1782 this.scenes.push(scene); -1783 scene.setEaseListener(this); -1784 if (null === this.currentScene) { -1785 this.setScene(0); -1786 } +1768 if ( CAAT.DEBUG ) { +1769 this.resetStats(); +1770 } +1771 +1772 for (i = 0, l=this.childrenList.length; i < l; i++) { +1773 var c= this.childrenList[i]; +1774 if (c.isInAnimationFrame(this.time)) { +1775 tt = c.time - c.start_time; +1776 if ( c.onRenderStart ) { +1777 c.onRenderStart(tt); +1778 } +1779 +1780 if ( c.onRenderEnd ) { +1781 c.onRenderEnd(tt); +1782 } +1783 +1784 if (!c.isPaused()) { +1785 c.time += time; +1786 } 1787 -1788 this.domElement.appendChild( scene.domElement ); -1789 }; -1790 -1791 CAAT.Director.prototype.emptyScenes= function() { -1792 this.scenes = []; -1793 this.domElement.innerHTML=''; -1794 this.createEventHandler(); -1795 }; -1796 -1797 CAAT.Director.prototype.setClear= function(clear) { -1798 return this; -1799 }; -1800 -1801 CAAT.Director.prototype.createEventHandler= function() { -1802 this.eventHandler= document.createElement('div'); -1803 this.domElement.appendChild(this.eventHandler); -1804 -1805 this.eventHandler.style.position= 'absolute'; -1806 this.eventHandler.style.left= '0'; -1807 this.eventHandler.style.top= '0'; -1808 this.eventHandler.style.zIndex= 999999; -1809 this.eventHandler.style.width= ''+this.width+'px'; -1810 this.eventHandler.style.height= ''+this.height+'px'; -1811 -1812 var canvas= this.eventHandler; -1813 this.in_ = false; -1814 -1815 this.addHandlers(canvas); -1816 }; -1817 } -1818 -1819 extend(CAAT.Director, CAAT.ActorContainer, null); -1820 })(); \ No newline at end of file +1788 if ( CAAT.DEBUG ) { +1789 this.statistics.size_total+= c.size_total; +1790 this.statistics.size_active+= c.size_active; +1791 } +1792 +1793 } +1794 } +1795 +1796 this.frameCounter++; +1797 }; +1798 +1799 CAAT.Director.prototype.addScene= function(scene) { +1800 scene.setVisible(true); +1801 scene.setBounds(0, 0, this.width, this.height); +1802 this.scenes.push(scene); +1803 scene.setEaseListener(this); +1804 if (null === this.currentScene) { +1805 this.setScene(0); +1806 } +1807 +1808 this.domElement.appendChild( scene.domElement ); +1809 }; +1810 +1811 CAAT.Director.prototype.emptyScenes= function() { +1812 this.scenes = []; +1813 this.domElement.innerHTML=''; +1814 this.createEventHandler(); +1815 }; +1816 +1817 CAAT.Director.prototype.setClear= function(clear) { +1818 return this; +1819 }; +1820 +1821 CAAT.Director.prototype.createEventHandler= function() { +1822 this.eventHandler= document.createElement('div'); +1823 this.domElement.appendChild(this.eventHandler); +1824 +1825 this.eventHandler.style.position= 'absolute'; +1826 this.eventHandler.style.left= '0'; +1827 this.eventHandler.style.top= '0'; +1828 this.eventHandler.style.zIndex= 999999; +1829 this.eventHandler.style.width= ''+this.width+'px'; +1830 this.eventHandler.style.height= ''+this.height+'px'; +1831 +1832 var canvas= this.eventHandler; +1833 this.in_ = false; +1834 +1835 this.addHandlers(canvas); +1836 }; +1837 } +1838 +1839 extend(CAAT.Director, CAAT.ActorContainer, null); +1840 })(); \ No newline at end of file diff --git a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_ImageUtil_ImageUtil.js.html b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_ImageUtil_ImageUtil.js.html index e55cf8b9..906b32e0 100644 --- a/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_ImageUtil_ImageUtil.js.html +++ b/documentation/jsdoc/symbols/src/_Users_ibon_js_CAAT_src_modules_ImageUtil_ImageUtil.js.html @@ -11,181 +11,209 @@ 4 5 (function() { 6 - 7 CAAT.modules.ImageUtil= function() { - 8 return this; - 9 }; + 7 CAAT.modules.ImageUtil= {}; + 8 + 9 CAAT.modules.ImageUtil.createAlphaSpriteSheet= function(maxAlpha, minAlpha, sheetSize, image, bg_fill_style ) { 10 - 11 CAAT.modules.ImageUtil.prototype= { - 12 createAlphaSpriteSheet: function(maxAlpha, minAlpha, sheetSize, image, bg_fill_style ) { - 13 - 14 if ( maxAlpha<minAlpha ) { - 15 var t= maxAlpha; - 16 maxAlpha= minAlpha; - 17 minAlpha= t; - 18 } - 19 - 20 var canvas= document.createElement('canvas'); - 21 canvas.width= image.width; - 22 canvas.height= image.height*sheetSize; - 23 var ctx= canvas.getContext('2d'); - 24 ctx.fillStyle = bg_fill_style ? bg_fill_style : 'rgba(255,255,255,0)'; - 25 ctx.fillRect(0,0,image.width,image.height*sheetSize); - 26 - 27 var i; - 28 for( i=0; i<sheetSize; i++ ) { - 29 ctx.globalAlpha= 1-(maxAlpha-minAlpha)/sheetSize*(i+1); - 30 ctx.drawImage(image, 0, i*image.height); - 31 } + 11 if ( maxAlpha<minAlpha ) { + 12 var t= maxAlpha; + 13 maxAlpha= minAlpha; + 14 minAlpha= t; + 15 } + 16 + 17 var canvas= document.createElement('canvas'); + 18 canvas.width= image.width; + 19 canvas.height= image.height*sheetSize; + 20 var ctx= canvas.getContext('2d'); + 21 ctx.fillStyle = bg_fill_style ? bg_fill_style : 'rgba(255,255,255,0)'; + 22 ctx.fillRect(0,0,image.width,image.height*sheetSize); + 23 + 24 var i; + 25 for( i=0; i<sheetSize; i++ ) { + 26 ctx.globalAlpha= 1-(maxAlpha-minAlpha)/sheetSize*(i+1); + 27 ctx.drawImage(image, 0, i*image.height); + 28 } + 29 + 30 return canvas; + 31 }; 32 - 33 return canvas; - 34 }, - 35 /** - 36 * Creates a rotated canvas image element. - 37 * @param img - 38 */ - 39 rotate : function( image, angle ) { - 40 - 41 angle= angle||0; - 42 if ( !angle ) { - 43 return image; - 44 } - 45 - 46 var canvas= document.createElement("canvas"); - 47 canvas.width= image.height; - 48 canvas.height= image.width; - 49 var ctx= canvas.getContext('2d'); - 50 ctx.globalAlpha= 1; - 51 ctx.fillStyle='rgba(0,0,0,0)'; - 52 ctx.clearRect(0,0,canvas.width,canvas.height); - 53 - 54 var m= new CAAT.Matrix(); - 55 m.multiply( new CAAT.Matrix().setTranslate( canvas.width/2, canvas.width/2 ) ); - 56 m.multiply( new CAAT.Matrix().setRotation( angle*Math.PI/180 ) ); - 57 m.multiply( new CAAT.Matrix().setTranslate( -canvas.width/2, -canvas.width/2 ) ); - 58 m.transformRenderingContext(ctx); - 59 ctx.drawImage(image,0,0); - 60 - 61 return canvas; - 62 }, - 63 /** - 64 * Remove an image's padding transparent border. - 65 * Transparent means that every scan pixel is alpha=0. - 66 * @param image - 67 * @param threshold {integer} any value below or equal to this will be optimized. + 33 /** + 34 * Creates a rotated canvas image element. + 35 * @param img + 36 */ + 37 CAAT.modules.ImageUtil.rotate= function( image, angle ) { + 38 + 39 angle= angle||0; + 40 if ( !angle ) { + 41 return image; + 42 } + 43 + 44 var canvas= document.createElement("canvas"); + 45 canvas.width= image.height; + 46 canvas.height= image.width; + 47 var ctx= canvas.getContext('2d'); + 48 ctx.globalAlpha= 1; + 49 ctx.fillStyle='rgba(0,0,0,0)'; + 50 ctx.clearRect(0,0,canvas.width,canvas.height); + 51 + 52 var m= new CAAT.Matrix(); + 53 m.multiply( new CAAT.Matrix().setTranslate( canvas.width/2, canvas.width/2 ) ); + 54 m.multiply( new CAAT.Matrix().setRotation( angle*Math.PI/180 ) ); + 55 m.multiply( new CAAT.Matrix().setTranslate( -canvas.width/2, -canvas.width/2 ) ); + 56 m.transformRenderingContext(ctx); + 57 ctx.drawImage(image,0,0); + 58 + 59 return canvas; + 60 }; + 61 + 62 /** + 63 * Remove an image's padding transparent border. + 64 * Transparent means that every scan pixel is alpha=0. + 65 * @param image + 66 * @param threshold {integer} any value below or equal to this will be optimized. + 67 * @param !areas { object{ top<boolean>, bottom<boolean>, left<boolean, right<boolean> }�} 68 */ - 69 optimize : function(image, threshold) { - 70 threshold>>=0; + 69 CAAT.modules.ImageUtil.optimize= function(image, threshold, areas ) { + 70 threshold>>=0; 71 - 72 var canvas= document.createElement('canvas'); - 73 canvas.width= image.width; - 74 canvas.height=image.height; - 75 var ctx= canvas.getContext('2d'); - 76 - 77 ctx.fillStyle='rgba(0,0,0,0)'; - 78 ctx.fillRect(0,0,image.width,image.height); - 79 ctx.drawImage( image, 0, 0 ); - 80 - 81 var imageData= ctx.getImageData(0,0,image.width,image.height); - 82 var data= imageData.data; - 83 - 84 var i,j; - 85 var miny= canvas.height, maxy=0; - 86 var minx= canvas.width, maxx=0; - 87 - 88 var alpha= false; - 89 for( i=0; i<canvas.height; i++ ) { - 90 for( j=0; j<canvas.width; j++ ) { - 91 if ( data[i*canvas.width*4 + 3+j*4]>threshold ) { - 92 alpha= true; - 93 break; - 94 } - 95 } + 72 var atop= true; + 73 var abottom= true; + 74 var aleft= true; + 75 var aright= true; + 76 if ( typeof areas!=='undefined' ) { + 77 if ( typeof areas.top!=='undefined' ) { + 78 atop= areas.top; + 79 } + 80 if ( typeof areas.bottom!=='undefined' ) { + 81 abottom= areas.bottom; + 82 } + 83 if ( typeof areas.left!=='undefined' ) { + 84 aleft= areas.left; + 85 } + 86 if ( typeof areas.right!=='undefined' ) { + 87 aright= areas.right; + 88 } + 89 } + 90 + 91 + 92 var canvas= document.createElement('canvas'); + 93 canvas.width= image.width; + 94 canvas.height=image.height; + 95 var ctx= canvas.getContext('2d'); 96 - 97 if ( alpha ) { - 98 break; - 99 } -100 } -101 // i contiene el indice del ultimo scan que no es transparente total. -102 miny= i; + 97 ctx.fillStyle='rgba(0,0,0,0)'; + 98 ctx.fillRect(0,0,image.width,image.height); + 99 ctx.drawImage( image, 0, 0 ); +100 +101 var imageData= ctx.getImageData(0,0,image.width,image.height); +102 var data= imageData.data; 103 -104 alpha= false; -105 for( i=canvas.height-1; i>=miny; i-- ) { -106 for( j=3; j<canvas.width*4; j+=4 ) { -107 if ( data[i*canvas.width*4 + 3+j*4]>threshold ) { -108 alpha= true; -109 break; -110 } -111 } -112 -113 if ( alpha ) { -114 break; -115 } -116 } -117 maxy= i; +104 var i,j; +105 var miny= 0, maxy=canvas.height-1; +106 var minx= 0, maxx=canvas.width-1; +107 +108 var alpha= false; +109 +110 if ( atop ) { +111 for( i=0; i<canvas.height; i++ ) { +112 for( j=0; j<canvas.width; j++ ) { +113 if ( data[i*canvas.width*4 + 3+j*4]>threshold ) { +114 alpha= true; +115 break; +116 } +117 } 118 -119 -120 alpha= false; -121 for( j=0; j<canvas.width; j++ ) { -122 for( i=0; i<canvas.height; i++ ) { -123 if ( data[i*canvas.width*4 + 3+j*4 ]>threshold ) { -124 alpha= true; -125 break; -126 } -127 } -128 if ( alpha ) { -129 break; -130 } -131 } -132 minx= j; -133 -134 alpha= false; -135 for( j=canvas.width-1; j>=minx; j-- ) { -136 for( i=0; i<canvas.height; i++ ) { -137 if ( data[i*canvas.width*4 + 3+j*4 ]>threshold ) { -138 alpha= true; -139 break; -140 } -141 } -142 if ( alpha ) { -143 break; -144 } -145 } -146 maxx= j; -147 -148 if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { -149 return canvas; -150 } -151 -152 var width= maxx-minx+1; -153 var height=maxy-miny+1; -154 var id2= ctx.getImageData( minx, miny, width, height ); -155 -156 canvas.width= width; -157 canvas.height= height; -158 ctx= canvas.getContext('2d'); -159 ctx.putImageData( id2, 0, 0 ); -160 -161 return canvas; -162 }, -163 createThumb : function(image, w, h, best_fit) { -164 w= w||24; -165 h= h||24; -166 var canvas= document.createElement('canvas'); -167 canvas.width= w; -168 canvas.height= h; -169 var ctx= canvas.getContext('2d'); -170 -171 if ( best_fit ) { -172 var max= Math.max( image.width, image.height ); -173 var ww= image.width/max*w; -174 var hh= image.height/max*h; -175 ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); -176 } else { -177 ctx.drawImage( image, 0, 0, w, h ); -178 } +119 if ( alpha ) { +120 break; +121 } +122 } +123 // i contiene el indice del ultimo scan que no es transparente total. +124 miny= i; +125 } +126 +127 if ( abottom ) { +128 alpha= false; +129 for( i=canvas.height-1; i>=miny; i-- ) { +130 for( j=0; j<canvas.width; j++ ) { +131 if ( data[i*canvas.width*4 + 3+j*4]>threshold ) { +132 alpha= true; +133 break; +134 } +135 } +136 +137 if ( alpha ) { +138 break; +139 } +140 } +141 maxy= i; +142 } +143 +144 if ( aleft ) { +145 alpha= false; +146 for( j=0; j<canvas.width; j++ ) { +147 for( i=miny; i<=maxy; i++ ) { +148 if ( data[i*canvas.width*4 + 3+j*4 ]>threshold ) { +149 alpha= true; +150 break; +151 } +152 } +153 if ( alpha ) { +154 break; +155 } +156 } +157 minx= j; +158 } +159 +160 if ( aright ) { +161 alpha= false; +162 for( j=canvas.width-1; j>=minx; j-- ) { +163 for( i=miny; i<=maxy; i++ ) { +164 if ( data[i*canvas.width*4 + 3+j*4 ]>threshold ) { +165 alpha= true; +166 break; +167 } +168 } +169 if ( alpha ) { +170 break; +171 } +172 } +173 maxx= j; +174 } +175 +176 if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { +177 return canvas; +178 } 179 -180 return canvas; -181 } -182 }; +180 var width= maxx-minx+1; +181 var height=maxy-miny+1; +182 var id2= ctx.getImageData( minx, miny, width, height ); 183 -184 })(); \ No newline at end of file +184 canvas.width= width; +185 canvas.height= height; +186 ctx= canvas.getContext('2d'); +187 ctx.putImageData( id2, 0, 0 ); +188 +189 return canvas; +190 }; +191 +192 CAAT.modules.ImageUtil.createThumb= function(image, w, h, best_fit) { +193 w= w||24; +194 h= h||24; +195 var canvas= document.createElement('canvas'); +196 canvas.width= w; +197 canvas.height= h; +198 var ctx= canvas.getContext('2d'); +199 +200 if ( best_fit ) { +201 var max= Math.max( image.width, image.height ); +202 var ww= image.width/max*w; +203 var hh= image.height/max*h; +204 ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); +205 } else { +206 ctx.drawImage( image, 0, 0, w, h ); +207 } +208 +209 return canvas; +210 } +211 +212 })(); \ No newline at end of file diff --git a/src/model/actor.js b/src/model/actor.js index 660ae6d1..30d1a5b6 100644 --- a/src/model/actor.js +++ b/src/model/actor.js @@ -2201,6 +2201,7 @@ return this; }, + /** * Calculates the text dimension in pixels and stores the values in textWidth and textHeight * attributes. @@ -2214,6 +2215,8 @@ return this; } + var ctx= director.ctx; + director.ctx.save(); director.ctx.font= this.font; @@ -2304,6 +2307,7 @@ if ( null!==this.outlineColor ) { canvas.strokeStyle= this.outlineColor; } + canvas.beginPath(); canvas.strokeText( this.text, tx, 0 ); } } diff --git a/src/model/director.js b/src/model/director.js index fd843a82..80e87e5a 100644 --- a/src/model/director.js +++ b/src/model/director.js @@ -224,16 +224,22 @@ * @param width {number} a canvas width * @param height {number} a canvas height * @param canvas {HTMLCanvasElement=} An optional Canvas object. + * @param proxy {HTMLElement} this object can be an event proxy in case you'd like to layer different elements + * and want events delivered to the correct element. * * @return this */ - initialize : function(width, height, canvas) { + initialize : function(width, height, canvas, proxy) { canvas = canvas || document.createElement('canvas'); this.canvas = canvas; + if ( typeof proxy==='undefined' ) { + proxy= canvas; + } + this.setBounds(0, 0, width, height); this.create(); - this.enableEvents(); + this.enableEvents(proxy); this.timeline = new Date().getTime(); @@ -266,12 +272,16 @@ * @param height * @param canvas */ - initializeGL : function(width, height, canvas) { + initializeGL : function(width, height, canvas, proxy) { canvas = canvas || document.createElement('canvas'); canvas.width = width; canvas.height = height; + if ( typeof proxy==='undefined' ) { + proxy= canvas; + } + this.referenceWidth= width; this.referenceHeight=height; @@ -290,7 +300,7 @@ this.setBounds(0, 0, width, height); this.crc = this.ctx; - this.enableEvents(); + this.enableEvents(canvas); this.timeline = new Date().getTime(); this.glColorProgram = new CAAT.ColorProgram(this.gl).create().initialize(); @@ -1676,16 +1686,17 @@ }, false ); }, - enableEvents : function() { + enableEvents : function( onElement ) { CAAT.RegisterDirector(this); this.in_ = false; - this.createEventHandler(); + this.createEventHandler( onElement ); }, - createEventHandler : function() { - var canvas= this.canvas; + createEventHandler : function( onElement ) { + //var canvas= this.canvas; this.in_ = false; - this.addHandlers(canvas); + //this.addHandlers(canvas); + this.addHandlers( onElement ); } }; @@ -1719,7 +1730,15 @@ return this; }; - CAAT.Director.prototype.initialize= function(width, height, domElement) { + /** + * In this DOM/CSS implementation, proxy is not taken into account since the event router is a top most + * div in the document hierarchy (z-index 999999). + * @param width + * @param height + * @param domElement + * @param proxy + */ + CAAT.Director.prototype.initialize= function(width, height, domElement, proxy) { this.timeline = new Date().getTime(); this.domElement= domElement; @@ -1727,7 +1746,8 @@ this.style('width',''+width+'px'); this.style('height',''+height+'px'); this.style('overflow', 'hidden' ); - this.enableEvents(); + + this.enableEvents(domElement); this.setBounds(0, 0, width, height); diff --git a/src/modules/Font/font.js b/src/modules/Font/font.js new file mode 100644 index 00000000..29c3d640 --- /dev/null +++ b/src/modules/Font/font.js @@ -0,0 +1,159 @@ + +(function() { + + /** + * @constructor + */ + CAAT.Font= function( ) { + return this; + }; + + var UNKNOWN_CHAR_WIDTH= 10; + + CAAT.Font.prototype= { + + fontSize : 10, + fontSizeUnit: "px", + font : 'Sans-Serif', + fontStyle : '', + fillStyle : '#fff', + strokeStyle : null, + padding : 0, + image : null, + charMap : null, + + height : 0, + + setPadding : function( padding ) { + this.padding= padding; + return this; + }, + + setFontStyle : function( style ) { + this.fontStyle= style; + return this; + }, + + setFontSize : function( fontSize ) { + this.fontSize= fontSize; + this.fontSizeUnit= 'px'; + return this; + }, + + setFont : function( font ) { + this.font= font; + return this; + }, + + setFillStyle : function( style ) { + this.fillStyle= style; + return this; + }, + + setStrokeStyle : function( style ) { + this.strokeStyle= style; + return this; + }, + + create : function( chars, padding ) { + var canvas= document.createElement('canvas'); + canvas.width= 1; + canvas.height= 1; + var ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + + var textWidth= 0; + var charWidth= []; + var i; + var x; + var cchar; + + for( i=0; i>0 ) + 2 * padding; + charWidth.push(cw); + textWidth+= cw; + } + + canvas.width= textWidth; + canvas.height= (this.fontSize*1.5)>>0; + ctx= canvas.getContext('2d'); + + ctx.textBaseline= 'top'; + ctx.font= this.fontStyle+' '+this.fontSize+""+this.fontSizeUnit+" "+ this.font; + ctx.fillStyle= this.fillStyle; + ctx.strokeStyle= this.strokeStyle; + + this.charMap= {}; + + x=0; + for( i=0; i, bottom, left }Ê} */ - optimize : function(image, threshold) { - threshold>>=0; + CAAT.modules.ImageUtil.optimize= function(image, threshold, areas ) { + threshold>>=0; + + var atop= true; + var abottom= true; + var aleft= true; + var aright= true; + if ( typeof areas!=='undefined' ) { + if ( typeof areas.top!=='undefined' ) { + atop= areas.top; + } + if ( typeof areas.bottom!=='undefined' ) { + abottom= areas.bottom; + } + if ( typeof areas.left!=='undefined' ) { + aleft= areas.left; + } + if ( typeof areas.right!=='undefined' ) { + aright= areas.right; + } + } - var canvas= document.createElement('canvas'); - canvas.width= image.width; - canvas.height=image.height; - var ctx= canvas.getContext('2d'); - ctx.fillStyle='rgba(0,0,0,0)'; - ctx.fillRect(0,0,image.width,image.height); - ctx.drawImage( image, 0, 0 ); + var canvas= document.createElement('canvas'); + canvas.width= image.width; + canvas.height=image.height; + var ctx= canvas.getContext('2d'); - var imageData= ctx.getImageData(0,0,image.width,image.height); - var data= imageData.data; + ctx.fillStyle='rgba(0,0,0,0)'; + ctx.fillRect(0,0,image.width,image.height); + ctx.drawImage( image, 0, 0 ); - var i,j; - var miny= canvas.height, maxy=0; - var minx= canvas.width, maxx=0; + var imageData= ctx.getImageData(0,0,image.width,image.height); + var data= imageData.data; - var alpha= false; + var i,j; + var miny= 0, maxy=canvas.height-1; + var minx= 0, maxx=canvas.width-1; + + var alpha= false; + + if ( atop ) { for( i=0; ithreshold ) { @@ -100,10 +122,12 @@ } // i contiene el indice del ultimo scan que no es transparente total. miny= i; + } + if ( abottom ) { alpha= false; for( i=canvas.height-1; i>=miny; i-- ) { - for( j=3; jthreshold ) { alpha= true; break; @@ -115,11 +139,12 @@ } } maxy= i; + } - + if ( aleft ) { alpha= false; for( j=0; jthreshold ) { alpha= true; break; @@ -130,10 +155,12 @@ } } minx= j; + } + if ( aright ) { alpha= false; for( j=canvas.width-1; j>=minx; j-- ) { - for( i=0; ithreshold ) { alpha= true; break; @@ -144,41 +171,42 @@ } } maxx= j; + } - if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { - return canvas; - } + if ( 0===minx && 0===miny && canvas.width-1===maxx && canvas.height-1===maxy ) { + return canvas; + } - var width= maxx-minx+1; - var height=maxy-miny+1; - var id2= ctx.getImageData( minx, miny, width, height ); + var width= maxx-minx+1; + var height=maxy-miny+1; + var id2= ctx.getImageData( minx, miny, width, height ); - canvas.width= width; - canvas.height= height; - ctx= canvas.getContext('2d'); - ctx.putImageData( id2, 0, 0 ); + canvas.width= width; + canvas.height= height; + ctx= canvas.getContext('2d'); + ctx.putImageData( id2, 0, 0 ); - return canvas; - }, - createThumb : function(image, w, h, best_fit) { - w= w||24; - h= h||24; - var canvas= document.createElement('canvas'); - canvas.width= w; - canvas.height= h; - var ctx= canvas.getContext('2d'); - - if ( best_fit ) { - var max= Math.max( image.width, image.height ); - var ww= image.width/max*w; - var hh= image.height/max*h; - ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); - } else { - ctx.drawImage( image, 0, 0, w, h ); - } + return canvas; + }; - return canvas; + CAAT.modules.ImageUtil.createThumb= function(image, w, h, best_fit) { + w= w||24; + h= h||24; + var canvas= document.createElement('canvas'); + canvas.width= w; + canvas.height= h; + var ctx= canvas.getContext('2d'); + + if ( best_fit ) { + var max= Math.max( image.width, image.height ); + var ww= image.width/max*w; + var hh= image.height/max*h; + ctx.drawImage( image, (w-ww)/2,(h-hh)/2,ww,hh ); + } else { + ctx.drawImage( image, 0, 0, w, h ); } - }; + + return canvas; + } })(); \ No newline at end of file

    Method Summary
    Method AttributesMethod Name and Description
    <static>   -
    CAAT.modules.ImageUtil() +
    + CAAT.modules.LayoutUtils
    See LICENSE file.