diff --git a/docs/EaselJS_docs-0.8.1.zip b/docs/EaselJS_docs-0.8.1.zip index d0bfe518c..b16d203fb 100644 Binary files a/docs/EaselJS_docs-0.8.1.zip and b/docs/EaselJS_docs-0.8.1.zip differ diff --git a/ellipticalArcDemo.htm b/ellipticalArcDemo.htm new file mode 100644 index 000000000..cc9fba880 --- /dev/null +++ b/ellipticalArcDemo.htm @@ -0,0 +1,99 @@ + + + +
+ + diff --git a/lib/easeljs-0.8.1.combined.js b/lib/easeljs-0.8.1.combined.js index d32fd5c64..1fd048864 100644 --- a/lib/easeljs-0.8.1.combined.js +++ b/lib/easeljs-0.8.1.combined.js @@ -1,385 +1,385 @@ -/*! -* EaselJS -* Visit http://createjs.com/ for documentation, updates and examples. -* -* Copyright (c) 2010 gskinner.com, inc. -* -* Permission is hereby granted, free of charge, to any person -* obtaining a copy of this software and associated documentation -* files (the "Software"), to deal in the Software without -* restriction, including without limitation the rights to use, -* copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the -* Software is furnished to do so, subject to the following -* conditions: -* -* The above copyright notice and this permission notice shall be -* included in all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -* OTHER DEALINGS IN THE SOFTWARE. -*/ +/*! +* EaselJS +* Visit http://createjs.com/ for documentation, updates and examples. +* +* Copyright (c) 2010 gskinner.com, inc. +* +* Permission is hereby granted, free of charge, to any person +* obtaining a copy of this software and associated documentation +* files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, +* copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following +* conditions: +* +* The above copyright notice and this permission notice shall be +* included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ //############################################################################## // extend.js //############################################################################## -this.createjs = this.createjs||{}; - -/** - * @class Utility Methods - */ - -/** - * Sets up the prototype chain and constructor property for a new class. - * - * This should be called right after creating the class constructor. - * - * function MySubClass() {} - * createjs.extend(MySubClass, MySuperClass); - * ClassB.prototype.doSomething = function() { } - * - * var foo = new MySubClass(); - * console.log(foo instanceof MySuperClass); // true - * console.log(foo.prototype.constructor === MySubClass); // true - * - * @method extend - * @param {Function} subclass The subclass. - * @param {Function} superclass The superclass to extend. - * @return {Function} Returns the subclass's new prototype. - */ -createjs.extend = function(subclass, superclass) { - "use strict"; - - function o() { this.constructor = subclass; } - o.prototype = superclass.prototype; - return (subclass.prototype = new o()); +this.createjs = this.createjs||{}; + +/** + * @class Utility Methods + */ + +/** + * Sets up the prototype chain and constructor property for a new class. + * + * This should be called right after creating the class constructor. + * + * function MySubClass() {} + * createjs.extend(MySubClass, MySuperClass); + * MySubClass.prototype.doSomething = function() { } + * + * var foo = new MySubClass(); + * console.log(foo instanceof MySuperClass); // true + * console.log(foo.prototype.constructor === MySubClass); // true + * + * @method extend + * @param {Function} subclass The subclass. + * @param {Function} superclass The superclass to extend. + * @return {Function} Returns the subclass's new prototype. + */ +createjs.extend = function(subclass, superclass) { + "use strict"; + + function o() { this.constructor = subclass; } + o.prototype = superclass.prototype; + return (subclass.prototype = new o()); }; //############################################################################## // promote.js //############################################################################## -this.createjs = this.createjs||{}; - -/** - * @class Utility Methods - */ - -/** - * Promotes any methods on the super class that were overridden, by creating an alias in the format `prefix_methodName`. - * It is recommended to use the super class's name as the prefix. - * An alias to the super class's constructor is always added in the format `prefix_constructor`. - * This allows the subclass to call super class methods without using `function.call`, providing better performance. - * - * For example, if `MySubClass` extends `MySuperClass`, and both define a `draw` method, then calling `promote(MySubClass, "MySuperClass")` - * would add a `MySuperClass_constructor` method to MySubClass and promote the `draw` method on `MySuperClass` to the - * prototype of `MySubClass` as `MySuperClass_draw`. - * - * This should be called after the class's prototype is fully defined. - * - * function ClassA(name) { - * this.name = name; - * } - * ClassA.prototype.greet = function() { - * return "Hello "+this.name; - * } - * - * function ClassB(name, punctuation) { - * this.ClassA_constructor(name); - * this.punctuation = punctuation; - * } - * createjs.extend(ClassB, ClassA); - * ClassB.prototype.greet = function() { - * return this.ClassA_greet()+this.punctuation; - * } - * createjs.promote(ClassB, "ClassA"); - * - * var foo = new ClassB("World", "!?!"); - * console.log(foo.greet()); // Hello World!?! - * - * @method promote - * @param {Function} subclass The class to promote super class methods on. - * @param {String} prefix The prefix to add to the promoted method names. Usually the name of the superclass. - * @return {Function} Returns the subclass. - */ -createjs.promote = function(subclass, prefix) { - "use strict"; - - var subP = subclass.prototype, supP = (Object.getPrototypeOf&&Object.getPrototypeOf(subP))||subP.__proto__; - if (supP) { - subP[(prefix+="_") + "constructor"] = supP.constructor; // constructor is not always innumerable - for (var n in supP) { - if (subP.hasOwnProperty(n) && (typeof supP[n] == "function")) { subP[prefix + n] = supP[n]; } - } - } - return subclass; +this.createjs = this.createjs||{}; + +/** + * @class Utility Methods + */ + +/** + * Promotes any methods on the super class that were overridden, by creating an alias in the format `prefix_methodName`. + * It is recommended to use the super class's name as the prefix. + * An alias to the super class's constructor is always added in the format `prefix_constructor`. + * This allows the subclass to call super class methods without using `function.call`, providing better performance. + * + * For example, if `MySubClass` extends `MySuperClass`, and both define a `draw` method, then calling `promote(MySubClass, "MySuperClass")` + * would add a `MySuperClass_constructor` method to MySubClass and promote the `draw` method on `MySuperClass` to the + * prototype of `MySubClass` as `MySuperClass_draw`. + * + * This should be called after the class's prototype is fully defined. + * + * function ClassA(name) { + * this.name = name; + * } + * ClassA.prototype.greet = function() { + * return "Hello "+this.name; + * } + * + * function ClassB(name, punctuation) { + * this.ClassA_constructor(name); + * this.punctuation = punctuation; + * } + * createjs.extend(ClassB, ClassA); + * ClassB.prototype.greet = function() { + * return this.ClassA_greet()+this.punctuation; + * } + * createjs.promote(ClassB, "ClassA"); + * + * var foo = new ClassB("World", "!?!"); + * console.log(foo.greet()); // Hello World!?! + * + * @method promote + * @param {Function} subclass The class to promote super class methods on. + * @param {String} prefix The prefix to add to the promoted method names. Usually the name of the superclass. + * @return {Function} Returns the subclass. + */ +createjs.promote = function(subclass, prefix) { + "use strict"; + + var subP = subclass.prototype, supP = (Object.getPrototypeOf&&Object.getPrototypeOf(subP))||subP.__proto__; + if (supP) { + subP[(prefix+="_") + "constructor"] = supP.constructor; // constructor is not always innumerable + for (var n in supP) { + if (subP.hasOwnProperty(n) && (typeof supP[n] == "function")) { subP[prefix + n] = supP[n]; } + } + } + return subclass; }; //############################################################################## // indexOf.js //############################################################################## -this.createjs = this.createjs||{}; - -/** - * @class Utility Methods - */ - -/** - * Finds the first occurrence of a specified value searchElement in the passed in array, and returns the index of - * that value. Returns -1 if value is not found. - * - * var i = createjs.indexOf(myArray, myElementToFind); - * - * @method indexOf - * @param {Array} array Array to search for searchElement - * @param searchElement Element to find in array. - * @return {Number} The first index of searchElement in array. - */ -createjs.indexOf = function (array, searchElement){ - "use strict"; - - for (var i = 0,l=array.length; i < l; i++) { - if (searchElement === array[i]) { - return i; - } - } - return -1; +this.createjs = this.createjs||{}; + +/** + * @class Utility Methods + */ + +/** + * Finds the first occurrence of a specified value searchElement in the passed in array, and returns the index of + * that value. Returns -1 if value is not found. + * + * var i = createjs.indexOf(myArray, myElementToFind); + * + * @method indexOf + * @param {Array} array Array to search for searchElement + * @param searchElement Element to find in array. + * @return {Number} The first index of searchElement in array. + */ +createjs.indexOf = function (array, searchElement){ + "use strict"; + + for (var i = 0,l=array.length; i < l; i++) { + if (searchElement === array[i]) { + return i; + } + } + return -1; }; //############################################################################## // Event.js //############################################################################## -this.createjs = this.createjs||{}; - -(function() { - "use strict"; - -// constructor: - /** - * Contains properties and methods shared by all events for use with - * {{#crossLink "EventDispatcher"}}{{/crossLink}}. - * - * Note that Event objects are often reused, so you should never - * 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. - * @constructor - **/ - function Event(type, bubbles, cancelable) { - - - // public properties: - /** - * The type of event. - * @property type - * @type String - **/ - this.type = type; - - /** - * The object that generated an event. - * @property target - * @type Object - * @default null - * @readonly - */ - this.target = null; - - /** - * The current target that a bubbling event is being dispatched from. For non-bubbling events, this will - * always be the same as target. For example, if childObj.parent = parentObj, and a bubbling event - * is generated from childObj, then a listener on parentObj would receive the event with - * target=childObj (the original target) and currentTarget=parentObj (where the listener was added). - * @property currentTarget - * @type Object - * @default null - * @readonly - */ - this.currentTarget = null; - - /** - * For bubbling events, this indicates the current event phase:paused
property
- * of the event will be `true`. Also, while paused the `runTime` will not increase. See {{#crossLink "Ticker/tick:event"}}{{/crossLink}},
- * {{#crossLink "Ticker/getTime"}}{{/crossLink}}, and {{#crossLink "Ticker/getEventTime"}}{{/crossLink}} for more
- * info.
- *
- * UID.get()
)
- * and should not be instantiated.
- * @class UID
- * @static
- **/
- function UID() {
- throw "UID cannot be instantiated";
- }
-
-
-// private static properties:
- /**
- * @property _nextID
- * @type Number
- * @protected
- **/
- UID._nextID = 0;
-
-
-// public static methods:
- /**
- * Returns the next unique id.
- * @method get
- * @return {Number} The next unique id
- * @static
- **/
- UID.get = function() {
- return UID._nextID++;
- };
-
-
- createjs.UID = UID;
-}());
-
-//##############################################################################
-// MouseEvent.js
-//##############################################################################
-
-this.createjs = this.createjs||{};
-
-(function() {
- "use strict";
-
-
-// constructor:
- /**
- * Passed as the parameter to all mouse/pointer/touch related events. For a listing of mouse events and their properties,
- * see the {{#crossLink "DisplayObject"}}{{/crossLink}} and {{#crossLink "Stage"}}{{/crossLink}} event listings.
- * @class MouseEvent
- * @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 {Number} stageX The normalized x position relative to the stage.
- * @param {Number} stageY The normalized y position relative to the stage.
- * @param {MouseEvent} nativeEvent The native DOM event related to this mouse event.
- * @param {Number} pointerID The unique id for the pointer.
- * @param {Boolean} primary Indicates whether this is the primary pointer in a multitouch environment.
- * @param {Number} rawX The raw x position relative to the stage.
- * @param {Number} rawY The raw y position relative to the stage.
- * @param {DisplayObject} relatedTarget The secondary target for the event.
- * @extends Event
- * @constructor
- **/
- function MouseEvent(type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {
- this.Event_constructor(type, bubbles, cancelable);
-
-
- // public properties:
- /**
- * The normalized x position on the stage. This will always be within the range 0 to stage width.
- * @property stageX
- * @type Number
- */
- this.stageX = stageX;
-
- /**
- * The normalized y position on the stage. This will always be within the range 0 to stage height.
- * @property stageY
- * @type Number
- **/
- this.stageY = stageY;
-
- /**
- * The raw x position relative to the stage. Normally this will be the same as the stageX value, unless
- * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
- * @property rawX
- * @type Number
- */
- this.rawX = (rawX==null)?stageX:rawX;
-
- /**
- * The raw y position relative to the stage. Normally this will be the same as the stageY value, unless
- * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
- * @property rawY
- * @type Number
- */
- this.rawY = (rawY==null)?stageY:rawY;
-
- /**
- * The native MouseEvent generated by the browser. The properties and API for this
- * event may differ between browsers. This property will be null if the
- * EaselJS property was not directly generated from a native MouseEvent.
- * @property nativeEvent
- * @type HtmlMouseEvent
- * @default null
- **/
- this.nativeEvent = nativeEvent;
-
- /**
- * The unique id for the pointer (touch point or cursor). This will be either -1 for the mouse, or the system
- * supplied id value.
- * @property pointerID
- * @type {Number}
- */
- this.pointerID = pointerID;
-
- /**
- * Indicates whether this is the primary pointer in a multitouch environment. This will always be true for the mouse.
- * For touch pointers, the first pointer in the current stack will be considered the primary pointer.
- * @property primary
- * @type {Boolean}
- */
- 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.
- *
- * Only valid interaction targets will be returned (ie. objects with mouse listeners or a cursor set).
- * @property relatedTarget
- * @type {DisplayObject}
- */
- this.relatedTarget = relatedTarget;
- }
- var p = createjs.extend(MouseEvent, createjs.Event);
-
- // TODO: deprecated
- // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
-
-
-// getter / setters:
- /**
- * Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
- * @property localX
- * @type {Number}
- * @readonly
- */
- p._get_localX = function() {
- return this.currentTarget.globalToLocal(this.rawX, this.rawY).x;
- };
-
- /**
- * Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
- * @property localY
- * @type {Number}
- * @readonly
- */
- p._get_localY = function() {
- return this.currentTarget.globalToLocal(this.rawX, this.rawY).y;
- };
-
- /**
- * Indicates whether the event was generated by a touch input (versus a mouse input).
- * @property isTouch
- * @type {Boolean}
- * @readonly
- */
- p._get_isTouch = function() {
- return this.pointerID !== -1;
- };
-
-
- try {
- Object.defineProperties(p, {
- localX: { get: p._get_localX },
- localY: { get: p._get_localY },
- isTouch: { get: p._get_isTouch }
- });
- } catch (e) {} // TODO: use Log
-
+this.createjs = this.createjs||{};
+
+(function() {
+ "use strict";
+
+
+// constructor:
+ /**
+ * The Ticker provides a centralized tick or heartbeat broadcast at a set interval. Listeners can subscribe to the tick
+ * event to be notified when a set time interval has elapsed.
+ *
+ * Note that the interval that the tick event is called is a target interval, and may be broadcast at a slower interval
+ * when under high CPU load. The Ticker class uses a static interface (ex. `Ticker.framerate = 30;`) and
+ * can not be instantiated.
+ *
+ * paused
property
+ * of the event will be `true`. Also, while paused the `runTime` will not increase. See {{#crossLink "Ticker/tick:event"}}{{/crossLink}},
+ * {{#crossLink "Ticker/getTime"}}{{/crossLink}}, and {{#crossLink "Ticker/getEventTime"}}{{/crossLink}} for more
+ * info.
+ *
+ * UID.get()
)
+ * and should not be instantiated.
+ * @class UID
+ * @static
+ **/
+ function UID() {
+ throw "UID cannot be instantiated";
+ }
+
+
+// private static properties:
+ /**
+ * @property _nextID
+ * @type Number
+ * @protected
+ **/
+ UID._nextID = 0;
+
+
+// public static methods:
+ /**
+ * Returns the next unique id.
+ * @method get
+ * @return {Number} The next unique id
+ * @static
+ **/
+ UID.get = function() {
+ return UID._nextID++;
+ };
+
+
+ createjs.UID = UID;
+}());
+//##############################################################################
+// MouseEvent.js
+//##############################################################################
- createjs.MouseEvent = createjs.promote(MouseEvent, "Event");
+this.createjs = this.createjs||{};
+
+(function() {
+ "use strict";
+
+
+// constructor:
+ /**
+ * Passed as the parameter to all mouse/pointer/touch related events. For a listing of mouse events and their properties,
+ * see the {{#crossLink "DisplayObject"}}{{/crossLink}} and {{#crossLink "Stage"}}{{/crossLink}} event listings.
+ * @class MouseEvent
+ * @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 {Number} stageX The normalized x position relative to the stage.
+ * @param {Number} stageY The normalized y position relative to the stage.
+ * @param {MouseEvent} nativeEvent The native DOM event related to this mouse event.
+ * @param {Number} pointerID The unique id for the pointer.
+ * @param {Boolean} primary Indicates whether this is the primary pointer in a multitouch environment.
+ * @param {Number} rawX The raw x position relative to the stage.
+ * @param {Number} rawY The raw y position relative to the stage.
+ * @param {DisplayObject} relatedTarget The secondary target for the event.
+ * @extends Event
+ * @constructor
+ **/
+ function MouseEvent(type, bubbles, cancelable, stageX, stageY, nativeEvent, pointerID, primary, rawX, rawY, relatedTarget) {
+ this.Event_constructor(type, bubbles, cancelable);
+
+
+ // public properties:
+ /**
+ * The normalized x position on the stage. This will always be within the range 0 to stage width.
+ * @property stageX
+ * @type Number
+ */
+ this.stageX = stageX;
+
+ /**
+ * The normalized y position on the stage. This will always be within the range 0 to stage height.
+ * @property stageY
+ * @type Number
+ **/
+ this.stageY = stageY;
+
+ /**
+ * The raw x position relative to the stage. Normally this will be the same as the stageX value, unless
+ * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
+ * @property rawX
+ * @type Number
+ */
+ this.rawX = (rawX==null)?stageX:rawX;
+
+ /**
+ * The raw y position relative to the stage. Normally this will be the same as the stageY value, unless
+ * stage.mouseMoveOutside is true and the pointer is outside of the stage bounds.
+ * @property rawY
+ * @type Number
+ */
+ this.rawY = (rawY==null)?stageY:rawY;
+
+ /**
+ * The native MouseEvent generated by the browser. The properties and API for this
+ * event may differ between browsers. This property will be null if the
+ * EaselJS property was not directly generated from a native MouseEvent.
+ * @property nativeEvent
+ * @type HtmlMouseEvent
+ * @default null
+ **/
+ this.nativeEvent = nativeEvent;
+
+ /**
+ * The unique id for the pointer (touch point or cursor). This will be either -1 for the mouse, or the system
+ * supplied id value.
+ * @property pointerID
+ * @type {Number}
+ */
+ this.pointerID = pointerID;
+
+ /**
+ * Indicates whether this is the primary pointer in a multitouch environment. This will always be true for the mouse.
+ * For touch pointers, the first pointer in the current stack will be considered the primary pointer.
+ * @property primary
+ * @type {Boolean}
+ */
+ 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.
+ *
+ * Only valid interaction targets will be returned (ie. objects with mouse listeners or a cursor set).
+ * @property relatedTarget
+ * @type {DisplayObject}
+ */
+ this.relatedTarget = relatedTarget;
+ }
+ var p = createjs.extend(MouseEvent, createjs.Event);
+
+ // TODO: deprecated
+ // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
+
+
+// getter / setters:
+ /**
+ * Returns the x position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
+ * @property localX
+ * @type {Number}
+ * @readonly
+ */
+ p._get_localX = function() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).x;
+ };
+
+ /**
+ * Returns the y position of the mouse in the local coordinate system of the current target (ie. the dispatcher).
+ * @property localY
+ * @type {Number}
+ * @readonly
+ */
+ p._get_localY = function() {
+ return this.currentTarget.globalToLocal(this.rawX, this.rawY).y;
+ };
+
+ /**
+ * Indicates whether the event was generated by a touch input (versus a mouse input).
+ * @property isTouch
+ * @type {Boolean}
+ * @readonly
+ */
+ p._get_isTouch = function() {
+ return this.pointerID !== -1;
+ };
+
+
+ try {
+ Object.defineProperties(p, {
+ localX: { get: p._get_localX },
+ localY: { get: p._get_localY },
+ isTouch: { get: p._get_isTouch }
+ });
+ } catch (e) {} // TODO: use Log
+
+
+// public methods:
+ /**
+ * Returns a clone of the MouseEvent instance.
+ * @method clone
+ * @return {MouseEvent} a clone of the MouseEvent instance.
+ **/
+ p.clone = function() {
+ return new MouseEvent(this.type, this.bubbles, this.cancelable, this.stageX, this.stageY, this.nativeEvent, this.pointerID, this.primary, this.rawX, this.rawY);
+ };
+
+ /**
+ * Returns a string representation of this object.
+ * @method toString
+ * @return {String} a string representation of the instance.
+ **/
+ p.toString = function() {
+ return "[MouseEvent (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]";
+ };
+
+
+ createjs.MouseEvent = createjs.promote(MouseEvent, "Event");
}());
//##############################################################################
// Matrix2D.js
//##############################################################################
-this.createjs = this.createjs||{};
-
-(function() {
- "use strict";
-
-
-// constructor:
- /**
- * Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.
- *
- * This matrix can be visualized as:
- *
- * [ a c tx
- * b d ty
- * 0 0 1 ]
- *
- * Note the locations of b and c.
- *
- * @class Matrix2D
- * @param {Number} [a=1] Specifies the a property for the new matrix.
- * @param {Number} [b=0] Specifies the b property for the new matrix.
- * @param {Number} [c=0] Specifies the c property for the new matrix.
- * @param {Number} [d=1] Specifies the d property for the new matrix.
- * @param {Number} [tx=0] Specifies the tx property for the new matrix.
- * @param {Number} [ty=0] Specifies the ty property for the new matrix.
- * @constructor
- **/
- function Matrix2D(a, b, c, d, tx, ty) {
- this.setValues(a,b,c,d,tx,ty);
-
- // public properties:
- // assigned in the setValues method.
- /**
- * Position (0, 0) in a 3x3 affine transformation matrix.
- * @property a
- * @type Number
- **/
-
- /**
- * Position (0, 1) in a 3x3 affine transformation matrix.
- * @property b
- * @type Number
- **/
-
- /**
- * Position (1, 0) in a 3x3 affine transformation matrix.
- * @property c
- * @type Number
- **/
-
- /**
- * Position (1, 1) in a 3x3 affine transformation matrix.
- * @property d
- * @type Number
- **/
-
- /**
- * Position (2, 0) in a 3x3 affine transformation matrix.
- * @property tx
- * @type Number
- **/
-
- /**
- * Position (2, 1) in a 3x3 affine transformation matrix.
- * @property ty
- * @type Number
- **/
- }
- var p = Matrix2D.prototype;
-
- /**
- * REMOVED. Removed in favor of using `MySuperClass_constructor`.
- * See {{#crossLink "Utility Methods/extend"}}{{/crossLink}} and {{#crossLink "Utility Methods/promote"}}{{/crossLink}}
- * for details.
- *
- * There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.
- *
- * @method initialize
- * @protected
- * @deprecated
- */
- // p.initialize = function() {}; // searchable for devs wondering where it is.
-
-
-// constants:
- /**
- * Multiplier for converting degrees to radians. Used internally by Matrix2D.
- * @property DEG_TO_RAD
- * @static
- * @final
- * @type Number
- * @readonly
- **/
- Matrix2D.DEG_TO_RAD = Math.PI/180;
-
-
-// static public properties:
- /**
- * An identity matrix, representing a null transformation.
- * @property identity
- * @static
- * @type Matrix2D
- * @readonly
- **/
- Matrix2D.identity = null; // set at bottom of class definition.
-
-
-// public methods:
- /**
- * Sets the specified values on this instance.
- * @method setValues
- * @param {Number} [a=1] Specifies the a property for the new matrix.
- * @param {Number} [b=0] Specifies the b property for the new matrix.
- * @param {Number} [c=0] Specifies the c property for the new matrix.
- * @param {Number} [d=1] Specifies the d property for the new matrix.
- * @param {Number} [tx=0] Specifies the tx property for the new matrix.
- * @param {Number} [ty=0] Specifies the ty property for the new matrix.
- * @return {Matrix2D} This instance. Useful for chaining method calls.
- */
- p.setValues = function(a, b, c, d, tx, ty) {
- // don't forget to update docs in the constructor if these change:
- this.a = (a == null) ? 1 : a;
- this.b = b || 0;
- this.c = c || 0;
- this.d = (d == null) ? 1 : d;
- this.tx = tx || 0;
- this.ty = ty || 0;
- return this;
- };
-
- /**
- * Appends the specified matrix properties to this matrix. All parameters are required.
- * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.
- * @method append
- * @param {Number} a
- * @param {Number} b
- * @param {Number} c
- * @param {Number} d
- * @param {Number} tx
- * @param {Number} ty
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.append = function(a, b, c, d, tx, ty) {
- var a1 = this.a;
- var b1 = this.b;
- var c1 = this.c;
- var d1 = this.d;
- if (a != 1 || b != 0 || c != 0 || d != 1) {
- this.a = a1*a+c1*b;
- this.b = b1*a+d1*b;
- this.c = a1*c+c1*d;
- this.d = b1*c+d1*d;
- }
- this.tx = a1*tx+c1*ty+this.tx;
- this.ty = b1*tx+d1*ty+this.ty;
- return this;
- };
-
- /**
- * Prepends the specified matrix properties to this matrix.
- * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
- * All parameters are required.
- * @method prepend
- * @param {Number} a
- * @param {Number} b
- * @param {Number} c
- * @param {Number} d
- * @param {Number} tx
- * @param {Number} ty
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.prepend = function(a, b, c, d, tx, ty) {
- var a1 = this.a;
- var c1 = this.c;
- var tx1 = this.tx;
-
- this.a = a*a1+c*this.b;
- this.b = b*a1+d*this.b;
- this.c = a*c1+c*this.d;
- this.d = b*c1+d*this.d;
- this.tx = a*tx1+c*this.ty+tx;
- this.ty = b*tx1+d*this.ty+ty;
- return this;
- };
-
- /**
- * Appends the specified matrix to this matrix.
- * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.
- * @method appendMatrix
- * @param {Matrix2D} matrix
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.appendMatrix = function(matrix) {
- return this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
- };
-
- /**
- * Prepends the specified matrix to this matrix.
- * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
- * For example, you could calculate the combined transformation for a child object using:
- *
- * var o = myDisplayObject;
- * var mtx = o.getMatrix();
- * while (o = o.parent) {
- * // prepend each parent's transformation in turn:
- * o.prependMatrix(o.getMatrix());
- * }
- * @method prependMatrix
- * @param {Matrix2D} matrix
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.prependMatrix = function(matrix) {
- return this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
- };
-
- /**
- * Generates matrix properties from the specified display object transform properties, and appends them to this matrix.
- * For example, you can use this to generate a matrix representing the transformations of a display object:
- *
- * var mtx = new Matrix2D();
- * mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);
- * @method appendTransform
- * @param {Number} x
- * @param {Number} y
- * @param {Number} scaleX
- * @param {Number} scaleY
- * @param {Number} rotation
- * @param {Number} skewX
- * @param {Number} skewY
- * @param {Number} regX Optional.
- * @param {Number} regY Optional.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.appendTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
- if (rotation%360) {
- var r = rotation*Matrix2D.DEG_TO_RAD;
- var cos = Math.cos(r);
- var sin = Math.sin(r);
- } else {
- cos = 1;
- sin = 0;
- }
-
- if (skewX || skewY) {
- // TODO: can this be combined into a single append operation?
- skewX *= Matrix2D.DEG_TO_RAD;
- skewY *= Matrix2D.DEG_TO_RAD;
- this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
- this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
- } else {
- this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
- }
-
- if (regX || regY) {
- // append the registration offset:
- this.tx -= regX*this.a+regY*this.c;
- this.ty -= regX*this.b+regY*this.d;
- }
- return this;
- };
-
- /**
- * Generates matrix properties from the specified display object transform properties, and prepends them to this matrix.
- * For example, you could calculate the combined transformation for a child object using:
- *
- * var o = myDisplayObject;
- * var mtx = new createjs.Matrix2D();
- * do {
- * // prepend each parent's transformation in turn:
- * mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
- * } while (o = o.parent);
- *
- * Note that the above example would not account for {{#crossLink "DisplayObject/transformMatrix:property"}}{{/crossLink}}
- * values. See {{#crossLink "Matrix2D/prependMatrix"}}{{/crossLink}} for an example that does.
- * @method prependTransform
- * @param {Number} x
- * @param {Number} y
- * @param {Number} scaleX
- * @param {Number} scaleY
- * @param {Number} rotation
- * @param {Number} skewX
- * @param {Number} skewY
- * @param {Number} regX Optional.
- * @param {Number} regY Optional.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.prependTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
- if (rotation%360) {
- var r = rotation*Matrix2D.DEG_TO_RAD;
- var cos = Math.cos(r);
- var sin = Math.sin(r);
- } else {
- cos = 1;
- sin = 0;
- }
-
- if (regX || regY) {
- // prepend the registration offset:
- this.tx -= regX; this.ty -= regY;
- }
- if (skewX || skewY) {
- // TODO: can this be combined into a single prepend operation?
- skewX *= Matrix2D.DEG_TO_RAD;
- skewY *= Matrix2D.DEG_TO_RAD;
- this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
- this.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
- } else {
- this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
- }
- return this;
- };
-
- /**
- * 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`.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.rotate = function(angle) {
- angle = angle*Matrix2D.DEG_TO_RAD;
- var cos = Math.cos(angle);
- var sin = Math.sin(angle);
-
- var a1 = this.a;
- var b1 = this.b;
-
- this.a = a1*cos+this.c*sin;
- this.b = b1*cos+this.d*sin;
- this.c = -a1*sin+this.c*cos;
- this.d = -b1*sin+this.d*cos;
- return this;
- };
-
- /**
- * 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} skewY The amount to skew vertically in degrees.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- */
- p.skew = function(skewX, skewY) {
- skewX = skewX*Matrix2D.DEG_TO_RAD;
- skewY = skewY*Matrix2D.DEG_TO_RAD;
- this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);
- return this;
- };
-
- /**
- * Applies a scale transformation to the matrix.
- * @method scale
- * @param {Number} x The amount to scale horizontally. E.G. a value of 2 will double the size in the X direction, and 0.5 will halve it.
- * @param {Number} y The amount to scale vertically.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.scale = function(x, y) {
- this.a *= x;
- this.b *= x;
- this.c *= y;
- this.d *= y;
- //this.tx *= x;
- //this.ty *= y;
- return this;
- };
-
- /**
- * Translates the matrix on the x and y axes.
- * @method translate
- * @param {Number} x
- * @param {Number} y
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.translate = function(x, y) {
- this.tx += this.a*x + this.c*y;
- this.ty += this.b*x + this.d*y;
- return this;
- };
-
- /**
- * Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).
- * @method identity
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.identity = function() {
- this.a = this.d = 1;
- this.b = this.c = this.tx = this.ty = 0;
- return this;
- };
-
- /**
- * Inverts the matrix, causing it to perform the opposite transformation.
- * @method invert
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- **/
- p.invert = function() {
- var a1 = this.a;
- var b1 = this.b;
- var c1 = this.c;
- var d1 = this.d;
- var tx1 = this.tx;
- var n = a1*d1-b1*c1;
-
- this.a = d1/n;
- this.b = -b1/n;
- this.c = -c1/n;
- this.d = a1/n;
- this.tx = (c1*this.ty-d1*tx1)/n;
- this.ty = -(a1*this.ty-b1*tx1)/n;
- return this;
- };
-
- /**
- * Returns true if the matrix is an identity matrix.
- * @method isIdentity
- * @return {Boolean}
- **/
- p.isIdentity = function() {
- return this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;
- };
-
- /**
- * Returns true if this matrix is equal to the specified matrix (all property values are equal).
- * @method equals
- * @param {Matrix2D} matrix The matrix to compare.
- * @return {Boolean}
- **/
- p.equals = function(matrix) {
- return this.tx === matrix.tx && this.ty === matrix.ty && this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d;
- };
-
- /**
- * Transforms a point according to this matrix.
- * @method transformPoint
- * @param {Number} x The x component of the point to transform.
- * @param {Number} y The y component of the point to transform.
- * @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
- * @return {Point} This matrix. Useful for chaining method calls.
- **/
- p.transformPoint = function(x, y, pt) {
- pt = pt||{};
- pt.x = x*this.a+y*this.c+this.tx;
- pt.y = x*this.b+y*this.d+this.ty;
- return pt;
- };
-
- /**
- * Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values
- * may not match the transform properties you used to generate the matrix, though they will produce the same visual
- * results.
- * @method decompose
- * @param {Object} target The object to apply the transform properties to. If null, then a new object will be returned.
- * @return {Object} The target, or a new generic object with the transform properties applied.
- */
- p.decompose = function(target) {
- // TODO: it would be nice to be able to solve for whether the matrix can be decomposed into only scale/rotation even when scale is negative
- if (target == null) { target = {}; }
- target.x = this.tx;
- target.y = this.ty;
- target.scaleX = Math.sqrt(this.a * this.a + this.b * this.b);
- target.scaleY = Math.sqrt(this.c * this.c + this.d * this.d);
-
- var skewX = Math.atan2(-this.c, this.d);
- var skewY = Math.atan2(this.b, this.a);
-
- var delta = Math.abs(1-skewX/skewY);
- if (delta < 0.00001) { // effectively identical, can use rotation:
- target.rotation = skewY/Matrix2D.DEG_TO_RAD;
- if (this.a < 0 && this.d >= 0) {
- target.rotation += (target.rotation <= 0) ? 180 : -180;
- }
- target.skewX = target.skewY = 0;
- } else {
- target.skewX = skewX/Matrix2D.DEG_TO_RAD;
- target.skewY = skewY/Matrix2D.DEG_TO_RAD;
- }
- return target;
- };
-
- /**
- * Copies all properties from the specified matrix to this matrix.
- * @method copy
- * @param {Matrix2D} matrix The matrix to copy properties from.
- * @return {Matrix2D} This matrix. Useful for chaining method calls.
- */
- p.copy = function(matrix) {
- return this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
- };
-
- /**
- * Returns a clone of the Matrix2D instance.
- * @method clone
- * @return {Matrix2D} a clone of the Matrix2D instance.
- **/
- p.clone = function() {
- return new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);
- };
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {String} a string representation of the instance.
- **/
- p.toString = function() {
- return "[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]";
- };
-
- // this has to be populated after the class is defined:
- Matrix2D.identity = new Matrix2D();
-
-
- createjs.Matrix2D = Matrix2D;
+this.createjs = this.createjs||{};
+
+(function() {
+ "use strict";
+
+
+// constructor:
+ /**
+ * Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.
+ *
+ * This matrix can be visualized as:
+ *
+ * [ a c tx
+ * b d ty
+ * 0 0 1 ]
+ *
+ * Note the locations of b and c.
+ *
+ * @class Matrix2D
+ * @param {Number} [a=1] Specifies the a property for the new matrix.
+ * @param {Number} [b=0] Specifies the b property for the new matrix.
+ * @param {Number} [c=0] Specifies the c property for the new matrix.
+ * @param {Number} [d=1] Specifies the d property for the new matrix.
+ * @param {Number} [tx=0] Specifies the tx property for the new matrix.
+ * @param {Number} [ty=0] Specifies the ty property for the new matrix.
+ * @constructor
+ **/
+ function Matrix2D(a, b, c, d, tx, ty) {
+ this.setValues(a,b,c,d,tx,ty);
+
+ // public properties:
+ // assigned in the setValues method.
+ /**
+ * Position (0, 0) in a 3x3 affine transformation matrix.
+ * @property a
+ * @type Number
+ **/
+
+ /**
+ * Position (0, 1) in a 3x3 affine transformation matrix.
+ * @property b
+ * @type Number
+ **/
+
+ /**
+ * Position (1, 0) in a 3x3 affine transformation matrix.
+ * @property c
+ * @type Number
+ **/
+
+ /**
+ * Position (1, 1) in a 3x3 affine transformation matrix.
+ * @property d
+ * @type Number
+ **/
+
+ /**
+ * Position (2, 0) in a 3x3 affine transformation matrix.
+ * @property tx
+ * @type Number
+ **/
+
+ /**
+ * Position (2, 1) in a 3x3 affine transformation matrix.
+ * @property ty
+ * @type Number
+ **/
+ }
+ var p = Matrix2D.prototype;
+
+ /**
+ * REMOVED. Removed in favor of using `MySuperClass_constructor`.
+ * See {{#crossLink "Utility Methods/extend"}}{{/crossLink}} and {{#crossLink "Utility Methods/promote"}}{{/crossLink}}
+ * for details.
+ *
+ * There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.
+ *
+ * @method initialize
+ * @protected
+ * @deprecated
+ */
+ // p.initialize = function() {}; // searchable for devs wondering where it is.
+
+
+// constants:
+ /**
+ * Multiplier for converting degrees to radians. Used internally by Matrix2D.
+ * @property DEG_TO_RAD
+ * @static
+ * @final
+ * @type Number
+ * @readonly
+ **/
+ Matrix2D.DEG_TO_RAD = Math.PI/180;
+
+
+// static public properties:
+ /**
+ * An identity matrix, representing a null transformation.
+ * @property identity
+ * @static
+ * @type Matrix2D
+ * @readonly
+ **/
+ Matrix2D.identity = null; // set at bottom of class definition.
+
+
+// public methods:
+ /**
+ * Sets the specified values on this instance.
+ * @method setValues
+ * @param {Number} [a=1] Specifies the a property for the new matrix.
+ * @param {Number} [b=0] Specifies the b property for the new matrix.
+ * @param {Number} [c=0] Specifies the c property for the new matrix.
+ * @param {Number} [d=1] Specifies the d property for the new matrix.
+ * @param {Number} [tx=0] Specifies the tx property for the new matrix.
+ * @param {Number} [ty=0] Specifies the ty property for the new matrix.
+ * @return {Matrix2D} This instance. Useful for chaining method calls.
+ */
+ p.setValues = function(a, b, c, d, tx, ty) {
+ // don't forget to update docs in the constructor if these change:
+ this.a = (a == null) ? 1 : a;
+ this.b = b || 0;
+ this.c = c || 0;
+ this.d = (d == null) ? 1 : d;
+ this.tx = tx || 0;
+ this.ty = ty || 0;
+ return this;
+ };
+
+ /**
+ * Appends the specified matrix properties to this matrix. All parameters are required.
+ * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.
+ * @method append
+ * @param {Number} a
+ * @param {Number} b
+ * @param {Number} c
+ * @param {Number} d
+ * @param {Number} tx
+ * @param {Number} ty
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.append = function(a, b, c, d, tx, ty) {
+ var a1 = this.a;
+ var b1 = this.b;
+ var c1 = this.c;
+ var d1 = this.d;
+ if (a != 1 || b != 0 || c != 0 || d != 1) {
+ this.a = a1*a+c1*b;
+ this.b = b1*a+d1*b;
+ this.c = a1*c+c1*d;
+ this.d = b1*c+d1*d;
+ }
+ this.tx = a1*tx+c1*ty+this.tx;
+ this.ty = b1*tx+d1*ty+this.ty;
+ return this;
+ };
+
+ /**
+ * Prepends the specified matrix properties to this matrix.
+ * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
+ * All parameters are required.
+ * @method prepend
+ * @param {Number} a
+ * @param {Number} b
+ * @param {Number} c
+ * @param {Number} d
+ * @param {Number} tx
+ * @param {Number} ty
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.prepend = function(a, b, c, d, tx, ty) {
+ var a1 = this.a;
+ var c1 = this.c;
+ var tx1 = this.tx;
+
+ this.a = a*a1+c*this.b;
+ this.b = b*a1+d*this.b;
+ this.c = a*c1+c*this.d;
+ this.d = b*c1+d*this.d;
+ this.tx = a*tx1+c*this.ty+tx;
+ this.ty = b*tx1+d*this.ty+ty;
+ return this;
+ };
+
+ /**
+ * Appends the specified matrix to this matrix.
+ * This is the equivalent of multiplying `(this matrix) * (specified matrix)`.
+ * @method appendMatrix
+ * @param {Matrix2D} matrix
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.appendMatrix = function(matrix) {
+ return this.append(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+
+ /**
+ * Prepends the specified matrix to this matrix.
+ * This is the equivalent of multiplying `(specified matrix) * (this matrix)`.
+ * For example, you could calculate the combined transformation for a child object using:
+ *
+ * var o = myDisplayObject;
+ * var mtx = o.getMatrix();
+ * while (o = o.parent) {
+ * // prepend each parent's transformation in turn:
+ * o.prependMatrix(o.getMatrix());
+ * }
+ * @method prependMatrix
+ * @param {Matrix2D} matrix
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.prependMatrix = function(matrix) {
+ return this.prepend(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+
+ /**
+ * Generates matrix properties from the specified display object transform properties, and appends them to this matrix.
+ * For example, you can use this to generate a matrix representing the transformations of a display object:
+ *
+ * var mtx = new createjs.Matrix2D();
+ * mtx.appendTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation);
+ * @method appendTransform
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} scaleX
+ * @param {Number} scaleY
+ * @param {Number} rotation
+ * @param {Number} skewX
+ * @param {Number} skewY
+ * @param {Number} regX Optional.
+ * @param {Number} regY Optional.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.appendTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ if (rotation%360) {
+ var r = rotation*Matrix2D.DEG_TO_RAD;
+ var cos = Math.cos(r);
+ var sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+
+ if (skewX || skewY) {
+ // TODO: can this be combined into a single append operation?
+ skewX *= Matrix2D.DEG_TO_RAD;
+ skewY *= Matrix2D.DEG_TO_RAD;
+ this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
+ this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
+ } else {
+ this.append(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
+ }
+
+ if (regX || regY) {
+ // append the registration offset:
+ this.tx -= regX*this.a+regY*this.c;
+ this.ty -= regX*this.b+regY*this.d;
+ }
+ return this;
+ };
+
+ /**
+ * Generates matrix properties from the specified display object transform properties, and prepends them to this matrix.
+ * For example, you could calculate the combined transformation for a child object using:
+ *
+ * var o = myDisplayObject;
+ * var mtx = new createjs.Matrix2D();
+ * do {
+ * // prepend each parent's transformation in turn:
+ * mtx.prependTransform(o.x, o.y, o.scaleX, o.scaleY, o.rotation, o.skewX, o.skewY, o.regX, o.regY);
+ * } while (o = o.parent);
+ *
+ * Note that the above example would not account for {{#crossLink "DisplayObject/transformMatrix:property"}}{{/crossLink}}
+ * values. See {{#crossLink "Matrix2D/prependMatrix"}}{{/crossLink}} for an example that does.
+ * @method prependTransform
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} scaleX
+ * @param {Number} scaleY
+ * @param {Number} rotation
+ * @param {Number} skewX
+ * @param {Number} skewY
+ * @param {Number} regX Optional.
+ * @param {Number} regY Optional.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.prependTransform = function(x, y, scaleX, scaleY, rotation, skewX, skewY, regX, regY) {
+ if (rotation%360) {
+ var r = rotation*Matrix2D.DEG_TO_RAD;
+ var cos = Math.cos(r);
+ var sin = Math.sin(r);
+ } else {
+ cos = 1;
+ sin = 0;
+ }
+
+ if (regX || regY) {
+ // prepend the registration offset:
+ this.tx -= regX; this.ty -= regY;
+ }
+ if (skewX || skewY) {
+ // TODO: can this be combined into a single prepend operation?
+ skewX *= Matrix2D.DEG_TO_RAD;
+ skewY *= Matrix2D.DEG_TO_RAD;
+ this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, 0, 0);
+ this.prepend(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), x, y);
+ } else {
+ this.prepend(cos*scaleX, sin*scaleX, -sin*scaleY, cos*scaleY, x, y);
+ }
+ return this;
+ };
+
+ /**
+ * 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`.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.rotate = function(angle) {
+ angle = angle*Matrix2D.DEG_TO_RAD;
+ var cos = Math.cos(angle);
+ var sin = Math.sin(angle);
+
+ var a1 = this.a;
+ var b1 = this.b;
+
+ this.a = a1*cos+this.c*sin;
+ this.b = b1*cos+this.d*sin;
+ this.c = -a1*sin+this.c*cos;
+ this.d = -b1*sin+this.d*cos;
+ return this;
+ };
+
+ /**
+ * 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} skewY The amount to skew vertically in degrees.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ */
+ p.skew = function(skewX, skewY) {
+ skewX = skewX*Matrix2D.DEG_TO_RAD;
+ skewY = skewY*Matrix2D.DEG_TO_RAD;
+ this.append(Math.cos(skewY), Math.sin(skewY), -Math.sin(skewX), Math.cos(skewX), 0, 0);
+ return this;
+ };
+
+ /**
+ * Applies a scale transformation to the matrix.
+ * @method scale
+ * @param {Number} x The amount to scale horizontally. E.G. a value of 2 will double the size in the X direction, and 0.5 will halve it.
+ * @param {Number} y The amount to scale vertically.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.scale = function(x, y) {
+ this.a *= x;
+ this.b *= x;
+ this.c *= y;
+ this.d *= y;
+ //this.tx *= x;
+ //this.ty *= y;
+ return this;
+ };
+
+ /**
+ * Translates the matrix on the x and y axes.
+ * @method translate
+ * @param {Number} x
+ * @param {Number} y
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.translate = function(x, y) {
+ this.tx += this.a*x + this.c*y;
+ this.ty += this.b*x + this.d*y;
+ return this;
+ };
+
+ /**
+ * Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).
+ * @method identity
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.identity = function() {
+ this.a = this.d = 1;
+ this.b = this.c = this.tx = this.ty = 0;
+ return this;
+ };
+
+ /**
+ * Inverts the matrix, causing it to perform the opposite transformation.
+ * @method invert
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ **/
+ p.invert = function() {
+ var a1 = this.a;
+ var b1 = this.b;
+ var c1 = this.c;
+ var d1 = this.d;
+ var tx1 = this.tx;
+ var n = a1*d1-b1*c1;
+
+ this.a = d1/n;
+ this.b = -b1/n;
+ this.c = -c1/n;
+ this.d = a1/n;
+ this.tx = (c1*this.ty-d1*tx1)/n;
+ this.ty = -(a1*this.ty-b1*tx1)/n;
+ return this;
+ };
+
+ /**
+ * Returns true if the matrix is an identity matrix.
+ * @method isIdentity
+ * @return {Boolean}
+ **/
+ p.isIdentity = function() {
+ return this.tx === 0 && this.ty === 0 && this.a === 1 && this.b === 0 && this.c === 0 && this.d === 1;
+ };
+
+ /**
+ * Returns true if this matrix is equal to the specified matrix (all property values are equal).
+ * @method equals
+ * @param {Matrix2D} matrix The matrix to compare.
+ * @return {Boolean}
+ **/
+ p.equals = function(matrix) {
+ return this.tx === matrix.tx && this.ty === matrix.ty && this.a === matrix.a && this.b === matrix.b && this.c === matrix.c && this.d === matrix.d;
+ };
+
+ /**
+ * Transforms a point according to this matrix.
+ * @method transformPoint
+ * @param {Number} x The x component of the point to transform.
+ * @param {Number} y The y component of the point to transform.
+ * @param {Point | Object} [pt] An object to copy the result into. If omitted a generic object with x/y properties will be returned.
+ * @return {Point} This matrix. Useful for chaining method calls.
+ **/
+ p.transformPoint = function(x, y, pt) {
+ pt = pt||{};
+ pt.x = x*this.a+y*this.c+this.tx;
+ pt.y = x*this.b+y*this.d+this.ty;
+ return pt;
+ };
+
+ /**
+ * Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values
+ * may not match the transform properties you used to generate the matrix, though they will produce the same visual
+ * results.
+ * @method decompose
+ * @param {Object} target The object to apply the transform properties to. If null, then a new object will be returned.
+ * @return {Object} The target, or a new generic object with the transform properties applied.
+ */
+ p.decompose = function(target) {
+ // TODO: it would be nice to be able to solve for whether the matrix can be decomposed into only scale/rotation even when scale is negative
+ if (target == null) { target = {}; }
+ target.x = this.tx;
+ target.y = this.ty;
+ target.scaleX = Math.sqrt(this.a * this.a + this.b * this.b);
+ target.scaleY = Math.sqrt(this.c * this.c + this.d * this.d);
+
+ var skewX = Math.atan2(-this.c, this.d);
+ var skewY = Math.atan2(this.b, this.a);
+
+ var delta = Math.abs(1-skewX/skewY);
+ if (delta < 0.00001) { // effectively identical, can use rotation:
+ target.rotation = skewY/Matrix2D.DEG_TO_RAD;
+ if (this.a < 0 && this.d >= 0) {
+ target.rotation += (target.rotation <= 0) ? 180 : -180;
+ }
+ target.skewX = target.skewY = 0;
+ } else {
+ target.skewX = skewX/Matrix2D.DEG_TO_RAD;
+ target.skewY = skewY/Matrix2D.DEG_TO_RAD;
+ }
+ return target;
+ };
+
+ /**
+ * Copies all properties from the specified matrix to this matrix.
+ * @method copy
+ * @param {Matrix2D} matrix The matrix to copy properties from.
+ * @return {Matrix2D} This matrix. Useful for chaining method calls.
+ */
+ p.copy = function(matrix) {
+ return this.setValues(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty);
+ };
+
+ /**
+ * Returns a clone of the Matrix2D instance.
+ * @method clone
+ * @return {Matrix2D} a clone of the Matrix2D instance.
+ **/
+ p.clone = function() {
+ return new Matrix2D(this.a, this.b, this.c, this.d, this.tx, this.ty);
+ };
+
+ /**
+ * Returns a string representation of this object.
+ * @method toString
+ * @return {String} a string representation of the instance.
+ **/
+ p.toString = function() {
+ return "[Matrix2D (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]";
+ };
+
+ // this has to be populated after the class is defined:
+ Matrix2D.identity = new Matrix2D();
+
+
+ createjs.Matrix2D = Matrix2D;
}());
//##############################################################################
// DisplayProps.js
//##############################################################################
-this.createjs = this.createjs||{};
-
-(function() {
- "use strict";
-
- /**
- * Used for calculating and encapsulating display related properties.
- * @class DisplayProps
- * @param {Number} [visible=true] Visible value.
- * @param {Number} [alpha=0] Alpha value.
- * @param {Number} [shadow=null] A Shadow instance or null.
- * @param {Number} [compositeOperation=null] A compositeOperation value or null.
- * @param {Number} [matrix] A transformation matrix. Defaults to a new identity matrix.
- * @constructor
- **/
- function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
- this.setValues(visible, alpha, shadow, compositeOperation, matrix);
-
- // public properties:
- // assigned in the setValues method.
- /**
- * Property representing the alpha that will be applied to a display object.
- * @property alpha
- * @type Number
- **/
-
- /**
- * Property representing the shadow that will be applied to a display object.
- * @property shadow
- * @type Shadow
- **/
-
- /**
- * Property representing the compositeOperation that will be applied to a display object.
- * You can find a list of valid composite operations at:
- * https://developer.mozilla.org/en/Canvas_tutorial/Compositing
- * @property compositeOperation
- * @type String
- **/
-
- /**
- * Property representing the value for visible that will be applied to a display object.
- * @property visible
- * @type Boolean
- **/
-
- /**
- * The transformation matrix that will be applied to a display object.
- * @property matrix
- * @type Matrix2D
- **/
- }
- var p = DisplayProps.prototype;
-
-// initialization:
- /**
- * Reinitializes the instance with the specified values.
- * @method setValues
- * @param {Number} [visible=true] Visible value.
- * @param {Number} [alpha=1] Alpha value.
- * @param {Number} [shadow=null] A Shadow instance or null.
- * @param {Number} [compositeOperation=null] A compositeOperation value or null.
- * @param {Number} [matrix] A transformation matrix. Defaults to an identity matrix.
- * @return {DisplayProps} This instance. Useful for chaining method calls.
- * @chainable
- */
- p.setValues = function (visible, alpha, shadow, compositeOperation, matrix) {
- this.visible = visible == null ? true : !!visible;
- this.alpha = alpha == null ? 1 : alpha;
- this.shadow = shadow;
- this.compositeOperation = shadow;
- this.matrix = matrix || (this.matrix&&this.matrix.identity()) || new createjs.Matrix2D();
- return this;
- };
-
-// public methods:
- /**
- * Appends the specified display properties. This is generally used to apply a child's properties its parent's.
- * @method append
- * @param {Boolean} visible desired visible value
- * @param {Number} alpha desired alpha value
- * @param {Shadow} shadow desired shadow value
- * @param {String} compositeOperation desired composite operation value
- * @param {Matrix2D} [matrix] a Matrix2D instance
- * @return {DisplayProps} This instance. Useful for chaining method calls.
- * @chainable
- */
- p.append = function(visible, alpha, shadow, compositeOperation, matrix) {
- this.alpha *= alpha;
- this.shadow = shadow || this.shadow;
- this.compositeOperation = compositeOperation || this.compositeOperation;
- this.visible = this.visible && visible;
- matrix&&this.matrix.appendMatrix(matrix);
- return this;
- };
-
- /**
- * Prepends the specified display properties. This is generally used to apply a parent's properties to a child's.
- * For example, to get the combined display properties that would be applied to a child, you could use:
- *
- * var o = myDisplayObject;
- * var props = new createjs.DisplayProps();
- * do {
- * // prepend each parent's props in turn:
- * props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation, o.getMatrix());
- * } while (o = o.parent);
- *
- * @method prepend
- * @param {Boolean} visible desired visible value
- * @param {Number} alpha desired alpha value
- * @param {Shadow} shadow desired shadow value
- * @param {String} compositeOperation desired composite operation value
- * @param {Matrix2D} [matrix] a Matrix2D instance
- * @return {DisplayProps} This instance. Useful for chaining method calls.
- * @chainable
- */
- p.prepend = function(visible, alpha, shadow, compositeOperation, matrix) {
- this.alpha *= alpha;
- this.shadow = this.shadow || shadow;
- this.compositeOperation = this.compositeOperation || compositeOperation;
- this.visible = this.visible && visible;
- matrix&&this.matrix.prependMatrix(matrix);
- return this;
- };
-
- /**
- * Resets this instance and its matrix to default values.
- * @method identity
- * @return {DisplayProps} This instance. Useful for chaining method calls.
- * @chainable
- */
- p.identity = function() {
- this.visible = true;
- this.alpha = 1;
- this.shadow = this.compositeOperation = null;
- this.matrix.identity();
- return this;
- };
-
- /**
- * Returns a clone of the DisplayProps instance. Clones the associated matrix.
- * @method clone
- * @return {DisplayProps} a clone of the DisplayProps instance.
- **/
- p.clone = function() {
- return new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());
- };
-
-// private methods:
-
- createjs.DisplayProps = DisplayProps;
+this.createjs = this.createjs||{};
+
+(function() {
+ "use strict";
+
+ /**
+ * Used for calculating and encapsulating display related properties.
+ * @class DisplayProps
+ * @param {Number} [visible=true] Visible value.
+ * @param {Number} [alpha=1] Alpha value.
+ * @param {Number} [shadow=null] A Shadow instance or null.
+ * @param {Number} [compositeOperation=null] A compositeOperation value or null.
+ * @param {Number} [matrix] A transformation matrix. Defaults to a new identity matrix.
+ * @constructor
+ **/
+ function DisplayProps(visible, alpha, shadow, compositeOperation, matrix) {
+ this.setValues(visible, alpha, shadow, compositeOperation, matrix);
+
+ // public properties:
+ // assigned in the setValues method.
+ /**
+ * Property representing the alpha that will be applied to a display object.
+ * @property alpha
+ * @type Number
+ **/
+
+ /**
+ * Property representing the shadow that will be applied to a display object.
+ * @property shadow
+ * @type Shadow
+ **/
+
+ /**
+ * Property representing the compositeOperation that will be applied to a display object.
+ * You can find a list of valid composite operations at:
+ * https://developer.mozilla.org/en/Canvas_tutorial/Compositing
+ * @property compositeOperation
+ * @type String
+ **/
+
+ /**
+ * Property representing the value for visible that will be applied to a display object.
+ * @property visible
+ * @type Boolean
+ **/
+
+ /**
+ * The transformation matrix that will be applied to a display object.
+ * @property matrix
+ * @type Matrix2D
+ **/
+ }
+ var p = DisplayProps.prototype;
+
+// initialization:
+ /**
+ * Reinitializes the instance with the specified values.
+ * @method setValues
+ * @param {Number} [visible=true] Visible value.
+ * @param {Number} [alpha=1] Alpha value.
+ * @param {Number} [shadow=null] A Shadow instance or null.
+ * @param {Number} [compositeOperation=null] A compositeOperation value or null.
+ * @param {Number} [matrix] A transformation matrix. Defaults to an identity matrix.
+ * @return {DisplayProps} This instance. Useful for chaining method calls.
+ * @chainable
+ */
+ p.setValues = function (visible, alpha, shadow, compositeOperation, matrix) {
+ this.visible = visible == null ? true : !!visible;
+ this.alpha = alpha == null ? 1 : alpha;
+ this.shadow = shadow;
+ this.compositeOperation = compositeOperation;
+ this.matrix = matrix || (this.matrix&&this.matrix.identity()) || new createjs.Matrix2D();
+ return this;
+ };
+
+// public methods:
+ /**
+ * Appends the specified display properties. This is generally used to apply a child's properties its parent's.
+ * @method append
+ * @param {Boolean} visible desired visible value
+ * @param {Number} alpha desired alpha value
+ * @param {Shadow} shadow desired shadow value
+ * @param {String} compositeOperation desired composite operation value
+ * @param {Matrix2D} [matrix] a Matrix2D instance
+ * @return {DisplayProps} This instance. Useful for chaining method calls.
+ * @chainable
+ */
+ p.append = function(visible, alpha, shadow, compositeOperation, matrix) {
+ this.alpha *= alpha;
+ this.shadow = shadow || this.shadow;
+ this.compositeOperation = compositeOperation || this.compositeOperation;
+ this.visible = this.visible && visible;
+ matrix&&this.matrix.appendMatrix(matrix);
+ return this;
+ };
+
+ /**
+ * Prepends the specified display properties. This is generally used to apply a parent's properties to a child's.
+ * For example, to get the combined display properties that would be applied to a child, you could use:
+ *
+ * var o = myDisplayObject;
+ * var props = new createjs.DisplayProps();
+ * do {
+ * // prepend each parent's props in turn:
+ * props.prepend(o.visible, o.alpha, o.shadow, o.compositeOperation, o.getMatrix());
+ * } while (o = o.parent);
+ *
+ * @method prepend
+ * @param {Boolean} visible desired visible value
+ * @param {Number} alpha desired alpha value
+ * @param {Shadow} shadow desired shadow value
+ * @param {String} compositeOperation desired composite operation value
+ * @param {Matrix2D} [matrix] a Matrix2D instance
+ * @return {DisplayProps} This instance. Useful for chaining method calls.
+ * @chainable
+ */
+ p.prepend = function(visible, alpha, shadow, compositeOperation, matrix) {
+ this.alpha *= alpha;
+ this.shadow = this.shadow || shadow;
+ this.compositeOperation = this.compositeOperation || compositeOperation;
+ this.visible = this.visible && visible;
+ matrix&&this.matrix.prependMatrix(matrix);
+ return this;
+ };
+
+ /**
+ * Resets this instance and its matrix to default values.
+ * @method identity
+ * @return {DisplayProps} This instance. Useful for chaining method calls.
+ * @chainable
+ */
+ p.identity = function() {
+ this.visible = true;
+ this.alpha = 1;
+ this.shadow = this.compositeOperation = null;
+ this.matrix.identity();
+ return this;
+ };
+
+ /**
+ * Returns a clone of the DisplayProps instance. Clones the associated matrix.
+ * @method clone
+ * @return {DisplayProps} a clone of the DisplayProps instance.
+ **/
+ p.clone = function() {
+ return new DisplayProps(this.alpha, this.shadow, this.compositeOperation, this.visible, this.matrix.clone());
+ };
+
+// private methods:
+
+ createjs.DisplayProps = DisplayProps;
})();
//##############################################################################
// Point.js
//##############################################################################
-this.createjs = this.createjs||{};
-
-(function() {
- "use strict";
-
-
-// constructor:
- /**
- * Represents a point on a 2 dimensional x / y coordinate system.
- *
- * shadow
property.
- *
- * Tiny | Method | Tiny | Method |
mt | {{#crossLink "Graphics/moveTo"}}{{/crossLink}} | + *lt | {{#crossLink "Graphics/lineTo"}}{{/crossLink}} |
a/at | {{#crossLink "Graphics/arc"}}{{/crossLink}} / {{#crossLink "Graphics/arcTo"}}{{/crossLink}} | + *bt | {{#crossLink "Graphics/bezierCurveTo"}}{{/crossLink}} |
ea | {{#crossLink "Graphics/ellipticalArc"}}{{/crossLink}} | + *r | {{#crossLink "Graphics/rect"}}{{/crossLink}} |
qt | {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}} (also curveTo) | + *c | {{#crossLink "Graphics/clear"}}{{/crossLink}} |
cp | {{#crossLink "Graphics/closePath"}}{{/crossLink}} | + *lf | {{#crossLink "Graphics/beginLinearGradientFill"}}{{/crossLink}} |
f | {{#crossLink "Graphics/beginFill"}}{{/crossLink}} | + *bf | {{#crossLink "Graphics/beginBitmapFill"}}{{/crossLink}} |
rf | {{#crossLink "Graphics/beginRadialGradientFill"}}{{/crossLink}} | + *ss / sd | {{#crossLink "Graphics/setStrokeStyle"}}{{/crossLink}} / {{#crossLink "Graphics/setStrokeDash"}}{{/crossLink}} |
ef | {{#crossLink "Graphics/endFill"}}{{/crossLink}} | + *ls | {{#crossLink "Graphics/beginLinearGradientStroke"}}{{/crossLink}} |
s | {{#crossLink "Graphics/beginStroke"}}{{/crossLink}} | + *bs | {{#crossLink "Graphics/beginBitmapStroke"}}{{/crossLink}} |
rs | {{#crossLink "Graphics/beginRadialGradientStroke"}}{{/crossLink}} | + *dr | {{#crossLink "Graphics/drawRect"}}{{/crossLink}} |
es | {{#crossLink "Graphics/endStroke"}}{{/crossLink}} | + *rc | {{#crossLink "Graphics/drawRoundRectComplex"}}{{/crossLink}} |
rr | {{#crossLink "Graphics/drawRoundRect"}}{{/crossLink}} | + *de | {{#crossLink "Graphics/drawEllipse"}}{{/crossLink}} |
dc | {{#crossLink "Graphics/drawCircle"}}{{/crossLink}} | + *p | {{#crossLink "Graphics/decodePath"}}{{/crossLink}} |
dp | {{#crossLink "Graphics/drawPolyStar"}}{{/crossLink}} |
beginFill(null)
.
+ * A tiny API method "ef" also exists.
+ * @method endFill
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.endFill = function() {
+ return this.beginFill();
+ };
+
+ /**
+ * Sets the stroke style. Like all drawing methods, this can be chained, so you can define
+ * the stroke style and color in a single line of code like so:
+ *
+ * myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");
+ *
+ * A tiny API method "ss" also exists.
+ * @method setStrokeStyle
+ * @param {Number} thickness The width of the stroke.
+ * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,
+ * round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with
+ * the tiny API.
+ * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.
+ * One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel)
+ * for use with the tiny API.
+ * @param {Number} [miterLimit=10] If joints is set to "miter", then you can specify a miter limit ratio which
+ * controls at what point a mitered joint will be clipped.
+ * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless
+ * of active transformations.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.setStrokeStyle = function(thickness, caps, joints, miterLimit, ignoreScale) {
+ this._updateInstructions(true);
+ this._strokeStyle = this.command = new G.StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);
+
+ // ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:
+ if (this._stroke) { this._stroke.ignoreScale = ignoreScale; }
+ this._strokeIgnoreScale = ignoreScale;
+ return this;
+ };
+
+ /**
+ * Sets or clears the stroke dash pattern.
+ *
+ * myGraphics.setStrokeDash([20, 10], 0);
+ *
+ * A tiny API method `sd` also exists.
+ * @method setStrokeDash
+ * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.
+ * For example, `[20,10]` would create a pattern of 20 pixel lines with 10 pixel gaps between them.
+ * Passing null or an empty array will clear the existing stroke dash.
+ * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a "marching ants" effect.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.setStrokeDash = function(segments, offset) {
+ this._updateInstructions(true);
+ this._strokeDash = this.command = new G.StrokeDash(segments, offset);
+ return this;
+ };
+
+ /**
+ * Begins a stroke with the specified color. This ends the current sub-path. A tiny API method "s" also exists.
+ * @method beginStroke
+ * @param {String} color A CSS compatible color value (ex. "#FF0000", "red", or "rgba(255,0,0,0.5)"). Setting to
+ * null will result in no stroke.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.beginStroke = function(color) {
+ return this._setStroke(color ? new G.Stroke(color) : null);
+ };
+
+ /**
+ * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For
+ * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a
+ * square to display it:
+ *
+ * myGraphics.setStrokeStyle(10).
+ * beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);
+ *
+ * A tiny API method "ls" also exists.
+ * @method beginLinearGradientStroke
+ * @param {Array} colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
+ * a gradient drawing from red to blue.
+ * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
+ * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
+ * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
+ * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
+ * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
+ * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.beginLinearGradientStroke = function(colors, ratios, x0, y0, x1, y1) {
+ return this._setStroke(new G.Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));
+ };
+
+ /**
+ * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to
+ * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it:
+ *
+ * myGraphics.setStrokeStyle(10)
+ * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50)
+ * .drawRect(50, 90, 150, 110);
+ *
+ * A tiny API method "rs" also exists.
+ * @method beginRadialGradientStroke
+ * @param {Array} colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
+ * a gradient drawing from red to blue.
+ * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
+ * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color
+ * to 100%.
+ * @param {Number} x0 Center position of the inner circle that defines the gradient.
+ * @param {Number} y0 Center position of the inner circle that defines the gradient.
+ * @param {Number} r0 Radius of the inner circle that defines the gradient.
+ * @param {Number} x1 Center position of the outer circle that defines the gradient.
+ * @param {Number} y1 Center position of the outer circle that defines the gradient.
+ * @param {Number} r1 Radius of the outer circle that defines the gradient.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.beginRadialGradientStroke = function(colors, ratios, x0, y0, r0, x1, y1, r1) {
+ return this._setStroke(new G.Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
+ };
+
+ /**
+ * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,
+ * strokes do not currently support a matrix parameter due to limitations in the canvas API. A tiny API method "bs"
+ * also exists.
+ * @method beginBitmapStroke
+ * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
+ * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.
+ * @param {String} [repetition=repeat] Optional. Indicates whether to repeat the image in the fill area. One of
+ * "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.beginBitmapStroke = function(image, repetition) {
+ // NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.
+ return this._setStroke(new G.Stroke().bitmap(image, repetition));
+ };
+
+ /**
+ * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to beginStroke(null)
.
+ * A tiny API method "es" also exists.
+ * @method endStroke
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.endStroke = function() {
+ return this.beginStroke();
+ };
+
+ /**
+ * Maps the familiar ActionScript curveTo()
method to the functionally similar {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}}
+ * method.
+ * @method quadraticCurveTo
+ * @param {Number} cpx
+ * @param {Number} cpy
+ * @param {Number} x
+ * @param {Number} y
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.curveTo = p.quadraticCurveTo;
+
+ /**
+ *
+ * Maps the familiar ActionScript drawRect()
method to the functionally similar {{#crossLink "Graphics/rect"}}{{/crossLink}}
+ * method.
+ * @method drawRect
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} w Width of the rectangle
+ * @param {Number} h Height of the rectangle
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawRect = p.rect;
+
+ /**
+ * Draws a rounded rectangle with all corners with the specified radius.
+ * @method drawRoundRect
+ * @param {Number} x
+ * @param {Number} y
+ * @param {Number} w
+ * @param {Number} h
+ * @param {Number} radius Corner radius.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawRoundRect = function(x, y, w, h, radius) {
+ return this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);
+ };
+
+ /**
+ * Draws a rounded rectangle with different corner radii. Supports positive and negative corner radii. A tiny API
+ * method "rc" also exists.
+ * @method drawRoundRectComplex
+ * @param {Number} x The horizontal coordinate to draw the round rect.
+ * @param {Number} y The vertical coordinate to draw the round rect.
+ * @param {Number} w The width of the round rect.
+ * @param {Number} h The height of the round rect.
+ * @param {Number} radiusTL Top left corner radius.
+ * @param {Number} radiusTR Top right corner radius.
+ * @param {Number} radiusBR Bottom right corner radius.
+ * @param {Number} radiusBL Bottom left corner radius.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawRoundRectComplex = function(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
+ return this.append(new G.RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));
+ };
+
+ /**
+ * Draws a circle with the specified radius at (x, y).
+ *
+ * var g = new createjs.Graphics();
+ * g.setStrokeStyle(1);
+ * g.beginStroke(createjs.Graphics.getRGB(0,0,0));
+ * g.beginFill(createjs.Graphics.getRGB(255,0,0));
+ * g.drawCircle(0,0,3);
+ *
+ * var s = new createjs.Shape(g);
+ * s.x = 100;
+ * s.y = 100;
+ *
+ * stage.addChild(s);
+ * stage.update();
+ *
+ * A tiny API method "dc" also exists.
+ * @method drawCircle
+ * @param {Number} x x coordinate center point of circle.
+ * @param {Number} y y coordinate center point of circle.
+ * @param {Number} radius Radius of circle.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawCircle = function(x, y, radius) {
+ return this.append(new G.Circle(x, y, radius));
+ };
+
+ /**
+ * Draws an ellipse (oval) with a specified width (w) and height (h). Similar to {{#crossLink "Graphics/drawCircle"}}{{/crossLink}},
+ * except the width and height can be different. A tiny API method "de" also exists.
+ * @method drawEllipse
+ * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {{#crossLink "Graphics/drawCircle"}}{{/crossLink}}
+ * which draws from center.
+ * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {{#crossLink "Graphics/drawCircle"}}{{/crossLink}}
+ * which draws from the center.
+ * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this
+ * number.
+ * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawEllipse = function(x, y, w, h) {
+ return this.append(new G.Ellipse(x, y, w, h));
+ };
+
+ /**
+ * Draws a star if pointSize is greater than 0, or a regular polygon if pointSize is 0 with the specified number of
+ * points. For example, the following code will draw a familiar 5 pointed star shape centered at 100, 100 and with a
+ * radius of 50:
+ *
+ * myGraphics.beginFill("#FF0").drawPolyStar(100, 100, 50, 5, 0.6, -90);
+ * // Note: -90 makes the first point vertical
+ *
+ * A tiny API method "dp" also exists.
+ *
+ * @method drawPolyStar
+ * @param {Number} x Position of the center of the shape.
+ * @param {Number} y Position of the center of the shape.
+ * @param {Number} radius The outer radius of the shape.
+ * @param {Number} sides The number of points on the star or sides on the polygon.
+ * @param {Number} pointSize The depth or "pointy-ness" of the star points. A pointSize of 0 will draw a regular
+ * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.
+ * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point
+ * directly to the right of the center.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.drawPolyStar = function(x, y, radius, sides, pointSize, angle) {
+ return this.append(new G.PolyStar(x, y, radius, sides, pointSize, angle));
+ };
+
+ // TODO: deprecated.
+ /**
+ * Removed in favour of using custom command objects with {{#crossLink "Graphics/append"}}{{/crossLink}}.
+ * @method inject
+ * @deprecated
+ **/
+
+ /**
+ * Appends a graphics command object to the graphics queue. Command objects expose an "exec" method
+ * that accepts two parameters: the Context2D to operate on, and an arbitrary data object passed into
+ * {{#crossLink "Graphics/draw"}}{{/crossLink}}. The latter will usually be the Shape instance that called draw.
+ *
+ * This method is used internally by Graphics methods, such as drawCircle, but can also be used directly to insert
+ * built-in or custom graphics commands. For example:
+ *
+ * // attach data to our shape, so we can access it during the draw:
+ * myShape.color = "red";
+ *
+ * // append a Circle command object:
+ * myShape.graphics.append(new createjs.Graphics.Circle(50, 50, 30));
+ *
+ * // append a custom command object with an exec method that sets the fill style
+ * // based on the shape's data, and then fills the circle.
+ * myShape.graphics.append({exec:function(ctx, shape) {
+ * ctx.fillStyle = shape.color;
+ * ctx.fill();
+ * }});
+ *
+ * @method append
+ * @param {Object} command A graphics command object exposing an "exec" method.
+ * @param {boolean} clean The clean param is primarily for internal use. A value of true indicates that a command does not generate a path that should be stroked or filled.
+ * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
+ * @chainable
+ **/
+ p.append = function(command, clean) {
+ this._activeInstructions.push(command);
+ this.command = command;
+ if (!clean) { this._dirty = true; }
+ return this;
+ };
+
+ /**
+ * Decodes a compact encoded path string into a series of draw instructions.
+ * This format is not intended to be human readable, and is meant for use by authoring tools.
+ * The format uses a base64 character set, with each character representing 6 bits, to define a series of draw
+ * commands.
+ *
+ * Each command is comprised of a single "header" character followed by a variable number of alternating x and y
+ * position values. Reading the header bits from left to right (most to least significant): bits 1 to 3 specify the
+ * type of operation (0-moveTo, 1-lineTo, 2-quadraticCurveTo, 3-bezierCurveTo, 4-closePath, 5-7 unused). Bit 4
+ * indicates whether position values use 12 bits (2 characters) or 18 bits (3 characters), with a one indicating the
+ * latter. Bits 5 and 6 are currently unused.
+ *
+ * Following the header is a series of 0 (closePath), 2 (moveTo, lineTo), 4 (quadraticCurveTo), or 6 (bezierCurveTo)
+ * parameters. These parameters are alternating x/y positions represented by 2 or 3 characters (as indicated by the
+ * 4th bit in the command char). These characters consist of a 1 bit sign (1 is negative, 0 is positive), followed
+ * by an 11 (2 char) or 17 (3 char) bit integer value. All position values are in tenths of a pixel. Except in the
+ * case of move operations which are absolute, this value is a delta from the previous x or y position (as
+ * appropriate).
+ *
+ * For example, the string "A3cAAMAu4AAA" represents a line starting at -150,0 and ending at 150,0.
+ * Tiny | Method | Tiny | Method |
mt | {{#crossLink "Graphics/moveTo"}}{{/crossLink}} | - *lt | {{#crossLink "Graphics/lineTo"}}{{/crossLink}} |
a/at | {{#crossLink "Graphics/arc"}}{{/crossLink}} / {{#crossLink "Graphics/arcTo"}}{{/crossLink}} | - *bt | {{#crossLink "Graphics/bezierCurveTo"}}{{/crossLink}} |
qt | {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}} (also curveTo) | - *r | {{#crossLink "Graphics/rect"}}{{/crossLink}} |
cp | {{#crossLink "Graphics/closePath"}}{{/crossLink}} | - *c | {{#crossLink "Graphics/clear"}}{{/crossLink}} |
f | {{#crossLink "Graphics/beginFill"}}{{/crossLink}} | - *lf | {{#crossLink "Graphics/beginLinearGradientFill"}}{{/crossLink}} |
rf | {{#crossLink "Graphics/beginRadialGradientFill"}}{{/crossLink}} | - *bf | {{#crossLink "Graphics/beginBitmapFill"}}{{/crossLink}} |
ef | {{#crossLink "Graphics/endFill"}}{{/crossLink}} | - *ss / sd | {{#crossLink "Graphics/setStrokeStyle"}}{{/crossLink}} / {{#crossLink "Graphics/setStrokeDash"}}{{/crossLink}} |
s | {{#crossLink "Graphics/beginStroke"}}{{/crossLink}} | - *ls | {{#crossLink "Graphics/beginLinearGradientStroke"}}{{/crossLink}} |
rs | {{#crossLink "Graphics/beginRadialGradientStroke"}}{{/crossLink}} | - *bs | {{#crossLink "Graphics/beginBitmapStroke"}}{{/crossLink}} |
es | {{#crossLink "Graphics/endStroke"}}{{/crossLink}} | - *dr | {{#crossLink "Graphics/drawRect"}}{{/crossLink}} |
rr | {{#crossLink "Graphics/drawRoundRect"}}{{/crossLink}} | - *rc | {{#crossLink "Graphics/drawRoundRectComplex"}}{{/crossLink}} |
dc | {{#crossLink "Graphics/drawCircle"}}{{/crossLink}} | - *de | {{#crossLink "Graphics/drawEllipse"}}{{/crossLink}} |
dp | {{#crossLink "Graphics/drawPolyStar"}}{{/crossLink}} | - *p | {{#crossLink "Graphics/decodePath"}}{{/crossLink}} |
beginFill(null)
.
- * A tiny API method "ef" also exists.
- * @method endFill
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.endFill = function() {
- return this.beginFill();
- };
-
- /**
- * Sets the stroke style. Like all drawing methods, this can be chained, so you can define
- * the stroke style and color in a single line of code like so:
- *
- * myGraphics.setStrokeStyle(8,"round").beginStroke("#F00");
- *
- * A tiny API method "ss" also exists.
- * @method setStrokeStyle
- * @param {Number} thickness The width of the stroke.
- * @param {String | Number} [caps=0] Indicates the type of caps to use at the end of lines. One of butt,
- * round, or square. Defaults to "butt". Also accepts the values 0 (butt), 1 (round), and 2 (square) for use with
- * the tiny API.
- * @param {String | Number} [joints=0] Specifies the type of joints that should be used where two lines meet.
- * One of bevel, round, or miter. Defaults to "miter". Also accepts the values 0 (miter), 1 (round), and 2 (bevel)
- * for use with the tiny API.
- * @param {Number} [miterLimit=10] If joints is set to "miter", then you can specify a miter limit ratio which
- * controls at what point a mitered joint will be clipped.
- * @param {Boolean} [ignoreScale=false] If true, the stroke will be drawn at the specified thickness regardless
- * of active transformations.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.setStrokeStyle = function(thickness, caps, joints, miterLimit, ignoreScale) {
- this._updateInstructions(true);
- this._strokeStyle = this.command = new G.StrokeStyle(thickness, caps, joints, miterLimit, ignoreScale);
-
- // ignoreScale lives on Stroke, not StrokeStyle, so we do a little trickery:
- if (this._stroke) { this._stroke.ignoreScale = ignoreScale; }
- this._strokeIgnoreScale = ignoreScale;
- return this;
- };
-
- /**
- * Sets or clears the stroke dash pattern.
- *
- * myGraphics.setStrokeDash([20, 10], 0);
- *
- * A tiny API method `sd` also exists.
- * @method setStrokeDash
- * @param {Array} [segments] An array specifying the dash pattern, alternating between line and gap.
- * For example, `[20,10]` would create a pattern of 20 pixel lines with 10 pixel gaps between them.
- * Passing null or an empty array will clear the existing stroke dash.
- * @param {Number} [offset=0] The offset of the dash pattern. For example, you could increment this value to create a "marching ants" effect.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.setStrokeDash = function(segments, offset) {
- this._updateInstructions(true);
- this._strokeDash = this.command = new G.StrokeDash(segments, offset);
- return this;
- };
-
- /**
- * Begins a stroke with the specified color. This ends the current sub-path. A tiny API method "s" also exists.
- * @method beginStroke
- * @param {String} color A CSS compatible color value (ex. "#FF0000", "red", or "rgba(255,0,0,0.5)"). Setting to
- * null will result in no stroke.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.beginStroke = function(color) {
- return this._setStroke(color ? new G.Stroke(color) : null);
- };
-
- /**
- * Begins a linear gradient stroke defined by the line (x0, y0) to (x1, y1). This ends the current sub-path. For
- * example, the following code defines a black to white vertical gradient ranging from 20px to 120px, and draws a
- * square to display it:
- *
- * myGraphics.setStrokeStyle(10).
- * beginLinearGradientStroke(["#000","#FFF"], [0, 1], 0, 20, 0, 120).drawRect(20, 20, 120, 120);
- *
- * A tiny API method "ls" also exists.
- * @method beginLinearGradientStroke
- * @param {Array} colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
- * a gradient drawing from red to blue.
- * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
- * 0.9] would draw the first color to 10% then interpolating to the second color at 90%.
- * @param {Number} x0 The position of the first point defining the line that defines the gradient direction and size.
- * @param {Number} y0 The position of the first point defining the line that defines the gradient direction and size.
- * @param {Number} x1 The position of the second point defining the line that defines the gradient direction and size.
- * @param {Number} y1 The position of the second point defining the line that defines the gradient direction and size.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.beginLinearGradientStroke = function(colors, ratios, x0, y0, x1, y1) {
- return this._setStroke(new G.Stroke().linearGradient(colors, ratios, x0, y0, x1, y1));
- };
-
- /**
- * Begins a radial gradient stroke. This ends the current sub-path. For example, the following code defines a red to
- * blue radial gradient centered at (100, 100), with a radius of 50, and draws a rectangle to display it:
- *
- * myGraphics.setStrokeStyle(10)
- * .beginRadialGradientStroke(["#F00","#00F"], [0, 1], 100, 100, 0, 100, 100, 50)
- * .drawRect(50, 90, 150, 110);
- *
- * A tiny API method "rs" also exists.
- * @method beginRadialGradientStroke
- * @param {Array} colors An array of CSS compatible color values. For example, ["#F00","#00F"] would define
- * a gradient drawing from red to blue.
- * @param {Array} ratios An array of gradient positions which correspond to the colors. For example, [0.1,
- * 0.9] would draw the first color to 10% then interpolating to the second color at 90%, then draw the second color
- * to 100%.
- * @param {Number} x0 Center position of the inner circle that defines the gradient.
- * @param {Number} y0 Center position of the inner circle that defines the gradient.
- * @param {Number} r0 Radius of the inner circle that defines the gradient.
- * @param {Number} x1 Center position of the outer circle that defines the gradient.
- * @param {Number} y1 Center position of the outer circle that defines the gradient.
- * @param {Number} r1 Radius of the outer circle that defines the gradient.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.beginRadialGradientStroke = function(colors, ratios, x0, y0, r0, x1, y1, r1) {
- return this._setStroke(new G.Stroke().radialGradient(colors, ratios, x0, y0, r0, x1, y1, r1));
- };
-
- /**
- * Begins a pattern fill using the specified image. This ends the current sub-path. Note that unlike bitmap fills,
- * strokes do not currently support a matrix parameter due to limitations in the canvas API. A tiny API method "bs"
- * also exists.
- * @method beginBitmapStroke
- * @param {HTMLImageElement | HTMLCanvasElement | HTMLVideoElement} image The Image, Canvas, or Video object to use
- * as the pattern. Must be loaded prior to creating a bitmap fill, or the fill will be empty.
- * @param {String} [repetition=repeat] Optional. Indicates whether to repeat the image in the fill area. One of
- * "repeat", "repeat-x", "repeat-y", or "no-repeat". Defaults to "repeat".
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.beginBitmapStroke = function(image, repetition) {
- // NOTE: matrix is not supported for stroke because transforms on strokes also affect the drawn stroke width.
- return this._setStroke(new G.Stroke().bitmap(image, repetition));
- };
-
- /**
- * Ends the current sub-path, and begins a new one with no stroke. Functionally identical to beginStroke(null)
.
- * A tiny API method "es" also exists.
- * @method endStroke
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.endStroke = function() {
- return this.beginStroke();
- };
-
- /**
- * Maps the familiar ActionScript curveTo()
method to the functionally similar {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}}
- * method.
- * @method quadraticCurveTo
- * @param {Number} cpx
- * @param {Number} cpy
- * @param {Number} x
- * @param {Number} y
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.curveTo = p.quadraticCurveTo;
-
- /**
- *
- * Maps the familiar ActionScript drawRect()
method to the functionally similar {{#crossLink "Graphics/rect"}}{{/crossLink}}
- * method.
- * @method drawRect
- * @param {Number} x
- * @param {Number} y
- * @param {Number} w Width of the rectangle
- * @param {Number} h Height of the rectangle
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawRect = p.rect;
-
- /**
- * Draws a rounded rectangle with all corners with the specified radius.
- * @method drawRoundRect
- * @param {Number} x
- * @param {Number} y
- * @param {Number} w
- * @param {Number} h
- * @param {Number} radius Corner radius.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawRoundRect = function(x, y, w, h, radius) {
- return this.drawRoundRectComplex(x, y, w, h, radius, radius, radius, radius);
- };
-
- /**
- * Draws a rounded rectangle with different corner radii. Supports positive and negative corner radii. A tiny API
- * method "rc" also exists.
- * @method drawRoundRectComplex
- * @param {Number} x The horizontal coordinate to draw the round rect.
- * @param {Number} y The vertical coordinate to draw the round rect.
- * @param {Number} w The width of the round rect.
- * @param {Number} h The height of the round rect.
- * @param {Number} radiusTL Top left corner radius.
- * @param {Number} radiusTR Top right corner radius.
- * @param {Number} radiusBR Bottom right corner radius.
- * @param {Number} radiusBL Bottom left corner radius.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawRoundRectComplex = function(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL) {
- return this.append(new G.RoundRect(x, y, w, h, radiusTL, radiusTR, radiusBR, radiusBL));
- };
-
- /**
- * Draws a circle with the specified radius at (x, y).
- *
- * var g = new createjs.Graphics();
- * g.setStrokeStyle(1);
- * g.beginStroke(createjs.Graphics.getRGB(0,0,0));
- * g.beginFill(createjs.Graphics.getRGB(255,0,0));
- * g.drawCircle(0,0,3);
- *
- * var s = new createjs.Shape(g);
- * s.x = 100;
- * s.y = 100;
- *
- * stage.addChild(s);
- * stage.update();
- *
- * A tiny API method "dc" also exists.
- * @method drawCircle
- * @param {Number} x x coordinate center point of circle.
- * @param {Number} y y coordinate center point of circle.
- * @param {Number} radius Radius of circle.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawCircle = function(x, y, radius) {
- return this.append(new G.Circle(x, y, radius));
- };
-
- /**
- * Draws an ellipse (oval) with a specified width (w) and height (h). Similar to {{#crossLink "Graphics/drawCircle"}}{{/crossLink}},
- * except the width and height can be different. A tiny API method "de" also exists.
- * @method drawEllipse
- * @param {Number} x The left coordinate point of the ellipse. Note that this is different from {{#crossLink "Graphics/drawCircle"}}{{/crossLink}}
- * which draws from center.
- * @param {Number} y The top coordinate point of the ellipse. Note that this is different from {{#crossLink "Graphics/drawCircle"}}{{/crossLink}}
- * which draws from the center.
- * @param {Number} w The height (horizontal diameter) of the ellipse. The horizontal radius will be half of this
- * number.
- * @param {Number} h The width (vertical diameter) of the ellipse. The vertical radius will be half of this number.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawEllipse = function(x, y, w, h) {
- return this.append(new G.Ellipse(x, y, w, h));
- };
-
- /**
- * Draws a star if pointSize is greater than 0, or a regular polygon if pointSize is 0 with the specified number of
- * points. For example, the following code will draw a familiar 5 pointed star shape centered at 100, 100 and with a
- * radius of 50:
- *
- * myGraphics.beginFill("#FF0").drawPolyStar(100, 100, 50, 5, 0.6, -90);
- * // Note: -90 makes the first point vertical
- *
- * A tiny API method "dp" also exists.
- *
- * @method drawPolyStar
- * @param {Number} x Position of the center of the shape.
- * @param {Number} y Position of the center of the shape.
- * @param {Number} radius The outer radius of the shape.
- * @param {Number} sides The number of points on the star or sides on the polygon.
- * @param {Number} pointSize The depth or "pointy-ness" of the star points. A pointSize of 0 will draw a regular
- * polygon (no points), a pointSize of 1 will draw nothing because the points are infinitely pointy.
- * @param {Number} angle The angle of the first point / corner. For example a value of 0 will draw the first point
- * directly to the right of the center.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.drawPolyStar = function(x, y, radius, sides, pointSize, angle) {
- return this.append(new G.PolyStar(x, y, radius, sides, pointSize, angle));
- };
-
- // TODO: deprecated.
- /**
- * Removed in favour of using custom command objects with {{#crossLink "Graphics/append"}}{{/crossLink}}.
- * @method inject
- * @deprecated
- **/
-
- /**
- * Appends a graphics command object to the graphics queue. Command objects expose an "exec" method
- * that accepts two parameters: the Context2D to operate on, and an arbitrary data object passed into
- * {{#crossLink "Graphics/draw"}}{{/crossLink}}. The latter will usually be the Shape instance that called draw.
- *
- * This method is used internally by Graphics methods, such as drawCircle, but can also be used directly to insert
- * built-in or custom graphics commands. For example:
- *
- * // attach data to our shape, so we can access it during the draw:
- * myShape.color = "red";
- *
- * // append a Circle command object:
- * myShape.graphics.append(new Graphics.Circle(50, 50, 30));
- *
- * // append a custom command object with an exec method that sets the fill style
- * // based on the shape's data, and then fills the circle.
- * myShape.graphics.append({exec:function(ctx, shape) {
- * ctx.fillStyle = shape.color;
- * ctx.fill();
- * }});
- *
- * @method append
- * @param {Object} command A graphics command object exposing an "exec" method.
- * @param {boolean} clean The clean param is primarily for internal use. A value of true indicates that a command does not generate a path that should be stroked or filled.
- * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.)
- * @chainable
- **/
- p.append = function(command, clean) {
- this._activeInstructions.push(command);
- this.command = command;
- if (!clean) { this._dirty = true; }
- return this;
- };
-
- /**
- * Decodes a compact encoded path string into a series of draw instructions.
- * This format is not intended to be human readable, and is meant for use by authoring tools.
- * The format uses a base64 character set, with each character representing 6 bits, to define a series of draw
- * commands.
- *
- * Each command is comprised of a single "header" character followed by a variable number of alternating x and y
- * position values. Reading the header bits from left to right (most to least significant): bits 1 to 3 specify the
- * type of operation (0-moveTo, 1-lineTo, 2-quadraticCurveTo, 3-bezierCurveTo, 4-closePath, 5-7 unused). Bit 4
- * indicates whether position values use 12 bits (2 characters) or 18 bits (3 characters), with a one indicating the
- * latter. Bits 5 and 6 are currently unused.
- *
- * Following the header is a series of 0 (closePath), 2 (moveTo, lineTo), 4 (quadraticCurveTo), or 6 (bezierCurveTo)
- * parameters. These parameters are alternating x/y positions represented by 2 or 3 characters (as indicated by the
- * 4th bit in the command char). These characters consist of a 1 bit sign (1 is negative, 0 is positive), followed
- * by an 11 (2 char) or 17 (3 char) bit integer value. All position values are in tenths of a pixel. Except in the
- * case of move operations which are absolute, this value is a delta from the previous x or y position (as
- * appropriate).
- *
- * For example, the string "A3cAAMAu4AAA" represents a line starting at -150,0 and ending at 150,0.
- * 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).
+ * @return {Boolean}
+ **/
+ p.draw = function(ctx, ignoreCache) {
+ var cacheCanvas = this.cacheCanvas;
+ if (ignoreCache || !cacheCanvas) { return false; }
+ var scale = this._cacheScale;
+ ctx.drawImage(cacheCanvas, this._cacheOffsetX+this._filterOffsetX, this._cacheOffsetY+this._filterOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale);
+ return true;
+ };
+
+ /**
+ * Applies this display object's transformation, alpha, globalCompositeOperation, clipping path (mask), and shadow
+ * to the specified context. This is typically called prior to {{#crossLink "DisplayObject/draw"}}{{/crossLink}}.
+ * @method updateContext
+ * @param {CanvasRenderingContext2D} ctx The canvas 2D to update.
+ **/
+ p.updateContext = function(ctx) {
+ var o=this, mask=o.mask, mtx= o._props.matrix;
+
+ if (mask && mask.graphics && !mask.graphics.isEmpty()) {
+ mask.getMatrix(mtx);
+ ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
+
+ mask.graphics.drawAsPath(ctx);
+ ctx.clip();
+
+ mtx.invert();
+ ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
+ }
+
+ this.getMatrix(mtx);
+ var tx = mtx.tx, ty = mtx.ty;
+ if (DisplayObject._snapToPixelEnabled && o.snapToPixel) {
+ tx = tx + (tx < 0 ? -0.5 : 0.5) | 0;
+ ty = ty + (ty < 0 ? -0.5 : 0.5) | 0;
+ }
+ ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, tx, ty);
+ ctx.globalAlpha *= o.alpha;
+ if (o.compositeOperation) { ctx.globalCompositeOperation = o.compositeOperation; }
+ if (o.shadow) { this._applyShadow(ctx, o.shadow); }
+ };
+
+ /**
+ * Draws the display object into a new canvas, which is then used for subsequent draws. For complex content
+ * 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()
or cache()
again. You must specify
+ * the cache 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.
+ *
+ * All | + * All display objects support setting bounds manually using setBounds(). Likewise, display objects that + * have been cached using cache() will return the bounds of their cache. Manual and cache bounds will override + * the automatic calculations listed below. + * |
Bitmap | + * Returns the width and height of the sourceRect (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(). + * |
Shape | + * 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". + * |
BitmapText | + * Returns approximate bounds. Values will be more accurate if spritesheet frame registration points are close + * to (x=0,y=0). + * |
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.
+ *
+ * Array.sort
+ * documentation for details.
+ **/
+ p.sortChildren = function(sortFunction) {
+ this.children.sort(sortFunction);
+ };
+
+ /**
+ * Returns the index of the specified child in the display list, or -1 if it is not in the display list.
+ *
+ * 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.
+ * @param {Number} y The y position in the container to test.
+ * @param {Number} mode The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.
+ * @return {DisplayObject} The top-most display object under the specified coordinates.
+ **/
+ p.getObjectUnderPoint = function(x, y, mode) {
+ var pt = this.localToGlobal(x, y);
+ return this._getObjectsUnderPoint(pt.x, pt.y, null, mode>0, mode==1);
+ };
+
+ /**
+ * Docced in superclass.
+ */
+ p.getBounds = function() {
+ return this._getBounds(null, true);
+ };
+
+
+ /**
+ * Docced in superclass.
+ */
+ p.getTransformedBounds = function() {
+ return this._getBounds();
+ };
+
+ /**
+ * Returns a clone of this Container. Some properties that are specific to this instance's current context are
+ * reverted to their defaults (for example .parent).
+ * @method clone
+ * @param {Boolean} [recursive=false] If true, all of the descendants of this container will be cloned recursively. If false, the
+ * properties of the container will be cloned, but the new instance will not have any children.
+ * @return {Container} A clone of the current Container instance.
+ **/
+ p.clone = function(recursive) {
+ var o = this._cloneProps(new Container());
+ if (recursive) { this._cloneChildren(o); }
+ return o;
+ };
+
+ /**
+ * Returns a string representation of this object.
+ * @method toString
+ * @return {String} a string representation of the instance.
+ **/
+ p.toString = function() {
+ return "[Container (name="+ this.name +")]";
+ };
+
+
+// private methods:
+ /**
+ * @method _tick
+ * @param {Object} evtObj An event object that will be dispatched to all tick listeners. This object is reused between dispatchers to reduce construction & GC costs.
+ * @protected
+ **/
+ p._tick = function(evtObj) {
+ if (this.tickChildren) {
+ for (var i=this.children.length-1; i>=0; i--) {
+ var child = this.children[i];
+ if (child.tickEnabled && child._tick) { child._tick(evtObj); }
+ }
+ }
+ this.DisplayObject__tick(evtObj);
+ };
+
+ /**
+ * Recursively clones all children of this container, and adds them to the target container.
+ * @method cloneChildren
+ * @protected
+ * @param {Container} o The target container.
+ **/
+ p._cloneChildren = function(o) {
+ if (o.children.length) { o.removeAllChildren(); }
+ var arr = o.children;
+ for (var i=0, l=this.children.length; ifalse
+ * to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for
+ * example).
+ *
+ * delta
and paused
parameters.
+ * @property handleEvent
+ * @type Function
+ **/
+ p.handleEvent = function(evt) {
+ if (evt.type == "tick") { this.update(evt); }
+ };
+
+ /**
+ * Clears the target canvas. Useful if {{#crossLink "Stage/autoClear:property"}}{{/crossLink}} is set to `false`.
+ * @method clear
+ **/
+ p.clear = function() {
+ if (!this.canvas) { return; }
+ var ctx = this.canvas.getContext("2d");
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
+ ctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1);
+ };
+
+ /**
+ * Returns a data url that contains a Base64-encoded image of the contents of the stage. The returned data url can
+ * be specified as the src value of an image element.
+ * @method toDataURL
+ * @param {String} [backgroundColor] The background color to be used for the generated image. Any valid CSS color
+ * 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.
+ * @return {String} a Base64 encoded image.
+ **/
+ p.toDataURL = function(backgroundColor, mimeType) {
+ var data, ctx = this.canvas.getContext('2d'), w = this.canvas.width, h = this.canvas.height;
+
+ if (backgroundColor) {
+ data = ctx.getImageData(0, 0, w, h);
+ var compositeOperation = ctx.globalCompositeOperation;
+ ctx.globalCompositeOperation = "destination-over";
+
+ ctx.fillStyle = backgroundColor;
+ ctx.fillRect(0, 0, w, h);
+ }
+
+ var dataURL = this.canvas.toDataURL(mimeType||"image/png");
+
+ if(backgroundColor) {
+ ctx.putImageData(data, 0, 0);
+ ctx.globalCompositeOperation = compositeOperation;
+ }
+
+ return dataURL;
+ };
+
+ /**
+ * Enables or disables (by passing a frequency of 0) mouse over ({{#crossLink "DisplayObject/mouseover:event"}}{{/crossLink}}
+ * and {{#crossLink "DisplayObject/mouseout:event"}}{{/crossLink}}) and roll over events ({{#crossLink "DisplayObject/rollover:event"}}{{/crossLink}}
+ * and {{#crossLink "DisplayObject/rollout:event"}}{{/crossLink}}) for this stage's display list. These events can
+ * be expensive to generate, so they are disabled by default. The frequency of the events can be controlled
+ * independently of mouse move events via the optional `frequency` parameter.
+ *
+ * currentFrame
.
+ * @property paused
* @type {Boolean}
- * @default true
+ * @default false
**/
- this.snapToPixel = true;
+ this.paused = true;
/**
- * An array of Filter objects to apply to this display object. Filters are only applied / updated when {{#crossLink "cache"}}{{/crossLink}}
- * or {{#crossLink "updateCache"}}{{/crossLink}} is called on the display object, and only apply to the area that is
- * cached.
- * @property filters
- * @type {Array}
- * @default null
+ * The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame
+ * data. See {{#crossLink "SpriteSheet"}}{{/crossLink}} for more information.
+ * @property spriteSheet
+ * @type {SpriteSheet}
+ * @readonly
**/
- this.filters = null;
-
- /**
- * A Shape instance that defines a vector mask (clipping path) for this display object. The shape's transformation
- * will be applied relative to the display object's parent coordinates (as if it were a child of the parent).
- * @property mask
- * @type {Shape}
- * @default null
- */
- this.mask = null;
-
- /**
- * A display object that will be tested when checking mouse interactions or testing {{#crossLink "Container/getObjectsUnderPoint"}}{{/crossLink}}.
- * The hit area will have its transformation applied relative to this display object's coordinate space (as though
- * the hit test object were a child of this display object and relative to its regX/Y). The hitArea will be tested
- * using only its own `alpha` value regardless of the alpha value on the target display object, or the target's
- * ancestors (parents).
- *
- * If set on a {{#crossLink "Container"}}{{/crossLink}}, children of the Container will not receive mouse events.
- * This is similar to setting {{#crossLink "mouseChildren"}}{{/crossLink}} to false.
- *
- * Note that hitArea is NOT currently used by the `hitTest()` method, nor is it supported for {{#crossLink "Stage"}}{{/crossLink}}.
- * @property hitArea
- * @type {DisplayObject}
- * @default null
- */
- this.hitArea = null;
-
- /**
- * A CSS cursor (ex. "pointer", "help", "text", etc) that will be displayed when the user hovers over this display
- * object. You must enable mouseover events using the {{#crossLink "Stage/enableMouseOver"}}{{/crossLink}} method to
- * use this property. Setting a non-null cursor on a Container will override the cursor set on its descendants.
- * @property cursor
- * @type {String}
- * @default null
- */
- this.cursor = null;
+ this.spriteSheet = spriteSheet;
-
- // private properties:
/**
- * @property _cacheOffsetX
- * @protected
+ * Specifies the current frame index within the currently playing animation. When playing normally, this will increase
+ * from 0 to n-1, where n is the number of frames in the current animation.
+ *
+ * This could be a non-integer value if
+ * using time-based playback (see {{#crossLink "Sprite/framerate"}}{{/crossLink}}, or if the animation's speed is
+ * not an integer.
+ * @property currentAnimationFrame
* @type {Number}
* @default 0
**/
- this._cacheOffsetX = 0;
+ this.currentAnimationFrame = 0;
/**
- * @property _cacheOffsetY
- * @protected
- * @type {Number}
- * @default 0
- **/
- this._cacheOffsetY = 0;
-
- /**
- * @property _filterOffsetX
- * @protected
- * @type {Number}
- * @default 0
- **/
- this._filterOffsetX = 0;
-
- /**
- * @property _filterOffsetY
- * @protected
- * @type {Number}
- * @default 0
- **/
- this._filterOffsetY = 0;
-
- /**
- * @property _cacheScale
- * @protected
+ * By default Sprite instances advance one frame per tick. Specifying a framerate for the Sprite (or its related
+ * SpriteSheet) will cause it to advance based on elapsed time between ticks as appropriate to maintain the target
+ * framerate.
+ *
+ * For example, if a Sprite with a framerate of 10 is placed on a Stage being updated at 40fps, then the Sprite will
+ * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will
+ * vary slightly between frames.
+ *
+ * This feature is dependent on the tick event object (or an object with an appropriate "delta" property) being
+ * passed into {{#crossLink "Stage/update"}}{{/crossLink}}.
+ * @property framerate
* @type {Number}
- * @default 1
+ * @default 0
**/
- this._cacheScale = 1;
+ this.framerate = 0;
- /**
- * @property _cacheDataURLID
- * @protected
- * @type {Number}
- * @default 0
- */
- this._cacheDataURLID = 0;
-
- /**
- * @property _cacheDataURL
- * @protected
- * @type {String}
- * @default null
- */
- this._cacheDataURL = null;
+ // private properties:
/**
- * @property _props
+ * Current animation object.
+ * @property _animation
* @protected
- * @type {DisplayObject}
+ * @type {Object}
* @default null
**/
- this._props = new createjs.DisplayProps();
+ this._animation = null;
/**
- * @property _rectangle
+ * Current frame index.
+ * @property _currentFrame
* @protected
- * @type {Rectangle}
+ * @type {Number}
* @default null
**/
- this._rectangle = new createjs.Rectangle();
-
+ this._currentFrame = null;
+
/**
- * @property _bounds
+ * Skips the next auto advance. Used by gotoAndPlay to avoid immediately jumping to the next frame
+ * @property _skipAdvance
* @protected
- * @type {Rectangle}
- * @default null
+ * @type {Boolean}
+ * @default false
**/
- this._bounds = null;
- }
- var p = createjs.extend(DisplayObject, createjs.EventDispatcher);
-
- // TODO: deprecated
- // p.initialize = function() {}; // searchable for devs wondering where it is. REMOVED. See docs for details.
-
-// static properties:
- /**
- * Listing of mouse event names. Used in _hasMouseEventListener.
- * @property _MOUSE_EVENTS
- * @protected
- * @static
- * @type {Array}
- **/
- DisplayObject._MOUSE_EVENTS = ["click","dblclick","mousedown","mouseout","mouseover","pressmove","pressup","rollout","rollover"];
-
- /**
- * Suppresses errors generated when using features like hitTest, mouse events, and {{#crossLink "getObjectsUnderPoint"}}{{/crossLink}}
- * with cross domain content.
- * @property suppressCrossDomainErrors
- * @static
- * @type {Boolean}
- * @default false
- **/
- DisplayObject.suppressCrossDomainErrors = false;
-
- /**
- * @property _snapToPixelEnabled
- * @protected
- * @static
- * @type {Boolean}
- * @default false
- **/
- DisplayObject._snapToPixelEnabled = false; // stage.snapToPixelEnabled is temporarily copied here during a draw to provide global access.
-
- /**
- * @property _hitTestCanvas
- * @type {HTMLCanvasElement | Object}
- * @static
- * @protected
- **/
- /**
- * @property _hitTestContext
- * @type {CanvasRenderingContext2D}
- * @static
- * @protected
- **/
- var canvas = createjs.createCanvas?createjs.createCanvas():document.createElement("canvas"); // prevent errors on load in browsers without canvas.
- if (canvas.getContext) {
- DisplayObject._hitTestCanvas = canvas;
- DisplayObject._hitTestContext = canvas.getContext("2d");
- canvas.width = canvas.height = 1;
+ this._skipAdvance = false;
+
+
+ if (frameOrAnimation != null) { this.gotoAndPlay(frameOrAnimation); }
}
+ var p = createjs.extend(Sprite, createjs.DisplayObject);
/**
- * @property _nextCacheID
- * @type {Number}
- * @static
- * @protected
+ * Constructor alias for backwards compatibility. This method will be removed in future versions.
+ * Subclasses should be updated to use {{#crossLink "Utility Methods/extends"}}{{/crossLink}}.
+ * @method initialize
+ * @deprecated in favour of `createjs.promote()`
**/
- DisplayObject._nextCacheID = 1;
+ p.initialize = Sprite; // TODO: Deprecated. This is for backwards support of FlashCC spritesheet export.
// events:
/**
- * Dispatched when the user presses their left mouse button over the display object. See the
- * {{#crossLink "MouseEvent"}}{{/crossLink}} class for a listing of event properties.
- * @event mousedown
- * @since 0.6.0
- */
-
- /**
- * Dispatched when the user presses their left mouse button and then releases it while over the display object.
- * See the {{#crossLink "MouseEvent"}}{{/crossLink}} class for a listing of event properties.
- * @event click
- * @since 0.6.0
- */
-
- /**
- * Dispatched when the user double clicks their left mouse button over this display object.
- * See the {{#crossLink "MouseEvent"}}{{/crossLink}} class for a listing of event properties.
- * @event dblclick
+ * Dispatched when an animation reaches its ends.
+ * @event animationend
+ * @param {Object} target The object that dispatched the event.
+ * @param {String} type The event type.
+ * @param {String} name The name of the animation that just ended.
+ * @param {String} next The name of the next animation that will be played, or null. This will be the same as name if the animation is looping.
* @since 0.6.0
*/
/**
- * Dispatched when the user's mouse enters this display object. This event must be enabled using
- * {{#crossLink "Stage/enableMouseOver"}}{{/crossLink}}. See also {{#crossLink "DisplayObject/rollover:event"}}{{/crossLink}}.
- * See the {{#crossLink "MouseEvent"}}{{/crossLink}} class for a listing of event properties.
- * @event mouseover
- * @since 0.6.0
+ * Dispatched any time the current frame changes. For example, this could be due to automatic advancement on a tick,
+ * or calling gotoAndPlay() or gotoAndStop().
+ * @event change
+ * @param {Object} target The object that dispatched the event.
+ * @param {String} type The event type.
*/
+
+// public methods:
/**
- * Dispatched when the user's mouse leaves this display object. This event must be enabled using
- * {{#crossLink "Stage/enableMouseOver"}}{{/crossLink}}. See also {{#crossLink "DisplayObject/rollout:event"}}{{/crossLink}}.
- * See the {{#crossLink "MouseEvent"}}{{/crossLink}} class for a listing of event properties.
- * @event mouseout
- * @since 0.6.0
- */
-
- /**
- * This event is similar to {{#crossLink "DisplayObject/mouseover:event"}}{{/crossLink}}, with the following
- * differences: it does not bubble, and it considers {{#crossLink "Container"}}{{/crossLink}} instances as an
- * aggregate of their content.
- *
- * For example, myContainer contains two overlapping children: shapeA and shapeB. The user moves their mouse over
- * shapeA and then directly on to shapeB. With a listener for {{#crossLink "mouseover:event"}}{{/crossLink}} on
- * myContainer, two events would be received, each targeting a child element:true
if the draw was handled (useful for overriding functionality).
+ * Advances the playhead. This occurs automatically each tick by default.
+ * @param [time] {Number} The amount of time in ms to advance by. Only applicable if framerate is set on the Sprite
+ * or its SpriteSheet.
+ * @method advance
+ */
+ p.advance = function(time) {
+ var fps = this.framerate || this.spriteSheet.framerate;
+ var t = (fps && time != null) ? time/(1000/fps) : 1;
+ this._normalizeFrame(t);
+ };
+
+ /**
+ * Returns a {{#crossLink "Rectangle"}}{{/crossLink}} instance defining the bounds of the current frame relative to
+ * the origin. For example, a 90 x 70 frame with regX=50
and regY=40
would return a
+ * rectangle with [x=-50, y=-40, width=90, height=70]. This ignores transformations on the display object.
*
- * 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).
- * @return {Boolean}
+ * Also see the SpriteSheet {{#crossLink "SpriteSheet/getFrameBounds"}}{{/crossLink}} method.
+ * @method getBounds
+ * @return {Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully
+ * loaded.
**/
- p.draw = function(ctx, ignoreCache) {
- var cacheCanvas = this.cacheCanvas;
- if (ignoreCache || !cacheCanvas) { return false; }
- var scale = this._cacheScale;
- ctx.drawImage(cacheCanvas, this._cacheOffsetX+this._filterOffsetX, this._cacheOffsetY+this._filterOffsetY, cacheCanvas.width/scale, cacheCanvas.height/scale);
- return true;
+ p.getBounds = function() {
+ // TODO: should this normalizeFrame?
+ return this.DisplayObject_getBounds() || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);
};
-
+
/**
- * Applies this display object's transformation, alpha, globalCompositeOperation, clipping path (mask), and shadow
- * to the specified context. This is typically called prior to {{#crossLink "DisplayObject/draw"}}{{/crossLink}}.
- * @method updateContext
- * @param {CanvasRenderingContext2D} ctx The canvas 2D to update.
+ * Returns a clone of the Sprite instance. Note that the same SpriteSheet is shared between cloned
+ * instances.
+ * @method clone
+ * @return {Sprite} a clone of the Sprite instance.
**/
- p.updateContext = function(ctx) {
- var o=this, mask=o.mask, mtx= o._props.matrix;
-
- if (mask && mask.graphics && !mask.graphics.isEmpty()) {
- mask.getMatrix(mtx);
- ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
-
- mask.graphics.drawAsPath(ctx);
- ctx.clip();
-
- mtx.invert();
- ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, mtx.tx, mtx.ty);
- }
-
- this.getMatrix(mtx);
- var tx = mtx.tx, ty = mtx.ty;
- if (DisplayObject._snapToPixelEnabled && o.snapToPixel) {
- tx = tx + (tx < 0 ? -0.5 : 0.5) | 0;
- ty = ty + (ty < 0 ? -0.5 : 0.5) | 0;
- }
- ctx.transform(mtx.a, mtx.b, mtx.c, mtx.d, tx, ty);
- ctx.globalAlpha *= o.alpha;
- if (o.compositeOperation) { ctx.globalCompositeOperation = o.compositeOperation; }
- if (o.shadow) { this._applyShadow(ctx, o.shadow); }
+ p.clone = function() {
+ return this._cloneProps(new Sprite(this.spriteSheet));
};
/**
- * Draws the display object into a new canvas, which is then used for subsequent draws. For complex content
- * 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()
or cache()
again. You must specify
- * the cache 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.
- *
- * currentFrame
if paused is not true. This is called automatically when the {{#crossLink "Stage"}}{{/crossLink}}
+ * ticks.
+ * @param {Object} evtObj An event object that will be dispatched to all tick listeners. This object is reused between dispatchers to reduce construction & GC costs.
+ * @protected
+ * @method _tick
+ **/
+ p._tick = function(evtObj) {
+ if (!this.paused) {
+ if (!this._skipAdvance) { this.advance(evtObj&&evtObj.delta); }
+ this._skipAdvance = false;
}
+ this.DisplayObject__tick(evtObj);
+ };
+
+
+ /**
+ * Normalizes the current frame, advancing animations and dispatching callbacks as appropriate.
+ * @protected
+ * @method _normalizeFrame
+ **/
+ p._normalizeFrame = function(frameDelta) {
+ frameDelta = frameDelta || 0;
+ var animation = this._animation;
+ var paused = this.paused;
+ var frame = this._currentFrame;
+ var l;
- ctx.save();
- ctx.globalCompositeOperation = compositeOperation;
- ctx.setTransform(scale, 0, 0, scale, -offX, -offY);
- this.draw(ctx, true);
- // TODO: filters and cache scale don't play well together at present.
- this._applyFilters();
- ctx.restore();
- this.cacheID = DisplayObject._nextCacheID++;
+ if (animation) {
+ var speed = animation.speed || 1;
+ var animFrame = this.currentAnimationFrame;
+ l = animation.frames.length;
+ if (animFrame + frameDelta * speed >= l) {
+ var next = animation.next;
+ if (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {
+ // something changed in the event stack, so we shouldn't make any more changes here.
+ return;
+ } else if (next) {
+ // sequence. Automatically calls _normalizeFrame again with the remaining frames.
+ return this._goto(next, frameDelta - (l - animFrame) / speed);
+ } else {
+ // end.
+ this.paused = true;
+ animFrame = animation.frames.length - 1;
+ }
+ } else {
+ animFrame += frameDelta * speed;
+ }
+ this.currentAnimationFrame = animFrame;
+ this._currentFrame = animation.frames[animFrame | 0]
+ } else {
+ frame = (this._currentFrame += frameDelta);
+ l = this.spriteSheet.getNumFrames();
+ if (frame >= l && l > 0) {
+ if (!this._dispatchAnimationEnd(animation, frame, paused, l - 1)) {
+ // looped.
+ if ((this._currentFrame -= l) >= l) { return this._normalizeFrame(); }
+ }
+ }
+ }
+ frame = this._currentFrame | 0;
+ if (this.currentFrame != frame) {
+ this.currentFrame = frame;
+ this.dispatchEvent("change");
+ }
};
/**
- * Clears the current cache. See {{#crossLink "DisplayObject/cache"}}{{/crossLink}} for more information.
- * @method uncache
+ * Dispatches the "animationend" event. Returns true if a handler changed the animation (ex. calling {{#crossLink "Sprite/stop"}}{{/crossLink}},
+ * {{#crossLink "Sprite/gotoAndPlay"}}{{/crossLink}}, etc.)
+ * @property _dispatchAnimationEnd
+ * @private
+ * @type {Function}
**/
- p.uncache = function() {
- this._cacheDataURL = this.cacheCanvas = null;
- this.cacheID = this._cacheOffsetX = this._cacheOffsetY = this._filterOffsetX = this._filterOffsetY = 0;
- this._cacheScale = 1;
+ p._dispatchAnimationEnd = function(animation, frame, paused, next, end) {
+ var name = animation ? animation.name : null;
+ if (this.hasEventListener("animationend")) {
+ var evt = new createjs.Event("animationend");
+ evt.name = name;
+ evt.next = next;
+ this.dispatchEvent(evt);
+ }
+ // did the animation get changed in the event stack?:
+ var changed = (this._animation != animation || this._currentFrame != frame);
+ // if the animation hasn't changed, but the sprite was paused, then we want to stick to the last frame:
+ if (!changed && !paused && this.paused) { this.currentAnimationFrame = end; changed = true; }
+ return changed;
};
-
+
/**
- * Returns a data URL for the cache, or null if this display object is not cached.
- * Uses cacheID to ensure a new data URL is not generated if the cache has not changed.
- * @method getCacheDataURL
- * @return {String} The image data url for the cache.
+ * Moves the playhead to the specified frame number or animation.
+ * @method _goto
+ * @param {String|Number} frameOrAnimation The frame number or animation that the playhead should move to.
+ * @param {Boolean} [frame] The frame of the animation to go to. Defaults to 0.
+ * @protected
**/
- p.getCacheDataURL = function() {
- if (!this.cacheCanvas) { return null; }
- if (this.cacheID != this._cacheDataURLID) { this._cacheDataURL = this.cacheCanvas.toDataURL(); }
- return this._cacheDataURL;
+ p._goto = function(frameOrAnimation, frame) {
+ this.currentAnimationFrame = 0;
+ if (isNaN(frameOrAnimation)) {
+ var data = this.spriteSheet.getAnimation(frameOrAnimation);
+ if (data) {
+ this._animation = data;
+ this.currentAnimation = frameOrAnimation;
+ this._normalizeFrame(frame);
+ }
+ } else {
+ this.currentAnimation = this._animation = null;
+ this._currentFrame = frameOrAnimation;
+ this._normalizeFrame();
+ }
};
+
+ createjs.Sprite = createjs.promote(Sprite, "DisplayObject");
+}());
+
+//##############################################################################
+// Shape.js
+//##############################################################################
+
+this.createjs = this.createjs||{};
+
+(function() {
+ "use strict";
+
+
+// constructor:
/**
- * Transforms the specified x and y position from the coordinate space of the display object
- * to the global (stage) coordinate space. For example, this could be used to position an HTML label
- * over a specific point on a nested display object. Returns a Point instance with x and y properties
- * correlating to the transformed coordinates on the stage.
+ * A Shape allows you to display vector art in the display list. It composites a {{#crossLink "Graphics"}}{{/crossLink}}
+ * instance which exposes all of the vector drawing methods. The Graphics instance can be shared between multiple Shape
+ * instances to display the same vector graphics with different positions or transforms.
+ *
+ * If the vector art will not
+ * change between draws, you may want to use the {{#crossLink "DisplayObject/cache"}}{{/crossLink}} method to reduce the
+ * rendering cost.
*
* All | - * All display objects support setting bounds manually using setBounds(). Likewise, display objects that - * have been cached using cache() will return the bounds of their cache. Manual and cache bounds will override - * the automatic calculations listed below. - * |
Bitmap | - * Returns the width and height of the sourceRect (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(). - * |
Shape | - * 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". - * |
BitmapText | - * Returns approximate bounds. Values will be more accurate if spritesheet frame registration points are close - * to (x=0,y=0). - * |
lineHeight
(if specified) or {{#crossLink "Text/getMeasuredLineHeight"}}{{/crossLink}}. Note that
+ * this operation requires the text flowing logic to run, which has an associated CPU cost.
+ * @method getMeasuredHeight
+ * @return {Number} The approximate height of the untransformed multi-line text.
**/
- p.getTransformedBounds = function() {
- return this._getBounds();
+ p.getMeasuredHeight = function() {
+ return this._drawText(null,{}).height;
+ };
+
+ /**
+ * Docced in superclass.
+ */
+ p.getBounds = function() {
+ var rect = this.DisplayObject_getBounds();
+ if (rect) { return rect; }
+ if (this.text == null || this.text === "") { return null; }
+ var o = this._drawText(null, {});
+ var w = (this.maxWidth && this.maxWidth < o.width) ? this.maxWidth : o.width;
+ var x = w * Text.H_OFFSETS[this.textAlign||"left"];
+ var lineHeight = this.lineHeight||this.getMeasuredLineHeight();
+ var y = lineHeight * Text.V_OFFSETS[this.textBaseline||"top"];
+ return this._rectangle.setValues(x, y, w, o.height);
};
/**
- * Allows you to manually specify the bounds of an object that either cannot calculate their own bounds (ex. Shape &
- * Text) for future reference, or so the object can be included in Container bounds. Manually set bounds will always
- * override calculated bounds.
- *
- * The bounds should be specified in the object's local (untransformed) coordinates. For example, a Shape instance
- * with a 25px radius circle centered at 0,0 would have bounds of (-25, -25, 50, 50).
- * @method setBounds
- * @param {Number} x The x origin of the bounds. Pass null to remove the manual bounds.
- * @param {Number} y The y origin of the bounds.
- * @param {Number} width The width of the bounds.
- * @param {Number} height The height of the bounds.
+ * Returns an object with width, height, and lines properties. The width and height are the visual width and height
+ * of the drawn text. The lines property contains an array of strings, one for
+ * each line of text that will be drawn, accounting for line breaks and wrapping. These strings have trailing
+ * whitespace removed.
+ * @method getMetrics
+ * @return {Object} An object with width, height, and lines properties.
**/
- p.setBounds = function(x, y, width, height) {
- if (x == null) { this._bounds = x; }
- this._bounds = (this._bounds || new createjs.Rectangle()).setValues(x, y, width, height);
+ p.getMetrics = function() {
+ var o = {lines:[]};
+ o.lineHeight = this.lineHeight || this.getMeasuredLineHeight();
+ o.vOffset = o.lineHeight * Text.V_OFFSETS[this.textBaseline||"top"];
+ return this._drawText(null, o, o.lines);
};
/**
- * Returns a clone of this DisplayObject. Some properties that are specific to this instance's current context are
- * reverted to their defaults (for example .parent). Caches are not maintained across clones, and some elements
- * are copied by reference (masks, individual filter instances, hit area)
+ * Returns a clone of the Text instance.
* @method clone
- * @return {DisplayObject} A clone of the current DisplayObject instance.
+ * @return {Text} a clone of the Text instance.
**/
p.clone = function() {
- return this._cloneProps(new DisplayObject());
+ return this._cloneProps(new Text(this.text, this.font, this.color));
};
/**
@@ -6894,278 +10040,802 @@ this.createjs = this.createjs||{};
* @return {String} a string representation of the instance.
**/
p.toString = function() {
- return "[DisplayObject (name="+ this.name +")]";
+ return "[Text (text="+ (this.text.length > 20 ? this.text.substr(0, 17)+"..." : this.text) +")]";
};
// private methods:
- // separated so it can be used more easily in subclasses:
/**
* @method _cloneProps
- * @param {DisplayObject} o The DisplayObject instance which will have properties from the current DisplayObject
- * instance copied into.
- * @return {DisplayObject} o
+ * @param {Text} o
* @protected
+ * @return {Text} o
**/
p._cloneProps = function(o) {
- o.alpha = this.alpha;
- o.mouseEnabled = this.mouseEnabled;
- o.tickEnabled = this.tickEnabled;
- o.name = this.name;
- o.regX = this.regX;
- o.regY = this.regY;
- o.rotation = this.rotation;
- o.scaleX = this.scaleX;
- o.scaleY = this.scaleY;
- o.shadow = this.shadow;
- o.skewX = this.skewX;
- o.skewY = this.skewY;
- o.visible = this.visible;
- o.x = this.x;
- o.y = this.y;
- o.compositeOperation = this.compositeOperation;
- o.snapToPixel = this.snapToPixel;
- o.filters = this.filters==null?null:this.filters.slice(0);
- o.mask = this.mask;
- o.hitArea = this.hitArea;
- o.cursor = this.cursor;
- o._bounds = this._bounds;
+ this.DisplayObject__cloneProps(o);
+ o.textAlign = this.textAlign;
+ o.textBaseline = this.textBaseline;
+ o.maxWidth = this.maxWidth;
+ o.outline = this.outline;
+ o.lineHeight = this.lineHeight;
+ o.lineWidth = this.lineWidth;
+ return o;
+ };
+
+ /**
+ * @method _getWorkingContext
+ * @param {CanvasRenderingContext2D} ctx
+ * @return {CanvasRenderingContext2D}
+ * @protected
+ **/
+ p._prepContext = function(ctx) {
+ ctx.font = this.font||"10px sans-serif";
+ ctx.textAlign = this.textAlign||"left";
+ ctx.textBaseline = this.textBaseline||"top";
+ return ctx;
+ };
+
+ /**
+ * Draws multiline text.
+ * @method _drawText
+ * @param {CanvasRenderingContext2D} ctx
+ * @param {Object} o
+ * @param {Array} lines
+ * @return {Object}
+ * @protected
+ **/
+ p._drawText = function(ctx, o, lines) {
+ var paint = !!ctx;
+ if (!paint) {
+ ctx = Text._workingContext;
+ ctx.save();
+ this._prepContext(ctx);
+ }
+ var lineHeight = this.lineHeight||this.getMeasuredLineHeight();
+
+ var maxW = 0, count = 0;
+ var hardLines = String(this.text).split(/(?:\r\n|\r|\n)/);
+ for (var i=0, l=hardLines.length; itransform
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.
- *
- * 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
+ * @extends Container
+ * @constructor
+ * @param {String} [mode=independent] Initial value for the mode property. One of {{#crossLink "MovieClip/INDEPENDENT:property"}}{{/crossLink}},
+ * {{#crossLink "MovieClip/SINGLE_FRAME:property"}}{{/crossLink}}, or {{#crossLink "MovieClip/SYNCHED:property"}}{{/crossLink}}.
+ * The default is {{#crossLink "MovieClip/INDEPENDENT:property"}}{{/crossLink}}.
+ * @param {Number} [startPosition=0] Initial value for the {{#crossLink "MovieClip/startPosition:property"}}{{/crossLink}}
+ * property.
+ * @param {Boolean} [loop=true] Initial value for the {{#crossLink "MovieClip/loop:property"}}{{/crossLink}}
+ * property. The default is `true`.
+ * @param {Object} [labels=null] A hash of labels to pass to the {{#crossLink "MovieClip/timeline:property"}}{{/crossLink}}
+ * instance associated with this MovieClip. Labels only need to be passed if they need to be used.
+ **/
+ function MovieClip(mode, startPosition, loop, labels) {
+ this.Container_constructor();
+ !MovieClip.inited&&MovieClip.init(); // static init
+
// public properties:
/**
- * The array of children in the display list. You should usually use the child management methods such as
- * {{#crossLink "Container/addChild"}}{{/crossLink}}, {{#crossLink "Container/removeChild"}}{{/crossLink}},
- * {{#crossLink "Container/swapChildren"}}{{/crossLink}}, etc, rather than accessing this directly, but it is
- * included for advanced uses.
- * @property children
- * @type Array
+ * Controls how this MovieClip advances its time. Must be one of 0 (INDEPENDENT), 1 (SINGLE_FRAME), or 2 (SYNCHED).
+ * See each constant for a description of the behaviour.
+ * @property mode
+ * @type String
* @default null
**/
- this.children = [];
-
+ this.mode = mode||MovieClip.INDEPENDENT;
+
/**
- * Indicates whether the children of this container are independently enabled for mouse/pointer interaction.
- * If false, the children will be aggregated under the container - for example, a click on a child shape would
- * trigger a click event on the container.
- * @property mouseChildren
+ * Specifies what the first frame to play in this movieclip, or the only frame to display if mode is SINGLE_FRAME.
+ * @property startPosition
+ * @type Number
+ * @default 0
+ */
+ this.startPosition = startPosition || 0;
+
+ /**
+ * Indicates whether this MovieClip should loop when it reaches the end of its timeline.
+ * @property loop
+ * @type Boolean
+ * @default true
+ */
+ this.loop = loop;
+
+ /**
+ * The current frame of the movieclip.
+ * @property currentFrame
+ * @type Number
+ * @default 0
+ * @readonly
+ */
+ this.currentFrame = 0;
+
+ /**
+ * The TweenJS Timeline that is associated with this MovieClip. This is created automatically when the MovieClip
+ * instance is initialized. Animations are created by adding TweenJS Tween
+ * instances to the timeline.
+ *
+ * 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})
+ * .wait(1).to({_off:false});
+ *
+ * @property timeline
+ * @type Timeline
+ * @default null
+ */
+ this.timeline = new createjs.Timeline(null, labels, {paused:true, position:startPosition, useTicks:true});
+
+ /**
+ * If true, the MovieClip's position will not advance when ticked.
+ * @property paused
+ * @type Boolean
+ * @default false
+ */
+ this.paused = false;
+
+ /**
+ * If true, actions in this MovieClip's tweens will be run when the playhead advances.
+ * @property actionsEnabled
+ * @type Boolean
+ * @default true
+ */
+ this.actionsEnabled = true;
+
+ /**
+ * 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.
+ * Array.sort
- * documentation for details.
- **/
- p.sortChildren = function(sortFunction) {
- this.children.sort(sortFunction);
+ var sfx = "_"+(h?"h":"")+(v?"v":"");
+ var names = spriteSheet._animations;
+ var data = spriteSheet._data;
+ var al = names.length/count;
+ for (i=0;igetObjectsUnderPoint()
, 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.
- * @param {Number} y The y position in the container to test.
- * @param {Number} mode The mode to use to determine which display objects to include. 0-all, 1-respect mouseEnabled/mouseChildren, 2-only mouse opaque objects.
- * @return {DisplayObject} The top-most display object under the specified coordinates.
+ * Adds an animation that will be included in the created {{#crossLink "SpriteSheet"}}{{/crossLink}}.
+ * @method addAnimation
+ * @param {String} name The name for the animation.
+ * @param {Array} frames An array of frame indexes that comprise the animation. Ex. [3,6,5] would describe an animation
+ * that played frame indexes 3, 6, and 5 in that order.
+ * @param {String} [next] Specifies the name of the animation to continue to after this animation ends. You can
+ * also pass false to have the animation stop when it ends. By default it will loop to the start of the same animation.
+ * @param {Number} [speed] Specifies a frame advance speed for this animation. For example, a value of 0.5 would
+ * cause the animation to advance every second tick. Note that earlier versions used `frequency` instead, which had
+ * the opposite effect.
**/
- p.getObjectUnderPoint = function(x, y, mode) {
- var pt = this.localToGlobal(x, y);
- return this._getObjectsUnderPoint(pt.x, pt.y, null, mode>0, mode==1);
+ p.addAnimation = function(name, frames, next, speed) {
+ if (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }
+ this._animations[name] = {frames:frames, next:next, speed:speed};
};
-
+
/**
- * Docced in superclass.
- */
- p.getBounds = function() {
- return this._getBounds(null, true);
+ * This will take a {{#crossLink "MovieClip"}}{{/crossLink}} instance, and add its frames and labels to this
+ * builder. Labels will be added as an animation running from the label index to the next label. For example, if
+ * there is a label named "foo" at frame 0 and a label named "bar" at frame 10, in a MovieClip with 15 frames, it
+ * will add an animation named "foo" that runs from frame index 0 to 9, and an animation named "bar" that runs from
+ * frame index 10 to 14.
+ *
+ * Note that this will iterate through the full MovieClip with {{#crossLink "MovieClip/actionsEnabled:property"}}{{/crossLink}}
+ * set to `false`, ending on the last frame.
+ * @method addMovieClip
+ * @param {MovieClip} source The source MovieClip instance to add to the SpriteSheet.
+ * @param {Rectangle} [sourceRect] A {{#crossLink "Rectangle"}}{{/crossLink}} defining the portion of the source to
+ * draw to the frame. If not specified, it will look for a {{#crossLink "DisplayObject/getBounds"}}{{/crossLink}}
+ * method, `frameBounds` Array, `bounds` property, or `nominalBounds` property on the source to use. If one is not
+ * found, the MovieClip will be skipped.
+ * @param {Number} [scale=1] The scale to draw the movie clip at.
+ * @param {Function} [setupFunction] A function to call immediately before drawing each frame. It will be called
+ * with three parameters: the source, setupData, and the frame index.
+ * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.
+ * @param {Function} [labelFunction] This method will be called for each MovieClip label that is added with four
+ * parameters: the label name, the source MovieClip instance, the starting frame index (in the movieclip timeline)
+ * and the end index. It must return a new name for the label/animation, or `false` to exclude the label.
+ **/
+ p.addMovieClip = function(source, sourceRect, scale, setupFunction, setupData, labelFunction) {
+ if (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }
+ var rects = source.frameBounds;
+ var rect = sourceRect||source.bounds||source.nominalBounds;
+ if (!rect&&source.getBounds) { rect = source.getBounds(); }
+ if (!rect && !rects) { return; }
+
+ var i, l, baseFrameIndex = this._frames.length;
+ var duration = source.timeline.duration;
+ for (i=0; ifalse
- * to manually control clearing (for generative art, or when pointing multiple stages at the same canvas for
- * example).
- *
- * delta
and paused
parameters.
- * @property handleEvent
- * @type Function
- **/
- p.handleEvent = function(evt) {
- if (evt.type == "tick") { this.update(evt); }
- };
-
- /**
- * Clears the target canvas. Useful if {{#crossLink "Stage/autoClear:property"}}{{/crossLink}} is set to `false`.
- * @method clear
- **/
- p.clear = function() {
- if (!this.canvas) { return; }
- var ctx = this.canvas.getContext("2d");
- ctx.setTransform(1, 0, 0, 1, 0, 0);
- ctx.clearRect(0, 0, this.canvas.width+1, this.canvas.height+1);
- };
-
- /**
- * Returns a data url that contains a Base64-encoded image of the contents of the stage. The returned data url can
- * be specified as the src value of an image element.
- * @method toDataURL
- * @param {String} [backgroundColor] The background color to be used for the generated image. Any valid CSS color
- * 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.
- * @return {String} a Base64 encoded image.
- **/
- p.toDataURL = function(backgroundColor, mimeType) {
- var data, ctx = this.canvas.getContext('2d'), w = this.canvas.width, h = this.canvas.height;
-
- if (backgroundColor) {
- data = ctx.getImageData(0, 0, w, h);
- var compositeOperation = ctx.globalCompositeOperation;
- ctx.globalCompositeOperation = "destination-over";
-
- ctx.fillStyle = backgroundColor;
- ctx.fillRect(0, 0, w, h);
- }
-
- var dataURL = this.canvas.toDataURL(mimeType||"image/png");
-
- if(backgroundColor) {
- ctx.putImageData(data, 0, 0);
- ctx.globalCompositeOperation = compositeOperation;
- }
-
- return dataURL;
- };
-
- /**
- * Enables or disables (by passing a frequency of 0) mouse over ({{#crossLink "DisplayObject/mouseover:event"}}{{/crossLink}}
- * and {{#crossLink "DisplayObject/mouseout:event"}}{{/crossLink}}) and roll over events ({{#crossLink "DisplayObject/rollover:event"}}{{/crossLink}}
- * and {{#crossLink "DisplayObject/rollout:event"}}{{/crossLink}}) for this stage's display list. These events can
- * be expensive to generate, so they are disabled by default. The frequency of the events can be controlled
- * independently of mouse move events via the optional `frequency` parameter.
- *
- * currentFrame
.
- * @property paused
- * @type {Boolean}
- * @default false
- **/
- this.paused = true;
-
- /**
- * The SpriteSheet instance to play back. This includes the source image, frame dimensions, and frame
- * data. See {{#crossLink "SpriteSheet"}}{{/crossLink}} for more information.
- * @property spriteSheet
- * @type {SpriteSheet}
- * @readonly
- **/
- this.spriteSheet = spriteSheet;
-
- /**
- * Specifies the current frame index within the currently playing animation. When playing normally, this will increase
- * from 0 to n-1, where n is the number of frames in the current animation.
- *
- * This could be a non-integer value if
- * using time-based playback (see {{#crossLink "Sprite/framerate"}}{{/crossLink}}, or if the animation's speed is
- * not an integer.
- * @property currentAnimationFrame
- * @type {Number}
- * @default 0
- **/
- this.currentAnimationFrame = 0;
-
- /**
- * By default Sprite instances advance one frame per tick. Specifying a framerate for the Sprite (or its related
- * SpriteSheet) will cause it to advance based on elapsed time between ticks as appropriate to maintain the target
- * framerate.
- *
- * For example, if a Sprite with a framerate of 10 is placed on a Stage being updated at 40fps, then the Sprite will
- * advance roughly one frame every 4 ticks. This will not be exact, because the time between each tick will
- * vary slightly between frames.
- *
- * This feature is dependent on the tick event object (or an object with an appropriate "delta" property) being
- * passed into {{#crossLink "Stage/update"}}{{/crossLink}}.
- * @property framerate
- * @type {Number}
- * @default 0
- **/
- this.framerate = 0;
-
-
- // private properties:
- /**
- * Current animation object.
- * @property _animation
- * @protected
- * @type {Object}
- * @default null
- **/
- this._animation = null;
-
- /**
- * Current frame index.
- * @property _currentFrame
- * @protected
- * @type {Number}
- * @default null
- **/
- this._currentFrame = null;
-
- /**
- * Skips the next auto advance. Used by gotoAndPlay to avoid immediately jumping to the next frame
- * @property _skipAdvance
- * @protected
- * @type {Boolean}
- * @default false
- **/
- this._skipAdvance = false;
-
-
- if (frameOrAnimation != null) { this.gotoAndPlay(frameOrAnimation); }
- }
- var p = createjs.extend(Sprite, createjs.DisplayObject);
-
- /**
- * Constructor alias for backwards compatibility. This method will be removed in future versions.
- * Subclasses should be updated to use {{#crossLink "Utility Methods/extends"}}{{/crossLink}}.
- * @method initialize
- * @deprecated in favour of `createjs.promote()`
- **/
- p.initialize = Sprite; // TODO: Deprecated. This is for backwards support of FlashCC spritesheet export.
-
-
-// events:
- /**
- * Dispatched when an animation reaches its ends.
- * @event animationend
- * @param {Object} target The object that dispatched the event.
- * @param {String} type The event type.
- * @param {String} name The name of the animation that just ended.
- * @param {String} next The name of the next animation that will be played, or null. This will be the same as name if the animation is looping.
- * @since 0.6.0
- */
-
- /**
- * Dispatched any time the current frame changes. For example, this could be due to automatic advancement on a tick,
- * or calling gotoAndPlay() or gotoAndStop().
- * @event change
- * @param {Object} target The object that dispatched the event.
- * @param {String} type The event type.
- */
-
-
-// public methods:
- /**
- * Returns true or false indicating whether the display object would be visible if drawn to a canvas.
- * This does not account for whether it would be visible within the boundaries of the stage.
- * NOTE: This method is mainly for internal use, though it may be useful for advanced uses.
- * @method isVisible
- * @return {Boolean} Boolean indicating whether the display object would be visible if drawn to a canvas
- **/
- p.isVisible = function() {
- var hasContent = this.cacheCanvas || this.spriteSheet.complete;
- return !!(this.visible && this.alpha > 0 && this.scaleX != 0 && this.scaleY != 0 && hasContent);
- };
-
- /**
- * 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).
- * 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 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) {
- if (this.DisplayObject_draw(ctx, ignoreCache)) { return true; }
- this._normalizeFrame();
- var o = this.spriteSheet.getFrame(this._currentFrame|0);
- if (!o) { return false; }
- var rect = o.rect;
- if (rect.width && rect.height) { ctx.drawImage(o.image, rect.x, rect.y, rect.width, rect.height, -o.regX, -o.regY, rect.width, rect.height); }
- return true;
- };
-
- //Note, the doc sections below document using the specified APIs (from DisplayObject) from
- //Bitmap. This is why they have no method implementations.
-
- /**
- * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.
- * You should not cache Sprite instances as it can degrade performance.
- * @method cache
- **/
-
- /**
- * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.
- * You should not cache Sprite instances as it can degrade performance.
- * @method updateCache
- **/
-
- /**
- * Because the content of a Sprite is already in a raster format, cache is unnecessary for Sprite instances.
- * You should not cache Sprite instances as it can degrade performance.
- * @method uncache
- **/
-
- /**
- * Play (unpause) the current animation. The Sprite will be paused if either {{#crossLink "Sprite/stop"}}{{/crossLink}}
- * or {{#crossLink "Sprite/gotoAndStop"}}{{/crossLink}} is called. Single frame animations will remain
- * unchanged.
- * @method play
- **/
- p.play = function() {
- this.paused = false;
- };
-
- /**
- * Stop playing a running animation. The Sprite will be playing if {{#crossLink "Sprite/gotoAndPlay"}}{{/crossLink}}
- * is called. Note that calling {{#crossLink "Sprite/gotoAndPlay"}}{{/crossLink}} or {{#crossLink "Sprite/play"}}{{/crossLink}}
- * will resume playback.
- * @method stop
- **/
- p.stop = function() {
- this.paused = true;
- };
-
- /**
- * Sets paused to false and plays the specified animation name, named frame, or frame number.
- * @method gotoAndPlay
- * @param {String|Number} frameOrAnimation The frame number or animation name that the playhead should move to
- * and begin playing.
- **/
- p.gotoAndPlay = function(frameOrAnimation) {
- this.paused = false;
- this._skipAdvance = true;
- this._goto(frameOrAnimation);
- };
-
- /**
- * Sets paused to true and seeks to the specified animation name, named frame, or frame number.
- * @method gotoAndStop
- * @param {String|Number} frameOrAnimation The frame number or animation name that the playhead should move to
- * and stop.
- **/
- p.gotoAndStop = function(frameOrAnimation) {
- this.paused = true;
- this._goto(frameOrAnimation);
- };
-
- /**
- * Advances the playhead. This occurs automatically each tick by default.
- * @param [time] {Number} The amount of time in ms to advance by. Only applicable if framerate is set on the Sprite
- * or its SpriteSheet.
- * @method advance
- */
- p.advance = function(time) {
- var fps = this.framerate || this.spriteSheet.framerate;
- var t = (fps && time != null) ? time/(1000/fps) : 1;
- this._normalizeFrame(t);
- };
-
- /**
- * Returns a {{#crossLink "Rectangle"}}{{/crossLink}} instance defining the bounds of the current frame relative to
- * the origin. For example, a 90 x 70 frame with regX=50
and regY=40
would return a
- * rectangle with [x=-50, y=-40, width=90, height=70]. This ignores transformations on the display object.
- *
- * Also see the SpriteSheet {{#crossLink "SpriteSheet/getFrameBounds"}}{{/crossLink}} method.
- * @method getBounds
- * @return {Rectangle} A Rectangle instance. Returns null if the frame does not exist, or the image is not fully
- * loaded.
- **/
- p.getBounds = function() {
- // TODO: should this normalizeFrame?
- return this.DisplayObject_getBounds() || this.spriteSheet.getFrameBounds(this.currentFrame, this._rectangle);
- };
-
- /**
- * Returns a clone of the Sprite instance. Note that the same SpriteSheet is shared between cloned
- * instances.
- * @method clone
- * @return {Sprite} a clone of the Sprite instance.
- **/
- p.clone = function() {
- return this._cloneProps(new Sprite(this.spriteSheet));
- };
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {String} a string representation of the instance.
- **/
- p.toString = function() {
- return "[Sprite (name="+ this.name +")]";
- };
-
-// private methods:
- /**
- * @method _cloneProps
- * @param {Sprite} o
- * @return {Sprite} o
- * @protected
- **/
- p._cloneProps = function(o) {
- this.DisplayObject__cloneProps(o);
- o.currentFrame = this.currentFrame;
- o.currentAnimation = this.currentAnimation;
- o.paused = this.paused;
- o.currentAnimationFrame = this.currentAnimationFrame;
- o.framerate = this.framerate;
-
- o._animation = this._animation;
- o._currentFrame = this._currentFrame;
- o._skipAdvance = this._skipAdvance;
- return o;
- };
-
- /**
- * Advances the currentFrame
if paused is not true. This is called automatically when the {{#crossLink "Stage"}}{{/crossLink}}
- * ticks.
- * @param {Object} evtObj An event object that will be dispatched to all tick listeners. This object is reused between dispatchers to reduce construction & GC costs.
- * @protected
- * @method _tick
- **/
- p._tick = function(evtObj) {
- if (!this.paused) {
- if (!this._skipAdvance) { this.advance(evtObj&&evtObj.delta); }
- this._skipAdvance = false;
- }
- this.DisplayObject__tick(evtObj);
- };
-
-
- /**
- * Normalizes the current frame, advancing animations and dispatching callbacks as appropriate.
- * @protected
- * @method _normalizeFrame
- **/
- p._normalizeFrame = function(frameDelta) {
- frameDelta = frameDelta || 0;
- var animation = this._animation;
- var paused = this.paused;
- var frame = this._currentFrame;
- var l;
-
- if (animation) {
- var speed = animation.speed || 1;
- var animFrame = this.currentAnimationFrame;
- l = animation.frames.length;
- if (animFrame + frameDelta * speed >= l) {
- var next = animation.next;
- if (this._dispatchAnimationEnd(animation, frame, paused, next, l - 1)) {
- // something changed in the event stack, so we shouldn't make any more changes here.
- return;
- } else if (next) {
- // sequence. Automatically calls _normalizeFrame again with the remaining frames.
- return this._goto(next, frameDelta - (l - animFrame) / speed);
- } else {
- // end.
- this.paused = true;
- animFrame = animation.frames.length - 1;
- }
- } else {
- animFrame += frameDelta * speed;
- }
- this.currentAnimationFrame = animFrame;
- this._currentFrame = animation.frames[animFrame | 0]
- } else {
- frame = (this._currentFrame += frameDelta);
- l = this.spriteSheet.getNumFrames();
- if (frame >= l && l > 0) {
- if (!this._dispatchAnimationEnd(animation, frame, paused, l - 1)) {
- // looped.
- if ((this._currentFrame -= l) >= l) { return this._normalizeFrame(); }
- }
- }
- }
- frame = this._currentFrame | 0;
- if (this.currentFrame != frame) {
- this.currentFrame = frame;
- this.dispatchEvent("change");
- }
- };
-
- /**
- * Dispatches the "animationend" event. Returns true if a handler changed the animation (ex. calling {{#crossLink "Sprite/stop"}}{{/crossLink}},
- * {{#crossLink "Sprite/gotoAndPlay"}}{{/crossLink}}, etc.)
- * @property _dispatchAnimationEnd
- * @private
- * @type {Function}
- **/
- p._dispatchAnimationEnd = function(animation, frame, paused, next, end) {
- var name = animation ? animation.name : null;
- if (this.hasEventListener("animationend")) {
- var evt = new createjs.Event("animationend");
- evt.name = name;
- evt.next = next;
- this.dispatchEvent(evt);
- }
- // did the animation get changed in the event stack?:
- var changed = (this._animation != animation || this._currentFrame != frame);
- // if the animation hasn't changed, but the sprite was paused, then we want to stick to the last frame:
- if (!changed && !paused && this.paused) { this.currentAnimationFrame = end; changed = true; }
- return changed;
- };
-
- /**
- * Moves the playhead to the specified frame number or animation.
- * @method _goto
- * @param {String|Number} frameOrAnimation The frame number or animation that the playhead should move to.
- * @param {Boolean} [frame] The frame of the animation to go to. Defaults to 0.
- * @protected
- **/
- p._goto = function(frameOrAnimation, frame) {
- this.currentAnimationFrame = 0;
- if (isNaN(frameOrAnimation)) {
- var data = this.spriteSheet.getAnimation(frameOrAnimation);
- if (data) {
- this._animation = data;
- this.currentAnimation = frameOrAnimation;
- this._normalizeFrame(frame);
- }
- } else {
- this.currentAnimation = this._animation = null;
- this._currentFrame = frameOrAnimation;
- this._normalizeFrame();
- }
- };
-
-
- createjs.Sprite = createjs.promote(Sprite, "DisplayObject");
-}());
-
-//##############################################################################
-// Shape.js
-//##############################################################################
-
-this.createjs = this.createjs||{};
-
-(function() {
- "use strict";
-
-
-// constructor:
- /**
- * A Shape allows you to display vector art in the display list. It composites a {{#crossLink "Graphics"}}{{/crossLink}}
- * instance which exposes all of the vector drawing methods. The Graphics instance can be shared between multiple Shape
- * instances to display the same vector graphics with different positions or transforms.
- *
- * If the vector art will not
- * change between draws, you may want to use the {{#crossLink "DisplayObject/cache"}}{{/crossLink}} method to reduce the
- * rendering cost.
- *
- * lineHeight
(if specified) or {{#crossLink "Text/getMeasuredLineHeight"}}{{/crossLink}}. Note that
- * this operation requires the text flowing logic to run, which has an associated CPU cost.
- * @method getMeasuredHeight
- * @return {Number} The approximate height of the untransformed multi-line text.
- **/
- p.getMeasuredHeight = function() {
- return this._drawText(null,{}).height;
- };
-
- /**
- * Docced in superclass.
- */
- p.getBounds = function() {
- var rect = this.DisplayObject_getBounds();
- if (rect) { return rect; }
- if (this.text == null || this.text === "") { return null; }
- var o = this._drawText(null, {});
- var w = (this.maxWidth && this.maxWidth < o.width) ? this.maxWidth : o.width;
- var x = w * Text.H_OFFSETS[this.textAlign||"left"];
- var lineHeight = this.lineHeight||this.getMeasuredLineHeight();
- var y = lineHeight * Text.V_OFFSETS[this.textBaseline||"top"];
- return this._rectangle.setValues(x, y, w, o.height);
- };
-
- /**
- * Returns an object with width, height, and lines properties. The width and height are the visual width and height
- * of the drawn text. The lines property contains an array of strings, one for
- * each line of text that will be drawn, accounting for line breaks and wrapping. These strings have trailing
- * whitespace removed.
- * @method getMetrics
- * @return {Object} An object with width, height, and lines properties.
- **/
- p.getMetrics = function() {
- var o = {lines:[]};
- o.lineHeight = this.lineHeight || this.getMeasuredLineHeight();
- o.vOffset = o.lineHeight * Text.V_OFFSETS[this.textBaseline||"top"];
- return this._drawText(null, o, o.lines);
- };
-
- /**
- * Returns a clone of the Text instance.
- * @method clone
- * @return {Text} a clone of the Text instance.
- **/
- p.clone = function() {
- return this._cloneProps(new Text(this.text, this.font, this.color));
- };
-
- /**
- * Returns a string representation of this object.
- * @method toString
- * @return {String} a string representation of the instance.
- **/
- p.toString = function() {
- return "[Text (text="+ (this.text.length > 20 ? this.text.substr(0, 17)+"..." : this.text) +")]";
- };
-
-
-// private methods:
- /**
- * @method _cloneProps
- * @param {Text} o
- * @protected
- * @return {Text} o
- **/
- p._cloneProps = function(o) {
- this.DisplayObject__cloneProps(o);
- o.textAlign = this.textAlign;
- o.textBaseline = this.textBaseline;
- o.maxWidth = this.maxWidth;
- o.outline = this.outline;
- o.lineHeight = this.lineHeight;
- o.lineWidth = this.lineWidth;
- return o;
- };
-
- /**
- * @method _getWorkingContext
- * @param {CanvasRenderingContext2D} ctx
- * @return {CanvasRenderingContext2D}
- * @protected
- **/
- p._prepContext = function(ctx) {
- ctx.font = this.font||"10px sans-serif";
- ctx.textAlign = this.textAlign||"left";
- ctx.textBaseline = this.textBaseline||"top";
- return ctx;
- };
-
- /**
- * Draws multiline text.
- * @method _drawText
- * @param {CanvasRenderingContext2D} ctx
- * @param {Object} o
- * @param {Array} lines
- * @return {Object}
- * @protected
- **/
- p._drawText = function(ctx, o, lines) {
- var paint = !!ctx;
- if (!paint) {
- ctx = Text._workingContext;
- ctx.save();
- this._prepContext(ctx);
- }
- var lineHeight = this.lineHeight||this.getMeasuredLineHeight();
-
- var maxW = 0, count = 0;
- var hardLines = String(this.text).split(/(?:\r\n|\r|\n)/);
- for (var i=0, l=hardLines.length; imaxHeight
.
- * @class SpriteSheetBuilder
- * @extends EventDispatcher
- * @constructor
- **/
- function SpriteSheetBuilder() {
- this.EventDispatcher_constructor();
-
- // public properties:
- /**
- * The maximum width for the images (not individual frames) in the generated sprite sheet. It is recommended to use
- * a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max dimensions, then
- * additional images will be created as needed.
- * @property maxWidth
- * @type Number
- * @default 2048
- */
- this.maxWidth = 2048;
-
- /**
- * The maximum height for the images (not individual frames) in the generated sprite sheet. It is recommended to use
- * a power of 2 for this value (ex. 1024, 2048, 4096). If the frames cannot all fit within the max dimensions, then
- * additional images will be created as needed.
- * @property maxHeight
- * @type Number
- * @default 2048
- **/
- this.maxHeight = 2048;
-
- /**
- * The sprite sheet that was generated. This will be null before a build is completed successfully.
- * @property spriteSheet
- * @type SpriteSheet
- **/
- this.spriteSheet = null;
-
- /**
- * The scale to apply when drawing all frames to the sprite sheet. This is multiplied against any scale specified
- * in the addFrame call. This can be used, for example, to generate a sprite sheet at run time that is tailored to
- * the a specific device resolution (ex. tablet vs mobile).
- * @property scale
- * @type Number
- * @default 1
- **/
- this.scale = 1;
-
- /**
- * The padding to use between frames. This is helpful to preserve antialiasing on drawn vector content.
- * @property padding
- * @type Number
- * @default 1
- **/
- this.padding = 1;
-
- /**
- * A number from 0.01 to 0.99 that indicates what percentage of time the builder can use. This can be
- * thought of as the number of seconds per second the builder will use. For example, with a timeSlice value of 0.3,
- * the builder will run 20 times per second, using approximately 15ms per build (30% of available time, or 0.3s per second).
- * Defaults to 0.3.
- * @property timeSlice
- * @type Number
- * @default 0.3
- **/
- this.timeSlice = 0.3;
-
- /**
- * A value between 0 and 1 that indicates the progress of a build, or -1 if a build has not
- * been initiated.
- * @property progress
- * @type Number
- * @default -1
- * @readonly
- **/
- this.progress = -1;
-
-
- // private properties:
- /**
- * @property _frames
- * @protected
- * @type Array
- **/
- this._frames = [];
-
- /**
- * @property _animations
- * @protected
- * @type Array
- **/
- this._animations = {};
-
- /**
- * @property _data
- * @protected
- * @type Array
- **/
- this._data = null;
-
- /**
- * @property _nextFrameIndex
- * @protected
- * @type Number
- **/
- this._nextFrameIndex = 0;
-
- /**
- * @property _index
- * @protected
- * @type Number
- **/
- this._index = 0;
-
- /**
- * @property _timerID
- * @protected
- * @type Number
- **/
- this._timerID = null;
-
- /**
- * @property _scale
- * @protected
- * @type Number
- **/
- this._scale = 1;
- }
- var p = createjs.extend(SpriteSheetBuilder, createjs.EventDispatcher);
-
- /**
- * REMOVED. Removed in favor of using `MySuperClass_constructor`.
- * See {{#crossLink "Utility Methods/extend"}}{{/crossLink}} and {{#crossLink "Utility Methods/promote"}}{{/crossLink}}
- * for details.
- *
- * There is an inheritance tutorial distributed with EaselJS in /tutorials/Inheritance.
- *
- * @method initialize
- * @protected
- * @deprecated
- */
- // p.initialize = function() {}; // searchable for devs wondering where it is.
-
-
-// constants:
- SpriteSheetBuilder.ERR_DIMENSIONS = "frame dimensions exceed max spritesheet dimensions";
- SpriteSheetBuilder.ERR_RUNNING = "a build is already running";
-
-// events:
- /**
- * Dispatched when a build completes.
- * @event complete
- * @param {Object} target The object that dispatched the event.
- * @param {String} type The event type.
- * @since 0.6.0
- */
-
- /**
- * Dispatched when an asynchronous build has progress.
- * @event progress
- * @param {Object} target The object that dispatched the event.
- * @param {String} type The event type.
- * @param {Number} progress The current progress value (0-1).
- * @since 0.6.0
- */
-
-
-// public methods:
- /**
- * Adds a frame to the {{#crossLink "SpriteSheet"}}{{/crossLink}}. Note that the frame will not be drawn until you
- * call {{#crossLink "SpriteSheetBuilder/build"}}{{/crossLink}} method. The optional setup params allow you to have
- * a function run immediately before the draw occurs. For example, this allows you to add a single source multiple
- * times, but manipulate it or its children to change it to generate different frames.
- *
- * Note that the source's transformations (x, y, scale, rotate, alpha) will be ignored, except for regX/Y. To apply
- * transforms to a source object and have them captured in the sprite sheet, simply place it into a {{#crossLink "Container"}}{{/crossLink}}
- * and pass in the Container as the source.
- * @method addFrame
- * @param {DisplayObject} source The source {{#crossLink "DisplayObject"}}{{/crossLink}} to draw as the frame.
- * @param {Rectangle} [sourceRect] A {{#crossLink "Rectangle"}}{{/crossLink}} defining the portion of the
- * source to draw to the frame. If not specified, it will look for a getBounds
method, bounds property,
- * or nominalBounds
property on the source to use. If one is not found, the frame will be skipped.
- * @param {Number} [scale=1] Optional. The scale to draw this frame at. Default is 1.
- * @param {Function} [setupFunction] A function to call immediately before drawing this frame. It will be called with two parameters: the source, and setupData.
- * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.
- * @return {Number} The index of the frame that was just added, or null if a sourceRect could not be determined.
- **/
- p.addFrame = function(source, sourceRect, scale, setupFunction, setupData) {
- if (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }
- var rect = sourceRect||source.bounds||source.nominalBounds;
- if (!rect&&source.getBounds) { rect = source.getBounds(); }
- if (!rect) { return null; }
- scale = scale||1;
- return this._frames.push({source:source, sourceRect:rect, scale:scale, funct:setupFunction, data:setupData, index:this._frames.length, height:rect.height*scale})-1;
- };
-
- /**
- * Adds an animation that will be included in the created sprite sheet.
- * @method addAnimation
- * @param {String} name The name for the animation.
- * @param {Array} frames An array of frame indexes that comprise the animation. Ex. [3,6,5] would describe an animation
- * that played frame indexes 3, 6, and 5 in that order.
- * @param {String} [next] Specifies the name of the animation to continue to after this animation ends. You can
- * also pass false to have the animation stop when it ends. By default it will loop to the start of the same animation.
- * @param {Number} [frequency] Specifies a frame advance frequency for this animation. For example, a value
- * of 2 would cause the animation to advance every second tick.
- **/
- p.addAnimation = function(name, frames, next, frequency) {
- if (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }
- this._animations[name] = {frames:frames, next:next, frequency:frequency};
- };
-
- /**
- * This will take a MovieClip instance, and add its frames and labels to this builder. Labels will be added as an animation
- * running from the label index to the next label. For example, if there is a label named "foo" at frame 0 and a label
- * named "bar" at frame 10, in a MovieClip with 15 frames, it will add an animation named "foo" that runs from frame
- * index 0 to 9, and an animation named "bar" that runs from frame index 10 to 14.
- *
- * Note that this will iterate through the full MovieClip with actionsEnabled set to false, ending on the last frame.
- * @method addMovieClip
- * @param {MovieClip} source The source MovieClip instance to add to the sprite sheet.
- * @param {Rectangle} [sourceRect] A {{#crossLink "Rectangle"}}{{/crossLink}} defining the portion of the source to
- * draw to the frame. If not specified, it will look for a getBounds
method, frameBounds
- * Array, bounds
property, or nominalBounds
property on the source to use. If one is not
- * found, the MovieClip will be skipped.
- * @param {Number} [scale=1] The scale to draw the movie clip at.
- * @param {Function} [setupFunction] A function to call immediately before drawing each frame. It will be called with three parameters: the source, setupData, and the frame index.
- * @param {Object} [setupData] Arbitrary setup data to pass to setupFunction as the second parameter.
- * @param {Function} [labelFunction] This method will be called for each movieclip label that is added with four parameters: the label name, the source movieclip instance, the starting frame index (in the movieclip timeline) and the end index. It must return a new name for the label/animation, or false to exclude the label.
- **/
- p.addMovieClip = function(source, sourceRect, scale, setupFunction, setupData, labelFunction) {
- if (this._data) { throw SpriteSheetBuilder.ERR_RUNNING; }
- var rects = source.frameBounds;
- var rect = sourceRect||source.bounds||source.nominalBounds;
- if (!rect&&source.getBounds) { rect = source.getBounds(); }
- if (!rect && !rects) { return; }
-
- var i, l, baseFrameIndex = this._frames.length;
- var duration = source.timeline.duration;
- for (i=0; ir&&(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};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]}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.push(a),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]}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),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}if(0>a||a>this.children.length-1)return!1;var f=this.children[a];return f&&(f.parent=null),this.children.splice(a,1),f.dispatchEvent("removed"),!0},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._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(){function a(a){this.DisplayObject_constructor(),"string"==typeof a?(this.image=document.createElement("img"),this.image.src=a):this.image=a,this.sourceRect=null}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)||!this.image)return!0;var c=this.image,d=this.sourceRect;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(){var b=new a(this.image);return this.sourceRect&&(b.sourceRect=this.sourceRect.clone()),this._cloneProps(b),b},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,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.maxWidth20?this.text.substr(0,17)+"...":this.text)+")]"},b._cloneProps=function(a){return this.DisplayObject__cloneProps(a),a.textAlign=this.textAlign,a.textBaseline=this.textBaseline,a.maxWidth=this.maxWidth,a.outline=this.outline,a.lineHeight=this.lineHeight,a.lineWidth=this.lineWidth,a},b._prepContext=function(a){return a.font=this.font||"10px sans-serif",a.textAlign=this.textAlign||"left",a.textBaseline=this.textBaseline||"top",a},b._drawText=function(b,c,d){var e=!!b;e||(b=a._workingContext,b.save(),this._prepContext(b));for(var f=this.lineHeight||this.getMeasuredLineHeight(),g=0,h=0,i=String(this.text).split(/(?:\r\n|\r|\n)/),j=0,k=i.length;k>j;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}}var b=createjs.extend(a,createjs.Container);a.maxPoolSize=100,a._spritePool=[],b.draw=function(a,b){this.DisplayObject_draw(a,b)||(this._updateText(),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._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(){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.addFlippedFrames=function(b,c,d,e){if(c||d||e){var f=0;c&&a._flip(b,++f,!0,!1),d&&a._flip(b,++f,!1,!0),e&&a._flip(b,++f,!0,!0)}},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.mergeAlpha=function(a,b,c){c||(c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),c.width=Math.max(b.width,a.width),c.height=Math.max(b.height,a.height);var d=c.getContext("2d");return d.save(),d.drawImage(a,0,0),d.globalCompositeOperation="destination-in",d.drawImage(b,0,0),d.restore(),c},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,l.height=k.height,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-o.x-o.width,p.regX=o.width-k.regX),e&&(o.y=l.height-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(){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._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,frequency: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,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 a)&&(a=0),(isNaN(b)||0>b)&&(b=0),(isNaN(c)||1>c)&&(c=1),this.blurX=0|a,this.blurY=0|b,this.quality=0|c}var b=createjs.extend(a,createjs.Filter);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(b*d+1,c*d+1,b*d+1,c*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.mask=a}var b=createjs.extend(a,createjs.Filter);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.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}var b=createjs.extend(a,createjs.Filter);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.length a.LENGTH&&(b=b.slice(0,a.LENGTH)),b},createjs.ColorMatrix=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.matrix=a}var b=createjs.extend(a,createjs.Filter);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="0.8.1",a.buildDate="Thu, 21 May 2015 16:17:39 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||a.useRAF&&a.RAF_SYNCHED;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.performance&&(performance.now||performance.mozNow||performance.msNow||performance.oNow||performance.webkitNow);a._getTime=function(){return(b&&b.call(performance)||(new Date).getTime())-a._startTime},createjs.Ticker=a}(),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||{},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.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 0)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()}function b(a,b,d,e,f,g,h,i){var j=c(g,e,f),k=c(h,e,f),l=-Math.sin(k-j)*(Math.sqrt(4+3*Math.pow(Math.tan((k-j)/2),2))-1)/3,m=e*f/Math.sqrt(Math.pow(f*Math.cos(g),2)+Math.pow(e*Math.sin(g),2)),n=b+m*Math.cos(g),o=d+m*Math.sin(g),p=e*f/Math.sqrt(Math.pow(f*Math.cos(h),2)+Math.pow(e*Math.sin(h),2)),q=b+p*Math.cos(h),r=d+p*Math.sin(h),s=n-l*Math.sin(-j)*e,t=o-l*Math.cos(-j)*f,u=q+l*Math.sin(-k)*e,v=r+l*Math.cos(-k)*f;return"radii"===i||"chord"===i?a.lineTo(n,o):a.moveTo(n,o),a.bezierCurveTo(s,t,u,v,q,r),{x:n,y:o}}function c(a,b,c){var e,f=Math.cos(a),g=Math.sin(a);if(d(b,c)||d(Math.abs(f),0)||d(Math.abs(g),0))return a;var h=b*Math.tan(a)/c;return f>0&&g>0?e=Math.atan(h):f<0&&g>0?e=Math.PI+Math.atan(h):f<0&&g<0?e=Math.PI+Math.atan(h):f>0&&g<0&&(e=2*Math.PI+Math.atan(h)),e}function d(a,b){var c=.001,d=2.220446049250313e-16;if(a===b)return!0;if(isNaN(a)||isNaN(b))return!1;if(isFinite(a)&&isFinite(b)){var e=Math.abs(a-b);return e >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 g=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");g.getContext&&(a._ctx=g.getContext("2d"),g.width=g.height=1),e.getInstructions=function(){return this._updateInstructions(),this._instructions};try{Object.defineProperties(e,{instructions:{get:e.getInstructions}})}catch(a){}e.isEmpty=function(){return!(this._instructions.length||this._activeInstructions.length)},e.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},e.store=function(){return this._updateInstructions(!0),this._storeIndex=this._instructions.length,this},e.unstore=function(){return this._storeIndex=0,this},e.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},e.toString=function(){return"[Graphics]"},e.mt=e.moveTo,e.lt=e.lineTo,e.at=e.arcTo,e.bt=e.bezierCurveTo,e.qt=e.quadraticCurveTo,e.a=e.arc,e.ea=e.ellipticalArc,e.r=e.rect,e.cp=e.closePath,e.c=e.clear,e.f=e.beginFill,e.lf=e.beginLinearGradientFill,e.rf=e.beginRadialGradientFill,e.bf=e.beginBitmapFill,e.ef=e.endFill,e.ss=e.setStrokeStyle,e.sd=e.setStrokeDash,e.s=e.beginStroke,e.ls=e.beginLinearGradientStroke,e.rs=e.beginRadialGradientStroke,e.bs=e.beginBitmapStroke,e.es=e.endStroke,e.dr=e.drawRect,e.rr=e.drawRoundRect,e.rc=e.drawRoundRectComplex,e.dc=e.drawCircle,e.de=e.drawEllipse,e.dp=e.drawPolyStar,e.p=e.decodePath,e._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},e.path=!1,e=(f.Stroke=function(a,b){this.style=a,this.ignoreScale=b}).prototype,e.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())},e.linearGradient=f.Fill.prototype.linearGradient,e.radialGradient=f.Fill.prototype.radialGradient,e.bitmap=f.Fill.prototype.bitmap,e.path=!1,e=(f.StrokeStyle=function(a,b,c,d,e){this.width=a,this.caps=b,this.joints=c,this.miterLimit=d,this.ignoreScale=e}).prototype,e.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},e.path=!1,(f.StrokeDash=function(a,b){this.segments=a,this.offset=b||0}).prototype.exec=function(a){a.setLineDash&&(a.setLineDash(this.segments||f.StrokeDash.EMPTY_SEGMENTS),a.lineDashOffset=this.offset||0)},f.StrokeDash.EMPTY_SEGMENTS=[],(f.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=(i b&&(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()},(f.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)},(f.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)},(f.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;i 0&&0!=this.scaleX&&0!=this.scaleY)},b.draw=function(a,b){var c=this.cacheCanvas;if(b||!c)return!1;var d=this._cacheScale;return a.drawImage(c,this._cacheOffsetX+this._filterOffsetX,this._cacheOffsetY+this._filterOffsetY,c.width/d,c.height/d),!0},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){e=e||1,this.cacheCanvas||(this.cacheCanvas=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),this._cacheWidth=c,this._cacheHeight=d,this._cacheOffsetX=a,this._cacheOffsetY=b,this._cacheScale=e,this.updateCache()},b.updateCache=function(b){var c=this.cacheCanvas;if(!c)throw"cache() must be called before updateCache()";var d=this._cacheScale,e=this._cacheOffsetX*d,f=this._cacheOffsetY*d,g=this._cacheWidth,h=this._cacheHeight,i=c.getContext("2d"),j=this._getFilterBounds();e+=this._filterOffsetX=j.x,f+=this._filterOffsetY=j.y,g=Math.ceil(g*d)+j.width,h=Math.ceil(h*d)+j.height,g!=c.width||h!=c.height?(c.width=g,c.height=h):b||i.clearRect(0,0,g+1,h+1),i.save(),i.globalCompositeOperation=b,i.setTransform(d,0,0,d,-e,-f),this.draw(i,!0),this._applyFilters(),i.restore(),this.cacheID=a._nextCacheID++},b.uncache=function(){this._cacheDataURL=this.cacheCanvas=null,this.cacheID=this._cacheOffsetX=this._cacheOffsetY=this._filterOffsetX=this._filterOffsetY=0,this._cacheScale=1},b.getCacheDataURL=function(){return this.cacheCanvas?(this.cacheID!=this._cacheDataURLID&&(this._cacheDataURL=this.cacheCanvas.toDataURL()),this._cacheDataURL):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){null==a&&(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._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(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._applyFilters=function(){if(this.filters&&0!=this.filters.length&&this.cacheCanvas)for(var a=this.filters.length,b=this.cacheCanvas.getContext("2d"),c=this.cacheCanvas.width,d=this.cacheCanvas.height,e=0;ep&&(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;d 1){for(var c=0;cthis.children.length)return arguments[c-2];if(c>2){for(var e=0;e 1){for(var c=!0,d=0;d1){for(var c=[],d=0;dthis.children.length-1)return!1;var f=this.children[a];return f&&(f.parent=null),this.children.splice(a,1),f.dispatchEvent("removed"),!0},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;c =d)){for(var e=0;e 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;c =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));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;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(){function a(a){this.DisplayObject_constructor(),"string"==typeof a?(this.image=document.createElement("img"),this.image.src=a):this.image=a,this.sourceRect=null}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)||!this.image)return!0;var c=this.image,d=this.sourceRect;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(){var b=new a(this.image);return this.sourceRect&&(b.sourceRect=this.sourceRect.clone()),this._cloneProps(b),b},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,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.maxWidth 20?this.text.substr(0,17)+"...":this.text)+")]"},b._cloneProps=function(a){return this.DisplayObject__cloneProps(a),a.textAlign=this.textAlign,a.textBaseline=this.textBaseline,a.maxWidth=this.maxWidth,a.outline=this.outline,a.lineHeight=this.lineHeight,a.lineWidth=this.lineWidth,a},b._prepContext=function(a){return a.font=this.font||"10px sans-serif",a.textAlign=this.textAlign||"left",a.textBaseline=this.textBaseline||"top",a},b._drawText=function(b,c,d){var e=!!b;e||(b=a._workingContext,b.save(),this._prepContext(b));for(var f=this.lineHeight||this.getMeasuredLineHeight(),g=0,h=0,i=String(this.text).split(/(?:\r\n|\r|\n)/),j=0,k=i.length;j this.lineWidth){var n=l.split(/(\s)/);l=n[0],m=b.measureText(l).width;for(var o=1,p=n.length;o 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}}var b=createjs.extend(a,createjs.Container);a.maxPoolSize=100,a._spritePool=[],b.draw=function(a,b){this.DisplayObject_draw(a,b)||(this._updateText(),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._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;p
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,c,d,e){this.Container_constructor(),!a.inited&&a.init(),this.mode=b||a.INDEPENDENT,this.startPosition=c||0,this.loop=d,this.currentFrame=0,this.timeline=new createjs.Timeline(null,e,{paused:!0,position:c,useTicks:!0}),this.paused=!1,this.actionsEnabled=!0,this.autoReset=!0,this.frameBounds=this.frameBounds||null,this.framerate=null,this._synchOffset=0,this._prevPos=-1,this._prevPosition=0,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.getCurrentLabel=function(){return this._updateTimeline(),this.timeline.getCurrentLabel()},c.getDuration=function(){return this.timeline.duration};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._updateTimeline(),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);this._framerate=e;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._prevPosition=this._prevPos<0?0:this._prevPosition+1,this._updateTimeline()}},c.clone=function(){throw"MovieClip cannot be cloned."},c.toString=function(){return"[MovieClip (name="+this.name+")]"},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&&(-1==this._prevPos&&(this._prevPos=NaN),this._prevPosition=b,this._t=0,this._updateTimeline())},c._reset=function(){this._prevPos=-1,this._t=this.currentFrame=0,this.paused=!1},c._updateTimeline=function(){var b=this.timeline,c=this.mode!=a.INDEPENDENT;b.loop=null==this.loop||this.loop;var d=c?this.startPosition+(this.mode==a.SINGLE_FRAME?0:this._synchOffset):this._prevPos<0?0:this._prevPosition,e=c||!this.actionsEnabled?createjs.Tween.NONE:null;if(this.currentFrame=b._calcPosition(d),b.setPosition(d,e),this._prevPosition=b._prevPosition,this._prevPos!=b._prevPos){this.currentFrame=this._prevPos=b._prevPos;for(var f in this._managed)this._managed[f]=1;for(var g=b._tweens,h=0,i=g.length;h=0;h--){var n=m[h].id;1==this._managed[n]&&(this.removeChildAt(h),delete this._managed[n])}}},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._updateTimeline(),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.install=function(){createjs.Tween.installPlugin(b,["startPosition"])},b.init=function(a,b,c){return c},b.step=function(){},b.tween=function(b,c,d,e,f,g,h,i){return b.target instanceof a?1==g?f[c]:e[c]:d}}(),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.addFlippedFrames=function(b,c,d,e){if(c||d||e){var f=0;c&&a._flip(b,++f,!0,!1),d&&a._flip(b,++f,!1,!0),e&&a._flip(b,++f,!0,!0)}},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.mergeAlpha=function(a,b,c){c||(c=createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),c.width=Math.max(b.width,a.width),c.height=Math.max(b.height,a.height);var d=c.getContext("2d");return d.save(),d.drawImage(a,0,0),d.globalCompositeOperation="destination-in",d.drawImage(b,0,0),d.restore(),c},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;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;i 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;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;c a.LENGTH&&(b=b.slice(0,a.LENGTH)),b},createjs.ColorMatrix=a}(),this.createjs=this.createjs||{},function(){"use strict";function a(a){this.matrix=a}var b=createjs.extend(a,createjs.Filter);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;C 0||window.navigator.pointerEnabled&&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.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&a._IE_enable(b),!0))},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;e 1?this.addChildAt.apply(this,Array.prototype.slice.call(arguments).concat([this.children.length])):this.addChildAt(a,this.children.length)},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]}if(!(a._spritestage_compatibility>=1))return console&&console.log("Error: You can only add children of type SpriteContainer, Sprite, BitmapText, or DOMElement ["+a.toString()+"]"),a;if(a._spritestage_compatibility<=4){var f=a.spriteSheet;if(!f||!f._images||f._images.length>1||this.spriteSheet&&this.spriteSheet!==f)return console&&console.log("Error: A child's spriteSheet must be equal to its parent spriteSheet and only use one image. ["+a.toString()+"]"),a;this.spriteSheet=f}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a},b.toString=function(){return"[SpriteContainer (name="+this.name+")]"},createjs.SpriteContainer=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.Stage_constructor(a),this._preserveDrawingBuffer=b||!1,this._antialias=c||!1,this._viewportWidth=0,this._viewportHeight=0,this._projectionMatrix=null,this._webGLContext=null,this._webGLErrorDetected=!1,this._clearColor=null,this._maxTexturesPerDraw=1,this._maxBoxesPointsPerDraw=null,this._maxBoxesPerDraw=null,this._maxIndicesPerDraw=null,this._shaderProgram=null,this._vertices=null,this._verticesBuffer=null,this._indices=null,this._indicesBuffer=null,this._currentBoxIndex=-1,this._drawTexture=null,this._initializeWebGL()}[createjs.SpriteContainer,createjs.Sprite,createjs.BitmapText,createjs.Bitmap,createjs.DOMElement].forEach(function(a,b){a.prototype._spritestage_compatibility=b+1});var b=createjs.extend(a,createjs.Stage);a.NUM_VERTEX_PROPERTIES=5,a.POINTS_PER_BOX=4,a.NUM_VERTEX_PROPERTIES_PER_BOX=a.POINTS_PER_BOX*a.NUM_VERTEX_PROPERTIES,a.INDICES_PER_BOX=6,a.MAX_INDEX_SIZE=Math.pow(2,16),a.MAX_BOXES_POINTS_INCREMENT=a.MAX_INDEX_SIZE/4,b._get_isWebGL=function(){return!!this._webGLContext};try{Object.defineProperties(b,{isWebGL:{get:b._get_isWebGL}})}catch(c){}b.addChild=function(a){return null==a?a:arguments.length>1?this.addChildAt.apply(this,Array.prototype.slice.call(arguments).concat([this.children.length])):this.addChildAt(a,this.children.length)},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]}return a._spritestage_compatibility>=1?!a.image&&!a.spriteSheet&&a._spritestage_compatibility<=4?(console&&console.log("Error: You can only add children that have an image or spriteSheet defined on them. ["+a.toString()+"]"),a):(a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a):(console&&console.log("Error: You can only add children of type SpriteContainer, Sprite, Bitmap, BitmapText, or DOMElement. ["+a.toString()+"]"),a)},b.update=function(a){if(this.canvas){this.tickOnUpdate&&this.tick(a),this.dispatchEvent("drawstart"),this.autoClear&&this.clear();var b=this._setWebGLContext();b?this.draw(b,!1):(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 a=this._setWebGLContext();a?a.clear(a.COLOR_BUFFER_BIT):(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.draw=function(a,b){return"undefined"!=typeof WebGLRenderingContext&&(a===this._webGLContext||a instanceof WebGLRenderingContext)?(this._drawWebGLKids(this.children,a),!0):this.Stage_draw(a,b)},b.updateViewport=function(a,b){this._viewportWidth=a,this._viewportHeight=b,this._webGLContext&&(this._webGLContext.viewport(0,0,this._viewportWidth,this._viewportHeight),this._projectionMatrix||(this._projectionMatrix=new Float32Array([0,0,0,0,0,1,-1,1,1])),this._projectionMatrix[0]=2/a,this._projectionMatrix[4]=-2/b)},b.clearImageTexture=function(a){a.__easeljs_texture=null},b.toString=function(){return"[SpriteStage (name="+this.name+")]"},b._initializeWebGL=function(){this._clearColor={r:0,g:0,b:0,a:0},this._setWebGLContext()},b._setWebGLContext=function(){return this.canvas?this._webGLContext&&this._webGLContext.canvas===this.canvas||this._initializeWebGLContext():this._webGLContext=null,this._webGLContext},b._initializeWebGLContext=function(){var a={depth:!1,alpha:!0,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias,premultipliedAlpha:!0},b=this._webGLContext=this.canvas.getContext("webgl",a)||this.canvas.getContext("experimental-webgl",a);if(b){if(this._maxTexturesPerDraw=1,this._setClearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),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,!1),this._createShaderProgram(b),this._webGLErrorDetected)return void(this._webGLContext=null);this._createBuffers(b),this.updateViewport(this._viewportWidth||this.canvas.width||0,this._viewportHeight||this.canvas.height||0)}},b._setClearColor=function(a,b,c,d){this._clearColor.r=a,this._clearColor.g=b,this._clearColor.b=c,this._clearColor.a=d,this._webGLContext&&this._webGLContext.clearColor(a,b,c,d)},b._createShaderProgram=function(a){var b=this._createShader(a,a.FRAGMENT_SHADER,"precision mediump float;uniform sampler2D uSampler0;varying vec3 vTextureCoord;void main(void) {vec4 color = texture2D(uSampler0, vTextureCoord.st);gl_FragColor = vec4(color.rgb, color.a * vTextureCoord.z);}"),c=this._createShader(a,a.VERTEX_SHADER,"attribute vec2 aVertexPosition;attribute vec3 aTextureCoord;uniform mat3 uPMatrix;varying vec3 vTextureCoord;void main(void) {vTextureCoord = aTextureCoord;gl_Position = vec4((uPMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);}");if(!this._webGLErrorDetected&&b&&c){var d=a.createProgram();if(a.attachShader(d,b),a.attachShader(d,c),a.linkProgram(d),!a.getProgramParameter(d,a.LINK_STATUS))return void(this._webGLErrorDetected=!0);d.vertexPositionAttribute=a.getAttribLocation(d,"aVertexPosition"),d.textureCoordAttribute=a.getAttribLocation(d,"aTextureCoord"),d.sampler0uniform=a.getUniformLocation(d,"uSampler0"),a.enableVertexAttribArray(d.vertexPositionAttribute),a.enableVertexAttribArray(d.textureCoordAttribute),d.pMatrixUniform=a.getUniformLocation(d,"uPMatrix"),a.useProgram(d),this._shaderProgram=d}},b._createShader=function(a,b,c){var d=a.createShader(b);return a.shaderSource(d,c),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:(this._webGLErrorDetected=!0,null)},b._createBuffers=function(b){this._verticesBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._verticesBuffer);var c=4*a.NUM_VERTEX_PROPERTIES;b.vertexAttribPointer(this._shaderProgram.vertexPositionAttribute,2,b.FLOAT,b.FALSE,c,0),b.vertexAttribPointer(this._shaderProgram.textureCoordAttribute,3,b.FLOAT,b.FALSE,c,8),this._indicesBuffer=b.createBuffer(),this._setMaxBoxesPoints(b,a.MAX_BOXES_POINTS_INCREMENT)},b._setMaxBoxesPoints=function(b,c){this._maxBoxesPointsPerDraw=c,this._maxBoxesPerDraw=this._maxBoxesPointsPerDraw/a.POINTS_PER_BOX|0,this._maxIndicesPerDraw=this._maxBoxesPerDraw*a.INDICES_PER_BOX,b.bindBuffer(b.ARRAY_BUFFER,this._verticesBuffer),this._vertices=new Float32Array(this._maxBoxesPerDraw*a.NUM_VERTEX_PROPERTIES_PER_BOX),b.bufferData(b.ARRAY_BUFFER,this._vertices,b.DYNAMIC_DRAW),this._indices=new Uint16Array(this._maxIndicesPerDraw);for(var d=0,e=this._indices.length;e>d;d+=a.INDICES_PER_BOX){var f=d*a.POINTS_PER_BOX/a.INDICES_PER_BOX;this._indices[d]=f,this._indices[d+1]=f+1,this._indices[d+2]=f+2,this._indices[d+3]=f,this._indices[d+4]=f+2,this._indices[d+5]=f+3}b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indicesBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this._indices,b.STATIC_DRAW)},b._setupImageTexture=function(a,b){if(b&&(b.naturalWidth||b.getContext||b.readyState>=2)){var c=b.__easeljs_texture;return c||(c=b.__easeljs_texture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,c),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),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)),c}},b._drawWebGLKids=function(b,c,d){for(var e,f,g=this.snapToPixelEnabled,h=null,i=0,j=0,k=0,l=0,m=this._vertices,n=a.NUM_VERTEX_PROPERTIES_PER_BOX,o=a.MAX_INDEX_SIZE,p=this._maxBoxesPerDraw-1,q=0,r=b.length;r>q;q++)if(e=b[q],e.isVisible()){var h=e.image||e.spriteSheet&&e.spriteSheet._images[0],s=h.__easeljs_texture;if(s||(s=this._setupImageTexture(c,h))){f=e._props.matrix,f=(d?f.copy(d):f.identity()).appendTransform(e.x,e.y,e.scaleX,e.scaleY,e.rotation,e.skewX,e.skewY,e.regX,e.regY);var t=0,u=1,v=0,w=1;if(4===e._spritestage_compatibility)i=0,j=0,k=h.width,l=h.height;else if(2===e._spritestage_compatibility){var x=e.spriteSheet.getFrame(e.currentFrame),y=x.rect;i=-x.regX,j=-x.regY,k=i+y.width,l=j+y.height,t=y.x/h.width,v=y.y/h.height,u=t+y.width/h.width,w=v+y.height/h.height}else h=null,3===e._spritestage_compatibility&&e._updateText();if(!d&&e._spritestage_compatibility<=4&&s!==this._drawTexture&&(this._drawToGPU(c),this._drawTexture=s),null!==h){var z=++this._currentBoxIndex*n,A=f.a,B=f.b,C=f.c,D=f.d,E=f.tx,F=f.ty;g&&e.snapToPixel&&(E=E+(0>E?-.5:.5)|0,F=F+(0>F?-.5:.5)|0),m[z]=i*A+j*C+E,m[z+1]=i*B+j*D+F,m[z+5]=i*A+l*C+E,m[z+6]=i*B+l*D+F,m[z+10]=k*A+l*C+E,m[z+11]=k*B+l*D+F,m[z+15]=k*A+j*C+E,m[z+16]=k*B+j*D+F,m[z+2]=m[z+7]=t,m[z+12]=m[z+17]=u,m[z+3]=m[z+18]=v,m[z+8]=m[z+13]=w,m[z+4]=m[z+9]=m[z+14]=m[z+19]=e.alpha,this._currentBoxIndex===p&&(this._drawToGPU(c),this._drawTexture=s,this._maxBoxesPointsPerDraw 1?this.addChildAt.apply(this,Array.prototype.slice.call(arguments).concat([this.children.length])):this.addChildAt(a,this.children.length)},b.addChildAt=function(a,b){var c=arguments.length,d=arguments[c-1];if(d<0||d>this.children.length)return arguments[c-2];if(c>2){for(var e=0;e =1))return console&&console.log("Error: You can only add children of type SpriteContainer, Sprite, BitmapText, or DOMElement ["+a.toString()+"]"),a;if(a._spritestage_compatibility<=4){var f=a.spriteSheet;if(!f||!f._images||f._images.length>1||this.spriteSheet&&this.spriteSheet!==f)return console&&console.log("Error: A child's spriteSheet must be equal to its parent spriteSheet and only use one image. ["+a.toString()+"]"),a;this.spriteSheet=f}return a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a},b.toString=function(){return"[SpriteContainer (name="+this.name+")]"},createjs.SpriteContainer=createjs.promote(a,"Container")}(),this.createjs=this.createjs||{},function(){"use strict";function a(a,b,c){this.Stage_constructor(a),this._preserveDrawingBuffer=b||!1,this._antialias=c||!1,this._viewportWidth=0,this._viewportHeight=0,this._projectionMatrix=null,this._webGLContext=null,this._webGLErrorDetected=!1,this._clearColor=null,this._maxTexturesPerDraw=1,this._maxBoxesPointsPerDraw=null,this._maxBoxesPerDraw=null,this._maxIndicesPerDraw=null,this._shaderProgram=null,this._vertices=null,this._verticesBuffer=null,this._indices=null,this._indicesBuffer=null,this._currentBoxIndex=-1,this._drawTexture=null,this._initializeWebGL()}[createjs.SpriteContainer,createjs.Sprite,createjs.BitmapText,createjs.Bitmap,createjs.DOMElement].forEach(function(a,b){a.prototype._spritestage_compatibility=b+1});var b=createjs.extend(a,createjs.Stage);a.NUM_VERTEX_PROPERTIES=5,a.POINTS_PER_BOX=4,a.NUM_VERTEX_PROPERTIES_PER_BOX=a.POINTS_PER_BOX*a.NUM_VERTEX_PROPERTIES,a.INDICES_PER_BOX=6,a.MAX_INDEX_SIZE=Math.pow(2,16),a.MAX_BOXES_POINTS_INCREMENT=a.MAX_INDEX_SIZE/4,b._get_isWebGL=function(){return!!this._webGLContext};try{Object.defineProperties(b,{isWebGL:{get:b._get_isWebGL}})}catch(a){}b.addChild=function(a){return null==a?a:arguments.length>1?this.addChildAt.apply(this,Array.prototype.slice.call(arguments).concat([this.children.length])):this.addChildAt(a,this.children.length)},b.addChildAt=function(a,b){var c=arguments.length,d=arguments[c-1];if(d<0||d>this.children.length)return arguments[c-2];if(c>2){for(var e=0;e =1?!a.image&&!a.spriteSheet&&a._spritestage_compatibility<=4?(console&&console.log("Error: You can only add children that have an image or spriteSheet defined on them. ["+a.toString()+"]"),a):(a.parent&&a.parent.removeChild(a),a.parent=this,this.children.splice(b,0,a),a):(console&&console.log("Error: You can only add children of type SpriteContainer, Sprite, Bitmap, BitmapText, or DOMElement. ["+a.toString()+"]"),a)},b.update=function(a){if(this.canvas){this.tickOnUpdate&&this.tick(a),this.dispatchEvent("drawstart"),this.autoClear&&this.clear();var b=this._setWebGLContext();b?this.draw(b,!1):(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 a=this._setWebGLContext();a?a.clear(a.COLOR_BUFFER_BIT):(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.draw=function(a,b){return"undefined"!=typeof WebGLRenderingContext&&(a===this._webGLContext||a instanceof WebGLRenderingContext)?(this._drawWebGLKids(this.children,a),!0):this.Stage_draw(a,b)},b.updateViewport=function(a,b){this._viewportWidth=a,this._viewportHeight=b,this._webGLContext&&(this._webGLContext.viewport(0,0,this._viewportWidth,this._viewportHeight),this._projectionMatrix||(this._projectionMatrix=new Float32Array([0,0,0,0,0,1,-1,1,1])),this._projectionMatrix[0]=2/a,this._projectionMatrix[4]=-2/b)},b.clearImageTexture=function(a){a.__easeljs_texture=null},b.toString=function(){return"[SpriteStage (name="+this.name+")]"},b._initializeWebGL=function(){this._clearColor={r:0,g:0,b:0,a:0},this._setWebGLContext()},b._setWebGLContext=function(){return this.canvas?this._webGLContext&&this._webGLContext.canvas===this.canvas||this._initializeWebGLContext():this._webGLContext=null,this._webGLContext},b._initializeWebGLContext=function(){var a={depth:!1,alpha:!0,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias,premultipliedAlpha:!0},b=this._webGLContext=this.canvas.getContext("webgl",a)||this.canvas.getContext("experimental-webgl",a);if(b){if(this._maxTexturesPerDraw=1,this._setClearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearColor.a),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,!1),this._createShaderProgram(b),this._webGLErrorDetected)return void(this._webGLContext=null);this._createBuffers(b),this.updateViewport(this._viewportWidth||this.canvas.width||0,this._viewportHeight||this.canvas.height||0)}},b._setClearColor=function(a,b,c,d){this._clearColor.r=a,this._clearColor.g=b,this._clearColor.b=c,this._clearColor.a=d,this._webGLContext&&this._webGLContext.clearColor(a,b,c,d)},b._createShaderProgram=function(a){var b=this._createShader(a,a.FRAGMENT_SHADER,"precision mediump float;uniform sampler2D uSampler0;varying vec3 vTextureCoord;void main(void) {vec4 color = texture2D(uSampler0, vTextureCoord.st);gl_FragColor = vec4(color.rgb, color.a * vTextureCoord.z);}"),c=this._createShader(a,a.VERTEX_SHADER,"attribute vec2 aVertexPosition;attribute vec3 aTextureCoord;uniform mat3 uPMatrix;varying vec3 vTextureCoord;void main(void) {vTextureCoord = aTextureCoord;gl_Position = vec4((uPMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);}");if(!this._webGLErrorDetected&&b&&c){var d=a.createProgram();if(a.attachShader(d,b),a.attachShader(d,c),a.linkProgram(d),!a.getProgramParameter(d,a.LINK_STATUS))return void(this._webGLErrorDetected=!0);d.vertexPositionAttribute=a.getAttribLocation(d,"aVertexPosition"),d.textureCoordAttribute=a.getAttribLocation(d,"aTextureCoord"),d.sampler0uniform=a.getUniformLocation(d,"uSampler0"),a.enableVertexAttribArray(d.vertexPositionAttribute),a.enableVertexAttribArray(d.textureCoordAttribute),d.pMatrixUniform=a.getUniformLocation(d,"uPMatrix"),a.useProgram(d),this._shaderProgram=d}},b._createShader=function(a,b,c){var d=a.createShader(b);return a.shaderSource(d,c),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:(this._webGLErrorDetected=!0,null)},b._createBuffers=function(b){this._verticesBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._verticesBuffer);var c=4*a.NUM_VERTEX_PROPERTIES;b.vertexAttribPointer(this._shaderProgram.vertexPositionAttribute,2,b.FLOAT,b.FALSE,c,0),b.vertexAttribPointer(this._shaderProgram.textureCoordAttribute,3,b.FLOAT,b.FALSE,c,8),this._indicesBuffer=b.createBuffer(),this._setMaxBoxesPoints(b,a.MAX_BOXES_POINTS_INCREMENT)},b._setMaxBoxesPoints=function(b,c){this._maxBoxesPointsPerDraw=c,this._maxBoxesPerDraw=this._maxBoxesPointsPerDraw/a.POINTS_PER_BOX|0,this._maxIndicesPerDraw=this._maxBoxesPerDraw*a.INDICES_PER_BOX,b.bindBuffer(b.ARRAY_BUFFER,this._verticesBuffer),this._vertices=new Float32Array(this._maxBoxesPerDraw*a.NUM_VERTEX_PROPERTIES_PER_BOX),b.bufferData(b.ARRAY_BUFFER,this._vertices,b.DYNAMIC_DRAW),this._indices=new Uint16Array(this._maxIndicesPerDraw);for(var d=0,e=this._indices.length;d =2)){var c=b.__easeljs_texture;return c||(c=b.__easeljs_texture=a.createTexture(),a.bindTexture(a.TEXTURE_2D,c),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,b),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),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)),c}},b._drawWebGLKids=function(b,c,d){for(var e,f,g=this.snapToPixelEnabled,h=null,i=0,j=0,k=0,l=0,m=this._vertices,n=a.NUM_VERTEX_PROPERTIES_PER_BOX,o=a.MAX_INDEX_SIZE,p=this._maxBoxesPerDraw-1,q=0,r=b.length;q lt {{#crossLink "Graphics/lineTo"}}{{/crossLink}} *- * a/at {{#crossLink "Graphics/arc"}}{{/crossLink}} / {{#crossLink "Graphics/arcTo"}}{{/crossLink}} *bt {{#crossLink "Graphics/bezierCurveTo"}}{{/crossLink}} qt {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}} (also curveTo) + *- * ea {{#crossLink "Graphics/ellipticalArc"}}{{/crossLink}} *r {{#crossLink "Graphics/rect"}}{{/crossLink}} cp {{#crossLink "Graphics/closePath"}}{{/crossLink}} + *- * qt {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}} (also curveTo) *c {{#crossLink "Graphics/clear"}}{{/crossLink}} f {{#crossLink "Graphics/beginFill"}}{{/crossLink}} + *- * cp {{#crossLink "Graphics/closePath"}}{{/crossLink}} *lf {{#crossLink "Graphics/beginLinearGradientFill"}}{{/crossLink}} rf {{#crossLink "Graphics/beginRadialGradientFill"}}{{/crossLink}} + *- * f {{#crossLink "Graphics/beginFill"}}{{/crossLink}} *bf {{#crossLink "Graphics/beginBitmapFill"}}{{/crossLink}} ef {{#crossLink "Graphics/endFill"}}{{/crossLink}} + *- * rf {{#crossLink "Graphics/beginRadialGradientFill"}}{{/crossLink}} *ss / sd {{#crossLink "Graphics/setStrokeStyle"}}{{/crossLink}} / {{#crossLink "Graphics/setStrokeDash"}}{{/crossLink}} s {{#crossLink "Graphics/beginStroke"}}{{/crossLink}} + *- * ef {{#crossLink "Graphics/endFill"}}{{/crossLink}} *ls {{#crossLink "Graphics/beginLinearGradientStroke"}}{{/crossLink}} rs {{#crossLink "Graphics/beginRadialGradientStroke"}}{{/crossLink}} + *- * s {{#crossLink "Graphics/beginStroke"}}{{/crossLink}} *bs {{#crossLink "Graphics/beginBitmapStroke"}}{{/crossLink}} es {{#crossLink "Graphics/endStroke"}}{{/crossLink}} + *- * rs {{#crossLink "Graphics/beginRadialGradientStroke"}}{{/crossLink}} *dr {{#crossLink "Graphics/drawRect"}}{{/crossLink}} rr {{#crossLink "Graphics/drawRoundRect"}}{{/crossLink}} + *- * es {{#crossLink "Graphics/endStroke"}}{{/crossLink}} *rc {{#crossLink "Graphics/drawRoundRectComplex"}}{{/crossLink}} dc {{#crossLink "Graphics/drawCircle"}}{{/crossLink}} + *- * rr {{#crossLink "Graphics/drawRoundRect"}}{{/crossLink}} *de {{#crossLink "Graphics/drawEllipse"}}{{/crossLink}} dp {{#crossLink "Graphics/drawPolyStar"}}{{/crossLink}} + *+ * dc {{#crossLink "Graphics/drawCircle"}}{{/crossLink}} *p {{#crossLink "Graphics/decodePath"}}{{/crossLink}} * * * Here is the above example, using the tiny API instead. @@ -533,6 +534,27 @@ this.createjs = this.createjs||{}; return this.append(new G.Arc(x, y, radius, startAngle, endAngle, anticlockwise)); }; + /** + * Draws an elliptical arc defined by the radii rx and ry, startAngle and endAngle arguments, centered at the position (x, y). + * + * A tiny API method "ea" also exists. + * @method ellipticalArc + * @param {Number} x center X + * @param {Number} y center Y + * @param {Number} rx horizontal radius + * @param {Number} ry vertical radius + * @param {Number} startAngle Measured in radians. + * @param {Number} endAngle Measured in radians. + * @param {Boolean} anticlockwise if true, clockwise if false + * @param {String} closure omit for no closure (just an arc), 'radii' (makes a sector), 'chord' (makes a segment) + * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.) + * @chainable + **/ + p.ellipticalArc = function(x, y, rx, ry, startAngle, endAngle, anticlockwise, closure) { + return this.append(new G.EllipticalArc(x, y, rx, ry, startAngle, endAngle, anticlockwise, closure)); + } + + /** * Draws a quadratic curve from the current drawing point to (x, y) using the control point (cpx, cpy). For detailed * information, read the @@ -1259,6 +1281,23 @@ this.createjs = this.createjs||{}; **/ p.a = p.arc; + /** + * Shortcut to ellipticalArc. + * @method ea + * @param {Number} x + * @param {Number} y + * @param {Number} rx + * @param {Number} ry + * @param {Number} startAngle Measured in radians. + * @param {Number} endAngle Measured in radians. + * @param {Boolean} anticlockwise + * @param {String} closure omit for no closure (just an arc), 'radii' (makes a sector), 'chord' (makes a segment) + * @return {Graphics} The Graphics instance the method is called on (useful for chaining calls.) + * @protected + * @chainable + **/ + p.ea = p.ellipticalArc; + /** * Shortcut to rect. * @method r @@ -1769,6 +1808,300 @@ this.createjs = this.createjs||{}; this.anticlockwise = !!anticlockwise; }).prototype.exec = function(ctx) { ctx.arc(this.x, this.y, this.radius, this.startAngle, this.endAngle, this.anticlockwise); }; + /** + * Graphics command object. See {{#crossLink "Graphics"}}{{/crossLink}} and {{#crossLink "Graphics/append"}}{{/crossLink}} for more information. + * @class EllipticalArc + * @constructor + * @param {Number} x + * @param {Number} y + * @param {Number} rx + * @param {Number} ry + * @param {Number} startAngle + * @param {Number} endAngle + * @param {Boolean} anticlockwise + * @param {String} closure + **/ + /** + * @property x + * @type Number + */ + /** + * @property y + * @type Number + */ + /** + * @property rx + * @type Number + */ + /** + * @property ry + * @Type Number + /** + * @property startAngle + * @type Number + */ + /** + * @property endAngle + * @type Number + */ + /** + * @property anticlockwise + * @type Boolean + */ + /** + * @property closure + * @type String + */ + (G.EllipticalArc = function(x, y, rx, ry, startAngle, endAngle, anticlockwise, closure) { + this.x = x; + this.y = y; + this.rx = rx; + this.ry = ry; + this.anticlockwise = !!anticlockwise; + this.closure = closure; + + // Map negative angles into positive range + if (startAngle < 0 || endAngle < 0) { + if (startAngle < -2 * Math.PI) { + var s = startAngle / (2 * Math.PI); + startAngle = (s + Math.floor(Math.abs(s))) * 2 * Math.PI + 2 * Math.PI; + } + else if (startAngle < 0) { + startAngle += 2 * Math.PI; + } + + if (endAngle < -2 * Math.PI) { + var e = endAngle / (2 * Math.PI); + endAngle = (e + Math.floor(Math.abs(e))) * 2 * Math.PI + 2 * Math.PI; + } + else if (endAngle < 0) { + endAngle += 2 * Math.PI; + } + } + + // Normalize the angles + if (startAngle < endAngle || equalEnough(startAngle, endAngle)) { + if (this.anticlockwise === false || equalEnough(startAngle, endAngle)) { + this.start = -endAngle; + this.end = -startAngle - 2 * Math.PI; + } + else { + this.start = -startAngle; + this.end = -endAngle; + } + } + else { + if (this.anticlockwise === true) { + this.start = -startAngle; + this.end = -endAngle - 2 * Math.PI; + } + else { + this.start = -endAngle; + this.end = -startAngle; + } + } + }).prototype.exec = function(ctx) { + // x, y - top left + // xe, ye - bottom right + // xm, ym - center + var rx = this.rx; + var ry = this.ry; + var start = this.start; + var end = this.end; + var xm = this.x; + var ym = this.y; + var closure = this.closure; + + var quadrantStart = Math.floor(2 * Math.abs(start) / Math.PI); + + // How long is the arc + var span = Math.abs(end); + + // Array of intermediate angles for + // breaking up the arc into segments <= PI/2 + var ia = [0]; + + for (var i = 1; i <= 4; i++) { + ia[i - 1] = (quadrantStart + i) * Math.PI / 2; + } + + var startPoint; + var chordMidX; + var chordMidY; + + if (closure === 'radii') { + ctx.moveTo(xm, ym); + } + else if (closure === 'chord') { + var startEA = eccentricAnomalyFromPolarAngle(start, rx, ry); + var endEA = eccentricAnomalyFromPolarAngle(end, rx, ry); + + chordMidX = xm + rx * (Math.cos(startEA) + Math.cos(endEA)) / 2; + chordMidY = ym + ry * (Math.sin(startEA) + Math.sin(endEA)) / 2; + + ctx.moveTo(chordMidX, chordMidY); + } + + if (span <= ia[0]) // 1 segment + { + startPoint = elarcseg(ctx, xm, ym, rx, ry, start, end, closure); + } + else if (span <= ia[1]) // 2 segments + { + startPoint = elarcseg(ctx, xm, ym, rx, ry, start, -ia[0], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[0], end, closure); + } + else if (span <= ia[2]) // 3 segments + { + startPoint = elarcseg(ctx, xm, ym, rx, ry, start, -ia[0], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[0], -ia[1], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[1], end, closure); + } + else if (span <= ia[3]) // 4 segments + { + startPoint = elarcseg(ctx, xm, ym, rx, ry, start, -ia[0], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[0], -ia[1], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[1], -ia[2], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[2], end, closure); + } + else // 5 segments + { + startPoint = elarcseg(ctx, xm, ym, rx, ry, start, -ia[0], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[0], -ia[1], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[1], -ia[2], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[2], -ia[3], closure); + elarcseg(ctx, xm, ym, rx, ry, -ia[3], end, closure); + } + + if (closure === 'radii') { + ctx.lineTo(xm, ym); + ctx.closePath(); + } + else if (closure === 'chord') { + ctx.lineTo(chordMidX, chordMidY); + + ctx.closePath(); + } + }; + + /** + * Begin support functions for elliptical arc + **/ + + // Elliptical arc segment + function elarcseg(ctx, xm, ym, rx, ry, start, end, closure) { + var startEA = eccentricAnomalyFromPolarAngle(start, rx, ry); + var endEA = eccentricAnomalyFromPolarAngle(end, rx, ry); + + // From parametric equation by L. Maisonobe + var k = -Math.sin(endEA - startEA) * (Math.sqrt(4 + 3 * Math.pow(Math.tan((endEA - startEA) / 2), 2)) - 1) / 3; + + // Starting point of the curve + var r1 = rx * ry / Math.sqrt(Math.pow(ry * Math.cos(start), 2) + Math.pow(rx * Math.sin(start), 2)); + var x1 = xm + r1 * Math.cos(start); + var y1 = ym + r1 * Math.sin(start); + + // End point of the curve + var r2 = rx * ry / Math.sqrt(Math.pow(ry * Math.cos(end), 2) + Math.pow(rx * Math.sin(end), 2)); + var x2 = xm + r2 * Math.cos(end); + var y2 = ym + r2 * Math.sin(end); + + // Control point 1 + var x3 = x1 - k * Math.sin(-startEA) * rx; + var y3 = y1 - k * Math.cos(-startEA) * ry; + + // Control point 2 + var x4 = x2 + k * Math.sin(-endEA) * rx; + var y4 = y2 + k * Math.cos(-endEA) * ry; + + if (closure === 'radii' || closure === 'chord') { + ctx.lineTo(x1, y1); + } + else { + ctx.moveTo(x1, y1); + } + + ctx.bezierCurveTo(x3, y3, x4, y4, x2, y2); + + var startPoint = { x: x1, y: y1 }; + + return startPoint; + } + + // Maps from polar angle into the angle used in ellipse + // parametric equations (this angle is called "eccentricAnomaly") + // it is the same as polar angle when the ellipse is a circle + // E = atan((rx/ry)*tan(A)) + // where A is the polar angle and E is the eccentricAnomaly angle + function eccentricAnomalyFromPolarAngle(angle, rx, ry) { + var retval; + + var cosa = Math.cos(angle); + var sina = Math.sin(angle); + + // circle or near extremeties -- polar angle and + // eccentricAnomaly are the same + if (equalEnough(rx, ry) || equalEnough(Math.abs(cosa), 0) || equalEnough(Math.abs(sina), 0)) { + return angle; + } + + var tana = rx * Math.tan(angle) / ry; + + // branches of arctan function + if (cosa > 0 && sina > 0) { + retval = Math.atan(tana); + } + else if (cosa < 0 && sina > 0) { + retval = Math.PI + Math.atan(tana); + } + else if (cosa < 0 && sina < 0) { + retval = Math.PI + Math.atan(tana); + } + else if (cosa > 0 && sina < 0) { + retval = 2 * Math.PI + Math.atan(tana); + } + + return retval; + } + + // This is just a copy of mathjs.equal, or rather mathjs.nearlyEqual + // For some reason can't use mathjs here + // But, perhaps this is better as it is self-contained and won't introduce a dependency in EaselJS on mathjs + // and also, the mathjs version is too stingy on its epsilon + function equalEnough(x, y) { + var relEpsilon = 0.001; + var absEpsilon = 2.2204460492503130808472633361816E-16; + + if (x === y) { + return true; + } + + // NaN + if (isNaN(x) || isNaN(y)) { + return false; + } + + // at this point x and y should be finite + if (isFinite(x) && isFinite(y)) { + // check numbers are very close, needed when comparing numbers near zero + var diff = Math.abs(x - y); + if (diff < absEpsilon) { + return true; + } + else { + // use relative error + return diff <= Math.max(Math.abs(x), Math.abs(y)) * relEpsilon; + } + } + + // Infinite and Number or negative Infinite and positive Infinite cases + return false; + } + + /** + * End support functions for elliptical arc + **/ + /** * Graphics command object. See {{#crossLink "Graphics/quadraticCurveTo"}}{{/crossLink}} and {{#crossLink "Graphics/append"}}{{/crossLink}} for more information. * @class QuadraticCurveTo diff --git a/tests/spec/GraphicsSpec.js b/tests/spec/GraphicsSpec.js index dd299c2cf..25de98fbd 100644 --- a/tests/spec/GraphicsSpec.js +++ b/tests/spec/GraphicsSpec.js @@ -323,5 +323,9 @@ describe("Graphics", function () { it('decodePath should equal p', function () { expect(this.g['decodePath']).toBe(this.g['p']); }); + + it ('ellipticalArc should equal ea', function () { + expect(this.g['ellipticalArc']).toBe(this.g['ea']); + }); }); }); dp {{#crossLink "Graphics/drawPolyStar"}}{{/crossLink}}