From 714965840ce7bf0e194c7b2c41f6575cdd39bcb5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 08:58:14 +0000 Subject: [PATCH 1/2] Initial plan From ed8a1c9ce382e1bf30c9577108485f78daa919fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 09:09:11 +0000 Subject: [PATCH 2/2] Perf: optimize BigText binary search, deep placeholder lookup, and reduce per-tick overhead Co-authored-by: daedeloth <1168599+daedeloth@users.noreply.github.com> --- .../EaselJS/DisplayObjects/Background.js | 20 ++++---- .../EaselJS/DisplayObjects/BigText.js | 46 +++++++++---------- .../EaselJS/DisplayObjects/Placeholder.js | 5 +- .../Easelbone/Utilities/MovieClipHelper.js | 32 +++++++++++-- dist/scripts/easelbone.js | 8 ++-- package-lock.json | 6 ++- 6 files changed, 76 insertions(+), 41 deletions(-) diff --git a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Background.js b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Background.js index fd29515..3bc6f2b 100644 --- a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Background.js +++ b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Background.js @@ -68,13 +68,14 @@ define( return this.childBounds; } - if (!this.displayobject.getBounds()) { + var bounds = this.displayobject.getBounds(); + if (!bounds) { return null; } return { - width: this.displayobject.getBounds().width, - height: this.displayobject.getBounds().height + width: bounds.width, + height: bounds.height }; }; @@ -105,12 +106,15 @@ define( width = bounds.width; height = bounds.height } - } else if (this.getBounds()) { - width = this.getBounds().width; - height = this.getBounds().height; } else { - width = 100; - height = 100; + bounds = this.getBounds(); + if (bounds) { + width = bounds.width; + height = bounds.height; + } else { + width = 100; + height = 100; + } } return {width: width, height: height}; diff --git a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/BigText.js b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/BigText.js index 6b97053..e9ae28d 100755 --- a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/BigText.js +++ b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/BigText.js @@ -163,18 +163,19 @@ define( }; p.getAvailableSpace = function () { + var bounds; if (this.limits !== null) { return this.limits; } else if (this._bounds) { width = this._bounds.width; height = this._bounds.height; - } else if (this.parent && this.parent.getBounds()) { - width = this.parent.getBounds().width; - height = this.parent.getBounds().height - } else if (this.getBounds()) { - width = this.getBounds().width; - height = this.getBounds().height; + } else if (this.parent && (bounds = this.parent.getBounds())) { + width = bounds.width; + height = bounds.height; + } else if ((bounds = this.getBounds())) { + width = bounds.width; + height = bounds.height; } else { width = 0; height = 0; @@ -266,6 +267,7 @@ define( /** * Find the largest font size that fits the available space using binary search. + * Reuses a single measurement text object to avoid creating one per iteration. * @param textstring * @param availableWidth * @param availableHeight @@ -273,35 +275,33 @@ define( p.goBigOrGoHomeBinary = function (textstring, availableWidth, availableHeight) { var minFontSize = this.minFontSize; var maxFontSize = availableHeight; - var bestFit = null; + var bestFontSize = minFontSize; + + // Reuse a single text object for measurement instead of creating one per step + var measureObj = this.createTextObject(textstring, minFontSize, this._font, this._color); + measureObj.lineWidth = availableWidth; - var steps = 0; while (minFontSize <= maxFontSize) { var midFontSize = Math.floor((minFontSize + maxFontSize) / 2); - var textObj = this.createTextObject(textstring, midFontSize, this._font, this._color); - textObj.lineWidth = availableWidth; - textObj.lineHeight = getFontLineheight(textObj, this._font); - updateCurrentSize(textObj); + measureObj.font = midFontSize + "px " + this._font; + measureObj.lineHeight = getFontLineheight(measureObj, this._font); + updateCurrentSize(measureObj); if (currentSize.height <= availableHeight && currentSize.width <= availableWidth) { - bestFit = textObj; + bestFontSize = midFontSize; minFontSize = midFontSize + 1; } else { maxFontSize = midFontSize - 1; } - - steps ++; } - if (!bestFit) { - // Could not find a fit, return smallest possible - bestFit = this.createTextObject(textstring, this.minFontSize, this._font, this._color); - bestFit.lineWidth = availableWidth; - bestFit.lineHeight = getFontLineheight(bestFit, this._font); - updateCurrentSize(bestFit); - } + // Create the final text object at the best size found + var bestFit = this.createTextObject(textstring, bestFontSize, this._font, this._color); + bestFit.lineWidth = availableWidth; + bestFit.lineHeight = getFontLineheight(bestFit, this._font); + updateCurrentSize(bestFit); - this.fontsize = parseInt(bestFit.font.split('px')[0]); + this.fontsize = bestFontSize; return bestFit; }; diff --git a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Placeholder.js b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Placeholder.js index 3e212fc..e473f73 100644 --- a/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Placeholder.js +++ b/app/scripts/CatLab/Easelbone/EaselJS/DisplayObjects/Placeholder.js @@ -89,7 +89,10 @@ define ( }; element._tick = function() { - this.updateZIndex(); + // Only check z-index if parent has children (skip orphaned elements) + if (element.parent && element.parent.children) { + this.updateZIndex(); + } return element.original_tick.apply(element, arguments); }; diff --git a/app/scripts/CatLab/Easelbone/Utilities/MovieClipHelper.js b/app/scripts/CatLab/Easelbone/Utilities/MovieClipHelper.js index 14c01b1..d4c8efc 100644 --- a/app/scripts/CatLab/Easelbone/Utilities/MovieClipHelper.js +++ b/app/scripts/CatLab/Easelbone/Utilities/MovieClipHelper.js @@ -95,6 +95,10 @@ define( // This is a simple 1-dimensional map: name -> child. container._mh_named_children_map = {}; + // Create a deep map of all descendants by name for O(1) lookups. + // This is a 1-dimensional map: name -> [child, child, ...] + container._mh_deep_named_children_map = {}; + // Create a map of timeline labels. // This is a 2-dimensional map: label -> [child, child, ...] // A label can have multiple children; grandchildren are included as well @@ -127,6 +131,22 @@ define( } } + // Build the deep map: add this child under its own name + if (typeof(container._mh_deep_named_children_map[name]) === 'undefined') { + container._mh_deep_named_children_map[name] = []; + } + container._mh_deep_named_children_map[name].push(child); + + // Merge child's deep map into container's deep map + for (var dk in child._mh_deep_named_children_map) { + if (child._mh_deep_named_children_map.hasOwnProperty(dk)) { + if (typeof(container._mh_deep_named_children_map[dk]) === 'undefined') { + container._mh_deep_named_children_map[dk] = []; + } + container._mh_deep_named_children_map[dk] = container._mh_deep_named_children_map[dk].concat(child._mh_deep_named_children_map[dk]); + } + } + }.bind(this)); } @@ -153,14 +173,20 @@ define( // Cache a container map for faster lookups. this.buildNamedChildMap(container); + // Direct child lookup (O(1)) if (typeof(container._mh_named_children_map[name]) !== 'undefined') { results.push(container._mh_named_children_map[name]); } + // Deep lookup using pre-built map instead of recursive search if (results.length === 0 || options.all) { - for (var k in container._mh_named_children_map) { - if (container._mh_named_children_map.hasOwnProperty(k)) { - this.findFromNameInContainer(container._mh_named_children_map[k], name, options, results); + if (container._mh_deep_named_children_map && container._mh_deep_named_children_map[name]) { + var deepResults = container._mh_deep_named_children_map[name]; + for (var i = 0; i < deepResults.length; i++) { + // Avoid duplicates from direct child lookup + if (results.indexOf(deepResults[i]) === -1) { + results.push(deepResults[i]); + } } } } diff --git a/dist/scripts/easelbone.js b/dist/scripts/easelbone.js index 5f30982..ee5bfcf 100644 --- a/dist/scripts/easelbone.js +++ b/dist/scripts/easelbone.js @@ -2,8 +2,8 @@ define("CatLab/Easelbone/Utilities/Deferred",[],(function(){function e(e){return define("CatLab/Easelbone/Utilities/Loader",["preloadjs","easeljs","CatLab/Easelbone/Utilities/Deferred"],(function(e,t,i){"use strict";var s=function(e){void 0===e&&(e={}),void 0===e.queue?this.queue=new t.LoadQueue(!1):this.queue=e.queue,this.queue.on("fileload",this.handleFileLoad.bind(this)),this.compositions=[],this.tasks=[]},o=s.prototype;return o.loadComposition=function(e,t){var i=e.getLibrary().properties.manifest;this.compositions.push(e),this.loadManifest(i,t)},o.loadAssets=function(e,t){return this.loadManifest(e.properties.manifest,t)},o.loadManifest=function(e,t){this.queue.loadManifest(e,!1,t)},o.handleFileLoad=function(e){"image"===e.item.type&&this.handleImageLoad(e.item.id,e.result)},o.task=function(e){this.tasks.push(e)},o.load=function(e){void 0===e&&(e={});var t=function(){};"function"==typeof e&&(t=e,e={}),"function"==typeof e.progress&&e.progress;var s=[];for(s.push(this.loadQueue());this.tasks.length>0;){var o=this.tasks.shift()();o&&s.push(o)}var n=i.when.apply(i,s);return n.then(function(){this.fixSpriteSheets(),t()}.bind(this)),n},o.loadQueue=function(){var e=new i;return this.queue.on("complete",(function(){e.resolve()}),this),this.queue.load(),e.promise()},o.handleImageLoad=function(e,t){this.compositions.forEach(function(i){i.getImages()[e]=t}.bind(this))},o.fixSpriteSheets=function(){this.compositions.forEach(function(e){var i=e.getLibrary();if(void 0!==i.ssMetadata)for(var s=e.getSpriteSheet(),o=i.ssMetadata,n=0;n0&&(m=this.findFromNames(t.join("."),m))}.bind(this)),m.length>0)return m;return m},t.buildNamedChildMap=function(e){if(void 0===e._mh_named_children_map){if(e._mh_named_children_map={},e._mh_timeline_label_map={},e.timeline)for(var i=e.timeline.getLabels(),n=0;n0)},t.pause=function(e){e.timeline&&(e.timeline._was_paused=e.timeline.paused,e.timeline.paused=!0),this.forEachNamedChild(e,function(e){this.pause(e)}.bind(this))},t.resume=function(e){e.timeline&&(e.timeline.paused=e.timeline._was_paused,delete e.timeline._was_paused),this.forEachNamedChild(e,function(e){this.resume(e)}.bind(this))},t.countLabeledFrames=function(e,i){this.buildNamedChildMap(i);var n=0;return i._mh_timeline_label_map&&i._mh_timeline_label_map[e]&&(n+=i._mh_timeline_label_map[e].length),n},t.jumpToFrame=function(e,i){var a=[];return i._mh_timeline_label_map&&i._mh_timeline_label_map[e]&&i._mh_timeline_label_map[e].forEach(function(i){a.push(this._jumpToFrameUntilFinished(e,i))}.bind(this)),n.when.apply(this,a)},t._jumpToFrameUntilFinished=function(e,i){var a=new n;return i.parent?(i.gotoAndPlay(e),i.timeline.on("complete",(function(){a.resolve()}))):a.resolve(),a.promise()},t.attach=function(e){var i=this,n=e.MovieClip.prototype;n.forEachNamedChild=function(e){return i.forEachNamedChild(this,e)},n.findNamedChildren=function(e){return i.findFromNames(e,this)},n.findPlaceholders=function(e){return i.findPlaceholders(e,this)},n.applySpriteFilters=function(e){return i.applySpriteFilters(e,this)},n.hasLabeledFrame=function(e){return i.hasLabeledFrame(e,this)},n.jumpToFrame=function(e){return i.jumpToFrame(e,this)}},new a})); +define("CatLab/Easelbone/EaselJS/DisplayObjects/Placeholder",["easeljs","CatLab/Easelbone/Utilities/CustomAttributes"],(function(i,e){var t=function(i){void 0!==i&&(this.initialize(),this.initializePlaceholder(i))};return(t.prototype=new i.Container).initializePlaceholder=function(t){if(t.easelPlaceholderInitialized)console.error("Element is already initialized as placeholder.",t);else{t.easelPlaceholderInitialized=!0;var n,a,s,d=this,l="0:0",h="0:0";if(e.forEach(function(i){Object.defineProperty(this,i,{get:function(){if(void 0!==t[i])return t[i]},set:function(e){console.log("setting",i,e)}})}.bind(this)),d.filters=t.filters,t.filters=[],t.uncache(),t.original_draw=t.draw,t.original_tick=t._tick,t.draw=function(i,e){return this.updateBounds(),this.updateZIndex(),t.original_draw.apply(t,arguments)},this.getBoundsHash=function(){return this.getBounds()?l=this.getBounds().width+":"+this.getBounds().height:null},this.hasBoundsChanged=function(){if(this.getBoundsHash()!==h)return h=l,!0},t._tick=function(){return t.parent&&t.parent.children&&this.updateZIndex(),t.original_tick.apply(t,arguments)},t.updateZIndex=function(){t.children&&(a=t.parent.getChildIndex(d),(s=t.parent.getChildIndex(t))+1!==a&&t.parent.addChildAt(d,s+1))},t.updateBounds=function(){d.setBounds(0,0,Math.ceil(100*this.scaleX),Math.ceil(100*this.scaleY)),d.x=this.x-this.regX*this.scaleX,d.y=this.y-this.regY*this.scaleY,d.rotation=this.rotation,d.hasBoundsChanged()&&(this.mask?d.mask=this.mask:this.originalMask&&(d.mask=this.originalMask),this.mask=!1,n=new i.Event("bounds:change"),d.dispatchEvent(n))},t.children)for(var r=0;r0&&(l=this.findFromNames(_.join("."),l))}.bind(this)),l.length>0)return l;return l},_.buildNamedChildMap=function(e){if(void 0===e._mh_named_children_map){if(e._mh_named_children_map={},e._mh_deep_named_children_map={},e._mh_timeline_label_map={},e.timeline)for(var i=e.timeline.getLabels(),n=0;n0)},_.pause=function(e){e.timeline&&(e.timeline._was_paused=e.timeline.paused,e.timeline.paused=!0),this.forEachNamedChild(e,function(e){this.pause(e)}.bind(this))},_.resume=function(e){e.timeline&&(e.timeline.paused=e.timeline._was_paused,delete e.timeline._was_paused),this.forEachNamedChild(e,function(e){this.resume(e)}.bind(this))},_.countLabeledFrames=function(e,i){this.buildNamedChildMap(i);var n=0;return i._mh_timeline_label_map&&i._mh_timeline_label_map[e]&&(n+=i._mh_timeline_label_map[e].length),n},_.jumpToFrame=function(e,i){var a=[];return i._mh_timeline_label_map&&i._mh_timeline_label_map[e]&&i._mh_timeline_label_map[e].forEach(function(i){a.push(this._jumpToFrameUntilFinished(e,i))}.bind(this)),n.when.apply(this,a)},_._jumpToFrameUntilFinished=function(e,i){var a=new n;return i.parent?(i.gotoAndPlay(e),i.timeline.on("complete",(function(){a.resolve()}))):a.resolve(),a.promise()},_.attach=function(e){var i=this,n=e.MovieClip.prototype;n.forEachNamedChild=function(e){return i.forEachNamedChild(this,e)},n.findNamedChildren=function(e){return i.findFromNames(e,this)},n.findPlaceholders=function(e){return i.findPlaceholders(e,this)},n.applySpriteFilters=function(e){return i.applySpriteFilters(e,this)},n.hasLabeledFrame=function(e){return i.hasLabeledFrame(e,this)},n.jumpToFrame=function(e){return i.jumpToFrame(e,this)}},new a})); define("CatLab/Easelbone/Views/Base",["backbone","easeljs","CatLab/Easelbone/Utilities/GlobalProperties","CatLab/Easelbone/Utilities/MovieClipHelper"],(function(e,t,i,r){"use strict";return e.View.extend({el:"div",easelScreen:null,setRootView:function(e){this.set("root",e)},getWidth:function(){return this.getStage().canvas.width},getHeight:function(){return this.getStage().canvas.height},getStage:function(){return void 0!==this.el.stage?this.el.stage:void 0!==this.el.getStage?this.el.getStage():void 0},setScreen:function(e){return this.easelScreen=e,this},getScreen:function(){return this.easelScreen},hasLabeledFrame:function(e,t){if(void 0===t&&(t=this.easelScreen),!t)throw new Error("hasLabeledFrame requires a screen to be set or a container to be provided.");return r.hasLabeledFrame(e,t)},jumpToFrame:function(e,t){if(void 0===t&&(t=this.easelScreen),!t)throw new Error("hasLabeledFrame requires a screen to be set or a container to be provided.");return r.jumpToFrame(e,t)},pause:function(e){if(void 0===e&&(e=this.easelScreen),!e)throw new Error("pause requires a screen to be set or a container to be provided.");return r.pause(this.easelScreen)},resume:function(e){if(void 0===e&&(e=this.easelScreen),!e)throw new Error("resume requires a screen to be set or a container to be provided.");return r.resume(this.easelScreen)},scale:function(e){var t=this.getScale();e.scaleX=t.x,e.scaleY=t.y},getScale:function(e,t,r){null==e&&(e=i.getWidth()),null==t&&(t=i.getHeight()),void 0===r&&(r=!1);var n=this.getWidth()/e,a=this.getHeight()/t,s=r?Math.max(n,a):Math.min(n,a);return{x:s,y:s}},addCenter:function(e,r,n,a,s){null==r&&(r=i.getWidth()),null==n&&(n=i.getHeight()),null==s&&(s=1);var h=this.getScale(r,n,a),o=!0;if(this.getWidth()===r&&this.getHeight()===n&&(o=!1),o&&(h.x=h.x*s,h.y=h.y*s,e.x=(this.getWidth()-r*h.x)/2,e.y=(this.getHeight()-n*h.y)/2,e.scaleX=h.x,e.scaleY=h.y),this.el.addChild(e),o){var l=new t.Graphics;e.x>=1&&(l.beginFill(this.getBackground()).drawRect(0,0,Math.ceil(e.x),this.getHeight()),l.beginFill(this.getBackground()).drawRect(this.getWidth()-Math.ceil(e.x),0,Math.ceil(e.x),this.getHeight())),e.y>=1&&(l.beginFill(this.getBackground()).drawRect(0,0,this.getWidth(),Math.ceil(e.y)),l.beginFill(this.getBackground()).drawRect(0,this.getHeight()-Math.ceil(e.y),this.getWidth(),Math.ceil(e.y)));var c=new t.Shape(l);this.el.addChild(c)}},clear:function(){this.el.removeAllChildren();var e=new t.Graphics;e.beginFill(this.getBackground()).drawRect(0,0,this.getWidth(),this.getHeight());var i=new t.Shape(e);this.el.addChild(i)},getBackground:function(){return"#000000"},render:function(){if(this.easelScreen)return this.addCenter(this.easelScreen),this;var e=new t.Container;e.setBounds(0,0,this.getWidth(),this.getHeight());var i=new t.BigText("easelbone view: no screen set and render function was not overridden...","Arial","#000000");e.addChild(i),this.el.addChild(e)},findPlaceholders:function(e,t){return void 0===t&&(t=[],this.easelScreen&&t.push(this.easelScreen)),r.findPlaceholders(e,t)},findTextPlaceholders:function(e,t){return this.findPlaceholdersPreferPostfix(e,t,"text")},findPlaceholdersPreferPostfix:function(e,t,i){var r=[];return Array.isArray(e)?e.forEach((function(e){r.push(e+".text"),r.push(e)})):(r.push(e+".text"),r.push(e)),this.findPlaceholders(r,t)},findFromNames:function(e,t){return void 0===t&&(t=[],this.easelScreen&&t.push(this.easelScreen)),r.findFromNames(e,t)},findFromNameInContainer:function(e,t,i){return r.findFromNameInContainer(e,t,i)},forEachNamedChild:function(e,t){return r.forEachNamedChild(e,t)},tick:function(){return!0},afterRender:function(){},onRemove:function(){},scrollIntoView:function(e){for(var t=e;t.parent;){if(void 0!==t._parentScrollArea)return void t._parentScrollArea.focus(e,200);t=t.parent}}})})); define("CatLab/Easelbone/Views/LoadingView",["CatLab/Easelbone/Views/Base"],(function(t){"use strict";var e=new Image;e.crossOrigin="anonymous",e.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAWCAYAAAA1vze2AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH3wMRCycoY5y7DgAAAeBJREFUSMel1j9sTlEYBvD3fv2DIqmmmmjTBSXVkYSBhAixWNRmMYvBgMZQSUeLQWIw2hqLWIRBYpCIQYcyYDBJNAQpBk21P8u5cdzcfv1835Pc3JznOed9zn3f95zciCbAAbzEIk5VtI04jxmMRzvAKD76i1VszvSZTFvESDsmk1jxLyYz/UtFu7pWrEYTn9EafUcyGIiIgYo23o5Jdw23kt79NVrR1AQNbEEe+F0WtMSLiIiiKN5HxGqdluL1oB89JdGFabzGLWxKfB9ms5zfqdTsYqbNoT+LN5tqdq+cfLrSQUcrOxrGCLoqJg1sxxg2ZPyZSsNcCTyvdMlUdABMpc2W+NyIiP2VecMtBjuMEzVSX2U82B0RSxHRk5H5gTsbEbcjYig1wpuI2BoRx7I5cxFxqCiK5URtq3SawINKui6nxfvwU2u4npneqGjzkQr3LRFPMZil40eLJnfLxsAQHuErHpfx1sr5Xnxq0WS6Wf2anfhzKb/r4XeqVcvt14sL//EFJZ6Uh3g9gzF80D7u4yQm1rzU8DYi9kRnWE333WBRFN/rarIQnaMREb/SU5uu3VjWOS6haFaX41iqWbjQosE8eltpgAk8TKf9FXYl/kgawzMcTPxOXMPN/B8gxx+XbHMxap3gAwAAAABJRU5ErkJggg==";var i=0,s={x:{start:0,end:100},y:{start:0,end:100}},a={x:s.x.end/2,y:s.y.end/2},n=[],h=!1;return t.extend({initialize:function(t){this.gameVersion=null,void 0!==t.gameVersion&&(this.gameVersion=t.gameVersion),this.dRotation=0,this.speed=10,this.angle=Math.random()*Math.PI*2,this.targetAngle=null,this.flippedX=!1,this.flippedY=!1,this.rotationSpeedRad=.2,this.screenMargin=50},render:function(){s={x:{start:0,end:this.el.stage.canvas.width},y:{start:0,end:this.el.stage.canvas.height}},this.loadingText=new createjs.Text("Loading","15px monospace","#ffffff"),this.loadingText.textAlign="center",this.loadingText.lineHeight=20,this.el.addChild(this.loadingText),this.versionText=null,this.gameVersion&&(this.versionText=new createjs.Text("v"+this.gameVersion,"12px monospace","#ffffff"),this.el.addChild(this.versionText),this.versionText.cache(-100,-100,200,200),this.loadingText.cache(-100,-100,200,200)),this.el.setBounds(0,0,this.el.stage.canvas.width,this.el.stage.canvas.height),this.updatePositions(),a={x:Math.random()*(s.x.end-2*this.screenMargin)+this.screenMargin,y:Math.random()*(s.y.end-2*this.screenMargin)+this.screenMargin}},tick:function(){this.updatePositions();var t=this.angle;null!==this.targetAngle&&(t=this.targetAngle),(a.xs.x.end-this.screenMargin&&Math.cos(t)>0)&&(this.targetAngle=Math.PI-t),(a.ys.y.end-this.screenMargin&&Math.sin(t)>0)&&(this.targetAngle=2*Math.PI-t),null!==this.targetAngle&&(this.targetAngle-this.angle>this.rotationSpeedRad?this.angle+=this.rotationSpeedRad:this.targetAngle-this.angle<0-this.rotationSpeedRad?this.angle-=this.rotationSpeedRad:this.targetAngle=null);var e=Math.cos(this.angle)*this.speed,h=Math.sin(this.angle)*this.speed;a.x+=e,a.y+=h,++i%6==0&&this.addPaw();for(var r=0;r0&&g.push(n[r]);return n=g,!0},updatePositions:function(){this.loadingText.x=this.el.getBounds().width/2,this.loadingText.y=this.el.getBounds().height/2,this.versionText&&(this.versionText.x=this.el.getBounds().width-60,this.versionText.y=this.el.getBounds().height-20)},stop:function(){},start:function(){},addPaw:function(){var t=10;(h=!h)&&(t*=-1);var i=new createjs.Bitmap(e),s=this.angle;i.regX=10,i.regY=10,i.x=a.x+Math.cos(s+Math.PI/2)*t,i.y=a.y+Math.sin(s+Math.PI/2)*t,i.scaleX=20/e.width,i.scaleY=20/e.height,i.rotation=(s+Math.PI/2)*(180/Math.PI),this.el.addChild(i),n.push(i)},setProgress:function(t){t=Math.floor(100*t),this.loadingText.text="Loading\n"+t+"%",this.loadingText.cache(-100,-100,200,200)}})})); define("CatLab/Easelbone/Views/Layer",["easeljs","underscore","backbone","CatLab/Easelbone/Utilities/Deferred"],(function(e,i,t,n){var r=function(n){i.extend(this,t.Events),void 0===n&&(n={}),void 0!==n.container?this.container=n.container:this.container=new e.Container,this.view=null};return r.prototype.setView=function(i){var t=this.view;this.view=i;var n=new e.Container;this.view.setElement(n),this.container.addChild(n),this.view.on("all",function(e){this.trigger("view:"+e)}.bind(this)),this.view.trigger("stage:added"),t&&this.container.children.length>0&&this.container.setChildIndex(t.el,this.container.children.length-1),t&&this._destroyView(t).then((function(){t=null}))},r.prototype.clearView=function(){this.view&&this._destroyView(this.view).pipe(function(){this.view=null}.bind(this))},r.prototype._destroyView=function(e){return this._waitForViewDestroy(e).pipe(function(){null!==e&&(e.trigger("stage:removed"),this.container.removeChild(e.el),e=null)}.bind(this))},r.prototype._waitForViewDestroy=function(e){var i=new n;return e&&void 0!==e.hasLabeledFrame&&void 0!==e.easelScreen&&e.easelScreen&&e.hasLabeledFrame("view:destroy")?(e.jumpToFrame("view:destroy").then((function(){i.resolve()})),i.promise()):(i.resolve(),i.promise())},r.prototype.render=function(){this.view&&(this.view.el.removeAllChildren(),this.view.trigger("render:before"),this.view.render(),this.view.trigger("render"),this.view.trigger("render:after"))},r.prototype.tick=function(e){return!!this.view&&this.view.tick(e)},r})); @@ -14,7 +14,7 @@ define("CatLab/Easelbone/Utilities/Path",[],(function(){var t,i=function(t,i){th define("CatLab/Easelbone/Controls/Slider",["CatLab/Easelbone/Controls/Base","CatLab/Easelbone/Utilities/Path"],(function(t,e){var i=function(t){var i;this.element=t,this.step=.1,this.path=new e(this.element.minimum,this.element.maximum),this.setValue(.5),this.element.pointer.on("pressmove",function(t){i=this.element.globalToLocal(t.stageX,t.stageY),this.setValue(this.path.getValue(i.x,i.y))}.bind(this)),this.element.pointer.on("click",(function(t){t.stopPropagation()})),this.element.on("click",function(t){i=this.element.globalToLocal(t.stageX,t.stageY),this.setValue(this.path.getValue(i.x,i.y))}.bind(this))};return(i.prototype=Object.create(t.prototype)).constructor=i,i.prototype.link=function(t,e){return this.setValue(t.get(e)),this},i.prototype.setValue=function(t){this.value=t,this.path.position(this.element.pointer,this.value)},i.prototype.keyInput=function(t){switch(t){case"up":this.value=Math.min(1,this.value+this.step);break;case"down":this.value=Math.max(0,this.value-this.step)}this.setValue(this.value)},i})); define("CatLab/Easelbone/Controls/Checkbox",["CatLab/Easelbone/Controls/Base"],(function(t){var e=function(e){t.call(this,e),this.element=e,this.element.addEventListener("click",function(){this.toggle()}.bind(this))};return(e.prototype=Object.create(t.prototype)).constructor=e,e.prototype.toggle=function(){this.checked=!this.checked,this.update(),this.trigger("update",this.checked)},e.prototype.check=function(){this.checked=!0,this.update(),this.trigger("update",this.checked)},e.prototype.uncheck=function(){this.checked=!1,this.update(),this.trigger("update",this.checked)},e.prototype.keyInput=function(t){switch(t){case"a":case"start":this.toggle()}},e})); define("CatLab/Easelbone/EaselJS/DisplayObjects/EmojiText",["easeljs"],(function(e){String.fromCharCode(8205);var t={},i={},r=e.Text;function s(e,t,i){this.Text_constructor(e,t,i),this._additionalEmojis={},this._lastReplacedText=null,this._lastReplacedResult=null,this.snapToPixel=!0}s.setEmojis=function(e){i=e};var n=e.extend(s,r);return n.setEmojis=function(e){this._additionalEmojis=e},n._drawText=function(e,t,i){var s=!!e;s||((e=r._workingContext).save(),this._prepContext(e));for(var n=this.lineHeight||this.getMeasuredLineHeight(),a=0,h=0,o=this._replaceEmojis(String(this.text)).split(/(?:\r\n|\r|\n)/),l=0,d=null!=this.lineWidth,u=this.lineWidth,m=0,c=o.length;mu){for(var j=this._splitWords(f),w=new Array(j.length),p=0;pu?(s&&(this._drawLineWithEmoji(e,f,h*n,l,n),l+=f.length+1),i&&i.push(f),g>a&&(a=g),f=j[E+1]||"",g=w[E+1]||0,h++):(f+=j[E]+(j[E+1]||""),g+=x)}}s?(_=this._drawLineWithEmoji(e,f,h*n,l,n),l+=f.length+1):_=null==g?e.measureText(f).width:g,i&&i.push(f),_>a&&(a=_),h++}return t&&(t.width=a,t.height=h*n),s||e.restore(),t},n._drawLineWithEmoji=function(e,t,i,s,n){if(this._drawTextLine(e,t,i),0===this._emoji.length)return e.measureText(t).width;var a=e.measureText(t).width,h=r.H_OFFSETS[this.textAlign||"left"];for(var o in this._emoji)o=parseInt(o),this._emoji.hasOwnProperty(o)&&o>=s&&o500||((o=this.createTextObject(t,n,this._font,this._color)).lineWidth=i,o.lineHeight=b(o,this._font),p(o),g.height500||((o=this.createTextObject(t,n,this._font,this._color)).lineWidth=i,o.lineHeight=b(o,this._font),p(o),f.height40?this.previous():this.next()}.bind(this)),this.convertText()};return(l.prototype=Object.create(e.prototype)).constructor=l,l.prototype.setText=function(e,t,s){var l=new this.textcontainer(e,t,s);this.textElement.removeAllChildren(),this.textElement.addChild(l)},l.prototype.convertText=function(){this.textElement=new s(this.element.value)},l.prototype.setValues=function(e){var t=[];if(e instanceof Array){for(var s=0;sthis.values.length-1||(this.selectedIndex=e,this.selectedValue=this.values[this.selectedIndex],this.setText(this.selectedValue.text))},l.prototype.getIndexFromText=function(e){for(var t=0;t0?this.select(this.selectedIndex-1):this.repeat&&this.select(this.allValues.length-1)},l.prototype.keyInput=function(e){switch(e){case"up":this.next();break;case"down":this.previous()}},Object.defineProperty(l.prototype,"text",{get:function(){return this.selectedValue.text},set:function(e){var t=this.getIndexFromText(e);null!==t&&(this.index=t)}}),Object.defineProperty(l.prototype,"value",{get:function(){return this.selectedValue.value},set:function(e){var t=this.getIndexFromValue(e);null!==t&&(this.index=t)}}),Object.defineProperty(l.prototype,"index",{get:function(){return this.selectedIndex},set:function(e){this.select(e)}}),Object.defineProperty(l.prototype,"values",{get:function(){return this.allValues},set:function(e){this.setValues(e)}}),l})); @@ -26,7 +26,7 @@ define("CatLab/Easelbone/Controls/ListElement",[],(function(){var t=function(t){ define("CatLab/Easelbone/Controls/List",["easeljs","CatLab/Easelbone/Controls/ListElement"],(function(t,e){var n=function(t){this.initialize(),this.listItems=[],void 0!==t&&this.setChildElement(t)},i=n.prototype=new t.Container;return i.setChildElement=function(t){this.childElement=t;var e=new t;this.boundary={x:e.boundary.x,y:e.boundary.y}},i.getChildElement=function(){if(void 0===this.childElement)throw"No child element set.";return this.childElement},i.updateBounds=function(){this.setBounds(0,0,this.boundary.x,this.boundary.y*this.listItems.length)},i.createElement=function(){var t=new e(new(this.getChildElement()));return this.listItems.push(t),this.addChild(t.element),t.element.y=this.boundary.y*(this.listItems.length-1),this.updateBounds(),t},n})); define("CatLab/Easelbone/Controls/FloatContainer",["easeljs","CatLab/Easelbone/Controls/ListElement"],(function(t,e){var i=function(t,e){this.initialize(),this.listItems=[],void 0!==t&&this.setChildElement(t),this.rows=0,this.columns=e,this.currentColumn=0,this.curX=0,this.curY=0,this.rowHeight=0},n=i.prototype=new t.Container;return n.setChildElement=function(t){this.childElement=t;var e=this.getChildElement(null,this.listItems.length);this.boundary={x:e.boundary.x,y:e.boundary.y},this.rowHeight=this.boundary.y},n.getChildElement=function(e,i){if(void 0===this.childElement)throw"No child element set.";return this.childElement.prototype instanceof t.DisplayObject?new this.childElement:this.childElement(e)},n.updateBounds=function(){this.setBounds(0,0,this.boundary.x*this.columns,this.curY+this.rowHeight)},n.nextRow=function(){this.currentColumn=1,this.rows++,this.curY+=this.rowHeight,this.rowHeight=0},n.getNextPosition=function(){var t={};return this.currentColumn++,this.currentColumn>this.columns&&this.nextRow(),t.x=this.boundary.x*(this.currentColumn-1),t.y=this.curY,t},n.createElement=function(t){var i=new e(this.getChildElement(t,this.listItems.length));this.listItems.push(i),this.addChild(i.element);var n=this.getNextPosition();return this.rowHeight=Math.max(this.rowHeight,i.getDimensions().height),i.element.x=n.x,i.element.y=n.y,this.updateBounds(),i},n.removeAllChildren_container=n.removeAllChildren,n.removeAllChildren=function(){this.currentColumn=0,this.rows=0,this.curY=0,this.listItems=[],this.removeAllChildren_container.apply(this,arguments)},i})); define("CatLab/Easelbone/Controls/GridFill",["easeljs"],(function(i){var t=function(i){this.initialize(),this.placeholder=i,this.grid=[],this.floaters=[],this.rows=0,this.columns=0,this.paddingX=0,this.paddingY=0,this.forceRatio=null,this.cellSize=null,this.cellEvents={},this.placeholder.on("bounds:change",function(){this.redrawGrid()}.bind(this)),this.placeholder.on("tick",function(){this.update()}.bind(this))},e=t.prototype=new i.Container;return e.set=function(i,t,e){return void 0===this.grid[t]&&(this.grid[t]=[]),this.grid[t][i]=e,this.resetSize(),this},e.float=function(i,t,e,n,s){void 0===n&&(n=0),void 0===s&&(s=0),e.gx=i,e.gy=t;var h={ox:n,oy:s,e:e};return this.floaters.push(h),h},e.removeFloat=function(i){var t=this.floaters.findIndex((function(t){return t.e===i}));t>-1&&this.floaters.splice(t,1)},e.clearFloats=function(i,t){for(var e=0;ethis.forceRatio?(t=e*this.forceRatio,n=(i.width-t*this.columns)/2):h0?this.findAttributeInParents(i,t,e.parent):void 0:null},o.applyFilterCacheInParents=function(i,t){if(void 0===t&&(t=this),!t.parent)return null;if(t.parent.filters){var e=t.parent.getBounds();e&&t.parent.cache(e.x,e.y,e.width,e.height)}return i>0?this.applyFilterCacheInParents(i,t.parent):void 0},i.Background=l,l})); +define("CatLab/Easelbone/EaselJS/DisplayObjects/Background",["easeljs"],(function(i){var t,e,s,a,h=!1,n={},l=function(t,e){if(void 0===e&&(e={zoom:"stretch",horizontalAlign:"center",verticalAlign:"center"}),this.fillOptions=e,this.limits=null,this.initialized=!1,this.debug=!1,this.childBounds=null,t instanceof Image||t instanceof HTMLImageElement)this.displayobject=new i.Bitmap(t);else if(t instanceof i.DisplayObject){if(!t.getBounds())throw"Objects to be filled must have bounds set.";var s=t.getBounds();this.childBounds={width:s.width,height:s.height},this.displayobject=t}else this.color=t;this.initialize()},r=l.prototype=new i.Container;return r.Container_initialize=r.initialize,r.initialize=function(){this.Container_initialize()},r.getChildBounds=function(){if(this.childBounds)return this.childBounds;var i=this.displayobject.getBounds();return i?{width:i.width,height:i.height}:null},r.isVisible=function(){return!0},r.setLimits=function(i,t){this.limits={width:i,height:t}},r.getAvailableSpace=function(){return null!==this.limits?this.limits:(this.parent?(a=this.parent.getBounds())&&(t=a.width,e=a.height):(a=this.getBounds())?(t=a.width,e=a.height):(t=100,e=100),{width:t,height:e})},r.Container_draw=r.draw,r.getLocationHash=function(){return s=this.getAvailableSpace(),Math.floor(s.width)+":"+Math.floor(s.height)},r.hasChanged=function(){return s=this.getLocationHash(),h=this.lastHash!==s,this.lastHash=s,h},r.align=function(i){if(this.displayobject){var t=this.getChildBounds();if(t){var e=this.fillOptions.horizontalAlign||"center",s=this.fillOptions.verticalAlign||"center";switch(e){case"left":this.displayobject.x=0;break;case"right":this.displayobject.x=i.width-t.width*this.displayobject.scaleX;break;case"center":default:this.displayobject.x=(i.width-t.width*this.displayobject.scaleX)/2}switch(s){case"top":this.displayobject.y=0;break;case"bottom":this.displayobject.y=i.height-t.height*this.displayobject.scaleY;break;case"center":default:this.displayobject.y=(i.height-t.height*this.displayobject.scaleY)/2}}}},r.draw=function(t,e){if(this.initialized&&!this.hasChanged())return this.Container_draw(t,e);this.initialized=!0,this.removeAllChildren();var s=this.getAvailableSpace();if(this.color){var a=new i.Shape;a.graphics.setStrokeStyle(0),a.graphics.beginFill(this.color),a.graphics.beginStroke(this.color),a.snapToPixel=!0,a.graphics.drawRect(0,0,s.width,s.height),this.addChild(a)}else if(this.displayobject){try{if(!this.getChildBounds())return void(this.initialized=!1)}catch(i){return void(this.initialized=!1)}var h=this.getChildBounds();n={x:s.width/h.width,y:s.height/h.height};var l=this.fillOptions.zoom,r=this.findAttributeInParents("zoomStrategy",3);switch(r&&(l=r),l){case"minimum":this.displayobject.scaleX=this.displayobject.scaleY=Math.min(n.x,n.y),this.align(s);break;case"maximum":this.displayobject.scaleX=this.displayobject.scaleY=Math.max(n.x,n.y),this.align(s);break;case"stretch":case"default":this.displayobject.scaleX=n.x,this.displayobject.scaleY=n.y}this.addChild(this.displayobject)}return this.applyFilterCacheInParents(5),this.Container_draw(t,e)},r.findAttributeInParents=function(i,t,e){return void 0===e&&(e=this),e.parent?e.parent[i]?e.parent[i]:t>0?this.findAttributeInParents(i,t,e.parent):void 0:null},r.applyFilterCacheInParents=function(i,t){if(void 0===t&&(t=this),!t.parent)return null;if(t.parent.filters){var e=t.parent.getBounds();e&&t.parent.cache(e.x,e.y,e.width,e.height)}return i>0?this.applyFilterCacheInParents(i,t.parent):void 0},i.Background=l,l})); define("CatLab/Easelbone/EaselJS/Filters/ColorSwapFilter",["easeljs"],(function(r){function e(r,e){this.Filter_constructor(),t.color=r,t.replaceColor=e}var t=r.extend(e,r.Filter);function o(r){var e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}return t._applyFilter=function(r){for(var e=r.data,t=this.color,n=[],a=[],i=0;i