From 357bc4eb893eecf3650bf1995add6ca6c42b9831 Mon Sep 17 00:00:00 2001 From: John Foster Date: Sat, 16 Dec 2023 16:15:23 -0800 Subject: [PATCH] Update build scripts --- .gitignore | 2 + bower.json | 2 +- build/Gruntfile.js | 3 +- build/package.json | 2 +- lib/easeljs.js | 3765 ++++++++++++++++++++++++++++---------------- lib/easeljs.min.js | 9 +- package.json | 2 +- tests/package.json | 10 +- 8 files changed, 2455 insertions(+), 1340 deletions(-) diff --git a/.gitignore b/.gitignore index 937166869..695443f40 100644 --- a/.gitignore +++ b/.gitignore @@ -10,11 +10,13 @@ node_modules/ *.sublime-project *.sublime-workspace config.local.json +*.zip *[\<\>\:\"\/\\\|\?\*]* npm-debug.log build/.sass-cache main.css +main.css.map spikes yarn.lock package-lock.json \ No newline at end of file diff --git a/bower.json b/bower.json index d3b535ace..27c78b63a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "EaselJS", - "version": "1.0.0", + "version": "1.0.4", "homepage": "https://github.com/CreateJS/EaselJS", "authors": [ "gskinner", diff --git a/build/Gruntfile.js b/build/Gruntfile.js index 47fe94931..587f9022f 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -148,8 +148,7 @@ module.exports = function (grunt) { sass: { docs: { options: { - style: 'compressed', - sourcemap:"none" + style: 'compressed' }, files: { 'createjsTheme/assets/css/main.css': 'createjsTheme/assets/scss/main.scss' diff --git a/build/package.json b/build/package.json index f21bc019f..242e235f9 100644 --- a/build/package.json +++ b/build/package.json @@ -1,6 +1,6 @@ { "name": "EaselJS", - "version": "1.0.0", + "version": "1.0.4", "description": "EaselJS Docs", "url": "http://www.createjs.com/easeljs", "logo": "assets/docs-icon-EaselJS.png", diff --git a/lib/easeljs.js b/lib/easeljs.js index d28e13489..d8982e0ba 100644 --- a/lib/easeljs.js +++ b/lib/easeljs.js @@ -261,8 +261,8 @@ this.createjs = this.createjs||{}; * rely on an event object's state outside of the call stack it was received in. * @class Event * @param {String} type The event type. - * @param {Boolean} bubbles Indicates whether the event will bubble through the display list. - * @param {Boolean} cancelable Indicates whether the default behaviour of this event can be cancelled. + * @param {Boolean} [bubbles=false] Indicates whether the event will bubble through the display list. + * @param {Boolean} [cancelable=false] Indicates whether the default behaviour of this event can be cancelled. * @constructor **/ function Event(type, bubbles, cancelable) { @@ -381,7 +381,7 @@ this.createjs = this.createjs||{}; // public methods: /** - * Sets {{#crossLink "Event/defaultPrevented"}}{{/crossLink}} to true if the event is cancelable. + * Sets {{#crossLink "Event/defaultPrevented:property"}}{{/crossLink}} to true if the event is cancelable. * Mirrors the DOM level 2 event standard. In general, cancelable events that have `preventDefault()` called will * cancel the default behaviour associated with the event. * @method preventDefault @@ -391,7 +391,7 @@ this.createjs = this.createjs||{}; }; /** - * Sets {{#crossLink "Event/propagationStopped"}}{{/crossLink}} to true. + * Sets {{#crossLink "Event/propagationStopped:property"}}{{/crossLink}} to true. * Mirrors the DOM event standard. * @method stopPropagation **/ @@ -400,8 +400,8 @@ this.createjs = this.createjs||{}; }; /** - * Sets {{#crossLink "Event/propagationStopped"}}{{/crossLink}} and - * {{#crossLink "Event/immediatePropagationStopped"}}{{/crossLink}} to true. + * Sets {{#crossLink "Event/propagationStopped:property"}}{{/crossLink}} and + * {{#crossLink "Event/immediatePropagationStopped:property"}}{{/crossLink}} to true. * Mirrors the DOM event standard. * @method stopImmediatePropagation **/ @@ -1127,6 +1127,12 @@ this.createjs = this.createjs||{}; if (!Ticker._inited) { return; } Ticker._setupTick(); }; + + /** + * Use the {{#crossLink "Ticker/interval:property"}}{{/crossLink}} property instead. + * @method setInterval + * @deprecated + */ // Ticker.setInterval is @deprecated. Remove for 1.1+ Ticker.setInterval = createjs.deprecate(Ticker._setInterval, "Ticker.setInterval"); @@ -1140,6 +1146,12 @@ this.createjs = this.createjs||{}; Ticker._getInterval = function() { return Ticker._interval; }; + + /** + * Use the {{#crossLink "Ticker/interval:property"}}{{/crossLink}} property instead. + * @method getInterval + * @deprecated + */ // Ticker.getInterval is @deprecated. Remove for 1.1+ Ticker.getInterval = createjs.deprecate(Ticker._getInterval, "Ticker.getInterval"); @@ -1153,6 +1165,12 @@ this.createjs = this.createjs||{}; Ticker._setFPS = function(value) { Ticker._setInterval(1000/value); }; + + /** + * Use the {{#crossLink "Ticker/framerate:property"}}{{/crossLink}} property instead. + * @method setFPS + * @deprecated + */ // Ticker.setFPS is @deprecated. Remove for 1.1+ Ticker.setFPS = createjs.deprecate(Ticker._setFPS, "Ticker.setFPS"); @@ -1166,6 +1184,12 @@ this.createjs = this.createjs||{}; Ticker._getFPS = function() { return 1000/Ticker._interval; }; + + /** + * Use the {{#crossLink "Ticker/framerate:property"}}{{/crossLink}} property instead. + * @method getFPS + * @deprecated + */ // Ticker.getFPS is @deprecated. Remove for 1.1+ Ticker.getFPS = createjs.deprecate(Ticker._getFPS, "Ticker.getFPS"); @@ -1293,7 +1317,7 @@ this.createjs = this.createjs||{}; * @method getEventTime * @static * @param runTime {Boolean} [runTime=false] If true, the runTime property will be returned instead of time. - * @returns {number} The time or runTime property from the most recent tick event or -1. + * @return {number} The time or runTime property from the most recent tick event or -1. */ Ticker.getEventTime = function(runTime) { return Ticker._startTime ? (Ticker._lastTime || Ticker._startTime) - (runTime ? Ticker._pausedTime : 0) : -1; @@ -1438,7 +1462,7 @@ this.createjs = this.createjs||{}; * this issue by drawing each frame to an off-screen canvas and preserving the prior frame during a seek. * * var myBuffer = new createjs.VideoBuffer(myVideo); - * var myBitmap = new Bitmap(myBuffer); + * var myBitmap = new createjs.Bitmap(myBuffer); * * @class VideoBuffer * @param {HTMLVideoElement} video The HTML video element to buffer. @@ -1612,9 +1636,12 @@ this.createjs = this.createjs||{}; this.primary = !!primary; /** - * The secondary target for the event, if applicable. This is used for mouseout/rollout - * events to indicate the object that the mouse entered from, mouseover/rollover for the object the mouse exited, - * and stagemousedown/stagemouseup events for the object that was the under the cursor, if any. + * The secondary target for the event, if applicable. This is used for {{#crossLink "DisplayObject/mouseout:event"}}{{/crossLink}}/ + * {{#crossLink "DisplayObject/rollout:event"}}{{/crossLink}} + * events to indicate the object that the mouse entered from, {{#crossLink "DisplayObject/rollover:event"}}{{/crossLink}}/ + * {{#crossLink "DisplayObject/rollover:event"}}{{/crossLink}} for the object the mouse exited, + * and {{#crossLink "Stage/stagemousedown:event"}}{{/crossLink}}/{{#crossLink "Stage/stagemouseup:event"}}{{/crossLink}} + * events for the object that was the under the cursor, if any. * * Only valid interaction targets will be returned (ie. objects with mouse listeners or a cursor set). * @property relatedTarget @@ -1997,7 +2024,7 @@ this.createjs = this.createjs||{}; /** * Applies a clockwise rotation transformation to the matrix. * @method rotate - * @param {Number} angle The angle to rotate by, in degrees. To use a value in radians, multiply it by `180/Math.PI`. + * @param {Number} angle The angle to rotate by, in degrees. To use a value in radians, multiply it by `Math.PI/180`. * @return {Matrix2D} This matrix. Useful for chaining method calls. **/ p.rotate = function(angle) { @@ -2018,7 +2045,7 @@ this.createjs = this.createjs||{}; /** * Applies a skew transformation to the matrix. * @method skew - * @param {Number} skewX The amount to skew horizontally in degrees. To use a value in radians, multiply it by `180/Math.PI`. + * @param {Number} skewX The amount to skew horizontally in degrees. To use a value in radians, multiply it by `Math.PI/180`. * @param {Number} skewY The amount to skew vertically in degrees. * @return {Matrix2D} This matrix. Useful for chaining method calls. */ @@ -2384,12 +2411,14 @@ this.createjs = this.createjs||{}; * X position. * @property x * @type Number + * @default 0 **/ /** * Y position. * @property y * @type Number + * @default 0 **/ } var p = Point.prototype; @@ -2409,6 +2438,69 @@ this.createjs = this.createjs||{}; return this; }; + /** + * Offsets the Point object by the specified amount. + * + * @method offset + * @param {Number} dx The amount by which to offset the horizontal coordinate, `x`. + * @param {Number} dy The amount by which to offset the vertical coordinate, `y`. + * @return {Point} This instance. Useful for chaining method calls. + * @chainable + */ + p.offset = function(dx, dy) { + this.x += dx; + this.y += dy; + return this; + }; + + /** + * Converts a pair of polar coordinates to a Cartesian point coordinate. + * @method polar + * @param {Number} len The length coordinate of the polar pair. + * @param {Number} angle The angle, in radians, of the polar pair. + * @param {Point | Object} [pt] An object to copy the result into. If omitted a new {{#crossLink "Point"}}{{/crossLink}} + * will be returned. + * @return {Point} The new, interpolated point. + * @static + */ + Point.polar = function(len, angle, pt) { + pt = pt||new Point(); + pt.x = len * Math.cos(angle); + pt.y = len * Math.sin(angle); + return pt; + }; + + /** + * Determine a point between two specified points. + * + * The parameter `f` determines where the new interpolated point is located relative to the two end points specified + * by parameters `pt1` and `pt2`: + * + * @method interpolate + * @param {Point | Object} pt1 The first point as a Point or generic object. + * @param {Point | Object} pt2 The second point as a Point or generic object. + * @param {Number} f The level of interpolation between the two points. Indicates where the new point will be, along + * the line between `pt1` and `pt2`. If `f=1`, `pt1` is returned; if `f=0`, `pt2` is returned. + * @param {Point | Object} [pt] An object to copy the result into. If omitted, a new {{#crossLink "Point"}}{{/crossLink}} + * will be returned. + * @return {Point} A new interpolated Point, or the `pt` passed in the 4th parameter with the interpolated values. + * @static + */ + Point.interpolate = function(pt1, pt2, f, pt) { + pt = pt || new Point(); + pt.x = pt2.x + f * (pt1.x - pt2.x); + pt.y = pt2.y + f * (pt1.y - pt2.y); + return pt; + }; + /** * Copies all properties from the specified point to this point. * @method copy @@ -2803,6 +2895,12 @@ this.createjs = this.createjs||{}; if (o.__reset) { o._reset = o.__reset; delete(o.__reset); } } }; + + /** + * Use the {{#crossLink "ButtonHelper/enabled:property"}}{{/crossLink}} property instead. + * @method setEnabled + * @deprecated + */ // ButtonHelper.setEnabled is @deprecated. Remove for 1.1+ p.setEnabled = createjs.deprecate(p._setEnabled, "ButtonHelper.setEnabled"); @@ -2815,6 +2913,12 @@ this.createjs = this.createjs||{}; p._getEnabled = function() { return this._enabled; }; + + /** + * Use the {{#crossLink "ButtonHelper/enabled:property"}}{{/crossLink}} property instead. + * @method getEnabled + * @deprecated + */ // ButtonHelper.getEnabled is @deprecated. Remove for 1.1+ p.getEnabled = createjs.deprecate(p._getEnabled, "ButtonHelper.getEnabled"); @@ -3147,7 +3251,7 @@ this.createjs = this.createjs||{}; * You can get around this by setting `crossOrigin` property on your images before passing them to EaselJS, or * setting the `crossOrigin` property on PreloadJS' LoadQueue or LoadItems. * - * var image = new Image(); + * var img = new Image(); * img.crossOrigin="Anonymous"; * img.src = "http://server-with-CORS-support.com/path/to/image.jpg"; * @@ -3323,6 +3427,12 @@ this.createjs = this.createjs||{}; p._getAnimations = function() { return this._animations.slice(); }; + + /** + * Use the {{#crossLink "SpriteSheet/animations:property"}}{{/crossLink}} property instead. + * @method getAnimations + * @deprecated + */ // SpriteSheet.getAnimations is @deprecated. Remove for 1.1+ p.getAnimations = createjs.deprecate(p._getAnimations, "SpriteSheet.getAnimations"); @@ -3676,6 +3786,7 @@ this.createjs = this.createjs||{}; * dc{{#crossLink "Graphics/drawCircle"}}{{/crossLink}} * de{{#crossLink "Graphics/drawEllipse"}}{{/crossLink}} * dp{{#crossLink "Graphics/drawPolyStar"}}{{/crossLink}} + * dp{{#crossLink "Graphics/drawPolygon"}}{{/crossLink}} * p{{#crossLink "Graphics/decodePath"}}{{/crossLink}} * * @@ -3865,7 +3976,7 @@ this.createjs = this.createjs||{}; // static properties: /** - * A reusable instance of {{#crossLink "Graphics/BeginPath"}}{{/crossLink}} to avoid + * A reusable instance of {{#crossLink "Graphics.BeginPath"}}{{/crossLink}} to avoid * unnecessary instantiation. * @property beginCmd * @type {Graphics.BeginPath} @@ -3939,6 +4050,12 @@ this.createjs = this.createjs||{}; this._updateInstructions(); return this._instructions; }; + + /** + * Use the {{#crossLink "Graphics/instructions:property"}}{{/crossLink}} property instead. + * @method getInstructions + * @deprecated + */ // Graphics.getInstructions is @deprecated. Remove for 1.1+ p.getInstructions = createjs.deprecate(p._getInstructions, "Graphics.getInstructions"); @@ -4520,6 +4637,25 @@ this.createjs = this.createjs||{}; p.drawPolyStar = function(x, y, radius, sides, pointSize, angle) { return this.append(new G.PolyStar(x, y, radius, sides, pointSize, angle)); }; + + /** + * Draws a polygon from array of point arrays. + * + * myGraphics.beginFill("#FF0").drawPolygon([100, 100], [150, 50], [200,100], [200,200], [100,200]); + * // makes a house shape + * + * A tiny API method "pg" also exists. + * + * @method drawPolygon + * @param {Array} points An array of [x,y] points. + * @param {Boolean} close Whether to close the polygon - default is true. + * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.) + * @chainable + **/ + + p.drawPolygon = function(points, close) { // Dan Zen 4/2/21 + return this.append(new G.Polygon(points, close)); + }; /** * Appends a graphics command object to the graphics queue. Command objects expose an "exec" method @@ -5087,6 +5223,18 @@ this.createjs = this.createjs||{}; * @protected **/ p.dp = p.drawPolyStar; + + /** + * Shortcut to drawPolygon. + * @method pg + * @param {Array} points An array of [x,y] points. + * @param {Boolean} close Whether to close the polygon - default is true. + * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.) + * @chainable + * @protected + **/ + p.pg = p.drawPolygon; + /** * Shortcut to decodePath. @@ -5525,9 +5673,11 @@ this.createjs = this.createjs||{}; * @method bitmap * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image Must be loaded prior to creating a bitmap fill, or the fill will be empty. * @param {String} [repetition] One of: repeat, repeat-x, repeat-y, or no-repeat. + * @param {Matrix2D} [matrix] Optional. Specifies a transformation matrix for the bitmap fill. This transformation will be applied relative to the parent transform. * @return {Fill} Returns this Fill object for chaining or assignment. */ - p.bitmap = function(image, repetition) { + p.bitmap = function(image, repetition, matrix) { + if (matrix) this.matrix = matrix; // Dan Zen 2020 if (image.naturalWidth || image.getContext || image.readyState >= 2) { var o = this.style = Graphics._ctx.createPattern(image, repetition || ""); o.props = {image: image, repetition: repetition, type: "bitmap"}; @@ -5752,7 +5902,7 @@ this.createjs = this.createjs||{}; this.radiusTL = radiusTL; this.radiusTR = radiusTR; this.radiusBR = radiusBR; this.radiusBL = radiusBL; }).prototype.exec = function(ctx) { - var max = (w - *
  • when the mouse enters shapeA (target=shapeA)
  • - *
  • when the mouse enters shapeB (target=shapeB)
  • + * myContainer, two events would be received, each targeting a child element: + *
      + *
    1. when the mouse enters shapeA (target=shapeA)
    2. + *
    3. when the mouse enters shapeB (target=shapeB)
    4. *
    * However, with a listener for "rollover" instead, only a single event is received when the mouse first enters * the aggregate myContainer content (target=myContainer). @@ -6417,9 +6623,10 @@ this.createjs = this.createjs||{}; * * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over * shapeA, then directly on to shapeB, then off both. With a listener for {{#crossLink "mouseout:event"}}{{/crossLink}} - * on myContainer, two events would be received, each targeting a child element:
      - *
    1. when the mouse leaves shapeA (target=shapeA)
    2. - *
    3. when the mouse leaves shapeB (target=shapeB)
    4. + * on myContainer, two events would be received, each targeting a child element: + *
        + *
      1. when the mouse leaves shapeA (target=shapeA)
      2. + *
      3. when the mouse leaves shapeB (target=shapeB)
      4. *
      * However, with a listener for "rollout" instead, only a single event is received when the mouse leaves * the aggregate myContainer content (target=myContainer). @@ -6499,6 +6706,12 @@ this.createjs = this.createjs||{}; if (o instanceof _Stage) { return o; } return null; }; + + /** + * Use the {{#crossLink "DisplayObject/stage:property"}}{{/crossLink}} property instead. + * @method getStage + * @deprecated + */ // DisplayObject.getStage is @deprecated. Remove for 1.1+ p.getStage = createjs.deprecate(p._getStage, "DisplayObject.getStage"); @@ -6520,10 +6733,10 @@ this.createjs = this.createjs||{}; */ /** - * Set both the {{#crossLink "DisplayObject/scaleX:property"}}{{/crossLink}} and the {{#crossLink "DisplayObject/scaleY"}}{{/crossLink}} + * Set both the {{#crossLink "DisplayObject/scaleX:property"}}{{/crossLink}} and the {{#crossLink "DisplayObject/scaleY:property"}}{{/crossLink}} * property to the same value. Note that when you get the value, if the `scaleX` and `scaleY` are different values, * it will return only the `scaleX`. - * @property scaleX + * @property scale * @type {Number} * @default 1 */ @@ -6536,7 +6749,7 @@ this.createjs = this.createjs||{}; }, scale: { get: function() { return this.scaleX; }, - set: function(scale) { this.scaleX = this.scaleY = scale; }, + set: function(scale) { this.scaleX = this.scaleY = scale; } } }); } catch (e) {} @@ -6557,7 +6770,7 @@ this.createjs = this.createjs||{}; /** * Draws the display object into the specified context ignoring its visible, alpha, shadow, and transform. - * Returns true if the draw was handled (useful for overriding functionality). + * Returns `true` if the draw was handled (useful for overriding functionality). * * NOTE: This method is mainly for internal use, though it may be useful for advanced uses. * @method draw @@ -6568,7 +6781,7 @@ this.createjs = this.createjs||{}; **/ p.draw = function(ctx, ignoreCache) { var cache = this.bitmapCache; - if(cache && !ignoreCache) { + if (cache && !ignoreCache) { return cache.draw(ctx); } return false; @@ -6611,8 +6824,8 @@ this.createjs = this.createjs||{}; * that does not change frequently (ex. a Container with many children that do not move, or a complex vector Shape), * this can provide for much faster rendering because the content does not need to be re-rendered each tick. The * cached display object can be moved, rotated, faded, etc freely, however if its content changes, you must manually - * update the cache by calling updateCache() again. You must specify the cached area via the x, y, w, - * and h parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates. + * update the cache by calling `updateCache()` again. You must specify the cached area via the x, y, w, and h + * parameters. This defines the rectangle that will be rendered and cached using this display object's coordinates. * *

      Example

      * For example if you defined a Shape that drew a circle at 0, 0 with a radius of 25: @@ -6643,8 +6856,10 @@ this.createjs = this.createjs||{}; * @param {Object} [options=undefined] Specify additional parameters for the cache logic **/ p.cache = function(x, y, width, height, scale, options) { - if(!this.bitmapCache){ + if (!this.bitmapCache){ this.bitmapCache = new createjs.BitmapCache(); + } else { + this.bitmapCache._autoGenerated = false; } this.bitmapCache.define(this, x, y, width, height, scale, options); }; @@ -6672,7 +6887,7 @@ this.createjs = this.createjs||{}; * whatwg spec on compositing. **/ p.updateCache = function(compositeOperation) { - if(!this.bitmapCache) { + if (!this.bitmapCache) { throw "cache() must be called before updateCache()"; } this.bitmapCache.update(compositeOperation); @@ -6683,7 +6898,7 @@ this.createjs = this.createjs||{}; * @method uncache **/ p.uncache = function() { - if(this.bitmapCache) { + if (this.bitmapCache) { this.bitmapCache.release(); this.bitmapCache = undefined; } @@ -6695,8 +6910,8 @@ this.createjs = this.createjs||{}; * @method getCacheDataURL * @return {String} The image data url for the cache. **/ - p.getCacheDataURL = function() { - return this.bitmapCache?this.bitmapCache.getCacheDataURL():null; + p.getCacheDataURL = function(type, encoderOptions) { + return this.bitmapCache?this.bitmapCache.getCacheDataURL(type, encoderOptions):null; }; /** @@ -6813,8 +7028,9 @@ this.createjs = this.createjs||{}; * @return {Matrix2D} A matrix representing this display object's transform. **/ p.getMatrix = function(matrix) { - var o = this, mtx = matrix&&matrix.identity() || new createjs.Matrix2D(); - return o.transformMatrix ? mtx.copy(o.transformMatrix) : mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY); + var o = this, mtx = matrix || new createjs.Matrix2D(); + return o.transformMatrix ? mtx.copy(o.transformMatrix) : + (mtx.identity() && mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY)); }; /** @@ -6877,7 +7093,8 @@ this.createjs = this.createjs||{}; p.hitTest = function(x, y) { var ctx = DisplayObject._hitTestContext; ctx.setTransform(1, 0, 0, 1, -x, -y); - this.draw(ctx); + // hit tests occur in a 2D context, so don't attempt to draw a GL only Texture into a 2D context + this.draw(ctx, !(this.bitmapCache && !(this.bitmapCache._cacheCanvas instanceof WebGLTexture) )); var hit = this._testHit(ctx); ctx.setTransform(1, 0, 0, 1, 0, 0); @@ -6918,21 +7135,22 @@ this.createjs = this.createjs||{}; * the automatic calculations listed below. * * Bitmap - * Returns the width and height of the sourceRect (if specified) or image, extending from (x=0,y=0). + * Returns the width and height of the {{#crossLink "Bitmap/sourceRect"}}{{/crossLink}} (if specified) or image, + * extending from (x=0,y=0). * * Sprite * Returns the bounds of the current frame. May have non-zero x/y if a frame registration point was specified * in the spritesheet data. See also {{#crossLink "SpriteSheet/getFrameBounds"}}{{/crossLink}} * * Container - * Returns the aggregate (combined) bounds of all children that return a non-null value from getBounds(). + * Returns the aggregate (combined) bounds of all children that return a non-null value from `getBounds()`. * * Shape - * Does not currently support automatic bounds calculations. Use setBounds() to manually define bounds. + * Does not currently support automatic bounds calculations. Use `setBounds()` to manually define bounds. * * Text - * Returns approximate bounds. Horizontal values (x/width) are quite accurate, but vertical values (y/height) are - * not, especially when using textBaseline values other than "top". + * Returns approximate bounds. Horizontal values (x/width) are quite accurate, but vertical values (y/height) + * are not, especially when using {{#crossLink "Text/textBaseline:property"}}{{/crossLink}} values other than "top". * * BitmapText * Returns approximate bounds. Values will be more accurate if spritesheet frame registration points are close @@ -6961,10 +7179,9 @@ this.createjs = this.createjs||{}; **/ p.getBounds = function() { if (this._bounds) { return this._rectangle.copy(this._bounds); } - var cacheCanvas = this.cacheCanvas; - if (cacheCanvas) { - var scale = this._cacheScale; - return this._rectangle.setValues(this._cacheOffsetX, this._cacheOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale); + var cache = this.bitmapCache; + if (cache && this.cacheCanvas) { + return cache.getBounds(); } return null; }; @@ -7037,6 +7254,7 @@ this.createjs = this.createjs||{}; * present in a {{#crossLink "StageGL"}}{{/crossLink}} instance. * * @method _updateState + * @protected * @default null */ p._updateState = null; @@ -7072,6 +7290,7 @@ this.createjs = this.createjs||{}; o.hitArea = this.hitArea; o.cursor = this.cursor; o._bounds = this._bounds; + o._webGLRenderStyle = this._webGLRenderStyle; return o; }; @@ -7198,12 +7417,11 @@ this.createjs = this.createjs||{}; * A Container is a nestable display list that allows you to work with compound display elements. For example you could * group arm, leg, torso and head {{#crossLink "Bitmap"}}{{/crossLink}} instances together into a Person Container, and * transform them as a group, while still being able to move the individual parts relative to each other. Children of - * containers have their transform and alpha properties concatenated with their parent - * Container. + * containers have their `transform` and `alpha` properties concatenated with their parent Container. * - * For example, a {{#crossLink "Shape"}}{{/crossLink}} with x=100 and alpha=0.5, placed in a Container with x=50 - * and alpha=0.7 will be rendered to the canvas at x=150 and alpha=0.35. - * Containers have some overhead, so you generally shouldn't create a Container to hold a single child. + * For example, a {{#crossLink "Shape"}}{{/crossLink}} with `x=100` and `alpha=0.5`, placed in a Container with `x=50` + * and `alpha=0.7` will be rendered to the canvas at `x=150` and `alpha=0.35`. Containers have some overhead, so you + * generally shouldn't create a Container to hold a single child. * *

      Example

      * @@ -7263,6 +7481,12 @@ this.createjs = this.createjs||{}; p._getNumChildren = function() { return this.children.length; }; + + /** + * Use the {{#crossLink "Container/numChildren:property"}}{{/crossLink}} property instead. + * @method getNumChildren + * @deprecated + */ // Container.getNumChildren is @deprecated. Remove for 1.1+ p.getNumChildren = createjs.deprecate(p._getNumChildren, "Container.getNumChildren"); @@ -7513,7 +7737,7 @@ this.createjs = this.createjs||{}; * container.sortChildren(sortFunction); * * @method sortChildren - * @param {Function} sortFunction the function to use to sort the child list. See JavaScript's Array.sort + * @param {Function} sortFunction the function to use to sort the child list. See JavaScript's `Array.sort` * documentation for details. **/ p.sortChildren = function(sortFunction) { @@ -7622,7 +7846,7 @@ this.createjs = this.createjs||{}; * list. This routine ignores any display objects with {{#crossLink "DisplayObject/mouseEnabled:property"}}{{/crossLink}} * set to `false`. The array will be sorted in order of visual depth, with the top-most display object at index 0. * This uses shape based hit detection, and can be an expensive operation to run, so it is best to use it carefully. - * For example, if testing for objects under the mouse, test on tick (instead of on {{#crossLink "DisplayObject/mousemove:event"}}{{/crossLink}}), + * For example, if testing for objects under the mouse, test on tick (instead of on {{#crossLink "Stage/stagemousemove:event"}}{{/crossLink}}), * and only if the mouse's position has changed. * *
        @@ -7633,7 +7857,7 @@ this.createjs = this.createjs||{}; * listeners or a {{#crossLink "DisplayObject:cursor:property"}}{{/crossLink}} property. That is, only objects * that would normally intercept mouse interaction will be included. This can significantly improve performance * in some cases by reducing the number of display objects that need to be tested. - * + *
      * * This method accounts for both {{#crossLink "DisplayObject/hitArea:property"}}{{/crossLink}} and {{#crossLink "DisplayObject/mask:property"}}{{/crossLink}}. * @method getObjectsUnderPoint @@ -7651,7 +7875,7 @@ this.createjs = this.createjs||{}; /** * Similar to {{#crossLink "Container/getObjectsUnderPoint"}}{{/crossLink}}, but returns only the top-most display - * object. This runs significantly faster than getObjectsUnderPoint(), but is still potentially an expensive + * object. This runs significantly faster than `getObjectsUnderPoint()`, but is still potentially an expensive * operation. See {{#crossLink "Container/getObjectsUnderPoint"}}{{/crossLink}} for more information. * @method getObjectUnderPoint * @param {Number} x The x position in the container to test. @@ -7664,17 +7888,13 @@ this.createjs = this.createjs||{}; return this._getObjectsUnderPoint(pt.x, pt.y, null, mode>0, mode==1); }; - /** - * Docced in superclass. - */ + // Docced in superclass p.getBounds = function() { return this._getBounds(null, true); }; - /** - * Docced in superclass. - */ + // Docced in superclass p.getTransformedBounds = function() { return this._getBounds(); }; @@ -8216,7 +8436,24 @@ this.createjs = this.createjs||{}; ctx.restore(); this.dispatchEvent("drawend"); }; - + + /** + * Draws the stage into the specified context ignoring its visible, alpha, shadow, and transform. + * Returns true if the draw was handled (useful for overriding functionality). + * + * NOTE: This method is mainly for internal use, though it may be useful for advanced uses. + * @method draw + * @param {CanvasRenderingContext2D} ctx The canvas 2D context object to draw into. + * @param {Boolean} [ignoreCache=false] Indicates whether the draw operation should ignore any current cache. + * For example, used for drawing the cache (to prevent it from simply drawing an existing cache back + * into itself). + **/ + p.draw = function(ctx, ignoreCache) { + var result = this.Container_draw(ctx, ignoreCache); + this.canvas._invalid = true; + return result; + }; + /** * Propagates a tick event through the display list. This is automatically called by {{#crossLink "Stage/update"}}{{/crossLink}} * unless {{#crossLink "Stage/tickOnUpdate:property"}}{{/crossLink}} is set to false. @@ -8294,9 +8531,11 @@ this.createjs = this.createjs||{}; * value is allowed. The default value is a transparent background. * @param {String} [mimeType="image/png"] The MIME type of the image format to be create. The default is "image/png". If an unknown MIME type * is passed in, or if the browser does not support the specified MIME type, the default value will be used. + * @param {Number} [encoderOptions=0.92] A Number between 0 and 1 indicating the image quality to use for image + * formats that use lossy compression such as image/jpeg and image/webp. * @return {String} a Base64 encoded image. **/ - p.toDataURL = function(backgroundColor, mimeType) { + p.toDataURL = function(backgroundColor, mimeType, encoderOptions) { var data, ctx = this.canvas.getContext('2d'), w = this.canvas.width, h = this.canvas.height; if (backgroundColor) { @@ -8308,7 +8547,7 @@ this.createjs = this.createjs||{}; ctx.fillRect(0, 0, w, h); } - var dataURL = this.canvas.toDataURL(mimeType||"image/png"); + var dataURL = this.canvas.toDataURL(mimeType||"image/png", encoderOptions); if(backgroundColor) { ctx.putImageData(data, 0, 0); @@ -8607,54 +8846,57 @@ this.createjs = this.createjs||{}; nextStage&&nextStage._testMouseOver(clear, owner, eventTarget); return; } - var o = this._getPointerData(-1); - // only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs. - if (!o || (!clear && this.mouseX == this._mouseOverX && this.mouseY == this._mouseOverY && this.mouseInBounds)) { return; } + if (this.canvas) { // Jeff Peck change from CreateJS Slack + var o = this._getPointerData(-1); + // only update if the mouse position has changed. This provides a lot of optimization, but has some trade-offs. + if (!o || (!clear && this.mouseX == this._mouseOverX && this.mouseY == this._mouseOverY && this.mouseInBounds)) { return; } + + var e = o.posEvtObj; + var isEventTarget = eventTarget || e&&(e.target == this.canvas); + var target=null, common = -1, cursor="", t, i, l; - var e = o.posEvtObj; - var isEventTarget = eventTarget || e&&(e.target == this.canvas); - var target=null, common = -1, cursor="", t, i, l; - - if (!owner && (clear || this.mouseInBounds && isEventTarget)) { - target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true); - this._mouseOverX = this.mouseX; - this._mouseOverY = this.mouseY; - } - - var oldList = this._mouseOverTarget||[]; - var oldTarget = oldList[oldList.length-1]; - var list = this._mouseOverTarget = []; + if (!owner && (clear || this.mouseInBounds && isEventTarget)) { + target = this._getObjectsUnderPoint(this.mouseX, this.mouseY, null, true); + this._mouseOverX = this.mouseX; + this._mouseOverY = this.mouseY; + } - // generate ancestor list and check for cursor: - t = target; - while (t) { - list.unshift(t); - if (!cursor) { cursor = t.cursor; } - t = t.parent; - } - this.canvas.style.cursor = cursor; - if (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; } + var oldList = this._mouseOverTarget||[]; + var oldTarget = oldList[oldList.length-1]; + var list = this._mouseOverTarget = []; + + // generate ancestor list and check for cursor: + // Note: Internet Explorer won't update null or undefined cursor properties + t = target; + while (t) { + list.unshift(t); + if (!cursor && t.cursor) { cursor = t.cursor; } + t = t.parent; + } + this.canvas.style.cursor = cursor; + if (!owner && eventTarget) { eventTarget.canvas.style.cursor = cursor; } - // find common ancestor: - for (i=0,l=list.length; icommon; i--) { - this._dispatchMouseEvent(oldList[i], "rollout", false, -1, o, e, target); - } + for (i=oldList.length-1; i>common; i--) { + this._dispatchMouseEvent(oldList[i], "rollout", false, -1, o, e, target); + } - for (i=list.length-1; i>common; i--) { - this._dispatchMouseEvent(list[i], "rollover", false, -1, o, e, oldTarget); - } + for (i=list.length-1; i>common; i--) { + this._dispatchMouseEvent(list[i], "rollover", false, -1, o, e, oldTarget); + } - if (oldTarget != target) { - this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget); + if (oldTarget != target) { + this._dispatchMouseEvent(target, "mouseover", true, -1, o, e, oldTarget); + } } nextStage&&nextStage._testMouseOver(clear, owner || target && this, eventTarget || isEventTarget && this); @@ -8711,29 +8953,41 @@ this.createjs = this.createjs||{}; /* * README IF EDITING: - * Terminology for developers: * + * - Terminology for developers: * Vertex: a point that help defines a shape, 3 per triangle. Usually has an x,y,z but can have more/less info. * Vertex Property: a piece of information attached to the vertex like a vector3 containing x,y,z * Index/Indices: used in groups of 3 to define a triangle, points to vertices by their index in an array (some render * modes do not use these) * Card: a group of 2 triangles used to display a rectangular image - * U/V: common names for the [0-1] texture co-ordinates on an image - * Batch: a single call to the renderer, best done as little as possible so multiple cards are put into a single batch - * Buffer: WebGL array data + * UV: common names for the [0-1] texture co-ordinates on an image + * Batch: a single call to the renderer, best done as little as possible. Multiple cards are batched for this reason * Program/Shader: For every vertex we run the Vertex shader. The results are used per pixel by the Fragment shader. When - * combined and paired these are a shader "program" - * Texture: WebGL representation of image data and associated extra information - * Slot: A space on the GPU into which textures can be loaded for use in a batch, using "ActiveTexture" switches texture slot. + * combined and paired these are a "shader program" + * Texture: WebGL representation of image data and associated extra information, separate from a DOM Image + * Slot: A space on the GPU into which textures can be loaded for use in a batch, i.e. using "ActiveTexture" switches texture slot. + * Render___: actual WebGL draw call + * Buffer: WebGL array data + * Cover: A card that covers the entire viewport + * Dst: The existing drawing surface in the shader + * Src: The new data being provided in the shader + * + * - Notes: + * WebGL treats 0,0 as the bottom left, as such there's a lot of co-ordinate space flipping to make regular canvas + * numbers make sense to users and WebGL simultaneously. This extends to textures stored in memory too. If writing + * code that deals with x/y, be aware your y may be flipped. + * Older versions had distinct internal paths for filters and regular draws, these have been merged. + * Draws are slowly assembled out of found content. Overflowing things like shaders, object/texture count will cause + * an early draw before continuing. Lookout for the things that force a draw. Marked with <------------------------ */ (function () { "use strict"; /** - * A StageGL instance is the root level {{#crossLink "Container"}}{{/crossLink}} for an WebGL-optimized display list, - * which is used in place of the usual {{#crossLink "Stage"}}{{/crossLink}}. This class should behave identically to - * a {{#crossLink "Stage"}}{{/crossLink}} except for WebGL-specific functionality. + * A StageGL instance is the root level {{#crossLink "Container"}}{{/crossLink}} for a WebGL-optimized display list, + * which can be used in place of the usual {{#crossLink "Stage"}}{{/crossLink}}. This class should behave identically + * to a {{#crossLink "Stage"}}{{/crossLink}} except for WebGL-specific functionality. * * Each time the {{#crossLink "Stage/tick"}}{{/crossLink}} method is called, the display list is rendered to the * target <canvas/> instance, ignoring non-WebGL-compatible display objects. On devices and browsers that don't @@ -8754,6 +9008,7 @@ this.createjs = this.createjs||{}; * resize your canvas after making a StageGL instance, this will properly size the WebGL context stored in memory. * - Best performance in demanding scenarios will come from manual management of texture memory, but it is handled * automatically by default. See {{#crossLink "StageGL/releaseTexture"}}{{/crossLink}} for details. + * - Disable `directDraw` to get access to cacheless filters and composite oeprations! * *

      Example

      * This example creates a StageGL instance, adds a child to it, then uses the EaselJS {{#crossLink "Ticker"}}{{/crossLink}} @@ -8771,41 +9026,45 @@ this.createjs = this.createjs||{}; * stage.update(); * } * - *

      Notes

      - * - StageGL is not currently included in the minified version of EaselJS. - * - {{#crossLink "SpriteContainer"}}{{/crossLink}} (the previous approach to WebGL with EaselJS) has been deprecated. - * - Earlier versions of WebGL support in EaselJS (SpriteStage and SpriteContainer) had hard limitations on images - * per container, which have been solved. - * * @class StageGL * @extends Stage * @constructor * @param {HTMLCanvasElement | String | Object} canvas A canvas object that StageGL will render to, or the string id - * of a canvas object in the current DOM. + * of a canvas object in the current DOM. * @param {Object} options All the option parameters in a reference object, some are not supported by some browsers. * @param {Boolean} [options.preserveBuffer=false] If `true`, the canvas is NOT auto-cleared by WebGL (the spec - * discourages setting this to `true`). This is useful if you want persistent draw effects. + * discourages setting this to `true`). This is useful if you want persistent draw effects and has also fixed device + * specific bugs due to mis-timed clear commands. * @param {Boolean} [options.antialias=false] Specifies whether or not the browser's WebGL implementation should try - * to perform anti-aliasing. This will also enable linear pixel sampling on power-of-two textures (smoother images). + * to perform anti-aliasing. This will also enable linear pixel sampling on power-of-two textures (smoother images). * @param {Boolean} [options.transparent=false] If `true`, the canvas is transparent. This is very * expensive, and should be used with caution. - * @param {Boolean} [options.premultiply=false] Alters color handling. If `true`, this assumes the shader must - * account for pre-multiplied alpha. This can help avoid visual halo effects with some assets, but may also cause - * problems with other assets. - * @param {Integer} [options.autoPurge=1200] How often the system should automatically dump unused textures with - * `purgeTextures(autoPurge)` every `autoPurge/2` draws. See {{#crossLink "StageGL/purgeTextures"}}{{/crossLink}} for more - * information. + * @param {Boolean} [options.directDraw=true] If `true`, this will bypass intermediary render-textures when possible + * resulting in reduced memory and increased performance, this disables some features. Cache-less filters and some + * {{#crossLink "DisplayObject/compositeOperation:property"}}{{/crossLink}} values rely on this being false. + * @param (Boolean} [options.premultiply] @deprecated Upgraded colour & transparency handling have fixed the issue + * this flag was trying to solve rendering it unnecessary. + * @param {int} [options.autoPurge=1200] How often the system should automatically dump unused textures. Calls + * `purgeTextures(autoPurge)` every `autoPurge/2` draws. See {{#crossLink "StageGL/purgeTextures"}}{{/crossLink}} + * for more information on texture purging. + * @param {String|int} [options.clearColor=undefined] Automatically calls {{#crossLink "StageGL/setClearColor"}}{{/crossLink}} + * after init is complete, can be overridden and changed manually later. + * @param {String|int} [options.batchSize=DEFAULT_MAX_BATCH_SIZE] The size of the buffer used to retain a batch. + * Making it smaller reduces GPU load, but making it too small adds extra GPU calls. Figure out your maximum batch + * count and set it to a small buffer above that per-project. Check src/utils/WebGLInspector to track. */ function StageGL(canvas, options) { this.Stage_constructor(canvas); + var transparent, antialias, preserveBuffer, autoPurge, directDraw, batchSize; if (options !== undefined) { if (typeof options !== "object"){ throw("Invalid options object"); } - var premultiply = options.premultiply; - var transparent = options.transparent; - var antialias = options.antialias; - var preserveBuffer = options.preserveBuffer; - var autoPurge = options.autoPurge; + transparent = options.transparent; + antialias = options.antialias; + preserveBuffer = options.preserveBuffer; + autoPurge = options.autoPurge; + directDraw = options.directDraw; + batchSize = options.batchSize; } // public properties: @@ -8818,6 +9077,18 @@ this.createjs = this.createjs||{}; */ this.vocalDebug = false; + /** + * Specifies whether this instance is slaved to a {{#crossLink "BitmapCache"}}{{/crossLink}} or draws independantly. + * Necessary to control texture outputs and behaviours when caching. StageGL cache outputs will only render + * properly for the StageGL that made them. See the {{#crossLink "cache"}}{{/crossLink}} function documentation + * for more information. Enabled by default when BitmapCache's `useGL` is true. + * NOTE: This property is mainly for internal use, though it may be useful for advanced uses. + * @property isCacheControlled + * @type {Boolean} + * @default false + */ + this.isCacheControlled = false; + // private properties: /** * Specifies whether or not the canvas is auto-cleared by WebGL. The WebGL spec discourages `true`. @@ -8848,24 +9119,24 @@ this.createjs = this.createjs||{}; */ this._transparent = transparent||false; - /** - * Specifies whether or not StageGL is handling colours as premultiplied alpha. - * @property _premultiply - * @protected - * @type {Boolean} - * @default false - */ - this._premultiply = premultiply||false; - /** * Internal value of {{#crossLink "StageGL/autoPurge"}}{{/crossLink}} * @property _autoPurge * @protected - * @type {Integer} + * @type {int} * @default null */ this._autoPurge = undefined; - this.autoPurge = autoPurge; //getter/setter handles setting the real value and validating + this.autoPurge = autoPurge; //getter/setter handles setting the real value and validating and documentation + + /** + * See directDraw + * @property _directDraw + * @protected + * @type {Boolean} + * @default false + */ + this._directDraw = directDraw === undefined ? true : (!!directDraw); /** * The width in px of the drawing surface saved in memory. @@ -8904,6 +9175,13 @@ this.createjs = this.createjs||{}; */ this._webGLContext = null; + /** + * Reduce API logic by allowing stage to behave as a renderTexture target, should always be null as null is canvas. + * @type {null} + * @protected + */ + this._frameBuffer = null; + /** * The color to use when the WebGL canvas has been cleared. May appear as a background color. Defaults to grey. * @property _clearColor @@ -8914,14 +9192,18 @@ this.createjs = this.createjs||{}; this._clearColor = {r: 0.50, g: 0.50, b: 0.50, a: 0.00}; /** - * The maximum number of cards (aka a single sprite) that can be drawn in one draw call. Use getter/setters to - * modify otherwise internal buffers may be incorrect sizes. - * @property _maxCardsPerBatch + * The maximum number of verticies (6 make a single sprite) that can be drawn in one draw call. Use constructor props + * to modify otherwise internal buffers may be invalid sizes. + * @property _maxBatchVertexCount * @protected * @type {Number} - * @default StageGL.DEFAULT_MAX_BATCH_SIZE (10000) + * @default StageGL.DEFAULT_MAX_BATCH_SIZE * StageGL.INDICIES_PER_CARD */ - this._maxCardsPerBatch = StageGL.DEFAULT_MAX_BATCH_SIZE; //TODO: write getter/setters for this + this._maxBatchVertexCount = Math.max( + Math.min( + Number(batchSize) || StageGL.DEFAULT_MAX_BATCH_SIZE, + StageGL.DEFAULT_MAX_BATCH_SIZE) + , StageGL.DEFAULT_MIN_BATCH_SIZE) * StageGL.INDICIES_PER_CARD; /** * The shader program used to draw the current batch. @@ -8933,76 +9215,89 @@ this.createjs = this.createjs||{}; this._activeShader = null; /** - * The vertex position data for the current draw call. - * @property _vertices + * The non cover, per object shader used for most rendering actions. + * @type {WebGLProgram} * @protected - * @type {Float32Array} - * @default null */ - this._vertices = null; + this._mainShader = null; /** - * The WebGL buffer attached to {{#crossLink "StageGL/_vertices:property"}}{{/crossLink}}. - * @property _vertexPositionBuffer + * All the different vertex attribute sets that can be used with the render buffer. Currently only internal, + * if/when alternate main shaders are possible, they'll register themselves here. + * @property _attributeConfig * @protected - * @type {WebGLBuffer} - * @default null + * @type {Object} */ - this._vertexPositionBuffer = null; + this._attributeConfig = {}; /** - * The vertex U/V data for the current draw call. - * @property _uvs + * Which of the configs in {{#crossLink "StageGL/_attributeConfig:property"}}{{/crossLink}} is currently active. + * @property _activeConfig * @protected - * @type {Float32Array} - * @default null + * @type {Object} */ - this._uvs = null; + this._activeConfig = null; /** - * The WebGL buffer attached to {{#crossLink "StageGL/_uvs:property"}}{{/crossLink}}. - * @property _uvPositionBuffer + * One of the major render buffers used in composite blending drawing. Do not expect this to always be the same object. + * "What you're drawing to", object occasionally swaps with concat. + * @property _bufferTextureOutput * @protected - * @type {WebGLBuffer} - * @default null + * @type {WebGLTexture} */ - this._uvPositionBuffer = null; + this._bufferTextureOutput = null; /** - * The vertex indices data for the current draw call. - * @property _indices + * One of the major render buffers used in composite blending drawing. Do not expect this to always be the same object. + * "What you've draw before now", object occasionally swaps with output. + * @property _bufferTextureConcat * @protected - * @type {Float32Array} - * @default null + * @type {WebGLTexture} */ - this._indices = null; + this._bufferTextureConcat = null; /** - * The WebGL buffer attached to {{#crossLink "StageGL/_indices:property"}}{{/crossLink}}. - * @property _textureIndexBuffer + * One of the major render buffers used in composite blending drawing. + * "Temporary mixing surface" + * @property _bufferTextureTemp * @protected - * @type {WebGLBuffer} - * @default null + * @type {WebGLTexture} */ - this._textureIndexBuffer = null; + this._bufferTextureTemp = null; /** - * The vertices data for the current draw call. - * @property _alphas + * The current render buffer being targeted, usually targets internal buffers, but may be set to cache's buffer during a cache render. + * @property _batchTextureOutput * @protected - * @type {Float32Array} - * @default null + * @type {WebGLTexture | StageGL} */ - this._alphas = null; + this._batchTextureOutput = this; /** - * The WebGL buffer attached to {{#crossLink "StageGL/_alphas:property"}}{{/crossLink}}. - * @property _alphaBuffer + * The current render buffer being targeted, usually targets internal buffers, but may be set to cache's buffer during a cache render. + * @property _batchTextureConcat * @protected - * @type {WebGLBuffer} - * @default null + * @type {WebGLTexture} + */ + this._batchTextureConcat = null; + + /** + * The current render buffer being targeted, usually targets internal buffers, but may be set to cache's buffer during a cache render. + * @property _batchTextureTemp + * @protected + * @type {WebGLTexture} + */ + this._batchTextureTemp = null; + + /** + * Internal library of the shaders that have been compiled and created along with their parameters. Should contain + * compiled `gl.ShaderProgram` and settings for `gl.blendFunc` and `gl.blendEquation`. Populated as requested. + * + * See {{#crossLink "StageGL/_updateRenderMode:method"}}{{/crossLink}} for exact details. + * @type {Object} + * @private */ - this._alphaBuffer = null; + this._builtShaders = {}; /** * An index based lookup of every WebGL Texture currently in use. @@ -9038,30 +9333,59 @@ this.createjs = this.createjs||{}; this._baseTextures = []; /** - * The number of concurrent textures the GPU can handle. This value is dynamically set from WebGL during initialization - * via `gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)`. The WebGL spec states that the lowest guaranteed value is 8, - * but it could be higher. Do not set this value higher than the value returned by the GPU. Setting it lower will - * probably reduce performance, but may be advisable to reserve slots for custom filter work. - * NOTE: Can also act as a length for {{#crossLink "StageGL/_batchTextures:property"}}. - * @property _batchTextureCount + * Texture slots for a draw + * @property _gpuTextureCount * @protected - * @type {Number} - * @default 8 + * @type {uint} */ - this._batchTextureCount = 8; + this._gpuTextureCount = 8; /** - * The location at which the last texture was inserted into a GPU slot in {{#crossLink "StageGL/_batchTextures:property"}}{{/crossLink}}. - * Manual control of this variable can yield improvements in performance by intelligently replacing textures - * inside a batch to reduce texture re-load. It is impossible to write automated general use code, as it requires - * display list look ahead inspection and/or render foreknowledge. - * @property _lastTextureInsert + * Texture slots on the hardware + * @property _gpuTextureMax * @protected - * @type {Number} - * @default -1 + * @type {uint} + */ + this._gpuTextureMax = 8; + + /** + * Texture slots in a batch for User textures + * @property _batchTextureCount + * @protected + * @type {uint} + */ + this._batchTextureCount = 0; + + /** + * The location at which the last texture was inserted into a GPU slot */ this._lastTextureInsert = -1; + /** + * The current string name of the render mode being employed per Context2D spec. + * Must start invalid to trigger default shader into being built during init. + * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation + * @type {string} + * @private + */ + this._renderMode = ""; + + /** + * Flag indicating that the content being batched in `appendToBatch` must be drawn now and not follow batch logic. + * Used for effects that are compounding in nature and cannot be applied in a single pass. + * Should be enabled with extreme care due to massive performance implications. + * @type {boolean} + * @private + */ + this._immediateRender = false; + + /** + * Vertices drawn into the batch so far. + * @type {number} + * @private + */ + this._batchVertexCount = 0; + /** * The current batch being drawn, A batch consists of a call to `drawElements` on the GPU. Many of these calls * can occur per draw. @@ -9083,21 +9407,21 @@ this.createjs = this.createjs||{}; this._drawID = 0; /** - * Used to prevent textures in certain GPU slots from being replaced by an insert. - * @property _slotBlackList + * Tracks how many renders have occurred this draw, used for performance monitoring and empty draw avoidance. + * @property _renderPerDraw * @protected - * @type {Array} + * @type {Number} + * @default 0 */ - this._slotBlacklist = []; + this._renderPerDraw = 0; /** - * Used to prevent nested draw calls from accidentally overwriting drawing information by tracking depth. - * @property _isDrawing + * Used to prevent textures in certain GPU slots from being replaced by an insert. + * @property _slotBlackList * @protected - * @type {Number} - * @default 0 + * @type {Array} */ - this._isDrawing = 0; + this._slotBlacklist = []; /** * Used to ensure every canvas used as a texture source has a unique ID. @@ -9106,18 +9430,7 @@ this.createjs = this.createjs||{}; * @type {Number} * @default 0 */ - this._lastTrackedCanvas = 0; - - /** - * Controls whether final rendering output of a {{#crossLink "cacheDraw"}}{{/crossLink}} is the canvas or a render - * texture. See the {{#crossLink "cache"}}{{/crossLink}} function modifications for full implications and discussion. - * @property isCacheControlled - * @protected - * @type {Boolean} - * @default false - * @todo LM: is this supposed to be _isCacheControlled since its private? - */ - this.isCacheControlled = false; + this._lastTrackedCanvas = -1; /** * Used to counter-position the object being cached so it aligns with the cache surface. Additionally ensures @@ -9131,12 +9444,18 @@ this.createjs = this.createjs||{}; // and begin this._initializeWebGL(); + + // these settings require everything to be ready + if (options !== undefined) { + options.clearColor !== undefined && this.setClearColor(options.clearColor); + options.premultiply !== undefined && (createjs.deprecate(null, "options.premultiply")()); + } } var p = createjs.extend(StageGL, createjs.Stage); // static methods: /** - * Calculate the U/V co-ordinate based info for sprite frames. Instead of pixel count it uses a 0-1 space. Also includes + * Calculate the UV co-ordinate based info for sprite frames. Instead of pixel count it uses a 0-1 space. Also includes * the ability to get info back for a specific frame, or only calculate that one frame. * * //generate UV rects for all entries @@ -9159,28 +9478,28 @@ this.createjs = this.createjs||{}; if (target === undefined) { target = -1; } if (onlyTarget === undefined) { onlyTarget = false; } - var start = (target != -1 && onlyTarget)?(target):(0); - var end = (target != -1 && onlyTarget)?(target+1):(spritesheet._frames.length); + var start = (target !== -1 && onlyTarget)?(target):(0); + var end = (target !== -1 && onlyTarget)?(target+1):(spritesheet._frames.length); for (var i=start; i 7 ? Number("0x"+color.slice(7, 9))/255 : 1; + } else if (color.indexOf("rgba(") === 0) { + var output = color.slice(5, -1).split(","); + r = Number(output[0])/255; + g = Number(output[1])/255; + b = Number(output[2])/255; + a = Number(output[3]); + } + } else { // >>> is an unsigned shift which is what we want as 0x80000000 and up are negative values + r = ((color & 0xFF000000) >>> 24)/255; + g = ((color & 0x00FF0000) >>> 16)/255; + b = ((color & 0x0000FF00) >>> 8)/255; + a = (color & 0x000000FF)/255; + } + + return { + r: Math.min(Math.max(0, r), 1), + g: Math.min(Math.max(0, g), 1), + b: Math.min(Math.max(0, b), 1), + a: Math.min(Math.max(0, a), 1) + } + }; + +// static properties: + /** + * The number of properties defined per vertex (x, y, textureU, textureV, textureIndex, alpha) + * @property VERTEX_PROPERTY_COUNT + * @protected + * @static + * @final * @type {Number} - * @default 10000 + * @default 6 * @readonly */ - StageGL.DEFAULT_MAX_BATCH_SIZE = 10000; + StageGL.VERTEX_PROPERTY_COUNT = 6; + + /** + * The number of triangle indices it takes to form a Card. 3 per triangle, 2 triangles. + * @property INDICIES_PER_CARD + * @protected + * @static + * @final + * @type {Number} + * @default 6 + * @readonly + */ + StageGL.INDICIES_PER_CARD = 6; + + /** + * The default value for the maximum number of cards we want to process in a batch. See + * {{#crossLink "StageGL/WEBGL_MAX_INDEX_NUM:property"}}{{/crossLink}} for a hard limit. + * this value comes is designed to sneak under that limit. + * @property DEFAULT_MAX_BATCH_SIZE + * @static + * @final + * @type {Number} + * @default 10920 + * @readonly + */ + StageGL.DEFAULT_MAX_BATCH_SIZE = 10920; + + /** + * The default value for the minimum number of cards we want to process in a batch. Less + * max cards can mean better performance, but anything below this is probably not worth it. + * @property DEFAULT_MIN_BATCH_SIZE + * @static + * @final + * @type {Number} + * @default 170 + * @readonly + */ + StageGL.DEFAULT_MIN_BATCH_SIZE = 170; /** * The maximum size WebGL allows for element index numbers. Uses a 16 bit unsigned integer. It takes 6 indices to @@ -9238,15 +9612,16 @@ this.createjs = this.createjs||{}; StageGL.WEBGL_MAX_INDEX_NUM = Math.pow(2, 16); /** - * Default U/V rect for dealing with full coverage from an image source. + * Default UV rect for dealing with full coverage from an image source. * @property UV_RECT + * @protected * @static * @final * @type {Object} * @default {t:0, l:0, b:1, r:1} * @readonly */ - StageGL.UV_RECT = {t:0, l:0, b:1, r:1}; + StageGL.UV_RECT = {t:1, l:0, b:0, r:1}; try { /** @@ -9259,15 +9634,15 @@ this.createjs = this.createjs||{}; */ StageGL.COVER_VERT = new Float32Array([ -1, 1, //TL - 1, 1, //TR + 1, 1, //TR -1, -1, //BL - 1, 1, //TR - 1, -1, //BR + 1, 1, //TR + 1, -1, //BR -1, -1 //BL ]); /** - * U/V for {{#crossLink "StageGL/COVER_VERT:property"}}{{/crossLink}}. + * UV for {{#crossLink "StageGL/COVER_VERT:property"}}{{/crossLink}}. * @property COVER_UV * @static * @final @@ -9275,23 +9650,6 @@ this.createjs = this.createjs||{}; * @readonly */ StageGL.COVER_UV = new Float32Array([ - 0, 0, //TL - 1, 0, //TR - 0, 1, //BL - 1, 0, //TR - 1, 1, //BR - 0, 1 //BL - ]); - - /** - * Flipped U/V for {{#crossLink "StageGL:COVER_VERT:property"}}{{/crossLink}}. - * @property COVER_UV_FLIP - * @static - * @final - * @type {Float32Array} - * @readonly - */ - StageGL.COVER_UV_FLIP = new Float32Array([ 0, 1, //TL 1, 1, //TR 0, 0, //BL @@ -9306,13 +9664,19 @@ this.createjs = this.createjs||{}; * regular shader is designed to render all expected objects. Shader code may contain templates that are replaced * pre-compile. * @property REGULAR_VARYING_HEADER + * @protected * @static * @final * @type {String} * @readonly */ StageGL.REGULAR_VARYING_HEADER = ( - "precision mediump float;" + + "#ifdef GL_FRAGMENT_PRECISION_HIGH \n"+ + "precision highp float; \n"+ + "#else \n"+ + "precision mediump float; \n"+ + "#endif \n"+ + "varying vec2 vTextureCoord;" + "varying lowp float indexPicker;" + "varying lowp float alphaValue;" @@ -9322,6 +9686,7 @@ this.createjs = this.createjs||{}; * Actual full header for the vertex shader. Includes the varying header. The regular shader is designed to render * all expected objects. Shader code may contain templates that are replaced pre-compile. * @property REGULAR_VERTEX_HEADER + * @protected * @static * @final * @type {String} @@ -9340,6 +9705,7 @@ this.createjs = this.createjs||{}; * Actual full header for the fragment shader. Includes the varying header. The regular shader is designed to render * all expected objects. Shader code may contain templates that are replaced pre-compile. * @property REGULAR_FRAGMENT_HEADER + * @protected * @static * @final * @type {String} @@ -9354,6 +9720,7 @@ this.createjs = this.createjs||{}; * Body of the vertex shader. The regular shader is designed to render all expected objects. Shader code may contain * templates that are replaced pre-compile. * @property REGULAR_VERTEX_BODY + * @protected * @static * @final * @type {String} @@ -9361,15 +9728,7 @@ this.createjs = this.createjs||{}; */ StageGL.REGULAR_VERTEX_BODY = ( "void main(void) {" + - //DHG TODO: This doesn't work. Must be something wrong with the hand built matrix see js... bypass for now - //vertexPosition, round if flag - //"gl_Position = pMatrix * vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);" + - "gl_Position = vec4("+ - "(vertexPosition.x * pMatrix[0][0]) + pMatrix[3][0]," + - "(vertexPosition.y * pMatrix[1][1]) + pMatrix[3][1]," + - "pMatrix[3][2]," + - "1.0" + - ");" + + "gl_Position = pMatrix * vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);" + "alphaValue = objectAlpha;" + "indexPicker = textureIndex;" + "vTextureCoord = uvPosition;" + @@ -9380,6 +9739,7 @@ this.createjs = this.createjs||{}; * Body of the fragment shader. The regular shader is designed to render all expected objects. Shader code may * contain templates that are replaced pre-compile. * @property REGULAR_FRAGMENT_BODY + * @protected * @static * @final * @type {String} @@ -9394,59 +9754,29 @@ this.createjs = this.createjs||{}; "{{alternates}}" + "}" + - "{{fragColor}}" + - "}" - ); - StageGL.REGULAR_FRAG_COLOR_NORMAL = ( - "gl_FragColor = vec4(color.rgb, color.a * alphaValue);" - ); - StageGL.REGULAR_FRAG_COLOR_PREMULTIPLY = ( - "if(color.a > 0.0035) {" + // 1/255 = 0.0039, so ignore any value below 1 because it's probably noise - "gl_FragColor = vec4(color.rgb/color.a, color.a * alphaValue);" + - "} else {" + - "gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);" + + "gl_FragColor = vec4(color.rgb * alphaValue, color.a * alphaValue);" + "}" ); - //TODO: DHG: a real particle shader - /** - * @property PARTICLE_VERTEX_BODY - * @todo - * @final - * @static - * @type {String} - * @readonly - */ - StageGL.PARTICLE_VERTEX_BODY = ( - StageGL.REGULAR_VERTEX_BODY - ); - /** - * @property PARTICLE_FRAGMENT_BODY - * @todo - * @final - * @static - * @type {String} - * @readonly - */ - StageGL.PARTICLE_FRAGMENT_BODY = ( - StageGL.REGULAR_FRAGMENT_BODY - ); - /** * Portion of the shader that contains the "varying" properties required in both vertex and fragment shaders. The * cover shader is designed to be a simple vertex/uv only texture render that covers the render surface. Shader * code may contain templates that are replaced pre-compile. * @property COVER_VARYING_HEADER + * @protected * @static * @final * @type {String} * @readonly */ StageGL.COVER_VARYING_HEADER = ( - "precision mediump float;" + + "#ifdef GL_FRAGMENT_PRECISION_HIGH \n"+ + "precision highp float; \n"+ + "#else \n"+ + "precision mediump float; \n"+ + "#endif \n"+ - "varying highp vec2 vRenderCoord;" + - "varying highp vec2 vTextureCoord;" + "varying vec2 vTextureCoord;" ); /** @@ -9454,6 +9784,7 @@ this.createjs = this.createjs||{}; * simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are * replaced pre-compile. * @property COVER_VERTEX_HEADER + * @protected * @static * @final * @type {String} @@ -9462,8 +9793,7 @@ this.createjs = this.createjs||{}; StageGL.COVER_VERTEX_HEADER = ( StageGL.COVER_VARYING_HEADER + "attribute vec2 vertexPosition;" + - "attribute vec2 uvPosition;" + - "uniform float uUpright;" + "attribute vec2 uvPosition;" ); /** @@ -9471,6 +9801,7 @@ this.createjs = this.createjs||{}; * simple vertex/uv only texture render that covers the render surface. Shader code may contain templates that are * replaced pre-compile. * @property COVER_FRAGMENT_HEADER + * @protected * @static * @final * @type {String} @@ -9485,6 +9816,7 @@ this.createjs = this.createjs||{}; * Body of the vertex shader. The cover shader is designed to be a simple vertex/uv only texture render that covers * the render surface. Shader code may contain templates that are replaced pre-compile. * @property COVER_VERTEX_BODY + * @protected * @static * @final * @type {String} @@ -9493,8 +9825,7 @@ this.createjs = this.createjs||{}; StageGL.COVER_VERTEX_BODY = ( "void main(void) {" + "gl_Position = vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);" + - "vRenderCoord = uvPosition;" + - "vTextureCoord = vec2(uvPosition.x, abs(uUpright - uvPosition.y));" + + "vTextureCoord = uvPosition;" + "}" ); @@ -9502,6 +9833,7 @@ this.createjs = this.createjs||{}; * Body of the fragment shader. The cover shader is designed to be a simple vertex/uv only texture render that * covers the render surface. Shader code may contain templates that are replaced pre-compile. * @property COVER_FRAGMENT_BODY + * @protected * @static * @final * @type {String} @@ -9509,11 +9841,299 @@ this.createjs = this.createjs||{}; */ StageGL.COVER_FRAGMENT_BODY = ( "void main(void) {" + - "vec4 color = texture2D(uSampler, vRenderCoord);" + - "gl_FragColor = color;" + + "gl_FragColor = texture2D(uSampler, vTextureCoord);" + + "}" + ); + + /** + * The starting template of a cover fragment shader with simple blending equations + * @property BLEND_FRAGMENT_SIMPLE + * @protected + * @static + * @final + * @type {String} + * @readonly + */ + StageGL.BLEND_FRAGMENT_SIMPLE = ( + "uniform sampler2D uMixSampler;"+ + "void main(void) {" + + "vec4 src = texture2D(uMixSampler, vTextureCoord);" + + "vec4 dst = texture2D(uSampler, vTextureCoord);" + // note this is an open bracket on main! + ); + + /** + * The starting template of a cover fragment shader which has complex blending equations + * @property BLEND_FRAGMENT_COMPLEX + * @protected + * @static + * @final + * @type {String} + * @readonly + */ + StageGL.BLEND_FRAGMENT_COMPLEX = ( + StageGL.BLEND_FRAGMENT_SIMPLE + + "vec3 srcClr = min(src.rgb/src.a, 1.0);" + + "vec3 dstClr = min(dst.rgb/dst.a, 1.0);" + + + "float totalAlpha = min(1.0 - (1.0-dst.a) * (1.0-src.a), 1.0);" + + "float srcFactor = min(max(src.a - dst.a, 0.0) / totalAlpha, 1.0);" + + "float dstFactor = min(max(dst.a - src.a, 0.0) / totalAlpha, 1.0);" + + "float mixFactor = max(max(1.0 - srcFactor, 0.0) - dstFactor, 0.0);" + + + "gl_FragColor = vec4(" + + "(" + + "srcFactor * srcClr +" + + "dstFactor * dstClr +" + + "mixFactor * vec3(" + // this should be closed with the cap! + ); + + /** + * The closing portion of a template for a cover fragment shader which has complex blending equations + * @property BLEND_FRAGMENT_COMPLEX_CAP + * @protected + * @static + * @final + * @type {String} + * @readonly + */ + StageGL.BLEND_FRAGMENT_COMPLEX_CAP = ( + ")" + + ") * totalAlpha, totalAlpha" + + ");" + "}" ); + /** + * A shader utility function, used to calculate the "overlay" blend of two elements + * @property BLEND_FRAGMENT_OVERLAY_UTIL + * @protected + * @static + * @final + * @type {String} + * @readonly + */ + StageGL.BLEND_FRAGMENT_OVERLAY_UTIL = ( + "float overlay(float a, float b) {" + + "if(a < 0.5) { return 2.0 * a * b; }" + + "return 1.0 - 2.0 * (1.0-a) * (1.0-b);" + + "}" + ); + + /** + * A collection of shader utility functions, used to calculate HSL math. Taken from W3C spec + * https://www.w3.org/TR/compositing-1/#blendingnonseparable + * @property BLEND_FRAGMENT_HSL_UTIL + * @protected + * @static + * @final + * @type {String} + * @readonly + */ + StageGL.BLEND_FRAGMENT_HSL_UTIL = ( + "float getLum(vec3 c) { return 0.299*c.r + 0.589*c.g + 0.109*c.b; }" + + "float getSat(vec3 c) { return max(max(c.r, c.g), c.b) - min(min(c.r, c.g), c.b); }" + + "vec3 clipHSL(vec3 c) {" + + "float lum = getLum(c);" + + "float n = min(min(c.r, c.g), c.b);" + + "float x = max(max(c.r, c.g), c.b);" + + "if(n < 0.0){ c = lum + (((c - lum) * lum) / (lum - n)); }" + + "if(x > 1.0){ c = lum + (((c - lum) * (1.0 - lum)) / (x - lum)); }" + + "return clamp(c, 0.0, 1.0);" + + "}" + + "vec3 setLum(vec3 c, float lum) {" + + "return clipHSL(c + (lum - getLum(c)));" + + "}" + + "vec3 setSat(vec3 c, float val) {" + + "vec3 result = vec3(0.0);" + + "float minVal = min(min(c.r, c.g), c.b);" + + "float maxVal = max(max(c.r, c.g), c.b);" + + "vec3 minMask = vec3(c.r == minVal, c.g == minVal, c.b == minVal);" + + "vec3 maxMask = vec3(c.r == maxVal, c.g == maxVal, c.b == maxVal);" + + "vec3 midMask = 1.0 - min(minMask+maxMask, 1.0);" + + "float midVal = (c*midMask).r + (c*midMask).g + (c*midMask).b;" + + "if(maxVal > minVal) {" + + "result = midMask * min( ((midVal - minVal) * val) / (maxVal - minVal), 1.0);" + + "result += maxMask * val;" + + "}" + + "return result;" + + "}" + ); + + /** + * The hash of supported blend modes and their properties + * @property BLEND_SOURCES + * @static + * @final + * @type {Object} + * @readonly + */ + StageGL.BLEND_SOURCES = { + "source-over": { // empty object verifies it as a blend mode, but default values handle actual settings + //eqRGB: "FUNC_ADD", eqA: "FUNC_ADD" + //srcRGB: "ONE", srcA: "ONE" + //dstRGB: "ONE_MINUS_SRC_ALPHA", dstA: "ONE_MINUS_SRC_ALPHA" + }, + "source-in": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "gl_FragColor = vec4(src.rgb * dst.a, src.a * dst.a);" + + "}") + }, + "source-in_cheap": { + srcRGB: "DST_ALPHA", srcA: "ZERO", + dstRGB: "ZERO", dstA: "SRC_ALPHA" + }, + "source-out": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "gl_FragColor = vec4(src.rgb * (1.0 - dst.a), src.a - dst.a);" + + "}") + }, + "source-out_cheap": { + eqA: "FUNC_SUBTRACT", + srcRGB: "ONE_MINUS_DST_ALPHA", srcA: "ONE", + dstRGB: "ZERO", dstA: "SRC_ALPHA" + }, + "source-atop": { + srcRGB: "DST_ALPHA", srcA: "ZERO", + dstRGB: "ONE_MINUS_SRC_ALPHA", dstA: "ONE" + }, + "destination-over": { + srcRGB: "ONE_MINUS_DST_ALPHA", srcA: "ONE_MINUS_DST_ALPHA", + dstRGB: "ONE", dstA: "ONE" + }, + "destination-in": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "gl_FragColor = vec4(dst.rgb * src.a, src.a * dst.a);" + + "}") + }, + "destination-in_cheap": { + srcRGB: "ZERO", srcA: "DST_ALPHA", + dstRGB: "SRC_ALPHA", dstA: "ZERO" + }, + "destination-out": { + eqA: "FUNC_REVERSE_SUBTRACT", + srcRGB: "ZERO", srcA: "DST_ALPHA", + dstRGB: "ONE_MINUS_SRC_ALPHA", dstA: "ONE" + }, + "destination-atop": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "gl_FragColor = vec4(dst.rgb * src.a + src.rgb * (1.0 - dst.a), src.a);" + + "}") + }, + "destination-atop_cheap": { + srcRGB: "ONE_MINUS_DST_ALPHA", srcA: "ONE", + dstRGB: "SRC_ALPHA", dstA: "ZERO" + }, + "copy": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "gl_FragColor = vec4(src.rgb, src.a);" + + "}") + }, + "copy_cheap": { + dstRGB: "ZERO", dstA: "ZERO" + }, + "xor": { + shader: (StageGL.BLEND_FRAGMENT_SIMPLE + + "float omSRC = (1.0 - src.a);" + + "float omDST = (1.0 - dst.a);" + + "gl_FragColor = vec4(src.rgb * omDST + dst.rgb * omSRC, src.a * omDST + dst.a * omSRC);" + + "}") + }, + + "multiply": { // this has to be complex to handle retention of both dst and src in non mixed scenarios + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "srcClr * dstClr" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "multiply_cheap": { // NEW, handles retention of src data incorrectly when no dst data present + srcRGB: "ONE_MINUS_DST_ALPHA", srcA: "ONE", + dstRGB: "SRC_COLOR", dstA: "ONE" + }, + "screen": { + srcRGB: "ONE", srcA: "ONE", + dstRGB: "ONE_MINUS_SRC_COLOR", dstA: "ONE_MINUS_SRC_ALPHA" + }, + "lighter": { + dstRGB: "ONE", dstA:"ONE" + }, + "lighten": { //WebGL 2.0 can optimize this + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "max(srcClr, dstClr)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "darken": { //WebGL 2.0 can optimize this + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "min(srcClr, dstClr)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + + "overlay": { + shader: (StageGL.BLEND_FRAGMENT_OVERLAY_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "overlay(dstClr.r,srcClr.r), overlay(dstClr.g,srcClr.g), overlay(dstClr.b,srcClr.b)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "hard-light": { + shader: (StageGL.BLEND_FRAGMENT_OVERLAY_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "overlay(srcClr.r,dstClr.r), overlay(srcClr.g,dstClr.g), overlay(srcClr.b,dstClr.b)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "soft-light": { + shader: ( + "float softcurve(float a) {" + + "if(a > 0.25) { return sqrt(a); }" + + "return ((16.0 * a - 12.0) * a + 4.0) * a;" + + "}" + + "float softmix(float a, float b) {" + + "if(b <= 0.5) { return a - (1.0 - 2.0*b) * a * (1.0 - a); }" + + "return a + (2.0 * b - 1.0) * (softcurve(a) - a);" + + "}" + StageGL.BLEND_FRAGMENT_COMPLEX + + "softmix(dstClr.r,srcClr.r), softmix(dstClr.g,srcClr.g), softmix(dstClr.b,srcClr.b)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "color-dodge": { + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "clamp(dstClr / (1.0 - srcClr), 0.0, 1.0)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "color-burn": { + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "1.0 - clamp((1.0 - smoothstep(0.0035, 0.9955, dstClr)) / smoothstep(0.0035, 0.9955, srcClr), 0.0, 1.0)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "difference": { // do this to match visible results in browsers + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "abs(src.rgb - dstClr)" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "exclusion": { // do this to match visible results in browsers + shader: (StageGL.BLEND_FRAGMENT_COMPLEX + + "dstClr + src.rgb - 2.0 * src.rgb * dstClr" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + + "hue": { + shader: (StageGL.BLEND_FRAGMENT_HSL_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "setLum(setSat(srcClr, getSat(dstClr)), getLum(dstClr))" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "saturation": { + shader: (StageGL.BLEND_FRAGMENT_HSL_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "setLum(setSat(dstClr, getSat(srcClr)), getLum(dstClr))" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "color": { + shader: (StageGL.BLEND_FRAGMENT_HSL_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "setLum(srcClr, getLum(dstClr))" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + }, + "luminosity": { + shader: (StageGL.BLEND_FRAGMENT_HSL_UTIL + StageGL.BLEND_FRAGMENT_COMPLEX + + "setLum(dstClr, getLum(srcClr))" + + StageGL.BLEND_FRAGMENT_COMPLEX_CAP) + } + }; + // events: /** * Dispatched each update immediately before the canvas is cleared and the display list is drawn to it. You can call @@ -9533,7 +10153,7 @@ this.createjs = this.createjs||{}; p._set_autoPurge = function (value) { value = isNaN(value)?1200:value; - if (value != -1) { + if (value !== -1) { value = value<10?10:value; } this._autoPurge = value; @@ -9555,10 +10175,12 @@ this.createjs = this.createjs||{}; /** * Specifies whether or not StageGL is automatically purging unused textures. Higher numbers purge less - * often. Values below 10 are upgraded to 10, and -1 disables this feature. + * often. Values below 10 are upgraded to 10, and -1 disables this feature. If you are not dynamically adding + * and removing new images this can be se9000t to -1, and should be for performance reasons. If you only add images, + * or add and remove the same images for the entire application, it is safe to turn off this feature. Alternately, + * manually manage removing textures yourself with {{#crossLink "StageGL/releaseTexture"}}{{/crossLink}} * @property autoPurge - * @protected - * @type {Integer} + * @type {int} * @default 1000 */ autoPurge: { get: p._get_autoPurge, set: p._set_autoPurge } @@ -9581,30 +10203,36 @@ this.createjs = this.createjs||{}; // defaults and options var options = { - depth: false, // Disable the depth buffer as it isn't used. - alpha: this._transparent, // Make the canvas background transparent. - stencil: true, + depth: false, // nothing has depth + stencil: false, // while there's uses for this, we're not using any yet + premultipliedAlpha: this._transparent, // this is complicated, trust it + + alpha: this._transparent, antialias: this._antialias, - premultipliedAlpha: this._premultiply, // Assume the drawing buffer contains colors with premultiplied alpha. preserveDrawingBuffer: this._preserveBuffer }; var gl = this._webGLContext = this._fetchWebGLContext(this.canvas, options); if (!gl) { return null; } - this.updateSimultaneousTextureCount(gl.getParameter(gl.MAX_TEXTURE_IMAGE_UNITS)); - this._maxTextureSlots = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); - this._createBuffers(gl); - this._initTextures(gl); - gl.disable(gl.DEPTH_TEST); + gl.depthMask(false); gl.enable(gl.BLEND); - gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA); - gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this._premultiply); - //gl.pixelStorei(gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, gl.NONE); + gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); + gl.clearColor(0.0, 0.0, 0.0, 0); + gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD); + gl.blendFuncSeparate(gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA); + + this._createBuffers(); + this._initMaterials(); + this._updateRenderMode("source-over"); + + this.updateViewport(this.canvas.width, this.canvas.height); + if (!this._directDraw) { + this._bufferTextureOutput = this.getRenderBufferTexture(this._viewportWidth, this._viewportHeight); + } - this._webGLContext.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearColor.a); - this.updateViewport(this._viewportWidth || this.canvas.width, this._viewportHeight || this.canvas.height); + this.canvas._invalid = true; } } else { this._webGLContext = null; @@ -9613,23 +10241,17 @@ this.createjs = this.createjs||{}; }; // public methods: - /** - * Docced in superclass - */ + // Docced in superclass p.update = function (props) { if (!this.canvas) { return; } if (this.tickOnUpdate) { this.tick(props); } this.dispatchEvent("drawstart"); - if (this.autoClear) { this.clear(); } if (this._webGLContext) { - // Use WebGL. - this._batchDraw(this, this._webGLContext); - if (this._autoPurge != -1 && !(this._drawID%((this._autoPurge/2)|0))) { - this.purgeTextures(this._autoPurge); - } + this.draw(this._webGLContext, false); } else { // Use 2D. + if (this.autoClear) { this.clear(); } var ctx = this.canvas.getContext("2d"); ctx.save(); this.updateContext(ctx); @@ -9639,23 +10261,18 @@ this.createjs = this.createjs||{}; this.dispatchEvent("drawend"); }; - /** - * Docced in superclass - */ + // Docced in superclass p.clear = function () { if (!this.canvas) { return; } - if (StageGL.isWebGLActive(this._webGLContext)) { - var gl = this._webGLContext; - var cc = this._clearColor; - var adjust = this._transparent ? cc.a : 1.0; - // Use WebGL settings; adjust for pre multiplied alpha appropriate to scenario - this._webGLContext.clearColor(cc.r * adjust, cc.g * adjust, cc.b * adjust, adjust); - gl.clear(gl.COLOR_BUFFER_BIT); - this._webGLContext.clearColor(cc.r, cc.g, cc.b, cc.a); - } else { - // Use 2D. + + var gl = this._webGLContext; + if (!StageGL.isWebGLActive(gl)) { // Use 2D. this.Stage_clear(); + return; } + + gl.bindFramebuffer(gl.FRAMEBUFFER, null); + this._clearFrameBuffer(this._transparent ? this._clearColor.a : 1); }; /** @@ -9671,13 +10288,55 @@ this.createjs = this.createjs||{}; * @return {Boolean} If the draw was handled by this function */ p.draw = function (context, ignoreCache) { - if (context === this._webGLContext && StageGL.isWebGLActive(this._webGLContext)) { - var gl = this._webGLContext; - this._batchDraw(this, gl, ignoreCache); - return true; - } else { + var gl = this._webGLContext; + // 2D context fallback + if (!(context === this._webGLContext && StageGL.isWebGLActive(gl))) { return this.Stage_draw(context, ignoreCache); } + + var storeBatchOutput = this._batchTextureOutput; + var storeBatchConcat = this._batchTextureConcat; + var storeBatchTemp = this._batchTextureTemp; + + // Use WebGL + this._renderPerDraw = 0; + this._batchVertexCount = 0; + this._drawID++; + + if (this._directDraw) { + this._batchTextureOutput = this; + if (this.autoClear) { this.clear(); } + } else { + this._batchTextureOutput = this._bufferTextureOutput; + this._batchTextureConcat = this._bufferTextureConcat; + this._batchTextureTemp = this._bufferTextureTemp; + } + + this._updateRenderMode("source-over"); + this._drawContent(this, ignoreCache); + + if (!this._directDraw) { + if (this.autoClear) { this.clear(); } + this.batchReason = "finalOutput"; + if(this._renderPerDraw) { + this._drawCover(null, this._batchTextureOutput); + } + } + + // batches may generate or swap around textures. To be sure we capture them, store them back into buffer + this._bufferTextureOutput = this._batchTextureOutput; + this._bufferTextureConcat = this._batchTextureConcat; + this._bufferTextureTemp = this._batchTextureTemp; + + this._batchTextureOutput = storeBatchOutput; + this._batchTextureConcat = storeBatchConcat; + this._batchTextureTemp = storeBatchTemp; + + if (this._autoPurge !== -1 && !(this._drawID%((this._autoPurge/2)|0))) { + this.purgeTextures(this._autoPurge); + } + + return true; }; /** @@ -9687,81 +10346,70 @@ this.createjs = this.createjs||{}; * @method cacheDraw * @param {DisplayObject} target The object we're drawing into cache. * For example, used for drawing the cache (to prevent it from simply drawing an existing cache back into itself). - * @param {Array} filters The filters we're drawing into cache. * @param {BitmapCache} manager The BitmapCache instance looking after the cache * @return {Boolean} If the draw was handled by this function */ - p.cacheDraw = function (target, filters, manager) { - if (StageGL.isWebGLActive(this._webGLContext)) { - var gl = this._webGLContext; - this._cacheDraw(gl, target, filters, manager); - return true; - } else { + p.cacheDraw = function (target, manager) { + // 2D context fallback + if (!StageGL.isWebGLActive(this._webGLContext)) { return false; } - }; - /** - * Blocks, or frees a texture "slot" on the GPU. Can be useful if you are overflowing textures. When overflowing - * textures they are re-uploaded to the GPU every time they're encountered, this can be expensive with large textures. - * By blocking the slot you reduce available slots, potentially increasing draw calls, but mostly you prevent a - * texture being re-uploaded if it would have moved slots due to overflow. - * - * NOTE: This method is mainly for internal use, though it may be useful for advanced uses. - * For example, block the slot a background image is stored in so there is less re-loading of that image. - * @method protectTextureSlot - * @param {Number} id The slot to be affected - * @param {Boolean} [lock=false] Whether this slot is the one being locked. - */ - p.protectTextureSlot = function (id, lock) { - if (id > this._maxTextureSlots || id < 0) { - throw "Slot outside of acceptable range"; + for (var i = 0; i < this._gpuTextureCount; i++) { + if(this._batchTextures[i]._frameBuffer) { + this._batchTextures[i] = this._baseTextures[i]; + } } - this._slotBlacklist[id] = !!lock; - }; - /** - * Render textures can't draw into themselves so any item being used for renderTextures needs two to alternate between. - * This function creates, gets, and toggles the render surface between the two. - * - * NOTE: This method is mainly for internal use, though it may be useful for advanced uses. - * @method getTargetRenderTexture - * @param {DisplayObject} target The object associated with the render textures, usually a cached object. - * @param {Number} w The width to create the texture at. - * @param {Number} h The height to create the texture at. - * @return {Objet} - * @todo fill in return type - */ - p.getTargetRenderTexture = function (target, w, h) { - var result, toggle = false; - var gl = this._webGLContext; - if (target.__lastRT !== undefined && target.__lastRT === target.__rtA) { toggle = true; } - if (!toggle) { - if (target.__rtA === undefined) { - target.__rtA = this.getRenderBufferTexture(w, h); - } else { - if (w != target.__rtA._width || h != target.__rtA._height) { - this.resizeTexture(target.__rtA, w, h); - } - this.setTextureParams(gl); - } - result = target.__rtA; - } else { - if (target.__rtB === undefined) { - target.__rtB = this.getRenderBufferTexture(w, h); - } else { - if (w != target.__rtB._width || h != target.__rtB._height) { - this.resizeTexture(target.__rtB, w, h); - } - this.setTextureParams(gl); - } - result = target.__rtB; + var storeBatchOutput = this._batchTextureOutput; + var storeBatchConcat = this._batchTextureConcat; + var storeBatchTemp = this._batchTextureTemp; + + var filterCount = manager._filterCount, filtersLeft = filterCount; + var backupWidth = this._viewportWidth, backupHeight = this._viewportHeight; + this._updateDrawingSurface(manager._drawWidth, manager._drawHeight); + + this._batchTextureOutput = (manager._filterCount%2) ? manager._bufferTextureConcat : manager._bufferTextureOutput; + this._batchTextureConcat = (manager._filterCount%2) ? manager._bufferTextureOutput : manager._bufferTextureConcat; + this._batchTextureTemp = manager._bufferTextureTemp; + + var container = this._cacheContainer; + container.children = [target]; + container.transformMatrix = this._alignTargetToCache(target, manager); + + this._updateRenderMode("source-over"); + this._drawContent(container, true); + + // re-align buffers with fake filter passes to solve certain error cases + if (this.isCacheControlled) { + // post filter pass to place content into output buffer + //TODO: add in directDraw support for cache controlled StageGLs + filterCount++; + filtersLeft++; + } else if (manager._cacheCanvas !== ((manager._filterCount%2) ? this._batchTextureConcat : this._batchTextureOutput)) { + // pre filter pass to align output, may of become misaligned due to composite operations + filtersLeft++; } - if (!result) { - throw "Problems creating render textures, known causes include using too much VRAM by not releasing WebGL texture instances"; + + while (filtersLeft) { //warning: pay attention to where filtersLeft is modified, this is a micro-optimization + var filter = manager._getGLFilter(filterCount - (filtersLeft--)); + var swap = this._batchTextureConcat; + this._batchTextureConcat = this._batchTextureOutput; + this._batchTextureOutput = (this.isCacheControlled && filtersLeft === 0) ? this : swap; + this.batchReason = "filterPass"; + this._drawCover(this._batchTextureOutput._frameBuffer, this._batchTextureConcat, filter); } - target.__lastRT = result; - return result; + + manager._bufferTextureOutput = this._batchTextureOutput; + manager._bufferTextureConcat = this._batchTextureConcat; + manager._bufferTextureTemp = this._batchTextureTemp; + + this._batchTextureOutput = storeBatchOutput; + this._batchTextureConcat = storeBatchConcat; + this._batchTextureTemp = storeBatchTemp; + + this._updateDrawingSurface(backupWidth, backupHeight); + return true; }; /** @@ -9775,18 +10423,19 @@ this.createjs = this.createjs||{}; * developer to ensure that a texture in use is not removed. * * Textures in use, or to be used again shortly, should not be removed. This is simply for performance reasons. - * Removing a texture in use will cause the texture to have to be re-uploaded slowing rendering. + * Removing a texture in use will cause the texture to end up being re-uploaded slowing rendering. * @method releaseTexture - * @param {DisplayObject | Texture | Image | Canvas} item An object that used the texture to be discarded. + * @param {DisplayObject | WebGLTexture | Image | Canvas} item An object that used the texture to be discarded. + * @param {Boolean} [safe=false] Should the release attempt to be "safe" and only delete this usage. */ - p.releaseTexture = function (item) { + p.releaseTexture = function (item, safe) { var i, l; if (!item) { return; } // this is a container object if (item.children) { for (i = 0, l = item.children.length; i < l; i++) { - this.releaseTexture(item.children[i]); + this.releaseTexture(item.children[i], safe); } } @@ -9809,10 +10458,11 @@ this.createjs = this.createjs||{}; } else if (item._webGLRenderStyle === 2) { // this is a Bitmap class foundImage = item.image; + if (foundImage.getImage) { foundImage = foundImage.getImage(); } } else if (item._webGLRenderStyle === 1) { // this is a SpriteSheet, we can't tell which image we used from the list easily so remove them all! for (i = 0, l = item.spriteSheet._images.length; i < l; i++) { - this.releaseTexture(item.spriteSheet._images[i]); + this.releaseTexture(item.spriteSheet._images[i], safe); } return; } @@ -9826,14 +10476,22 @@ this.createjs = this.createjs||{}; } // remove it - this._killTextureObject(this._textureDictionary[foundImage._storeID]); - foundImage._storeID = undefined; + var texture = this._textureDictionary[foundImage._storeID]; + if (safe) { + var data = texture._imageData; + var index = data.indexOf(foundImage); + if (index >= 0) { data.splice(index, 1); } + foundImage._storeID = undefined; + if (data.length === 0) { this._killTextureObject(texture); } + } else { + this._killTextureObject(texture); + } }; /** * Similar to {{#crossLink "releaseTexture"}}{{/crossLink}}, but this function differs by searching for textures to * release. It works by assuming that it can purge any texture which was last used more than "count" draw calls ago. - * Because this process is unaware of the objects and whether they may be used on your stage, false positives can + * Because this process is unaware of the objects and whether they may be used later on your stage, false positives can * occur. It is recommended to manually manage your memory with {{#crossLink "StageGL/releaseTexture"}}{{/crossLink}}, * however, there are many use cases where this is simpler and error-free. This process is also run by default under * the hood to prevent leaks. To disable it see the {{#crossLink "StageGL/autoPurge:property"}}{{/crossLink}} property. @@ -9841,53 +10499,24 @@ this.createjs = this.createjs||{}; * @param {Number} [count=100] How many renders ago the texture was last used */ p.purgeTextures = function (count) { - if (count == undefined){ count = 100; } + if (!(count >= 0)){ count = 100; } var dict = this._textureDictionary; var l = dict.length; - for (var i= 0; i>> is an unsigned shift which is what we want as 0x80000000 and up are negative values - r = ((color & 0xFF000000) >>> 24)/255; - g = ((color & 0x00FF0000) >>> 16)/255; - b = ((color & 0x0000FF00) >>> 8)/255; - a = (color & 0x000000FF)/255; } - this._clearColor.r = r || 0; - this._clearColor.g = g || 0; - this._clearColor.b = b || 0; - this._clearColor.a = a || 0; + // create the dataurl + dataURL = this.canvas.toDataURL(mimeType||"image/png", encoderOptions); + + // reset the picture in the canvas + if(!this._preserveBuffer || backgroundColor !== undefined) { + if(backgroundColor !== undefined) { + this._clearColor = clearBackup; + } + this.clear(); + if(!this._directDraw) { + this._drawCover(null, this._bufferTextureOutput); + } else { + this.draw(gl); + } + } - if (!this._webGLContext) { return; } - this._webGLContext.clearColor(this._clearColor.r, this._clearColor.g, this._clearColor.b, this._clearColor.a); + return dataURL; }; - /** - * docced in subclass - */ + // Docced in subclass p.toString = function () { return "[StageGL (name="+ this.name +")]"; }; // private methods: + /** + * Changes the active drawing surface and view matrix to the correct parameters without polluting the concept + * of the current stage size + * @param {uint} w The width of the surface in pixels, defaults to _viewportWidth + * @param {uint} h The height of the surface in pixels, defaults to _viewportHeight + */ + p._updateDrawingSurface = function(w, h) { + this._viewportWidth = w; + this._viewportHeight = h; + + this._webGLContext.viewport(0, 0, this._viewportWidth, this._viewportHeight); + + // WebGL works with a -1,1 space on its screen. It also follows Y-Up + // we need to flip the y, scale and then translate the co-ordinates to match this + // additionally we offset into they Y so the polygons are inside the camera's "clipping" plane + this._projectionMatrix = new Float32Array([ + 2 / w, 0, 0, 0, + 0, -2 / h, 0, 0, + 0, 0, 1, 0, + -1, 1, 0, 1 + ]); + }; + + /** + * Returns a base texture that has no image or data loaded. Not intended for loading images. In some error cases, + * the texture creation will fail. This function differs from {{#crossLink "StageGL/getBaseTexture"}}{{/crossLink}} + * in that the failed textures will be replaced with a safe to render "nothing" texture. + * @method _getSafeTexture + * @param {uint} [w=1] The width of the texture in pixels, defaults to 1 + * @param {uint} [h=1] The height of the texture in pixels, defaults to 1 + * @protected + */ + p._getSafeTexture = function (w, h) { + var texture = this.getBaseTexture(w, h); + + if (!texture) { + var msg = "Problem creating texture, possible cause: using too much VRAM, please try releasing texture memory"; + (console.error && console.error(msg)) || console.log(msg); + + texture = this._baseTextures[0]; + } + + return texture; + }; + + /** + * Visually clear out the currently active FrameBuffer, does not rebind or adjust the frameBuffer in use. + * @method _getSafeTexture + * @param alpha + * @protected + */ + p._clearFrameBuffer = function (alpha) { + var gl = this._webGLContext; + var cc = this._clearColor; + + if (alpha > 0) { alpha = 1; } + if (alpha < 0) { alpha = 0; } + + // Use WebGL settings; adjust for pre multiplied alpha appropriate to scenario + gl.clearColor(cc.r * alpha, cc.g * alpha, cc.b * alpha, alpha); + gl.clear(gl.COLOR_BUFFER_BIT); + gl.clearColor(0, 0, 0, 0); + }; + /** * Sets up and returns the WebGL context for the canvas. May return undefined in error scenarios. These can include * situations where the canvas element already has a context, 2D or GL. @@ -10161,40 +10872,29 @@ this.createjs = this.createjs||{}; * filters. Once compiled, shaders are saved so. If the Shader code requires dynamic alterations re-run this function * to generate a new shader. * @method _fetchShaderProgram - * @param {WebGLRenderingContext} gl The canvas WebGL context object to draw into. - * @param {String} [shaderName="regular"] Working values: "regular", "override", and "filter". Which type of shader to build. + * @param {Boolean} coverShader Is this a per object shader or a cover shader * Filter and override both accept the custom params. Regular and override have all features. Filter is a special case reduced feature shader meant to be over-ridden. - * @param {String} [customVTX] Extra vertex shader information to replace a regular draw, see + * @param {String | undefined} [customVTX=undefined] Extra vertex shader information to replace a regular draw, see * {{#crossLink "StageGL/COVER_VERTEX_BODY"}}{{/crossLink}} for default and {{#crossLink "Filter"}}{{/crossLink}} for examples. - * @param {String} [customFRAG] Extra fragment shader information to replace a regular draw, see + * @param {String | undefined} [customFRAG=undefined] Extra fragment shader information to replace a regular draw, see * {{#crossLink "StageGL/COVER_FRAGMENT_BODY"}}{{/crossLink}} for default and {{#crossLink "Filter"}}{{/crossLink}} for examples. - * @param {Function} [shaderParamSetup] Function to run so custom shader parameters can get applied for the render. + * @param {Function | undefined} [shaderParamSetup=undefined] Function to run so custom shader parameters can get applied for the render. * @protected * @return {WebGLProgram} The compiled and linked shader */ - p._fetchShaderProgram = function (gl, shaderName, customVTX, customFRAG, shaderParamSetup) { + p._fetchShaderProgram = function (coverShader, customVTX, customFRAG, shaderParamSetup) { + var gl = this._webGLContext; + gl.useProgram(null); // safety to avoid collisions // build the correct shader string out of the right headers and bodies var targetFrag, targetVtx; - switch (shaderName) { - case "filter": - targetVtx = StageGL.COVER_VERTEX_HEADER + (customVTX || StageGL.COVER_VERTEX_BODY); - targetFrag = StageGL.COVER_FRAGMENT_HEADER + (customFRAG || StageGL.COVER_FRAGMENT_BODY); - break; - case "particle": //TODO - targetVtx = StageGL.REGULAR_VERTEX_HEADER + StageGL.PARTICLE_VERTEX_BODY; - targetFrag = StageGL.REGULAR_FRAGMENT_HEADER + StageGL.PARTICLE_FRAGMENT_BODY; - break; - case "override": - targetVtx = StageGL.REGULAR_VERTEX_HEADER + (customVTX || StageGL.REGULAR_VERTEX_BODY); - targetFrag = StageGL.REGULAR_FRAGMENT_HEADER + (customFRAG || StageGL.REGULAR_FRAGMENT_BODY); - break; - case "regular": - default: - targetVtx = StageGL.REGULAR_VERTEX_HEADER + StageGL.REGULAR_VERTEX_BODY; - targetFrag = StageGL.REGULAR_FRAGMENT_HEADER + StageGL.REGULAR_FRAGMENT_BODY; - break; + if (coverShader) { + targetVtx = StageGL.COVER_VERTEX_HEADER + (customVTX || StageGL.COVER_VERTEX_BODY); + targetFrag = StageGL.COVER_FRAGMENT_HEADER + (customFRAG || StageGL.COVER_FRAGMENT_BODY); + } else { + targetVtx = StageGL.REGULAR_VERTEX_HEADER + (customVTX || StageGL.REGULAR_VERTEX_BODY); + targetFrag = StageGL.REGULAR_FRAGMENT_HEADER + (customFRAG || StageGL.REGULAR_FRAGMENT_BODY); } // create the separate vars @@ -10206,7 +10906,6 @@ this.createjs = this.createjs||{}; gl.attachShader(shaderProgram, vertexShader); gl.attachShader(shaderProgram, fragmentShader); gl.linkProgram(shaderProgram); - shaderProgram._type = shaderName; // check compile status if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { @@ -10216,58 +10915,44 @@ this.createjs = this.createjs||{}; // set up the parameters on the shader gl.useProgram(shaderProgram); - switch (shaderName) { - case "filter": - // get the places in memory the shader is stored so we can feed information into them - // then save it off on the shader because it's so tied to the shader itself - shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "vertexPosition"); - gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute); - shaderProgram.uvPositionAttribute = gl.getAttribLocation(shaderProgram, "uvPosition"); - gl.enableVertexAttribArray(shaderProgram.uvPositionAttribute); + // get the places in memory the shader is stored so we can feed information into them + // then save it off on the shader because it's so tied to the shader itself + shaderProgram.positionAttribute = gl.getAttribLocation(shaderProgram, "vertexPosition"); + gl.enableVertexAttribArray(shaderProgram.positionAttribute); - shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); - gl.uniform1i(shaderProgram.samplerUniform, 0); + shaderProgram.uvPositionAttribute = gl.getAttribLocation(shaderProgram, "uvPosition"); + gl.enableVertexAttribArray(shaderProgram.uvPositionAttribute); - shaderProgram.uprightUniform = gl.getUniformLocation(shaderProgram, "uUpright"); - gl.uniform1f(shaderProgram.uprightUniform, 0); + if (coverShader) { + shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); + gl.uniform1i(shaderProgram.samplerUniform, 0); - // if there's some custom attributes be sure to hook them up - if (shaderParamSetup) { - shaderParamSetup(gl, this, shaderProgram); - } - break; - case "override": - case "particle": - case "regular": - default: - // get the places in memory the shader is stored so we can feed information into them - // then save it off on the shader because it's so tied to the shader itself - shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "vertexPosition"); - gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute); - - shaderProgram.uvPositionAttribute = gl.getAttribLocation(shaderProgram, "uvPosition"); - gl.enableVertexAttribArray(shaderProgram.uvPositionAttribute); - - shaderProgram.textureIndexAttribute = gl.getAttribLocation(shaderProgram, "textureIndex"); - gl.enableVertexAttribArray(shaderProgram.textureIndexAttribute); - - shaderProgram.alphaAttribute = gl.getAttribLocation(shaderProgram, "objectAlpha"); - gl.enableVertexAttribArray(shaderProgram.alphaAttribute); - - var samplers = []; - for (var i = 0; i < this._batchTextureCount; i++) { - samplers[i] = i; - } + // if there's some custom attributes be sure to hook them up + if (shaderParamSetup) { + shaderParamSetup(gl, this, shaderProgram); + } + } else { + shaderProgram.textureIndexAttribute = gl.getAttribLocation(shaderProgram, "textureIndex"); + gl.enableVertexAttribArray(shaderProgram.textureIndexAttribute); + + shaderProgram.alphaAttribute = gl.getAttribLocation(shaderProgram, "objectAlpha"); + gl.enableVertexAttribArray(shaderProgram.alphaAttribute); + + var samplers = []; + for (var i = 0; i < this._gpuTextureCount; i++) { + samplers[i] = i; + } + shaderProgram.samplerData = samplers; - shaderProgram.samplerData = samplers; - shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); - gl.uniform1iv(shaderProgram.samplerUniform, samplers); + shaderProgram.samplerUniform = gl.getUniformLocation(shaderProgram, "uSampler"); + gl.uniform1iv(shaderProgram.samplerUniform, shaderProgram.samplerData); - shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "pMatrix"); - break; + shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "pMatrix"); } + shaderProgram._type = coverShader ? "cover" : "batch"; + gl.useProgram(this._activeShader); return shaderProgram; }; @@ -10282,17 +10967,20 @@ this.createjs = this.createjs||{}; * @protected */ p._createShader = function (gl, type, str) { - // inject the static number - str = str.replace(/{{count}}/g, this._batchTextureCount); + var textureCount = this._batchTextureCount; - // resolve issue with no dynamic samplers by creating correct samplers in if else chain - // TODO: WebGL 2.0 does not need this support - var insert = ""; - for (var i = 1; i gl.MAX_TEXTURE_SIZE || image.height > gl.MAX_TEXTURE_SIZE){ console && console.error("Oversized Texture: "+ image.width+"x"+image.height +" vs "+ gl.MAX_TEXTURE_SIZE +"max"); @@ -10525,14 +11253,14 @@ this.createjs = this.createjs||{}; * @protected */ p._insertTextureInBatch = function (gl, texture) { - // if it wasn't used last batch - if (this._batchTextures[texture._activeIndex] !== texture) { + var image; + if (this._batchTextures[texture._activeIndex] !== texture) { // if it wasn't used last batch // we've got to find it a a spot. var found = -1; var start = (this._lastTextureInsert+1) % this._batchTextureCount; var look = start; do { - if (this._batchTextures[look]._batchID != this._batchID && !this._slotBlacklist[look]) { + if (this._batchTextures[look]._batchID !== this._batchID && !this._slotBlacklist[look]) { found = look; break; } @@ -10542,26 +11270,27 @@ this.createjs = this.createjs||{}; // we couldn't find anywhere for it go, meaning we're maxed out if (found === -1) { this.batchReason = "textureOverflow"; - this._drawBuffers(gl); // <------------------------------------------------------------------------ - this.batchCardCount = 0; - found = start; + this._renderBatch(); // <------------------------------------------------------------------------ + found = start; //TODO: how do we optimize this to be smarter? } // lets put it into that spot this._batchTextures[found] = texture; texture._activeIndex = found; - var image = texture._imageData; - if (image && image._invalid && texture._drawID !== undefined) { + image = texture._imageData && texture._imageData[0]; // first come first served, potentially problematic + if (image && ((image._invalid === undefined && image._isCanvas) || image._invalid)) { this._updateTextureImageData(gl, image); } else { - gl.activeTexture(gl.TEXTURE0 + found); - gl.bindTexture(gl.TEXTURE_2D, texture); - this.setTextureParams(gl); + // probably redundant, confirm functionality then remove from codebase + //gl.activeTexture(gl.TEXTURE0 + found); + //gl.bindTexture(gl.TEXTURE_2D, texture); + //this.setTextureParams(gl); } this._lastTextureInsert = found; - } else { - var image = texture._imageData; - if (texture._storeID != undefined && image && image._invalid) { + + } else if (texture._drawID !== this._drawID) { // being active from previous draws doesn't mean up to date + image = texture._imageData && texture._imageData[0]; + if (image && ((image._invalid === undefined && image._isCanvas) || image._invalid)) { this._updateTextureImageData(gl, image); } } @@ -10575,32 +11304,35 @@ this.createjs = this.createjs||{}; * {{#crossLink "StageGL/releaseTexture"}}{{/crossLink}} instead as it will call this with the correct texture object(s). * Note: Testing shows this may not happen immediately, have to wait frames for WebGL to have actually adjust memory. * @method _killTextureObject - * @param {Texture} tex The texture to be cleaned out + * @param {WebGLTexture} texture The texture to be cleaned out * @protected */ - p._killTextureObject = function (tex) { - if (!tex) { return; } + p._killTextureObject = function (texture) { + if (!texture) { return; } var gl = this._webGLContext; // remove linkage - if (tex._storeID !== undefined && tex._storeID >= 0) { - this._textureDictionary[tex._storeID] = undefined; + if (texture._storeID !== undefined && texture._storeID >= 0) { + this._textureDictionary[texture._storeID] = undefined; for (var n in this._textureIDs) { - if (this._textureIDs[n] == tex._storeID) { delete this._textureIDs[n]; } + if (this._textureIDs[n] === texture._storeID) { delete this._textureIDs[n]; } + } + var data = texture._imageData; + if (data) { + for (var i=data.length-1; i>=0; i--) { data[i]._storeID = undefined; } } - if(tex._imageData) { tex._imageData._storeID = undefined; } - tex._imageData = tex._storeID = undefined; + texture._imageData = texture._storeID = undefined; } // make sure to drop it out of an active slot - if (tex._activeIndex !== undefined && this._batchTextures[tex._activeIndex] === tex) { - this._batchTextures[tex._activeIndex] = this._baseTextures[tex._activeIndex]; + if (texture._activeIndex !== undefined && this._batchTextures[texture._activeIndex] === texture) { + this._batchTextures[texture._activeIndex] = this._baseTextures[texture._activeIndex]; } // remove buffers if present try { - if (tex._frameBuffer) { gl.deleteFramebuffer(tex._frameBuffer); } - tex._frameBuffer = undefined; + if (texture._frameBuffer) { gl.deleteFramebuffer(texture._frameBuffer); } + texture._frameBuffer = undefined; } catch(e) { /* suppress delete errors because it's already gone or didn't need deleting probably */ if (this.vocalDebug) { console.log(e); } @@ -10608,7 +11340,7 @@ this.createjs = this.createjs||{}; // remove entry try { - gl.deleteTexture(tex); + gl.deleteTexture(texture); } catch(e) { /* suppress delete errors because it's already gone or didn't need deleting probably */ if (this.vocalDebug) { console.log(e); } @@ -10616,241 +11348,180 @@ this.createjs = this.createjs||{}; }; /** - * Store or restore current batch textures into a backup array - * @method _backupBatchTextures - * @param {Boolean} restore Perform a restore instead of a store. - * @param {Array} [target=this._backupTextures] Where to perform the backup, defaults to internal backup. + * Small utility function to keep internal API consistent and set the uniforms for a dual texture cover render + * @method _setCoverMixShaderParams + * @param {WebGLRenderingContext} gl The context where the drawing takes place + * @param stage unused + * @param shaderProgram unused * @protected */ - p._backupBatchTextures = function (restore, target) { - var gl = this._webGLContext; - - if (!this._backupTextures) { this._backupTextures = []; } - if (target === undefined) { target = this._backupTextures; } - - for (var i=0; i 0) { - this._drawBuffers(gl); + p._updateRenderMode = function (newMode) { + if ( newMode === null || newMode === undefined){ newMode = "source-over"; } + + var blendSrc = StageGL.BLEND_SOURCES[newMode]; + if (blendSrc === undefined) { + if (this.vocalDebug){ console.log("Unknown compositeOperation ["+ newMode +"], reverting to default"); } + blendSrc = StageGL.BLEND_SOURCES[newMode = "source-over"]; + } + + if (this._renderMode === newMode) { return; } + + var gl = this._webGLContext; + var shaderData = this._builtShaders[newMode]; + if (shaderData === undefined) { + try { + shaderData = this._builtShaders[newMode] = { + eqRGB: gl[blendSrc.eqRGB || "FUNC_ADD"], + srcRGB: gl[blendSrc.srcRGB || "ONE"], + dstRGB: gl[blendSrc.dstRGB || "ONE_MINUS_SRC_ALPHA"], + eqA: gl[blendSrc.eqA || "FUNC_ADD"], + srcA: gl[blendSrc.srcA || "ONE"], + dstA: gl[blendSrc.dstA || "ONE_MINUS_SRC_ALPHA"], + immediate: blendSrc.shader !== undefined, + shader: (blendSrc.shader || this._builtShaders["source-over"] === undefined) ? + this._fetchShaderProgram( + true, undefined, blendSrc.shader, + this._setCoverMixShaderParams + ) : this._builtShaders["source-over"].shader // re-use source-over when we don't need a new shader + }; + if (blendSrc.shader) { shaderData.shader._name = newMode; } + } catch (e) { + this._builtShaders[newMode] = undefined; + console && console.log("SHADER SWITCH FAILURE", e); + return; + } + } + + if (shaderData.immediate) { + if (this._directDraw) { + if (this.vocalDebug) { console.log("Illegal compositeOperation ["+ newMode +"] due to StageGL.directDraw = true, reverting to default"); } + return; + } + this._activeConfig = this._attributeConfig["micro"]; } - this._isDrawing++; - this._drawID++; - this.batchCardCount = 0; - this.depth = 0; + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureOutput._frameBuffer); - this._appendToBatchGroup(sceneGraph, gl, new createjs.Matrix2D(), this.alpha, ignoreCache); + this.batchReason = "shaderSwap"; + this._renderBatch(); // <-------------------------------------------------------------------------------- - this.batchReason = "drawFinish"; - this._drawBuffers(gl); // <-------------------------------------------------------- - this._isDrawing--; + this._renderMode = newMode; + this._immediateRender = shaderData.immediate; + gl.blendEquationSeparate(shaderData.eqRGB, shaderData.eqA); + gl.blendFuncSeparate(shaderData.srcRGB, shaderData.dstRGB, shaderData.srcA, shaderData.dstA); }; /** - * Perform the drawing process to fill a specific cache texture, including applying filters. - * @method _cacheDraw - * @param {DisplayObject} target The object we're drawing into the cache. For example, used for drawing the cache - * (to prevent it from simply drawing an existing cache back into itself). - * @param {Array} filters The filters we're drawing into cache. - * @param {BitmapCache} manager The BitmapCache instance looking after the cache + * Helper function for the standard content draw + * @method _drawContent + * @param {Stage | Container} content + * @param {Boolean} ignoreCache * @protected */ - p._cacheDraw = function (gl, target, filters, manager) { - /* - Implicitly there are 4 modes to this function: filtered-sameContext, filtered-uniqueContext, sameContext, uniqueContext. - Each situation must be handled slightly differently as 'sameContext' or 'uniqueContext' define how the output works, - one drawing directly into the main context and the other drawing into a stored renderTexture respectively. - When the draw is a 'filtered' draw, the filters are applied sequentially and will draw into saved textures repeatedly. - Once the final filter is done the final output is treated depending upon whether it is a same or unique context. - The internal complexity comes from reducing over-draw, shared code, and issues like textures needing to be flipped - sometimes when written to render textures. - */ - var renderTexture; - var shaderBackup = this._activeShader; - var blackListBackup = this._slotBlacklist; - var lastTextureSlot = this._maxTextureSlots-1; - var wBackup = this._viewportWidth, hBackup = this._viewportHeight; - - // protect the last slot so that we have somewhere to bind the renderTextures so it doesn't get upset - this.protectTextureSlot(lastTextureSlot, true); - - // create offset container for drawing item - var mtx = target.getMatrix(); - mtx = mtx.clone(); - mtx.scale(1/manager.scale, 1/manager.scale); - mtx = mtx.invert(); - mtx.translate(-manager.offX/manager.scale*target.scaleX, -manager.offY/manager.scale*target.scaleY); - var container = this._cacheContainer; - container.children = [target]; - container.transformMatrix = mtx; + p._drawContent = function (content, ignoreCache) { + var gl = this._webGLContext; - this._backupBatchTextures(false); + this._activeShader = this._mainShader; - if (filters && filters.length) { - this._drawFilters(target, filters, manager); - } else { - // is this for another stage or mine? - if (this.isCacheControlled) { - // draw item to canvas I -> C - gl.clear(gl.COLOR_BUFFER_BIT); - this._batchDraw(container, gl, true); - } else { - gl.activeTexture(gl.TEXTURE0 + lastTextureSlot); - target.cacheCanvas = this.getTargetRenderTexture(target, manager._drawWidth, manager._drawHeight); - renderTexture = target.cacheCanvas; - - // draw item to render texture I -> T - gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture._frameBuffer); - this.updateViewport(manager._drawWidth, manager._drawHeight); - this._projectionMatrix = this._projectionMatrixFlip; - gl.clear(gl.COLOR_BUFFER_BIT); - this._batchDraw(container, gl, true); - - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - this.updateViewport(wBackup, hBackup); - } - } + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureOutput._frameBuffer); + if(this._batchTextureOutput._frameBuffer !== null) { gl.clear(gl.COLOR_BUFFER_BIT); } - this._backupBatchTextures(true); + this._appendToBatch(content, new createjs.Matrix2D(), this.alpha, ignoreCache); - this.protectTextureSlot(lastTextureSlot, false); - this._activeShader = shaderBackup; - this._slotBlacklist = blackListBackup; + this.batchReason = "contentEnd"; + this._renderBatch(); }; /** - * Sub portion of _cacheDraw, split off for readability. Do not call independently. - * @method _drawFilters - * @param {DisplayObject} target The object we're drawing with a filter. - * @param {Array} filters The filters we're drawing into cache. - * @param {BitmapCache} manager The BitmapCache instance looking after the cache + * Used to draw one or more textures potentially using a filter into the supplied buffer. + * Mostly used for caches, filters, and outputting final render frames. + * Draws `dst` into `out` after applying `srcFilter` depending on its current value. + * @method _drawCover + * @param {WebGLFramebuffer} out Buffer to draw the results into (null is the canvas element) + * @param {WebGLTexture} dst Base texture layer aka "destination" in image blending terminology + * @param {WebGLTexture | Filter} [srcFilter = undefined] Modification parameter for the draw. If a texture, the + * current _renderMode applies it as a "source" image. If a Filter, the filter is applied to the dst with its params. + * @protected */ - p._drawFilters = function (target, filters, manager) { + p._drawCover = function (out, dst, srcFilter) { var gl = this._webGLContext; - var renderTexture; - var lastTextureSlot = this._maxTextureSlots-1; - var wBackup = this._viewportWidth, hBackup = this._viewportHeight; - - var container = this._cacheContainer; - var filterCount = filters.length; - - // we don't know which texture slot we're dealing with previously and we need one out of the way - // once we're using that slot activate it so when we make and bind our RenderTexture it's safe there - gl.activeTexture(gl.TEXTURE0 + lastTextureSlot); - renderTexture = this.getTargetRenderTexture(target, manager._drawWidth, manager._drawHeight); - // draw item to render texture I -> T - gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture._frameBuffer); - this.updateViewport(manager._drawWidth, manager._drawHeight); - gl.clear(gl.COLOR_BUFFER_BIT); - this._batchDraw(container, gl, true); + gl.bindFramebuffer(gl.FRAMEBUFFER, out); + if (out !== null){ gl.clear(gl.COLOR_BUFFER_BIT); } - // bind the result texture to slot 0 as all filters and cover draws assume original content is in slot 0 gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, renderTexture); + gl.bindTexture(gl.TEXTURE_2D, dst); this.setTextureParams(gl); - var flipY = false; - var i = 0, filter = filters[i]; - do { // this is safe because we wouldn't be in apply filters without a filter count of at least 1 - - // swap to correct shader - this._activeShader = this.getFilterShader(filter); - if (!this._activeShader) { continue; } - - // now the old result is stored in slot 0, make a new render texture - gl.activeTexture(gl.TEXTURE0 + lastTextureSlot); - renderTexture = this.getTargetRenderTexture(target, manager._drawWidth, manager._drawHeight); - gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture._frameBuffer); - - // draw result to render texture R -> T - gl.viewport(0, 0, manager._drawWidth, manager._drawHeight); - gl.clear(gl.COLOR_BUFFER_BIT); - this._drawCover(gl, flipY); - - // bind the result texture to slot 0 as all filters and cover draws assume original content is in slot 0 - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, renderTexture); - this.setTextureParams(gl); - - // use flipping to keep things upright, things already cancel out on a single filter - // this needs to be here as multiPass is not accurate to _this_ frame until after shader acquisition - if (filterCount > 1 || filters[0]._multiPass) { - flipY = !flipY; + if (srcFilter instanceof createjs.Filter) { + this._activeShader = this.getFilterShader(srcFilter); + } else { + if (srcFilter instanceof WebGLTexture) { + gl.activeTexture(gl.TEXTURE1); + gl.bindTexture(gl.TEXTURE_2D, srcFilter); + this.setTextureParams(gl); + } else if (srcFilter !== undefined && this.vocalDebug) { + console.log("Unknown data handed to function: ", srcFilter); } + this._activeShader = this._builtShaders[this._renderMode].shader; + } - // work through the multipass if it's there, otherwise move on - filter = filter._multiPass !== null ? filter._multiPass : filters[++i]; - } while (filter); - - // is this for another stage or mine - if (this.isCacheControlled) { - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - this.updateViewport(wBackup, hBackup); + this._renderCover(); + }; - // draw result to canvas R -> C - this._activeShader = this.getFilterShader(this); - gl.clear(gl.COLOR_BUFFER_BIT); - this._drawCover(gl, flipY); + /** + * Returns a matrix that can be used to counter position the `target` so that it fits and scales to the `manager` + * @param {DisplayObject} target The object to be counter positioned + * @param {BitmapCache} manager The cache manager to be aligned to + * @returns {Matrix2D} The matrix that can be used used to counter position the container + * @method _alignTargetToCache + * @private + */ + p._alignTargetToCache = function(target, manager) { + if (manager._counterMatrix === null) { + manager._counterMatrix = target.getMatrix(); } else { - //TODO: DHG: this is less than ideal. A flipped initial render for this circumstance might help. Adjust the perspective matrix? - if (flipY) { - gl.activeTexture(gl.TEXTURE0 + lastTextureSlot); - renderTexture = this.getTargetRenderTexture(target, manager._drawWidth, manager._drawHeight); - gl.bindFramebuffer(gl.FRAMEBUFFER, renderTexture._frameBuffer); - - this._activeShader = this.getFilterShader(this); - gl.viewport(0, 0, manager._drawWidth, manager._drawHeight); - gl.clear(gl.COLOR_BUFFER_BIT); - this._drawCover(gl, !flipY); - } - gl.bindFramebuffer(gl.FRAMEBUFFER, null); - this.updateViewport(wBackup, hBackup); - - // make sure the last texture is the active thing to draw - target.cacheCanvas = renderTexture; + target.getMatrix(manager._counterMatrix) } + + var mtx = manager._counterMatrix; + mtx.scale(1/manager.scale, 1/manager.scale); + mtx = mtx.invert(); + mtx.translate(-manager.offX/manager.scale*target.scaleX, -manager.offY/manager.scale*target.scaleY); + + return mtx; }; /** * Add all the contents of a container to the pending buffers, called recursively on each container. This may * trigger a draw if a buffer runs out of space. This is the main workforce of the render loop. - * @method _appendToBatchGroup + * @method _appendToBatch * @param {Container} container The {{#crossLink "Container"}}{{/crossLink}} that contains everything to be drawn. - * @param {WebGLRenderingContext} gl The canvas WebGL context object to draw into. * @param {Matrix2D} concatMtx The effective (concatenated) transformation matrix when beginning this container * @param {Number} concatAlpha The effective (concatenated) alpha when beginning this container - * @param {Boolean} ignoreCache Don't use an element's cache during this draw + * @param {Boolean} [ignoreCache=false] Don't use an element's cache during this draw * @protected */ - p._appendToBatchGroup = function (container, gl, concatMtx, concatAlpha, ignoreCache) { + p._appendToBatch = function (container, concatMtx, concatAlpha, ignoreCache) { + var gl = this._webGLContext; + // sort out shared properties - if (!container._glMtx) { container._glMtx = new createjs.Matrix2D(); } var cMtx = container._glMtx; cMtx.copy(concatMtx); - if (container.transformMatrix) { + if (container.transformMatrix !== null) { cMtx.appendMatrix(container.transformMatrix); } else { cMtx.appendTransform( @@ -10861,6 +11532,11 @@ this.createjs = this.createjs||{}; ); } + var previousRenderMode = this._renderMode; + if (container.compositeOperation) { + this._updateRenderMode(container.compositeOperation); + } + // sub components of figuring out the position an object holds var subL, subT, subR, subB; @@ -10868,28 +11544,57 @@ this.createjs = this.createjs||{}; var l = container.children.length; for (var i = 0; i < l; i++) { var item = container.children[i]; + var useCache = (!ignoreCache && item.cacheCanvas) || false; - if (!(item.visible && concatAlpha)) { continue; } - if (!item.cacheCanvas || ignoreCache) { + if (!(item.visible && concatAlpha > 0.0035)) { continue; } + var itemAlpha = item.alpha; + + if (useCache === false) { if (item._updateState){ item._updateState(); } - if (item.children) { - this._appendToBatchGroup(item, gl, cMtx, item.alpha * concatAlpha); - continue; + + if(!this._directDraw && (!ignoreCache && item.cacheCanvas === null && item.filters !== null && item.filters.length)) { + var bounds; + if (item.bitmapCache === null) { + bounds = item.getBounds(); + item.bitmapCache = new createjs.BitmapCache(); + item.bitmapCache._autoGenerated = true; + } + if (item.bitmapCache._autoGenerated) { + this.batchReason = "cachelessFilterInterupt"; + this._renderBatch(); // <---------------------------------------------------- + + item.alpha = 1; + var shaderBackup = this._activeShader; + bounds = bounds || item.getBounds(); + item.bitmapCache.define(item, bounds.x, bounds.y, bounds.width, bounds.height, 1, {useGL:this}); + useCache = item.bitmapCache._cacheCanvas; + + item.alpha = itemAlpha; + this._activeShader = shaderBackup; + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureOutput._frameBuffer); + } } } + if (useCache === false && item.children) { + this._appendToBatch(item, cMtx, itemAlpha * concatAlpha); + continue; + } + + var containerRenderMode = this._renderMode; + if (item.compositeOperation) { + this._updateRenderMode(item.compositeOperation); + } + // check for overflowing batch, if yes then force a render - // TODO: DHG: consider making this polygon count dependant for things like vector draws - if (this.batchCardCount+1 > this._maxCardsPerBatch) { + if (this._batchVertexCount + StageGL.INDICIES_PER_CARD > this._maxBatchVertexCount) { this.batchReason = "vertexOverflow"; - this._drawBuffers(gl); // <------------------------------------------------------------ - this.batchCardCount = 0; + this._renderBatch(); // <------------------------------------------------------------ } // keep track of concatenated position - if (!item._glMtx) { item._glMtx = new createjs.Matrix2D(); } var iMtx = item._glMtx; iMtx.copy(cMtx); if (item.transformMatrix) { @@ -10904,34 +11609,34 @@ this.createjs = this.createjs||{}; } var uvRect, texIndex, image, frame, texture, src; - var useCache = item.cacheCanvas && !ignoreCache; - if (item._webGLRenderStyle === 2 || useCache) { // BITMAP / Cached Canvas - image = (ignoreCache?false:item.cacheCanvas) || item.image; - } else if (item._webGLRenderStyle === 1) { // SPRITE - frame = item.spriteSheet.getFrame(item.currentFrame); //TODO: Faster way? + // get the image data, or abort if not present + // BITMAP / Cached Canvas + if (item._webGLRenderStyle === 2 || useCache !== false) { + image = useCache === false ? item.image : useCache; + + // SPRITE + } else if (item._webGLRenderStyle === 1) { + frame = item.spriteSheet.getFrame(item.currentFrame); if (frame === null) { continue; } image = frame.image; - } else { // MISC (DOM objects render themselves later) + + // MISC (DOM objects render themselves later) + } else { continue; } - - var uvs = this._uvs; - var vertices = this._vertices; - var texI = this._indices; - var alphas = this._alphas; + if (!image) { continue; } // calculate texture - if (!image) { continue; } if (image._storeID === undefined) { // this texture is new to us so load it and add it to the batch texture = this._loadTextureImage(gl, image); - this._insertTextureInBatch(gl, texture); } else { // fetch the texture (render textures know how to look themselves up to simplify this logic) texture = this._textureDictionary[image._storeID]; - if (!texture){ - if (this.vocalDebug){ console.log("Texture should not be looked up while not being stored."); } + + if (!texture){ //TODO: this should really not occur but has due to bugs, hopefully this can be removed eventually + if (this.vocalDebug){ console.log("Image source should not be lookup a non existent texture, please report a bug."); } continue; } @@ -10941,16 +11646,18 @@ this.createjs = this.createjs||{}; } } texIndex = texture._activeIndex; + image._drawID = this._drawID; - if (item._webGLRenderStyle === 2 || useCache) { // BITMAP / Cached Canvas - if (!useCache && item.sourceRect) { + // BITMAP / Cached Canvas + if (item._webGLRenderStyle === 2 || useCache !== false) { + if (useCache === false && item.sourceRect) { // calculate uvs if (!item._uvRect) { item._uvRect = {}; } src = item.sourceRect; uvRect = item._uvRect; - uvRect.t = (src.y)/image.height; + uvRect.t = 1 - ((src.y)/image.height); uvRect.l = (src.x)/image.width; - uvRect.b = (src.y + src.height)/image.height; + uvRect.b = 1 - ((src.y + src.height)/image.height); uvRect.r = (src.x + src.width)/image.width; // calculate vertices @@ -10960,16 +11667,18 @@ this.createjs = this.createjs||{}; // calculate uvs uvRect = StageGL.UV_RECT; // calculate vertices - if (useCache) { + if (useCache === false) { + subL = 0; subT = 0; + subR = image.width+subL; subB = image.height+subT; + } else { src = item.bitmapCache; subL = src.x+(src._filterOffX/src.scale); subT = src.y+(src._filterOffY/src.scale); subR = (src._drawWidth/src.scale)+subL; subB = (src._drawHeight/src.scale)+subT; - } else { - subL = 0; subT = 0; - subR = image.width+subL; subB = image.height+subT; } } - } else if (item._webGLRenderStyle === 1) { // SPRITE + + // SPRITE + } else if (item._webGLRenderStyle === 1) { var rect = frame.rect; // calculate uvs @@ -10983,120 +11692,210 @@ this.createjs = this.createjs||{}; subR = rect.width-frame.regX; subB = rect.height-frame.regY; } - // These must be calculated here else a forced draw might happen after they're set - var offV1 = this.batchCardCount*StageGL.INDICIES_PER_CARD; // offset for 1 component vectors - var offV2 = offV1*2; // offset for 2 component vectors + var spacing = 0; + var cfg = this._activeConfig; + var vpos = cfg.position.array; + var uvs = cfg.uv.array; + var texI = cfg.texture.array; + var alphas = cfg.alpha.array; - //DHG: See Matrix2D.transformPoint for why this math specifically // apply vertices - vertices[offV2] = subL *iMtx.a + subT *iMtx.c +iMtx.tx; vertices[offV2+1] = subL *iMtx.b + subT *iMtx.d +iMtx.ty; - vertices[offV2+2] = subL *iMtx.a + subB *iMtx.c +iMtx.tx; vertices[offV2+3] = subL *iMtx.b + subB *iMtx.d +iMtx.ty; - vertices[offV2+4] = subR *iMtx.a + subT *iMtx.c +iMtx.tx; vertices[offV2+5] = subR *iMtx.b + subT *iMtx.d +iMtx.ty; - vertices[offV2+6] = vertices[offV2+2]; vertices[offV2+7] = vertices[offV2+3]; - vertices[offV2+8] = vertices[offV2+4]; vertices[offV2+9] = vertices[offV2+5]; - vertices[offV2+10] = subR *iMtx.a + subB *iMtx.c +iMtx.tx; vertices[offV2+11] = subR *iMtx.b + subB *iMtx.d +iMtx.ty; + spacing = cfg.position.spacing; + var vtxOff = this._batchVertexCount * spacing + cfg.position.offset; + vpos[vtxOff] = subL*iMtx.a + subT*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subL*iMtx.b + subT*iMtx.d + iMtx.ty; + vtxOff += spacing; + vpos[vtxOff] = subL*iMtx.a + subB*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subL*iMtx.b + subB*iMtx.d + iMtx.ty; + vtxOff += spacing; + vpos[vtxOff] = subR*iMtx.a + subT*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subR*iMtx.b + subT*iMtx.d + iMtx.ty; + vtxOff += spacing; + vpos[vtxOff] = subL*iMtx.a + subB*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subL*iMtx.b + subB*iMtx.d + iMtx.ty; + vtxOff += spacing; + vpos[vtxOff] = subR*iMtx.a + subT*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subR*iMtx.b + subT*iMtx.d + iMtx.ty; + vtxOff += spacing; + vpos[vtxOff] = subR*iMtx.a + subB*iMtx.c + iMtx.tx; vpos[vtxOff+1] = subR*iMtx.b + subB*iMtx.d + iMtx.ty; // apply uvs - uvs[offV2] = uvRect.l; uvs[offV2+1] = uvRect.t; - uvs[offV2+2] = uvRect.l; uvs[offV2+3] = uvRect.b; - uvs[offV2+4] = uvRect.r; uvs[offV2+5] = uvRect.t; - uvs[offV2+6] = uvRect.l; uvs[offV2+7] = uvRect.b; - uvs[offV2+8] = uvRect.r; uvs[offV2+9] = uvRect.t; - uvs[offV2+10] = uvRect.r; uvs[offV2+11] = uvRect.b; + spacing = cfg.uv.spacing; + var uvOff = this._batchVertexCount * spacing + cfg.uv.offset; + uvs[uvOff] = uvRect.l; uvs[uvOff+1] = uvRect.t; + uvOff += spacing; + uvs[uvOff] = uvRect.l; uvs[uvOff+1] = uvRect.b; + uvOff += spacing; + uvs[uvOff] = uvRect.r; uvs[uvOff+1] = uvRect.t; + uvOff += spacing; + uvs[uvOff] = uvRect.l; uvs[uvOff+1] = uvRect.b; + uvOff += spacing; + uvs[uvOff] = uvRect.r; uvs[uvOff+1] = uvRect.t; + uvOff += spacing; + uvs[uvOff] = uvRect.r; uvs[uvOff+1] = uvRect.b; // apply texture - texI[offV1] = texI[offV1+1] = texI[offV1+2] = texI[offV1+3] = texI[offV1+4] = texI[offV1+5] = texIndex; + spacing = cfg.texture.spacing; + var texOff = this._batchVertexCount * spacing + cfg.texture.offset; + texI[texOff] = texIndex; + texOff += spacing; + texI[texOff] = texIndex; + texOff += spacing; + texI[texOff] = texIndex; + texOff += spacing; + texI[texOff] = texIndex; + texOff += spacing; + texI[texOff] = texIndex; + texOff += spacing; + texI[texOff] = texIndex; // apply alpha - alphas[offV1] = alphas[offV1+1] = alphas[offV1+2] = alphas[offV1+3] = alphas[offV1+4] = alphas[offV1+5] = item.alpha * concatAlpha; + spacing = cfg.alpha.spacing; + var aOff = this._batchVertexCount * spacing + cfg.alpha.offset; + alphas[aOff] = itemAlpha * concatAlpha; + aOff += spacing; + alphas[aOff] = itemAlpha * concatAlpha; + aOff += spacing; + alphas[aOff] = itemAlpha * concatAlpha; + aOff += spacing; + alphas[aOff] = itemAlpha * concatAlpha; + aOff += spacing; + alphas[aOff] = itemAlpha * concatAlpha; + aOff += spacing; + alphas[aOff] = itemAlpha * concatAlpha; + + this._batchVertexCount += StageGL.INDICIES_PER_CARD; + + if (this._immediateRender) { + this._activeConfig = this._attributeConfig["default"]; + this._immediateBatchRender(); + } + + if (this._renderMode !== containerRenderMode) { + this._updateRenderMode(containerRenderMode); + } + } + + if (this._renderMode !== previousRenderMode) { + this._updateRenderMode(previousRenderMode); + } + }; + + /** + * The shader or effect needs to be drawn immediately, sub function of `_appendToBatch` + * @method _immediateBatchRender + * @protected + */ + p._immediateBatchRender = function() { + var gl = this._webGLContext; - this.batchCardCount++; + if (this._batchTextureConcat === null){ + this._batchTextureConcat = this.getRenderBufferTexture(this._viewportWidth, this._viewportHeight); + } else { + this.resizeTexture(this._batchTextureConcat, this._viewportWidth, this._viewportHeight); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureConcat._frameBuffer); + gl.clear(gl.COLOR_BUFFER_BIT); + } + if (this._batchTextureTemp === null){ + this._batchTextureTemp = this.getRenderBufferTexture(this._viewportWidth, this._viewportHeight); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureTemp._frameBuffer); + } else { + this.resizeTexture(this._batchTextureTemp, this._viewportWidth, this._viewportHeight); + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureTemp._frameBuffer); + gl.clear(gl.COLOR_BUFFER_BIT); } + + var swap = this._batchTextureOutput; + this._batchTextureOutput = this._batchTextureConcat; + this._batchTextureConcat = swap; + + this._activeShader = this._mainShader; + this.batchReason = "immediatePrep"; + this._renderBatch();//<----------------------------------------------------------------------------------------- + + this.batchReason = "immediateResults"; + this._drawCover(this._batchTextureOutput._frameBuffer, this._batchTextureConcat, this._batchTextureTemp); + + gl.bindFramebuffer(gl.FRAMEBUFFER, this._batchTextureOutput._frameBuffer); }; /** * Draws all the currently defined cards in the buffer to the render surface. - * @method _drawBuffers - * @param {WebGLRenderingContext} gl The canvas WebGL context object to draw into. + * @method _renderBatch * @protected */ - p._drawBuffers = function (gl) { - if (this.batchCardCount <= 0) { return; } // prevents error logs on stages filled with un-renederable content. + p._renderBatch = function () { + if (this._batchVertexCount <= 0) { return; } // prevents error logs on stages filled with un-renederable content. + var gl = this._webGLContext; + this._renderPerDraw++; if (this.vocalDebug) { - console.log("Draw["+ this._drawID +":"+ this._batchID +"] : "+ this.batchReason); + console.log("Batch["+ this._drawID +":"+ this._batchID +"] : "+ this.batchReason); } var shaderProgram = this._activeShader; - var vertexPositionBuffer = this._vertexPositionBuffer; - var textureIndexBuffer = this._textureIndexBuffer; - var uvPositionBuffer = this._uvPositionBuffer; - var alphaBuffer = this._alphaBuffer; + var pc, config = this._activeConfig; gl.useProgram(shaderProgram); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexPositionBuffer); - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._vertices); + pc = config.position; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.positionAttribute, pc.size, pc.type, false, pc.stride, pc.offB); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, pc.array); - gl.bindBuffer(gl.ARRAY_BUFFER, textureIndexBuffer); - gl.vertexAttribPointer(shaderProgram.textureIndexAttribute, textureIndexBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._indices); + pc = config.texture; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.textureIndexAttribute, pc.size, pc.type, false, pc.stride, pc.offB); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, pc.array); - gl.bindBuffer(gl.ARRAY_BUFFER, uvPositionBuffer); - gl.vertexAttribPointer(shaderProgram.uvPositionAttribute, uvPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._uvs); + pc = config.uv; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.uvPositionAttribute, pc.size, pc.type, false, pc.stride, pc.offB); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, pc.array); - gl.bindBuffer(gl.ARRAY_BUFFER, alphaBuffer); - gl.vertexAttribPointer(shaderProgram.alphaAttribute, alphaBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, this._alphas); + pc = config.alpha; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.alphaAttribute, pc.size, pc.type, false, pc.stride, pc.offB); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, pc.array); gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, gl.FALSE, this._projectionMatrix); for (var i = 0; i < this._batchTextureCount; i++) { - var texture = this._batchTextures[i]; gl.activeTexture(gl.TEXTURE0 + i); - gl.bindTexture(gl.TEXTURE_2D, texture); - this.setTextureParams(gl, texture.isPOT); + gl.bindTexture(gl.TEXTURE_2D, this._batchTextures[i]); } - gl.drawArrays(gl.TRIANGLES, 0, this.batchCardCount*StageGL.INDICIES_PER_CARD); + gl.drawArrays(gl.TRIANGLES, 0, this._batchVertexCount); + + this._batchVertexCount = 0; this._batchID++; }; /** - * Draws a card that covers the entire render surface. Mainly used for filters. - * @method _drawBuffers - * @param {WebGLRenderingContext} gl The canvas WebGL context object to draw into. - * @param {Boolean} flipY Covers are used for things like RenderTextures and because of 3D vs Canvas space this can - * end up meaning the `y` space sometimes requires flipping in the render. + * Draws a card that covers the entire render surface. Mainly used for filters and composite operations. + * @method _renderCover * @protected */ - p._drawCover = function (gl, flipY) { - if (this._isDrawing > 0) { - this._drawBuffers(gl); - } + p._renderCover = function () { + var gl = this._webGLContext; + this._renderPerDraw++; if (this.vocalDebug) { - console.log("Draw["+ this._drawID +":"+ this._batchID +"] : "+ "Cover"); + console.log("Cover["+ this._drawID +":"+ this._batchID +"] : "+ this.batchReason); } var shaderProgram = this._activeShader; - var vertexPositionBuffer = this._vertexPositionBuffer; - var uvPositionBuffer = this._uvPositionBuffer; + var pc, config = this._attributeConfig.default; - gl.clear(gl.COLOR_BUFFER_BIT); gl.useProgram(shaderProgram); - gl.bindBuffer(gl.ARRAY_BUFFER, vertexPositionBuffer); - gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, vertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); + pc = config.position; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.positionAttribute, pc.size, pc.type, false, pc.stride, pc.offB); gl.bufferSubData(gl.ARRAY_BUFFER, 0, StageGL.COVER_VERT); - gl.bindBuffer(gl.ARRAY_BUFFER, uvPositionBuffer); - gl.vertexAttribPointer(shaderProgram.uvPositionAttribute, uvPositionBuffer.itemSize, gl.FLOAT, false, 0, 0); - gl.bufferSubData(gl.ARRAY_BUFFER, 0, flipY?StageGL.COVER_UV_FLIP:StageGL.COVER_UV); + + pc = config.uv; + gl.bindBuffer(gl.ARRAY_BUFFER, pc.buffer); + gl.vertexAttribPointer(shaderProgram.uvPositionAttribute, pc.size, pc.type, false, pc.stride, pc.offB); + gl.bufferSubData(gl.ARRAY_BUFFER, 0, StageGL.COVER_UV); gl.uniform1i(shaderProgram.samplerUniform, 0); - gl.uniform1f(shaderProgram.uprightUniform, flipY?0:1); gl.drawArrays(gl.TRIANGLES, 0, StageGL.INDICIES_PER_CARD); + this._batchID++; // while this isn't a batch, this fixes issues with expected textures in expected places }; createjs.StageGL = createjs.promote(StageGL, "Stage"); @@ -11173,9 +11972,7 @@ this.createjs = this.createjs||{}; this.sourceRect = null; // private properties: - /** - * Docced in superclass. - */ + // Docced in superclass this._webGLRenderStyle = createjs.DisplayObject._StageGL_BITMAP; } var p = createjs.extend(Bitmap, createjs.DisplayObject); @@ -11268,9 +12065,7 @@ this.createjs = this.createjs||{}; * @method uncache **/ - /** - * Docced in superclass. - */ + // Docced in superclass p.getBounds = function() { var rect = this.DisplayObject_getBounds(); if (rect) { return rect; } @@ -11287,7 +12082,10 @@ this.createjs = this.createjs||{}; **/ p.clone = function(node) { var image = this.image; - if(image && node){ image = image.cloneNode(); } + if(image && node){ + image = image.cloneNode(); + image.src = image.src; // IE cloneNode bug fix + } var o = new Bitmap(image); if (this.sourceRect) { o.sourceRect = this.sourceRect.clone(); } this._cloneProps(o); @@ -11442,9 +12240,7 @@ this.createjs = this.createjs||{}; **/ this._skipAdvance = false; - /** - * Docced in superclass. - */ + // Docced in superclass this._webGLRenderStyle = createjs.DisplayObject._StageGL_SPRITE; if (frameOrAnimation != null) { this.gotoAndPlay(frameOrAnimation); } @@ -12087,9 +12883,7 @@ this.createjs = this.createjs||{}; return this._drawText(null,{}).height; }; - /** - * Docced in superclass. - */ + // Docced in superclass p.getBounds = function() { var rect = this.DisplayObject_getBounds(); if (rect) { return rect; } @@ -12394,6 +13188,7 @@ this.createjs = this.createjs || {}; /** * Sprite object pool. + * @property _spritePool * @type {Array} * @static * @private @@ -12402,18 +13197,14 @@ this.createjs = this.createjs || {}; // public methods: - /** - * Docced in superclass. - **/ + // Docced in superclass p.draw = function(ctx, ignoreCache) { if (this.DisplayObject_draw(ctx, ignoreCache)) { return; } this._updateState(); this.Container_draw(ctx, ignoreCache); }; - /** - * Docced in superclass. - **/ + // Docced in superclass p.getBounds = function() { this._updateText(); return this.Container_getBounds(); @@ -12459,9 +13250,7 @@ this.createjs = this.createjs || {}; // private methods: - /** - * Docced in superclass. - **/ + // Docced in superclass p._updateState = function() { this._updateText(); }; @@ -12638,15 +13427,15 @@ this.createjs = this.createjs||{}; * * mc.gotoAndPlay("start"); * - * It is recommended to use tween.to() to animate and set properties (use no duration to have it set - * immediately), and the tween.wait() method to create delays between animations. Note that using the - * tween.set() method to affect properties will likely not provide the desired result. + * It is recommended to use `tween.to()` to animate and set properties (use no duration to have it set + * immediately), and the `tween.wait()`method to create delays between animations. Note that using the + * `tween.set()` method to affect properties will likely not provide the desired result. * * @class MovieClip * @main MovieClip * @param {Object} [props] The configuration properties to apply to this instance (ex. `{mode:MovieClip.SYNCHED}`). - * Supported props for the MovieClip are listed below. These props are set on the corresponding instance properties except where - * specified.
        + * Supported props for the MovieClip are listed below. These props are set on the corresponding instance properties + * except where specified.
          *
        • `mode`
        • *
        • `startPosition`
        • *
        • `frameBounds`
        • @@ -12735,12 +13524,11 @@ this.createjs = this.createjs||{}; /** * If true, the MovieClip will automatically be reset to its first frame whenever the timeline adds - * it back onto the display list. This only applies to MovieClip instances with mode=INDEPENDENT. - *

          - * For example, if you had a character animation with a "body" child MovieClip instance - * with different costumes on each frame, you could set body.autoReset = false, so that - * you can manually change the frame it is on, without worrying that it will be reset - * automatically. + * it back onto the display list. This only applies to MovieClip instances with `mode` of "INDEPENDENT". + + * For example, if you had a character animation with a "body" child MovieClip instance with different costumes + * on each frame, you could set `body.autoReset = false`, so that you can manually change the frame it is on, + * without worrying that it will be reset automatically. * @property autoReset * @type Boolean * @default true @@ -12787,9 +13575,9 @@ this.createjs = this.createjs||{}; * mc.timeline.addTween(tween); * * Elements can be added and removed from the timeline by toggling an "_off" property - * using the tweenInstance.to() method. Note that using Tween.set is not recommended to - * create MovieClip animations. The following example will toggle the target off on frame 0, and then back on for - * frame 1. You can use the "visible" property to achieve the same effect. + * using the `tweenInstance.to()` method. Note that using `Tween.set` is not recommended to create MovieClip + * animations. The following example will toggle the target off on frame 0, and then back on for frame 1. You + * can use the "visible" property to achieve the same effect. * * var tween = createjs.Tween.get(target).to({_off:false}) * .wait(1).to({_off:true}) @@ -12903,6 +13691,12 @@ this.createjs = this.createjs||{}; p._getLabels = function() { return this.timeline.getLabels(); }; + + /** + * Use the {{#crossLink "MovieClip/labels:property"}}{{/crossLink}} property instead. + * @method getLabels + * @deprecated + */ // MovieClip.getLabels is @deprecated. Remove for 1.1+ p.getLabels = createjs.deprecate(p._getLabels, "MovieClip.getLabels"); @@ -12915,6 +13709,12 @@ this.createjs = this.createjs||{}; p._getCurrentLabel = function() { return this.timeline.currentLabel; }; + + /** + * Use the {{#crossLink "MovieClip/currentLabel:property"}}{{/crossLink}} property instead. + * @method getCurrentLabel + * @deprecated + */ // MovieClip.getCurrentLabel is @deprecated. Remove for 1.1+ p.getCurrentLabel = createjs.deprecate(p._getCurrentLabel, "MovieClip.getCurrentLabel"); @@ -12927,6 +13727,12 @@ this.createjs = this.createjs||{}; p._getDuration = function() { return this.timeline.duration; }; + + /** + * Use the {{#crossLink "MovieClip/duration:property"}}{{/crossLink}} property instead. + * @method getDuration + * @deprecated + */ // MovieClip.getDuration is @deprecated. Remove for 1.1+ p.getDuration = createjs.deprecate(p._getDuration, "MovieClip.getDuration"); @@ -12971,9 +13777,10 @@ this.createjs = this.createjs||{}; // public methods: /** * Constructor alias for backwards compatibility. This method will be removed in future versions. - * Subclasses should be updated to use {{#crossLink "Utility Methods/extends"}}{{/crossLink}}. + * Subclasses should be updated to use {{#crossLink "Utility Methods/extend"}}{{/crossLink}} and + * {{#crossLink "Utility Methods/promote"}}{{/crossLink}} instead. * @method initialize - * @deprecated in favour of `createjs.promote()` + * @deprecated **/ p.initialize = MovieClip; // TODO: Deprecated. This is for backwards support of Adobe Flash/Animate @@ -13057,14 +13864,15 @@ this.createjs = this.createjs||{}; while ((o = o.parent) && fps === null) { if (o.mode === independent) { fps = o._framerate; } } this._framerate = fps; - if (this.paused) { return; } + // adjusted by Dan Zen 3/27/21 for https://github.com/CreateJS/EaselJS/issues/1048 + if (this.totalFrames <= 1) { return; } // calculate how many frames to advance: var t = (fps !== null && fps !== -1 && time !== null) ? time/(1000/fps) + this._t : 1; var frames = t|0; this._t = t-frames; // leftover time, save to add to next advance. - while (frames--) { this._updateTimeline(this._rawPosition+1, false); } + while (!this.paused && frames--) { this._updateTimeline(this._rawPosition+1, false); } }; /** @@ -13087,9 +13895,6 @@ this.createjs = this.createjs||{}; // private methods: - /** - * Docced in superclass. - **/ p._updateState = function() { if (this._rawPosition === -1 || this.mode !== MovieClip.INDEPENDENT) { this._updateTimeline(-1); } }; @@ -13402,10 +14207,20 @@ this.createjs = this.createjs||{}; return img; }; + /** + * Use the {{#crossLink "DisplayObject/scaleX:property"}}{{/crossLink}} property instead. + * @method addFlippedFrames + * @deprecated + */ // SpriteSheetUtils.addFlippedFrames is @deprecated. Remove for 1.1+ SpriteSheetUtils.addFlippedFrames = createjs.deprecate(null, "SpriteSheetUtils.addFlippedFrames"); - // SpriteSheetUtils.addFlippedFrames is @deprecated. Remove for 1.1+ + /** + * Use the {{#crossLink "AlphaMapFilter"}}{{/crossLink}} instead. + * @method mergeAlpha + * @deprecated + */ + // SpriteSheetUtils.mergeAlpha is @deprecated. Remove for 1.1+ SpriteSheetUtils.mergeAlpha = createjs.deprecate(null, "SpriteSheetUtils.mergeAlpha"); @@ -13997,8 +14812,6 @@ this.createjs = this.createjs||{}; // constructor: /** - * This class is still experimental, and more advanced use is likely to be buggy. Please report bugs. - * * A DOMElement allows you to associate a HTMLElement with the display list. It will be transformed * within the DOM as though it is child of the {{#crossLink "Container"}}{{/crossLink}} it is added to. However, it is * not rendered to canvas, and as such will retain whatever z-index it has relative to the canvas (ie. it will be @@ -14265,9 +15078,11 @@ this.createjs = this.createjs||{}; // constructor: /** - * Base class that all filters should inherit from. Filters need to be applied to objects that have been cached using - * the {{#crossLink "DisplayObject/cache"}}{{/crossLink}} method. If an object changes, please cache it again, or use - * {{#crossLink "DisplayObject/updateCache"}}{{/crossLink}}. Note that the filters must be applied before caching. + * Base class that all filters should inherit from. Appli + * + * When on a regular Stage apply the Filters and then cache the object using the {{#crossLink "DisplayObject/cache"}}{{/crossLink}} method. + * When a cached object changes, please use {{#crossLink "DisplayObject/updateCache"}}{{/crossLink}}. + * When on a StageGL simply setting content in the `.filters` array will trigger an automatic and constantly updated cache. * *

          Example

          * @@ -14281,13 +15096,20 @@ this.createjs = this.createjs||{}; * margins that need to be applied in order to fully display the filter. For example, the {{#crossLink "BlurFilter"}}{{/crossLink}} * will cause an object to feather outwards, resulting in a margin around the shape. * + * Any filter that consumes an external image stretches the image to cover the cached bounds. If this is an undesired + * visual result, then use an intermediary cache to properly size and layout your data before passing it to a filter. + * + * *

          EaselJS Filters

          * EaselJS comes with a number of pre-built filters: - *
          • {{#crossLink "AlphaMapFilter"}}{{/crossLink}} : Map a greyscale image to the alpha channel of a display object
          • - *
          • {{#crossLink "AlphaMaskFilter"}}{{/crossLink}}: Map an image's alpha channel to the alpha channel of a display object
          • - *
          • {{#crossLink "BlurFilter"}}{{/crossLink}}: Apply vertical and horizontal blur to a display object
          • - *
          • {{#crossLink "ColorFilter"}}{{/crossLink}}: Color transform a display object
          • - *
          • {{#crossLink "ColorMatrixFilter"}}{{/crossLink}}: Transform an image using a {{#crossLink "ColorMatrix"}}{{/crossLink}}
          • + *
              + *
            • {{#crossLink "AberrationFilter"}}{{/crossLink}} : Shift the RGB components separately along a given vector
            • + *
            • {{#crossLink "AlphaMapFilter"}}{{/crossLink}} : Map a greyscale image to the alpha channel of a display object
            • + *
            • {{#crossLink "AlphaMaskFilter"}}{{/crossLink}}: Map an image's alpha channel to the alpha channel of a display object
            • + *
            • {{#crossLink "BlurFilter"}}{{/crossLink}}: Apply vertical and horizontal blur to a display object
            • + *
            • {{#crossLink "ColorFilter"}}{{/crossLink}}: Color transform a display object
            • + *
            • {{#crossLink "ColorMatrixFilter"}}{{/crossLink}}: Transform an image using a {{#crossLink "ColorMatrix"}}{{/crossLink}}
            • + *
            • {{#crossLink "DisplacementFilter"}}{{/crossLink}}: Create localized distortions in supplied display object
            • *
            * * @class Filter @@ -14315,7 +15137,6 @@ this.createjs = this.createjs||{}; * Pre-processed template shader code. It will be parsed before being fed in into the shader compiler. * This should be based upon StageGL.SHADER_VERTEX_BODY_REGULAR * @property VTX_SHADER - * @virtual * @type {String} * @readonly */ @@ -14325,7 +15146,6 @@ this.createjs = this.createjs||{}; * Pre-processed template shader code. It will be parsed before being fed in into the shader compiler. * This should be based upon StageGL.SHADER_FRAGMENT_BODY_REGULAR * @property FRAG_SHADER - * @virtual * @type {String} * @readonly */ @@ -14333,6 +15153,30 @@ this.createjs = this.createjs||{}; } var p = Filter.prototype; +// static methods: + /** + * Check to see if an image source being provided is one that is valid. + *

            Valid Sources:

            + *
              + *
            • Image Object
            • + *
            • HTML Canvas Element
            • + *
            • `.cacheCanvas` on an object with the same stage
            • + *
            + * WebGLTextures CANNOT be shared between multiple WebGL contexts. This means the only safe source for a WebGLTexture + * is an object cached using the same StageGL as the object trying to use it in a filter. This function does not + * enforce that restriction, as it is difficult or expensive to detect. The render will crash or fail to load the + * image data if the rule isn't followed. + * @param {HTMLImageElement|HTMLCanvasElement|WebGLTexture} src The element to check for validity + * @return Boolean Whether the source is valid + */ + Filter.isValidImageSource = function(src) { + return Boolean(src) && ( + src instanceof Image || + src instanceof WebGLTexture || + src instanceof HTMLCanvasElement + ); + }; + // public methods: /** * Provides padding values for this filter. That is, how much the filter will extend the visual bounds of an object it is applied to. @@ -14347,7 +15191,6 @@ this.createjs = this.createjs||{}; /** * Assign any unique uniforms or other setup functionality here. * @method shaderParamSetup - * @virtual * @param {WebGLContext} gl The context associated with the stage performing the render. * @param {StageGL} stage The stage instance that will be rendering. * @param {ShaderProgram} shaderProgram The compiled shader that is going to be used to perform the render. @@ -14362,23 +15205,19 @@ this.createjs = this.createjs||{}; * @param {Number} y The y position to use for the source rect. * @param {Number} width The width to use for the source rect. * @param {Number} height The height to use for the source rect. - * @param {CanvasRenderingContext2D} [targetCtx] The 2D context to draw the result to. Defaults to the context passed to ctx. - * @param {Number} [targetX] The x position to draw the result to. Defaults to the value passed to x. - * @param {Number} [targetY] The y position to draw the result to. Defaults to the value passed to y. + * @param {CanvasRenderingContext2D} [targetCtx=ctx] The 2D context to draw the result to. Defaults to the context passed to ctx. * @return {Boolean} If the filter was applied successfully. **/ - p.applyFilter = function(ctx, x, y, width, height, targetCtx, targetX, targetY) { + p.applyFilter = function(ctx, x, y, width, height, targetCtx) { // this is the default behaviour because most filters access pixel data. It is overridden when not needed. targetCtx = targetCtx || ctx; - if (targetX == null) { targetX = x; } - if (targetY == null) { targetY = y; } try { var imageData = ctx.getImageData(x, y, width, height); } catch (e) { return false; } if (this._applyFilter(imageData)) { - targetCtx.putImageData(imageData, targetX, targetY); + targetCtx.putImageData(imageData, x, y); return true; } return false; @@ -14423,7 +15262,6 @@ this.createjs = this.createjs||{}; (function() { "use strict"; - // constructor: /** * The BitmapCache is an internal representation of all the cache properties and logic required in order to "cache" @@ -14432,17 +15270,20 @@ this.createjs = this.createjs||{}; * * Caching in this context is purely visual, and will render the DisplayObject out into an image to be used instead * of the object. The actual cache itself is still stored on the target with the {{#crossLink "DisplayObject/cacheCanvas:property"}}{{/crossLink}}. - * Working with a singular image like a {{#crossLink "Bitmap"}}{{/crossLink}} there is little benefit to performing - * a cache as it is already a single image. Caching is best done on containers containing multiple complex parts that - * do not move often, so that rendering the image instead will improve overall rendering speed. A cached object will - * not visually update until explicitly told to do so with a call to update, much like a Stage. If a cache is being + * Working with a singular image like a {{#crossLink "Bitmap"}}{{/crossLink}} there is little benefit to performing + * a cache as it is already a single image. Caching is best done on containers containing multiple complex parts that + * do not move often, so that rendering the image instead will improve overall rendering speed. A cached object will + * not visually update until explicitly told to do so with a call to update, much like a Stage. If a cache is being * updated every frame it is likely not improving rendering performance. Cache are best used when updates will be sparse. * - * Caching is also a co-requisite for applying filters to prevent expensive filters running constantly without need, - * and to physically enable some effects. The BitmapCache is also responsible for applying filters to objects and - * reads each {{#crossLink "Filter"}}{{/crossLink}} due to this relationship. Real-time Filters are not recommended - * performance wise when dealing with a Context2D canvas. For best performance and to still allow for some visual - * effects use a compositeOperation when possible. + * Caching is also a co-requisite for applying filters to prevent expensive filters running constantly without need, + * and to physically enable some effects. The BitmapCache is also responsible for applying filters to objects and + * reads each {{#crossLink "Filter"}}{{/crossLink}} due to this relationship. Real-time Filters are not recommended + * performance wise when dealing with a Context2D canvas. On a StageGL performance is better so the presence of a + * filter will automatically create a cache if one is not made manually. + * + * Some visual effects can be achieved with a {{#crossLink "DisplayObject/compositeOperation:property"}}{{/crossLink}} + * so check out that setting before settling on a filter. * @class BitmapCache * @constructor **/ @@ -14525,6 +15366,13 @@ this.createjs = this.createjs||{}; this.cacheID = 0; // protected: + /** + * The number of filters found to process this update, used to optimize some decisions and surfaces + * @type {number} + * @private + */ + this._filterCount = 0; + /** * The relative offset of the filter's x position, used for drawing the cache onto its container. * Re-calculated every update call before drawing. @@ -14545,6 +15393,37 @@ this.createjs = this.createjs||{}; **/ this._filterOffY = 0; + /** + * Internal tracking of the disabled state, use the getter/setters. + * @property _disabled + * @type {boolean} + * @protected + */ + this._disabled = false; + + /** + * Internal tracking of whether this cache was automatically created and thus automatically controlled + * @type {boolean} + * @protected + */ + this._autoGenerated = false; + + /** + * Internal tracking of intended cacheCanvas, may or may not be assigned based on disabled state. + * @property _cacheCanvas + * @type {HTMLCanvasElement | WebGLTexture | Object} + * @protected + */ + this._cacheCanvas = null; + + /** + * Output StageGL target for GL drawing + * @property _stageGL + * @type {StageGL} + * @protected + */ + this._stageGL = null; + /** * The cacheID when a DataURL was requested. * @property _cacheDataURLID @@ -14580,9 +15459,73 @@ this.createjs = this.createjs||{}; * @default 0 **/ this._drawHeight = 0; + + /** + * Internal tracking of the last requested bounds, may happen repeadtedly so stored to avoid object creation + * @property _boundRect + * @protected + * @type {Rectangle} + * @default 0 + **/ + this._boundRect = new createjs.Rectangle(); + + // semi protected: not public API but modified by other classes + /** + * Storage for the StageGL counter positioning matrix used on the object being cached + * @property _counterMatrix + * @type {Matrix2D} + */ + this._counterMatrix = null; + + /** + * One of the major render buffers used in composite blending and filter drawing. Do not expect this to always be the same object. + * "What you're drawing to", object occasionally swaps with concat. + * @property _bufferTextureOutput + * @type {WebGLTexture} + */ + this._bufferTextureOutput = null; + + /** + * One of the major render buffers used in composite blending and filter drawing. Do not expect this to always be the same object. + * "What you've draw before now", object occasionally swaps with output. + * @property _bufferTextureConcat + * @type {WebGLTexture} + */ + this._bufferTextureConcat = null; + + /** + * One of the major render buffers used only for composite blending draws. + * "Temporary mixing surface" + * @property _bufferTextureTemp + * @type {WebGLTexture} + */ + this._bufferTextureTemp = null; } var p = BitmapCache.prototype; + p._get_disabled = function () { + return this._disabled; + }; + p._set_disabled = function (value) { + this._disabled = !!value; + if (this.target) { + this.target.cacheCanvas = (this._disabled || this._autoGenerated) ? null : this._cacheCanvas; + } + }; + + try { + Object.defineProperties(p, { + /** + * Disable or enable the BitmapCache from displaying. Does not cause or block cache or cache updates when toggled. + * Best used if the cached state is always identical, but the object will need temporary uncaching. + * @property autoPurge + * @type {Boolean} + * @default false + */ + disabled: { get: p._get_disabled, set: p._set_disabled } + }); + } catch (e) {} // TODO: use Log + /** * Returns the bounds that surround all applied filters, relies on each filter to describe how it changes bounds. * @method getFilterBounds @@ -14592,17 +15535,17 @@ this.createjs = this.createjs||{}; * @static **/ BitmapCache.getFilterBounds = function(target, output) { - if(!output){ output = new createjs.Rectangle(); } + if (!output){ output = new createjs.Rectangle(); } var filters = target.filters; var filterCount = filters && filters.length; if (!!filterCount <= 0) { return output; } - for(var i=0; i= 1) { + if (this._bufferTextureConcat === null) { + this._bufferTextureConcat = this._stageGL.getRenderBufferTexture(this._drawWidth, this._drawHeight); + } else { + this._stageGL.resizeTexture(this._bufferTextureConcat, this._drawWidth, this._drawHeight); + } + } + } + this._filterOffX = filterBounds.x; this._filterOffY = filterBounds.y; this.offX = this.x*this.scale + this._filterOffX; @@ -14733,24 +15712,21 @@ this.createjs = this.createjs||{}; * @method release **/ p.release = function() { - if (this._webGLCache) { - // if it isn't cache controlled clean up after yourself - if (!this._webGLCache.isCacheControlled) { - if (this.__lastRT){ this.__lastRT = undefined; } - if (this.__rtA){ this._webGLCache._killTextureObject(this.__rtA); } - if (this.__rtB){ this._webGLCache._killTextureObject(this.__rtB); } - if (this.target && this.target.cacheCanvas){ this._webGLCache._killTextureObject(this.target.cacheCanvas); } - } + if (this._stageGL) { + if (this._bufferTextureOutput !== null){ this._stageGL._killTextureObject(this._bufferTextureOutput); } + if (this._bufferTextureConcat !== null){ this._stageGL._killTextureObject(this._bufferTextureConcat); } + if (this._bufferTextureTemp !== null){ this._stageGL._killTextureObject(this._bufferTextureTemp); } // set the context to none and let the garbage collector get the rest when the canvas itself gets removed - this._webGLCache = false; + this._stageGL = false; } else { var stage = this.target.stage; - if (stage instanceof createjs.StageGL){ - stage.releaseTexture(this.target.cacheCanvas); + if (stage instanceof createjs.StageGL) { + stage.releaseTexture(this._cacheCanvas); } } - this.target = this.target.cacheCanvas = null; + this.disabled = true; + this.target = this._cacheCanvas = null; this.cacheID = this._cacheDataURLID = this._cacheDataURL = undefined; this.width = this.height = this.x = this.y = this.offX = this.offY = 0; this.scale = 1; @@ -14763,12 +15739,12 @@ this.createjs = this.createjs||{}; * @method getCacheDataURL * @return {String} The image data url for the cache. **/ - p.getCacheDataURL = function() { - var cacheCanvas = this.target && this.target.cacheCanvas; + p.getCacheDataURL = function(type, encoderOptions) { + var cacheCanvas = this.target && this._cacheCanvas; if (!cacheCanvas) { return null; } - if (this.cacheID != this._cacheDataURLID) { + if (this.cacheID !== this._cacheDataURLID) { this._cacheDataURLID = this.cacheID; - this._cacheDataURL = cacheCanvas.toDataURL?cacheCanvas.toDataURL():null; // incase function is + this._cacheDataURL = cacheCanvas.getCacheDataURL ? cacheCanvas.getCacheDataURL(type, encoderOptions) : null; } return this._cacheDataURL; }; @@ -14780,14 +15756,41 @@ this.createjs = this.createjs||{}; * @return {Boolean} Whether the draw was handled successfully. **/ p.draw = function(ctx) { - if(!this.target) { return false; } - ctx.drawImage(this.target.cacheCanvas, + if (!this.target) { return false; } + ctx.drawImage(this._cacheCanvas, this.x + (this._filterOffX/this.scale), this.y + (this._filterOffY/this.scale), this._drawWidth/this.scale, this._drawHeight/this.scale ); return true; }; + /** + * Determine the bounds of the shape in local space. + * @method getBounds + * @return {Rectangle} + */ + p.getBounds = function() { + var scale = this.scale; + return this._boundRect.setValues( + this.x, this.y, + this.width/scale, this.height/scale + ); + }; + + /** + * Fetch the correct filter in order, complicated by multipass filtering. + * @param {Number} lookup The filter in the list to return + */ + p._getGLFilter = function(lookup) { + if (this.target.filters === null || lookup < 0){ return undefined; } + var i = 0; + var result = this.target.filters[i]; + while (result && --lookup >= 0) { + result = result._multiPass ? result._multiPass : this.target.filters[++i]; + } + return result; + }; + // private methods: /** * Create or resize the invisible canvas/surface that is needed for the display object(s) to draw to, @@ -14797,12 +15800,15 @@ this.createjs = this.createjs||{}; * @protected **/ p._updateSurface = function() { + var surface; + if (!this._options || !this._options.useGL) { - var surface = this.target.cacheCanvas; + surface = this._cacheCanvas; // create it if it's missing - if(!surface) { - surface = this.target.cacheCanvas = createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"); + if (!surface) { + surface = this._cacheCanvas = createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"); + this.disabled = this._disabled; } // now size it @@ -14812,51 +15818,43 @@ this.createjs = this.createjs||{}; } // create it if it's missing - if (!this._webGLCache) { + if (!this._stageGL) { if (this._options.useGL === "stage") { - if(!(this.target.stage && this.target.stage.isWebGL)){ + var targetStage = this.target.stage; + // use the stage that this object belongs on as the WebGL context + if (!(targetStage && targetStage.isWebGL)){ var error = "Cannot use 'stage' for cache because the object's parent stage is "; - error += this.target.stage ? "non WebGL." : "not set, please addChild to the correct stage."; + error += targetStage ? "non WebGL." : "not set, please addChild to the correct stage."; throw error; } - this.target.cacheCanvas = true; // will be replaced with RenderTexture, temporary positive value for old "isCached" checks - this._webGLCache = this.target.stage; + this._stageGL = targetStage; - } else if(this._options.useGL === "new") { - this.target.cacheCanvas = document.createElement("canvas"); // we can turn off autopurge because we wont be making textures here - this._webGLCache = new createjs.StageGL(this.target.cacheCanvas, {antialias: true, transparent: true, autoPurge: -1}); - this._webGLCache.isCacheControlled = true; // use this flag to control stage sizing and final output + } else if (this._options.useGL === "new") { + // create a new WebGL context to run this cache + this._cacheCanvas = document.createElement("canvas"); // low autopurge in case of filter swapping and low texture count + this._stageGL = new createjs.StageGL(this._cacheCanvas, {antialias: true, transparent: true, autoPurge: 10}); + if (!this._stageGL._webGLContext){ throw "GL Cache asked for but unavailable"; } + this._stageGL.isCacheControlled = true; // use this flag to control stage sizing and final output - } else if(this._options.useGL instanceof createjs.StageGL) { - this.target.cacheCanvas = true; // will be replaced with RenderTexture, temporary positive value for old "isCached" checks - this._webGLCache = this._options.useGL; - this._webGLCache.isCacheControlled = true; // use this flag to control stage sizing and final output + } else if (this._options.useGL instanceof createjs.StageGL) { + // use the provided WebGL context to run this cache, trust the user it works and is configured. + this._stageGL = this._options.useGL; } else { throw "Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got "+ this._options.useGL; } } - // now size render surfaces - var surface = this.target.cacheCanvas; - var stageGL = this._webGLCache; + this.disabled = this._disabled; - // if we have a dedicated stage we've gotta size it + // if we have a dedicated stage we've got to size it + var stageGL = this._stageGL; if (stageGL.isCacheControlled) { + surface = this._cacheCanvas; surface.width = this._drawWidth; surface.height = this._drawHeight; stageGL.updateViewport(this._drawWidth, this._drawHeight); } - if (this.target.filters) { - // with filters we can't tell how many we'll need but the most we'll ever need is two, so make them now - stageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight); - stageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight); - } else { - // without filters then we only need one RenderTexture, and that's only if its not a dedicated stage - if (!stageGL.isCacheControlled) { - stageGL.getTargetRenderTexture(this.target, this._drawWidth,this._drawHeight); - } - } }; /** @@ -14865,19 +15863,12 @@ this.createjs = this.createjs||{}; * @protected **/ p._drawToCache = function(compositeOperation) { - var surface = this.target.cacheCanvas; + var surface = this._cacheCanvas; var target = this.target; - var webGL = this._webGLCache; - - if (webGL){ - //TODO: auto split blur into an x/y pass - webGL.cacheDraw(target, target.filters, this); + var webGL = this._stageGL; - // we may of swapped around which element the surface is, so we re-fetch it - surface = this.target.cacheCanvas; - - surface.width = this._drawWidth; - surface.height = this._drawHeight; + if (webGL) { + webGL.cacheDraw(target, this); } else { var ctx = surface.getContext("2d"); @@ -14892,7 +15883,6 @@ this.createjs = this.createjs||{}; target.draw(ctx, true); ctx.restore(); - if (target.filters && target.filters.length) { this._applyFilters(ctx); } @@ -14915,14 +15905,14 @@ this.createjs = this.createjs||{}; var i = 0, filter = filters[i]; do { // this is safe because we wouldn't be in apply filters without a filter count of at least 1 - if(filter.usesContext){ - if(data) { + if (filter.usesContext){ + if (data) { ctx.putImageData(data, 0,0); data = null; } filter.applyFilter(ctx, 0,0, w,h); } else { - if(!data) { + if (!data) { data = ctx.getImageData(0,0, w,h); } filter._applyFilter(data); @@ -14933,7 +15923,7 @@ this.createjs = this.createjs||{}; } while (filter); //done - if(data) { + if (data) { ctx.putImageData(data, 0,0); } }; @@ -15011,9 +16001,7 @@ this.createjs = this.createjs||{}; this._quality; this._lastQuality = null; - /** - * This is a template to generate the shader for {{#crossLink FRAG_SHADER_BODY}}{{/crossLink}} - */ + // This is a template to generate the shader for BlurFilter.FRAG_SHADER_BODY. this.FRAG_SHADER_TEMPLATE = ( "uniform float xWeight[{{blurX}}];" + "uniform float yWeight[{{blurY}}];" + @@ -15027,7 +16015,7 @@ this.createjs = this.createjs||{}; "for(int i=0; i<{{blurX}}; i++) {" + "for(int j=0; j<{{blurY}}; j++) {" + - "sampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));" + + "sampleOffset = vTextureCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));" + "color += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);" + "}" + "}" + @@ -15075,7 +16063,7 @@ this.createjs = this.createjs||{}; } return this._compiledShader; }; - p._setShader = function() { this._compiledShader; }; + p._setShader = function(value) { this._compiledShader = value; }; try { Object.defineProperties(p, { @@ -15120,7 +16108,7 @@ this.createjs = this.createjs||{}; this.FRAG_SHADER_BODY = result; }; - /** docced in super class **/ + // Docced in superclass p.shaderParamSetup = function(gl, stage, shaderProgram) { // load the normalized gaussian weight tables gl.uniform1fv( @@ -15159,7 +16147,7 @@ this.createjs = this.createjs||{}; BlurFilter.SHG_TABLE = [0, 9, 10, 11, 9, 12, 10, 11, 12, 9, 13, 13, 10, 9, 13, 13, 14, 14, 14, 14, 10, 13, 14, 14, 14, 13, 13, 13, 9, 14, 14, 14, 15, 14, 15, 14, 15, 15, 14, 15, 15, 15, 14, 15, 15, 15, 15, 15, 14, 15, 15, 15, 15, 15, 15, 12, 14, 15, 15, 13, 15, 15, 15, 15, 16, 16, 16, 15, 16, 14, 16, 16, 14, 16, 13, 16, 16, 16, 15, 16, 13, 16, 15, 16, 14, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 13, 14, 16, 16, 15, 16, 16, 10, 16, 15, 16, 14, 16, 16, 14, 16, 16, 14, 16, 16, 14, 15, 16, 16, 16, 14, 15, 14, 15, 13, 16, 16, 15, 17, 17, 17, 17, 17, 17, 14, 15, 17, 17, 16, 16, 17, 16, 15, 17, 16, 17, 11, 17, 16, 17, 16, 17, 16, 17, 17, 16, 17, 17, 16, 17, 17, 16, 16, 17, 17, 17, 16, 14, 17, 17, 17, 17, 15, 16, 14, 16, 15, 16, 13, 16, 15, 16, 14, 16, 15, 16, 12, 16, 15, 16, 17, 17, 17, 17, 17, 13, 16, 15, 17, 17, 17, 16, 15, 17, 17, 17, 16, 15, 17, 17, 14, 16, 17, 17, 16, 17, 17, 16, 15, 17, 16, 14, 17, 16, 15, 17, 16, 17, 17, 16, 17, 15, 16, 17, 14, 17, 16, 15, 17, 16, 17, 13, 17, 16, 17, 17, 16, 17, 14, 17, 16, 17, 16, 17, 16, 17, 9]; // public methods: - /** docced in super class **/ + // Docced in superclass p.getBounds = function (rect) { var x = this.blurX|0, y = this.blurY| 0; if(x <= 0 && y <= 0) { return rect; } @@ -15167,12 +16155,12 @@ this.createjs = this.createjs||{}; return (rect || new createjs.Rectangle()).pad(y*q+1,x*q+1,y*q+1,x*q+1); }; - /** docced in super class **/ + // Docced in superclass p.clone = function() { return new BlurFilter(this.blurX, this.blurY, this.quality); }; - /** docced in super class **/ + // Docced in superclass p.toString = function() { return "[BlurFilter]"; }; @@ -15180,7 +16168,7 @@ this.createjs = this.createjs||{}; // private methods: - /** docced in super class **/ + // Docced in superclass p._applyFilter = function (imageData) { var radiusX = this._blurX >> 1; if (isNaN(radiusX) || radiusX < 0) return false; @@ -15425,12 +16413,16 @@ this.createjs = this.createjs || {}; * @class AlphaMapFilter * @extends Filter * @constructor - * @param {HTMLImageElement|HTMLCanvasElement} alphaMap The greyscale image (or canvas) to use as the alpha value for the + * @param {HTMLImageElement|HTMLCanvasElement|WebGLTexture} alphaMap The greyscale image (or canvas) to use as the alpha value for the * result. This should be exactly the same dimensions as the target. **/ function AlphaMapFilter(alphaMap) { this.Filter_constructor(); - + + if (!createjs.Filter.isValidImageSource(alphaMap)) { + throw "Must provide valid image source for alpha map, see Filter.isValidImageSource"; + } + // public properties: /** * The greyscale image (or canvas) to use as the alpha value for the result. This should be exactly the same @@ -15440,49 +16432,61 @@ this.createjs = this.createjs || {}; **/ this.alphaMap = alphaMap; - // private properties: /** - * @property _alphaMap + * @property _map * @protected * @type HTMLImageElement|HTMLCanvasElement **/ - this._alphaMap = null; + this._map = null; /** - * @property _mapData + * @property _mapCtx * @protected - * @type Uint8ClampedArray + * @type CanvasRenderingContext2D **/ - this._mapData = null; + this._mapCtx = null; + + /** + * @property _mapTexture + * @protected + * @type WebGLTexture + */ this._mapTexture = null; this.FRAG_SHADER_BODY = ( "uniform sampler2D uAlphaSampler;"+ "void main(void) {" + - "vec4 color = texture2D(uSampler, vRenderCoord);" + + "vec4 color = texture2D(uSampler, vTextureCoord);" + "vec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);" + // some image formats can have transparent white rgba(1,1,1, 0) when put on the GPU, this means we need a slight tweak // using ceil ensure that the colour will be used so long as it exists but pure transparency will be treated black - "gl_FragColor = vec4(color.rgb, color.a * (alphaMap.r * ceil(alphaMap.a)));" + + "float newAlpha = alphaMap.r * ceil(alphaMap.a);" + + "gl_FragColor = vec4(clamp(color.rgb/color.a, 0.0, 1.0) * newAlpha, newAlpha);" + "}" ); + + if(alphaMap instanceof WebGLTexture) { + this._mapTexture = alphaMap; + } } var p = createjs.extend(AlphaMapFilter, createjs.Filter); // TODO: deprecated // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details. - /** docced in super class **/ + // Docced in superclass p.shaderParamSetup = function(gl, stage, shaderProgram) { - if(!this._mapTexture) { this._mapTexture = gl.createTexture(); } + if(this._mapTexture === null) { this._mapTexture = gl.createTexture(); } gl.activeTexture(gl.TEXTURE1); gl.bindTexture(gl.TEXTURE_2D, this._mapTexture); stage.setTextureParams(gl); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap); + if (this.alphaMap !== this._mapTexture) { + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.alphaMap); + } gl.uniform1i( gl.getUniformLocation(shaderProgram, "uAlphaSampler"), @@ -15491,31 +16495,57 @@ this.createjs = this.createjs || {}; }; // public methods: - /** docced in super class **/ + // Docced in superclass p.clone = function () { var o = new AlphaMapFilter(this.alphaMap); - o._alphaMap = this._alphaMap; - o._mapData = this._mapData; return o; }; - /** docced in super class **/ + // Docced in superclass p.toString = function () { return "[AlphaMapFilter]"; }; // private methods: - /** docced in super class **/ + // Docced in superclass p._applyFilter = function (imageData) { - if (!this.alphaMap) { return true; } if (!this._prepAlphaMap()) { return false; } - - // TODO: update to support scenarios where the target has different dimensions. - var data = imageData.data; - var map = this._mapData; - for(var i=0, l=data.length; iExample + * This example uses a preset to generate a sepia photograph effect + * + * var shape = new createjs.Shape().set({x:100,y:100}); + * shape.graphics.beginFill("#ff0000").drawCircle(0,0,50); + * + * shape.filters = [ + * new createjs.ColorMatrixFilter( createjs.ColorMatrix.createSepiaPreset() ) + * ]; + * + * shape.cache(-50, -50, 100, 100); + * * See {{#crossLink "Filter"}}{{/crossLink}} for an more information on applying filters. * @class ColorMatrixFilter * @constructor @@ -16252,14 +17362,15 @@ this.createjs = this.createjs||{}; "uniform vec4 uColorMatrixOffset;" + "void main(void) {" + - "vec4 color = texture2D(uSampler, vRenderCoord);" + + "vec4 color = texture2D(uSampler, vTextureCoord);" + "mat4 m = uColorMatrix;" + - "vec4 newColor = vec4(0,0,0,0);" + - "newColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];" + - "newColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];" + - "newColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];" + - "newColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];" + + "vec4 newColor = vec4(" + + "color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3]," + + "color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3]," + + "color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3]," + + "color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3]" + + ");" + "gl_FragColor = newColor + uColorMatrixOffset;" + "}" @@ -16270,7 +17381,7 @@ this.createjs = this.createjs||{}; // TODO: deprecated // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details. - /** docced in super class **/ + // Docced in superclass p.shaderParamSetup = function(gl, stage, shaderProgram) { var mat = this.matrix; var colorMatrix = new Float32Array([ @@ -16291,18 +17402,18 @@ this.createjs = this.createjs||{}; }; // public methods: - /** docced in super class **/ + // Docced in superclass p.toString = function() { return "[ColorMatrixFilter]"; }; - /** docced in super class **/ + // Docced in superclass p.clone = function() { return new ColorMatrixFilter(this.matrix); }; // private methods: - /** docced in super class **/ + // Docced in superclass p._applyFilter = function(imageData) { var data = imageData.data; var l = data.length; @@ -16372,9 +17483,9 @@ this.createjs = this.createjs||{}; * @static **/ Touch.isSupported = function() { - return !!(('ontouchstart' in window) // iOS & Android - || (window.navigator['msPointerEnabled'] && window.navigator['msMaxTouchPoints'] > 0) // IE10 - || (window.navigator['pointerEnabled'] && window.navigator['maxTouchPoints'] > 0)); // IE11+ + return !!(('ontouchstart' in window) // iOS & Android + || (window.MSPointerEvent && window.navigator.msMaxTouchPoints > 0) // IE10 + || (window.PointerEvent && window.navigator.maxTouchPoints > 0)); // IE11+ }; /** @@ -16401,7 +17512,7 @@ this.createjs = this.createjs||{}; // note that in the future we may need to disable the standard mouse event model before adding // these to prevent duplicate calls. It doesn't seem to be an issue with iOS devices though. if ('ontouchstart' in window) { Touch._IOS_enable(stage); } - else if (window.navigator['msPointerEnabled'] || window.navigator["pointerEnabled"]) { Touch._IE_enable(stage); } + else if (window.PointerEvent || window.MSPointerEvent) { Touch._IE_enable(stage); } return true; }; @@ -16412,9 +17523,9 @@ this.createjs = this.createjs||{}; * @static **/ Touch.disable = function(stage) { - if (!stage) { return; } + if (!stage||!stage.__touch) { return; } if ('ontouchstart' in window) { Touch._IOS_disable(stage); } - else if (window.navigator['msPointerEnabled'] || window.navigator["pointerEnabled"]) { Touch._IE_disable(stage); } + else if (window.PointerEvent || window.MSPointerEvent) { Touch._IE_disable(stage); } delete stage.__touch; }; @@ -16469,11 +17580,11 @@ this.createjs = this.createjs||{}; var id = touch.identifier; if (touch.target != stage.canvas) { continue; } - if (type == "touchstart") { + if (type === "touchstart") { this._handleStart(stage, id, e, touch.pageX, touch.pageY); - } else if (type == "touchmove") { + } else if (type === "touchmove") { this._handleMove(stage, id, e, touch.pageX, touch.pageY); - } else if (type == "touchend" || type == "touchcancel") { + } else if (type === "touchend" || type === "touchcancel") { this._handleEnd(stage, id, e); } } @@ -16489,7 +17600,7 @@ this.createjs = this.createjs||{}; var canvas = stage.canvas; var f = stage.__touch.f = function(e) { Touch._IE_handleEvent(stage,e); }; - if (window.navigator["pointerEnabled"] === undefined) { + if (window.PointerEvent === undefined) { canvas.addEventListener("MSPointerDown", f, false); window.addEventListener("MSPointerMove", f, false); window.addEventListener("MSPointerUp", f, false); @@ -16515,7 +17626,7 @@ this.createjs = this.createjs||{}; Touch._IE_disable = function(stage) { var f = stage.__touch.f; - if (window.navigator["pointerEnabled"] === undefined) { + if (window.PointerEvent === undefined) { window.removeEventListener("MSPointerMove", f, false); window.removeEventListener("MSPointerUp", f, false); window.removeEventListener("MSPointerCancel", f, false); @@ -16546,15 +17657,15 @@ this.createjs = this.createjs||{}; var id = e.pointerId; var ids = stage.__touch.activeIDs; - if (type == "MSPointerDown" || type == "pointerdown") { + if (type === "MSPointerDown" || type === "pointerdown") { if (e.srcElement != stage.canvas) { return; } ids[id] = true; this._handleStart(stage, id, e, e.pageX, e.pageY); } else if (ids[id]) { // it's an id we're watching - if (type == "MSPointerMove" || type == "pointermove") { + if (type === "MSPointerMove" || type === "pointermove") { this._handleMove(stage, id, e, e.pageX, e.pageY); - } else if (type == "MSPointerUp" || type == "MSPointerCancel" - || type == "pointerup" || type == "pointercancel") { + } else if (type === "MSPointerUp" || type === "MSPointerCancel" + || type === "pointerup" || type === "pointercancel") { delete(ids[id]); this._handleEnd(stage, id, e); } @@ -16637,7 +17748,7 @@ this.createjs = this.createjs || {}; * @type String * @static **/ - s.version = /*=version*/"1.0.0"; // injected by build process + s.version = /*=version*/"1.0.4"; // injected by build process /** * The build date for this release in UTC format. @@ -16645,6 +17756,6 @@ this.createjs = this.createjs || {}; * @type String * @static **/ - s.buildDate = /*=date*/"Thu, 14 Sep 2017 19:47:53 GMT"; // injected by build process + s.buildDate = /*=date*/"Sun, 17 Dec 2023 00:04:21 GMT"; // injected by build process })(); \ No newline at end of file diff --git a/lib/easeljs.min.js b/lib/easeljs.min.js index ec40b26c9..9fafe3e50 100644 --- a/lib/easeljs.min.js +++ b/lib/easeljs.min.js @@ -9,7 +9,8 @@ * * This notice shall be included in all copies or substantial portions of the Software. */ -this.createjs=this.createjs||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},createjs.indexOf=function(a,b){"use strict";for(var c=0,d=a.length;d>c;c++)if(b===a[c])return c;return-1},this.createjs=this.createjs||{},function(){"use strict";function a(){throw"UID cannot be instantiated"}a._nextID=0,a.get=function(){return a._nextID++},createjs.UID=a}(),this.createjs=this.createjs||{},createjs.deprecate=function(a,b){"use strict";return function(){var c="Deprecated property or method '"+b+"'. See docs for info.";return console&&(console.warn?console.warn(c):console.log(c)),a&&a.apply(this,arguments)}},this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.type=a,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=!!b,this.cancelable=!!c,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var b=a.prototype;b.preventDefault=function(){this.defaultPrevented=this.cancelable&&!0},b.stopPropagation=function(){this.propagationStopped=!0},b.stopImmediatePropagation=function(){this.immediatePropagationStopped=this.propagationStopped=!0},b.remove=function(){this.removed=!0},b.clone=function(){return new a(this.type,this.bubbles,this.cancelable)},b.set=function(a){for(var b in a)this[b]=a[b];return this},b.toString=function(){return"[Event (type="+this.type+")]"},createjs.Event=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(){this._listeners=null,this._captureListeners=null}var b=a.prototype;a.initialize=function(a){a.addEventListener=b.addEventListener,a.on=b.on,a.removeEventListener=a.off=b.removeEventListener,a.removeAllEventListeners=b.removeAllEventListeners,a.hasEventListener=b.hasEventListener,a.dispatchEvent=b.dispatchEvent,a._dispatchEvent=b._dispatchEvent,a.willTrigger=b.willTrigger},b.addEventListener=function(a,b,c){var d;d=c?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{};var e=d[a];return e&&this.removeEventListener(a,b,c),e=d[a],e?e.push(b):d[a]=[b],b},b.on=function(a,b,c,d,e,f){return b.handleEvent&&(c=c||b,b=b.handleEvent),c=c||this,this.addEventListener(a,function(a){b.call(c,a,e),d&&a.remove()},f)},b.removeEventListener=function(a,b,c){var d=c?this._captureListeners:this._listeners;if(d){var e=d[a];if(e)for(var f=0,g=e.length;g>f;f++)if(e[f]==b){1==g?delete d[a]:e.splice(f,1);break}}},b.off=b.removeEventListener,b.removeAllEventListeners=function(a){a?(this._listeners&&delete this._listeners[a],this._captureListeners&&delete this._captureListeners[a]):this._listeners=this._captureListeners=null},b.dispatchEvent=function(a,b,c){if("string"==typeof a){var d=this._listeners;if(!(b||d&&d[a]))return!0;a=new createjs.Event(a,b,c)}else a.target&&a.clone&&(a=a.clone());try{a.target=this}catch(e){}if(a.bubbles&&this.parent){for(var f=this,g=[f];f.parent;)g.push(f=f.parent);var h,i=g.length;for(h=i-1;h>=0&&!a.propagationStopped;h--)g[h]._dispatchEvent(a,1+(0==h));for(h=1;i>h&&!a.propagationStopped;h++)g[h]._dispatchEvent(a,3)}else this._dispatchEvent(a,2);return!a.defaultPrevented},b.hasEventListener=function(a){var b=this._listeners,c=this._captureListeners;return!!(b&&b[a]||c&&c[a])},b.willTrigger=function(a){for(var b=this;b;){if(b.hasEventListener(a))return!0;b=b.parent}return!1},b.toString=function(){return"[EventDispatcher]"},b._dispatchEvent=function(a,b){var c,d,e=2>=b?this._captureListeners:this._listeners;if(a&&e&&(d=e[a.type])&&(c=d.length)){try{a.currentTarget=this}catch(f){}try{a.eventPhase=0|b}catch(f){}a.removed=!1,d=d.slice();for(var g=0;c>g&&!a.immediatePropagationStopped;g++){var h=d[g];h.handleEvent?h.handleEvent(a):h(a),a.removed&&(this.off(a.type,h,1==b),a.removed=!1)}}2===b&&this._dispatchEvent(a,2.1)},createjs.EventDispatcher=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(){throw"Ticker cannot be instantiated."}a.RAF_SYNCHED="synched",a.RAF="raf",a.TIMEOUT="timeout",a.timingMode=null,a.maxDelta=0,a.paused=!1,a.removeEventListener=null,a.removeAllEventListeners=null,a.dispatchEvent=null,a.hasEventListener=null,a._listeners=null,createjs.EventDispatcher.initialize(a),a._addEventListener=a.addEventListener,a.addEventListener=function(){return!a._inited&&a.init(),a._addEventListener.apply(a,arguments)},a._inited=!1,a._startTime=0,a._pausedTime=0,a._ticks=0,a._pausedTicks=0,a._interval=50,a._lastTime=0,a._times=null,a._tickTimes=null,a._timerId=null,a._raf=!0,a._setInterval=function(b){a._interval=b,a._inited&&a._setupTick()},a.setInterval=createjs.deprecate(a._setInterval,"Ticker.setInterval"),a._getInterval=function(){return a._interval},a.getInterval=createjs.deprecate(a._getInterval,"Ticker.getInterval"),a._setFPS=function(b){a._setInterval(1e3/b)},a.setFPS=createjs.deprecate(a._setFPS,"Ticker.setFPS"),a._getFPS=function(){return 1e3/a._interval},a.getFPS=createjs.deprecate(a._getFPS,"Ticker.getFPS");try{Object.defineProperties(a,{interval:{get:a._getInterval,set:a._setInterval},framerate:{get:a._getFPS,set:a._setFPS}})}catch(b){console.log(b)}a.init=function(){a._inited||(a._inited=!0,a._times=[],a._tickTimes=[],a._startTime=a._getTime(),a._times.push(a._lastTime=0),a.interval=a._interval)},a.reset=function(){if(a._raf){var b=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;b&&b(a._timerId)}else clearTimeout(a._timerId);a.removeAllEventListeners("tick"),a._timerId=a._times=a._tickTimes=null,a._startTime=a._lastTime=a._ticks=a._pausedTime=0,a._inited=!1},a.getMeasuredTickTime=function(b){var c=0,d=a._tickTimes;if(!d||d.length<1)return-1;b=Math.min(d.length,b||0|a._getFPS());for(var e=0;b>e;e++)c+=d[e];return c/b},a.getMeasuredFPS=function(b){var c=a._times;return!c||c.length<2?-1:(b=Math.min(c.length-1,b||0|a._getFPS()),1e3/((c[0]-c[b])/b))},a.getTime=function(b){return a._startTime?a._getTime()-(b?a._pausedTime:0):-1},a.getEventTime=function(b){return a._startTime?(a._lastTime||a._startTime)-(b?a._pausedTime:0):-1},a.getTicks=function(b){return a._ticks-(b?a._pausedTicks:0)},a._handleSynch=function(){a._timerId=null,a._setupTick(),a._getTime()-a._lastTime>=.97*(a._interval-1)&&a._tick()},a._handleRAF=function(){a._timerId=null,a._setupTick(),a._tick()},a._handleTimeout=function(){a._timerId=null,a._setupTick(),a._tick()},a._setupTick=function(){if(null==a._timerId){var b=a.timingMode;if(b==a.RAF_SYNCHED||b==a.RAF){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(c)return a._timerId=c(b==a.RAF?a._handleRAF:a._handleSynch),void(a._raf=!0)}a._raf=!1,a._timerId=setTimeout(a._handleTimeout,a._interval)}},a._tick=function(){var b=a.paused,c=a._getTime(),d=c-a._lastTime;if(a._lastTime=c,a._ticks++,b&&(a._pausedTicks++,a._pausedTime+=d),a.hasEventListener("tick")){var e=new createjs.Event("tick"),f=a.maxDelta;e.delta=f&&d>f?f:d,e.paused=b,e.time=c,e.runTime=c-a._pausedTime,a.dispatchEvent(e)}for(a._tickTimes.unshift(a._getTime()-c);a._tickTimes.length>100;)a._tickTimes.pop();for(a._times.unshift(c);a._times.length>100;)a._times.pop()};var c=window,d=c.performance.now||c.performance.mozNow||c.performance.msNow||c.performance.oNow||c.performance.webkitNow;a._getTime=function(){return(d&&d.call(c.performance)||(new Date).getTime())-a._startTime},createjs.Ticker=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.readyState=a.readyState,this._video=a,this._canvas=null,this._lastTime=-1,this.readyState<2&&a.addEventListener("canplaythrough",this._videoReady.bind(this))}var b=a.prototype;b.getImage=function(){if(!(this.readyState<2)){var a=this._canvas,b=this._video;if(a||(a=this._canvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"),a.width=b.videoWidth,a.height=b.videoHeight),b.readyState>=2&&b.currentTime!==this._lastTime){var c=a.getContext("2d");c.clearRect(0,0,a.width,a.height),c.drawImage(b,0,0,a.width,a.height),this._lastTime=b.currentTime}return a}},b._videoReady=function(){this.readyState=2},createjs.VideoBuffer=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k){this.Event_constructor(a,b,c),this.stageX=d,this.stageY=e,this.rawX=null==i?d:i,this.rawY=null==j?e:j,this.nativeEvent=f,this.pointerID=g,this.primary=!!h,this.relatedTarget=k}var b=createjs.extend(a,createjs.Event);b._get_localX=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).x},b._get_localY=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).y},b._get_isTouch=function(){return-1!==this.pointerID};try{Object.defineProperties(b,{localX:{get:b._get_localX},localY:{get:b._get_localY},isTouch:{get:b._get_isTouch}})}catch(c){}b.clone=function(){return new a(this.type,this.bubbles,this.cancelable,this.stageX,this.stageY,this.nativeEvent,this.pointerID,this.primary,this.rawX,this.rawY)},b.toString=function(){return"[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"},createjs.MouseEvent=createjs.promote(a,"Event")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f){this.setValues(a,b,c,d,e,f)}var b=a.prototype;a.DEG_TO_RAD=Math.PI/180,a.identity=null,b.setValues=function(a,b,c,d,e,f){return this.a=null==a?1:a,this.b=b||0,this.c=c||0,this.d=null==d?1:d,this.tx=e||0,this.ty=f||0,this},b.append=function(a,b,c,d,e,f){var g=this.a,h=this.b,i=this.c,j=this.d;return(1!=a||0!=b||0!=c||1!=d)&&(this.a=g*a+i*b,this.b=h*a+j*b,this.c=g*c+i*d,this.d=h*c+j*d),this.tx=g*e+i*f+this.tx,this.ty=h*e+j*f+this.ty,this},b.prepend=function(a,b,c,d,e,f){var g=this.a,h=this.c,i=this.tx;return this.a=a*g+c*this.b,this.b=b*g+d*this.b,this.c=a*h+c*this.d,this.d=b*h+d*this.d,this.tx=a*i+c*this.ty+e,this.ty=b*i+d*this.ty+f,this},b.appendMatrix=function(a){return this.append(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.prependMatrix=function(a){return this.prepend(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.appendTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.append(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c),this.append(l*d,m*d,-m*e,l*e,0,0)):this.append(l*d,m*d,-m*e,l*e,b,c),(i||j)&&(this.tx-=i*this.a+j*this.c,this.ty-=i*this.b+j*this.d),this},b.prependTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return(i||j)&&(this.tx-=i,this.ty-=j),g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.prepend(l*d,m*d,-m*e,l*e,0,0),this.prepend(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c)):this.prepend(l*d,m*d,-m*e,l*e,b,c),this},b.rotate=function(b){b*=a.DEG_TO_RAD;var c=Math.cos(b),d=Math.sin(b),e=this.a,f=this.b;return this.a=e*c+this.c*d,this.b=f*c+this.d*d,this.c=-e*d+this.c*c,this.d=-f*d+this.d*c,this},b.skew=function(b,c){return b*=a.DEG_TO_RAD,c*=a.DEG_TO_RAD,this.append(Math.cos(c),Math.sin(c),-Math.sin(b),Math.cos(b),0,0),this},b.scale=function(a,b){return this.a*=a,this.b*=a,this.c*=b,this.d*=b,this},b.translate=function(a,b){return this.tx+=this.a*a+this.c*b,this.ty+=this.b*a+this.d*b,this},b.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},b.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.isIdentity=function(){return 0===this.tx&&0===this.ty&&1===this.a&&0===this.b&&0===this.c&&1===this.d},b.equals=function(a){return this.tx===a.tx&&this.ty===a.ty&&this.a===a.a&&this.b===a.b&&this.c===a.c&&this.d===a.d},b.transformPoint=function(a,b,c){return c=c||{},c.x=a*this.a+b*this.c+this.tx,c.y=a*this.b+b*this.d+this.ty,c},b.decompose=function(b){null==b&&(b={}),b.x=this.tx,b.y=this.ty,b.scaleX=Math.sqrt(this.a*this.a+this.b*this.b),b.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var c=Math.atan2(-this.c,this.d),d=Math.atan2(this.b,this.a),e=Math.abs(1-c/d);return 1e-5>e?(b.rotation=d/a.DEG_TO_RAD,this.a<0&&this.d>=0&&(b.rotation+=b.rotation<=0?180:-180),b.skewX=b.skewY=0):(b.skewX=c/a.DEG_TO_RAD,b.skewY=d/a.DEG_TO_RAD),b},b.copy=function(a){return this.setValues(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.clone=function(){return new a(this.a,this.b,this.c,this.d,this.tx,this.ty)},b.toString=function(){return"[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"},a.identity=new a,createjs.Matrix2D=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e){this.setValues(a,b,c,d,e)}var b=a.prototype;b.setValues=function(a,b,c,d,e){return this.visible=null==a?!0:!!a,this.alpha=null==b?1:b,this.shadow=c,this.compositeOperation=d,this.matrix=e||this.matrix&&this.matrix.identity()||new createjs.Matrix2D,this},b.append=function(a,b,c,d,e){return this.alpha*=b,this.shadow=c||this.shadow,this.compositeOperation=d||this.compositeOperation,this.visible=this.visible&&a,e&&this.matrix.appendMatrix(e),this},b.prepend=function(a,b,c,d,e){return this.alpha*=b,this.shadow=this.shadow||c,this.compositeOperation=this.compositeOperation||d,this.visible=this.visible&&a,e&&this.matrix.prependMatrix(e),this},b.identity=function(){return this.visible=!0,this.alpha=1,this.shadow=this.compositeOperation=null,this.matrix.identity(),this},b.clone=function(){return new a(this.alpha,this.shadow,this.compositeOperation,this.visible,this.matrix.clone())},createjs.DisplayProps=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.setValues(a,b)}var b=a.prototype;b.setValues=function(a,b){return this.x=a||0,this.y=b||0,this},b.copy=function(a){return this.x=a.x,this.y=a.y,this},b.clone=function(){return new a(this.x,this.y)},b.toString=function(){return"[Point (x="+this.x+" y="+this.y+")]"},createjs.Point=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d){this.setValues(a,b,c,d)}var b=a.prototype;b.setValues=function(a,b,c,d){return this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0,this},b.extend=function(a,b,c,d){return c=c||0,d=d||0,a+c>this.x+this.width&&(this.width=a+c-this.x),b+d>this.y+this.height&&(this.height=b+d-this.y),a=this.x&&a+c<=this.x+this.width&&b>=this.y&&b+d<=this.y+this.height},b.union=function(a){return this.clone().extend(a.x,a.y,a.width,a.height)},b.intersection=function(b){var c=b.x,d=b.y,e=c+b.width,f=d+b.height;return this.x>c&&(c=this.x),this.y>d&&(d=this.y),this.x+this.width=e||d>=f?null:new a(c,d,e-c,f-d)},b.intersects=function(a){return a.x<=this.x+this.width&&this.x<=a.x+a.width&&a.y<=this.y+this.height&&this.y<=a.y+a.height},b.isEmpty=function(){return this.width<=0||this.height<=0},b.clone=function(){return new a(this.x,this.y,this.width,this.height)},b.toString=function(){return"[Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")]"},createjs.Rectangle=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f,g){a.addEventListener&&(this.target=a,this.overLabel=null==c?"over":c,this.outLabel=null==b?"out":b,this.downLabel=null==d?"down":d,this.play=e,this._isPressed=!1,this._isOver=!1,this._enabled=!1,a.mouseChildren=!1,this.enabled=!0,this.handleEvent({}),f&&(g&&(f.actionsEnabled=!1,f.gotoAndStop&&f.gotoAndStop(g)),a.hitArea=f))}var b=a.prototype;b._setEnabled=function(a){if(a!=this._enabled){var b=this.target;this._enabled=a,a?(b.cursor="pointer",b.addEventListener("rollover",this),b.addEventListener("rollout",this),b.addEventListener("mousedown",this),b.addEventListener("pressup",this),b._reset&&(b.__reset=b._reset,b._reset=this._reset)):(b.cursor=null,b.removeEventListener("rollover",this),b.removeEventListener("rollout",this),b.removeEventListener("mousedown",this),b.removeEventListener("pressup",this),b.__reset&&(b._reset=b.__reset,delete b.__reset))}},b.setEnabled=createjs.deprecate(b._setEnabled,"ButtonHelper.setEnabled"),b._getEnabled=function(){return this._enabled},b.getEnabled=createjs.deprecate(b._getEnabled,"ButtonHelper.getEnabled");try{Object.defineProperties(b,{enabled:{get:b._getEnabled,set:b._setEnabled}})}catch(c){}b.toString=function(){return"[ButtonHelper]"},b.handleEvent=function(a){var b,c=this.target,d=a.type;"mousedown"==d?(this._isPressed=!0,b=this.downLabel):"pressup"==d?(this._isPressed=!1,b=this._isOver?this.overLabel:this.outLabel):"rollover"==d?(this._isOver=!0,b=this._isPressed?this.downLabel:this.overLabel):(this._isOver=!1,b=this._isPressed?this.overLabel:this.outLabel),this.play?c.gotoAndPlay&&c.gotoAndPlay(b):c.gotoAndStop&&c.gotoAndStop(b)},b._reset=function(){var a=this.paused;this.__reset(),this.paused=a},createjs.ButtonHelper=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d){this.color=a||"black",this.offsetX=b||0,this.offsetY=c||0,this.blur=d||0}var b=a.prototype;a.identity=new a("transparent",0,0,0),b.toString=function(){return"[Shadow]"},b.clone=function(){return new a(this.color,this.offsetX,this.offsetY,this.blur)},createjs.Shadow=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.EventDispatcher_constructor(),this.complete=!0,this.framerate=0,this._animations=null,this._frames=null,this._images=null,this._data=null,this._loadCount=0,this._frameHeight=0,this._frameWidth=0,this._numFrames=0,this._regX=0,this._regY=0,this._spacing=0,this._margin=0,this._parseData(a)}var b=createjs.extend(a,createjs.EventDispatcher);b._getAnimations=function(){return this._animations.slice()},b.getAnimations=createjs.deprecate(b._getAnimations,"SpriteSheet.getAnimations");try{Object.defineProperties(b,{animations:{get:b._getAnimations}})}catch(c){}b.getNumFrames=function(a){if(null==a)return this._frames?this._frames.length:this._numFrames||0;var b=this._data[a];return null==b?0:b.frames.length},b.getAnimation=function(a){return this._data[a]},b.getFrame=function(a){var b;return this._frames&&(b=this._frames[a])?b:null},b.getFrameBounds=function(a,b){var c=this.getFrame(a);return c?(b||new createjs.Rectangle).setValues(-c.regX,-c.regY,c.rect.width,c.rect.height):null},b.toString=function(){return"[SpriteSheet]"},b.clone=function(){throw"SpriteSheet cannot be cloned."},b._parseData=function(a){var b,c,d,e;if(null!=a){if(this.framerate=a.framerate||0,a.images&&(c=a.images.length)>0)for(e=this._images=[],b=0;c>b;b++){var f=a.images[b];if("string"==typeof f){var g=f;f=document.createElement("img"),f.src=g}e.push(f),f.getContext||f.naturalWidth||(this._loadCount++,this.complete=!1,function(a,b){f.onload=function(){a._handleImageLoad(b)}}(this,g),function(a,b){f.onerror=function(){a._handleImageError(b)}}(this,g))}if(null==a.frames);else if(Array.isArray(a.frames))for(this._frames=[],e=a.frames,b=0,c=e.length;c>b;b++){var h=e[b];this._frames.push({image:this._images[h[4]?h[4]:0],rect:new createjs.Rectangle(h[0],h[1],h[2],h[3]),regX:h[5]||0,regY:h[6]||0})}else d=a.frames,this._frameWidth=d.width,this._frameHeight=d.height,this._regX=d.regX||0,this._regY=d.regY||0,this._spacing=d.spacing||0,this._margin=d.margin||0,this._numFrames=d.count,0==this._loadCount&&this._calculateFrames();if(this._animations=[],null!=(d=a.animations)){this._data={};var i;for(i in d){var j={name:i},k=d[i];if("number"==typeof k)e=j.frames=[k];else if(Array.isArray(k))if(1==k.length)j.frames=[k[0]];else for(j.speed=k[3],j.next=k[2],e=j.frames=[],b=k[0];b<=k[1];b++)e.push(b);else{j.speed=k.speed,j.next=k.next;var l=k.frames;e=j.frames="number"==typeof l?[l]:l.slice(0)}(j.next===!0||void 0===j.next)&&(j.next=i),(j.next===!1||e.length<2&&j.next==i)&&(j.next=null),j.speed||(j.speed=1),this._animations.push(i),this._data[i]=j}}}},b._handleImageLoad=function(){0==--this._loadCount&&(this._calculateFrames(),this.complete=!0,this.dispatchEvent("complete"))},b._handleImageError=function(a){var b=new createjs.Event("error");b.src=a,this.dispatchEvent(b),0==--this._loadCount&&this.dispatchEvent("complete")},b._calculateFrames=function(){if(!this._frames&&0!=this._frameWidth){this._frames=[];var a=this._numFrames||1e5,b=0,c=this._frameWidth,d=this._frameHeight,e=this._spacing,f=this._margin;a:for(var g=0,h=this._images;g=l;){for(var m=f;j-f-c>=m;){if(b>=a)break a;b++,this._frames.push({image:i,rect:new createjs.Rectangle(m,l,c,d),regX:this._regX,regY:this._regY}),m+=c+e}l+=d+e}this._numFrames=b}},createjs.SpriteSheet=createjs.promote(a,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function a(){this.command=null,this._stroke=null,this._strokeStyle=null,this._oldStrokeStyle=null,this._strokeDash=null,this._oldStrokeDash=null,this._strokeIgnoreScale=!1,this._fill=null,this._instructions=[],this._commitIndex=0,this._activeInstructions=[],this._dirty=!1,this._storeIndex=0,this.clear()}var b=a.prototype,c=a;a.getRGB=function(a,b,c,d){return null!=a&&null==c&&(d=b,c=255&a,b=a>>8&255,a=a>>16&255),null==d?"rgb("+a+","+b+","+c+")":"rgba("+a+","+b+","+c+","+d+")"},a.getHSL=function(a,b,c,d){return null==d?"hsl("+a%360+","+b+"%,"+c+"%)":"hsla("+a%360+","+b+"%,"+c+"%,"+d+")"},a.BASE_64={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"+":62,"/":63},a.STROKE_CAPS_MAP=["butt","round","square"],a.STROKE_JOINTS_MAP=["miter","round","bevel"];var d=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");d.getContext&&(a._ctx=d.getContext("2d"),d.width=d.height=1),b._getInstructions=function(){return this._updateInstructions(),this._instructions},b.getInstructions=createjs.deprecate(b._getInstructions,"Graphics.getInstructions");try{Object.defineProperties(b,{instructions:{get:b._getInstructions}})}catch(e){}b.isEmpty=function(){return!(this._instructions.length||this._activeInstructions.length)},b.draw=function(a,b){this._updateInstructions();for(var c=this._instructions,d=this._storeIndex,e=c.length;e>d;d++)c[d].exec(a,b)},b.drawAsPath=function(a){this._updateInstructions();for(var b,c=this._instructions,d=this._storeIndex,e=c.length;e>d;d++)(b=c[d]).path!==!1&&b.exec(a)},b.moveTo=function(a,b){return this.append(new c.MoveTo(a,b),!0)},b.lineTo=function(a,b){return this.append(new c.LineTo(a,b))},b.arcTo=function(a,b,d,e,f){return this.append(new c.ArcTo(a,b,d,e,f))},b.arc=function(a,b,d,e,f,g){return this.append(new c.Arc(a,b,d,e,f,g))},b.quadraticCurveTo=function(a,b,d,e){return this.append(new c.QuadraticCurveTo(a,b,d,e))},b.bezierCurveTo=function(a,b,d,e,f,g){return this.append(new c.BezierCurveTo(a,b,d,e,f,g))},b.rect=function(a,b,d,e){return this.append(new c.Rect(a,b,d,e))},b.closePath=function(){return this._activeInstructions.length?this.append(new c.ClosePath):this},b.clear=function(){return this._instructions.length=this._activeInstructions.length=this._commitIndex=0,this._strokeStyle=this._oldStrokeStyle=this._stroke=this._fill=this._strokeDash=this._oldStrokeDash=null,this._dirty=this._strokeIgnoreScale=!1,this},b.beginFill=function(a){return this._setFill(a?new c.Fill(a):null)},b.beginLinearGradientFill=function(a,b,d,e,f,g){return this._setFill((new c.Fill).linearGradient(a,b,d,e,f,g))},b.beginRadialGradientFill=function(a,b,d,e,f,g,h,i){return this._setFill((new c.Fill).radialGradient(a,b,d,e,f,g,h,i))},b.beginBitmapFill=function(a,b,d){return this._setFill(new c.Fill(null,d).bitmap(a,b))},b.endFill=function(){return this.beginFill()},b.setStrokeStyle=function(a,b,d,e,f){return this._updateInstructions(!0),this._strokeStyle=this.command=new c.StrokeStyle(a,b,d,e,f),this._stroke&&(this._stroke.ignoreScale=f),this._strokeIgnoreScale=f,this},b.setStrokeDash=function(a,b){return this._updateInstructions(!0),this._strokeDash=this.command=new c.StrokeDash(a,b),this},b.beginStroke=function(a){return this._setStroke(a?new c.Stroke(a):null)},b.beginLinearGradientStroke=function(a,b,d,e,f,g){return this._setStroke((new c.Stroke).linearGradient(a,b,d,e,f,g))},b.beginRadialGradientStroke=function(a,b,d,e,f,g,h,i){return this._setStroke((new c.Stroke).radialGradient(a,b,d,e,f,g,h,i))},b.beginBitmapStroke=function(a,b){return this._setStroke((new c.Stroke).bitmap(a,b))},b.endStroke=function(){return this.beginStroke()},b.curveTo=b.quadraticCurveTo,b.drawRect=b.rect,b.drawRoundRect=function(a,b,c,d,e){return this.drawRoundRectComplex(a,b,c,d,e,e,e,e)},b.drawRoundRectComplex=function(a,b,d,e,f,g,h,i){return this.append(new c.RoundRect(a,b,d,e,f,g,h,i))},b.drawCircle=function(a,b,d){return this.append(new c.Circle(a,b,d))},b.drawEllipse=function(a,b,d,e){return this.append(new c.Ellipse(a,b,d,e))},b.drawPolyStar=function(a,b,d,e,f,g){return this.append(new c.PolyStar(a,b,d,e,f,g))},b.append=function(a,b){return this._activeInstructions.push(a),this.command=a,b||(this._dirty=!0),this},b.decodePath=function(b){for(var c=[this.moveTo,this.lineTo,this.quadraticCurveTo,this.bezierCurveTo,this.closePath],d=[2,2,4,6,0],e=0,f=b.length,g=[],h=0,i=0,j=a.BASE_64;f>e;){var k=b.charAt(e),l=j[k],m=l>>3,n=c[m];if(!n||3&l)throw"bad path data (@"+e+"): "+k;var o=d[m];m||(h=i=0),g.length=0,e++;for(var p=(l>>2&1)+2,q=0;o>q;q++){var r=j[b.charAt(e)],s=r>>5?-1:1;r=(31&r)<<6|j[b.charAt(e+1)],3==p&&(r=r<<6|j[b.charAt(e+2)]),r=s*r/10,q%2?h=r+=h:i=r+=i,g[q]=r,e+=p}n.apply(this,g)}return this},b.store=function(){return this._updateInstructions(!0),this._storeIndex=this._instructions.length,this},b.unstore=function(){return this._storeIndex=0,this},b.clone=function(){var b=new a;return b.command=this.command,b._stroke=this._stroke,b._strokeStyle=this._strokeStyle,b._strokeDash=this._strokeDash,b._strokeIgnoreScale=this._strokeIgnoreScale,b._fill=this._fill,b._instructions=this._instructions.slice(),b._commitIndex=this._commitIndex,b._activeInstructions=this._activeInstructions.slice(),b._dirty=this._dirty,b._storeIndex=this._storeIndex,b},b.toString=function(){return"[Graphics]"},b.mt=b.moveTo,b.lt=b.lineTo,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.qt=b.quadraticCurveTo,b.a=b.arc,b.r=b.rect,b.cp=b.closePath,b.c=b.clear,b.f=b.beginFill,b.lf=b.beginLinearGradientFill,b.rf=b.beginRadialGradientFill,b.bf=b.beginBitmapFill,b.ef=b.endFill,b.ss=b.setStrokeStyle,b.sd=b.setStrokeDash,b.s=b.beginStroke,b.ls=b.beginLinearGradientStroke,b.rs=b.beginRadialGradientStroke,b.bs=b.beginBitmapStroke,b.es=b.endStroke,b.dr=b.drawRect,b.rr=b.drawRoundRect,b.rc=b.drawRoundRectComplex,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dp=b.drawPolyStar,b.p=b.decodePath,b._updateInstructions=function(b){var c=this._instructions,d=this._activeInstructions,e=this._commitIndex;if(this._dirty&&d.length){c.length=e,c.push(a.beginCmd);var f=d.length,g=c.length;c.length=g+f;for(var h=0;f>h;h++)c[h+g]=d[h];this._fill&&c.push(this._fill),this._stroke&&(this._strokeDash!==this._oldStrokeDash&&c.push(this._strokeDash),this._strokeStyle!==this._oldStrokeStyle&&c.push(this._strokeStyle),b&&(this._oldStrokeStyle=this._strokeStyle,this._oldStrokeDash=this._strokeDash),c.push(this._stroke)),this._dirty=!1}b&&(d.length=0,this._commitIndex=c.length)},b._setFill=function(a){return this._updateInstructions(!0),this.command=this._fill=a,this},b._setStroke=function(a){return this._updateInstructions(!0),(this.command=this._stroke=a)&&(a.ignoreScale=this._strokeIgnoreScale),this},(c.LineTo=function(a,b){this.x=a,this.y=b}).prototype.exec=function(a){a.lineTo(this.x,this.y)},(c.MoveTo=function(a,b){this.x=a,this.y=b}).prototype.exec=function(a){a.moveTo(this.x,this.y)},(c.ArcTo=function(a,b,c,d,e){this.x1=a,this.y1=b,this.x2=c,this.y2=d,this.radius=e}).prototype.exec=function(a){a.arcTo(this.x1,this.y1,this.x2,this.y2,this.radius)},(c.Arc=function(a,b,c,d,e,f){this.x=a,this.y=b,this.radius=c,this.startAngle=d,this.endAngle=e,this.anticlockwise=!!f}).prototype.exec=function(a){a.arc(this.x,this.y,this.radius,this.startAngle,this.endAngle,this.anticlockwise)},(c.QuadraticCurveTo=function(a,b,c,d){this.cpx=a,this.cpy=b,this.x=c,this.y=d}).prototype.exec=function(a){a.quadraticCurveTo(this.cpx,this.cpy,this.x,this.y)},(c.BezierCurveTo=function(a,b,c,d,e,f){this.cp1x=a,this.cp1y=b,this.cp2x=c,this.cp2y=d,this.x=e,this.y=f}).prototype.exec=function(a){a.bezierCurveTo(this.cp1x,this.cp1y,this.cp2x,this.cp2y,this.x,this.y)},(c.Rect=function(a,b,c,d){this.x=a,this.y=b,this.w=c,this.h=d}).prototype.exec=function(a){a.rect(this.x,this.y,this.w,this.h)},(c.ClosePath=function(){}).prototype.exec=function(a){a.closePath()},(c.BeginPath=function(){}).prototype.exec=function(a){a.beginPath()},b=(c.Fill=function(a,b){this.style=a,this.matrix=b}).prototype,b.exec=function(a){if(this.style){a.fillStyle=this.style;var b=this.matrix;b&&(a.save(),a.transform(b.a,b.b,b.c,b.d,b.tx,b.ty)),a.fill(),b&&a.restore()}},b.linearGradient=function(b,c,d,e,f,g){for(var h=this.style=a._ctx.createLinearGradient(d,e,f,g),i=0,j=b.length;j>i;i++)h.addColorStop(c[i],b[i]);return h.props={colors:b,ratios:c,x0:d,y0:e,x1:f,y1:g,type:"linear"},this},b.radialGradient=function(b,c,d,e,f,g,h,i){for(var j=this.style=a._ctx.createRadialGradient(d,e,f,g,h,i),k=0,l=b.length;l>k;k++)j.addColorStop(c[k],b[k]);return j.props={colors:b,ratios:c,x0:d,y0:e,r0:f,x1:g,y1:h,r1:i,type:"radial"},this},b.bitmap=function(b,c){if(b.naturalWidth||b.getContext||b.readyState>=2){var d=this.style=a._ctx.createPattern(b,c||"");d.props={image:b,repetition:c,type:"bitmap"}}return this},b.path=!1,b=(c.Stroke=function(a,b){this.style=a,this.ignoreScale=b}).prototype,b.exec=function(a){this.style&&(a.strokeStyle=this.style,this.ignoreScale&&(a.save(),a.setTransform(1,0,0,1,0,0)),a.stroke(),this.ignoreScale&&a.restore())},b.linearGradient=c.Fill.prototype.linearGradient,b.radialGradient=c.Fill.prototype.radialGradient,b.bitmap=c.Fill.prototype.bitmap,b.path=!1,b=(c.StrokeStyle=function(a,b,c,d,e){this.width=a,this.caps=b,this.joints=c,this.miterLimit=d,this.ignoreScale=e}).prototype,b.exec=function(b){b.lineWidth=null==this.width?"1":this.width,b.lineCap=null==this.caps?"butt":isNaN(this.caps)?this.caps:a.STROKE_CAPS_MAP[this.caps],b.lineJoin=null==this.joints?"miter":isNaN(this.joints)?this.joints:a.STROKE_JOINTS_MAP[this.joints],b.miterLimit=null==this.miterLimit?"10":this.miterLimit,b.ignoreScale=null==this.ignoreScale?!1:this.ignoreScale},b.path=!1,(c.StrokeDash=function(a,b){this.segments=a,this.offset=b||0}).prototype.exec=function(a){a.setLineDash&&(a.setLineDash(this.segments||c.StrokeDash.EMPTY_SEGMENTS),a.lineDashOffset=this.offset||0)},c.StrokeDash.EMPTY_SEGMENTS=[],(c.RoundRect=function(a,b,c,d,e,f,g,h){this.x=a,this.y=b,this.w=c,this.h=d,this.radiusTL=e,this.radiusTR=f,this.radiusBR=g,this.radiusBL=h}).prototype.exec=function(a){var b=(j>i?i:j)/2,c=0,d=0,e=0,f=0,g=this.x,h=this.y,i=this.w,j=this.h,k=this.radiusTL,l=this.radiusTR,m=this.radiusBR,n=this.radiusBL;0>k&&(k*=c=-1),k>b&&(k=b),0>l&&(l*=d=-1),l>b&&(l=b),0>m&&(m*=e=-1),m>b&&(m=b),0>n&&(n*=f=-1),n>b&&(n=b),a.moveTo(g+i-l,h),a.arcTo(g+i+l*d,h-l*d,g+i,h+l,l),a.lineTo(g+i,h+j-m),a.arcTo(g+i+m*e,h+j+m*e,g+i-m,h+j,m),a.lineTo(g+n,h+j),a.arcTo(g-n*f,h+j+n*f,g,h+j-n,n),a.lineTo(g,h+k),a.arcTo(g-k*c,h-k*c,g+k,h,k),a.closePath() -},(c.Circle=function(a,b,c){this.x=a,this.y=b,this.radius=c}).prototype.exec=function(a){a.arc(this.x,this.y,this.radius,0,2*Math.PI)},(c.Ellipse=function(a,b,c,d){this.x=a,this.y=b,this.w=c,this.h=d}).prototype.exec=function(a){var b=this.x,c=this.y,d=this.w,e=this.h,f=.5522848,g=d/2*f,h=e/2*f,i=b+d,j=c+e,k=b+d/2,l=c+e/2;a.moveTo(b,l),a.bezierCurveTo(b,l-h,k-g,c,k,c),a.bezierCurveTo(k+g,c,i,l-h,i,l),a.bezierCurveTo(i,l+h,k+g,j,k,j),a.bezierCurveTo(k-g,j,b,l+h,b,l)},(c.PolyStar=function(a,b,c,d,e,f){this.x=a,this.y=b,this.radius=c,this.sides=d,this.pointSize=e,this.angle=f}).prototype.exec=function(a){var b=this.x,c=this.y,d=this.radius,e=(this.angle||0)/180*Math.PI,f=this.sides,g=1-(this.pointSize||0),h=Math.PI/f;a.moveTo(b+Math.cos(e)*d,c+Math.sin(e)*d);for(var i=0;f>i;i++)e+=h,1!=g&&a.lineTo(b+Math.cos(e)*d*g,c+Math.sin(e)*d*g),e+=h,a.lineTo(b+Math.cos(e)*d,c+Math.sin(e)*d);a.closePath()},a.beginCmd=new c.BeginPath,createjs.Graphics=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(){this.EventDispatcher_constructor(),this.alpha=1,this.cacheCanvas=null,this.bitmapCache=null,this.id=createjs.UID.get(),this.mouseEnabled=!0,this.tickEnabled=!0,this.name=null,this.parent=null,this.regX=0,this.regY=0,this.rotation=0,this.scaleX=1,this.scaleY=1,this.skewX=0,this.skewY=0,this.shadow=null,this.visible=!0,this.x=0,this.y=0,this.transformMatrix=null,this.compositeOperation=null,this.snapToPixel=!0,this.filters=null,this.mask=null,this.hitArea=null,this.cursor=null,this._props=new createjs.DisplayProps,this._rectangle=new createjs.Rectangle,this._bounds=null,this._webGLRenderStyle=a._StageGL_NONE}var b=createjs.extend(a,createjs.EventDispatcher);a._MOUSE_EVENTS=["click","dblclick","mousedown","mouseout","mouseover","pressmove","pressup","rollout","rollover"],a.suppressCrossDomainErrors=!1,a._snapToPixelEnabled=!1,a._StageGL_NONE=0,a._StageGL_SPRITE=1,a._StageGL_BITMAP=2;var c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");c.getContext&&(a._hitTestCanvas=c,a._hitTestContext=c.getContext("2d"),c.width=c.height=1),b._getStage=function(){for(var a=this,b=createjs.Stage;a.parent;)a=a.parent;return a instanceof b?a:null},b.getStage=createjs.deprecate(b._getStage,"DisplayObject.getStage");try{Object.defineProperties(b,{stage:{get:b._getStage},cacheID:{get:function(){return this.bitmapCache&&this.bitmapCache.cacheID},set:function(a){this.bitmapCache&&(this.bitmapCache.cacheID=a)}},scale:{get:function(){return this.scaleX},set:function(a){this.scaleX=this.scaleY=a}}})}catch(d){}b.isVisible=function(){return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY)},b.draw=function(a,b){var c=this.bitmapCache;return c&&!b?c.draw(a):!1},b.updateContext=function(b){var c=this,d=c.mask,e=c._props.matrix;d&&d.graphics&&!d.graphics.isEmpty()&&(d.getMatrix(e),b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),d.graphics.drawAsPath(b),b.clip(),e.invert(),b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty)),this.getMatrix(e);var f=e.tx,g=e.ty;a._snapToPixelEnabled&&c.snapToPixel&&(f=f+(0>f?-.5:.5)|0,g=g+(0>g?-.5:.5)|0),b.transform(e.a,e.b,e.c,e.d,f,g),b.globalAlpha*=c.alpha,c.compositeOperation&&(b.globalCompositeOperation=c.compositeOperation),c.shadow&&this._applyShadow(b,c.shadow)},b.cache=function(a,b,c,d,e,f){this.bitmapCache||(this.bitmapCache=new createjs.BitmapCache),this.bitmapCache.define(this,a,b,c,d,e,f)},b.updateCache=function(a){if(!this.bitmapCache)throw"cache() must be called before updateCache()";this.bitmapCache.update(a)},b.uncache=function(){this.bitmapCache&&(this.bitmapCache.release(),this.bitmapCache=void 0)},b.getCacheDataURL=function(){return this.bitmapCache?this.bitmapCache.getDataURL():null},b.localToGlobal=function(a,b,c){return this.getConcatenatedMatrix(this._props.matrix).transformPoint(a,b,c||new createjs.Point)},b.globalToLocal=function(a,b,c){return this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(a,b,c||new createjs.Point)},b.localToLocal=function(a,b,c,d){return d=this.localToGlobal(a,b,d),c.globalToLocal(d.x,d.y,d)},b.setTransform=function(a,b,c,d,e,f,g,h,i){return this.x=a||0,this.y=b||0,this.scaleX=null==c?1:c,this.scaleY=null==d?1:d,this.rotation=e||0,this.skewX=f||0,this.skewY=g||0,this.regX=h||0,this.regY=i||0,this},b.getMatrix=function(a){var b=this,c=a&&a.identity()||new createjs.Matrix2D;return b.transformMatrix?c.copy(b.transformMatrix):c.appendTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY)},b.getConcatenatedMatrix=function(a){for(var b=this,c=this.getMatrix(a);b=b.parent;)c.prependMatrix(b.getMatrix(b._props.matrix));return c},b.getConcatenatedDisplayProps=function(a){a=a?a.identity():new createjs.DisplayProps;var b=this,c=b.getMatrix(a.matrix);do a.prepend(b.visible,b.alpha,b.shadow,b.compositeOperation),b!=this&&c.prependMatrix(b.getMatrix(b._props.matrix));while(b=b.parent);return a},b.hitTest=function(b,c){var d=a._hitTestContext;d.setTransform(1,0,0,1,-b,-c),this.draw(d);var e=this._testHit(d);return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,2,2),e},b.set=function(a){for(var b in a)this[b]=a[b];return this},b.getBounds=function(){if(this._bounds)return this._rectangle.copy(this._bounds);var a=this.cacheCanvas;if(a){var b=this._cacheScale;return this._rectangle.setValues(this._cacheOffsetX,this._cacheOffsetY,a.width/b,a.height/b)}return null},b.getTransformedBounds=function(){return this._getBounds()},b.setBounds=function(a,b,c,d){return null==a?void(this._bounds=a):void(this._bounds=(this._bounds||new createjs.Rectangle).setValues(a,b,c,d))},b.clone=function(){return this._cloneProps(new a)},b.toString=function(){return"[DisplayObject (name="+this.name+")]"},b._updateState=null,b._cloneProps=function(a){return a.alpha=this.alpha,a.mouseEnabled=this.mouseEnabled,a.tickEnabled=this.tickEnabled,a.name=this.name,a.regX=this.regX,a.regY=this.regY,a.rotation=this.rotation,a.scaleX=this.scaleX,a.scaleY=this.scaleY,a.shadow=this.shadow,a.skewX=this.skewX,a.skewY=this.skewY,a.visible=this.visible,a.x=this.x,a.y=this.y,a.compositeOperation=this.compositeOperation,a.snapToPixel=this.snapToPixel,a.filters=null==this.filters?null:this.filters.slice(0),a.mask=this.mask,a.hitArea=this.hitArea,a.cursor=this.cursor,a._bounds=this._bounds,a},b._applyShadow=function(a,b){b=b||Shadow.identity,a.shadowColor=b.color,a.shadowOffsetX=b.offsetX,a.shadowOffsetY=b.offsetY,a.shadowBlur=b.blur},b._tick=function(a){var b=this._listeners;b&&b.tick&&(a.target=null,a.propagationStopped=a.immediatePropagationStopped=!1,this.dispatchEvent(a))},b._testHit=function(b){try{var c=b.getImageData(0,0,1,1).data[3]>1}catch(d){if(!a.suppressCrossDomainErrors)throw"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images."}return c},b._getBounds=function(a,b){return this._transformBounds(this.getBounds(),a,b)},b._transformBounds=function(a,b,c){if(!a)return a;var d=a.x,e=a.y,f=a.width,g=a.height,h=this._props.matrix;h=c?h.identity():this.getMatrix(h),(d||e)&&h.appendTransform(0,0,1,1,0,0,0,-d,-e),b&&h.prependMatrix(b);var i=f*h.a,j=f*h.b,k=g*h.c,l=g*h.d,m=h.tx,n=h.ty,o=m,p=m,q=n,r=n;return(d=i+m)p&&(p=d),(d=i+k+m)p&&(p=d),(d=k+m)p&&(p=d),(e=j+n)r&&(r=e),(e=j+l+n)r&&(r=e),(e=l+n)r&&(r=e),a.setValues(o,q,p-o,r-q)},b._hasMouseEventListener=function(){for(var b=a._MOUSE_EVENTS,c=0,d=b.length;d>c;c++)if(this.hasEventListener(b[c]))return!0;return!!this.cursor},createjs.DisplayObject=createjs.promote(a,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function a(){this.DisplayObject_constructor(),this.children=[],this.mouseChildren=!0,this.tickChildren=!0}var b=createjs.extend(a,createjs.DisplayObject);b._getNumChildren=function(){return this.children.length},b.getNumChildren=createjs.deprecate(b._getNumChildren,"Container.getNumChildren");try{Object.defineProperties(b,{numChildren:{get:b._getNumChildren}})}catch(c){}b.initialize=a,b.isVisible=function(){var a=this.cacheCanvas||this.children.length;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;for(var c=this.children.slice(),d=0,e=c.length;e>d;d++){var f=c[d];f.isVisible()&&(a.save(),f.updateContext(a),f.draw(a),a.restore())}return!0},b.addChild=function(a){if(null==a)return a;var b=arguments.length;if(b>1){for(var c=0;b>c;c++)this.addChild(arguments[c]);return arguments[b-1]}var d=a.parent,e=d===this;return d&&d._removeChildAt(createjs.indexOf(d.children,a),e),a.parent=this,this.children.push(a),e||a.dispatchEvent("added"),a},b.addChildAt=function(a,b){var c=arguments.length,d=arguments[c-1];if(0>d||d>this.children.length)return arguments[c-2];if(c>2){for(var e=0;c-1>e;e++)this.addChildAt(arguments[e],d+e);return arguments[c-2]}var f=a.parent,g=f===this;return f&&f._removeChildAt(createjs.indexOf(f.children,a),g),a.parent=this,this.children.splice(b,0,a),g||a.dispatchEvent("added"),a},b.removeChild=function(a){var b=arguments.length;if(b>1){for(var c=!0,d=0;b>d;d++)c=c&&this.removeChild(arguments[d]);return c}return this._removeChildAt(createjs.indexOf(this.children,a))},b.removeChildAt=function(a){var b=arguments.length;if(b>1){for(var c=[],d=0;b>d;d++)c[d]=arguments[d];c.sort(function(a,b){return b-a});for(var e=!0,d=0;b>d;d++)e=e&&this._removeChildAt(c[d]);return e}return this._removeChildAt(a)},b.removeAllChildren=function(){for(var a=this.children;a.length;)this._removeChildAt(0)},b.getChildAt=function(a){return this.children[a]},b.getChildByName=function(a){for(var b=this.children,c=0,d=b.length;d>c;c++)if(b[c].name==a)return b[c];return null},b.sortChildren=function(a){this.children.sort(a)},b.getChildIndex=function(a){return createjs.indexOf(this.children,a)},b.swapChildrenAt=function(a,b){var c=this.children,d=c[a],e=c[b];d&&e&&(c[a]=e,c[b]=d)},b.swapChildren=function(a,b){for(var c,d,e=this.children,f=0,g=e.length;g>f&&(e[f]==a&&(c=f),e[f]==b&&(d=f),null==c||null==d);f++);f!=g&&(e[c]=b,e[d]=a)},b.setChildIndex=function(a,b){var c=this.children,d=c.length;if(!(a.parent!=this||0>b||b>=d)){for(var e=0;d>e&&c[e]!=a;e++);e!=d&&e!=b&&(c.splice(e,1),c.splice(b,0,a))}},b.contains=function(a){for(;a;){if(a==this)return!0;a=a.parent}return!1},b.hitTest=function(a,b){return null!=this.getObjectUnderPoint(a,b)},b.getObjectsUnderPoint=function(a,b,c){var d=[],e=this.localToGlobal(a,b);return this._getObjectsUnderPoint(e.x,e.y,d,c>0,1==c),d},b.getObjectUnderPoint=function(a,b,c){var d=this.localToGlobal(a,b);return this._getObjectsUnderPoint(d.x,d.y,null,c>0,1==c)},b.getBounds=function(){return this._getBounds(null,!0)},b.getTransformedBounds=function(){return this._getBounds()},b.clone=function(b){var c=this._cloneProps(new a);return b&&this._cloneChildren(c),c},b.toString=function(){return"[Container (name="+this.name+")]"},b._tick=function(a){if(this.tickChildren)for(var b=this.children.length-1;b>=0;b--){var c=this.children[b];c.tickEnabled&&c._tick&&c._tick(a)}this.DisplayObject__tick(a)},b._cloneChildren=function(a){a.children.length&&a.removeAllChildren();for(var b=a.children,c=0,d=this.children.length;d>c;c++){var e=this.children[c].clone(!0);e.parent=a,b.push(e)}},b._removeChildAt=function(a,b){if(0>a||a>this.children.length-1)return!1;var c=this.children[a];return c&&(c.parent=null),this.children.splice(a,1),b||c.dispatchEvent("removed"),!0},b._getObjectsUnderPoint=function(b,c,d,e,f,g){if(g=g||0,!g&&!this._testMask(this,b,c))return null;var h,i=createjs.DisplayObject._hitTestContext;f=f||e&&this._hasMouseEventListener();for(var j=this.children,k=j.length,l=k-1;l>=0;l--){var m=j[l],n=m.hitArea;if(m.visible&&(n||m.isVisible())&&(!e||m.mouseEnabled)&&(n||this._testMask(m,b,c)))if(!n&&m instanceof a){var o=m._getObjectsUnderPoint(b,c,d,e,f,g+1);if(!d&&o)return e&&!this.mouseChildren?this:o}else{if(e&&!f&&!m._hasMouseEventListener())continue;var p=m.getConcatenatedDisplayProps(m._props);if(h=p.matrix,n&&(h.appendMatrix(n.getMatrix(n._props.matrix)),p.alpha=n.alpha),i.globalAlpha=p.alpha,i.setTransform(h.a,h.b,h.c,h.d,h.tx-b,h.ty-c),(n||m).draw(i),!this._testHit(i))continue;if(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,2,2),!d)return e&&!this.mouseChildren?this:m;d.push(m)}}return null},b._testMask=function(a,b,c){var d=a.mask;if(!d||!d.graphics||d.graphics.isEmpty())return!0;var e=this._props.matrix,f=a.parent;e=f?f.getConcatenatedMatrix(e):e.identity(),e=d.getMatrix(d._props.matrix).prependMatrix(e);var g=createjs.DisplayObject._hitTestContext;return g.setTransform(e.a,e.b,e.c,e.d,e.tx-b,e.ty-c),d.graphics.drawAsPath(g),g.fillStyle="#000",g.fill(),this._testHit(g)?(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,2,2),!0):!1},b._getBounds=function(a,b){var c=this.DisplayObject_getBounds();if(c)return this._transformBounds(c,a,b);var d=this._props.matrix;d=b?d.identity():this.getMatrix(d),a&&d.prependMatrix(a);for(var e=this.children.length,f=null,g=0;e>g;g++){var h=this.children[g];h.visible&&(c=h._getBounds(d))&&(f?f.extend(c.x,c.y,c.width,c.height):f=c.clone())}return f},createjs.Container=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.Container_constructor(),this.autoClear=!0,this.canvas="string"==typeof a?document.getElementById(a):a,this.mouseX=0,this.mouseY=0,this.drawRect=null,this.snapToPixelEnabled=!1,this.mouseInBounds=!1,this.tickOnUpdate=!0,this.mouseMoveOutside=!1,this.preventSelection=!0,this._pointerData={},this._pointerCount=0,this._primaryPointerID=null,this._mouseOverIntervalID=null,this._nextStage=null,this._prevStage=null,this.enableDOMEvents(!0)}var b=createjs.extend(a,createjs.Container);b._get_nextStage=function(){return this._nextStage},b._set_nextStage=function(a){this._nextStage&&(this._nextStage._prevStage=null),a&&(a._prevStage=this),this._nextStage=a};try{Object.defineProperties(b,{nextStage:{get:b._get_nextStage,set:b._set_nextStage}})}catch(c){}b.update=function(a){if(this.canvas&&(this.tickOnUpdate&&this.tick(a),this.dispatchEvent("drawstart",!1,!0)!==!1)){createjs.DisplayObject._snapToPixelEnabled=this.snapToPixelEnabled;var b=this.drawRect,c=this.canvas.getContext("2d");c.setTransform(1,0,0,1,0,0),this.autoClear&&(b?c.clearRect(b.x,b.y,b.width,b.height):c.clearRect(0,0,this.canvas.width+1,this.canvas.height+1)),c.save(),this.drawRect&&(c.beginPath(),c.rect(b.x,b.y,b.width,b.height),c.clip()),this.updateContext(c),this.draw(c,!1),c.restore(),this.dispatchEvent("drawend")}},b.tick=function(a){if(this.tickEnabled&&this.dispatchEvent("tickstart",!1,!0)!==!1){var b=new createjs.Event("tick");if(a)for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);this._tick(b),this.dispatchEvent("tickend")}},b.handleEvent=function(a){"tick"==a.type&&this.update(a)},b.clear=function(){if(this.canvas){var a=this.canvas.getContext("2d");a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,this.canvas.width+1,this.canvas.height+1)}},b.toDataURL=function(a,b){var c,d=this.canvas.getContext("2d"),e=this.canvas.width,f=this.canvas.height;if(a){c=d.getImageData(0,0,e,f);var g=d.globalCompositeOperation;d.globalCompositeOperation="destination-over",d.fillStyle=a,d.fillRect(0,0,e,f)}var h=this.canvas.toDataURL(b||"image/png");return a&&(d.putImageData(c,0,0),d.globalCompositeOperation=g),h},b.enableMouseOver=function(a){if(this._mouseOverIntervalID&&(clearInterval(this._mouseOverIntervalID),this._mouseOverIntervalID=null,0==a&&this._testMouseOver(!0)),null==a)a=20;else if(0>=a)return;var b=this;this._mouseOverIntervalID=setInterval(function(){b._testMouseOver()},1e3/Math.min(50,a))},b.enableDOMEvents=function(a){null==a&&(a=!0);var b,c,d=this._eventListeners;if(!a&&d){for(b in d)c=d[b],c.t.removeEventListener(b,c.f,!1);this._eventListeners=null}else if(a&&!d&&this.canvas){var e=window.addEventListener?window:document,f=this;d=this._eventListeners={},d.mouseup={t:e,f:function(a){f._handleMouseUp(a)}},d.mousemove={t:e,f:function(a){f._handleMouseMove(a)}},d.dblclick={t:this.canvas,f:function(a){f._handleDoubleClick(a)}},d.mousedown={t:this.canvas,f:function(a){f._handleMouseDown(a)}};for(b in d)c=d[b],c.t.addEventListener(b,c.f,!1)}},b.clone=function(){throw"Stage cannot be cloned."},b.toString=function(){return"[Stage (name="+this.name+")]"},b._getElementRect=function(a){var b;try{b=a.getBoundingClientRect()}catch(c){b={top:a.offsetTop,left:a.offsetLeft,width:a.offsetWidth,height:a.offsetHeight}}var d=(window.pageXOffset||document.scrollLeft||0)-(document.clientLeft||document.body.clientLeft||0),e=(window.pageYOffset||document.scrollTop||0)-(document.clientTop||document.body.clientTop||0),f=window.getComputedStyle?getComputedStyle(a,null):a.currentStyle,g=parseInt(f.paddingLeft)+parseInt(f.borderLeftWidth),h=parseInt(f.paddingTop)+parseInt(f.borderTopWidth),i=parseInt(f.paddingRight)+parseInt(f.borderRightWidth),j=parseInt(f.paddingBottom)+parseInt(f.borderBottomWidth);return{left:b.left+d+g,right:b.right+d-i,top:b.top+e+h,bottom:b.bottom+e-j}},b._getPointerData=function(a){var b=this._pointerData[a];return b||(b=this._pointerData[a]={x:0,y:0}),b},b._handleMouseMove=function(a){a||(a=window.event),this._handlePointerMove(-1,a,a.pageX,a.pageY)},b._handlePointerMove=function(a,b,c,d,e){if((!this._prevStage||void 0!==e)&&this.canvas){var f=this._nextStage,g=this._getPointerData(a),h=g.inBounds;this._updatePointerPosition(a,b,c,d),(h||g.inBounds||this.mouseMoveOutside)&&(-1===a&&g.inBounds==!h&&this._dispatchMouseEvent(this,h?"mouseleave":"mouseenter",!1,a,g,b),this._dispatchMouseEvent(this,"stagemousemove",!1,a,g,b),this._dispatchMouseEvent(g.target,"pressmove",!0,a,g,b)),f&&f._handlePointerMove(a,b,c,d,null)}},b._updatePointerPosition=function(a,b,c,d){var e=this._getElementRect(this.canvas);c-=e.left,d-=e.top;var f=this.canvas.width,g=this.canvas.height;c/=(e.right-e.left)/f,d/=(e.bottom-e.top)/g;var h=this._getPointerData(a);(h.inBounds=c>=0&&d>=0&&f-1>=c&&g-1>=d)?(h.x=c,h.y=d):this.mouseMoveOutside&&(h.x=0>c?0:c>f-1?f-1:c,h.y=0>d?0:d>g-1?g-1:d),h.posEvtObj=b,h.rawX=c,h.rawY=d,(a===this._primaryPointerID||-1===a)&&(this.mouseX=h.x,this.mouseY=h.y,this.mouseInBounds=h.inBounds)},b._handleMouseUp=function(a){this._handlePointerUp(-1,a,!1)},b._handlePointerUp=function(a,b,c,d){var e=this._nextStage,f=this._getPointerData(a);if(!this._prevStage||void 0!==d){var g=null,h=f.target;d||!h&&!e||(g=this._getObjectsUnderPoint(f.x,f.y,null,!0)),f.down&&(this._dispatchMouseEvent(this,"stagemouseup",!1,a,f,b,g),f.down=!1),g==h&&this._dispatchMouseEvent(h,"click",!0,a,f,b),this._dispatchMouseEvent(h,"pressup",!0,a,f,b),c?(a==this._primaryPointerID&&(this._primaryPointerID=null),delete this._pointerData[a]):f.target=null,e&&e._handlePointerUp(a,b,c,d||g&&this)}},b._handleMouseDown=function(a){this._handlePointerDown(-1,a,a.pageX,a.pageY)},b._handlePointerDown=function(a,b,c,d,e){this.preventSelection&&b.preventDefault(),(null==this._primaryPointerID||-1===a)&&(this._primaryPointerID=a),null!=d&&this._updatePointerPosition(a,b,c,d);var f=null,g=this._nextStage,h=this._getPointerData(a);e||(f=h.target=this._getObjectsUnderPoint(h.x,h.y,null,!0)),h.inBounds&&(this._dispatchMouseEvent(this,"stagemousedown",!1,a,h,b,f),h.down=!0),this._dispatchMouseEvent(f,"mousedown",!0,a,h,b),g&&g._handlePointerDown(a,b,c,d,e||f&&this)},b._testMouseOver=function(a,b,c){if(!this._prevStage||void 0!==b){var d=this._nextStage;if(!this._mouseOverIntervalID)return void(d&&d._testMouseOver(a,b,c));var e=this._getPointerData(-1);if(e&&(a||this.mouseX!=this._mouseOverX||this.mouseY!=this._mouseOverY||!this.mouseInBounds)){var f,g,h,i=e.posEvtObj,j=c||i&&i.target==this.canvas,k=null,l=-1,m="";!b&&(a||this.mouseInBounds&&j)&&(k=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,!0),this._mouseOverX=this.mouseX,this._mouseOverY=this.mouseY);var n=this._mouseOverTarget||[],o=n[n.length-1],p=this._mouseOverTarget=[];for(f=k;f;)p.unshift(f),m||(m=f.cursor),f=f.parent;for(this.canvas.style.cursor=m,!b&&c&&(c.canvas.style.cursor=m),g=0,h=p.length;h>g&&p[g]==n[g];g++)l=g;for(o!=k&&this._dispatchMouseEvent(o,"mouseout",!0,-1,e,i,k),g=n.length-1;g>l;g--)this._dispatchMouseEvent(n[g],"rollout",!1,-1,e,i,k);for(g=p.length-1;g>l;g--)this._dispatchMouseEvent(p[g],"rollover",!1,-1,e,i,o);o!=k&&this._dispatchMouseEvent(k,"mouseover",!0,-1,e,i,o),d&&d._testMouseOver(a,b||k&&this,c||j&&this)}}},b._handleDoubleClick=function(a,b){var c=null,d=this._nextStage,e=this._getPointerData(-1);b||(c=this._getObjectsUnderPoint(e.x,e.y,null,!0),this._dispatchMouseEvent(c,"dblclick",!0,-1,e,a)),d&&d._handleDoubleClick(a,b||c&&this)},b._dispatchMouseEvent=function(a,b,c,d,e,f,g){if(a&&(c||a.hasEventListener(b))){var h=new createjs.MouseEvent(b,c,!1,e.x,e.y,f,d,d===this._primaryPointerID||-1===d,e.rawX,e.rawY,g);a.dispatchEvent(h)}},createjs.Stage=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(b,c){if(this.Stage_constructor(b),void 0!==c){if("object"!=typeof c)throw"Invalid options object";var d=c.premultiply,e=c.transparent,f=c.antialias,g=c.preserveBuffer,h=c.autoPurge}this.vocalDebug=!1,this._preserveBuffer=g||!1,this._antialias=f||!1,this._transparent=e||!1,this._premultiply=d||!1,this._autoPurge=void 0,this.autoPurge=h,this._viewportWidth=0,this._viewportHeight=0,this._projectionMatrix=null,this._webGLContext=null,this._clearColor={r:.5,g:.5,b:.5,a:0},this._maxCardsPerBatch=a.DEFAULT_MAX_BATCH_SIZE,this._activeShader=null,this._vertices=null,this._vertexPositionBuffer=null,this._uvs=null,this._uvPositionBuffer=null,this._indices=null,this._textureIndexBuffer=null,this._alphas=null,this._alphaBuffer=null,this._textureDictionary=[],this._textureIDs={},this._batchTextures=[],this._baseTextures=[],this._batchTextureCount=8,this._lastTextureInsert=-1,this._batchID=0,this._drawID=0,this._slotBlacklist=[],this._isDrawing=0,this._lastTrackedCanvas=0,this.isCacheControlled=!1,this._cacheContainer=new createjs.Container,this._initializeWebGL()}var b=createjs.extend(a,createjs.Stage);a.buildUVRects=function(a,b,c){if(!a||!a._frames)return null;void 0===b&&(b=-1),void 0===c&&(c=!1);for(var d=-1!=b&&c?b:0,e=-1!=b&&c?b+1:a._frames.length,f=d;e>f;f++){var g=a._frames[f];if(!(g.uvRect||g.image.width<=0||g.image.height<=0)){var h=g.rect;g.uvRect={t:h.y/g.image.height,l:h.x/g.image.width,b:(h.y+h.height)/g.image.height,r:(h.x+h.width)/g.image.width}}}return a._frames[-1!=b?b:0].uvRect||{t:0,l:0,b:1,r:1}},a.isWebGLActive=function(a){return a&&a instanceof WebGLRenderingContext&&"undefined"!=typeof WebGLRenderingContext},a.VERTEX_PROPERTY_COUNT=6,a.INDICIES_PER_CARD=6,a.DEFAULT_MAX_BATCH_SIZE=1e4,a.WEBGL_MAX_INDEX_NUM=Math.pow(2,16),a.UV_RECT={t:0,l:0,b:1,r:1};try{a.COVER_VERT=new Float32Array([-1,1,1,1,-1,-1,1,1,1,-1,-1,-1]),a.COVER_UV=new Float32Array([0,0,1,0,0,1,1,0,1,1,0,1]),a.COVER_UV_FLIP=new Float32Array([0,1,1,1,0,0,1,1,1,0,0,0])}catch(c){}a.REGULAR_VARYING_HEADER="precision mediump float;varying vec2 vTextureCoord;varying lowp float indexPicker;varying lowp float alphaValue;",a.REGULAR_VERTEX_HEADER=a.REGULAR_VARYING_HEADER+"attribute vec2 vertexPosition;attribute vec2 uvPosition;attribute lowp float textureIndex;attribute lowp float objectAlpha;uniform mat4 pMatrix;",a.REGULAR_FRAGMENT_HEADER=a.REGULAR_VARYING_HEADER+"uniform sampler2D uSampler[{{count}}];",a.REGULAR_VERTEX_BODY="void main(void) {gl_Position = vec4((vertexPosition.x * pMatrix[0][0]) + pMatrix[3][0],(vertexPosition.y * pMatrix[1][1]) + pMatrix[3][1],pMatrix[3][2],1.0);alphaValue = objectAlpha;indexPicker = textureIndex;vTextureCoord = uvPosition;}",a.REGULAR_FRAGMENT_BODY="void main(void) {vec4 color = vec4(1.0, 0.0, 0.0, 1.0);if (indexPicker <= 0.5) {color = texture2D(uSampler[0], vTextureCoord);{{alternates}}}{{fragColor}}}",a.REGULAR_FRAG_COLOR_NORMAL="gl_FragColor = vec4(color.rgb, color.a * alphaValue);",a.REGULAR_FRAG_COLOR_PREMULTIPLY="if(color.a > 0.0035) {gl_FragColor = vec4(color.rgb/color.a, color.a * alphaValue);} else {gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);}",a.PARTICLE_VERTEX_BODY=a.REGULAR_VERTEX_BODY,a.PARTICLE_FRAGMENT_BODY=a.REGULAR_FRAGMENT_BODY,a.COVER_VARYING_HEADER="precision mediump float;varying highp vec2 vRenderCoord;varying highp vec2 vTextureCoord;",a.COVER_VERTEX_HEADER=a.COVER_VARYING_HEADER+"attribute vec2 vertexPosition;attribute vec2 uvPosition;uniform float uUpright;",a.COVER_FRAGMENT_HEADER=a.COVER_VARYING_HEADER+"uniform sampler2D uSampler;",a.COVER_VERTEX_BODY="void main(void) {gl_Position = vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);vRenderCoord = uvPosition;vTextureCoord = vec2(uvPosition.x, abs(uUpright - uvPosition.y));}",a.COVER_FRAGMENT_BODY="void main(void) {vec4 color = texture2D(uSampler, vRenderCoord);gl_FragColor = color;}",b._get_isWebGL=function(){return!!this._webGLContext},b._set_autoPurge=function(a){a=isNaN(a)?1200:a,-1!=a&&(a=10>a?10:a),this._autoPurge=a},b._get_autoPurge=function(){return Number(this._autoPurge)};try{Object.defineProperties(b,{isWebGL:{get:b._get_isWebGL},autoPurge:{get:b._get_autoPurge,set:b._set_autoPurge}})}catch(c){}b._initializeWebGL=function(){if(this.canvas){if(!this._webGLContext||this._webGLContext.canvas!==this.canvas){var a={depth:!1,alpha:this._transparent,stencil:!0,antialias:this._antialias,premultipliedAlpha:this._premultiply,preserveDrawingBuffer:this._preserveBuffer},b=this._webGLContext=this._fetchWebGLContext(this.canvas,a);if(!b)return null;this.updateSimultaneousTextureCount(b.getParameter(b.MAX_TEXTURE_IMAGE_UNITS)),this._maxTextureSlots=b.getParameter(b.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._createBuffers(b),this._initTextures(b),b.disable(b.DEPTH_TEST),b.enable(b.BLEND),b.blendFuncSeparate(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA,b.ONE,b.ONE_MINUS_SRC_ALPHA),b.pixelStorei(b.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiply),this._webGLContext.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),this.updateViewport(this._viewportWidth||this.canvas.width,this._viewportHeight||this.canvas.height)}}else this._webGLContext=null;return this._webGLContext},b.update=function(a){if(this.canvas){if(this.tickOnUpdate&&this.tick(a),this.dispatchEvent("drawstart"),this.autoClear&&this.clear(),this._webGLContext)this._batchDraw(this,this._webGLContext),-1==this._autoPurge||this._drawID%(this._autoPurge/2|0)||this.purgeTextures(this._autoPurge);else{var b=this.canvas.getContext("2d");b.save(),this.updateContext(b),this.draw(b,!1),b.restore()}this.dispatchEvent("drawend")}},b.clear=function(){if(this.canvas)if(a.isWebGLActive(this._webGLContext)){var b=this._webGLContext,c=this._clearColor,d=this._transparent?c.a:1;this._webGLContext.clearColor(c.r*d,c.g*d,c.b*d,d),b.clear(b.COLOR_BUFFER_BIT),this._webGLContext.clearColor(c.r,c.g,c.b,c.a)}else this.Stage_clear()},b.draw=function(b,c){if(b===this._webGLContext&&a.isWebGLActive(this._webGLContext)){var d=this._webGLContext;return this._batchDraw(this,d,c),!0}return this.Stage_draw(b,c)},b.cacheDraw=function(b,c,d){if(a.isWebGLActive(this._webGLContext)){var e=this._webGLContext;return this._cacheDraw(e,b,c,d),!0}return!1},b.protectTextureSlot=function(a,b){if(a>this._maxTextureSlots||0>a)throw"Slot outside of acceptable range";this._slotBlacklist[a]=!!b},b.getTargetRenderTexture=function(a,b,c){var d,e=!1,f=this._webGLContext;if(void 0!==a.__lastRT&&a.__lastRT===a.__rtA&&(e=!0),e?(void 0===a.__rtB?a.__rtB=this.getRenderBufferTexture(b,c):((b!=a.__rtB._width||c!=a.__rtB._height)&&this.resizeTexture(a.__rtB,b,c),this.setTextureParams(f)),d=a.__rtB):(void 0===a.__rtA?a.__rtA=this.getRenderBufferTexture(b,c):((b!=a.__rtA._width||c!=a.__rtA._height)&&this.resizeTexture(a.__rtA,b,c),this.setTextureParams(f)),d=a.__rtA),!d)throw"Problems creating render textures, known causes include using too much VRAM by not releasing WebGL texture instances";return a.__lastRT=d,d},b.releaseTexture=function(a){var b,c;if(a){if(a.children)for(b=0,c=a.children.length;c>b;b++)this.releaseTexture(a.children[b]);a.cacheCanvas&&a.uncache();var d=void 0;if(void 0!==a._storeID){if(a===this._textureDictionary[a._storeID])return this._killTextureObject(a),void(a._storeID=void 0);d=a}else if(2===a._webGLRenderStyle)d=a.image;else if(1===a._webGLRenderStyle){for(b=0,c=a.spriteSheet._images.length;c>b;b++)this.releaseTexture(a.spriteSheet._images[b]);return}if(void 0===d)return void(this.vocalDebug&&console.log("No associated texture found on release"));this._killTextureObject(this._textureDictionary[d._storeID]),d._storeID=void 0}},b.purgeTextures=function(a){void 0==a&&(a=100);for(var b=this._textureDictionary,c=b.length,d=0;c>d;d++){var e=b[d];e&&e._drawID+a<=this._drawID&&this._killTextureObject(e)}},b.updateSimultaneousTextureCount=function(a){var b=this._webGLContext,c=!1;for((1>a||isNaN(a))&&(a=1),this._batchTextureCount=a;!c;)try{this._activeShader=this._fetchShaderProgram(b),c=!0}catch(d){if(1==this._batchTextureCount)throw"Cannot compile shader "+d;this._batchTextureCount-=4,this._batchTextureCount<1&&(this._batchTextureCount=1),this.vocalDebug&&console.log("Reducing desired texture count due to errors: "+this._batchTextureCount)}},b.updateViewport=function(a,b){this._viewportWidth=0|a,this._viewportHeight=0|b;var c=this._webGLContext;c&&(c.viewport(0,0,this._viewportWidth,this._viewportHeight),this._projectionMatrix=new Float32Array([2/this._viewportWidth,0,0,0,0,-2/this._viewportHeight,1,0,0,0,1,0,-1,1,.1,0]),this._projectionMatrixFlip=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),this._projectionMatrixFlip.set(this._projectionMatrix),this._projectionMatrixFlip[5]*=-1,this._projectionMatrixFlip[13]*=-1)},b.getFilterShader=function(a){a||(a=this);var b=this._webGLContext,c=this._activeShader;if(a._builtShader)c=a._builtShader,a.shaderParamSetup&&(b.useProgram(c),a.shaderParamSetup(b,this,c));else try{c=this._fetchShaderProgram(b,"filter",a.VTX_SHADER_BODY,a.FRAG_SHADER_BODY,a.shaderParamSetup&&a.shaderParamSetup.bind(a)),a._builtShader=c,c._name=a.toString()}catch(d){console&&console.log("SHADER SWITCH FAILURE",d)}return c},b.getBaseTexture=function(a,b){var c=Math.ceil(a>0?a:1)||1,d=Math.ceil(b>0?b:1)||1,e=this._webGLContext,f=e.createTexture();return this.resizeTexture(f,c,d),this.setTextureParams(e,!1),f},b.resizeTexture=function(a,b,c){var d=this._webGLContext;d.bindTexture(d.TEXTURE_2D,a),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,b,c,0,d.RGBA,d.UNSIGNED_BYTE,null),a.width=b,a.height=c},b.getRenderBufferTexture=function(a,b){var c=this._webGLContext,d=this.getBaseTexture(a,b);if(!d)return null;var e=c.createFramebuffer();return e?(d.width=a,d.height=b,c.bindFramebuffer(c.FRAMEBUFFER,e),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,d,0),e._renderTexture=d,d._frameBuffer=e,d._storeID=this._textureDictionary.length,this._textureDictionary[d._storeID]=d,c.bindFramebuffer(c.FRAMEBUFFER,null),d):null},b.setTextureParams=function(a,b){b&&this._antialias?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR)):(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST)),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)},b.setClearColor=function(a){var b,c,d,e,f;"string"==typeof a?0==a.indexOf("#")?(4==a.length&&(a="#"+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2)+a.charAt(3)+a.charAt(3)),b=Number("0x"+a.slice(1,3))/255,c=Number("0x"+a.slice(3,5))/255,d=Number("0x"+a.slice(5,7))/255,e=Number("0x"+a.slice(7,9))/255):0==a.indexOf("rgba(")&&(f=a.slice(5,-1).split(","),b=Number(f[0])/255,c=Number(f[1])/255,d=Number(f[2])/255,e=Number(f[3])):(b=((4278190080&a)>>>24)/255,c=((16711680&a)>>>16)/255,d=((65280&a)>>>8)/255,e=(255&a)/255),this._clearColor.r=b||0,this._clearColor.g=c||0,this._clearColor.b=d||0,this._clearColor.a=e||0,this._webGLContext&&this._webGLContext.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a)},b.toString=function(){return"[StageGL (name="+this.name+")]" -},b._fetchWebGLContext=function(a,b){var c;try{c=a.getContext("webgl",b)||a.getContext("experimental-webgl",b)}catch(d){}if(c)c.viewportWidth=a.width,c.viewportHeight=a.height;else{var e="Could not initialize WebGL";console.error?console.error(e):console.log(e)}return c},b._fetchShaderProgram=function(b,c,d,e,f){b.useProgram(null);var g,h;switch(c){case"filter":h=a.COVER_VERTEX_HEADER+(d||a.COVER_VERTEX_BODY),g=a.COVER_FRAGMENT_HEADER+(e||a.COVER_FRAGMENT_BODY);break;case"particle":h=a.REGULAR_VERTEX_HEADER+a.PARTICLE_VERTEX_BODY,g=a.REGULAR_FRAGMENT_HEADER+a.PARTICLE_FRAGMENT_BODY;break;case"override":h=a.REGULAR_VERTEX_HEADER+(d||a.REGULAR_VERTEX_BODY),g=a.REGULAR_FRAGMENT_HEADER+(e||a.REGULAR_FRAGMENT_BODY);break;case"regular":default:h=a.REGULAR_VERTEX_HEADER+a.REGULAR_VERTEX_BODY,g=a.REGULAR_FRAGMENT_HEADER+a.REGULAR_FRAGMENT_BODY}var i=this._createShader(b,b.VERTEX_SHADER,h),j=this._createShader(b,b.FRAGMENT_SHADER,g),k=b.createProgram();if(b.attachShader(k,i),b.attachShader(k,j),b.linkProgram(k),k._type=c,!b.getProgramParameter(k,b.LINK_STATUS))throw b.useProgram(this._activeShader),b.getProgramInfoLog(k);switch(b.useProgram(k),c){case"filter":k.vertexPositionAttribute=b.getAttribLocation(k,"vertexPosition"),b.enableVertexAttribArray(k.vertexPositionAttribute),k.uvPositionAttribute=b.getAttribLocation(k,"uvPosition"),b.enableVertexAttribArray(k.uvPositionAttribute),k.samplerUniform=b.getUniformLocation(k,"uSampler"),b.uniform1i(k.samplerUniform,0),k.uprightUniform=b.getUniformLocation(k,"uUpright"),b.uniform1f(k.uprightUniform,0),f&&f(b,this,k);break;case"override":case"particle":case"regular":default:k.vertexPositionAttribute=b.getAttribLocation(k,"vertexPosition"),b.enableVertexAttribArray(k.vertexPositionAttribute),k.uvPositionAttribute=b.getAttribLocation(k,"uvPosition"),b.enableVertexAttribArray(k.uvPositionAttribute),k.textureIndexAttribute=b.getAttribLocation(k,"textureIndex"),b.enableVertexAttribArray(k.textureIndexAttribute),k.alphaAttribute=b.getAttribLocation(k,"objectAlpha"),b.enableVertexAttribArray(k.alphaAttribute);for(var l=[],m=0;md;d+=c)h[d]=h[d+1]=0;b.bufferData(b.ARRAY_BUFFER,h,b.DYNAMIC_DRAW),g.itemSize=c,g.numItems=f;var i=this._uvPositionBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,i),c=2;var j=this._uvs=new Float32Array(f*c);for(d=0,e=j.length;e>d;d+=c)j[d]=j[d+1]=0;b.bufferData(b.ARRAY_BUFFER,j,b.DYNAMIC_DRAW),i.itemSize=c,i.numItems=f;var k=this._textureIndexBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,k),c=1;var l=this._indices=new Float32Array(f*c);for(d=0,e=l.length;e>d;d++)l[d]=0;b.bufferData(b.ARRAY_BUFFER,l,b.DYNAMIC_DRAW),k.itemSize=c,k.numItems=f;var m=this._alphaBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,m),c=1;var n=this._alphas=new Float32Array(f*c);for(d=0,e=n.length;e>d;d++)n[d]=1;b.bufferData(b.ARRAY_BUFFER,n,b.DYNAMIC_DRAW),m.itemSize=c,m.numItems=f},b._initTextures=function(){this._lastTextureInsert=-1,this._textureDictionary=[],this._textureIDs={},this._baseTextures=[],this._batchTextures=[];for(var a=0;aa.MAX_TEXTURE_SIZE||b.height>a.MAX_TEXTURE_SIZE)&&console&&console.error("Oversized Texture: "+b.width+"x"+b.height+" vs "+a.MAX_TEXTURE_SIZE+"max"))},b._insertTextureInBatch=function(a,b){if(this._batchTextures[b._activeIndex]!==b){var c=-1,d=(this._lastTextureInsert+1)%this._batchTextureCount,e=d;do{if(this._batchTextures[e]._batchID!=this._batchID&&!this._slotBlacklist[e]){c=e;break}e=(e+1)%this._batchTextureCount}while(e!==d);-1===c&&(this.batchReason="textureOverflow",this._drawBuffers(a),this.batchCardCount=0,c=d),this._batchTextures[c]=b,b._activeIndex=c;var f=b._imageData;f&&f._invalid&&void 0!==b._drawID?this._updateTextureImageData(a,f):(a.activeTexture(a.TEXTURE0+c),a.bindTexture(a.TEXTURE_2D,b),this.setTextureParams(a)),this._lastTextureInsert=c}else{var f=b._imageData;void 0!=b._storeID&&f&&f._invalid&&this._updateTextureImageData(a,f)}b._drawID=this._drawID,b._batchID=this._batchID},b._killTextureObject=function(a){if(a){var b=this._webGLContext;if(void 0!==a._storeID&&a._storeID>=0){this._textureDictionary[a._storeID]=void 0;for(var c in this._textureIDs)this._textureIDs[c]==a._storeID&&delete this._textureIDs[c];a._imageData&&(a._imageData._storeID=void 0),a._imageData=a._storeID=void 0}void 0!==a._activeIndex&&this._batchTextures[a._activeIndex]===a&&(this._batchTextures[a._activeIndex]=this._baseTextures[a._activeIndex]);try{a._frameBuffer&&b.deleteFramebuffer(a._frameBuffer),a._frameBuffer=void 0}catch(d){this.vocalDebug&&console.log(d)}try{b.deleteTexture(a)}catch(d){this.vocalDebug&&console.log(d)}}},b._backupBatchTextures=function(a,b){var c=this._webGLContext;this._backupTextures||(this._backupTextures=[]),void 0===b&&(b=this._backupTextures);for(var d=0;d0&&this._drawBuffers(b),this._isDrawing++,this._drawID++,this.batchCardCount=0,this.depth=0,this._appendToBatchGroup(a,b,new createjs.Matrix2D,this.alpha,c),this.batchReason="drawFinish",this._drawBuffers(b),this._isDrawing--},b._cacheDraw=function(a,b,c,d){var e,f=this._activeShader,g=this._slotBlacklist,h=this._maxTextureSlots-1,i=this._viewportWidth,j=this._viewportHeight;this.protectTextureSlot(h,!0);var k=b.getMatrix();k=k.clone(),k.scale(1/d.scale,1/d.scale),k=k.invert(),k.translate(-d.offX/d.scale*b.scaleX,-d.offY/d.scale*b.scaleY);var l=this._cacheContainer;l.children=[b],l.transformMatrix=k,this._backupBatchTextures(!1),c&&c.length?this._drawFilters(b,c,d):this.isCacheControlled?(a.clear(a.COLOR_BUFFER_BIT),this._batchDraw(l,a,!0)):(a.activeTexture(a.TEXTURE0+h),b.cacheCanvas=this.getTargetRenderTexture(b,d._drawWidth,d._drawHeight),e=b.cacheCanvas,a.bindFramebuffer(a.FRAMEBUFFER,e._frameBuffer),this.updateViewport(d._drawWidth,d._drawHeight),this._projectionMatrix=this._projectionMatrixFlip,a.clear(a.COLOR_BUFFER_BIT),this._batchDraw(l,a,!0),a.bindFramebuffer(a.FRAMEBUFFER,null),this.updateViewport(i,j)),this._backupBatchTextures(!0),this.protectTextureSlot(h,!1),this._activeShader=f,this._slotBlacklist=g},b._drawFilters=function(a,b,c){var d,e=this._webGLContext,f=this._maxTextureSlots-1,g=this._viewportWidth,h=this._viewportHeight,i=this._cacheContainer,j=b.length;e.activeTexture(e.TEXTURE0+f),d=this.getTargetRenderTexture(a,c._drawWidth,c._drawHeight),e.bindFramebuffer(e.FRAMEBUFFER,d._frameBuffer),this.updateViewport(c._drawWidth,c._drawHeight),e.clear(e.COLOR_BUFFER_BIT),this._batchDraw(i,e,!0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d),this.setTextureParams(e);var k=!1,l=0,m=b[l];do this._activeShader=this.getFilterShader(m),this._activeShader&&(e.activeTexture(e.TEXTURE0+f),d=this.getTargetRenderTexture(a,c._drawWidth,c._drawHeight),e.bindFramebuffer(e.FRAMEBUFFER,d._frameBuffer),e.viewport(0,0,c._drawWidth,c._drawHeight),e.clear(e.COLOR_BUFFER_BIT),this._drawCover(e,k),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d),this.setTextureParams(e),(j>1||b[0]._multiPass)&&(k=!k),m=null!==m._multiPass?m._multiPass:b[++l]);while(m);this.isCacheControlled?(e.bindFramebuffer(e.FRAMEBUFFER,null),this.updateViewport(g,h),this._activeShader=this.getFilterShader(this),e.clear(e.COLOR_BUFFER_BIT),this._drawCover(e,k)):(k&&(e.activeTexture(e.TEXTURE0+f),d=this.getTargetRenderTexture(a,c._drawWidth,c._drawHeight),e.bindFramebuffer(e.FRAMEBUFFER,d._frameBuffer),this._activeShader=this.getFilterShader(this),e.viewport(0,0,c._drawWidth,c._drawHeight),e.clear(e.COLOR_BUFFER_BIT),this._drawCover(e,!k)),e.bindFramebuffer(e.FRAMEBUFFER,null),this.updateViewport(g,h),a.cacheCanvas=d)},b._appendToBatchGroup=function(b,c,d,e,f){b._glMtx||(b._glMtx=new createjs.Matrix2D);var g=b._glMtx;g.copy(d),b.transformMatrix?g.appendMatrix(b.transformMatrix):g.appendTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY);for(var h,i,j,k,l=b.children.length,m=0;l>m;m++){var n=b.children[m];if(n.visible&&e)if(n.cacheCanvas&&!f||(n._updateState&&n._updateState(),!n.children)){this.batchCardCount+1>this._maxCardsPerBatch&&(this.batchReason="vertexOverflow",this._drawBuffers(c),this.batchCardCount=0),n._glMtx||(n._glMtx=new createjs.Matrix2D);var o=n._glMtx;o.copy(g),n.transformMatrix?o.appendMatrix(n.transformMatrix):o.appendTransform(n.x,n.y,n.scaleX,n.scaleY,n.rotation,n.skewX,n.skewY,n.regX,n.regY);var p,q,r,s,t,u,v=n.cacheCanvas&&!f;if(2===n._webGLRenderStyle||v)r=(f?!1:n.cacheCanvas)||n.image;else{if(1!==n._webGLRenderStyle)continue;if(s=n.spriteSheet.getFrame(n.currentFrame),null===s)continue;r=s.image}var w=this._uvs,x=this._vertices,y=this._indices,z=this._alphas;if(r){if(void 0===r._storeID)t=this._loadTextureImage(c,r),this._insertTextureInBatch(c,t);else{if(t=this._textureDictionary[r._storeID],!t){this.vocalDebug&&console.log("Texture should not be looked up while not being stored.");continue}t._batchID!==this._batchID&&this._insertTextureInBatch(c,t)}if(q=t._activeIndex,2===n._webGLRenderStyle||v)!v&&n.sourceRect?(n._uvRect||(n._uvRect={}),u=n.sourceRect,p=n._uvRect,p.t=u.y/r.height,p.l=u.x/r.width,p.b=(u.y+u.height)/r.height,p.r=(u.x+u.width)/r.width,h=0,i=0,j=u.width+h,k=u.height+i):(p=a.UV_RECT,v?(u=n.bitmapCache,h=u.x+u._filterOffX/u.scale,i=u.y+u._filterOffY/u.scale,j=u._drawWidth/u.scale+h,k=u._drawHeight/u.scale+i):(h=0,i=0,j=r.width+h,k=r.height+i));else if(1===n._webGLRenderStyle){var A=s.rect;p=s.uvRect,p||(p=a.buildUVRects(n.spriteSheet,n.currentFrame,!1)),h=-s.regX,i=-s.regY,j=A.width-s.regX,k=A.height-s.regY}var B=this.batchCardCount*a.INDICIES_PER_CARD,C=2*B;x[C]=h*o.a+i*o.c+o.tx,x[C+1]=h*o.b+i*o.d+o.ty,x[C+2]=h*o.a+k*o.c+o.tx,x[C+3]=h*o.b+k*o.d+o.ty,x[C+4]=j*o.a+i*o.c+o.tx,x[C+5]=j*o.b+i*o.d+o.ty,x[C+6]=x[C+2],x[C+7]=x[C+3],x[C+8]=x[C+4],x[C+9]=x[C+5],x[C+10]=j*o.a+k*o.c+o.tx,x[C+11]=j*o.b+k*o.d+o.ty,w[C]=p.l,w[C+1]=p.t,w[C+2]=p.l,w[C+3]=p.b,w[C+4]=p.r,w[C+5]=p.t,w[C+6]=p.l,w[C+7]=p.b,w[C+8]=p.r,w[C+9]=p.t,w[C+10]=p.r,w[C+11]=p.b,y[B]=y[B+1]=y[B+2]=y[B+3]=y[B+4]=y[B+5]=q,z[B]=z[B+1]=z[B+2]=z[B+3]=z[B+4]=z[B+5]=n.alpha*e,this.batchCardCount++}}else this._appendToBatchGroup(n,c,g,n.alpha*e)}},b._drawBuffers=function(b){if(!(this.batchCardCount<=0)){this.vocalDebug&&console.log("Draw["+this._drawID+":"+this._batchID+"] : "+this.batchReason);var c=this._activeShader,d=this._vertexPositionBuffer,e=this._textureIndexBuffer,f=this._uvPositionBuffer,g=this._alphaBuffer;b.useProgram(c),b.bindBuffer(b.ARRAY_BUFFER,d),b.vertexAttribPointer(c.vertexPositionAttribute,d.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,this._vertices),b.bindBuffer(b.ARRAY_BUFFER,e),b.vertexAttribPointer(c.textureIndexAttribute,e.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,this._indices),b.bindBuffer(b.ARRAY_BUFFER,f),b.vertexAttribPointer(c.uvPositionAttribute,f.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,this._uvs),b.bindBuffer(b.ARRAY_BUFFER,g),b.vertexAttribPointer(c.alphaAttribute,g.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,this._alphas),b.uniformMatrix4fv(c.pMatrixUniform,b.FALSE,this._projectionMatrix);for(var h=0;h0&&this._drawBuffers(b),this.vocalDebug&&console.log("Draw["+this._drawID+":"+this._batchID+"] : Cover");var d=this._activeShader,e=this._vertexPositionBuffer,f=this._uvPositionBuffer;b.clear(b.COLOR_BUFFER_BIT),b.useProgram(d),b.bindBuffer(b.ARRAY_BUFFER,e),b.vertexAttribPointer(d.vertexPositionAttribute,e.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,a.COVER_VERT),b.bindBuffer(b.ARRAY_BUFFER,f),b.vertexAttribPointer(d.uvPositionAttribute,f.itemSize,b.FLOAT,!1,0,0),b.bufferSubData(b.ARRAY_BUFFER,0,c?a.COVER_UV_FLIP:a.COVER_UV),b.uniform1i(d.samplerUniform,0),b.uniform1f(d.uprightUniform,c?0:1),b.drawArrays(b.TRIANGLES,0,a.INDICIES_PER_CARD)},createjs.StageGL=createjs.promote(a,"Stage")}(),this.createjs=this.createjs||{},function(){function a(a){this.DisplayObject_constructor(),"string"==typeof a?(this.image=document.createElement("img"),this.image.src=a):this.image=a,this.sourceRect=null,this._webGLRenderStyle=createjs.DisplayObject._StageGL_BITMAP}var b=createjs.extend(a,createjs.DisplayObject);b.initialize=a,b.isVisible=function(){var a=this.image,b=this.cacheCanvas||a&&(a.naturalWidth||a.getContext||a.readyState>=2);return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&b)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.image,d=this.sourceRect;if(c.getImage&&(c=c.getImage()),!c)return!0;if(d){var e=d.x,f=d.y,g=e+d.width,h=f+d.height,i=0,j=0,k=c.width,l=c.height;0>e&&(i-=e,e=0),g>k&&(g=k),0>f&&(j-=f,f=0),h>l&&(h=l),a.drawImage(c,e,f,g-e,h-f,i,j,g-e,h-f)}else a.drawImage(c,0,0);return!0},b.getBounds=function(){var a=this.DisplayObject_getBounds();if(a)return a;var b=this.image,c=this.sourceRect||b,d=b&&(b.naturalWidth||b.getContext||b.readyState>=2);return d?this._rectangle.setValues(0,0,c.width,c.height):null},b.clone=function(b){var c=this.image;c&&b&&(c=c.cloneNode());var d=new a(c);return this.sourceRect&&(d.sourceRect=this.sourceRect.clone()),this._cloneProps(d),d},b.toString=function(){return"[Bitmap (name="+this.name+")]"},createjs.Bitmap=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.DisplayObject_constructor(),this.currentFrame=0,this.currentAnimation=null,this.paused=!0,this.spriteSheet=a,this.currentAnimationFrame=0,this.framerate=0,this._animation=null,this._currentFrame=null,this._skipAdvance=!1,this._webGLRenderStyle=createjs.DisplayObject._StageGL_SPRITE,null!=b&&this.gotoAndPlay(b)}var b=createjs.extend(a,createjs.DisplayObject);b.initialize=a,b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet.complete;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;this._normalizeFrame();var c=this.spriteSheet.getFrame(0|this._currentFrame);if(!c)return!1;var d=c.rect;return d.width&&d.height&&a.drawImage(c.image,d.x,d.y,d.width,d.height,-c.regX,-c.regY,d.width,d.height),!0},b.play=function(){this.paused=!1},b.stop=function(){this.paused=!0},b.gotoAndPlay=function(a){this.paused=!1,this._skipAdvance=!0,this._goto(a)},b.gotoAndStop=function(a){this.paused=!0,this._goto(a)},b.advance=function(a){var b=this.framerate||this.spriteSheet.framerate,c=b&&null!=a?a/(1e3/b):1;this._normalizeFrame(c)},b.getBounds=function(){return this.DisplayObject_getBounds()||this.spriteSheet.getFrameBounds(this.currentFrame,this._rectangle)},b.clone=function(){return this._cloneProps(new a(this.spriteSheet))},b.toString=function(){return"[Sprite (name="+this.name+")]"},b._cloneProps=function(a){return this.DisplayObject__cloneProps(a),a.currentFrame=this.currentFrame,a.currentAnimation=this.currentAnimation,a.paused=this.paused,a.currentAnimationFrame=this.currentAnimationFrame,a.framerate=this.framerate,a._animation=this._animation,a._currentFrame=this._currentFrame,a._skipAdvance=this._skipAdvance,a},b._tick=function(a){this.paused||(this._skipAdvance||this.advance(a&&a.delta),this._skipAdvance=!1),this.DisplayObject__tick(a)},b._normalizeFrame=function(a){a=a||0;var b,c=this._animation,d=this.paused,e=this._currentFrame;if(c){var f=c.speed||1,g=this.currentAnimationFrame;if(b=c.frames.length,g+a*f>=b){var h=c.next;if(this._dispatchAnimationEnd(c,e,d,h,b-1))return;if(h)return this._goto(h,a-(b-g)/f);this.paused=!0,g=c.frames.length-1}else g+=a*f;this.currentAnimationFrame=g,this._currentFrame=c.frames[0|g]}else if(e=this._currentFrame+=a,b=this.spriteSheet.getNumFrames(),e>=b&&b>0&&!this._dispatchAnimationEnd(c,e,d,b-1)&&(this._currentFrame-=b)>=b)return this._normalizeFrame();e=0|this._currentFrame,this.currentFrame!=e&&(this.currentFrame=e,this.dispatchEvent("change"))},b._dispatchAnimationEnd=function(a,b,c,d,e){var f=a?a.name:null;if(this.hasEventListener("animationend")){var g=new createjs.Event("animationend");g.name=f,g.next=d,this.dispatchEvent(g)}var h=this._animation!=a||this._currentFrame!=b;return h||c||!this.paused||(this.currentAnimationFrame=e,h=!0),h},b._goto=function(a,b){if(this.currentAnimationFrame=0,isNaN(a)){var c=this.spriteSheet.getAnimation(a);c&&(this._animation=c,this.currentAnimation=a,this._normalizeFrame(b))}else this.currentAnimation=this._animation=null,this._currentFrame=a,this._normalizeFrame()},createjs.Sprite=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.DisplayObject_constructor(),this.graphics=a?a:new createjs.Graphics}var b=createjs.extend(a,createjs.DisplayObject);b.isVisible=function(){var a=this.cacheCanvas||this.graphics&&!this.graphics.isEmpty();return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){return this.DisplayObject_draw(a,b)?!0:(this.graphics.draw(a,this),!0)},b.clone=function(b){var c=b&&this.graphics?this.graphics.clone():this.graphics;return this._cloneProps(new a(c))},b.toString=function(){return"[Shape (name="+this.name+")]"},createjs.Shape=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.DisplayObject_constructor(),this.text=a,this.font=b,this.color=c,this.textAlign="left",this.textBaseline="top",this.maxWidth=null,this.outline=0,this.lineHeight=0,this.lineWidth=null}var b=createjs.extend(a,createjs.DisplayObject),c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");c.getContext&&(a._workingContext=c.getContext("2d"),c.width=c.height=1),a.H_OFFSETS={start:0,left:0,center:-.5,end:-1,right:-1},a.V_OFFSETS={top:0,hanging:-.01,middle:-.4,alphabetic:-.8,ideographic:-.85,bottom:-1},b.isVisible=function(){var a=this.cacheCanvas||null!=this.text&&""!==this.text;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.color||"#000";return this.outline?(a.strokeStyle=c,a.lineWidth=1*this.outline):a.fillStyle=c,this._drawText(this._prepContext(a)),!0},b.getMeasuredWidth=function(){return this._getMeasuredWidth(this.text)},b.getMeasuredLineHeight=function(){return 1.2*this._getMeasuredWidth("M")},b.getMeasuredHeight=function(){return this._drawText(null,{}).height},b.getBounds=function(){var b=this.DisplayObject_getBounds();if(b)return b;if(null==this.text||""===this.text)return null;var c=this._drawText(null,{}),d=this.maxWidth&&this.maxWidthj;j++){var l=i[j],m=null;if(null!=this.lineWidth&&(m=b.measureText(l).width)>this.lineWidth){var n=l.split(/(\s)/);l=n[0],m=b.measureText(l).width;for(var o=1,p=n.length;p>o;o+=2){var q=b.measureText(n[o]+n[o+1]).width;m+q>this.lineWidth?(e&&this._drawTextLine(b,l,h*f),d&&d.push(l),m>g&&(g=m),l=n[o+1],m=b.measureText(l).width,h++):(l+=n[o]+n[o+1],m+=q)}}e&&this._drawTextLine(b,l,h*f),d&&d.push(l),c&&null==m&&(m=b.measureText(l).width),m>g&&(g=m),h++}return c&&(c.width=g,c.height=h*f),e||b.restore(),c},b._drawTextLine=function(a,b,c){this.outline?a.strokeText(b,0,c,this.maxWidth||65535):a.fillText(b,0,c,this.maxWidth||65535)},b._getMeasuredWidth=function(b){var c=a._workingContext;c.save();var d=this._prepContext(c).measureText(b).width;return c.restore(),d},createjs.Text=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.Container_constructor(),this.text=a||"",this.spriteSheet=b,this.lineHeight=0,this.letterSpacing=0,this.spaceWidth=0,this._oldProps={text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0},this._oldStage=null,this._drawAction=null}var b=createjs.extend(a,createjs.Container);a.maxPoolSize=100,a._spritePool=[],b.draw=function(a,b){this.DisplayObject_draw(a,b)||(this._updateState(),this.Container_draw(a,b))},b.getBounds=function(){return this._updateText(),this.Container_getBounds()},b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet&&this.spriteSheet.complete&&this.text;return!!(this.visible&&this.alpha>0&&0!==this.scaleX&&0!==this.scaleY&&a)},b.clone=function(){return this._cloneProps(new a(this.text,this.spriteSheet))},b.addChild=b.addChildAt=b.removeChild=b.removeChildAt=b.removeAllChildren=function(){},b._updateState=function(){this._updateText()},b._cloneProps=function(a){return this.Container__cloneProps(a),a.lineHeight=this.lineHeight,a.letterSpacing=this.letterSpacing,a.spaceWidth=this.spaceWidth,a},b._getFrameIndex=function(a,b){var c,d=b.getAnimation(a);return d||(a!=(c=a.toUpperCase())||a!=(c=a.toLowerCase())||(c=null),c&&(d=b.getAnimation(c))),d&&d.frames[0]},b._getFrame=function(a,b){var c=this._getFrameIndex(a,b);return null==c?c:b.getFrame(c)},b._getLineHeight=function(a){var b=this._getFrame("1",a)||this._getFrame("T",a)||this._getFrame("L",a)||a.getFrame(0);return b?b.rect.height:1},b._getSpaceWidth=function(a){var b=this._getFrame("1",a)||this._getFrame("l",a)||this._getFrame("e",a)||this._getFrame("a",a)||a.getFrame(0);return b?b.rect.width:1},b._updateText=function(){var b,c=0,d=0,e=this._oldProps,f=!1,g=this.spaceWidth,h=this.lineHeight,i=this.spriteSheet,j=a._spritePool,k=this.children,l=0,m=k.length;for(var n in e)e[n]!=this[n]&&(e[n]=this[n],f=!0);if(f){var o=!!this._getFrame(" ",i);o||g||(g=this._getSpaceWidth(i)),h||(h=this._getLineHeight(i));for(var p=0,q=this.text.length;q>p;p++){var r=this.text.charAt(p);if(" "!=r||o)if("\n"!=r&&"\r"!=r){var s=this._getFrameIndex(r,i);null!=s&&(m>l?b=k[l]:(k.push(b=j.length?j.pop():new createjs.Sprite),b.parent=this,m++),b.spriteSheet=i,b.gotoAndStop(s),b.x=c,b.y=d,l++,c+=b.getBounds().width+this.letterSpacing)}else"\r"==r&&"\n"==this.text.charAt(p+1)&&p++,c=0,d+=h;else c+=g}for(;m>l;)j.push(b=k.pop()),b.parent=null,m--;j.length>a.maxPoolSize&&(j.length=a.maxPoolSize)}},createjs.BitmapText=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(b){this.Container_constructor(),!a.inited&&a.init();var c,d,e,f;b instanceof String||arguments.length>1?(c=b,d=arguments[1],e=arguments[2],f=arguments[3],null==e&&(e=-1),b=null):b&&(c=b.mode,d=b.startPosition,e=b.loop,f=b.labels),b||(b={labels:f}),this.mode=c||a.INDEPENDENT,this.startPosition=d||0,this.loop=e===!0?-1:e||0,this.currentFrame=0,this.paused=b.paused||!1,this.actionsEnabled=!0,this.autoReset=!0,this.frameBounds=this.frameBounds||b.frameBounds,this.framerate=null,b.useTicks=b.paused=!0,this.timeline=new createjs.Timeline(b),this._synchOffset=0,this._rawPosition=-1,this._bound_resolveState=this._resolveState.bind(this),this._t=0,this._managed={}}function b(){throw"MovieClipPlugin cannot be instantiated."}var c=createjs.extend(a,createjs.Container);a.INDEPENDENT="independent",a.SINGLE_FRAME="single",a.SYNCHED="synched",a.inited=!1,a.init=function(){a.inited||(b.install(),a.inited=!0)},c._getLabels=function(){return this.timeline.getLabels()},c.getLabels=createjs.deprecate(c._getLabels,"MovieClip.getLabels"),c._getCurrentLabel=function(){return this.timeline.currentLabel},c.getCurrentLabel=createjs.deprecate(c._getCurrentLabel,"MovieClip.getCurrentLabel"),c._getDuration=function(){return this.timeline.duration},c.getDuration=createjs.deprecate(c._getDuration,"MovieClip.getDuration");try{Object.defineProperties(c,{labels:{get:c._getLabels},currentLabel:{get:c._getCurrentLabel},totalFrames:{get:c._getDuration},duration:{get:c._getDuration}})}catch(d){}c.initialize=a,c.isVisible=function(){return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY)},c.draw=function(a,b){return this.DisplayObject_draw(a,b)?!0:(this._updateState(),this.Container_draw(a,b),!0)},c.play=function(){this.paused=!1},c.stop=function(){this.paused=!0},c.gotoAndPlay=function(a){this.paused=!1,this._goto(a)},c.gotoAndStop=function(a){this.paused=!0,this._goto(a)},c.advance=function(b){var c=a.INDEPENDENT;if(this.mode===c){for(var d=this,e=d.framerate;(d=d.parent)&&null===e;)d.mode===c&&(e=d._framerate);if(this._framerate=e,!this.paused){var f=null!==e&&-1!==e&&null!==b?b/(1e3/e)+this._t:1,g=0|f;for(this._t=f-g;g--;)this._updateTimeline(this._rawPosition+1,!1)}}},c.clone=function(){throw"MovieClip cannot be cloned."},c.toString=function(){return"[MovieClip (name="+this.name+")]"},c._updateState=function(){(-1===this._rawPosition||this.mode!==a.INDEPENDENT)&&this._updateTimeline(-1)},c._tick=function(a){this.advance(a&&a.delta),this.Container__tick(a)},c._goto=function(a){var b=this.timeline.resolve(a);null!=b&&(this._t=0,this._updateTimeline(b,!0))},c._reset=function(){this._rawPosition=-1,this._t=this.currentFrame=0,this.paused=!1},c._updateTimeline=function(b,c){var d=this.mode!==a.INDEPENDENT,e=this.timeline;d&&(b=this.startPosition+(this.mode===a.SINGLE_FRAME?0:this._synchOffset)),0>b&&(b=0),(this._rawPosition!==b||d)&&(this._rawPosition=b,e.loop=this.loop,e.setPosition(b,d||!this.actionsEnabled,c,this._bound_resolveState))},c._renderFirstFrame=function(){var a=this.timeline,b=a.rawPosition;a.setPosition(0,!0,!0,this._bound_resolveState),a.rawPosition=b},c._resolveState=function(){var a=this.timeline;this.currentFrame=a.position;for(var b in this._managed)this._managed[b]=1;for(var c=a.tweens,d=0,e=c.length;e>d;d++){var f=c[d],g=f.target;if(g!==this&&!f.passive){var h=f._stepPosition;g instanceof createjs.DisplayObject?this._addManagedChild(g,h):this._setState(g.state,h)}}var i=this.children;for(d=i.length-1;d>=0;d--){var j=i[d].id;1===this._managed[j]&&(this.removeChildAt(d),delete this._managed[j])}},c._setState=function(a,b){if(a)for(var c=a.length-1;c>=0;c--){var d=a[c],e=d.t,f=d.p;for(var g in f)e[g]=f[g];this._addManagedChild(e,b)}},c._addManagedChild=function(b,c){b._off||(this.addChildAt(b,0),b instanceof a&&(b._synchOffset=c,b.mode===a.INDEPENDENT&&b.autoReset&&!this._managed[b.id]&&b._reset()),this._managed[b.id]=2)},c._getBounds=function(a,b){var c=this.DisplayObject_getBounds();return c||this.frameBounds&&(c=this._rectangle.copy(this.frameBounds[this.currentFrame])),c?this._transformBounds(c,a,b):this.Container__getBounds(a,b)},createjs.MovieClip=createjs.promote(a,"Container"),b.priority=100,b.ID="MovieClip",b.install=function(){createjs.Tween._installPlugin(b)},b.init=function(c,d){"startPosition"===d&&c.target instanceof a&&c._addPlugin(b)},b.step=function(){},b.change=function(a,b,c,d,e){return"startPosition"===c?1===e?b.props[c]:b.prev.props[c]:void 0}}(),this.createjs=this.createjs||{},function(){"use strict";function a(){throw"SpriteSheetUtils cannot be instantiated"}var b=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");b.getContext&&(a._workingCanvas=b,a._workingContext=b.getContext("2d"),b.width=b.height=1),a.extractFrame=function(b,c){isNaN(c)&&(c=b.getAnimation(c).frames[0]);var d=b.getFrame(c);if(!d)return null;var e=d.rect,f=a._workingCanvas;f.width=e.width,f.height=e.height,a._workingContext.drawImage(d.image,e.x,e.y,e.width,e.height,0,0,e.width,e.height);var g=document.createElement("img");return g.src=f.toDataURL("image/png"),g},a.addFlippedFrames=createjs.deprecate(null,"SpriteSheetUtils.addFlippedFrames"),a.mergeAlpha=createjs.deprecate(null,"SpriteSheetUtils.mergeAlpha"),a._flip=function(b,c,d,e){for(var f=b._images,g=a._workingCanvas,h=a._workingContext,i=f.length/c,j=0;i>j;j++){var k=f[j];k.__tmp=j,h.setTransform(1,0,0,1,0,0),h.clearRect(0,0,g.width+1,g.height+1),g.width=k.width,g.height=k.height,h.setTransform(d?-1:1,0,0,e?-1:1,d?k.width:0,e?k.height:0),h.drawImage(k,0,0);var l=document.createElement("img");l.src=g.toDataURL("image/png"),l.width=k.width||k.naturalWidth,l.height=k.height||k.naturalHeight,f.push(l)}var m=b._frames,n=m.length/c;for(j=0;n>j;j++){k=m[j]; -var o=k.rect.clone();l=f[k.image.__tmp+i*c];var p={image:l,rect:o,regX:k.regX,regY:k.regY};d&&(o.x=(l.width||l.naturalWidth)-o.x-o.width,p.regX=o.width-k.regX),e&&(o.y=(l.height||l.naturalHeight)-o.y-o.height,p.regY=o.height-k.regY),m.push(p)}var q="_"+(d?"h":"")+(e?"v":""),r=b._animations,s=b._data,t=r.length/c;for(j=0;t>j;j++){var u=r[j];k=s[u];var v={name:u+q,speed:k.speed,next:k.next,frames:[]};k.next&&(v.next+=q),m=k.frames;for(var w=0,x=m.length;x>w;w++)v.frames.push(m[w]+n*c);s[v.name]=v,r.push(v.name)}},createjs.SpriteSheetUtils=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.EventDispatcher_constructor(),this.maxWidth=2048,this.maxHeight=2048,this.spriteSheet=null,this.scale=1,this.padding=1,this.timeSlice=.3,this.progress=-1,this.framerate=a||0,this._frames=[],this._animations={},this._data=null,this._nextFrameIndex=0,this._index=0,this._timerID=null,this._scale=1}var b=createjs.extend(a,createjs.EventDispatcher);a.ERR_DIMENSIONS="frame dimensions exceed max spritesheet dimensions",a.ERR_RUNNING="a build is already running",b.addFrame=function(b,c,d,e,f){if(this._data)throw a.ERR_RUNNING;var g=c||b.bounds||b.nominalBounds;return!g&&b.getBounds&&(g=b.getBounds()),g?(d=d||1,this._frames.push({source:b,sourceRect:g,scale:d,funct:e,data:f,index:this._frames.length,height:g.height*d})-1):null},b.addAnimation=function(b,c,d,e){if(this._data)throw a.ERR_RUNNING;this._animations[b]={frames:c,next:d,speed:e}},b.addMovieClip=function(b,c,d,e,f,g){if(this._data)throw a.ERR_RUNNING;var h=b.frameBounds,i=c||b.bounds||b.nominalBounds;if(!i&&b.getBounds&&(i=b.getBounds()),i||h){var j,k,l=this._frames.length,m=b.timeline.duration;for(j=0;m>j;j++){var n=h&&h[j]?h[j]:i;this.addFrame(b,n,d,this._setupMovieClipFrame,{i:j,f:e,d:f})}var o=b.timeline._labels,p=[];for(var q in o)p.push({index:o[q],label:q});if(p.length)for(p.sort(function(a,b){return a.index-b.index}),j=0,k=p.length;k>j;j++){for(var r=p[j].label,s=l+p[j].index,t=l+(j==k-1?m:p[j+1].index),u=[],v=s;t>v;v++)u.push(v);(!g||(r=g(r,b,s,t)))&&this.addAnimation(r,u,!0)}}},b.build=function(){if(this._data)throw a.ERR_RUNNING;for(this._startBuild();this._drawNext(););return this._endBuild(),this.spriteSheet},b.buildAsync=function(b){if(this._data)throw a.ERR_RUNNING;this.timeSlice=b,this._startBuild();var c=this;this._timerID=setTimeout(function(){c._run()},50-50*Math.max(.01,Math.min(.99,this.timeSlice||.3)))},b.stopAsync=function(){clearTimeout(this._timerID),this._data=null},b.clone=function(){throw"SpriteSheetBuilder cannot be cloned."},b.toString=function(){return"[SpriteSheetBuilder]"},b._startBuild=function(){var b=this.padding||0;this.progress=0,this.spriteSheet=null,this._index=0,this._scale=this.scale;var c=[];this._data={images:[],frames:c,framerate:this.framerate,animations:this._animations};var d=this._frames.slice();if(d.sort(function(a,b){return a.height<=b.height?-1:1}),d[d.length-1].height+2*b>this.maxHeight)throw a.ERR_DIMENSIONS;for(var e=0,f=0,g=0;d.length;){var h=this._fillRow(d,e,g,c,b);if(h.w>f&&(f=h.w),e+=h.h,!h.h||!d.length){var i=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");i.width=this._getSize(f,this.maxWidth),i.height=this._getSize(e,this.maxHeight),this._data.images[g]=i,h.h||(f=e=0,g++)}}},b._setupMovieClipFrame=function(a,b){var c=a.actionsEnabled;a.actionsEnabled=!1,a.gotoAndStop(b.i),a.actionsEnabled=c,b.f&&b.f(a,b.d,b.i)},b._getSize=function(a,b){for(var c=4;Math.pow(2,++c)=0;l--){var m=b[l],n=this._scale*m.scale,o=m.sourceRect,p=m.source,q=Math.floor(n*o.x-f),r=Math.floor(n*o.y-f),s=Math.ceil(n*o.height+2*f),t=Math.ceil(n*o.width+2*f);if(t>g)throw a.ERR_DIMENSIONS;s>i||j+t>g||(m.img=d,m.rect=new createjs.Rectangle(j,c,t,s),k=k||s,b.splice(l,1),e[m.index]=[j,c,t,s,d,Math.round(-q+n*p.regX-f),Math.round(-r+n*p.regY-f)],j+=t)}return{w:j,h:k}},b._endBuild=function(){this.spriteSheet=new createjs.SpriteSheet(this._data),this._data=null,this.progress=1,this.dispatchEvent("complete")},b._run=function(){for(var a=50*Math.max(.01,Math.min(.99,this.timeSlice||.3)),b=(new Date).getTime()+a,c=!1;b>(new Date).getTime();)if(!this._drawNext()){c=!0;break}if(c)this._endBuild();else{var d=this;this._timerID=setTimeout(function(){d._run()},50-a)}var e=this.progress=this._index/this._frames.length;if(this.hasEventListener("progress")){var f=new createjs.Event("progress");f.progress=e,this.dispatchEvent(f)}},b._drawNext=function(){var a=this._frames[this._index],b=a.scale*this._scale,c=a.rect,d=a.sourceRect,e=this._data.images[a.img],f=e.getContext("2d");return a.funct&&a.funct(a.source,a.data),f.save(),f.beginPath(),f.rect(c.x,c.y,c.width,c.height),f.clip(),f.translate(Math.ceil(c.x-d.x*b),Math.ceil(c.y-d.y*b)),f.scale(b,b),a.source.draw(f),f.restore(),++this._index=!!d)return b;for(var e=0;d>e;e++){var f=c[e];if(f&&f.getBounds){var g=f.getBounds();g&&(0==e?b.setValues(g.x,g.y,g.width,g.height):b.extend(g.x,g.y,g.width,g.height))}}return b},b.toString=function(){return"[BitmapCache]"},b.define=function(a,b,c,d,e,f,g){if(!a)throw"No symbol to cache";this._options=g,this.target=a,this.width=d>=1?d:1,this.height=e>=1?e:1,this.x=b||0,this.y=c||0,this.scale=f||1,this.update()},b.update=function(b){if(!this.target)throw"define() must be called before update()";var c=a.getFilterBounds(this.target),d=this.target.cacheCanvas;this._drawWidth=Math.ceil(this.width*this.scale)+c.width,this._drawHeight=Math.ceil(this.height*this.scale)+c.height,d&&this._drawWidth==d.width&&this._drawHeight==d.height||this._updateSurface(),this._filterOffX=c.x,this._filterOffY=c.y,this.offX=this.x*this.scale+this._filterOffX,this.offY=this.y*this.scale+this._filterOffY,this._drawToCache(b),this.cacheID=this.cacheID?this.cacheID+1:1},b.release=function(){if(this._webGLCache)this._webGLCache.isCacheControlled||(this.__lastRT&&(this.__lastRT=void 0),this.__rtA&&this._webGLCache._killTextureObject(this.__rtA),this.__rtB&&this._webGLCache._killTextureObject(this.__rtB),this.target&&this.target.cacheCanvas&&this._webGLCache._killTextureObject(this.target.cacheCanvas)),this._webGLCache=!1;else{var a=this.target.stage;a instanceof createjs.StageGL&&a.releaseTexture(this.target.cacheCanvas)}this.target=this.target.cacheCanvas=null,this.cacheID=this._cacheDataURLID=this._cacheDataURL=void 0,this.width=this.height=this.x=this.y=this.offX=this.offY=0,this.scale=1},b.getCacheDataURL=function(){var a=this.target&&this.target.cacheCanvas;return a?(this.cacheID!=this._cacheDataURLID&&(this._cacheDataURLID=this.cacheID,this._cacheDataURL=a.toDataURL?a.toDataURL():null),this._cacheDataURL):null},b.draw=function(a){return this.target?(a.drawImage(this.target.cacheCanvas,this.x+this._filterOffX/this.scale,this.y+this._filterOffY/this.scale,this._drawWidth/this.scale,this._drawHeight/this.scale),!0):!1},b._updateSurface=function(){if(!this._options||!this._options.useGL){var a=this.target.cacheCanvas;return a||(a=this.target.cacheCanvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),a.width=this._drawWidth,void(a.height=this._drawHeight)}if(!this._webGLCache)if("stage"===this._options.useGL){if(!this.target.stage||!this.target.stage.isWebGL){var b="Cannot use 'stage' for cache because the object's parent stage is ";throw b+=this.target.stage?"non WebGL.":"not set, please addChild to the correct stage."}this.target.cacheCanvas=!0,this._webGLCache=this.target.stage}else if("new"===this._options.useGL)this.target.cacheCanvas=document.createElement("canvas"),this._webGLCache=new createjs.StageGL(this.target.cacheCanvas,{antialias:!0,transparent:!0,autoPurge:-1}),this._webGLCache.isCacheControlled=!0;else{if(!(this._options.useGL instanceof createjs.StageGL))throw"Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got "+this._options.useGL;this.target.cacheCanvas=!0,this._webGLCache=this._options.useGL,this._webGLCache.isCacheControlled=!0}var a=this.target.cacheCanvas,c=this._webGLCache;c.isCacheControlled&&(a.width=this._drawWidth,a.height=this._drawHeight,c.updateViewport(this._drawWidth,this._drawHeight)),this.target.filters?(c.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight),c.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight)):c.isCacheControlled||c.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight)},b._drawToCache=function(a){var b=this.target.cacheCanvas,c=this.target,d=this._webGLCache;if(d)d.cacheDraw(c,c.filters,this),b=this.target.cacheCanvas,b.width=this._drawWidth,b.height=this._drawHeight;else{var e=b.getContext("2d");a||e.clearRect(0,0,this._drawWidth+1,this._drawHeight+1),e.save(),e.globalCompositeOperation=a,e.setTransform(this.scale,0,0,this.scale,-this._filterOffX,-this._filterOffY),e.translate(-this.x,-this.y),c.draw(e,!0),e.restore(),c.filters&&c.filters.length&&this._applyFilters(e)}b._invalid=!0},b._applyFilters=function(a){var b,c=this.target.filters,d=this._drawWidth,e=this._drawHeight,f=0,g=c[f];do g.usesContext?(b&&(a.putImageData(b,0,0),b=null),g.applyFilter(a,0,0,d,e)):(b||(b=a.getImageData(0,0,d,e)),g._applyFilter(b)),g=null!==g._multiPass?g._multiPass:c[++f];while(g);b&&a.putImageData(b,0,0)},createjs.BitmapCache=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.Filter_constructor(),this._blurX=a,this._blurXTable=[],this._lastBlurX=null,this._blurY=b,this._blurYTable=[],this._lastBlurY=null,this._quality,this._lastQuality=null,this.FRAG_SHADER_TEMPLATE="uniform float xWeight[{{blurX}}];uniform float yWeight[{{blurY}}];uniform vec2 textureOffset;void main(void) {vec4 color = vec4(0.0);float xAdj = ({{blurX}}.0-1.0)/2.0;float yAdj = ({{blurY}}.0-1.0)/2.0;vec2 sampleOffset;for(int i=0; i<{{blurX}}; i++) {for(int j=0; j<{{blurY}}; j++) {sampleOffset = vRenderCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));color += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);}}gl_FragColor = color.rgba;}",(isNaN(c)||1>c)&&(c=1),this.setQuality(0|c)}var b=createjs.extend(a,createjs.Filter);b.getBlurX=function(){return this._blurX},b.getBlurY=function(){return this._blurY},b.setBlurX=function(a){(isNaN(a)||0>a)&&(a=0),this._blurX=a},b.setBlurY=function(a){(isNaN(a)||0>a)&&(a=0),this._blurY=a},b.getQuality=function(){return this._quality},b.setQuality=function(a){(isNaN(a)||0>a)&&(a=0),this._quality=0|a},b._getShader=function(){var a=this._lastBlurX!==this._blurX,b=this._lastBlurY!==this._blurY,c=this._lastQuality!==this._quality;return a||b||c?((a||c)&&(this._blurXTable=this._getTable(this._blurX*this._quality)),(b||c)&&(this._blurYTable=this._getTable(this._blurY*this._quality)),this._updateShader(),this._lastBlurX=this._blurX,this._lastBlurY=this._blurY,void(this._lastQuality=this._quality)):this._compiledShader},b._setShader=function(){this._compiledShader};try{Object.defineProperties(b,{blurX:{get:b.getBlurX,set:b.setBlurX},blurY:{get:b.getBlurY,set:b.setBlurY},quality:{get:b.getQuality,set:b.setQuality},_builtShader:{get:b._getShader,set:b._setShader}})}catch(c){console.log(c)}b._getTable=function(a){var b=4.2;if(1>=a)return[1];var c=[],d=Math.ceil(2*a);d+=d%2?0:1;for(var e=d/2|0,f=-e;e>=f;f++){var g=f/e*b;c.push(1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-(Math.pow(g,2)/4)))}var h=c.reduce(function(a,b){return a+b});return c.map(function(a){return a/h})},b._updateShader=function(){if(void 0!==this._blurX&&void 0!==this._blurY){var a=this.FRAG_SHADER_TEMPLATE;a=a.replace(/\{\{blurX\}\}/g,this._blurXTable.length.toFixed(0)),a=a.replace(/\{\{blurY\}\}/g,this._blurYTable.length.toFixed(0)),this.FRAG_SHADER_BODY=a}},b.shaderParamSetup=function(a,b,c){a.uniform1fv(a.getUniformLocation(c,"xWeight"),this._blurXTable),a.uniform1fv(a.getUniformLocation(c,"yWeight"),this._blurYTable),a.uniform2f(a.getUniformLocation(c,"textureOffset"),2/(b._viewportWidth*this._quality),2/(b._viewportHeight*this._quality))},a.MUL_TABLE=[1,171,205,293,57,373,79,137,241,27,391,357,41,19,283,265,497,469,443,421,25,191,365,349,335,161,155,149,9,278,269,261,505,245,475,231,449,437,213,415,405,395,193,377,369,361,353,345,169,331,325,319,313,307,301,37,145,285,281,69,271,267,263,259,509,501,493,243,479,118,465,459,113,446,55,435,429,423,209,413,51,403,199,393,97,3,379,375,371,367,363,359,355,351,347,43,85,337,333,165,327,323,5,317,157,311,77,305,303,75,297,294,73,289,287,71,141,279,277,275,68,135,67,133,33,262,260,129,511,507,503,499,495,491,61,121,481,477,237,235,467,232,115,457,227,451,7,445,221,439,218,433,215,427,425,211,419,417,207,411,409,203,202,401,399,396,197,49,389,387,385,383,95,189,47,187,93,185,23,183,91,181,45,179,89,177,11,175,87,173,345,343,341,339,337,21,167,83,331,329,327,163,81,323,321,319,159,79,315,313,39,155,309,307,153,305,303,151,75,299,149,37,295,147,73,291,145,289,287,143,285,71,141,281,35,279,139,69,275,137,273,17,271,135,269,267,133,265,33,263,131,261,130,259,129,257,1],a.SHG_TABLE=[0,9,10,11,9,12,10,11,12,9,13,13,10,9,13,13,14,14,14,14,10,13,14,14,14,13,13,13,9,14,14,14,15,14,15,14,15,15,14,15,15,15,14,15,15,15,15,15,14,15,15,15,15,15,15,12,14,15,15,13,15,15,15,15,16,16,16,15,16,14,16,16,14,16,13,16,16,16,15,16,13,16,15,16,14,9,16,16,16,16,16,16,16,16,16,13,14,16,16,15,16,16,10,16,15,16,14,16,16,14,16,16,14,16,16,14,15,16,16,16,14,15,14,15,13,16,16,15,17,17,17,17,17,17,14,15,17,17,16,16,17,16,15,17,16,17,11,17,16,17,16,17,16,17,17,16,17,17,16,17,17,16,16,17,17,17,16,14,17,17,17,17,15,16,14,16,15,16,13,16,15,16,14,16,15,16,12,16,15,16,17,17,17,17,17,13,16,15,17,17,17,16,15,17,17,17,16,15,17,17,14,16,17,17,16,17,17,16,15,17,16,14,17,16,15,17,16,17,17,16,17,15,16,17,14,17,16,15,17,16,17,13,17,16,17,17,16,17,14,17,16,17,16,17,16,17,9],b.getBounds=function(a){var b=0|this.blurX,c=0|this.blurY;if(0>=b&&0>=c)return a;var d=Math.pow(this.quality,.2);return(a||new createjs.Rectangle).pad(c*d+1,b*d+1,c*d+1,b*d+1)},b.clone=function(){return new a(this.blurX,this.blurY,this.quality)},b.toString=function(){return"[BlurFilter]"},b._applyFilter=function(b){var c=this._blurX>>1;if(isNaN(c)||0>c)return!1;var d=this._blurY>>1;if(isNaN(d)||0>d)return!1;if(0==c&&0==d)return!1;var e=this.quality;(isNaN(e)||1>e)&&(e=1),e|=0,e>3&&(e=3),1>e&&(e=1);var f=b.data,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=c+c+1|0,w=d+d+1|0,x=0|b.width,y=0|b.height,z=x-1|0,A=y-1|0,B=c+1|0,C=d+1|0,D={r:0,b:0,g:0,a:0},E=D;for(i=1;v>i;i++)E=E.n={r:0,b:0,g:0,a:0};E.n=D;var F={r:0,b:0,g:0,a:0},G=F;for(i=1;w>i;i++)G=G.n={r:0,b:0,g:0,a:0};G.n=F;for(var H=null,I=0|a.MUL_TABLE[c],J=0|a.SHG_TABLE[c],K=0|a.MUL_TABLE[d],L=0|a.SHG_TABLE[d];e-->0;){m=l=0;var M=I,N=J;for(h=y;--h>-1;){for(n=B*(r=f[0|l]),o=B*(s=f[l+1|0]),p=B*(t=f[l+2|0]),q=B*(u=f[l+3|0]),E=D,i=B;--i>-1;)E.r=r,E.g=s,E.b=t,E.a=u,E=E.n;for(i=1;B>i;i++)j=l+((i>z?z:i)<<2)|0,n+=E.r=f[j],o+=E.g=f[j+1],p+=E.b=f[j+2],q+=E.a=f[j+3],E=E.n;for(H=D,g=0;x>g;g++)f[l++]=n*M>>>N,f[l++]=o*M>>>N,f[l++]=p*M>>>N,f[l++]=q*M>>>N,j=m+((j=g+c+1)g;g++){for(l=g<<2|0,n=C*(r=f[l])|0,o=C*(s=f[l+1|0])|0,p=C*(t=f[l+2|0])|0,q=C*(u=f[l+3|0])|0,G=F,i=0;C>i;i++)G.r=r,G.g=s,G.b=t,G.a=u,G=G.n;for(k=x,i=1;d>=i;i++)l=k+g<<2,n+=G.r=f[l],o+=G.g=f[l+1],p+=G.b=f[l+2],q+=G.a=f[l+3],G=G.n,A>i&&(k+=x);if(l=g,H=F,e>0)for(h=0;y>h;h++)j=l<<2,f[j+3]=u=q*M>>>N,u>0?(f[j]=n*M>>>N,f[j+1]=o*M>>>N,f[j+2]=p*M>>>N):f[j]=f[j+1]=f[j+2]=0,j=g+((j=h+C)h;h++)j=l<<2,f[j+3]=u=q*M>>>N,u>0?(u=255/u,f[j]=(n*M>>>N)*u,f[j+1]=(o*M>>>N)*u,f[j+2]=(p*M>>>N)*u):f[j]=f[j+1]=f[j+2]=0,j=g+((j=h+C)d;d+=4)b[d+3]=c[d]||0;return!0},b._prepAlphaMap=function(){if(!this.alphaMap)return!1;if(this.alphaMap==this._alphaMap&&this._mapData)return!0;this._mapData=null;var a,b=this._alphaMap=this.alphaMap,c=b;b instanceof HTMLCanvasElement?a=c.getContext("2d"):(c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"),c.width=b.width,c.height=b.height,a=c.getContext("2d"),a.drawImage(b,0,0));try{var d=a.getImageData(0,0,b.width,b.height)}catch(e){return!1}return this._mapData=d.data,!0},createjs.AlphaMapFilter=createjs.promote(a,"Filter")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.Filter_constructor(),this.mask=a,this.usesContext=!0,this.FRAG_SHADER_BODY="uniform sampler2D uAlphaSampler;void main(void) {vec4 color = texture2D(uSampler, vRenderCoord);vec4 alphaMap = texture2D(uAlphaSampler, vTextureCoord);gl_FragColor = vec4(color.rgb, color.a * alphaMap.a);}"}var b=createjs.extend(a,createjs.Filter);b.shaderParamSetup=function(a,b,c){this._mapTexture||(this._mapTexture=a.createTexture()),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,this._mapTexture),b.setTextureParams(a),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,this.mask),a.uniform1i(a.getUniformLocation(c,"uAlphaSampler"),1)},b.applyFilter=function(a,b,c,d,e,f,g,h){return this.mask?(f=f||a,null==g&&(g=b),null==h&&(h=c),f.save(),a!=f?!1:(f.globalCompositeOperation="destination-in",f.drawImage(this.mask,g,h),f.restore(),!0)):!0},b.clone=function(){return new a(this.mask)},b.toString=function(){return"[AlphaMaskFilter]"},createjs.AlphaMaskFilter=createjs.promote(a,"Filter")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f,g,h){this.Filter_constructor(),this.redMultiplier=null!=a?a:1,this.greenMultiplier=null!=b?b:1,this.blueMultiplier=null!=c?c:1,this.alphaMultiplier=null!=d?d:1,this.redOffset=e||0,this.greenOffset=f||0,this.blueOffset=g||0,this.alphaOffset=h||0,this.FRAG_SHADER_BODY="uniform vec4 uColorMultiplier;uniform vec4 uColorOffset;void main(void) {vec4 color = texture2D(uSampler, vRenderCoord);gl_FragColor = (color * uColorMultiplier) + uColorOffset;}"}var b=createjs.extend(a,createjs.Filter);b.shaderParamSetup=function(a,b,c){a.uniform4f(a.getUniformLocation(c,"uColorMultiplier"),this.redMultiplier,this.greenMultiplier,this.blueMultiplier,this.alphaMultiplier),a.uniform4f(a.getUniformLocation(c,"uColorOffset"),this.redOffset/255,this.greenOffset/255,this.blueOffset/255,this.alphaOffset/255)},b.toString=function(){return"[ColorFilter]"},b.clone=function(){return new a(this.redMultiplier,this.greenMultiplier,this.blueMultiplier,this.alphaMultiplier,this.redOffset,this.greenOffset,this.blueOffset,this.alphaOffset)},b._applyFilter=function(a){for(var b=a.data,c=b.length,d=0;c>d;d+=4)b[d]=b[d]*this.redMultiplier+this.redOffset,b[d+1]=b[d+1]*this.greenMultiplier+this.greenOffset,b[d+2]=b[d+2]*this.blueMultiplier+this.blueOffset,b[d+3]=b[d+3]*this.alphaMultiplier+this.alphaOffset;return!0},createjs.ColorFilter=createjs.promote(a,"Filter")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d){this.setColor(a,b,c,d)}var b=a.prototype;a.DELTA_INDEX=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10],a.IDENTITY_MATRIX=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1],a.LENGTH=a.IDENTITY_MATRIX.length,b.setColor=function(a,b,c,d){return this.reset().adjustColor(a,b,c,d)},b.reset=function(){return this.copy(a.IDENTITY_MATRIX)},b.adjustColor=function(a,b,c,d){return this.adjustHue(d),this.adjustContrast(b),this.adjustBrightness(a),this.adjustSaturation(c)},b.adjustBrightness=function(a){return 0==a||isNaN(a)?this:(a=this._cleanValue(a,255),this._multiplyMatrix([1,0,0,0,a,0,1,0,0,a,0,0,1,0,a,0,0,0,1,0,0,0,0,0,1]),this)},b.adjustContrast=function(b){if(0==b||isNaN(b))return this;b=this._cleanValue(b,100);var c;return 0>b?c=127+b/100*127:(c=b%1,c=0==c?a.DELTA_INDEX[b]:a.DELTA_INDEX[b<<0]*(1-c)+a.DELTA_INDEX[(b<<0)+1]*c,c=127*c+127),this._multiplyMatrix([c/127,0,0,0,.5*(127-c),0,c/127,0,0,.5*(127-c),0,0,c/127,0,.5*(127-c),0,0,0,1,0,0,0,0,0,1]),this},b.adjustSaturation=function(a){if(0==a||isNaN(a))return this;a=this._cleanValue(a,100);var b=1+(a>0?3*a/100:a/100),c=.3086,d=.6094,e=.082;return this._multiplyMatrix([c*(1-b)+b,d*(1-b),e*(1-b),0,0,c*(1-b),d*(1-b)+b,e*(1-b),0,0,c*(1-b),d*(1-b),e*(1-b)+b,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.adjustHue=function(a){if(0==a||isNaN(a))return this;a=this._cleanValue(a,180)/180*Math.PI;var b=Math.cos(a),c=Math.sin(a),d=.213,e=.715,f=.072;return this._multiplyMatrix([d+b*(1-d)+c*-d,e+b*-e+c*-e,f+b*-f+c*(1-f),0,0,d+b*-d+.143*c,e+b*(1-e)+.14*c,f+b*-f+c*-.283,0,0,d+b*-d+c*-(1-d),e+b*-e+c*e,f+b*(1-f)+c*f,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.concat=function(b){return b=this._fixMatrix(b),b.length!=a.LENGTH?this:(this._multiplyMatrix(b),this)},b.clone=function(){return(new a).copy(this)},b.toArray=function(){for(var b=[],c=0,d=a.LENGTH;d>c;c++)b[c]=this[c];return b},b.copy=function(b){for(var c=a.LENGTH,d=0;c>d;d++)this[d]=b[d];return this},b.toString=function(){return"[ColorMatrix]"},b._multiplyMatrix=function(a){var b,c,d,e=[];for(b=0;5>b;b++){for(c=0;5>c;c++)e[c]=this[c+5*b];for(c=0;5>c;c++){var f=0;for(d=0;5>d;d++)f+=a[c+5*d]*e[d];this[c+5*b]=f}}},b._cleanValue=function(a,b){return Math.min(b,Math.max(-b,a))},b._fixMatrix=function(b){return b instanceof a&&(b=b.toArray()),b.lengtha.LENGTH&&(b=b.slice(0,a.LENGTH)),b},createjs.ColorMatrix=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.Filter_constructor(),this.matrix=a,this.FRAG_SHADER_BODY="uniform mat4 uColorMatrix;uniform vec4 uColorMatrixOffset;void main(void) {vec4 color = texture2D(uSampler, vRenderCoord);mat4 m = uColorMatrix;vec4 newColor = vec4(0,0,0,0);newColor.r = color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3];newColor.g = color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3];newColor.b = color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3];newColor.a = color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3];gl_FragColor = newColor + uColorMatrixOffset;}"}var b=createjs.extend(a,createjs.Filter);b.shaderParamSetup=function(a,b,c){var d=this.matrix,e=new Float32Array([d[0],d[1],d[2],d[3],d[5],d[6],d[7],d[8],d[10],d[11],d[12],d[13],d[15],d[16],d[17],d[18]]);a.uniformMatrix4fv(a.getUniformLocation(c,"uColorMatrix"),!1,e),a.uniform4f(a.getUniformLocation(c,"uColorMatrixOffset"),d[4]/255,d[9]/255,d[14]/255,d[19]/255)},b.toString=function(){return"[ColorMatrixFilter]"},b.clone=function(){return new a(this.matrix)},b._applyFilter=function(a){for(var b,c,d,e,f=a.data,g=f.length,h=this.matrix,i=h[0],j=h[1],k=h[2],l=h[3],m=h[4],n=h[5],o=h[6],p=h[7],q=h[8],r=h[9],s=h[10],t=h[11],u=h[12],v=h[13],w=h[14],x=h[15],y=h[16],z=h[17],A=h[18],B=h[19],C=0;g>C;C+=4)b=f[C],c=f[C+1],d=f[C+2],e=f[C+3],f[C]=b*i+c*j+d*k+e*l+m,f[C+1]=b*n+c*o+d*p+e*q+r,f[C+2]=b*s+c*t+d*u+e*v+w,f[C+3]=b*x+c*y+d*z+e*A+B;return!0},createjs.ColorMatrixFilter=createjs.promote(a,"Filter")}(),this.createjs=this.createjs||{},function(){"use strict";function a(){throw"Touch cannot be instantiated"}a.isSupported=function(){return!!("ontouchstart"in window||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)},a.enable=function(b,c,d){return b&&b.canvas&&a.isSupported()?b.__touch?!0:(b.__touch={pointers:{},multitouch:!c,preventDefault:!d,count:0},"ontouchstart"in window?a._IOS_enable(b):(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&a._IE_enable(b),!0):!1},a.disable=function(b){b&&("ontouchstart"in window?a._IOS_disable(b):(window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&a._IE_disable(b),delete b.__touch)},a._IOS_enable=function(b){var c=b.canvas,d=b.__touch.f=function(c){a._IOS_handleEvent(b,c)};c.addEventListener("touchstart",d,!1),c.addEventListener("touchmove",d,!1),c.addEventListener("touchend",d,!1),c.addEventListener("touchcancel",d,!1)},a._IOS_disable=function(a){var b=a.canvas;if(b){var c=a.__touch.f;b.removeEventListener("touchstart",c,!1),b.removeEventListener("touchmove",c,!1),b.removeEventListener("touchend",c,!1),b.removeEventListener("touchcancel",c,!1)}},a._IOS_handleEvent=function(a,b){if(a){a.__touch.preventDefault&&b.preventDefault&&b.preventDefault();for(var c=b.changedTouches,d=b.type,e=0,f=c.length;f>e;e++){var g=c[e],h=g.identifier;g.target==a.canvas&&("touchstart"==d?this._handleStart(a,h,b,g.pageX,g.pageY):"touchmove"==d?this._handleMove(a,h,b,g.pageX,g.pageY):("touchend"==d||"touchcancel"==d)&&this._handleEnd(a,h,b))}}},a._IE_enable=function(b){var c=b.canvas,d=b.__touch.f=function(c){a._IE_handleEvent(b,c)};void 0===window.navigator.pointerEnabled?(c.addEventListener("MSPointerDown",d,!1),window.addEventListener("MSPointerMove",d,!1),window.addEventListener("MSPointerUp",d,!1),window.addEventListener("MSPointerCancel",d,!1),b.__touch.preventDefault&&(c.style.msTouchAction="none")):(c.addEventListener("pointerdown",d,!1),window.addEventListener("pointermove",d,!1),window.addEventListener("pointerup",d,!1),window.addEventListener("pointercancel",d,!1),b.__touch.preventDefault&&(c.style.touchAction="none")),b.__touch.activeIDs={}},a._IE_disable=function(a){var b=a.__touch.f;void 0===window.navigator.pointerEnabled?(window.removeEventListener("MSPointerMove",b,!1),window.removeEventListener("MSPointerUp",b,!1),window.removeEventListener("MSPointerCancel",b,!1),a.canvas&&a.canvas.removeEventListener("MSPointerDown",b,!1)):(window.removeEventListener("pointermove",b,!1),window.removeEventListener("pointerup",b,!1),window.removeEventListener("pointercancel",b,!1),a.canvas&&a.canvas.removeEventListener("pointerdown",b,!1))},a._IE_handleEvent=function(a,b){if(a){a.__touch.preventDefault&&b.preventDefault&&b.preventDefault();var c=b.type,d=b.pointerId,e=a.__touch.activeIDs;if("MSPointerDown"==c||"pointerdown"==c){if(b.srcElement!=a.canvas)return;e[d]=!0,this._handleStart(a,d,b,b.pageX,b.pageY)}else e[d]&&("MSPointerMove"==c||"pointermove"==c?this._handleMove(a,d,b,b.pageX,b.pageY):("MSPointerUp"==c||"MSPointerCancel"==c||"pointerup"==c||"pointercancel"==c)&&(delete e[d],this._handleEnd(a,d,b)))}},a._handleStart=function(a,b,c,d,e){var f=a.__touch;if(f.multitouch||!f.count){var g=f.pointers;g[b]||(g[b]=!0,f.count++,a._handlePointerDown(b,c,d,e))}},a._handleMove=function(a,b,c,d,e){a.__touch.pointers[b]&&a._handlePointerMove(b,c,d,e)},a._handleEnd=function(a,b,c){var d=a.__touch,e=d.pointers;e[b]&&(d.count--,a._handlePointerUp(b,c,!0),delete e[b])},createjs.Touch=a}(),this.createjs=this.createjs||{},function(){"use strict";var a=createjs.EaselJS=createjs.EaselJS||{};a.version="1.0.0",a.buildDate="Thu, 14 Sep 2017 19:47:53 GMT"}(); \ No newline at end of file +this.createjs=this.createjs||{},createjs.extend=function(a,b){"use strict";function c(){this.constructor=a}return c.prototype=b.prototype,a.prototype=new c},this.createjs=this.createjs||{},createjs.promote=function(a,b){"use strict";var c=a.prototype,d=Object.getPrototypeOf&&Object.getPrototypeOf(c)||c.__proto__;if(d){c[(b+="_")+"constructor"]=d.constructor;for(var e in d)c.hasOwnProperty(e)&&"function"==typeof d[e]&&(c[b+e]=d[e])}return a},this.createjs=this.createjs||{},createjs.indexOf=function(a,b){"use strict";for(var c=0,d=a.length;c=0&&!a.propagationStopped;g--)f[g]._dispatchEvent(a,1+(0==g));for(g=1;g=.97*(a._interval-1)&&a._tick()},a._handleRAF=function(){a._timerId=null,a._setupTick(),a._tick()},a._handleTimeout=function(){a._timerId=null,a._setupTick(),a._tick()},a._setupTick=function(){if(null==a._timerId){var b=a.timingMode;if(b==a.RAF_SYNCHED||b==a.RAF){var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(c)return a._timerId=c(b==a.RAF?a._handleRAF:a._handleSynch),void(a._raf=!0)}a._raf=!1,a._timerId=setTimeout(a._handleTimeout,a._interval)}},a._tick=function(){var b=a.paused,c=a._getTime(),d=c-a._lastTime;if(a._lastTime=c,a._ticks++,b&&(a._pausedTicks++,a._pausedTime+=d),a.hasEventListener("tick")){var e=new createjs.Event("tick"),f=a.maxDelta;e.delta=f&&d>f?f:d,e.paused=b,e.time=c,e.runTime=c-a._pausedTime,a.dispatchEvent(e)}for(a._tickTimes.unshift(a._getTime()-c);a._tickTimes.length>100;)a._tickTimes.pop();for(a._times.unshift(c);a._times.length>100;)a._times.pop()};var b=window,c=b.performance.now||b.performance.mozNow||b.performance.msNow||b.performance.oNow||b.performance.webkitNow;a._getTime=function(){return(c&&c.call(b.performance)||(new Date).getTime())-a._startTime},createjs.Ticker=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.readyState=a.readyState,this._video=a,this._canvas=null,this._lastTime=-1,this.readyState<2&&a.addEventListener("canplaythrough",this._videoReady.bind(this))}var b=a.prototype;b.getImage=function(){if(!(this.readyState<2)){var a=this._canvas,b=this._video;if(a||(a=this._canvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"),a.width=b.videoWidth,a.height=b.videoHeight),b.readyState>=2&&b.currentTime!==this._lastTime){var c=a.getContext("2d");c.clearRect(0,0,a.width,a.height),c.drawImage(b,0,0,a.width,a.height),this._lastTime=b.currentTime}return a}},b._videoReady=function(){this.readyState=2},createjs.VideoBuffer=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f,g,h,i,j,k){this.Event_constructor(a,b,c),this.stageX=d,this.stageY=e,this.rawX=null==i?d:i,this.rawY=null==j?e:j,this.nativeEvent=f,this.pointerID=g,this.primary=!!h,this.relatedTarget=k}var b=createjs.extend(a,createjs.Event);b._get_localX=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).x},b._get_localY=function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).y},b._get_isTouch=function(){return-1!==this.pointerID};try{Object.defineProperties(b,{localX:{get:b._get_localX},localY:{get:b._get_localY},isTouch:{get:b._get_isTouch}})}catch(a){}b.clone=function(){return new a(this.type,this.bubbles,this.cancelable,this.stageX,this.stageY,this.nativeEvent,this.pointerID,this.primary,this.rawX,this.rawY)},b.toString=function(){return"[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"},createjs.MouseEvent=createjs.promote(a,"Event")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e,f){this.setValues(a,b,c,d,e,f)}var b=a.prototype;a.DEG_TO_RAD=Math.PI/180,a.identity=null,b.setValues=function(a,b,c,d,e,f){return this.a=null==a?1:a,this.b=b||0,this.c=c||0,this.d=null==d?1:d,this.tx=e||0,this.ty=f||0,this},b.append=function(a,b,c,d,e,f){var g=this.a,h=this.b,i=this.c,j=this.d;return 1==a&&0==b&&0==c&&1==d||(this.a=g*a+i*b,this.b=h*a+j*b,this.c=g*c+i*d,this.d=h*c+j*d),this.tx=g*e+i*f+this.tx,this.ty=h*e+j*f+this.ty,this},b.prepend=function(a,b,c,d,e,f){var g=this.a,h=this.c,i=this.tx;return this.a=a*g+c*this.b,this.b=b*g+d*this.b,this.c=a*h+c*this.d,this.d=b*h+d*this.d,this.tx=a*i+c*this.ty+e,this.ty=b*i+d*this.ty+f,this},b.appendMatrix=function(a){return this.append(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.prependMatrix=function(a){return this.prepend(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.appendTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.append(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c),this.append(l*d,m*d,-m*e,l*e,0,0)):this.append(l*d,m*d,-m*e,l*e,b,c),(i||j)&&(this.tx-=i*this.a+j*this.c,this.ty-=i*this.b+j*this.d),this},b.prependTransform=function(b,c,d,e,f,g,h,i,j){if(f%360)var k=f*a.DEG_TO_RAD,l=Math.cos(k),m=Math.sin(k);else l=1,m=0;return(i||j)&&(this.tx-=i,this.ty-=j),g||h?(g*=a.DEG_TO_RAD,h*=a.DEG_TO_RAD,this.prepend(l*d,m*d,-m*e,l*e,0,0),this.prepend(Math.cos(h),Math.sin(h),-Math.sin(g),Math.cos(g),b,c)):this.prepend(l*d,m*d,-m*e,l*e,b,c),this},b.rotate=function(b){b*=a.DEG_TO_RAD;var c=Math.cos(b),d=Math.sin(b),e=this.a,f=this.b;return this.a=e*c+this.c*d,this.b=f*c+this.d*d,this.c=-e*d+this.c*c,this.d=-f*d+this.d*c,this},b.skew=function(b,c){return b*=a.DEG_TO_RAD,c*=a.DEG_TO_RAD,this.append(Math.cos(c),Math.sin(c),-Math.sin(b),Math.cos(b),0,0),this},b.scale=function(a,b){return this.a*=a,this.b*=a,this.c*=b,this.d*=b,this},b.translate=function(a,b){return this.tx+=this.a*a+this.c*b,this.ty+=this.b*a+this.d*b,this},b.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},b.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.isIdentity=function(){return 0===this.tx&&0===this.ty&&1===this.a&&0===this.b&&0===this.c&&1===this.d},b.equals=function(a){return this.tx===a.tx&&this.ty===a.ty&&this.a===a.a&&this.b===a.b&&this.c===a.c&&this.d===a.d},b.transformPoint=function(a,b,c){return c=c||{},c.x=a*this.a+b*this.c+this.tx,c.y=a*this.b+b*this.d+this.ty,c},b.decompose=function(b){null==b&&(b={}),b.x=this.tx,b.y=this.ty,b.scaleX=Math.sqrt(this.a*this.a+this.b*this.b),b.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var c=Math.atan2(-this.c,this.d),d=Math.atan2(this.b,this.a);return Math.abs(1-c/d)<1e-5?(b.rotation=d/a.DEG_TO_RAD,this.a<0&&this.d>=0&&(b.rotation+=b.rotation<=0?180:-180),b.skewX=b.skewY=0):(b.skewX=c/a.DEG_TO_RAD,b.skewY=d/a.DEG_TO_RAD),b},b.copy=function(a){return this.setValues(a.a,a.b,a.c,a.d,a.tx,a.ty)},b.clone=function(){return new a(this.a,this.b,this.c,this.d,this.tx,this.ty)},b.toString=function(){return"[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"},a.identity=new a,createjs.Matrix2D=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d,e){this.setValues(a,b,c,d,e)}var b=a.prototype;b.setValues=function(a,b,c,d,e){return this.visible=null==a||!!a,this.alpha=null==b?1:b,this.shadow=c,this.compositeOperation=d,this.matrix=e||this.matrix&&this.matrix.identity()||new createjs.Matrix2D,this},b.append=function(a,b,c,d,e){return this.alpha*=b,this.shadow=c||this.shadow,this.compositeOperation=d||this.compositeOperation,this.visible=this.visible&&a,e&&this.matrix.appendMatrix(e),this},b.prepend=function(a,b,c,d,e){return this.alpha*=b,this.shadow=this.shadow||c,this.compositeOperation=this.compositeOperation||d,this.visible=this.visible&&a,e&&this.matrix.prependMatrix(e),this},b.identity=function(){return this.visible=!0,this.alpha=1,this.shadow=this.compositeOperation=null,this.matrix.identity(),this},b.clone=function(){return new a(this.alpha,this.shadow,this.compositeOperation,this.visible,this.matrix.clone())},createjs.DisplayProps=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.setValues(a,b)}var b=a.prototype;b.setValues=function(a,b){return this.x=a||0,this.y=b||0,this},b.offset=function(a,b){return this.x+=a,this.y+=b,this},a.polar=function(b,c,d){return d=d||new a,d.x=b*Math.cos(c),d.y=b*Math.sin(c),d},a.interpolate=function(b,c,d,e){return e=e||new a,e.x=c.x+d*(b.x-c.x),e.y=c.y+d*(b.y-c.y),e},b.copy=function(a){return this.x=a.x,this.y=a.y,this},b.clone=function(){return new a(this.x,this.y)},b.toString=function(){return"[Point (x="+this.x+" y="+this.y+")]"},createjs.Point=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c,d){this.setValues(a,b,c,d)}var b=a.prototype;b.setValues=function(a,b,c,d){return this.x=a||0,this.y=b||0,this.width=c||0,this.height=d||0,this},b.extend=function(a,b,c,d){return c=c||0,d=d||0,a+c>this.x+this.width&&(this.width=a+c-this.x),b+d>this.y+this.height&&(this.height=b+d-this.y),a=this.x&&a+c<=this.x+this.width&&b>=this.y&&b+d<=this.y+this.height},b.union=function(a){return this.clone().extend(a.x,a.y,a.width,a.height)},b.intersection=function(b){var c=b.x,d=b.y,e=c+b.width,f=d+b.height;return this.x>c&&(c=this.x),this.y>d&&(d=this.y),this.x+this.width0)for(e=this._images=[],b=0;b=a)break a;b++,this._frames.push({image:i,rect:new createjs.Rectangle(m,l,c,d),regX:this._regX,regY:this._regY}),m+=c+e}l+=d+e}this._numFrames=b}},createjs.SpriteSheet=createjs.promote(a,"EventDispatcher")}(),this.createjs=this.createjs||{},function(){"use strict";function a(){this.command=null,this._stroke=null,this._strokeStyle=null,this._oldStrokeStyle=null,this._strokeDash=null,this._oldStrokeDash=null,this._strokeIgnoreScale=!1,this._fill=null,this._instructions=[],this._commitIndex=0,this._activeInstructions=[],this._dirty=!1,this._storeIndex=0,this.clear()}var b=a.prototype,c=a;a.getRGB=function(a,b,c,d){return null!=a&&null==c&&(d=b,c=255&a,b=a>>8&255,a=a>>16&255),null==d?"rgb("+a+","+b+","+c+")":"rgba("+a+","+b+","+c+","+d+")"},a.getHSL=function(a,b,c,d){return null==d?"hsl("+a%360+","+b+"%,"+c+"%)":"hsla("+a%360+","+b+"%,"+c+"%,"+d+")"},a.BASE_64={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,a:26,b:27,c:28,d:29,e:30,f:31,g:32,h:33,i:34,j:35,k:36,l:37,m:38,n:39,o:40,p:41,q:42,r:43,s:44,t:45,u:46,v:47,w:48,x:49,y:50,z:51,0:52,1:53,2:54,3:55,4:56,5:57,6:58,7:59,8:60,9:61,"+":62,"/":63},a.STROKE_CAPS_MAP=["butt","round","square"],a.STROKE_JOINTS_MAP=["miter","round","bevel"];var d=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");d.getContext&&(a._ctx=d.getContext("2d"),d.width=d.height=1),b._getInstructions=function(){return this._updateInstructions(),this._instructions},b.getInstructions=createjs.deprecate(b._getInstructions,"Graphics.getInstructions");try{Object.defineProperties(b,{instructions:{get:b._getInstructions}})}catch(a){}b.isEmpty=function(){return!(this._instructions.length||this._activeInstructions.length)},b.draw=function(a,b){this._updateInstructions();for(var c=this._instructions,d=this._storeIndex,e=c.length;d>3,n=c[m];if(!n||3&l)throw"bad path data (@"+e+"): "+k;var o=d[m];m||(h=i=0),g.length=0,e++;for(var p=2+(l>>2&1),q=0;q>5?-1:1;r=(31&r)<<6|j[b.charAt(e+1)],3==p&&(r=r<<6|j[b.charAt(e+2)]),r=s*r/10,q%2?h=r+=h:i=r+=i,g[q]=r,e+=p}n.apply(this,g)}return this},b.store=function(){return this._updateInstructions(!0),this._storeIndex=this._instructions.length,this},b.unstore=function(){return this._storeIndex=0,this},b.clone=function(){var b=new a;return b.command=this.command,b._stroke=this._stroke,b._strokeStyle=this._strokeStyle,b._strokeDash=this._strokeDash,b._strokeIgnoreScale=this._strokeIgnoreScale,b._fill=this._fill,b._instructions=this._instructions.slice(),b._commitIndex=this._commitIndex,b._activeInstructions=this._activeInstructions.slice(),b._dirty=this._dirty,b._storeIndex=this._storeIndex,b},b.toString=function(){return"[Graphics]"},b.mt=b.moveTo,b.lt=b.lineTo,b.at=b.arcTo,b.bt=b.bezierCurveTo,b.qt=b.quadraticCurveTo,b.a=b.arc,b.r=b.rect,b.cp=b.closePath,b.c=b.clear,b.f=b.beginFill,b.lf=b.beginLinearGradientFill,b.rf=b.beginRadialGradientFill,b.bf=b.beginBitmapFill,b.ef=b.endFill,b.ss=b.setStrokeStyle,b.sd=b.setStrokeDash,b.s=b.beginStroke,b.ls=b.beginLinearGradientStroke,b.rs=b.beginRadialGradientStroke,b.bs=b.beginBitmapStroke,b.es=b.endStroke,b.dr=b.drawRect,b.rr=b.drawRoundRect,b.rc=b.drawRoundRectComplex,b.dc=b.drawCircle,b.de=b.drawEllipse,b.dp=b.drawPolyStar,b.pg=b.drawPolygon,b.p=b.decodePath,b._updateInstructions=function(b){var c=this._instructions,d=this._activeInstructions,e=this._commitIndex;if(this._dirty&&d.length){c.length=e,c.push(a.beginCmd);var f=d.length,g=c.length;c.length=g+f;for(var h=0;h=2){(this.style=a._ctx.createPattern(b,c||"")).props={image:b,repetition:c,type:"bitmap"}}return this},b.path=!1,b=(c.Stroke=function(a,b){this.style=a,this.ignoreScale=b}).prototype,b.exec=function(a){this.style&&(a.strokeStyle=this.style,this.ignoreScale&&(a.save(),a.setTransform(1,0,0,1,0,0)),a.stroke(),this.ignoreScale&&a.restore())},b.linearGradient=c.Fill.prototype.linearGradient,b.radialGradient=c.Fill.prototype.radialGradient,b.bitmap=c.Fill.prototype.bitmap,b.path=!1,b=(c.StrokeStyle=function(a,b,c,d,e){this.width=a,this.caps=b,this.joints=c,this.miterLimit=d,this.ignoreScale=e}).prototype,b.exec=function(b){b.lineWidth=null==this.width?"1":this.width,b.lineCap=null==this.caps?"butt":isNaN(this.caps)?this.caps:a.STROKE_CAPS_MAP[this.caps],b.lineJoin=null==this.joints?"miter":isNaN(this.joints)?this.joints:a.STROKE_JOINTS_MAP[this.joints],b.miterLimit=null==this.miterLimit?"10":this.miterLimit,b.ignoreScale=null!=this.ignoreScale&&this.ignoreScale},b.path=!1,(c.StrokeDash=function(a,b){this.segments=a,this.offset=b||0}).prototype.exec=function(a){a.setLineDash&&(a.setLineDash(this.segments||c.StrokeDash.EMPTY_SEGMENTS),a.lineDashOffset=this.offset||0)},c.StrokeDash.EMPTY_SEGMENTS=[],(c.RoundRect=function(a,b,c,d,e,f,g,h){this.x=a,this.y=b,this.w=c,this.h=d,this.radiusTL=e,this.radiusTR=f,this.radiusBR=g,this.radiusBL=h}).prototype.exec=function(a){ +var b=(this.wb&&(k=b),l<0&&(l*=d=-1),l>b&&(l=b),m<0&&(m*=e=-1),m>b&&(m=b),n<0&&(n*=f=-1),n>b&&(n=b),a.moveTo(g+i-l,h),a.arcTo(g+i+l*d,h-l*d,g+i,h+l,l),a.lineTo(g+i,h+j-m),a.arcTo(g+i+m*e,h+j+m*e,g+i-m,h+j,m),a.lineTo(g+n,h+j),a.arcTo(g-n*f,h+j+n*f,g,h+j-n,n),a.lineTo(g,h+k),a.arcTo(g-k*c,h-k*c,g+k,h,k),a.closePath()},(c.Circle=function(a,b,c){this.x=a,this.y=b,this.radius=c}).prototype.exec=function(a){a.arc(this.x,this.y,this.radius,0,2*Math.PI)},(c.Ellipse=function(a,b,c,d){this.x=a,this.y=b,this.w=c,this.h=d}).prototype.exec=function(a){var b=this.x,c=this.y,d=this.w,e=this.h,f=.5522848,g=d/2*f,h=e/2*f,i=b+d,j=c+e,k=b+d/2,l=c+e/2;a.moveTo(b,l),a.bezierCurveTo(b,l-h,k-g,c,k,c),a.bezierCurveTo(k+g,c,i,l-h,i,l),a.bezierCurveTo(i,l+h,k+g,j,k,j),a.bezierCurveTo(k-g,j,b,l+h,b,l)},(c.PolyStar=function(a,b,c,d,e,f){this.x=a,this.y=b,this.radius=c,this.sides=d,this.pointSize=e,this.angle=f}).prototype.exec=function(a){var b=this.x,c=this.y,d=this.radius,e=(this.angle||0)/180*Math.PI,f=this.sides,g=1-(this.pointSize||0),h=Math.PI/f;a.moveTo(b+Math.cos(e)*d,c+Math.sin(e)*d);for(var i=0;i0&&0!=this.scaleX&&0!=this.scaleY)},b.draw=function(a,b){var c=this.bitmapCache;return!(!c||b)&&c.draw(a)},b.updateContext=function(b){var c=this,d=c.mask,e=c._props.matrix;d&&d.graphics&&!d.graphics.isEmpty()&&(d.getMatrix(e),b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),d.graphics.drawAsPath(b),b.clip(),e.invert(),b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty)),this.getMatrix(e);var f=e.tx,g=e.ty;a._snapToPixelEnabled&&c.snapToPixel&&(f=f+(f<0?-.5:.5)|0,g=g+(g<0?-.5:.5)|0),b.transform(e.a,e.b,e.c,e.d,f,g),b.globalAlpha*=c.alpha,c.compositeOperation&&(b.globalCompositeOperation=c.compositeOperation),c.shadow&&this._applyShadow(b,c.shadow)},b.cache=function(a,b,c,d,e,f){this.bitmapCache?this.bitmapCache._autoGenerated=!1:this.bitmapCache=new createjs.BitmapCache,this.bitmapCache.define(this,a,b,c,d,e,f)},b.updateCache=function(a){if(!this.bitmapCache)throw"cache() must be called before updateCache()";this.bitmapCache.update(a)},b.uncache=function(){this.bitmapCache&&(this.bitmapCache.release(),this.bitmapCache=void 0)},b.getCacheDataURL=function(a,b){return this.bitmapCache?this.bitmapCache.getCacheDataURL(a,b):null},b.localToGlobal=function(a,b,c){return this.getConcatenatedMatrix(this._props.matrix).transformPoint(a,b,c||new createjs.Point)},b.globalToLocal=function(a,b,c){return this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(a,b,c||new createjs.Point)},b.localToLocal=function(a,b,c,d){return d=this.localToGlobal(a,b,d),c.globalToLocal(d.x,d.y,d)},b.setTransform=function(a,b,c,d,e,f,g,h,i){return this.x=a||0,this.y=b||0,this.scaleX=null==c?1:c,this.scaleY=null==d?1:d,this.rotation=e||0,this.skewX=f||0,this.skewY=g||0,this.regX=h||0,this.regY=i||0,this},b.getMatrix=function(a){var b=this,c=a||new createjs.Matrix2D;return b.transformMatrix?c.copy(b.transformMatrix):c.identity()&&c.appendTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY)},b.getConcatenatedMatrix=function(a){for(var b=this,c=this.getMatrix(a);b=b.parent;)c.prependMatrix(b.getMatrix(b._props.matrix));return c},b.getConcatenatedDisplayProps=function(a){a=a?a.identity():new createjs.DisplayProps;var b=this,c=b.getMatrix(a.matrix);do{a.prepend(b.visible,b.alpha,b.shadow,b.compositeOperation),b!=this&&c.prependMatrix(b.getMatrix(b._props.matrix))}while(b=b.parent);return a},b.hitTest=function(b,c){var d=a._hitTestContext;d.setTransform(1,0,0,1,-b,-c),this.draw(d,!(this.bitmapCache&&!(this.bitmapCache._cacheCanvas instanceof WebGLTexture)));var e=this._testHit(d);return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,2,2),e},b.set=function(a){for(var b in a)this[b]=a[b];return this},b.getBounds=function(){if(this._bounds)return this._rectangle.copy(this._bounds);var a=this.bitmapCache;return a&&this.cacheCanvas?a.getBounds():null},b.getTransformedBounds=function(){return this._getBounds()},b.setBounds=function(a,b,c,d){if(null==a)return void(this._bounds=a);this._bounds=(this._bounds||new createjs.Rectangle).setValues(a,b,c,d)},b.clone=function(){return this._cloneProps(new a)},b.toString=function(){return"[DisplayObject (name="+this.name+")]"},b._updateState=null,b._cloneProps=function(a){return a.alpha=this.alpha,a.mouseEnabled=this.mouseEnabled,a.tickEnabled=this.tickEnabled,a.name=this.name,a.regX=this.regX,a.regY=this.regY,a.rotation=this.rotation,a.scaleX=this.scaleX,a.scaleY=this.scaleY,a.shadow=this.shadow,a.skewX=this.skewX,a.skewY=this.skewY,a.visible=this.visible,a.x=this.x,a.y=this.y,a.compositeOperation=this.compositeOperation,a.snapToPixel=this.snapToPixel,a.filters=null==this.filters?null:this.filters.slice(0),a.mask=this.mask,a.hitArea=this.hitArea,a.cursor=this.cursor,a._bounds=this._bounds,a._webGLRenderStyle=this._webGLRenderStyle,a},b._applyShadow=function(a,b){b=b||Shadow.identity,a.shadowColor=b.color,a.shadowOffsetX=b.offsetX,a.shadowOffsetY=b.offsetY,a.shadowBlur=b.blur},b._tick=function(a){var b=this._listeners;b&&b.tick&&(a.target=null,a.propagationStopped=a.immediatePropagationStopped=!1,this.dispatchEvent(a))},b._testHit=function(b){try{var c=b.getImageData(0,0,1,1).data[3]>1}catch(b){if(!a.suppressCrossDomainErrors)throw"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images."}return c},b._getBounds=function(a,b){return this._transformBounds(this.getBounds(),a,b)},b._transformBounds=function(a,b,c){if(!a)return a;var d=a.x,e=a.y,f=a.width,g=a.height,h=this._props.matrix;h=c?h.identity():this.getMatrix(h),(d||e)&&h.appendTransform(0,0,1,1,0,0,0,-d,-e),b&&h.prependMatrix(b);var i=f*h.a,j=f*h.b,k=g*h.c,l=g*h.d,m=h.tx,n=h.ty,o=m,p=m,q=n,r=n;return(d=i+m)p&&(p=d),(d=i+k+m)p&&(p=d),(d=k+m)p&&(p=d),(e=j+n)r&&(r=e),(e=j+l+n)r&&(r=e),(e=l+n)r&&(r=e),a.setValues(o,q,p-o,r-q)},b._hasMouseEventListener=function(){for(var b=a._MOUSE_EVENTS,c=0,d=b.length;c0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;for(var c=this.children.slice(),d=0,e=c.length;d1){for(var c=0;cthis.children.length)return arguments[c-2];if(c>2){for(var e=0;e1){for(var c=!0,d=0;d1){for(var c=[],d=0;d=d)){for(var e=0;e0,1==c),d},b.getObjectUnderPoint=function(a,b,c){var d=this.localToGlobal(a,b);return this._getObjectsUnderPoint(d.x,d.y,null,c>0,1==c)},b.getBounds=function(){return this._getBounds(null,!0)},b.getTransformedBounds=function(){return this._getBounds()},b.clone=function(b){var c=this._cloneProps(new a);return b&&this._cloneChildren(c),c},b.toString=function(){return"[Container (name="+this.name+")]"},b._tick=function(a){if(this.tickChildren)for(var b=this.children.length-1;b>=0;b--){var c=this.children[b];c.tickEnabled&&c._tick&&c._tick(a)}this.DisplayObject__tick(a)},b._cloneChildren=function(a){a.children.length&&a.removeAllChildren();for(var b=a.children,c=0,d=this.children.length;cthis.children.length-1)return!1;var c=this.children[a];return c&&(c.parent=null),this.children.splice(a,1),b||c.dispatchEvent("removed"),!0},b._getObjectsUnderPoint=function(b,c,d,e,f,g){if(!(g=g||0)&&!this._testMask(this,b,c))return null;var h,i=createjs.DisplayObject._hitTestContext;f=f||e&&this._hasMouseEventListener();for(var j=this.children,k=j.length,l=k-1;l>=0;l--){var m=j[l],n=m.hitArea;if(m.visible&&(n||m.isVisible())&&(!e||m.mouseEnabled)&&(n||this._testMask(m,b,c)))if(!n&&m instanceof a){var o=m._getObjectsUnderPoint(b,c,d,e,f,g+1);if(!d&&o)return e&&!this.mouseChildren?this:o}else{if(e&&!f&&!m._hasMouseEventListener())continue;var p=m.getConcatenatedDisplayProps(m._props);if(h=p.matrix,n&&(h.appendMatrix(n.getMatrix(n._props.matrix)),p.alpha=n.alpha),i.globalAlpha=p.alpha,i.setTransform(h.a,h.b,h.c,h.d,h.tx-b,h.ty-c),(n||m).draw(i),!this._testHit(i))continue;if(i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,2,2),!d)return e&&!this.mouseChildren?this:m;d.push(m)}}return null},b._testMask=function(a,b,c){var d=a.mask;if(!d||!d.graphics||d.graphics.isEmpty())return!0;var e=this._props.matrix,f=a.parent;e=f?f.getConcatenatedMatrix(e):e.identity(),e=d.getMatrix(d._props.matrix).prependMatrix(e);var g=createjs.DisplayObject._hitTestContext;return g.setTransform(e.a,e.b,e.c,e.d,e.tx-b,e.ty-c),d.graphics.drawAsPath(g),g.fillStyle="#000",g.fill(),!!this._testHit(g)&&(g.setTransform(1,0,0,1,0,0),g.clearRect(0,0,2,2),!0)},b._getBounds=function(a,b){var c=this.DisplayObject_getBounds();if(c)return this._transformBounds(c,a,b);var d=this._props.matrix;d=b?d.identity():this.getMatrix(d),a&&d.prependMatrix(a);for(var e=this.children.length,f=null,g=0;g=0&&d>=0&&c<=f-1&&d<=g-1)?(h.x=c,h.y=d):this.mouseMoveOutside&&(h.x=c<0?0:c>f-1?f-1:c,h.y=d<0?0:d>g-1?g-1:d),h.posEvtObj=b,h.rawX=c,h.rawY=d,a!==this._primaryPointerID&&-1!==a||(this.mouseX=h.x,this.mouseY=h.y,this.mouseInBounds=h.inBounds)},b._handleMouseUp=function(a){this._handlePointerUp(-1,a,!1)},b._handlePointerUp=function(a,b,c,d){var e=this._nextStage,f=this._getPointerData(a);if(!this._prevStage||void 0!==d){var g=null,h=f.target;d||!h&&!e||(g=this._getObjectsUnderPoint(f.x,f.y,null,!0)),f.down&&(this._dispatchMouseEvent(this,"stagemouseup",!1,a,f,b,g),f.down=!1),g==h&&this._dispatchMouseEvent(h,"click",!0,a,f,b),this._dispatchMouseEvent(h,"pressup",!0,a,f,b),c?(a==this._primaryPointerID&&(this._primaryPointerID=null),delete this._pointerData[a]):f.target=null,e&&e._handlePointerUp(a,b,c,d||g&&this)}},b._handleMouseDown=function(a){this._handlePointerDown(-1,a,a.pageX,a.pageY)},b._handlePointerDown=function(a,b,c,d,e){this.preventSelection&&b.preventDefault(),null!=this._primaryPointerID&&-1!==a||(this._primaryPointerID=a),null!=d&&this._updatePointerPosition(a,b,c,d);var f=null,g=this._nextStage,h=this._getPointerData(a);e||(f=h.target=this._getObjectsUnderPoint(h.x,h.y,null,!0)),h.inBounds&&(this._dispatchMouseEvent(this,"stagemousedown",!1,a,h,b,f),h.down=!0),this._dispatchMouseEvent(f,"mousedown",!0,a,h,b),g&&g._handlePointerDown(a,b,c,d,e||f&&this)},b._testMouseOver=function(a,b,c){if(!this._prevStage||void 0!==b){var d=this._nextStage;if(!this._mouseOverIntervalID)return void(d&&d._testMouseOver(a,b,c));if(this.canvas){var e=this._getPointerData(-1);if(!e||!a&&this.mouseX==this._mouseOverX&&this.mouseY==this._mouseOverY&&this.mouseInBounds)return;var f,g,h,i=e.posEvtObj,j=c||i&&i.target==this.canvas,k=null,l=-1,m="";!b&&(a||this.mouseInBounds&&j)&&(k=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,!0),this._mouseOverX=this.mouseX,this._mouseOverY=this.mouseY);var n=this._mouseOverTarget||[],o=n[n.length-1],p=this._mouseOverTarget=[];for(f=k;f;)p.unshift(f),!m&&f.cursor&&(m=f.cursor),f=f.parent;for(this.canvas.style.cursor=m,!b&&c&&(c.canvas.style.cursor=m),g=0,h=p.length;gl;g--)this._dispatchMouseEvent(n[g],"rollout",!1,-1,e,i,k);for(g=p.length-1;g>l;g--)this._dispatchMouseEvent(p[g],"rollover",!1,-1,e,i,o);o!=k&&this._dispatchMouseEvent(k,"mouseover",!0,-1,e,i,o)}d&&d._testMouseOver(a,b||k&&this,c||j&&this)}},b._handleDoubleClick=function(a,b){var c=null,d=this._nextStage,e=this._getPointerData(-1);b||(c=this._getObjectsUnderPoint(e.x,e.y,null,!0),this._dispatchMouseEvent(c,"dblclick",!0,-1,e,a)),d&&d._handleDoubleClick(a,b||c&&this)},b._dispatchMouseEvent=function(a,b,c,d,e,f,g){if(a&&(c||a.hasEventListener(b))){var h=new createjs.MouseEvent(b,c,!1,e.x,e.y,f,d,d===this._primaryPointerID||-1===d,e.rawX,e.rawY,g);a.dispatchEvent(h)}},createjs.Stage=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(b,c){this.Stage_constructor(b);var d,e,f,g,h,i;if(void 0!==c){if("object"!=typeof c)throw"Invalid options object";d=c.transparent,e=c.antialias,f=c.preserveBuffer,g=c.autoPurge,h=c.directDraw,i=c.batchSize}this.vocalDebug=!1,this.isCacheControlled=!1,this._preserveBuffer=f||!1,this._antialias=e||!1,this._transparent=d||!1,this._autoPurge=void 0,this.autoPurge=g,this._directDraw=void 0===h||!!h,this._viewportWidth=0,this._viewportHeight=0,this._projectionMatrix=null,this._webGLContext=null,this._frameBuffer=null,this._clearColor={r:.5,g:.5,b:.5,a:0},this._maxBatchVertexCount=Math.max(Math.min(Number(i)||a.DEFAULT_MAX_BATCH_SIZE,a.DEFAULT_MAX_BATCH_SIZE),a.DEFAULT_MIN_BATCH_SIZE)*a.INDICIES_PER_CARD,this._activeShader=null,this._mainShader=null,this._attributeConfig={},this._activeConfig=null,this._bufferTextureOutput=null,this._bufferTextureConcat=null,this._bufferTextureTemp=null,this._batchTextureOutput=this,this._batchTextureConcat=null,this._batchTextureTemp=null,this._builtShaders={},this._textureDictionary=[],this._textureIDs={},this._batchTextures=[],this._baseTextures=[],this._gpuTextureCount=8,this._gpuTextureMax=8,this._batchTextureCount=0,this._lastTextureInsert=-1,this._renderMode="",this._immediateRender=!1,this._batchVertexCount=0,this._batchID=0,this._drawID=0,this._renderPerDraw=0,this._slotBlacklist=[],this._lastTrackedCanvas=-1,this._cacheContainer=new createjs.Container,this._initializeWebGL(),void 0!==c&&(void 0!==c.clearColor&&this.setClearColor(c.clearColor),void 0!==c.premultiply&&createjs.deprecate(null,"options.premultiply")())}var b=createjs.extend(a,createjs.Stage);a.buildUVRects=function(a,b,c){if(!a||!a._frames)return null;void 0===b&&(b=-1),void 0===c&&(c=!1);for(var d=-1!==b&&c?b:0,e=-1!==b&&c?b+1:a._frames.length,f=d;f7?Number("0x"+a.slice(7,9))/255:1;else if(0===a.indexOf("rgba(")){var f=a.slice(5,-1).split(",");b=Number(f[0])/255,c=Number(f[1])/255,d=Number(f[2])/255,e=Number(f[3])}}else b=((4278190080&a)>>>24)/255,c=((16711680&a)>>>16)/255,d=((65280&a)>>>8)/255,e=(255&a)/255;return{r:Math.min(Math.max(0,b),1),g:Math.min(Math.max(0,c),1),b:Math.min(Math.max(0,d),1),a:Math.min(Math.max(0,e),1)}},a.VERTEX_PROPERTY_COUNT=6,a.INDICIES_PER_CARD=6,a.DEFAULT_MAX_BATCH_SIZE=10920,a.DEFAULT_MIN_BATCH_SIZE=170,a.WEBGL_MAX_INDEX_NUM=Math.pow(2,16),a.UV_RECT={t:1,l:0,b:0,r:1};try{a.COVER_VERT=new Float32Array([-1,1,1,1,-1,-1,1,1,1,-1,-1,-1]),a.COVER_UV=new Float32Array([0,1,1,1,0,0,1,1,1,0,0,0])}catch(a){}a.REGULAR_VARYING_HEADER="#ifdef GL_FRAGMENT_PRECISION_HIGH \nprecision highp float; \n#else \nprecision mediump float; \n#endif \nvarying vec2 vTextureCoord;varying lowp float indexPicker;varying lowp float alphaValue;",a.REGULAR_VERTEX_HEADER=a.REGULAR_VARYING_HEADER+"attribute vec2 vertexPosition;attribute vec2 uvPosition;attribute lowp float textureIndex;attribute lowp float objectAlpha;uniform mat4 pMatrix;",a.REGULAR_FRAGMENT_HEADER=a.REGULAR_VARYING_HEADER+"uniform sampler2D uSampler[{{count}}];",a.REGULAR_VERTEX_BODY="void main(void) {gl_Position = pMatrix * vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);alphaValue = objectAlpha;indexPicker = textureIndex;vTextureCoord = uvPosition;}",a.REGULAR_FRAGMENT_BODY="void main(void) {vec4 color = vec4(1.0, 0.0, 0.0, 1.0);if (indexPicker <= 0.5) {color = texture2D(uSampler[0], vTextureCoord);{{alternates}}}gl_FragColor = vec4(color.rgb * alphaValue, color.a * alphaValue);}",a.COVER_VARYING_HEADER="#ifdef GL_FRAGMENT_PRECISION_HIGH \nprecision highp float; \n#else \nprecision mediump float; \n#endif \nvarying vec2 vTextureCoord;",a.COVER_VERTEX_HEADER=a.COVER_VARYING_HEADER+"attribute vec2 vertexPosition;attribute vec2 uvPosition;",a.COVER_FRAGMENT_HEADER=a.COVER_VARYING_HEADER+"uniform sampler2D uSampler;",a.COVER_VERTEX_BODY="void main(void) {gl_Position = vec4(vertexPosition.x, vertexPosition.y, 0.0, 1.0);vTextureCoord = uvPosition;}",a.COVER_FRAGMENT_BODY="void main(void) {gl_FragColor = texture2D(uSampler, vTextureCoord);}",a.BLEND_FRAGMENT_SIMPLE="uniform sampler2D uMixSampler;void main(void) {vec4 src = texture2D(uMixSampler, vTextureCoord);vec4 dst = texture2D(uSampler, vTextureCoord);",a.BLEND_FRAGMENT_COMPLEX=a.BLEND_FRAGMENT_SIMPLE+"vec3 srcClr = min(src.rgb/src.a, 1.0);vec3 dstClr = min(dst.rgb/dst.a, 1.0);float totalAlpha = min(1.0 - (1.0-dst.a) * (1.0-src.a), 1.0);float srcFactor = min(max(src.a - dst.a, 0.0) / totalAlpha, 1.0);float dstFactor = min(max(dst.a - src.a, 0.0) / totalAlpha, 1.0);float mixFactor = max(max(1.0 - srcFactor, 0.0) - dstFactor, 0.0);gl_FragColor = vec4((srcFactor * srcClr +dstFactor * dstClr +mixFactor * vec3(",a.BLEND_FRAGMENT_COMPLEX_CAP=")) * totalAlpha, totalAlpha);}",a.BLEND_FRAGMENT_OVERLAY_UTIL="float overlay(float a, float b) {if(a < 0.5) { return 2.0 * a * b; }return 1.0 - 2.0 * (1.0-a) * (1.0-b);}",a.BLEND_FRAGMENT_HSL_UTIL="float getLum(vec3 c) { return 0.299*c.r + 0.589*c.g + 0.109*c.b; }float getSat(vec3 c) { return max(max(c.r, c.g), c.b) - min(min(c.r, c.g), c.b); }vec3 clipHSL(vec3 c) {float lum = getLum(c);float n = min(min(c.r, c.g), c.b);float x = max(max(c.r, c.g), c.b);if(n < 0.0){ c = lum + (((c - lum) * lum) / (lum - n)); }if(x > 1.0){ c = lum + (((c - lum) * (1.0 - lum)) / (x - lum)); }return clamp(c, 0.0, 1.0);}vec3 setLum(vec3 c, float lum) {return clipHSL(c + (lum - getLum(c)));}vec3 setSat(vec3 c, float val) {vec3 result = vec3(0.0);float minVal = min(min(c.r, c.g), c.b);float maxVal = max(max(c.r, c.g), c.b);vec3 minMask = vec3(c.r == minVal, c.g == minVal, c.b == minVal);vec3 maxMask = vec3(c.r == maxVal, c.g == maxVal, c.b == maxVal);vec3 midMask = 1.0 - min(minMask+maxMask, 1.0);float midVal = (c*midMask).r + (c*midMask).g + (c*midMask).b;if(maxVal > minVal) {result = midMask * min( ((midVal - minVal) * val) / (maxVal - minVal), 1.0);result += maxMask * val;}return result;}",a.BLEND_SOURCES={"source-over":{},"source-in":{shader:a.BLEND_FRAGMENT_SIMPLE+"gl_FragColor = vec4(src.rgb * dst.a, src.a * dst.a);}"},"source-in_cheap":{srcRGB:"DST_ALPHA",srcA:"ZERO",dstRGB:"ZERO",dstA:"SRC_ALPHA"},"source-out":{shader:a.BLEND_FRAGMENT_SIMPLE+"gl_FragColor = vec4(src.rgb * (1.0 - dst.a), src.a - dst.a);}"},"source-out_cheap":{eqA:"FUNC_SUBTRACT",srcRGB:"ONE_MINUS_DST_ALPHA",srcA:"ONE",dstRGB:"ZERO",dstA:"SRC_ALPHA"},"source-atop":{srcRGB:"DST_ALPHA",srcA:"ZERO",dstRGB:"ONE_MINUS_SRC_ALPHA",dstA:"ONE"},"destination-over":{srcRGB:"ONE_MINUS_DST_ALPHA",srcA:"ONE_MINUS_DST_ALPHA",dstRGB:"ONE",dstA:"ONE"},"destination-in":{shader:a.BLEND_FRAGMENT_SIMPLE+"gl_FragColor = vec4(dst.rgb * src.a, src.a * dst.a);}"},"destination-in_cheap":{srcRGB:"ZERO",srcA:"DST_ALPHA",dstRGB:"SRC_ALPHA",dstA:"ZERO"},"destination-out":{eqA:"FUNC_REVERSE_SUBTRACT",srcRGB:"ZERO",srcA:"DST_ALPHA",dstRGB:"ONE_MINUS_SRC_ALPHA",dstA:"ONE"},"destination-atop":{shader:a.BLEND_FRAGMENT_SIMPLE+"gl_FragColor = vec4(dst.rgb * src.a + src.rgb * (1.0 - dst.a), src.a);}"},"destination-atop_cheap":{srcRGB:"ONE_MINUS_DST_ALPHA",srcA:"ONE",dstRGB:"SRC_ALPHA",dstA:"ZERO"},copy:{shader:a.BLEND_FRAGMENT_SIMPLE+"gl_FragColor = vec4(src.rgb, src.a);}"},copy_cheap:{dstRGB:"ZERO",dstA:"ZERO"},xor:{shader:a.BLEND_FRAGMENT_SIMPLE+"float omSRC = (1.0 - src.a);float omDST = (1.0 - dst.a);gl_FragColor = vec4(src.rgb * omDST + dst.rgb * omSRC, src.a * omDST + dst.a * omSRC);}"},multiply:{shader:a.BLEND_FRAGMENT_COMPLEX+"srcClr * dstClr"+a.BLEND_FRAGMENT_COMPLEX_CAP},multiply_cheap:{srcRGB:"ONE_MINUS_DST_ALPHA",srcA:"ONE",dstRGB:"SRC_COLOR",dstA:"ONE"},screen:{srcRGB:"ONE",srcA:"ONE",dstRGB:"ONE_MINUS_SRC_COLOR",dstA:"ONE_MINUS_SRC_ALPHA"},lighter:{dstRGB:"ONE",dstA:"ONE"},lighten:{shader:a.BLEND_FRAGMENT_COMPLEX+"max(srcClr, dstClr)"+a.BLEND_FRAGMENT_COMPLEX_CAP},darken:{shader:a.BLEND_FRAGMENT_COMPLEX+"min(srcClr, dstClr)"+a.BLEND_FRAGMENT_COMPLEX_CAP},overlay:{shader:a.BLEND_FRAGMENT_OVERLAY_UTIL+a.BLEND_FRAGMENT_COMPLEX+"overlay(dstClr.r,srcClr.r), overlay(dstClr.g,srcClr.g), overlay(dstClr.b,srcClr.b)"+a.BLEND_FRAGMENT_COMPLEX_CAP},"hard-light":{shader:a.BLEND_FRAGMENT_OVERLAY_UTIL+a.BLEND_FRAGMENT_COMPLEX+"overlay(srcClr.r,dstClr.r), overlay(srcClr.g,dstClr.g), overlay(srcClr.b,dstClr.b)"+a.BLEND_FRAGMENT_COMPLEX_CAP},"soft-light":{shader:"float softcurve(float a) {if(a > 0.25) { return sqrt(a); }return ((16.0 * a - 12.0) * a + 4.0) * a;}float softmix(float a, float b) {if(b <= 0.5) { return a - (1.0 - 2.0*b) * a * (1.0 - a); }return a + (2.0 * b - 1.0) * (softcurve(a) - a);}"+a.BLEND_FRAGMENT_COMPLEX+"softmix(dstClr.r,srcClr.r), softmix(dstClr.g,srcClr.g), softmix(dstClr.b,srcClr.b)"+a.BLEND_FRAGMENT_COMPLEX_CAP},"color-dodge":{shader:a.BLEND_FRAGMENT_COMPLEX+"clamp(dstClr / (1.0 - srcClr), 0.0, 1.0)"+a.BLEND_FRAGMENT_COMPLEX_CAP},"color-burn":{shader:a.BLEND_FRAGMENT_COMPLEX+"1.0 - clamp((1.0 - smoothstep(0.0035, 0.9955, dstClr)) / smoothstep(0.0035, 0.9955, srcClr), 0.0, 1.0)"+a.BLEND_FRAGMENT_COMPLEX_CAP},difference:{shader:a.BLEND_FRAGMENT_COMPLEX+"abs(src.rgb - dstClr)"+a.BLEND_FRAGMENT_COMPLEX_CAP},exclusion:{shader:a.BLEND_FRAGMENT_COMPLEX+"dstClr + src.rgb - 2.0 * src.rgb * dstClr"+a.BLEND_FRAGMENT_COMPLEX_CAP},hue:{shader:a.BLEND_FRAGMENT_HSL_UTIL+a.BLEND_FRAGMENT_COMPLEX+"setLum(setSat(srcClr, getSat(dstClr)), getLum(dstClr))"+a.BLEND_FRAGMENT_COMPLEX_CAP},saturation:{shader:a.BLEND_FRAGMENT_HSL_UTIL+a.BLEND_FRAGMENT_COMPLEX+"setLum(setSat(dstClr, getSat(srcClr)), getLum(dstClr))"+a.BLEND_FRAGMENT_COMPLEX_CAP},color:{ +shader:a.BLEND_FRAGMENT_HSL_UTIL+a.BLEND_FRAGMENT_COMPLEX+"setLum(srcClr, getLum(dstClr))"+a.BLEND_FRAGMENT_COMPLEX_CAP},luminosity:{shader:a.BLEND_FRAGMENT_HSL_UTIL+a.BLEND_FRAGMENT_COMPLEX+"setLum(dstClr, getLum(srcClr))"+a.BLEND_FRAGMENT_COMPLEX_CAP}},b._get_isWebGL=function(){return!!this._webGLContext},b._set_autoPurge=function(a){a=isNaN(a)?1200:a,-1!==a&&(a=a<10?10:a),this._autoPurge=a},b._get_autoPurge=function(){return Number(this._autoPurge)};try{Object.defineProperties(b,{isWebGL:{get:b._get_isWebGL},autoPurge:{get:b._get_autoPurge,set:b._set_autoPurge}})}catch(a){}b._initializeWebGL=function(){if(this.canvas){if(!this._webGLContext||this._webGLContext.canvas!==this.canvas){var a={depth:!1,stencil:!1,premultipliedAlpha:this._transparent,alpha:this._transparent,antialias:this._antialias,preserveDrawingBuffer:this._preserveBuffer},b=this._webGLContext=this._fetchWebGLContext(this.canvas,a);if(!b)return null;b.disable(b.DEPTH_TEST),b.depthMask(!1),b.enable(b.BLEND),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,!0),b.clearColor(0,0,0,0),b.blendEquationSeparate(b.FUNC_ADD,b.FUNC_ADD),b.blendFuncSeparate(b.ONE,b.ONE_MINUS_SRC_ALPHA,b.ONE,b.ONE_MINUS_SRC_ALPHA),this._createBuffers(),this._initMaterials(),this._updateRenderMode("source-over"),this.updateViewport(this.canvas.width,this.canvas.height),this._directDraw||(this._bufferTextureOutput=this.getRenderBufferTexture(this._viewportWidth,this._viewportHeight)),this.canvas._invalid=!0}}else this._webGLContext=null;return this._webGLContext},b.update=function(a){if(this.canvas){if(this.tickOnUpdate&&this.tick(a),this.dispatchEvent("drawstart"),this._webGLContext)this.draw(this._webGLContext,!1);else{this.autoClear&&this.clear();var b=this.canvas.getContext("2d");b.save(),this.updateContext(b),this.draw(b,!1),b.restore()}this.dispatchEvent("drawend")}},b.clear=function(){if(this.canvas){var b=this._webGLContext;if(!a.isWebGLActive(b))return void this.Stage_clear();b.bindFramebuffer(b.FRAMEBUFFER,null),this._clearFrameBuffer(this._transparent?this._clearColor.a:1)}},b.draw=function(b,c){var d=this._webGLContext;if(b!==this._webGLContext||!a.isWebGLActive(d))return this.Stage_draw(b,c);var e=this._batchTextureOutput,f=this._batchTextureConcat,g=this._batchTextureTemp;return this._renderPerDraw=0,this._batchVertexCount=0,this._drawID++,this._directDraw?(this._batchTextureOutput=this,this.autoClear&&this.clear()):(this._batchTextureOutput=this._bufferTextureOutput,this._batchTextureConcat=this._bufferTextureConcat,this._batchTextureTemp=this._bufferTextureTemp),this._updateRenderMode("source-over"),this._drawContent(this,c),this._directDraw||(this.autoClear&&this.clear(),this.batchReason="finalOutput",this._renderPerDraw&&this._drawCover(null,this._batchTextureOutput)),this._bufferTextureOutput=this._batchTextureOutput,this._bufferTextureConcat=this._batchTextureConcat,this._bufferTextureTemp=this._batchTextureTemp,this._batchTextureOutput=e,this._batchTextureConcat=f,this._batchTextureTemp=g,-1===this._autoPurge||this._drawID%(this._autoPurge/2|0)||this.purgeTextures(this._autoPurge),!0},b.cacheDraw=function(b,c){if(!a.isWebGLActive(this._webGLContext))return!1;for(var d=0;d=0&&g.splice(h,1),e._storeID=void 0,0===g.length&&this._killTextureObject(f)}else this._killTextureObject(f)}},b.purgeTextures=function(a){a>=0||(a=100);for(var b=this._textureDictionary,c=b.length,d=0;d0?a:1)||1,d=Math.ceil(b>0?b:1)||1,e=this._webGLContext,f=e.createTexture();return this.resizeTexture(f,c,d),this.setTextureParams(e,!1),f},b.resizeTexture=function(a,b,c){if(a.width!==b||a.height!==c){var d=this._webGLContext;d.bindTexture(d.TEXTURE_2D,a),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,b,c,0,d.RGBA,d.UNSIGNED_BYTE,null),a.width=b,a.height=c}},b.getRenderBufferTexture=function(a,b){var c=this._webGLContext,d=this.getBaseTexture(a,b);if(!d)return null;var e=c.createFramebuffer();return e?(d.width=a,d.height=b,c.bindFramebuffer(c.FRAMEBUFFER,e),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,d,0),e._renderTexture=d,d._frameBuffer=e,d._storeID=this._textureDictionary.length,this._textureDictionary[d._storeID]=d,c.bindFramebuffer(c.FRAMEBUFFER,null),d):null},b.setTextureParams=function(a,b){b&&this._antialias?(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR)):(a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.NEAREST)),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)},b.setClearColor=function(b){this._clearColor=a.colorToObj(b)},b.toDataURL=function(b,c,d){var e,f=this._webGLContext;this.batchReason="dataURL";var g=this._clearColor;if(this.canvas)return a.isWebGLActive(f)?(this._preserveBuffer&&void 0===b||(void 0!==b&&(this._clearColor=a.colorToObj(b)),this.clear(),this._directDraw?(console.log("No stored/useable gl render info, result may be incorrect if content was changed since render"),this.draw(f)):this._drawCover(null,this._bufferTextureOutput)),e=this.canvas.toDataURL(c||"image/png",d),this._preserveBuffer&&void 0===b||(void 0!==b&&(this._clearColor=g),this.clear(),this._directDraw?this.draw(f):this._drawCover(null,this._bufferTextureOutput)),e):this.Stage_toDataURL(b,c,d)},b.toString=function(){return"[StageGL (name="+this.name+")]"},b._updateDrawingSurface=function(a,b){this._viewportWidth=a,this._viewportHeight=b,this._webGLContext.viewport(0,0,this._viewportWidth,this._viewportHeight),this._projectionMatrix=new Float32Array([2/a,0,0,0,0,-2/b,0,0,0,0,1,0,-1,1,0,1])},b._getSafeTexture=function(a,b){var c=this.getBaseTexture(a,b);if(!c){var d="Problem creating texture, possible cause: using too much VRAM, please try releasing texture memory";console.error&&console.error(d)||console.log(d),c=this._baseTextures[0]}return c},b._clearFrameBuffer=function(a){var b=this._webGLContext,c=this._clearColor;a>0&&(a=1),a<0&&(a=0),b.clearColor(c.r*a,c.g*a,c.b*a,a),b.clear(b.COLOR_BUFFER_BIT),b.clearColor(0,0,0,0)},b._fetchWebGLContext=function(a,b){var c;try{c=a.getContext("webgl",b)||a.getContext("experimental-webgl",b)}catch(a){}if(c)c.viewportWidth=a.width,c.viewportHeight=a.height;else{var d="Could not initialize WebGL";console.error?console.error(d):console.log(d)}return c},b._fetchShaderProgram=function(b,c,d,e){var f=this._webGLContext;f.useProgram(null);var g,h;b?(h=a.COVER_VERTEX_HEADER+(c||a.COVER_VERTEX_BODY),g=a.COVER_FRAGMENT_HEADER+(d||a.COVER_FRAGMENT_BODY)):(h=a.REGULAR_VERTEX_HEADER+(c||a.REGULAR_VERTEX_BODY),g=a.REGULAR_FRAGMENT_HEADER+(d||a.REGULAR_FRAGMENT_BODY));var i=this._createShader(f,f.VERTEX_SHADER,h),j=this._createShader(f,f.FRAGMENT_SHADER,g),k=f.createProgram();if(f.attachShader(k,i),f.attachShader(k,j),f.linkProgram(k),!f.getProgramParameter(k,f.LINK_STATUS))throw f.useProgram(this._activeShader),f.getProgramInfoLog(k);if(f.useProgram(k),k.positionAttribute=f.getAttribLocation(k,"vertexPosition"),f.enableVertexAttribArray(k.positionAttribute),k.uvPositionAttribute=f.getAttribLocation(k,"uvPosition"),f.enableVertexAttribArray(k.uvPositionAttribute),b)k.samplerUniform=f.getUniformLocation(k,"uSampler"),f.uniform1i(k.samplerUniform,0),e&&e(f,this,k);else{k.textureIndexAttribute=f.getAttribLocation(k,"textureIndex"),f.enableVertexAttribArray(k.textureIndexAttribute),k.alphaAttribute=f.getAttribLocation(k,"objectAlpha"),f.enableVertexAttribArray(k.alphaAttribute);for(var l=[],m=0;ma.MAX_TEXTURE_SIZE||b.height>a.MAX_TEXTURE_SIZE)&&console&&console.error("Oversized Texture: "+b.width+"x"+b.height+" vs "+a.MAX_TEXTURE_SIZE+"max"))}},b._insertTextureInBatch=function(a,b){var c;if(this._batchTextures[b._activeIndex]!==b){var d=-1,e=(this._lastTextureInsert+1)%this._batchTextureCount,f=e;do{if(this._batchTextures[f]._batchID!==this._batchID&&!this._slotBlacklist[f]){d=f;break}f=(f+1)%this._batchTextureCount}while(f!==e);-1===d&&(this.batchReason="textureOverflow",this._renderBatch(),d=e),this._batchTextures[d]=b,b._activeIndex=d,c=b._imageData&&b._imageData[0],c&&(void 0===c._invalid&&c._isCanvas||c._invalid)&&this._updateTextureImageData(a,c),this._lastTextureInsert=d}else b._drawID!==this._drawID&&(c=b._imageData&&b._imageData[0])&&(void 0===c._invalid&&c._isCanvas||c._invalid)&&this._updateTextureImageData(a,c);b._drawID=this._drawID,b._batchID=this._batchID},b._killTextureObject=function(a){if(a){var b=this._webGLContext;if(void 0!==a._storeID&&a._storeID>=0){this._textureDictionary[a._storeID]=void 0;for(var c in this._textureIDs)this._textureIDs[c]===a._storeID&&delete this._textureIDs[c];var d=a._imageData;if(d)for(var e=d.length-1;e>=0;e--)d[e]._storeID=void 0;a._imageData=a._storeID=void 0}void 0!==a._activeIndex&&this._batchTextures[a._activeIndex]===a&&(this._batchTextures[a._activeIndex]=this._baseTextures[a._activeIndex]);try{a._frameBuffer&&b.deleteFramebuffer(a._frameBuffer),a._frameBuffer=void 0}catch(a){this.vocalDebug&&console.log(a)}try{b.deleteTexture(a)}catch(a){this.vocalDebug&&console.log(a)}}},b._setCoverMixShaderParams=function(a,b,c){a.uniform1i(a.getUniformLocation(c,"uMixSampler"),1)},b._updateRenderMode=function(b){null!==b&&void 0!==b||(b="source-over");var c=a.BLEND_SOURCES[b];if(void 0===c&&(this.vocalDebug&&console.log("Unknown compositeOperation ["+b+"], reverting to default"),c=a.BLEND_SOURCES[b="source-over"]),this._renderMode!==b){var d=this._webGLContext,e=this._builtShaders[b];if(void 0===e)try{e=this._builtShaders[b]={eqRGB:d[c.eqRGB||"FUNC_ADD"],srcRGB:d[c.srcRGB||"ONE"],dstRGB:d[c.dstRGB||"ONE_MINUS_SRC_ALPHA"],eqA:d[c.eqA||"FUNC_ADD"],srcA:d[c.srcA||"ONE"],dstA:d[c.dstA||"ONE_MINUS_SRC_ALPHA"],immediate:void 0!==c.shader,shader:c.shader||void 0===this._builtShaders["source-over"]?this._fetchShaderProgram(!0,void 0,c.shader,this._setCoverMixShaderParams):this._builtShaders["source-over"].shader},c.shader&&(e.shader._name=b)}catch(a){return this._builtShaders[b]=void 0,void(console&&console.log("SHADER SWITCH FAILURE",a))}if(e.immediate){if(this._directDraw)return void(this.vocalDebug&&console.log("Illegal compositeOperation ["+b+"] due to StageGL.directDraw = true, reverting to default"));this._activeConfig=this._attributeConfig.micro}d.bindFramebuffer(d.FRAMEBUFFER,this._batchTextureOutput._frameBuffer),this.batchReason="shaderSwap",this._renderBatch(),this._renderMode=b,this._immediateRender=e.immediate,d.blendEquationSeparate(e.eqRGB,e.eqA),d.blendFuncSeparate(e.srcRGB,e.dstRGB,e.srcA,e.dstA)}},b._drawContent=function(a,b){var c=this._webGLContext;this._activeShader=this._mainShader,c.bindFramebuffer(c.FRAMEBUFFER,this._batchTextureOutput._frameBuffer),null!==this._batchTextureOutput._frameBuffer&&c.clear(c.COLOR_BUFFER_BIT),this._appendToBatch(a,new createjs.Matrix2D,this.alpha,b),this.batchReason="contentEnd",this._renderBatch()},b._drawCover=function(a,b,c){var d=this._webGLContext;d.bindFramebuffer(d.FRAMEBUFFER,a),null!==a&&d.clear(d.COLOR_BUFFER_BIT),d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,b),this.setTextureParams(d),c instanceof createjs.Filter?this._activeShader=this.getFilterShader(c):(c instanceof WebGLTexture?(d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c),this.setTextureParams(d)):void 0!==c&&this.vocalDebug&&console.log("Unknown data handed to function: ",c),this._activeShader=this._builtShaders[this._renderMode].shader),this._renderCover()},b._alignTargetToCache=function(a,b){null===b._counterMatrix?b._counterMatrix=a.getMatrix():a.getMatrix(b._counterMatrix);var c=b._counterMatrix;return c.scale(1/b.scale,1/b.scale),c=c.invert(),c.translate(-b.offX/b.scale*a.scaleX,-b.offY/b.scale*a.scaleY),c},b._appendToBatch=function(b,c,d,e){var f=this._webGLContext,g=b._glMtx;g.copy(c),null!==b.transformMatrix?g.appendMatrix(b.transformMatrix):g.appendTransform(b.x,b.y,b.scaleX,b.scaleY,b.rotation,b.skewX,b.skewY,b.regX,b.regY);var h=this._renderMode;b.compositeOperation&&this._updateRenderMode(b.compositeOperation);for(var i,j,k,l,m=b.children.length,n=0;n.0035){var q=o.alpha;if(!1===p&&(o._updateState&&o._updateState(),!this._directDraw&&!e&&null===o.cacheCanvas&&null!==o.filters&&o.filters.length)){var r;if(null===o.bitmapCache&&(r=o.getBounds(),o.bitmapCache=new createjs.BitmapCache,o.bitmapCache._autoGenerated=!0),o.bitmapCache._autoGenerated){this.batchReason="cachelessFilterInterupt",this._renderBatch(),o.alpha=1;var s=this._activeShader;r=r||o.getBounds(),o.bitmapCache.define(o,r.x,r.y,r.width,r.height,1,{useGL:this}),p=o.bitmapCache._cacheCanvas,o.alpha=q,this._activeShader=s,f.bindFramebuffer(f.FRAMEBUFFER,this._batchTextureOutput._frameBuffer)}}if(!1===p&&o.children)this._appendToBatch(o,g,q*d);else{var t=this._renderMode;o.compositeOperation&&this._updateRenderMode(o.compositeOperation),this._batchVertexCount+a.INDICIES_PER_CARD>this._maxBatchVertexCount&&(this.batchReason="vertexOverflow",this._renderBatch());var u=o._glMtx;u.copy(g),o.transformMatrix?u.appendMatrix(o.transformMatrix):u.appendTransform(o.x,o.y,o.scaleX,o.scaleY,o.rotation,o.skewX,o.skewY,o.regX,o.regY);var v,w,x,y,z,A;if(2===o._webGLRenderStyle||!1!==p)x=!1===p?o.image:p;else{if(1!==o._webGLRenderStyle)continue;if(null===(y=o.spriteSheet.getFrame(o.currentFrame)))continue;x=y.image}if(x){if(void 0===x._storeID)z=this._loadTextureImage(f,x);else{if(!(z=this._textureDictionary[x._storeID])){this.vocalDebug&&console.log("Image source should not be lookup a non existent texture, please report a bug.");continue}z._batchID!==this._batchID&&this._insertTextureInBatch(f,z)}if(w=z._activeIndex,x._drawID=this._drawID,2===o._webGLRenderStyle||!1!==p)!1===p&&o.sourceRect?(o._uvRect||(o._uvRect={}),A=o.sourceRect,v=o._uvRect,v.t=1-A.y/x.height,v.l=A.x/x.width,v.b=1-(A.y+A.height)/x.height,v.r=(A.x+A.width)/x.width,i=0,j=0,k=A.width+i,l=A.height+j):(v=a.UV_RECT,!1===p?(i=0,j=0,k=x.width+i,l=x.height+j):(A=o.bitmapCache,i=A.x+A._filterOffX/A.scale,j=A.y+A._filterOffY/A.scale,k=A._drawWidth/A.scale+i,l=A._drawHeight/A.scale+j));else if(1===o._webGLRenderStyle){var B=y.rect;v=y.uvRect,v||(v=a.buildUVRects(o.spriteSheet,o.currentFrame,!1)),i=-y.regX,j=-y.regY,k=B.width-y.regX,l=B.height-y.regY}var C=0,D=this._activeConfig,E=D.position.array,F=D.uv.array,G=D.texture.array,H=D.alpha.array;C=D.position.spacing;var I=this._batchVertexCount*C+D.position.offset;E[I]=i*u.a+j*u.c+u.tx,E[I+1]=i*u.b+j*u.d+u.ty,I+=C,E[I]=i*u.a+l*u.c+u.tx,E[I+1]=i*u.b+l*u.d+u.ty,I+=C,E[I]=k*u.a+j*u.c+u.tx,E[I+1]=k*u.b+j*u.d+u.ty,I+=C,E[I]=i*u.a+l*u.c+u.tx,E[I+1]=i*u.b+l*u.d+u.ty,I+=C,E[I]=k*u.a+j*u.c+u.tx,E[I+1]=k*u.b+j*u.d+u.ty,I+=C,E[I]=k*u.a+l*u.c+u.tx,E[I+1]=k*u.b+l*u.d+u.ty,C=D.uv.spacing;var J=this._batchVertexCount*C+D.uv.offset;F[J]=v.l,F[J+1]=v.t,J+=C,F[J]=v.l,F[J+1]=v.b,J+=C,F[J]=v.r,F[J+1]=v.t,J+=C,F[J]=v.l,F[J+1]=v.b,J+=C,F[J]=v.r,F[J+1]=v.t,J+=C,F[J]=v.r,F[J+1]=v.b,C=D.texture.spacing;var K=this._batchVertexCount*C+D.texture.offset;G[K]=w,K+=C,G[K]=w,K+=C,G[K]=w,K+=C,G[K]=w,K+=C,G[K]=w,K+=C,G[K]=w,C=D.alpha.spacing;var L=this._batchVertexCount*C+D.alpha.offset;H[L]=q*d,L+=C,H[L]=q*d,L+=C,H[L]=q*d,L+=C,H[L]=q*d,L+=C,H[L]=q*d,L+=C,H[L]=q*d,this._batchVertexCount+=a.INDICIES_PER_CARD,this._immediateRender&&(this._activeConfig=this._attributeConfig.default,this._immediateBatchRender()),this._renderMode!==t&&this._updateRenderMode(t)}}}}this._renderMode!==h&&this._updateRenderMode(h)},b._immediateBatchRender=function(){var a=this._webGLContext;null===this._batchTextureConcat?this._batchTextureConcat=this.getRenderBufferTexture(this._viewportWidth,this._viewportHeight):(this.resizeTexture(this._batchTextureConcat,this._viewportWidth,this._viewportHeight),a.bindFramebuffer(a.FRAMEBUFFER,this._batchTextureConcat._frameBuffer),a.clear(a.COLOR_BUFFER_BIT)),null===this._batchTextureTemp?(this._batchTextureTemp=this.getRenderBufferTexture(this._viewportWidth,this._viewportHeight),a.bindFramebuffer(a.FRAMEBUFFER,this._batchTextureTemp._frameBuffer)):(this.resizeTexture(this._batchTextureTemp,this._viewportWidth,this._viewportHeight),a.bindFramebuffer(a.FRAMEBUFFER,this._batchTextureTemp._frameBuffer),a.clear(a.COLOR_BUFFER_BIT));var b=this._batchTextureOutput;this._batchTextureOutput=this._batchTextureConcat,this._batchTextureConcat=b,this._activeShader=this._mainShader,this.batchReason="immediatePrep",this._renderBatch(),this.batchReason="immediateResults",this._drawCover(this._batchTextureOutput._frameBuffer,this._batchTextureConcat,this._batchTextureTemp),a.bindFramebuffer(a.FRAMEBUFFER,this._batchTextureOutput._frameBuffer)},b._renderBatch=function(){if(!(this._batchVertexCount<=0)){var a=this._webGLContext;this._renderPerDraw++,this.vocalDebug&&console.log("Batch["+this._drawID+":"+this._batchID+"] : "+this.batchReason);var b,c=this._activeShader,d=this._activeConfig;a.useProgram(c),b=d.position,a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.vertexAttribPointer(c.positionAttribute,b.size,b.type,!1,b.stride,b.offB),a.bufferSubData(a.ARRAY_BUFFER,0,b.array),b=d.texture,a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.vertexAttribPointer(c.textureIndexAttribute,b.size,b.type,!1,b.stride,b.offB),a.bufferSubData(a.ARRAY_BUFFER,0,b.array),b=d.uv,a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.vertexAttribPointer(c.uvPositionAttribute,b.size,b.type,!1,b.stride,b.offB),a.bufferSubData(a.ARRAY_BUFFER,0,b.array),b=d.alpha,a.bindBuffer(a.ARRAY_BUFFER,b.buffer),a.vertexAttribPointer(c.alphaAttribute,b.size,b.type,!1,b.stride,b.offB),a.bufferSubData(a.ARRAY_BUFFER,0,b.array),a.uniformMatrix4fv(c.pMatrixUniform,a.FALSE,this._projectionMatrix);for(var e=0;e=2);return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&b)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.image,d=this.sourceRect;if(c.getImage&&(c=c.getImage()),!c)return!0;if(d){var e=d.x,f=d.y,g=e+d.width,h=f+d.height,i=0,j=0,k=c.width,l=c.height;e<0&&(i-=e,e=0),g>k&&(g=k),f<0&&(j-=f,f=0),h>l&&(h=l),a.drawImage(c,e,f,g-e,h-f,i,j,g-e,h-f)}else a.drawImage(c,0,0);return!0},b.getBounds=function(){var a=this.DisplayObject_getBounds();if(a)return a;var b=this.image,c=this.sourceRect||b;return b&&(b.naturalWidth||b.getContext||b.readyState>=2)?this._rectangle.setValues(0,0,c.width,c.height):null},b.clone=function(b){var c=this.image;c&&b&&(c=c.cloneNode(),c.src=c.src);var d=new a(c);return this.sourceRect&&(d.sourceRect=this.sourceRect.clone()),this._cloneProps(d),d},b.toString=function(){return"[Bitmap (name="+this.name+")]"},createjs.Bitmap=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.DisplayObject_constructor(),this.currentFrame=0,this.currentAnimation=null,this.paused=!0,this.spriteSheet=a,this.currentAnimationFrame=0,this.framerate=0,this._animation=null,this._currentFrame=null,this._skipAdvance=!1,this._webGLRenderStyle=createjs.DisplayObject._StageGL_SPRITE,null!=b&&this.gotoAndPlay(b)}var b=createjs.extend(a,createjs.DisplayObject);b.initialize=a,b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet.complete;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;this._normalizeFrame();var c=this.spriteSheet.getFrame(0|this._currentFrame);if(!c)return!1;var d=c.rect;return d.width&&d.height&&a.drawImage(c.image,d.x,d.y,d.width,d.height,-c.regX,-c.regY,d.width,d.height),!0},b.play=function(){this.paused=!1},b.stop=function(){this.paused=!0},b.gotoAndPlay=function(a){this.paused=!1,this._skipAdvance=!0,this._goto(a)},b.gotoAndStop=function(a){this.paused=!0,this._goto(a)},b.advance=function(a){var b=this.framerate||this.spriteSheet.framerate,c=b&&null!=a?a/(1e3/b):1;this._normalizeFrame(c)},b.getBounds=function(){return this.DisplayObject_getBounds()||this.spriteSheet.getFrameBounds(this.currentFrame,this._rectangle)},b.clone=function(){return this._cloneProps(new a(this.spriteSheet))},b.toString=function(){return"[Sprite (name="+this.name+")]"},b._cloneProps=function(a){return this.DisplayObject__cloneProps(a),a.currentFrame=this.currentFrame,a.currentAnimation=this.currentAnimation,a.paused=this.paused,a.currentAnimationFrame=this.currentAnimationFrame,a.framerate=this.framerate,a._animation=this._animation,a._currentFrame=this._currentFrame,a._skipAdvance=this._skipAdvance,a},b._tick=function(a){this.paused||(this._skipAdvance||this.advance(a&&a.delta),this._skipAdvance=!1),this.DisplayObject__tick(a)},b._normalizeFrame=function(a){a=a||0;var b,c=this._animation,d=this.paused,e=this._currentFrame;if(c){var f=c.speed||1,g=this.currentAnimationFrame;if(b=c.frames.length,g+a*f>=b){var h=c.next;if(this._dispatchAnimationEnd(c,e,d,h,b-1))return;if(h)return this._goto(h,a-(b-g)/f);this.paused=!0,g=c.frames.length-1}else g+=a*f;this.currentAnimationFrame=g,this._currentFrame=c.frames[0|g]}else if(e=this._currentFrame+=a,b=this.spriteSheet.getNumFrames(),e>=b&&b>0&&!this._dispatchAnimationEnd(c,e,d,b-1)&&(this._currentFrame-=b)>=b)return this._normalizeFrame();e=0|this._currentFrame,this.currentFrame!=e&&(this.currentFrame=e,this.dispatchEvent("change"))},b._dispatchAnimationEnd=function(a,b,c,d,e){var f=a?a.name:null;if(this.hasEventListener("animationend")){var g=new createjs.Event("animationend");g.name=f,g.next=d,this.dispatchEvent(g)}var h=this._animation!=a||this._currentFrame!=b;return h||c||!this.paused||(this.currentAnimationFrame=e,h=!0),h},b._goto=function(a,b){if(this.currentAnimationFrame=0,isNaN(a)){var c=this.spriteSheet.getAnimation(a);c&&(this._animation=c,this.currentAnimation=a,this._normalizeFrame(b))}else this.currentAnimation=this._animation=null,this._currentFrame=a,this._normalizeFrame()},createjs.Sprite=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.DisplayObject_constructor(),this.graphics=a||new createjs.Graphics}var b=createjs.extend(a,createjs.DisplayObject);b.isVisible=function(){var a=this.cacheCanvas||this.graphics&&!this.graphics.isEmpty();return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){return!!this.DisplayObject_draw(a,b)||(this.graphics.draw(a,this),!0)},b.clone=function(b){var c=b&&this.graphics?this.graphics.clone():this.graphics;return this._cloneProps(new a(c))},b.toString=function(){return"[Shape (name="+this.name+")]"},createjs.Shape=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{}, +function(){"use strict";function a(a,b,c){this.DisplayObject_constructor(),this.text=a,this.font=b,this.color=c,this.textAlign="left",this.textBaseline="top",this.maxWidth=null,this.outline=0,this.lineHeight=0,this.lineWidth=null}var b=createjs.extend(a,createjs.DisplayObject),c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");c.getContext&&(a._workingContext=c.getContext("2d"),c.width=c.height=1),a.H_OFFSETS={start:0,left:0,center:-.5,end:-1,right:-1},a.V_OFFSETS={top:0,hanging:-.01,middle:-.4,alphabetic:-.8,ideographic:-.85,bottom:-1},b.isVisible=function(){var a=this.cacheCanvas||null!=this.text&&""!==this.text;return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY&&a)},b.draw=function(a,b){if(this.DisplayObject_draw(a,b))return!0;var c=this.color||"#000";return this.outline?(a.strokeStyle=c,a.lineWidth=1*this.outline):a.fillStyle=c,this._drawText(this._prepContext(a)),!0},b.getMeasuredWidth=function(){return this._getMeasuredWidth(this.text)},b.getMeasuredLineHeight=function(){return 1.2*this._getMeasuredWidth("M")},b.getMeasuredHeight=function(){return this._drawText(null,{}).height},b.getBounds=function(){var b=this.DisplayObject_getBounds();if(b)return b;if(null==this.text||""===this.text)return null;var c=this._drawText(null,{}),d=this.maxWidth&&this.maxWidththis.lineWidth){var n=l.split(/(\s)/);l=n[0],m=b.measureText(l).width;for(var o=1,p=n.length;othis.lineWidth?(e&&this._drawTextLine(b,l,h*f),d&&d.push(l),m>g&&(g=m),l=n[o+1],m=b.measureText(l).width,h++):(l+=n[o]+n[o+1],m+=q)}}e&&this._drawTextLine(b,l,h*f),d&&d.push(l),c&&null==m&&(m=b.measureText(l).width),m>g&&(g=m),h++}return c&&(c.width=g,c.height=h*f),e||b.restore(),c},b._drawTextLine=function(a,b,c){this.outline?a.strokeText(b,0,c,this.maxWidth||65535):a.fillText(b,0,c,this.maxWidth||65535)},b._getMeasuredWidth=function(b){var c=a._workingContext;c.save();var d=this._prepContext(c).measureText(b).width;return c.restore(),d},createjs.Text=createjs.promote(a,"DisplayObject")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b){this.Container_constructor(),this.text=a||"",this.spriteSheet=b,this.lineHeight=0,this.letterSpacing=0,this.spaceWidth=0,this._oldProps={text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0},this._oldStage=null,this._drawAction=null}var b=createjs.extend(a,createjs.Container);a.maxPoolSize=100,a._spritePool=[],b.draw=function(a,b){this.DisplayObject_draw(a,b)||(this._updateState(),this.Container_draw(a,b))},b.getBounds=function(){return this._updateText(),this.Container_getBounds()},b.isVisible=function(){var a=this.cacheCanvas||this.spriteSheet&&this.spriteSheet.complete&&this.text;return!!(this.visible&&this.alpha>0&&0!==this.scaleX&&0!==this.scaleY&&a)},b.clone=function(){return this._cloneProps(new a(this.text,this.spriteSheet))},b.addChild=b.addChildAt=b.removeChild=b.removeChildAt=b.removeAllChildren=function(){},b._updateState=function(){this._updateText()},b._cloneProps=function(a){return this.Container__cloneProps(a),a.lineHeight=this.lineHeight,a.letterSpacing=this.letterSpacing,a.spaceWidth=this.spaceWidth,a},b._getFrameIndex=function(a,b){var c,d=b.getAnimation(a);return d||(a!=(c=a.toUpperCase())||a!=(c=a.toLowerCase())||(c=null),c&&(d=b.getAnimation(c))),d&&d.frames[0]},b._getFrame=function(a,b){var c=this._getFrameIndex(a,b);return null==c?c:b.getFrame(c)},b._getLineHeight=function(a){var b=this._getFrame("1",a)||this._getFrame("T",a)||this._getFrame("L",a)||a.getFrame(0);return b?b.rect.height:1},b._getSpaceWidth=function(a){var b=this._getFrame("1",a)||this._getFrame("l",a)||this._getFrame("e",a)||this._getFrame("a",a)||a.getFrame(0);return b?b.rect.width:1},b._updateText=function(){var b,c=0,d=0,e=this._oldProps,f=!1,g=this.spaceWidth,h=this.lineHeight,i=this.spriteSheet,j=a._spritePool,k=this.children,l=0,m=k.length;for(var n in e)e[n]!=this[n]&&(e[n]=this[n],f=!0);if(f){var o=!!this._getFrame(" ",i);o||g||(g=this._getSpaceWidth(i)),h||(h=this._getLineHeight(i));for(var p=0,q=this.text.length;pl;)j.push(b=k.pop()),b.parent=null,m--;j.length>a.maxPoolSize&&(j.length=a.maxPoolSize)}},createjs.BitmapText=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(b){this.Container_constructor(),!a.inited&&a.init();var c,d,e,f;b instanceof String||arguments.length>1?(c=b,d=arguments[1],e=arguments[2],f=arguments[3],null==e&&(e=-1),b=null):b&&(c=b.mode,d=b.startPosition,e=b.loop,f=b.labels),b||(b={labels:f}),this.mode=c||a.INDEPENDENT,this.startPosition=d||0,this.loop=!0===e?-1:e||0,this.currentFrame=0,this.paused=b.paused||!1,this.actionsEnabled=!0,this.autoReset=!0,this.frameBounds=this.frameBounds||b.frameBounds,this.framerate=null,b.useTicks=b.paused=!0,this.timeline=new createjs.Timeline(b),this._synchOffset=0,this._rawPosition=-1,this._bound_resolveState=this._resolveState.bind(this),this._t=0,this._managed={}}function b(){throw"MovieClipPlugin cannot be instantiated."}var c=createjs.extend(a,createjs.Container);a.INDEPENDENT="independent",a.SINGLE_FRAME="single",a.SYNCHED="synched",a.inited=!1,a.init=function(){a.inited||(b.install(),a.inited=!0)},c._getLabels=function(){return this.timeline.getLabels()},c.getLabels=createjs.deprecate(c._getLabels,"MovieClip.getLabels"),c._getCurrentLabel=function(){return this.timeline.currentLabel},c.getCurrentLabel=createjs.deprecate(c._getCurrentLabel,"MovieClip.getCurrentLabel"),c._getDuration=function(){return this.timeline.duration},c.getDuration=createjs.deprecate(c._getDuration,"MovieClip.getDuration");try{Object.defineProperties(c,{labels:{get:c._getLabels},currentLabel:{get:c._getCurrentLabel},totalFrames:{get:c._getDuration},duration:{get:c._getDuration}})}catch(a){}c.initialize=a,c.isVisible=function(){return!!(this.visible&&this.alpha>0&&0!=this.scaleX&&0!=this.scaleY)},c.draw=function(a,b){return!!this.DisplayObject_draw(a,b)||(this._updateState(),this.Container_draw(a,b),!0)},c.play=function(){this.paused=!1},c.stop=function(){this.paused=!0},c.gotoAndPlay=function(a){this.paused=!1,this._goto(a)},c.gotoAndStop=function(a){this.paused=!0,this._goto(a)},c.advance=function(b){var c=a.INDEPENDENT;if(this.mode===c){for(var d=this,e=d.framerate;(d=d.parent)&&null===e;)d.mode===c&&(e=d._framerate);if(this._framerate=e,!(this.totalFrames<=1)){var f=null!==e&&-1!==e&&null!==b?b/(1e3/e)+this._t:1,g=0|f;for(this._t=f-g;!this.paused&&g--;)this._updateTimeline(this._rawPosition+1,!1)}}},c.clone=function(){throw"MovieClip cannot be cloned."},c.toString=function(){return"[MovieClip (name="+this.name+")]"},c._updateState=function(){-1!==this._rawPosition&&this.mode===a.INDEPENDENT||this._updateTimeline(-1)},c._tick=function(a){this.advance(a&&a.delta),this.Container__tick(a)},c._goto=function(a){var b=this.timeline.resolve(a);null!=b&&(this._t=0,this._updateTimeline(b,!0))},c._reset=function(){this._rawPosition=-1,this._t=this.currentFrame=0,this.paused=!1},c._updateTimeline=function(b,c){var d=this.mode!==a.INDEPENDENT,e=this.timeline;d&&(b=this.startPosition+(this.mode===a.SINGLE_FRAME?0:this._synchOffset)),b<0&&(b=0),(this._rawPosition!==b||d)&&(this._rawPosition=b,e.loop=this.loop,e.setPosition(b,d||!this.actionsEnabled,c,this._bound_resolveState))},c._renderFirstFrame=function(){var a=this.timeline,b=a.rawPosition;a.setPosition(0,!0,!0,this._bound_resolveState),a.rawPosition=b},c._resolveState=function(){var a=this.timeline;this.currentFrame=a.position;for(var b in this._managed)this._managed[b]=1;for(var c=a.tweens,d=0,e=c.length;d=0;d--){var j=i[d].id;1===this._managed[j]&&(this.removeChildAt(d),delete this._managed[j])}},c._setState=function(a,b){if(a)for(var c=a.length-1;c>=0;c--){var d=a[c],e=d.t,f=d.p;for(var g in f)e[g]=f[g];this._addManagedChild(e,b)}},c._addManagedChild=function(b,c){b._off||(this.addChildAt(b,0),b instanceof a&&(b._synchOffset=c,b.mode===a.INDEPENDENT&&b.autoReset&&!this._managed[b.id]&&b._reset()),this._managed[b.id]=2)},c._getBounds=function(a,b){var c=this.DisplayObject_getBounds();return c||this.frameBounds&&(c=this._rectangle.copy(this.frameBounds[this.currentFrame])),c?this._transformBounds(c,a,b):this.Container__getBounds(a,b)},createjs.MovieClip=createjs.promote(a,"Container"),b.priority=100,b.ID="MovieClip",b.install=function(){createjs.Tween._installPlugin(b)},b.init=function(c,d,e){"startPosition"===d&&c.target instanceof a&&c._addPlugin(b)},b.step=function(a,b,c){},b.change=function(a,b,c,d,e,f){if("startPosition"===c)return 1===e?b.props[c]:b.prev.props[c]}}(),this.createjs=this.createjs||{},function(){"use strict";function a(){throw"SpriteSheetUtils cannot be instantiated"}var b=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");b.getContext&&(a._workingCanvas=b,a._workingContext=b.getContext("2d"),b.width=b.height=1),a.extractFrame=function(b,c){isNaN(c)&&(c=b.getAnimation(c).frames[0]);var d=b.getFrame(c);if(!d)return null;var e=d.rect,f=a._workingCanvas;f.width=e.width,f.height=e.height,a._workingContext.drawImage(d.image,e.x,e.y,e.width,e.height,0,0,e.width,e.height);var g=document.createElement("img");return g.src=f.toDataURL("image/png"),g},a.addFlippedFrames=createjs.deprecate(null,"SpriteSheetUtils.addFlippedFrames"),a.mergeAlpha=createjs.deprecate(null,"SpriteSheetUtils.mergeAlpha"),a._flip=function(b,c,d,e){for(var f=b._images,g=a._workingCanvas,h=a._workingContext,i=f.length/c,j=0;jthis.maxHeight)throw a.ERR_DIMENSIONS;for(var e=0,f=0,g=0;d.length;){var h=this._fillRow(d,e,g,c,b);if(h.w>f&&(f=h.w),e+=h.h,!h.h||!d.length){var i=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");i.width=this._getSize(f,this.maxWidth),i.height=this._getSize(e,this.maxHeight),this._data.images[g]=i,h.h||(f=e=0,g++)}}},b._setupMovieClipFrame=function(a,b){var c=a.actionsEnabled;a.actionsEnabled=!1,a.gotoAndStop(b.i),a.actionsEnabled=c,b.f&&b.f(a,b.d,b.i)},b._getSize=function(a,b){for(var c=4;Math.pow(2,++c)=0;l--){var m=b[l],n=this._scale*m.scale,o=m.sourceRect,p=m.source,q=Math.floor(n*o.x-f),r=Math.floor(n*o.y-f),s=Math.ceil(n*o.height+2*f),t=Math.ceil(n*o.width+2*f);if(t>g)throw a.ERR_DIMENSIONS;s>i||j+t>g||(m.img=d,m.rect=new createjs.Rectangle(j,c,t,s),k=k||s,b.splice(l,1),e[m.index]=[j,c,t,s,d,Math.round(-q+n*p.regX-f),Math.round(-r+n*p.regY-f)],j+=t)}return{w:j,h:k}},b._endBuild=function(){this.spriteSheet=new createjs.SpriteSheet(this._data),this._data=null,this.progress=1,this.dispatchEvent("complete")},b._run=function(){for(var a=50*Math.max(.01,Math.min(.99,this.timeSlice||.3)),b=(new Date).getTime()+a,c=!1;b>(new Date).getTime();)if(!this._drawNext()){c=!0;break}if(c)this._endBuild();else{var d=this;this._timerID=setTimeout(function(){d._run()},50-a)}var e=this.progress=this._index/this._frames.length;if(this.hasEventListener("progress")){var f=new createjs.Event("progress");f.progress=e,this.dispatchEvent(f)}},b._drawNext=function(){var a=this._frames[this._index],b=a.scale*this._scale,c=a.rect,d=a.sourceRect,e=this._data.images[a.img],f=e.getContext("2d");return a.funct&&a.funct(a.source,a.data),f.save(),f.beginPath(),f.rect(c.x,c.y,c.width,c.height),f.clip(),f.translate(Math.ceil(c.x-d.x*b),Math.ceil(c.y-d.y*b)),f.scale(b,b),a.source.draw(f),f.restore(),++this._index=1?d:1,this.height=e>=1?e:1,this.x=b||0,this.y=c||0,this.scale=f||1,this.update()},b.update=function(b){if(!this.target)throw"define() must be called before update()";var c=a.getFilterBounds(this.target),d=this._cacheCanvas;this._drawWidth=Math.ceil(this.width*this.scale)+c.width,this._drawHeight=Math.ceil(this.height*this.scale)+c.height,this._filterCount=this.target.filters&&this.target.filters.reduce(a.filterCounter,0),d&&this._drawWidth===d.width&&this._drawHeight===d.height||this._updateSurface(),this._stageGL&&(null===this._bufferTextureOutput?this._bufferTextureOutput=this._stageGL.getRenderBufferTexture(this._drawWidth,this._drawHeight):this._stageGL.resizeTexture(this._bufferTextureOutput,this._drawWidth,this._drawHeight),null===this._cacheCanvas&&(this._cacheCanvas=this._bufferTextureOutput,this.disabled=this._disabled),this._filterCount>=1&&(null===this._bufferTextureConcat?this._bufferTextureConcat=this._stageGL.getRenderBufferTexture(this._drawWidth,this._drawHeight):this._stageGL.resizeTexture(this._bufferTextureConcat,this._drawWidth,this._drawHeight))),this._filterOffX=c.x,this._filterOffY=c.y,this.offX=this.x*this.scale+this._filterOffX,this.offY=this.y*this.scale+this._filterOffY,this._drawToCache(b),this.cacheID=this.cacheID?this.cacheID+1:1},b.release=function(){if(this._stageGL)null!==this._bufferTextureOutput&&this._stageGL._killTextureObject(this._bufferTextureOutput),null!==this._bufferTextureConcat&&this._stageGL._killTextureObject(this._bufferTextureConcat),null!==this._bufferTextureTemp&&this._stageGL._killTextureObject(this._bufferTextureTemp),this._stageGL=!1;else{var a=this.target.stage;a instanceof createjs.StageGL&&a.releaseTexture(this._cacheCanvas)}this.disabled=!0,this.target=this._cacheCanvas=null,this.cacheID=this._cacheDataURLID=this._cacheDataURL=void 0,this.width=this.height=this.x=this.y=this.offX=this.offY=0,this.scale=1},b.getCacheDataURL=function(a,b){var c=this.target&&this._cacheCanvas;return c?(this.cacheID!==this._cacheDataURLID&&(this._cacheDataURLID=this.cacheID,this._cacheDataURL=c.getCacheDataURL?c.getCacheDataURL(a,b):null),this._cacheDataURL):null},b.draw=function(a){return!!this.target&&(a.drawImage(this._cacheCanvas,this.x+this._filterOffX/this.scale,this.y+this._filterOffY/this.scale,this._drawWidth/this.scale,this._drawHeight/this.scale),!0)},b.getBounds=function(){var a=this.scale;return this._boundRect.setValues(this.x,this.y,this.width/a,this.height/a)},b._getGLFilter=function(a){if(!(null===this.target.filters||a<0)){for(var b=0,c=this.target.filters[b];c&&--a>=0;)c=c._multiPass?c._multiPass:this.target.filters[++b];return c}},b._updateSurface=function(){var a;if(!this._options||!this._options.useGL)return a=this._cacheCanvas,a||(a=this._cacheCanvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"),this.disabled=this._disabled),a.width=this._drawWidth,void(a.height=this._drawHeight);if(!this._stageGL)if("stage"===this._options.useGL){var b=this.target.stage;if(!b||!b.isWebGL){var c="Cannot use 'stage' for cache because the object's parent stage is ";throw c+=b?"non WebGL.":"not set, please addChild to the correct stage."}this._stageGL=b}else if("new"===this._options.useGL){if(this._cacheCanvas=document.createElement("canvas"),this._stageGL=new createjs.StageGL(this._cacheCanvas,{antialias:!0,transparent:!0,autoPurge:10}),!this._stageGL._webGLContext)throw"GL Cache asked for but unavailable";this._stageGL.isCacheControlled=!0}else{if(!(this._options.useGL instanceof createjs.StageGL))throw"Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got "+this._options.useGL;this._stageGL=this._options.useGL}this.disabled=this._disabled;var d=this._stageGL;d.isCacheControlled&&(a=this._cacheCanvas,a.width=this._drawWidth,a.height=this._drawHeight,d.updateViewport(this._drawWidth,this._drawHeight))},b._drawToCache=function(a){var b=this._cacheCanvas,c=this.target,d=this._stageGL;if(d)d.cacheDraw(c,this);else{var e=b.getContext("2d");a||e.clearRect(0,0,this._drawWidth+1,this._drawHeight+1),e.save(),e.globalCompositeOperation=a,e.setTransform(this.scale,0,0,this.scale,-this._filterOffX,-this._filterOffY),e.translate(-this.x,-this.y),c.draw(e,!0),e.restore(),c.filters&&c.filters.length&&this._applyFilters(e)}b._invalid=!0},b._applyFilters=function(a){var b,c=this.target.filters,d=this._drawWidth,e=this._drawHeight,f=0,g=c[f];do{g.usesContext?(b&&(a.putImageData(b,0,0),b=null),g.applyFilter(a,0,0,d,e)):(b||(b=a.getImageData(0,0,d,e)),g._applyFilter(b)),g=null!==g._multiPass?g._multiPass:c[++f]}while(g);b&&a.putImageData(b,0,0)},createjs.BitmapCache=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.Filter_constructor(),this._blurX=a,this._blurXTable=[],this._lastBlurX=null,this._blurY=b,this._blurYTable=[],this._lastBlurY=null,this._quality,this._lastQuality=null,this.FRAG_SHADER_TEMPLATE="uniform float xWeight[{{blurX}}];uniform float yWeight[{{blurY}}];uniform vec2 textureOffset;void main(void) {vec4 color = vec4(0.0);float xAdj = ({{blurX}}.0-1.0)/2.0;float yAdj = ({{blurY}}.0-1.0)/2.0;vec2 sampleOffset;for(int i=0; i<{{blurX}}; i++) {for(int j=0; j<{{blurY}}; j++) {sampleOffset = vTextureCoord + (textureOffset * vec2(float(i)-xAdj, float(j)-yAdj));color += texture2D(uSampler, sampleOffset) * (xWeight[i] * yWeight[j]);}}gl_FragColor = color.rgba;}",(isNaN(c)||c<1)&&(c=1),this.setQuality(0|c)}var b=createjs.extend(a,createjs.Filter);b.getBlurX=function(){return this._blurX},b.getBlurY=function(){return this._blurY},b.setBlurX=function(a){(isNaN(a)||a<0)&&(a=0),this._blurX=a},b.setBlurY=function(a){(isNaN(a)||a<0)&&(a=0),this._blurY=a},b.getQuality=function(){return this._quality},b.setQuality=function(a){(isNaN(a)||a<0)&&(a=0),this._quality=0|a},b._getShader=function(){var a=this._lastBlurX!==this._blurX,b=this._lastBlurY!==this._blurY,c=this._lastQuality!==this._quality;return a||b||c?((a||c)&&(this._blurXTable=this._getTable(this._blurX*this._quality)),(b||c)&&(this._blurYTable=this._getTable(this._blurY*this._quality)),this._updateShader(),this._lastBlurX=this._blurX,this._lastBlurY=this._blurY,void(this._lastQuality=this._quality)):this._compiledShader},b._setShader=function(a){this._compiledShader=a};try{Object.defineProperties(b,{blurX:{get:b.getBlurX,set:b.setBlurX},blurY:{get:b.getBlurY,set:b.setBlurY},quality:{get:b.getQuality,set:b.setQuality},_builtShader:{get:b._getShader,set:b._setShader}})}catch(a){console.log(a)}b._getTable=function(a){var b=4.2;if(a<=1)return[1];var c=[],d=Math.ceil(2*a);d+=d%2?0:1;for(var e=d/2|0,f=-e;f<=e;f++){var g=f/e*b;c.push(1/Math.sqrt(2*Math.PI)*Math.pow(Math.E,-Math.pow(g,2)/4))}var h=c.reduce(function(a,b){return a+b});return c.map(function(a,b,c){return a/h})},b._updateShader=function(){if(void 0!==this._blurX&&void 0!==this._blurY){var a=this.FRAG_SHADER_TEMPLATE;a=a.replace(/\{\{blurX\}\}/g,this._blurXTable.length.toFixed(0)),a=a.replace(/\{\{blurY\}\}/g,this._blurYTable.length.toFixed(0)),this.FRAG_SHADER_BODY=a}},b.shaderParamSetup=function(a,b,c){a.uniform1fv(a.getUniformLocation(c,"xWeight"),this._blurXTable),a.uniform1fv(a.getUniformLocation(c,"yWeight"),this._blurYTable),a.uniform2f(a.getUniformLocation(c,"textureOffset"),2/(b._viewportWidth*this._quality),2/(b._viewportHeight*this._quality))},a.MUL_TABLE=[1,171,205,293,57,373,79,137,241,27,391,357,41,19,283,265,497,469,443,421,25,191,365,349,335,161,155,149,9,278,269,261,505,245,475,231,449,437,213,415,405,395,193,377,369,361,353,345,169,331,325,319,313,307,301,37,145,285,281,69,271,267,263,259,509,501,493,243,479,118,465,459,113,446,55,435,429,423,209,413,51,403,199,393,97,3,379,375,371,367,363,359,355,351,347,43,85,337,333,165,327,323,5,317,157,311,77,305,303,75,297,294,73,289,287,71,141,279,277,275,68,135,67,133,33,262,260,129,511,507,503,499,495,491,61,121,481,477,237,235,467,232,115,457,227,451,7,445,221,439,218,433,215,427,425,211,419,417,207,411,409,203,202,401,399,396,197,49,389,387,385,383,95,189,47,187,93,185,23,183,91,181,45,179,89,177,11,175,87,173,345,343,341,339,337,21,167,83,331,329,327,163,81,323,321,319,159,79,315,313,39,155,309,307,153,305,303,151,75,299,149,37,295,147,73,291,145,289,287,143,285,71,141,281,35,279,139,69,275,137,273,17,271,135,269,267,133,265,33,263,131,261,130,259,129,257,1],a.SHG_TABLE=[0,9,10,11,9,12,10,11,12,9,13,13,10,9,13,13,14,14,14,14,10,13,14,14,14,13,13,13,9,14,14,14,15,14,15,14,15,15,14,15,15,15,14,15,15,15,15,15,14,15,15,15,15,15,15,12,14,15,15,13,15,15,15,15,16,16,16,15,16,14,16,16,14,16,13,16,16,16,15,16,13,16,15,16,14,9,16,16,16,16,16,16,16,16,16,13,14,16,16,15,16,16,10,16,15,16,14,16,16,14,16,16,14,16,16,14,15,16,16,16,14,15,14,15,13,16,16,15,17,17,17,17,17,17,14,15,17,17,16,16,17,16,15,17,16,17,11,17,16,17,16,17,16,17,17,16,17,17,16,17,17,16,16,17,17,17,16,14,17,17,17,17,15,16,14,16,15,16,13,16,15,16,14,16,15,16,12,16,15,16,17,17,17,17,17,13,16,15,17,17,17,16,15,17,17,17,16,15,17,17,14,16,17,17,16,17,17,16,15,17,16,14,17,16,15,17,16,17,17,16,17,15,16,17,14,17,16,15,17,16,17,13,17,16,17,17,16,17,14,17,16,17,16,17,16,17,9],b.getBounds=function(a){var b=0|this.blurX,c=0|this.blurY;if(b<=0&&c<=0)return a;var d=Math.pow(this.quality,.2);return(a||new createjs.Rectangle).pad(c*d+1,b*d+1,c*d+1,b*d+1)},b.clone=function(){return new a(this.blurX,this.blurY,this.quality)},b.toString=function(){return"[BlurFilter]"},b._applyFilter=function(b){var c=this._blurX>>1;if(isNaN(c)||c<0)return!1;var d=this._blurY>>1;if(isNaN(d)||d<0)return!1;if(0==c&&0==d)return!1;var e=this.quality;(isNaN(e)||e<1)&&(e=1),e|=0,e>3&&(e=3),e<1&&(e=1);var f=b.data,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=c+c+1|0,w=d+d+1|0,x=0|b.width,y=0|b.height,z=x-1|0,A=y-1|0,B=c+1|0,C=d+1|0,D={r:0,b:0,g:0,a:0},E=D;for(i=1;i0;){m=l=0;var M=I,N=J;for(h=y;--h>-1;){for(n=B*(r=f[0|l]),o=B*(s=f[l+1|0]),p=B*(t=f[l+2|0]),q=B*(u=f[l+3|0]),E=D,i=B;--i>-1;)E.r=r,E.g=s,E.b=t,E.a=u,E=E.n;for(i=1;i>>N,f[l++]=o*M>>>N,f[l++]=p*M>>>N,f[l++]=q*M>>>N,j=m+((j=g+c+1)0)for(h=0;h>>N,u>0?(f[j]=n*M>>>N,f[j+1]=o*M>>>N,f[j+2]=p*M>>>N):f[j]=f[j+1]=f[j+2]=0,j=g+((j=h+C)>>N,u>0?(u=255/u,f[j]=(n*M>>>N)*u,f[j+1]=(o*M>>>N)*u,f[j+2]=(p*M>>>N)*u):f[j]=f[j+1]=f[j+2]=0,j=g+((j=h+C)0?3*a/100:a/100),c=.3086,d=.6094,e=.082;return this._multiplyMatrix([c*(1-b)+b,d*(1-b),e*(1-b),0,0,c*(1-b),d*(1-b)+b,e*(1-b),0,0,c*(1-b),d*(1-b),e*(1-b)+b,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.adjustHue=function(a){if(0==a||isNaN(a))return this;a=this._cleanValue(a,180)/180*Math.PI;var b=Math.cos(a),c=Math.sin(a),d=.213,e=.715,f=.072;return this._multiplyMatrix([d+b*(1-d)+c*-d,e+b*-e+c*-e,f+b*-f+c*(1-f),0,0,d+b*-d+.143*c,e+b*(1-e)+.14*c,f+b*-f+-.283*c,0,0,d+b*-d+c*-(1-d),e+b*-e+c*e,f+b*(1-f)+c*f,0,0,0,0,0,1,0,0,0,0,0,1]),this},b.concat=function(b){return b=this._fixMatrix(b),b.length!=a.LENGTH?this:(this._multiplyMatrix(b),this)},b.clone=function(){return(new a).copy(this)},b.toArray=function(){for(var b=[],c=0,d=a.LENGTH;ca.LENGTH&&(b=b.slice(0,a.LENGTH)),b},createjs.ColorMatrix=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.Filter_constructor(),this.matrix=a,this.FRAG_SHADER_BODY="uniform mat4 uColorMatrix;uniform vec4 uColorMatrixOffset;void main(void) {vec4 color = texture2D(uSampler, vTextureCoord);mat4 m = uColorMatrix;vec4 newColor = vec4(color.r*m[0][0] + color.g*m[0][1] + color.b*m[0][2] + color.a*m[0][3],color.r*m[1][0] + color.g*m[1][1] + color.b*m[1][2] + color.a*m[1][3],color.r*m[2][0] + color.g*m[2][1] + color.b*m[2][2] + color.a*m[2][3],color.r*m[3][0] + color.g*m[3][1] + color.b*m[3][2] + color.a*m[3][3]);gl_FragColor = newColor + uColorMatrixOffset;}"}var b=createjs.extend(a,createjs.Filter);b.shaderParamSetup=function(a,b,c){var d=this.matrix,e=new Float32Array([d[0],d[1],d[2],d[3],d[5],d[6],d[7],d[8],d[10],d[11],d[12],d[13],d[15],d[16],d[17],d[18]]);a.uniformMatrix4fv(a.getUniformLocation(c,"uColorMatrix"),!1,e),a.uniform4f(a.getUniformLocation(c,"uColorMatrixOffset"),d[4]/255,d[9]/255,d[14]/255,d[19]/255)},b.toString=function(){return"[ColorMatrixFilter]"},b.clone=function(){return new a(this.matrix)},b._applyFilter=function(a){for(var b,c,d,e,f=a.data,g=f.length,h=this.matrix,i=h[0],j=h[1],k=h[2],l=h[3],m=h[4],n=h[5],o=h[6],p=h[7],q=h[8],r=h[9],s=h[10],t=h[11],u=h[12],v=h[13],w=h[14],x=h[15],y=h[16],z=h[17],A=h[18],B=h[19],C=0;C0||window.PointerEvent&&window.navigator.maxTouchPoints>0)},a.enable=function(b,c,d){return!!(b&&b.canvas&&a.isSupported())&&(!!b.__touch||(b.__touch={pointers:{},multitouch:!c,preventDefault:!d,count:0},"ontouchstart"in window?a._IOS_enable(b):(window.PointerEvent||window.MSPointerEvent)&&a._IE_enable(b),!0))},a.disable=function(b){b&&b.__touch&&("ontouchstart"in window?a._IOS_disable(b):(window.PointerEvent||window.MSPointerEvent)&&a._IE_disable(b),delete b.__touch)},a._IOS_enable=function(b){var c=b.canvas,d=b.__touch.f=function(c){a._IOS_handleEvent(b,c)};c.addEventListener("touchstart",d,!1),c.addEventListener("touchmove",d,!1),c.addEventListener("touchend",d,!1),c.addEventListener("touchcancel",d,!1)},a._IOS_disable=function(a){var b=a.canvas;if(b){var c=a.__touch.f;b.removeEventListener("touchstart",c,!1),b.removeEventListener("touchmove",c,!1),b.removeEventListener("touchend",c,!1),b.removeEventListener("touchcancel",c,!1)}},a._IOS_handleEvent=function(a,b){if(a){a.__touch.preventDefault&&b.preventDefault&&b.preventDefault();for(var c=b.changedTouches,d=b.type,e=0,f=c.length;e= 0.10.22" + "engine": "node >= 0.10.22", + "dependencies": { + "canvas": "^2.11.2" + } }